@arcgis/core 4.24.0-next.20220329 → 4.24.0-next.20220401

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (456) hide show
  1. package/PopupTemplate.js +1 -1
  2. package/WebMap.js +1 -1
  3. package/WebScene.js +1 -1
  4. package/analysis/LineOfSightAnalysisObserver.js +1 -1
  5. package/analysis/LineOfSightAnalysisTarget.js +1 -1
  6. package/arcade/featureset/actions/Adapted.js +1 -1
  7. package/arcade/featureset/sources/FeatureLayerDynamic.js +1 -1
  8. package/arcade/featureset/sources/FeatureLayerMemory.js +1 -1
  9. package/arcade/featureset/sources/FeatureLayerRelated.js +1 -1
  10. package/arcade/featureset/support/FeatureSet.js +1 -1
  11. package/arcade/featureset/support/RecentlyUsedCache.js +1 -1
  12. package/arcade/featureset/support/shared.js +1 -1
  13. package/arcade/functions/convertdirection.js +1 -1
  14. package/arcade/lib/character.js +1 -1
  15. package/arcade/lib/scanner.js +1 -1
  16. package/arcade/lib/tokenizer.js +1 -1
  17. package/arcade/request.js +1 -1
  18. package/arcade/treeAnalysis.js +1 -1
  19. package/assets/esri/core/workers/RemoteClient.js +1 -1
  20. package/assets/esri/core/workers/chunks/0bfedb1dbdff8205e468.js +1 -0
  21. package/assets/esri/core/workers/chunks/{5e472c89a38d6a42b84d.js → 0e29250c24a3a7b1ce13.js} +1 -1
  22. package/assets/esri/core/workers/chunks/0eb9c9477d36cd212f8b.js +1 -0
  23. package/assets/esri/core/workers/chunks/10779a256841c37f2429.js +1 -0
  24. package/assets/esri/core/workers/chunks/10a119889d1ab13402a3.js +1 -0
  25. package/assets/esri/core/workers/chunks/125b14c2ccd96d7c20c2.js +1 -0
  26. package/assets/esri/core/workers/chunks/23ec33a30db201e8b2c3.js +1 -0
  27. package/assets/esri/core/workers/chunks/2530e8ccf6e12787ce76.js +1 -0
  28. package/assets/esri/core/workers/chunks/2d9e97ba5b50aec4dd01.js +1 -0
  29. package/assets/esri/core/workers/chunks/365dc146398420f13f82.js +1 -0
  30. package/assets/esri/core/workers/chunks/3ae2827e8d55d6713d20.js +1 -0
  31. package/assets/esri/core/workers/chunks/3e3eebaa0844742db2f2.js +1 -0
  32. package/assets/esri/core/workers/chunks/3fd5b2d6eccd9098d492.js +1 -0
  33. package/assets/esri/core/workers/chunks/404f1d7bce014c7e6965.js +1 -0
  34. package/assets/esri/core/workers/chunks/411b7777bb5e943c156f.js +1 -0
  35. package/assets/esri/core/workers/chunks/{12ca192a5233bb2875d0.js → 4312902ab6e42fbe119b.js} +1 -1
  36. package/assets/esri/core/workers/chunks/{4ef07f50da39f8607c1c.js → 44e95e87bd9e820aeb53.js} +1 -1
  37. package/assets/esri/core/workers/chunks/{4d4c5e535d8b9ceb865a.js → 4810edf605838d07e5c5.js} +1 -1
  38. package/assets/esri/core/workers/chunks/4bce446391176a9d4588.js +1 -0
  39. package/assets/esri/core/workers/chunks/52a0e387073ea264e194.js +1 -0
  40. package/assets/esri/core/workers/chunks/560234694f3e53802aff.js +1 -0
  41. package/assets/esri/core/workers/chunks/5633710daeb3bbb79bcf.js +1 -0
  42. package/assets/esri/core/workers/chunks/5682039666f874836451.js +1 -0
  43. package/assets/esri/core/workers/chunks/6f01905936396fe87865.js +1 -0
  44. package/assets/esri/core/workers/chunks/6f7917da7166e8c6854b.js +1 -0
  45. package/assets/esri/core/workers/chunks/7388824eac8da01ea03d.js +1 -0
  46. package/assets/esri/core/workers/chunks/7745efef7d5119d0b087.js +1 -0
  47. package/assets/esri/core/workers/chunks/794b47764ebb0257ed41.js +1 -0
  48. package/assets/esri/core/workers/chunks/{da64dedf9270b64f42b2.js → 79bdb26244ec7b4472fe.js} +1 -1
  49. package/assets/esri/core/workers/chunks/79ec28b3e3c57fe026aa.js +1 -0
  50. package/assets/esri/core/workers/chunks/81e9d860a044acec74ce.js +1 -0
  51. package/assets/esri/core/workers/chunks/831dc0187f71e658550c.js +1 -0
  52. package/assets/esri/core/workers/chunks/86ad6b020c01850d9095.js +1 -0
  53. package/assets/esri/core/workers/chunks/{fb7397da8d4ec2ae4587.js → 87458fbf395338511662.js} +1 -1
  54. package/assets/esri/core/workers/chunks/{1a859be598ad96bb4719.js → 8771296b537f366596c4.js} +18 -18
  55. package/assets/esri/core/workers/chunks/8958cd555f4887526e8b.js +1 -0
  56. package/assets/esri/core/workers/chunks/{e57b71ba70f088a3a052.js → 90dcd86cdef90099abfa.js} +1 -1
  57. package/assets/esri/core/workers/chunks/93067e27eea5844edc6c.js +1 -0
  58. package/assets/esri/core/workers/chunks/{9fbee2d9bf50c4c148c6.js → 9a146c9e9b4bf7fba88f.js} +1 -1
  59. package/assets/esri/core/workers/chunks/9b9821772b6cbe189fe0.js +1 -0
  60. package/assets/esri/core/workers/chunks/{6c4ce530b493c6f7c430.js → 9df2f9f7c28b31866be8.js} +1 -1
  61. package/assets/esri/core/workers/chunks/{d0620ce99b620621d8bc.js → a0552044e123a3c51ddf.js} +1 -1
  62. package/assets/esri/core/workers/chunks/acc1a4acd57f5657e782.js +1 -0
  63. package/assets/esri/core/workers/chunks/b055ae7c54796751b64c.js +1 -0
  64. package/assets/esri/core/workers/chunks/{acc2cfb116fee7f82ae9.js → b26bd8fde2fc65bb67fb.js} +1 -1
  65. package/assets/esri/core/workers/chunks/{9b45b94c4dbdc8d2c5fd.js → b34ba22c7a5adce8a7a2.js} +1 -1
  66. package/assets/esri/core/workers/chunks/b75665d0bf417c6ef24a.js +1 -0
  67. package/assets/esri/core/workers/chunks/bd50ec30688463b821d1.js +1 -0
  68. package/assets/esri/core/workers/chunks/c28f7ae4756ad1ba94bd.js +1 -0
  69. package/assets/esri/core/workers/chunks/c4f713959d4115b87c6c.js +1 -0
  70. package/assets/esri/core/workers/chunks/c58aa209492bd94b7aad.js +1 -0
  71. package/assets/esri/core/workers/chunks/{9b117097b7be0efd21d4.js → c59b0b58e24e6a60cf3e.js} +1 -1
  72. package/assets/esri/core/workers/chunks/c7bd5a4d318299388645.js +1 -0
  73. package/assets/esri/core/workers/chunks/c7cee13a962396b23a5e.js +1 -0
  74. package/assets/esri/core/workers/chunks/{3bbff5ea1ea0e955c592.js → cd3679fa86129ebabfdf.js} +1 -1
  75. package/assets/esri/core/workers/chunks/{1a36dc0daffd536ea44d.js → cee7ce362860717713bf.js} +1 -1
  76. package/assets/esri/core/workers/chunks/cf463d6309f14df2f2fa.js +1 -0
  77. package/assets/esri/core/workers/chunks/{224c0e64160bdc170051.js → d076627bb7dadea89e89.js} +1 -1
  78. package/assets/esri/core/workers/chunks/{fff4200bc61b82dd6193.js → d1d1c45243af614f2e74.js} +1 -1
  79. package/assets/esri/core/workers/chunks/{1e0498dc9836658d9aba.js → d5fd12ea541c1a6b7fce.js} +1 -1
  80. package/assets/esri/core/workers/chunks/{10322d990cda5aedf2f0.js → d6e32ca237ad9309c76a.js} +1 -1
  81. package/assets/esri/core/workers/chunks/e06ad3a3d71154fed654.js +1 -0
  82. package/assets/esri/core/workers/chunks/{7a77d4cd27c30f1a5cae.js → ee3387a43dfbb3df23e1.js} +1 -1
  83. package/assets/esri/core/workers/chunks/{5d5fa2b1fc48a17eb9ab.js → f4fc165420d449e442b8.js} +1 -1
  84. package/assets/esri/core/workers/chunks/{3d6d9906a534ddd8fa37.js → f5ee03f3fca7a75192de.js} +1 -1
  85. package/assets/esri/themes/base/widgets/_Daylight.scss +1 -1
  86. package/assets/esri/themes/base/widgets/_ElevationProfile.scss +1 -1
  87. package/assets/esri/themes/base/widgets/_Weather.scss +1 -1
  88. package/assets/esri/themes/base/widgets/_Widget.scss +12 -0
  89. package/assets/esri/themes/dark/main.css +1 -1
  90. package/assets/esri/themes/dark-blue/main.css +1 -1
  91. package/assets/esri/themes/dark-green/main.css +1 -1
  92. package/assets/esri/themes/dark-purple/main.css +1 -1
  93. package/assets/esri/themes/dark-red/main.css +1 -1
  94. package/assets/esri/themes/light/main.css +1 -1
  95. package/assets/esri/themes/light/view.css +1 -1
  96. package/assets/esri/themes/light-blue/main.css +1 -1
  97. package/assets/esri/themes/light-green/main.css +1 -1
  98. package/assets/esri/themes/light-purple/main.css +1 -1
  99. package/assets/esri/themes/light-red/main.css +1 -1
  100. package/chunks/ComponentShader.glsl.js +25 -25
  101. package/chunks/HighlightApply.glsl.js +36 -0
  102. package/chunks/HighlightBlur.glsl.js +26 -0
  103. package/chunks/HighlightDownsample.glsl.js +12 -0
  104. package/chunks/ImageMaterial.glsl.js +8 -8
  105. package/chunks/LineCallout.glsl.js +1 -1
  106. package/chunks/Pattern.glsl.js +2 -2
  107. package/chunks/SimpleAtmosphere.glsl.js +7 -7
  108. package/chunks/Stars.glsl.js +1 -1
  109. package/chunks/arcade.js +1 -1
  110. package/chunks/color.js +1 -1
  111. package/chunks/languageUtils.js +1 -1
  112. package/chunks/mat3.js +1 -1
  113. package/copyright.txt +2 -2
  114. package/core/AsyncUpdate.js +1 -1
  115. package/core/Evented.js +1 -1
  116. package/core/PooledArray.js +1 -1
  117. package/core/accessorSupport/diffUtils.js +1 -1
  118. package/core/accessorSupport/get.js +1 -1
  119. package/core/accessorSupport/read.js +1 -1
  120. package/core/accessorSupport/set.js +1 -1
  121. package/core/accessorSupport/tracking.js +1 -1
  122. package/core/accessorSupport/utils.js +1 -1
  123. package/core/arrayUtils.js +1 -1
  124. package/core/libs/gl-matrix-2/mat3.js +1 -1
  125. package/core/libs/gl-matrix-2/math/mat3.js +1 -1
  126. package/core/number.js +1 -1
  127. package/core/object.js +1 -1
  128. package/core/string.js +1 -1
  129. package/core/unitUtils.js +1 -1
  130. package/core/watchUtils.js +1 -1
  131. package/core/workers/RemoteClient.js +1 -1
  132. package/exports/csv.js +1 -1
  133. package/geometry/support/heightModelInfoUtils.js +1 -1
  134. package/geometry/support/meshUtils/exporters/gltf/geometry.js +1 -1
  135. package/geometry/support/normalizeUtils.js +1 -1
  136. package/identity/IdentityManagerBase.js +1 -1
  137. package/interfaces.d.ts +155 -20
  138. package/layers/ImageryLayer.js +1 -1
  139. package/layers/MapImageLayer.js +1 -1
  140. package/layers/RouteLayer.js +1 -1
  141. package/layers/SceneLayer.js +1 -1
  142. package/layers/SubtypeGroupLayer.js +1 -1
  143. package/layers/TileLayer.js +1 -1
  144. package/layers/VectorTileLayer.js +1 -1
  145. package/layers/WMSLayer.js +1 -1
  146. package/layers/WMTSLayer.js +1 -1
  147. package/layers/WebTileLayer.js +1 -1
  148. package/layers/graphics/data/AttributesBuilder.js +1 -1
  149. package/layers/graphics/data/QueryEngine.js +1 -1
  150. package/layers/graphics/editingSupport.js +1 -1
  151. package/layers/graphics/sources/connections/GeoEventConnection.js +1 -1
  152. package/layers/graphics/sources/support/MemorySourceWorker.js +1 -1
  153. package/layers/graphics/sources/support/inferenceUtils.js +1 -1
  154. package/layers/mixins/ArcGISCachedService.js +1 -1
  155. package/layers/mixins/ArcGISImageService.js +1 -1
  156. package/layers/ogc/ogcFeatureUtils.js +1 -1
  157. package/layers/support/ExportImageServiceParameters.js +1 -1
  158. package/layers/support/PixelBlock.js +1 -1
  159. package/layers/support/RasterJobHandler.js +1 -1
  160. package/layers/support/SpriteSource.js +1 -1
  161. package/layers/support/Sublayer.js +1 -1
  162. package/layers/support/TilemapCache.js +1 -1
  163. package/layers/support/WMTSSublayer.js +1 -1
  164. package/layers/support/arcgisLayerUrl.js +1 -1
  165. package/layers/support/fieldUtils.js +1 -1
  166. package/layers/support/kmlUtils.js +1 -1
  167. package/layers/support/layerUtils.js +1 -1
  168. package/layers/support/rasterDatasets/ImageAuxRaster.js +1 -1
  169. package/layers/support/rasterDatasets/ImageServerRaster.js +1 -1
  170. package/layers/support/rasterDatasets/RasterFactory.js +1 -1
  171. package/layers/support/rasterDatasets/WCSRaster.js +1 -1
  172. package/layers/support/rasterDatasets/multipartParser.js +1 -1
  173. package/layers/support/rasterDatasets/wcsCoverageParser.js +1 -1
  174. package/layers/support/rasterDatasets/xmlUtilities.js +1 -1
  175. package/layers/support/rasterFormats/RasterCodec.js +1 -1
  176. package/layers/support/rasterFormats/TiffDecoder.js +1 -1
  177. package/layers/support/rasterFunctions/pixelUtils.js +1 -1
  178. package/layers/support/vectorTileLayerLoader.js +1 -1
  179. package/layers/support/wmsUtils.js +1 -1
  180. package/layers/support/wmtsUtils.js +1 -1
  181. package/libs/i3s/I3SModule.js +1 -1
  182. package/libs/vxl/VxlModule.js +1 -1
  183. package/package.json +1 -1
  184. package/portal/Portal.js +1 -1
  185. package/portal/PortalItem.js +1 -1
  186. package/portal/schemas/definitions.js +1 -1
  187. package/portal/support/layersLoader.js +1 -1
  188. package/portal/support/portalItemUtils.js +1 -1
  189. package/portal/support/portalLayers.js +1 -1
  190. package/renderers/support/AuthoringInfoVisualVariable.js +1 -1
  191. package/renderers/support/DictionaryLoader.js +1 -1
  192. package/renderers/support/RasterSymbolizer.js +1 -1
  193. package/renderers/support/numberUtils.js +1 -1
  194. package/renderers/support/rasterRendererHelper.js +1 -1
  195. package/renderers/support/utils.js +1 -1
  196. package/request.js +1 -1
  197. package/rest/imageService.js +1 -1
  198. package/rest/operations/find.js +1 -1
  199. package/rest/query/operations/query.js +1 -1
  200. package/rest/query/operations/queryRelatedRecords.js +1 -1
  201. package/rest/query/operations/queryTopFeatures.js +1 -1
  202. package/rest/support/DirectionLine.js +1 -1
  203. package/rest/support/DirectionPoint.js +1 -1
  204. package/rest/support/PointBarrier.js +1 -1
  205. package/rest/support/PolygonBarrier.js +1 -1
  206. package/rest/support/PolylineBarrier.js +1 -1
  207. package/rest/support/RouteInfo.js +1 -1
  208. package/rest/support/Stop.js +1 -1
  209. package/smartMapping/labels/clusters.js +1 -1
  210. package/smartMapping/popup/dotDensity.js +1 -1
  211. package/smartMapping/popup/support/clusterUtils.js +1 -1
  212. package/smartMapping/popup/support/utils.js +1 -1
  213. package/smartMapping/raster/support/utils.js +1 -1
  214. package/smartMapping/renderers/color.js +1 -1
  215. package/smartMapping/renderers/location.js +1 -1
  216. package/smartMapping/renderers/predominance.js +1 -1
  217. package/smartMapping/renderers/relationship.js +1 -1
  218. package/smartMapping/renderers/size.js +1 -1
  219. package/smartMapping/renderers/support/utils.js +1 -1
  220. package/smartMapping/renderers/type.js +1 -1
  221. package/smartMapping/renderers/univariateColorSize.js +1 -1
  222. package/smartMapping/statistics/summaryStatisticsForAge.js +1 -1
  223. package/smartMapping/statistics/support/ageUtils.js +1 -1
  224. package/smartMapping/statistics/support/utils.js +1 -1
  225. package/smartMapping/support/adapters/SceneLayerAdapter.js +1 -1
  226. package/smartMapping/support/adapters/support/utils.js +1 -1
  227. package/smartMapping/support/utils.js +1 -1
  228. package/smartMapping/symbology/support/Theme.js +1 -1
  229. package/smartMapping/symbology/support/colorRamps.js +1 -1
  230. package/smartMapping/symbology/support/symbologyUtils.js +1 -1
  231. package/smartMapping/symbology/support/utils.js +1 -1
  232. package/statistics/utils.js +1 -1
  233. package/support/basemapDefinitions.js +1 -1
  234. package/support/basemapUtils.js +1 -1
  235. package/support/elevationInfoUtils.js +1 -1
  236. package/support/popupUtils.js +1 -1
  237. package/support/revision.js +1 -1
  238. package/symbols/cim/CIMSymbolRasterizer.js +1 -1
  239. package/symbols/cim/cimAnalyzer.js +1 -1
  240. package/symbols/cim/utils.js +1 -1
  241. package/symbols/support/previewSymbol3D.js +1 -1
  242. package/symbols/support/renderUtils.js +1 -1
  243. package/symbols/support/symbolLayerUtils.js +1 -1
  244. package/views/2d/engine/Bitmap.js +1 -1
  245. package/views/2d/engine/flow/FlowDisplayObject.js +1 -1
  246. package/views/2d/engine/imagery/RasterBitmap.js +1 -1
  247. package/views/2d/engine/imagery/RasterVFDisplayObject.js +1 -1
  248. package/views/2d/engine/vectorTiles/TextShaping.js +1 -1
  249. package/views/2d/engine/vectorTiles/TileParser.js +1 -1
  250. package/views/2d/engine/vectorTiles/buckets/SymbolBucket.js +1 -1
  251. package/views/2d/engine/vectorTiles/expression/expression.js +1 -1
  252. package/views/2d/engine/vectorTiles/shaders/VTLMaterial.js +1 -1
  253. package/views/2d/engine/webgl/Profiler.js +1 -1
  254. package/views/2d/engine/webgl/Utils.js +1 -1
  255. package/views/2d/engine/webgl/brushes/WGLGeometryBrush.js +1 -1
  256. package/views/2d/engine/webgl/definitions.js +1 -1
  257. package/views/2d/engine/webgl/effects/HittestEffect.js +1 -1
  258. package/views/2d/engine/webgl/effects/HittestEffectVTL.js +1 -1
  259. package/views/2d/engine/webgl/mesh/templates/WGLTemplateStore.js +1 -1
  260. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  261. package/views/2d/engine/webgl/util/Lock.js +1 -1
  262. package/views/2d/layers/RouteLayerView2D.js +1 -1
  263. package/views/2d/layers/features/schemaUtils.js +1 -1
  264. package/views/2d/layers/features/sources/SnapshotFeatureSource.js +1 -1
  265. package/views/2d/layers/features/support/AttributeStore.js +1 -1
  266. package/views/2d/layers/features/support/FeatureSetReaderPBF.js +1 -1
  267. package/views/2d/layers/features/tileRenderers/SymbolTileRenderer.js +1 -1
  268. package/views/2d/layers/support/webStyleUtils.js +1 -1
  269. package/views/2d/support/Timeline.js +1 -1
  270. package/views/3d/analysis/LineOfSight/LineOfSightController.js +1 -1
  271. package/views/3d/analysis/LineOfSight/LineOfSightIntersectionResult.js +1 -1
  272. package/views/3d/analysis/LineOfSight/LineOfSightRayIntersector.js +1 -1
  273. package/views/3d/analysis/Slice/SliceController.js +1 -1
  274. package/views/3d/environment/PanoramicAtmosphere.js +1 -1
  275. package/views/3d/environment/SceneViewAtmosphere.js +1 -1
  276. package/views/3d/environment/StarsTechnique.js +1 -1
  277. package/views/3d/externalRenderers/ExternalRendererStore.js +1 -1
  278. package/views/3d/glTF/loader.js +1 -1
  279. package/views/3d/interactive/analysisTools/lineOfSight/LineOfSightTool.js +1 -1
  280. package/views/3d/interactive/analysisTools/slice/SliceTool.js +1 -1
  281. package/views/3d/layers/BuildingComponentSublayerView3D.js +1 -1
  282. package/views/3d/layers/FeatureLikeLayerView3D.js +1 -1
  283. package/views/3d/layers/I3SMeshView3D.js +1 -1
  284. package/views/3d/layers/ImageryLayerView3D.js +1 -1
  285. package/views/3d/layers/LayerView3D.js +1 -1
  286. package/views/3d/layers/PointCloudLayerView3D.js +1 -1
  287. package/views/3d/layers/RouteLayerView3D.js +1 -1
  288. package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
  289. package/views/3d/layers/VectorTileLayerView3D.js +1 -1
  290. package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
  291. package/views/3d/layers/i3s/I3SIndex.js +1 -1
  292. package/views/3d/layers/i3s/I3SMeshViewFilter.js +1 -1
  293. package/views/3d/layers/i3s/I3SNodeLoader.js +1 -1
  294. package/views/3d/layers/i3s/I3SUtil.js +1 -1
  295. package/views/3d/layers/i3s/IDBMockCache.js +5 -0
  296. package/views/3d/layers/i3s/PointCloudWorkerUtil.js +1 -1
  297. package/views/3d/layers/support/PopupSceneLayerView.js +1 -1
  298. package/views/3d/state/ViewStateManager.js +1 -1
  299. package/views/3d/state/controllers/RotateController.js +1 -1
  300. package/views/3d/state/controllers/global/PinchAndPanController.js +1 -1
  301. package/views/3d/state/controllers/global/ZoomController.js +1 -1
  302. package/views/3d/state/controllers/global/ZoomStepController.js +1 -1
  303. package/views/3d/state/controllers/local/PinchAndPanController.js +1 -1
  304. package/views/3d/state/controllers/local/ZoomController.js +1 -1
  305. package/views/3d/support/HighlightOptions.js +1 -1
  306. package/views/3d/support/buffer/InterleavedLayout.js +1 -1
  307. package/views/3d/support/debugFlags.js +1 -1
  308. package/views/3d/support/orientedBoundingBox.js +1 -1
  309. package/views/3d/terrain/TerrainSurface.js +1 -1
  310. package/views/3d/webgl-engine/Stage.js +1 -1
  311. package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
  312. package/views/3d/webgl-engine/collections/Component/DepthRange.js +1 -1
  313. package/views/3d/webgl-engine/core/shaderLibrary/ForwardLinearDepth.glsl.js +3 -3
  314. package/views/3d/webgl-engine/core/shaderLibrary/attributes/VertexPosition.glsl.js +5 -5
  315. package/views/3d/webgl-engine/core/shaderModules/ShaderBuilder.js +1 -1
  316. package/views/3d/webgl-engine/lib/HighlightHelper.js +1 -1
  317. package/views/3d/webgl-engine/lib/Object3D.js +1 -1
  318. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  319. package/views/3d/webgl-engine/lib/edgeRendering/EdgeRenderer.js +1 -1
  320. package/views/3d/webgl-engine/lib/edgeRendering/EdgeShaderParameters.js +1 -1
  321. package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
  322. package/views/3d/webgl-engine/lib/lodRendering/InstanceData.js +1 -1
  323. package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
  324. package/views/3d/webgl-engine/materials/PathTechnique.js +1 -1
  325. package/views/3d/webgl-engine/materials/WaterTechnique.js +1 -1
  326. package/views/3d/webgl-engine/parts/ScreenshotManager.js +1 -1
  327. package/views/3d/webgl-engine/shaders/HighlightApply.glsl.js +5 -0
  328. package/views/3d/webgl-engine/shaders/HighlightApplyTechnique.js +5 -0
  329. package/views/3d/webgl-engine/shaders/HighlightBlur.glsl.js +5 -0
  330. package/views/3d/webgl-engine/shaders/HighlightBlurTechnique.js +5 -0
  331. package/views/3d/webgl-engine/shaders/HighlightDownsample.glsl.js +5 -0
  332. package/views/3d/webgl-engine/shaders/HighlightDownsampleTechnique.js +5 -0
  333. package/views/3d/webgl-engine/shaders/HighlightOptions.js +4 -0
  334. package/views/3d/webgl-engine/shaders/HighlightPassParameters.js +5 -0
  335. package/views/3d/webgl-engine/shaders/ImageMaterial.glsl.js +1 -1
  336. package/views/3d/webgl-engine/shaders/ImageMaterialTechnique.js +1 -1
  337. package/views/3d/webgl-engine/shaders/NativeLineTechnique.js +1 -1
  338. package/views/3d/webgl-engine/shaders/PatternTechnique.js +1 -1
  339. package/views/3d/webgl-engine/shaders/sources/edgeRenderer/AdjustProjectedPosition.glsl.js +5 -7
  340. package/views/3d/webgl-engine/shaders/sources/edgeRenderer/EdgeUtil.glsl.js +14 -14
  341. package/views/SceneView.js +1 -1
  342. package/views/draw/support/GraphicMover.js +1 -1
  343. package/views/input/InputHandler.js +1 -1
  344. package/views/input/InputManager.js +1 -1
  345. package/views/layers/ImageryTileLayerView.js +1 -1
  346. package/views/layers/MapImageLayerView.js +1 -1
  347. package/views/layers/TileLayerView.js +1 -1
  348. package/views/layers/support/popupUtils.js +1 -1
  349. package/views/support/DefaultsFromMap.js +1 -1
  350. package/views/support/Scheduler.js +1 -1
  351. package/views/support/screenshotUtils.js +1 -1
  352. package/views/ui/DefaultUI.js +1 -1
  353. package/views/webgl/ShaderTranspiler.js +1 -1
  354. package/webscene/Slide.js +1 -1
  355. package/webscene/spec-certification/spec.js +1 -1
  356. package/widgets/AreaMeasurement3D/AreaMeasurement3DViewModel.js +1 -1
  357. package/widgets/Attachments/support/attachmentUtils.js +1 -1
  358. package/widgets/Attachments.js +1 -1
  359. package/widgets/Attribution.js +1 -1
  360. package/widgets/BasemapLayerList.js +1 -1
  361. package/widgets/Bookmarks/BookmarksViewModel.js +1 -1
  362. package/widgets/Bookmarks.js +1 -1
  363. package/widgets/BuildingExplorer/support/filterUtils.js +1 -1
  364. package/widgets/CoordinateConversion/CoordinateConversionViewModel.js +1 -1
  365. package/widgets/CoordinateConversion/support/coordinateConversionUtils.js +1 -1
  366. package/widgets/CoordinateConversion/support/formatUtils.js +1 -1
  367. package/widgets/DirectLineMeasurement3D/DirectLineMeasurement3DViewModel.js +1 -1
  368. package/widgets/Directions/DirectionsViewModel.js +1 -1
  369. package/widgets/Directions.js +1 -1
  370. package/widgets/Editor/EditorViewModel.js +1 -1
  371. package/widgets/Editor/workflowUtils.js +1 -1
  372. package/widgets/Editor.js +1 -1
  373. package/widgets/ElevationProfile/ElevationProfileViewModel.js +1 -1
  374. package/widgets/Feature/FeatureMedia.js +1 -1
  375. package/widgets/Feature/support/featureUtils.js +1 -1
  376. package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
  377. package/widgets/FeatureForm/InputField.js +1 -1
  378. package/widgets/FeatureForm.js +1 -1
  379. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  380. package/widgets/FeatureTable/Grid/Grid.js +1 -1
  381. package/widgets/FeatureTable/support/FeatureStore.js +1 -1
  382. package/widgets/FeatureTemplates.js +1 -1
  383. package/widgets/FloorFilter/FloorFilterViewModel.js +1 -1
  384. package/widgets/LayerList/ListItemPanel.js +1 -1
  385. package/widgets/LayerList.js +1 -1
  386. package/widgets/Legend/LegendViewModel.js +1 -1
  387. package/widgets/Legend/styles/Card.js +1 -1
  388. package/widgets/Legend/styles/Classic.js +1 -1
  389. package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
  390. package/widgets/Legend/support/colorRampUtils.js +1 -1
  391. package/widgets/Legend/support/relationshipRampUtils.js +1 -1
  392. package/widgets/Legend/support/sizeRampUtils.js +1 -1
  393. package/widgets/Popup/PopupViewModel.js +1 -1
  394. package/widgets/Popup/actionUtils.js +1 -1
  395. package/widgets/Print/PrintViewModel.js +1 -1
  396. package/widgets/Print.js +1 -1
  397. package/widgets/ScaleBar/ScaleBarViewModel.js +1 -1
  398. package/widgets/Search/SearchViewModel.js +1 -1
  399. package/widgets/Search/support/layerSearchUtils.js +1 -1
  400. package/widgets/Slider.js +1 -1
  401. package/widgets/Swipe.js +1 -1
  402. package/widgets/TableList.js +1 -1
  403. package/widgets/TimeSlider/TimeSliderViewModel.js +1 -1
  404. package/widgets/TimeSlider.js +1 -1
  405. package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
  406. package/widgets/support/DatePicker.js +1 -1
  407. package/widgets/support/Popover.js +1 -1
  408. package/widgets/support/SnappingControls.js +1 -1
  409. package/widgets/support/TimePicker.js +1 -1
  410. package/widgets/support/timeWidgetUtils.js +1 -1
  411. package/assets/esri/core/workers/chunks/083a5d10f8e243641cb9.js +0 -1
  412. package/assets/esri/core/workers/chunks/0872812ce4d0ec8faf8f.js +0 -1
  413. package/assets/esri/core/workers/chunks/0bc26899780c33637746.js +0 -1
  414. package/assets/esri/core/workers/chunks/113362697da1b69deaed.js +0 -1
  415. package/assets/esri/core/workers/chunks/11a2f9708938eac98815.js +0 -1
  416. package/assets/esri/core/workers/chunks/11a45709b703be84caaf.js +0 -1
  417. package/assets/esri/core/workers/chunks/1c1294ff1ebbd8f774f7.js +0 -1
  418. package/assets/esri/core/workers/chunks/1c915cc9a9d5729b6f17.js +0 -1
  419. package/assets/esri/core/workers/chunks/31786756b3d44540f8c0.js +0 -1
  420. package/assets/esri/core/workers/chunks/36a6f34fe40785beff5d.js +0 -1
  421. package/assets/esri/core/workers/chunks/373c16f8b8093d001064.js +0 -1
  422. package/assets/esri/core/workers/chunks/382a331a592abb61267f.js +0 -1
  423. package/assets/esri/core/workers/chunks/3bf106fe34e3992032c4.js +0 -1
  424. package/assets/esri/core/workers/chunks/3dcec610f1c1497d87bc.js +0 -1
  425. package/assets/esri/core/workers/chunks/46495e726d8739260d44.js +0 -1
  426. package/assets/esri/core/workers/chunks/4a82a6a473b3d540d0be.js +0 -1
  427. package/assets/esri/core/workers/chunks/4b6719377a95ac10fa43.js +0 -1
  428. package/assets/esri/core/workers/chunks/4d2ef57ff3a5cfc1313f.js +0 -1
  429. package/assets/esri/core/workers/chunks/4fd2b8153d62592210a2.js +0 -1
  430. package/assets/esri/core/workers/chunks/56e6a1079269e2964b02.js +0 -1
  431. package/assets/esri/core/workers/chunks/5b4d9786c010d265346c.js +0 -1
  432. package/assets/esri/core/workers/chunks/604637e1c3937b376a0d.js +0 -1
  433. package/assets/esri/core/workers/chunks/60f83257e361f87fa6fd.js +0 -1
  434. package/assets/esri/core/workers/chunks/6d3f80be6fceb2c18b5d.js +0 -1
  435. package/assets/esri/core/workers/chunks/6f827a32646bab0a8777.js +0 -1
  436. package/assets/esri/core/workers/chunks/70bd2ab42e3801ef5974.js +0 -1
  437. package/assets/esri/core/workers/chunks/746222184b361b50d6ba.js +0 -1
  438. package/assets/esri/core/workers/chunks/7fb72b2d11e8d840f982.js +0 -1
  439. package/assets/esri/core/workers/chunks/85bb6a1a7704fcdcbec2.js +0 -1
  440. package/assets/esri/core/workers/chunks/8b4c76cebb100e6c06f8.js +0 -1
  441. package/assets/esri/core/workers/chunks/9586a6b320edb1922926.js +0 -1
  442. package/assets/esri/core/workers/chunks/99638697ffda9022ce92.js +0 -1
  443. package/assets/esri/core/workers/chunks/a9da1cb118ca62a9581d.js +0 -1
  444. package/assets/esri/core/workers/chunks/aaa41a5013eef713c032.js +0 -1
  445. package/assets/esri/core/workers/chunks/ac321f939dd488ff6ce4.js +0 -1
  446. package/assets/esri/core/workers/chunks/add6027a96398ecf69de.js +0 -1
  447. package/assets/esri/core/workers/chunks/b75206b46ba81606087c.js +0 -1
  448. package/assets/esri/core/workers/chunks/bf8456828e38a768eba3.js +0 -1
  449. package/assets/esri/core/workers/chunks/c0720d0d8adcba6738d4.js +0 -1
  450. package/assets/esri/core/workers/chunks/c5bb712d5cf8c05a4e13.js +0 -1
  451. package/assets/esri/core/workers/chunks/d343f05a3366f95e0494.js +0 -1
  452. package/assets/esri/core/workers/chunks/d8b1f00075983d769985.js +0 -1
  453. package/chunks/Highlight.glsl.js +0 -88
  454. package/views/3d/webgl-engine/shaders/Highlight.glsl.js +0 -5
  455. package/views/3d/webgl-engine/shaders/HighlightTechnique.js +0 -5
  456. package/views/3d/webgl-engine/shaders/HighlightTechniqueConfiguration.js +0 -5
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import t from"../../../core/Error.js";import{isSome as i,isNone as s,unwrap as n}from"../../../core/maybe.js";import{isAbortError as o}from"../../../core/promiseUtils.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as a}from"../../../core/accessorSupport/decorators/subclass.js";import{isAxesOrderReversedForWkid as l}from"../../ogc/crsUtils.js";import c from"../DimensionalDefinition.js";import d from"./BaseRaster.js";import{parse as p}from"./multipartParser.js";import{parseCapabilities as h}from"./wcsCapabilitiesParser.js";import{standardizeInterpolations as f,parseCoverages as u}from"./wcsCoverageParser.js";import{clip as g}from"../rasterFunctions/pixelUtils.js";import m from"../../../geometry/Extent.js";const v=["nearest neighbor","bilinear","bicubic"],x=["nearest","linear","cubic"];let w=class extends d{constructor(){super(...arguments),this.datasetFormat="WCSServer"}async open(e){await this.init();const i=null==e?void 0:e.signal,s=await this._getCapabilities(i);if(this.capabilities=s,!this.version){var n;let e=null==(n=s.capabilitiesVersion)?void 0:n.slice(0,3);"2.0"===e||"1.1"===e||"1.0"===e?this.version=s.capabilitiesVersion:(e=s.supportedVersions.find((e=>"2.0.1"===e))||s.supportedVersions.find((e=>"2.0"===e.slice(0,3)))||s.supportedVersions.find((e=>"1.1"===e.slice(0,3)))||s.supportedVersions.find((e=>"1.0"===e.slice(0,3)))||"1.0.0",this.version=e)}null==this.coverageId&&(this.coverageId=s.coverages[0].id);const o=s.coverages.find((e=>e.id===this.coverageId));if(null==o)throw new t("wcsraster-open",`the coverageId ${this.coverageId} does not exist in capabilities`);const r=await this._describeCoverage(i);this.coverageInfo=r[0],"2.0"===this.version.slice(0,3)&&(this.coverageInfo.lonLatEnvelope=o.lonLatEnvelope,this.coverageInfo.supportedInterpolations=f(s.supportedInterpolations)),this.datasetName=this.coverageInfo.title;const{rasterInfo:a}=this.coverageInfo;if(this.createRemoteDatasetStorageInfo(a,512,512),this._set("rasterInfo",a),null==a.spatialReference)throw new t("wcsraster-open",`coverage without spatial referernce is not supported: ${this.coverageId}`);const{pixelType:l,bandCount:c}=await this._getPixelTypeAndBandCount(i);a.pixelType=l,1===a.bandCount&&c>1&&(a.bandCount=c),this.updateTileInfo()}async fetchRawTile(e,n,o,r={}){if(this.isBlockOutside(e,n,o))return null;const{nativePixelSize:a,spatialReference:l}=this.rasterInfo,c=2**e,d=a.x*c,p=a.y*c,{blockWidth:h,blockHeight:f}=this.getBlockWidthHeight(e),{origin:u}=this.rasterInfo.storageInfo.tileInfo,m=this.getTileExtent({x:d,y:p},n,o,u,l,[h,f]),v=this.rasterInfo.extent,x=m.xmax>v.xmax||m.ymin<v.ymin;let w=m,y=h,I=f;if(x&&(w=m.clone().intersection(v),i(w)&&(y=Math.floor((w.xmax-w.xmin)/d),I=Math.floor((w.ymax-w.ymin)/p),w.xmax=w.xmin+d*y,w.ymin=w.ymax-p*I)),s(w)||y<=1||I<=1)return null;const b=await this._getCoverage(w,y,I,c,r);if(!b)return null;const C=await this.decodePixelBlock(b,{width:y,height:I,planes:null,pixelType:null});if(C&&(C.width!==y||C.height!==I))throw new t("wcsraster-fetch",`the reponse has unexpected dimension width: ${C.width}, height: {pixelBlock.height}`);return x?g(C,{x:0,y:0},{width:f,height:f}):C}async _getCapabilities(e){const i={service:"WCS",request:"GetCapabilities"};this.version&&(i.version=this.version,i.acceptVersions=this.version);try{const{data:t}=await this.request(this.url,{query:i,responseType:"xml",signal:e});return h(t)}catch(s){if(!o(s))throw new t("wcslayer:open","wcs capabilities is not valid or supported");throw s}}async _describeCoverage(e){const i={service:"WCS",request:"DescribeCoverage",version:this.version},s=this.version.slice(0,3);"1.0"===s?i.coverage=this.coverageId:"1.1"===s?i.identifiers=this.coverageId:"2.0"===s&&(i.coverageId=this.coverageId);try{const{data:t}=await this.request(this.url,{query:i,responseType:"xml",signal:e});return u(t,this.version)}catch(n){if(!o(n))throw new t("wcslayer:open","wcs coverage description is not valid or supported");throw n}}async _getPixelTypeAndBandCount(e){const{pixelSize:s,extent:o,multidimensionalInfo:r}=this.rasterInfo,a=o.center,l=new m({xmin:a.x-s.x,xmax:a.x+s.x,ymin:a.y-s.y,ymax:a.y+s.y,spatialReference:o.spatialReference});let d;if(i(r)){const e=r.variables[0];d=[],e.dimensions.forEach((t=>{d.push(new c({variableName:e.name,dimensionName:t.name,values:t.hasRegularIntervals?t.extent[0]:t.values[0],isSlice:!0}))}))}const p=await this._getCoverage(l,2,2,1,{multidimensionalDefinition:d,signal:n(e)});if(!p)throw new t("wcsraster-open","unable to determine pixel type");const h=await this.decodePixelBlock(p,{width:2,height:2,planes:null,pixelType:null});return{pixelType:h.pixelType,bandCount:h.getPlaneCount()}}async _getCoverage(e,i,s,n,o){const{coverageDescription:r}=this.coverageInfo,{version:a}=r,l="2.0"===r.version?this._getCoverage201Parameters(e,i,s,n,o,r):"1.1"===r.version?this._getCoverage110Parameters(e,i,s,o,r):this._getCoverage100Parameters(e,i,s,o),c="2.0"===r.version?await this.request(this._constructWCS201Url(l),{signal:o.signal,responseType:"array-buffer"}):await this.request(this.url,{query:l,signal:o.signal,responseType:"array-buffer"});if("1.0"===a)return c.data;const d=p(c);if(d.isMultipart&&d.data){const e=d.data.find((e=>{var t;return(null==(t=e.contentType)?void 0:t.toLowerCase().includes("image"))&&null!=e.contentData}));return null==e?void 0:e.contentData}if(this.ioConfig.allowAnyMediaType)return c.data;throw new t("wcsraster:getcoverage","response is not a valid coverage, multipart response is expected")}_getInterpolationIndex(e){return-1===this.coverageInfo.supportedInterpolations.indexOf(e)||"nearest"===e?0:"bilinear"===e?1:"cubic"===e?2:0}_getCoverage100Parameters(e,t,i,s){const n=`${e.xmin},${e.ymin},${e.xmax},${e.ymax}`,o=e.spatialReference.wkid,r=(this.coverageInfo.supportedFormats||[]).find((e=>e.toLowerCase().indexOf("tiff")>-1))||"GEOTIFF",{bandIds:a,interpolation:l}=s,c=this._getInterpolationIndex(l),d=a?a.map((e=>this.coverageInfo.bandNames[e])):null,p=v[c];return{service:"WCS",request:"GetCoverage",version:this.version,coverage:this.coverageId,format:r,crs:`EPSG:${o}`,bbox:n,width:t,height:i,interpolation:p,band:null==d?void 0:d.join(",")}}_getCoverage110Parameters(e,t,s,n,o){var r;const{multidimensionalDefinition:a,bandIds:c,interpolation:d}=n,p=e.spatialReference.wkid,h=`urn:ogc:def:crs:EPSG::${p}`,f=(this.coverageInfo.supportedFormats||[]).find((e=>e.toLowerCase().indexOf("tiff")>-1))||"image/tiff",u=this._getInterpolationIndex(d),g=x[u],m=null==d||0===(null==(r=this.coverageInfo.supportedInterpolations)?void 0:r.indexOf(d)),v=o.domain.spatialDomain,w=v.origin.x<=v.envelope.xmin&&v.origin.y<=v.envelope.ymin,y=e.width/t,I=e.height/s*(w?1:-1),b=w?[e.xmin,e.ymin]:[e.xmin,e.ymax],C=v.useEPSGAxis&&l(p),$=C?`${b[1]},${b[0]}`:`${b[0]},${b[1]}`,S=C?`${I},0,0,${y}`:`${y},0,0,${I}`,j=y/2,T=e.xmin+j,_=e.xmax-j,O=Math.abs(I)/2,P=e.ymin+O,L=e.ymax-O,E=C?`${P},${T},${L},${_},${h}`:`${T},${P},${_},${L},${h}`,R=o.range.find((e=>e.axis.some((e=>e.identifier.toLowerCase().indexOf("band")>-1))));let q,k=R&&g&&c?m?`${R.identifier}[${R.axis[0].identifier}[${c.join(",")}]]`:`${R.identifier}:${g}[${R.axis[0].identifier}[${c.join(",")}]]`:null;if(i(a)&&a.length)for(let i=0;i<a.length;i++){let e=a[i].values;const t=a[i].dimensionName.toLowerCase(),s=a[i].variableName.toLowerCase();if(e.length>0)if(e[0]instanceof Array&&(e=e[0]),"stdtime"===t)q=e.map((e=>this._convertToISOTime(e))).join(",");else{const i=o.range.find((e=>e.identifier.toLowerCase()===s));if(i){const s=i.axis.find((e=>e.identifier.toLowerCase()===t));s&&(k=m?i.identifier+"["+s.identifier+"["+e.join(",")+"]]":i.identifier+":"+g+"["+s.identifier+"["+e.join(",")+"]]")}}}return{service:"WCS",request:"GetCoverage",version:this.version,identifier:this.coverageId,format:f,crs:`EPSG:${p}`,boundingbox:E,gridCS:"urn:ogc:def:cs:OGC:0.0:Grid2dSquareCS",gridType:"urn:ogc:def:method:WCS:1.1:2dGridIn2dCrs",gridOrigin:$,gridOffsets:S,gridBaseCRS:h,timeSequence:q,rangeSubset:k}}_convertToISOTime(e,t=!1){return(t?new Date(24*(e-25569)*60*60*1e3):new Date(e)).toISOString()}_getCoverage201Parameters(e,t,s,n,o,r){const{multidimensionalDefinition:a,interpolation:l}=o,c=this._getInterpolationIndex(l);let d=null;const{supportedInterpolations:p}=this.capabilities;if(null!=p&&p.length)switch(c){case 0:d=p.find((e=>e.includes("nearest")));break;case 1:d=p.find((e=>e.includes("linear")));break;case 2:d=p.find((e=>e.includes("cubic")||e.includes("quadratic")))}const h=(this.coverageInfo.supportedFormats||[]).find((e=>e.toLowerCase().indexOf("tiff")>-1))||"image/tiff",{bandNames:f}=this.coverageInfo,{boundedBy:u,domainSet:g,rangeType:m}=r,v=u.isEastFirst?0:1,x=1-v,{axisLabels:w}=u,y=w[v],I=w[x],b=`http://www.opengis.net/def/crs/EPSG/0/${e.spatialReference.wkid}`,C=b,$=[];$.push(`${y}(${e.xmin},${e.xmax})`),$.push(`${I}(${e.ymin},${e.ymax})`);const S=[];if(w.length>2)for(let i=2;i<w.length;i++){const e=g.origin[i];if(w[i].toLowerCase().indexOf("time")>-1){let t=e.toString();u.uomLabels[i].toLowerCase().indexOf("ole")>-1&&(S.push(w[i]),t=this._convertToISOTime(e,!0)),$.push(w[i]+",http://www.opengis.net("+t+")")}else $.push(w[i]+",http://www.opengis.net("+e+")")}let j=null;if(i(a)&&a.length){const e=[];m.forEach((t=>t.forEach((t=>e.push(t.name)))));const t=[];for(let i=0;i<a.length;i++){const s=w.find((e=>e===a[i].dimensionName)),n=e.find((e=>e===a[i].variableName));if(-1===t.indexOf(n)&&t.push(n),s){let e=a[i].values;if(e.length>0){Array.isArray(e[0])&&(e=e[0]);let t="";t=s.toLowerCase().indexOf("time")>-1?e.map((e=>this._convertToISOTime(e))).join(","):e.join(",");const i=$.findIndex((e=>0===e.indexOf(s+",http://www.opengis.net")));-1===i&&$.push(s+",http://www.opengis.net("+t+")"),-1!==i&&-1===$[i].indexOf("("+t+")")&&$.splice(i,1,s+",http://www.opengis.net("+t+")")}}}t.length&&(j=t.join(","))}else if(null!=f&&f.length){j=(o.bandIds?o.bandIds.map((e=>f[e])):f).join(",")}const T=$.join("&subset="),_=!(r.domainSet.axisLabels.join("")===r.boundedBy.axisLabels.join(""))&&!1!==this.ioConfig.allowScaleFactor,O=_?null:`${y}(${t}),${I}(${s})`,P=_?1/n:null;return{service:"WCS",request:"GetCoverage",version:this.version,coverageId:this.coverageId,rangesubset:j,interpolation:d,scaleSize:O,scaleFactor:P,subset:T,format:h,mediaType:this.ioConfig.allowAnyMediaType?null:"multipart/related",outputcrs:b,subsettingcrs:C}}_constructWCS201Url(e){const t={...this.ioConfig.customFetchParameters,...e},i=[];Object.keys(t).forEach((e=>{const s=t[e];null!=s&&("subset"===e?s.split("&subset=").forEach((e=>{e&&i.push(`subset=${encodeURIComponent(e)}`)})):i.push(`${e}=${encodeURIComponent(s)}`))}));return`${encodeURI(this.url)}?${i.join("&")}`}};e([r({type:String,json:{write:!0}})],w.prototype,"datasetFormat",void 0),e([r()],w.prototype,"tileType",void 0),e([r({type:String,json:{write:!0}})],w.prototype,"version",void 0),e([r({type:String,json:{write:!0}})],w.prototype,"coverageId",void 0),w=e([a("esri.layers.support.rasterDatasets.ImageServerRaster")],w);const y=w;export{y as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import t from"../../../core/Error.js";import{isSome as i,isNone as s,unwrap as n}from"../../../core/maybe.js";import{isAbortError as o}from"../../../core/promiseUtils.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as a}from"../../../core/accessorSupport/decorators/subclass.js";import{isAxesOrderReversedForWkid as l}from"../../ogc/crsUtils.js";import c from"../DimensionalDefinition.js";import d from"./BaseRaster.js";import{parse as p}from"./multipartParser.js";import{parseCapabilities as h}from"./wcsCapabilitiesParser.js";import{standardizeInterpolations as u,parseCoverages as f}from"./wcsCoverageParser.js";import{clip as g}from"../rasterFunctions/pixelUtils.js";import m from"../../../geometry/Extent.js";const v=["nearest neighbor","bilinear","bicubic"],w=["nearest","linear","cubic"];let x=class extends d{constructor(){super(...arguments),this.datasetFormat="WCSServer"}async open(e){await this.init();const i=null==e?void 0:e.signal,s=await this._getCapabilities(i);if(this.capabilities=s,!this.version){var n;let e=null==(n=s.capabilitiesVersion)?void 0:n.slice(0,3);"2.0"===e||"1.1"===e||"1.0"===e?this.version=s.capabilitiesVersion:(e=s.supportedVersions.find((e=>"2.0.1"===e))||s.supportedVersions.find((e=>"2.0"===e.slice(0,3)))||s.supportedVersions.find((e=>"1.1"===e.slice(0,3)))||s.supportedVersions.find((e=>"1.0"===e.slice(0,3)))||"1.0.0",this.version=e)}null==this.coverageId&&(this.coverageId=s.coverages[0].id);const o=s.coverages.find((e=>e.id===this.coverageId));if(null==o)throw new t("wcsraster-open",`the coverageId ${this.coverageId} does not exist in capabilities`);const r=await this._describeCoverage(i);this.coverageInfo=r[0],"2.0"===this.version.slice(0,3)&&(this.coverageInfo.lonLatEnvelope=o.lonLatEnvelope,this.coverageInfo.supportedInterpolations=u(s.supportedInterpolations)),this.datasetName=this.coverageInfo.title;const{rasterInfo:a}=this.coverageInfo;if(this.createRemoteDatasetStorageInfo(a,512,512),this._set("rasterInfo",a),null==a.spatialReference)throw new t("wcsraster-open",`coverage without spatial referernce is not supported: ${this.coverageId}`);const{pixelType:l,bandCount:c}=await this._getPixelTypeAndBandCount(i);a.pixelType=l,1===a.bandCount&&c>1&&(a.bandCount=c),this.updateTileInfo()}async fetchRawTile(e,n,o,r={}){if(this.isBlockOutside(e,n,o))return null;const{nativePixelSize:a,spatialReference:l}=this.rasterInfo,c=2**e,d=a.x*c,p=a.y*c,{blockWidth:h,blockHeight:u}=this.getBlockWidthHeight(e),{origin:f}=this.rasterInfo.storageInfo.tileInfo,m=this.getTileExtent({x:d,y:p},n,o,f,l,[h,u]),v=this.rasterInfo.extent,w=m.xmax>v.xmax||m.ymin<v.ymin;let x=m,y=h,I=u;if(w&&(x=m.clone().intersection(v),i(x)&&(y=Math.floor((x.xmax-x.xmin)/d),I=Math.floor((x.ymax-x.ymin)/p),x.xmax=x.xmin+d*y,x.ymin=x.ymax-p*I)),s(x)||y<=1||I<=1)return null;const b=await this._getCoverage(x,y,I,c,r);if(!b)return null;const C=await this.decodePixelBlock(b,{width:y,height:I,planes:null,pixelType:null});if(C&&(C.width!==y||C.height!==I))throw new t("wcsraster-fetch",`the reponse has unexpected dimension width: ${C.width}, height: {pixelBlock.height}`);return w?g(C,{x:0,y:0},{width:u,height:u}):C}async _getCapabilities(e){const i={service:"WCS",request:"GetCapabilities"};this.version&&(i.version=this.version,i.acceptVersions=this.version);try{const{data:t}=await this.request(this.url,{query:i,responseType:"xml",signal:e});return h(t)}catch(s){if(!o(s))throw new t("wcslayer:open","wcs capabilities is not valid or supported");throw s}}async _describeCoverage(e){const i={service:"WCS",request:"DescribeCoverage",version:this.version},s=this.version.slice(0,3);"1.0"===s?i.coverage=this.coverageId:"1.1"===s?i.identifiers=this.coverageId:"2.0"===s&&(i.coverageId=this.coverageId);try{const{data:t}=await this.request(this.url,{query:i,responseType:"xml",signal:e});return f(t,this.version)}catch(n){if(!o(n))throw new t("wcslayer:open","wcs coverage description is not valid or supported");throw n}}async _getPixelTypeAndBandCount(e){const{pixelSize:s,extent:o,multidimensionalInfo:r}=this.rasterInfo,a=o.center,l=new m({xmin:a.x-s.x,xmax:a.x+s.x,ymin:a.y-s.y,ymax:a.y+s.y,spatialReference:o.spatialReference});let d;if(i(r)){const e=r.variables[0];d=[],e.dimensions.forEach((t=>{d.push(new c({variableName:e.name,dimensionName:t.name,values:t.hasRegularIntervals?t.extent[0]:t.values[0],isSlice:!0}))}))}const p=await this._getCoverage(l,2,2,1,{multidimensionalDefinition:d,signal:n(e)});if(!p)throw new t("wcsraster-open","unable to determine pixel type");const h=await this.decodePixelBlock(p,{width:2,height:2,planes:null,pixelType:null});return{pixelType:h.pixelType,bandCount:h.getPlaneCount()}}async _getCoverage(e,i,s,n,o){const{coverageDescription:r}=this.coverageInfo,{version:a}=r,l="2.0"===r.version?this._getCoverage201Parameters(e,i,s,n,o,r):"1.1"===r.version?this._getCoverage110Parameters(e,i,s,o,r):this._getCoverage100Parameters(e,i,s,o),c="2.0"===r.version?await this.request(this._constructWCS201Url(l),{signal:o.signal,responseType:"array-buffer"}):await this.request(this.url,{query:l,signal:o.signal,responseType:"array-buffer"});if("1.0"===a)return c.data;const d=p(c);if(d.isMultipart&&d.data){const e=d.data.find((e=>{var t;return(null==(t=e.contentType)?void 0:t.toLowerCase().includes("image"))&&null!=e.contentData}));return null==e?void 0:e.contentData}if(this.ioConfig.allowAnyMediaType)return c.data;throw new t("wcsraster:getcoverage","response is not a valid coverage, multipart response is expected")}_getInterpolationIndex(e){return this.coverageInfo.supportedInterpolations.includes(e)?"nearest"===e?0:"bilinear"===e?1:"cubic"===e?2:0:0}_getCoverage100Parameters(e,t,i,s){const n=`${e.xmin},${e.ymin},${e.xmax},${e.ymax}`,o=e.spatialReference.wkid,r=(this.coverageInfo.supportedFormats||[]).find((e=>e.toLowerCase().includes("tiff")))||"GEOTIFF",{bandIds:a,interpolation:l}=s,c=this._getInterpolationIndex(l),d=a?a.map((e=>this.coverageInfo.bandNames[e])):null,p=v[c];return{service:"WCS",request:"GetCoverage",version:this.version,coverage:this.coverageId,format:r,crs:`EPSG:${o}`,bbox:n,width:t,height:i,interpolation:p,band:null==d?void 0:d.join(",")}}_getCoverage110Parameters(e,t,s,n,o){var r;const{multidimensionalDefinition:a,bandIds:c,interpolation:d}=n,p=e.spatialReference.wkid,h=`urn:ogc:def:crs:EPSG::${p}`,u=(this.coverageInfo.supportedFormats||[]).find((e=>e.toLowerCase().includes("tiff")))||"image/tiff",f=this._getInterpolationIndex(d),g=w[f],m=null==d||0===(null==(r=this.coverageInfo.supportedInterpolations)?void 0:r.indexOf(d)),v=o.domain.spatialDomain,x=v.origin.x<=v.envelope.xmin&&v.origin.y<=v.envelope.ymin,y=e.width/t,I=e.height/s*(x?1:-1),b=x?[e.xmin,e.ymin]:[e.xmin,e.ymax],C=v.useEPSGAxis&&l(p),$=C?`${b[1]},${b[0]}`:`${b[0]},${b[1]}`,S=C?`${I},0,0,${y}`:`${y},0,0,${I}`,j=y/2,T=e.xmin+j,_=e.xmax-j,P=Math.abs(I)/2,L=e.ymin+P,E=e.ymax-P,R=C?`${L},${T},${E},${_},${h}`:`${T},${L},${_},${E},${h}`,q=o.range.find((e=>e.axis.some((e=>e.identifier.toLowerCase().includes("band")))));let k,D=q&&g&&c?m?`${q.identifier}[${q.axis[0].identifier}[${c.join(",")}]]`:`${q.identifier}:${g}[${q.axis[0].identifier}[${c.join(",")}]]`:null;if(i(a)&&a.length)for(let i=0;i<a.length;i++){let e=a[i].values;const t=a[i].dimensionName.toLowerCase(),s=a[i].variableName.toLowerCase();if(e.length>0)if(e[0]instanceof Array&&(e=e[0]),"stdtime"===t)k=e.map((e=>this._convertToISOTime(e))).join(",");else{const i=o.range.find((e=>e.identifier.toLowerCase()===s));if(i){const s=i.axis.find((e=>e.identifier.toLowerCase()===t));s&&(D=m?i.identifier+"["+s.identifier+"["+e.join(",")+"]]":i.identifier+":"+g+"["+s.identifier+"["+e.join(",")+"]]")}}}return{service:"WCS",request:"GetCoverage",version:this.version,identifier:this.coverageId,format:u,crs:`EPSG:${p}`,boundingbox:R,gridCS:"urn:ogc:def:cs:OGC:0.0:Grid2dSquareCS",gridType:"urn:ogc:def:method:WCS:1.1:2dGridIn2dCrs",gridOrigin:$,gridOffsets:S,gridBaseCRS:h,timeSequence:k,rangeSubset:D}}_convertToISOTime(e,t=!1){return(t?new Date(24*(e-25569)*60*60*1e3):new Date(e)).toISOString()}_getCoverage201Parameters(e,t,s,n,o,r){const{multidimensionalDefinition:a,interpolation:l}=o,c=this._getInterpolationIndex(l);let d=null;const{supportedInterpolations:p}=this.capabilities;if(null!=p&&p.length)switch(c){case 0:d=p.find((e=>e.includes("nearest")));break;case 1:d=p.find((e=>e.includes("linear")));break;case 2:d=p.find((e=>e.includes("cubic")||e.includes("quadratic")))}const h=(this.coverageInfo.supportedFormats||[]).find((e=>e.toLowerCase().includes("tiff")))||"image/tiff",{bandNames:u}=this.coverageInfo,{boundedBy:f,domainSet:g,rangeType:m}=r,v=f.isEastFirst?0:1,w=1-v,{axisLabels:x}=f,y=x[v],I=x[w],b=`http://www.opengis.net/def/crs/EPSG/0/${e.spatialReference.wkid}`,C=b,$=[];$.push(`${y}(${e.xmin},${e.xmax})`),$.push(`${I}(${e.ymin},${e.ymax})`);const S=[];if(x.length>2)for(let i=2;i<x.length;i++){const e=g.origin[i];if(x[i].toLowerCase().includes("time")){let t=e.toString();f.uomLabels[i].toLowerCase().includes("ole")&&(S.push(x[i]),t=this._convertToISOTime(e,!0)),$.push(x[i]+",http://www.opengis.net("+t+")")}else $.push(x[i]+",http://www.opengis.net("+e+")")}let j=null;if(i(a)&&a.length){const e=[];m.forEach((t=>t.forEach((t=>e.push(t.name)))));const t=[];for(let i=0;i<a.length;i++){const s=x.find((e=>e===a[i].dimensionName)),n=e.find((e=>e===a[i].variableName));if(t.includes(n)||t.push(n),s){let e=a[i].values;if(e.length>0){Array.isArray(e[0])&&(e=e[0]);let t="";t=s.toLowerCase().includes("time")?e.map((e=>this._convertToISOTime(e))).join(","):e.join(",");const i=$.findIndex((e=>0===e.indexOf(s+",http://www.opengis.net")));-1===i&&$.push(s+",http://www.opengis.net("+t+")"),-1===i||$[i].includes("("+t+")")||$.splice(i,1,s+",http://www.opengis.net("+t+")")}}}t.length&&(j=t.join(","))}else if(null!=u&&u.length){j=(o.bandIds?o.bandIds.map((e=>u[e])):u).join(",")}const T=$.join("&subset="),_=!(r.domainSet.axisLabels.join("")===r.boundedBy.axisLabels.join(""))&&!1!==this.ioConfig.allowScaleFactor,P=_?null:`${y}(${t}),${I}(${s})`,L=_?1/n:null;return{service:"WCS",request:"GetCoverage",version:this.version,coverageId:this.coverageId,rangesubset:j,interpolation:d,scaleSize:P,scaleFactor:L,subset:T,format:h,mediaType:this.ioConfig.allowAnyMediaType?null:"multipart/related",outputcrs:b,subsettingcrs:C}}_constructWCS201Url(e){const t={...this.ioConfig.customFetchParameters,...e},i=[];Object.keys(t).forEach((e=>{const s=t[e];null!=s&&("subset"===e?s.split("&subset=").forEach((e=>{e&&i.push(`subset=${encodeURIComponent(e)}`)})):i.push(`${e}=${encodeURIComponent(s)}`))}));return`${encodeURI(this.url)}?${i.join("&")}`}};e([r({type:String,json:{write:!0}})],x.prototype,"datasetFormat",void 0),e([r()],x.prototype,"tileType",void 0),e([r({type:String,json:{write:!0}})],x.prototype,"version",void 0),e([r({type:String,json:{write:!0}})],x.prototype,"coverageId",void 0),x=e([a("esri.layers.support.rasterDatasets.ImageServerRaster")],x);const y=x;export{y as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- const t=5e4;function n(t){const n=o(t);if(!n)return{isMultipart:!1,data:null};return{isMultipart:!0,data:n.boundary?r(t.data,n,0):null}}function e(t){const n=new Uint8Array(t,0,2e3),e=String.fromCharCode.apply(null,n),r=e.indexOf('boundary="'),o=-1!==r?e.slice(r+10,e.indexOf('"',r+10)):"";return{boundary:o,offset:-1!==r?r+12+o.length:0}}function r(n,e,r=0){const o="--"+e.boundary,a=[];for(let t=0;t<o.length;t++)a.push(o.charCodeAt(t));const s=[],l="\n--"+e.boundary+"--";for(let t=0;t<l.length;t++)s.push(l.charCodeAt(t));const c=[10],u=[13,10],f=[],h=a.length,d=new Uint8Array(n,r),p=Math.min(t,d.length-h);let g=0,y=0;for(let t=0;t<p;t++){for(y=0;y<h&&d[t+y]===a[y];y++);y===h&&(g&&f.push(i(d.subarray(g,t),e)),t+=h-1,d[t+1]===c[0]?t+=1:d[t+1]===u[0]&&d[t+2]===u[1]&&(t+=2),g=t+1)}const b=s.length;for(let t=d.length-b-10;t<d.length-b;t++){for(y=0;y<b&&d[t+y]===s[y];y++);if(y===b){f.push(i(d.subarray(g,t),e));break}}return f}function o(t){var n,e;const r=null==(n=t.getHeader("Content-Type"))?void 0:n.split(";");if(!(null!=(e=null==r?void 0:r[0].trim())?e:"").startsWith("multipart/"))return null;const o={boundary:"",start:"",type:""};for(let i=1;i<r.length;i++){const t=r[i].split("="),n=t[1].trim();o[t[0].trim()]=n.startsWith('"')?n.slice(1,t[1].length-1):n}return o}function i(t,n){const e=String.fromCharCode.apply(null,t.subarray(0,Math.min(300,t.length))).split("\n"),r=Math.min(e.length,7),o={contentDisposition:"inline"};let i=0;for(let s=0;s<r;s++){var a;if(e[s].length<4)i=i+e[s].length+1;else if("content"===e[s].slice(0,7).toLowerCase()){if(i=i+e[s].length+1,-1===e[s].indexOf(":"))continue;const t=e[s].substring(0,e[s].indexOf(":")).trim(),n=e[s].substring(e[s].indexOf(":")+1).trim();switch(t.toLowerCase()){case"content-type":o.contentType=n;break;case"content-description":o.contentDescription=n;break;case"content-transfer-encoding":o.contentTransferEncoding=n;break;case"content-id":o.contentID=n;break;case"content-disposition":o.contentDisposition=n;break;case"content-location":o.contentLocation=n}}else{if(o.contentDisposition.toLowerCase().indexOf("inline")>-1&&e[s].length>=4&&(null==(a=o.contentType)?void 0:a.toLowerCase().indexOf("image"))>-1){let n=!0;if(o.contentType.toLowerCase().indexOf("tif")>0&&(n=73===t[i]&&73===t[i+1]||77===t[i]&&77===t[i+1]),n){const n=new ArrayBuffer(t.length-i);new Uint8Array(n).set(t.subarray(i,t.length)),o.contentData=n}break}if((""===n.start||o.contentID===n.start)&&o.contentType){if(o.contentType.indexOf("text")>-1||o.contentType.indexOf("xml")>-1){o.contentData=String.fromCharCode.apply(null,t.subarray(i,t.length));break}o.contentData=t.subarray(i,t.length)}}}return o}export{e as getBoundary,n as parse};
5
+ const t=5e4;function n(t){const n=o(t);if(!n)return{isMultipart:!1,data:null};return{isMultipart:!0,data:n.boundary?r(t.data,n,0):null}}function e(t){const n=new Uint8Array(t,0,2e3),e=String.fromCharCode.apply(null,n),r=e.indexOf('boundary="'),o=-1!==r?e.slice(r+10,e.indexOf('"',r+10)):"";return{boundary:o,offset:-1!==r?r+12+o.length:0}}function r(n,e,r=0){const o="--"+e.boundary,a=[];for(let t=0;t<o.length;t++)a.push(o.charCodeAt(t));const s=[],l="\n--"+e.boundary+"--";for(let t=0;t<l.length;t++)s.push(l.charCodeAt(t));const c=[10],u=[13,10],f=[],h=a.length,d=new Uint8Array(n,r),p=Math.min(t,d.length-h);let g=0,y=0;for(let t=0;t<p;t++){for(y=0;y<h&&d[t+y]===a[y];y++);y===h&&(g&&f.push(i(d.subarray(g,t),e)),t+=h-1,d[t+1]===c[0]?t+=1:d[t+1]===u[0]&&d[t+2]===u[1]&&(t+=2),g=t+1)}const b=s.length;for(let t=d.length-b-10;t<d.length-b;t++){for(y=0;y<b&&d[t+y]===s[y];y++);if(y===b){f.push(i(d.subarray(g,t),e));break}}return f}function o(t){var n,e;const r=null==(n=t.getHeader("Content-Type"))?void 0:n.split(";");if(!(null!=(e=null==r?void 0:r[0].trim())?e:"").startsWith("multipart/"))return null;const o={boundary:"",start:"",type:""};for(let i=1;i<r.length;i++){const t=r[i].split("="),n=t[1].trim();o[t[0].trim()]=n.startsWith('"')?n.slice(1,t[1].length-1):n}return o}function i(t,n){const e=String.fromCharCode.apply(null,t.subarray(0,Math.min(300,t.length))).split("\n"),r=Math.min(e.length,7),o={contentDisposition:"inline"};let i=0;for(let s=0;s<r;s++){var a;if(e[s].length<4)i=i+e[s].length+1;else if("content"===e[s].slice(0,7).toLowerCase()){if(i=i+e[s].length+1,!e[s].includes(":"))continue;const t=e[s].substring(0,e[s].indexOf(":")).trim(),n=e[s].substring(e[s].indexOf(":")+1).trim();switch(t.toLowerCase()){case"content-type":o.contentType=n;break;case"content-description":o.contentDescription=n;break;case"content-transfer-encoding":o.contentTransferEncoding=n;break;case"content-id":o.contentID=n;break;case"content-disposition":o.contentDisposition=n;break;case"content-location":o.contentLocation=n}}else{if(o.contentDisposition.toLowerCase().includes("inline")&&e[s].length>=4&&(null==(a=o.contentType)?void 0:a.toLowerCase().indexOf("image"))>-1){let n=!0;if(o.contentType.toLowerCase().indexOf("tif")>0&&(n=73===t[i]&&73===t[i+1]||77===t[i]&&77===t[i+1]),n){const n=new ArrayBuffer(t.length-i);new Uint8Array(n).set(t.subarray(i,t.length)),o.contentData=n}break}if((""===n.start||o.contentID===n.start)&&o.contentType){if(o.contentType.includes("text")||o.contentType.includes("xml")){o.contentData=String.fromCharCode.apply(null,t.subarray(i,t.length));break}o.contentData=t.subarray(i,t.length)}}}return o}export{e as getBoundary,n as parse};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../geometry/Extent.js";import t from"../../../geometry/Polygon.js";import{isAxesOrderReversedForWkid as n}from"../../ogc/crsUtils.js";import i from"../RasterInfo.js";import{getElements as o,isSameTagIgnoreNS as s,getElementValue as a,getElementValues as r,getNodeNameIgnoreNS as l,getElement as p,getSpaceDelimitedNumericValues as m}from"./xmlUtilities.js";function u(e){return{requestResponseCRSs:r(e,"requestResponseCRSs").map((e=>e.split(":")[1])),nativeCRSs:r(e,"nativeCRSs").map((e=>e.split(":")[1]))}}function d(e,t){const n=r(e,"1.0.0"===t?"interpolationMethod":"InterpolationMethod"),i="1.0.0"===t?e.getAttribute("default"):a(e,"InterpolationMethods/Default");return null!=i?[i].concat(n.filter((e=>e.toLowerCase()!==i.toLowerCase()))):n}function c(e){return null==e?["nearest"]:e.map((e=>{const t=e.toLowerCase();return t.indexOf("nearest")>-1?"nearest":t.indexOf("linear")>-1?"bilinear":t.indexOf("cubic")>-1?"cubic":null})).filter((e=>!!e))}function f(t){const n=o(t,"pos"),i=m(n[0]),s=m(n[1]);return new e({xmin:i[0],ymin:i[1],xmax:s[0],ymax:s[1],spatialReference:{wkid:4326}})}function g(e){const t=[],n=o(e,"RangeSet");let i=[];for(let s=0;s<n.length;s++){const e=a(n[s],"name"),l=a(n[s],"label"),p=[],m=o(n[s],"AxisDescription");for(let t=0;t<m.length;t++){const e=a(m[t],"name"),n=a(m[t],"label"),o=r(m[t],"singleValue");if(0===o.length){const e=a(m[t],"min"),n=a(m[t],"max"),i=Number(a(m[t],"res"))||1;if(null!==e&&null!==n)for(let t=parseInt(e,10);t<=parseInt(n,10);t+=i)o.push(t.toString())}"band"===e.toLowerCase()&&(i=o),p.push({name:e,label:n,values:o})}t.push({name:e,label:l,axis:p})}return{rangeSet:t,bandNames:i}}function h(e=null){if(!e)return{resolution:null,units:null};let t=e.toUpperCase();const n=["Y","M","D"],i=["H","M","S"],o=["Years","Months","Days","Hours","Minutes","Seconds"];let s,a,r;return-1===t.indexOf("PT")?(t=t.slice(1),r=n.findIndex((e=>t.indexOf(e)>-1)),r>-1&&(s=o[r]),a=parseFloat(t.substring(0,t.length-1))):(t=t.slice(2),r=i.findIndex((e=>t.indexOf(e)>-1)),s=o[3+r],a=parseFloat(t.substring(0,t.length-1))),{resolution:a,units:s}}function x(e){const t=o(e,"timeposition");if(t.length>0){const e=[];for(let n=0;n<t.length;n++)e.push(new Date(a(t[n])));return{begin:e[0],end:e[e.length-1],values:e}}const n=p(e,"timePeriod")||p(e,"TimePeriod");if(n){return{begin:new Date(a(n,"beginPosition")||a(n,"BeginPosition")),end:new Date(a(n,"endPosition")||a(n,"EndPosition")),...h(a(n,"timeResolution")||a(n,"TimeResolution"))}}return null}function b(t){const n=p(t,"spatialDomain"),i=p(n,"Envelope")||p(n,"EnvelopeWithTimePeriod"),s=i.getAttribute("srsName").split(":"),r=s[s.length-1],l=o(i,"pos"),u=m(l[0]),d=m(l[1]),c=parseInt(r,10),f=isNaN(c)?null:{wkid:c},g=new e({xmin:u[0],ymin:u[1],xmax:d[0],ymax:d[1],spatialReference:f}),h=p(n,"RectifiedGrid"),b=a(h,"low").split(" "),v=a(h,"high").split(" "),w=parseInt(v[0],10)-parseInt(b[0],10)+1,y=parseInt(v[1],10)-parseInt(b[1],10)+1,D=m(n,"origin/pos"),L=o(n,"offsetVector"),S={envelope:g,columns:w,rows:y,offset:{x:parseFloat(a(L[0]).split(" ")[0]),y:parseFloat(a(L[1]).split(" ")[1])},origin:{x:D[0],y:D[1]}},C=p(t,"temporalDomain")||p(t,"TemporalDomain");return{spatialDomain:S,temporalDomain:C?x(C):null}}function v(e){const t={version:"1.0"};let n=[];for(let i=0;i<e.childNodes.length;i++){const o=e.childNodes[i];if(1===o.nodeType)if(s(o,"description"))t.description=a(o);else if(s(o,"name"))t.name=a(o);else if(s(o,"label"))t.label=a(o);else if(s(o,"supportedFormats"))t.supportedFormats=r(o,"formats");else if(s(o,"supportedCRSs"))t.supportedCRSs=u(o);else if(s(o,"supportedInterpolations"))t.supportedInterpolations=d(o,"1.0.0");else if(s(o,"lonLatEnvelope"))t.lonLatEnvelope=f(o);else if(s(o,"rangeSet")){const e=g(o);t.rangeSet=e.rangeSet,n=e.bandNames}else s(o,"domainSet")&&(t.domainSet=b(o))}const o=c(t.supportedInterpolations),{name:l,description:p,label:m,lonLatEnvelope:h,supportedFormats:x}=t,{spatialDomain:v}=t.domainSet,w={x:Math.abs(v.offset.x),y:Math.abs(v.offset.y)},y=new i({width:v.columns,height:v.rows,pixelSize:w,extent:v.envelope,spatialReference:v.envelope.spatialReference,bandCount:n.length||1});return{id:l,title:t.name,description:p||m,lonLatEnvelope:h,rasterInfo:y,bandNames:n,supportedFormats:x,supportedInterpolations:o,coverageDescription:t,version:"1.0.0",useEPSGAxis:!1}}function w(e){const t=[],n=o(e,"Field");let i=[];for(let s=0;s<n.length;s++){const e=a(n[s],"Identifier"),l=a(n[s],"Description"),p=a(n[s],"Definition"),m=a(n[s],"Abstract"),u=a(n[s],"Title"),c=d(n[s],"1.1.0"),f=[],g=o(n[s],"Axis");for(let t=0;t<g.length;t++){const e=g[t].getAttribute("identifier"),n=a(g[t],"UOM"),o=a(g[t],"DataType"),s=r(g[t],"Key");"band"===e.toLowerCase()&&(i=s),f.push({identifier:e,uom:n,dataType:o,values:s})}t.push({identifier:e,description:l,definition:p,abstract:m,title:u,supportedInterpolations:c,axis:f})}return{rangeSet:t,bandNames:i}}function y(e,t){const n=e.filter((e=>-1===e.identifier.toLowerCase().indexOf("field_1")&&!e.axis.some((e=>"band"===e.identifier.toLowerCase())))),i=[];if(n.length&&n.forEach((e=>{var t,n;const o=e.axis.map((e=>{const t=e.values.map((t=>{if("ISO8601"===e.uom){return-1===(t=t.trim()).toLowerCase().indexOf("z")?new Date(t+"Z").getTime():new Date(t).getTime()}return parseFloat(t.trim())})),n=[Math.min.apply(null,t),Math.max.apply(null,t)];return{name:e.identifier.trim(),description:"",field:e.identifier.trim(),unit:e.uom?e.uom.trim():"",hasRegularIntervals:!1,values:t,extent:n}}));i.push({name:e.identifier.trim(),description:null!=(t=null==(n=e.description)?void 0:n.trim())?t:"",unit:"",dimensions:o})})),t.temporalDomain){const{begin:e,end:n,values:o,units:s,resolution:a}=t.temporalDomain;i.some((e=>e.dimensions.some((e=>"stdtime"===e.name.toLowerCase()))))||i.forEach((t=>{t.dimensions.push({name:"StdTime",description:"",unit:"ISO8601",values:null==o?void 0:o.map((e=>e.getTime())),hasRegularIntervals:!o,interval:a,intervalUnit:s,extent:[e.getTime(),n.getTime()]})}))}return i.length?{variables:i}:null}function D(t){var i;const s=p(t,"SpatialDomain"),r=p(s,"GridCRS"),l=a(r,"GridBaseCRS"),u=a(r,"GridOrigin"),d=null!=(i=null==u?void 0:u.split(" ").map((e=>parseFloat(e))))?i:[0,0],c=m(r,"GridOffsets"),f=o(s,"BoundingBox");let g,h,b,v;for(let n=0;n<f.length;n++){var w;const t=null==(w=f[n].getAttribute("crs"))?void 0:w.toLowerCase();if(null!=t)if(t.indexOf("imagecrs")>-1){const e=m(f[n],"LowerCorner"),t=m(f[n],"UpperCorner");g=t[0]-e[0]+1,h=t[1]-e[1]+1}else if(t.indexOf("epsg")>0){const i=t.split(":");b=parseInt(i[i.length-1],10);const o=m(f[n],"LowerCorner"),s=m(f[n],"UpperCorner");v=new e({xmin:o[0],ymin:o[1],xmax:s[0],ymax:s[1],spatialReference:{wkid:b}})}}const y=g>h,D=v.xmax-v.xmin>v.ymax-v.ymin;let L=!1;n(b)&&(y===D?L=!1:(L=!0,v=new e({xmin:v.ymin,ymin:v.xmin,xmax:v.ymax,ymax:v.xmax,spatialReference:{wkid:b}})));const S={columns:g,rows:h,origin:{x:d[0],y:d[1]},offset:{x:c[0],y:c[1]},gridBaseCRS:l,envelope:v,useEPSGAxis:L},C=p(t,"temporalDomain")||p(t,"TemporalDomain");return{spatialDomain:S,temporalDomain:C?x(C):null}}function L(e,t){const n=[],o=[],s={supportedFormats:n,supportedCRSs:o,version:"1.1"};let r;for(let i=0;i<e.childNodes.length;i++){const t=e.childNodes[i];if(1!==t.nodeType)continue;const p=l(t).toLowerCase();switch(p){case"title":case"abstract":case"identifier":s[p]=a(t);break;case"supportedformat":{const e=a(t);-1===n.indexOf(e)&&n.push(e)}break;case"supportedcrs":{const e=a(t);-1===o.indexOf(e)&&o.push(e)}break;case"range":{const e=w(t);s.range=e.rangeSet,r=e.bandNames}break;case"domain":s.domain=D(t)}}const p=c(s.range[0].supportedInterpolations),{identifier:m,abstract:u,title:d,domain:f,range:g}=s,h={x:Math.abs(f.spatialDomain.offset.x),y:Math.abs(f.spatialDomain.offset.y)},x=y(g,f),b=new i({width:f.spatialDomain.columns,height:f.spatialDomain.rows,pixelSize:h,extent:f.spatialDomain.envelope,spatialReference:f.spatialDomain.envelope.spatialReference,bandCount:r.length||1,multidimensionalInfo:x});return{id:m,title:s.title,description:u||d,lonLatEnvelope:null,bandNames:r,rasterInfo:b,supportedFormats:n,supportedInterpolations:p,coverageDescription:s,version:t,useEPSGAxis:f.spatialDomain.useEPSGAxis}}function S(t){const n=p(t,"Envelope")||p(t,"EnvelopeWithTimePeriod"),i=n.getAttribute("srsName"),o=i.slice(i.lastIndexOf("/")+1),r=n.getAttribute("axisLabels").split(" ").map((e=>e.trim())).filter((e=>""!==e.trim())),l=m(n,"lowerCorner"),u=m(n,"upperCorner"),d=!["y","lat","latitude","north","nor","n","b"].some((e=>e===r[0].toLowerCase()));let c;const f=parseInt(o,10),g=isNaN(f)?null:{wkid:f};c=new e(d?{xmin:l[0],ymin:l[1],xmax:u[0],ymax:u[1],spatialReference:g}:{xmin:l[1],ymin:l[0],xmax:u[1],ymax:u[0],spatialReference:g});const h={mins:l,maxs:u},x=n.getAttribute("uomLabels").trim().split(" ");let b,v;return s(n,"EnvelopeWithTimePeriod")&&(b=new Date(a(t,"beginPosition")||a(t,"BeginPosition")),v=new Date(a(t,"endPosition")||a(t,"EndPosition"))),{envelope:c,axisLabels:r,uomLabels:x.length?x:null,envelopeAllDims:h,beginPosition:b,endPosition:v,isEastFirst:d}}function C(e){const t=[],n=o(e,"DataRecord"),i=[];for(let r=0;r<n.length;r++){const e=o(n[r],"field"),l=[];for(let t=0;t<e.length;t++){var s;const n=e[t].getAttribute("name"),o=a(e[t],"description")||"",r=(null==(s=p(e[t],"uom"))?void 0:s.getAttribute("code"))||"",u=m(e[t],"interval");n.toLowerCase().indexOf("band")>-1&&i.push(n),l.push({name:n,description:o,uom:r,allowedValues:u})}t.push(l)}return{rangeType:t,bandNames:i}}function I(e){let t=1,n="";const i=.01;return Math.abs(e-1/24)<1/24*i?n="Hours":Math.abs(e-1)<1*i?n="Days":e<1?(t=Math.round(24*e),n="Hours"):e>28-i&&e<31+i||Math.round(e/30)<12?n="Months":e>365-i&&e<366+i&&(n="Years"),{interval:t,intervalUnit:n}}function R(e,t,n){const i=[];for(let s=0;s<e.length;s++){const t=e[s];for(let e=0;e<t.length;e++)-1===t[e].name.toLowerCase().indexOf("band")&&i.push(t[e])}const o=[];if(i.length){const e=[];for(let i=2;i<n.axisLabels.length;i++){const o=(t.uomLabels&&t.uomLabels.length)>i?t.uomLabels[i]:"",s=n.axisLabels[i].toLowerCase().indexOf("time")>-1||"iso8601"===o.toLowerCase()||"oledatetime"===o.toLowerCase();let a,r;if(s){const e=I(n.offset[i]);a=e.interval,r=e.intervalUnit}else a=n.offset[i],r=o;const l=[];s?(l.push((new Date).setTime(24*(t.envelopeAllDims.mins[i]-25569)*3600*1e3)),l.push((new Date).setTime(24*(t.envelopeAllDims.maxs[i]-25569)*3600*1e3))):(l.push(t.envelopeAllDims.mins[i]),l.push(t.envelopeAllDims.maxs[i])),e.push({name:n.axisLabels[i].trim(),description:n.axisLabels[i].trim(),unit:t.uomLabels&&t.uomLabels.length>i?t.uomLabels[i].trim():"",hasRegularIntervals:!0,extent:l,interval:a,intervalUnit:r})}if(i.forEach((t=>{var n,i;return o.push({name:t.name.trim(),description:null!=(n=null==(i=t.description)?void 0:i.trim())?n:"",unit:t.uom.trim(),dimensions:e})})),o.length)return{variables:o}}return null}function T(e,t){const n=p(e,"RectifiedGrid"),i=m(n,"low"),s=m(n,"high"),r=[];for(let o=0;o<i.length;o++)r.push(s[o]-i[o]+1);const l=a(n,"axisLabels").split(" "),u=m(n,"origin/pos"),d=o(n,"offsetVector"),c=[];for(let o=0;o<d.length;o++){const e=m(d[o]),t=e.findIndex((e=>0!==e));c[t]=e[t]}const f=t||l;let g,h,x;return["y","lat","latitude","north","nor","n","b"].some((e=>e===f[0].toLowerCase()))?(g=r[1],h=r[0],x={y:Math.abs(c[0]),x:Math.abs(c[1])}):(g=r[0],h=r[1],x={x:Math.abs(c[0]),y:Math.abs(c[1])}),{columns:g,rows:h,origin:u,offset:c,resolution:x,gridSamples:r,axisLabels:l}}function M(e){const n=p(e,"EarthObservation");if(!n)return null;const i=p(n,"phenomenonTime"),o=i?x(i):null,s=p(n,"phenomenonTime"),r=s?x(s):null,l=a(n,"featureOfInterest/Footprint/multiExtentOf/MultiSurface/surfaceMembers/Polygon/exterior/LinearRing/posList");let m=null;if(l){const e=l.split(" ").map((e=>e.trim())).filter((e=>null!=e&&""!==e));if(e.length){const n=[];for(let t=0;t<e.length/2;t+=2)n.push(e[t],e[t+1]);m=new t({rings:[n],spatialReference:{wkid:4326}})}}return{observation:{phonomenonTime:o,resultTime:r,footprint:m,identifier:a(e,"metaDataProperty/EarthObservationMetaData/identifier"),acquisitionType:a(e,"metaDataProperty/EarthObservationMetaData/acquisitionType"),status:a(e,"metaDataProperty/EarthObservationMetaData/status")}}}function O(e){const t={version:"2.0"};let n=[];for(let i=0;i<e.childNodes.length;i++){const l=e.childNodes[i];if(1===l.nodeType)if(s(l,"coverageId"))t.coverageId=a(l);else if(s(l,"ServiceParameters"))t.serviceParameters={supportedFormats:r(l,"nativeFormat")};else if(s(l,"boundedBy"))t.boundedBy=S(l);else if(s(l,"rangeType")){const e=C(l);t.rangeType=e.rangeType,n=e.bandNames}else if(s(l,"domainSet")){var o;t.domainSet=T(l,null==(o=t.boundedBy)?void 0:o.axisLabels)}else if(s(l,"metadata")){const e=p(l,"EOMetadata");t.eoMetadata=e?M(e):null}}const{coverageId:l,boundedBy:m,domainSet:u,rangeType:d,serviceParameters:c}=t,f=R(d,m,u);return{id:l,title:l,description:l,lonLatEnvelope:null,bandNames:n,rasterInfo:new i({width:u.columns,height:u.rows,pixelSize:u.resolution,extent:m.envelope,spatialReference:m.envelope.spatialReference,bandCount:n.length||1,multidimensionalInfo:f}),supportedFormats:c.supportedFormats,supportedInterpolations:null,coverageDescription:t,version:"2.0.1",useEPSGAxis:!1}}function P(e,t){let n=null;if("string"==typeof e){n=(new DOMParser).parseFromString(e,"text/xml")}else n=e;if("1.0.0"===t){return o(n,"CoverageOffering").map((e=>v(e)))}const i=o(n,"CoverageDescription");return"1.1.0"===t||"1.1.1"===t||"1.1.2"===t?i.map((e=>L(e,t))):i.map((e=>O(e)))}export{P as parseCoverages,c as standardizeInterpolations};
5
+ import e from"../../../geometry/Extent.js";import t from"../../../geometry/Polygon.js";import{isAxesOrderReversedForWkid as n}from"../../ogc/crsUtils.js";import i from"../RasterInfo.js";import{getElements as o,isSameTagIgnoreNS as s,getElementValue as a,getElementValues as r,getNodeNameIgnoreNS as l,getElement as u,getSpaceDelimitedNumericValues as p}from"./xmlUtilities.js";function m(e){return{requestResponseCRSs:r(e,"requestResponseCRSs").map((e=>e.split(":")[1])),nativeCRSs:r(e,"nativeCRSs").map((e=>e.split(":")[1]))}}function d(e,t){const n=r(e,"1.0.0"===t?"interpolationMethod":"InterpolationMethod"),i="1.0.0"===t?e.getAttribute("default"):a(e,"InterpolationMethods/Default");return null!=i?[i].concat(n.filter((e=>e.toLowerCase()!==i.toLowerCase()))):n}function c(e){return null==e?["nearest"]:e.map((e=>{const t=e.toLowerCase();return t.includes("nearest")?"nearest":t.includes("linear")?"bilinear":t.includes("cubic")?"cubic":null})).filter((e=>!!e))}function f(t){const n=o(t,"pos"),i=p(n[0]),s=p(n[1]);return new e({xmin:i[0],ymin:i[1],xmax:s[0],ymax:s[1],spatialReference:{wkid:4326}})}function g(e){const t=[],n=o(e,"RangeSet");let i=[];for(let s=0;s<n.length;s++){const e=a(n[s],"name"),l=a(n[s],"label"),u=[],p=o(n[s],"AxisDescription");for(let t=0;t<p.length;t++){const e=a(p[t],"name"),n=a(p[t],"label"),o=r(p[t],"singleValue");if(0===o.length){const e=a(p[t],"min"),n=a(p[t],"max"),i=Number(a(p[t],"res"))||1;if(null!==e&&null!==n)for(let t=parseInt(e,10);t<=parseInt(n,10);t+=i)o.push(t.toString())}"band"===e.toLowerCase()&&(i=o),u.push({name:e,label:n,values:o})}t.push({name:e,label:l,axis:u})}return{rangeSet:t,bandNames:i}}function h(e=null){if(!e)return{resolution:null,units:null};let t=e.toUpperCase();const n=["Y","M","D"],i=["H","M","S"],o=["Years","Months","Days","Hours","Minutes","Seconds"];let s,a,r;return t.includes("PT")?(t=t.slice(2),r=i.findIndex((e=>t.includes(e))),s=o[3+r],a=parseFloat(t.substring(0,t.length-1))):(t=t.slice(1),r=n.findIndex((e=>t.includes(e))),r>-1&&(s=o[r]),a=parseFloat(t.substring(0,t.length-1))),{resolution:a,units:s}}function b(e){const t=o(e,"timeposition");if(t.length>0){const e=[];for(let n=0;n<t.length;n++)e.push(new Date(a(t[n])));return{begin:e[0],end:e[e.length-1],values:e}}const n=u(e,"timePeriod")||u(e,"TimePeriod");if(n){return{begin:new Date(a(n,"beginPosition")||a(n,"BeginPosition")),end:new Date(a(n,"endPosition")||a(n,"EndPosition")),...h(a(n,"timeResolution")||a(n,"TimeResolution"))}}return null}function x(t){const n=u(t,"spatialDomain"),i=u(n,"Envelope")||u(n,"EnvelopeWithTimePeriod"),s=i.getAttribute("srsName").split(":"),r=s[s.length-1],l=o(i,"pos"),m=p(l[0]),d=p(l[1]),c=parseInt(r,10),f=isNaN(c)?null:{wkid:c},g=new e({xmin:m[0],ymin:m[1],xmax:d[0],ymax:d[1],spatialReference:f}),h=u(n,"RectifiedGrid"),x=a(h,"low").split(" "),v=a(h,"high").split(" "),w=parseInt(v[0],10)-parseInt(x[0],10)+1,y=parseInt(v[1],10)-parseInt(x[1],10)+1,D=p(n,"origin/pos"),L=o(n,"offsetVector"),S={envelope:g,columns:w,rows:y,offset:{x:parseFloat(a(L[0]).split(" ")[0]),y:parseFloat(a(L[1]).split(" ")[1])},origin:{x:D[0],y:D[1]}},C=u(t,"temporalDomain")||u(t,"TemporalDomain");return{spatialDomain:S,temporalDomain:C?b(C):null}}function v(e){const t={version:"1.0"};let n=[];for(let i=0;i<e.childNodes.length;i++){const o=e.childNodes[i];if(1===o.nodeType)if(s(o,"description"))t.description=a(o);else if(s(o,"name"))t.name=a(o);else if(s(o,"label"))t.label=a(o);else if(s(o,"supportedFormats"))t.supportedFormats=r(o,"formats");else if(s(o,"supportedCRSs"))t.supportedCRSs=m(o);else if(s(o,"supportedInterpolations"))t.supportedInterpolations=d(o,"1.0.0");else if(s(o,"lonLatEnvelope"))t.lonLatEnvelope=f(o);else if(s(o,"rangeSet")){const e=g(o);t.rangeSet=e.rangeSet,n=e.bandNames}else s(o,"domainSet")&&(t.domainSet=x(o))}const o=c(t.supportedInterpolations),{name:l,description:u,label:p,lonLatEnvelope:h,supportedFormats:b}=t,{spatialDomain:v}=t.domainSet,w={x:Math.abs(v.offset.x),y:Math.abs(v.offset.y)},y=new i({width:v.columns,height:v.rows,pixelSize:w,extent:v.envelope,spatialReference:v.envelope.spatialReference,bandCount:n.length||1});return{id:l,title:t.name,description:u||p,lonLatEnvelope:h,rasterInfo:y,bandNames:n,supportedFormats:b,supportedInterpolations:o,coverageDescription:t,version:"1.0.0",useEPSGAxis:!1}}function w(e){const t=[],n=o(e,"Field");let i=[];for(let s=0;s<n.length;s++){const e=a(n[s],"Identifier"),l=a(n[s],"Description"),u=a(n[s],"Definition"),p=a(n[s],"Abstract"),m=a(n[s],"Title"),c=d(n[s],"1.1.0"),f=[],g=o(n[s],"Axis");for(let t=0;t<g.length;t++){const e=g[t].getAttribute("identifier"),n=a(g[t],"UOM"),o=a(g[t],"DataType"),s=r(g[t],"Key");"band"===e.toLowerCase()&&(i=s),f.push({identifier:e,uom:n,dataType:o,values:s})}t.push({identifier:e,description:l,definition:u,abstract:p,title:m,supportedInterpolations:c,axis:f})}return{rangeSet:t,bandNames:i}}function y(e,t){const n=e.filter((e=>!e.identifier.toLowerCase().includes("field_1")&&!e.axis.some((e=>"band"===e.identifier.toLowerCase())))),i=[];if(n.length&&n.forEach((e=>{var t,n;const o=e.axis.map((e=>{const t=e.values.map((t=>{if("ISO8601"===e.uom){return(t=t.trim()).toLowerCase().includes("z")?new Date(t).getTime():new Date(t+"Z").getTime()}return parseFloat(t.trim())})),n=[Math.min.apply(null,t),Math.max.apply(null,t)];return{name:e.identifier.trim(),description:"",field:e.identifier.trim(),unit:e.uom?e.uom.trim():"",hasRegularIntervals:!1,values:t,extent:n}}));i.push({name:e.identifier.trim(),description:null!=(t=null==(n=e.description)?void 0:n.trim())?t:"",unit:"",dimensions:o})})),t.temporalDomain){const{begin:e,end:n,values:o,units:s,resolution:a}=t.temporalDomain;i.some((e=>e.dimensions.some((e=>"stdtime"===e.name.toLowerCase()))))||i.forEach((t=>{t.dimensions.push({name:"StdTime",description:"",unit:"ISO8601",values:null==o?void 0:o.map((e=>e.getTime())),hasRegularIntervals:!o,interval:a,intervalUnit:s,extent:[e.getTime(),n.getTime()]})}))}return i.length?{variables:i}:null}function D(t){var i;const s=u(t,"SpatialDomain"),r=u(s,"GridCRS"),l=a(r,"GridBaseCRS"),m=a(r,"GridOrigin"),d=null!=(i=null==m?void 0:m.split(" ").map((e=>parseFloat(e))))?i:[0,0],c=p(r,"GridOffsets"),f=o(s,"BoundingBox");let g,h,x,v;for(let n=0;n<f.length;n++){var w;const t=null==(w=f[n].getAttribute("crs"))?void 0:w.toLowerCase();if(null!=t)if(t.includes("imagecrs")){const e=p(f[n],"LowerCorner"),t=p(f[n],"UpperCorner");g=t[0]-e[0]+1,h=t[1]-e[1]+1}else if(t.indexOf("epsg")>0){const i=t.split(":");x=parseInt(i[i.length-1],10);const o=p(f[n],"LowerCorner"),s=p(f[n],"UpperCorner");v=new e({xmin:o[0],ymin:o[1],xmax:s[0],ymax:s[1],spatialReference:{wkid:x}})}}const y=g>h,D=v.xmax-v.xmin>v.ymax-v.ymin;let L=!1;n(x)&&(y===D?L=!1:(L=!0,v=new e({xmin:v.ymin,ymin:v.xmin,xmax:v.ymax,ymax:v.xmax,spatialReference:{wkid:x}})));const S={columns:g,rows:h,origin:{x:d[0],y:d[1]},offset:{x:c[0],y:c[1]},gridBaseCRS:l,envelope:v,useEPSGAxis:L},C=u(t,"temporalDomain")||u(t,"TemporalDomain");return{spatialDomain:S,temporalDomain:C?b(C):null}}function L(e,t){const n=[],o=[],s={supportedFormats:n,supportedCRSs:o,version:"1.1"};let r;for(let i=0;i<e.childNodes.length;i++){const t=e.childNodes[i];if(1!==t.nodeType)continue;const u=l(t).toLowerCase();switch(u){case"title":case"abstract":case"identifier":s[u]=a(t);break;case"supportedformat":{const e=a(t);n.includes(e)||n.push(e)}break;case"supportedcrs":{const e=a(t);o.includes(e)||o.push(e)}break;case"range":{const e=w(t);s.range=e.rangeSet,r=e.bandNames}break;case"domain":s.domain=D(t)}}const u=c(s.range[0].supportedInterpolations),{identifier:p,abstract:m,title:d,domain:f,range:g}=s,h={x:Math.abs(f.spatialDomain.offset.x),y:Math.abs(f.spatialDomain.offset.y)},b=y(g,f),x=new i({width:f.spatialDomain.columns,height:f.spatialDomain.rows,pixelSize:h,extent:f.spatialDomain.envelope,spatialReference:f.spatialDomain.envelope.spatialReference,bandCount:r.length||1,multidimensionalInfo:b});return{id:p,title:s.title,description:m||d,lonLatEnvelope:null,bandNames:r,rasterInfo:x,supportedFormats:n,supportedInterpolations:u,coverageDescription:s,version:t,useEPSGAxis:f.spatialDomain.useEPSGAxis}}function S(t){const n=u(t,"Envelope")||u(t,"EnvelopeWithTimePeriod"),i=n.getAttribute("srsName"),o=i.slice(i.lastIndexOf("/")+1),r=n.getAttribute("axisLabels").split(" ").map((e=>e.trim())).filter((e=>""!==e.trim())),l=p(n,"lowerCorner"),m=p(n,"upperCorner"),d=!["y","lat","latitude","north","nor","n","b"].includes(r[0].toLowerCase());let c;const f=parseInt(o,10),g=isNaN(f)?null:{wkid:f};c=new e(d?{xmin:l[0],ymin:l[1],xmax:m[0],ymax:m[1],spatialReference:g}:{xmin:l[1],ymin:l[0],xmax:m[1],ymax:m[0],spatialReference:g});const h={mins:l,maxs:m},b=n.getAttribute("uomLabels").trim().split(" ");let x,v;return s(n,"EnvelopeWithTimePeriod")&&(x=new Date(a(t,"beginPosition")||a(t,"BeginPosition")),v=new Date(a(t,"endPosition")||a(t,"EndPosition"))),{envelope:c,axisLabels:r,uomLabels:b.length?b:null,envelopeAllDims:h,beginPosition:x,endPosition:v,isEastFirst:d}}function C(e){const t=[],n=o(e,"DataRecord"),i=[];for(let r=0;r<n.length;r++){const e=o(n[r],"field"),l=[];for(let t=0;t<e.length;t++){var s;const n=e[t].getAttribute("name"),o=a(e[t],"description")||"",r=(null==(s=u(e[t],"uom"))?void 0:s.getAttribute("code"))||"",m=p(e[t],"interval");n.toLowerCase().includes("band")&&i.push(n),l.push({name:n,description:o,uom:r,allowedValues:m})}t.push(l)}return{rangeType:t,bandNames:i}}function I(e){let t=1,n="";const i=.01;return Math.abs(e-1/24)<1/24*i?n="Hours":Math.abs(e-1)<1*i?n="Days":e<1?(t=Math.round(24*e),n="Hours"):e>28-i&&e<31+i||Math.round(e/30)<12?n="Months":e>365-i&&e<366+i&&(n="Years"),{interval:t,intervalUnit:n}}function R(e,t,n){const i=[];for(let s=0;s<e.length;s++){const t=e[s];for(let e=0;e<t.length;e++)t[e].name.toLowerCase().includes("band")||i.push(t[e])}const o=[];if(i.length){const e=[];for(let i=2;i<n.axisLabels.length;i++){const o=(t.uomLabels&&t.uomLabels.length)>i?t.uomLabels[i]:"",s=n.axisLabels[i].toLowerCase().includes("time")||"iso8601"===o.toLowerCase()||"oledatetime"===o.toLowerCase();let a,r;if(s){const e=I(n.offset[i]);a=e.interval,r=e.intervalUnit}else a=n.offset[i],r=o;const l=[];s?(l.push((new Date).setTime(24*(t.envelopeAllDims.mins[i]-25569)*3600*1e3)),l.push((new Date).setTime(24*(t.envelopeAllDims.maxs[i]-25569)*3600*1e3))):(l.push(t.envelopeAllDims.mins[i]),l.push(t.envelopeAllDims.maxs[i])),e.push({name:n.axisLabels[i].trim(),description:n.axisLabels[i].trim(),unit:t.uomLabels&&t.uomLabels.length>i?t.uomLabels[i].trim():"",hasRegularIntervals:!0,extent:l,interval:a,intervalUnit:r})}if(i.forEach((t=>{var n,i;return o.push({name:t.name.trim(),description:null!=(n=null==(i=t.description)?void 0:i.trim())?n:"",unit:t.uom.trim(),dimensions:e})})),o.length)return{variables:o}}return null}function T(e,t){const n=u(e,"RectifiedGrid"),i=p(n,"low"),s=p(n,"high"),r=[];for(let o=0;o<i.length;o++)r.push(s[o]-i[o]+1);const l=a(n,"axisLabels").split(" "),m=p(n,"origin/pos"),d=o(n,"offsetVector"),c=[];for(let o=0;o<d.length;o++){const e=p(d[o]),t=e.findIndex((e=>0!==e));c[t]=e[t]}let f,g,h;return["y","lat","latitude","north","nor","n","b"].includes((t||l)[0].toLowerCase())?(f=r[1],g=r[0],h={y:Math.abs(c[0]),x:Math.abs(c[1])}):(f=r[0],g=r[1],h={x:Math.abs(c[0]),y:Math.abs(c[1])}),{columns:f,rows:g,origin:m,offset:c,resolution:h,gridSamples:r,axisLabels:l}}function M(e){const n=u(e,"EarthObservation");if(!n)return null;const i=u(n,"phenomenonTime"),o=i?b(i):null,s=u(n,"phenomenonTime"),r=s?b(s):null,l=a(n,"featureOfInterest/Footprint/multiExtentOf/MultiSurface/surfaceMembers/Polygon/exterior/LinearRing/posList");let p=null;if(l){const e=l.split(" ").map((e=>e.trim())).filter((e=>null!=e&&""!==e));if(e.length){const n=[];for(let t=0;t<e.length/2;t+=2)n.push(e[t],e[t+1]);p=new t({rings:[n],spatialReference:{wkid:4326}})}}return{observation:{phonomenonTime:o,resultTime:r,footprint:p,identifier:a(e,"metaDataProperty/EarthObservationMetaData/identifier"),acquisitionType:a(e,"metaDataProperty/EarthObservationMetaData/acquisitionType"),status:a(e,"metaDataProperty/EarthObservationMetaData/status")}}}function P(e){const t={version:"2.0"};let n=[];for(let i=0;i<e.childNodes.length;i++){const l=e.childNodes[i];if(1===l.nodeType)if(s(l,"coverageId"))t.coverageId=a(l);else if(s(l,"ServiceParameters"))t.serviceParameters={supportedFormats:r(l,"nativeFormat")};else if(s(l,"boundedBy"))t.boundedBy=S(l);else if(s(l,"rangeType")){const e=C(l);t.rangeType=e.rangeType,n=e.bandNames}else if(s(l,"domainSet")){var o;t.domainSet=T(l,null==(o=t.boundedBy)?void 0:o.axisLabels)}else if(s(l,"metadata")){const e=u(l,"EOMetadata");t.eoMetadata=e?M(e):null}}const{coverageId:l,boundedBy:p,domainSet:m,rangeType:d,serviceParameters:c}=t,f=R(d,p,m);return{id:l,title:l,description:l,lonLatEnvelope:null,bandNames:n,rasterInfo:new i({width:m.columns,height:m.rows,pixelSize:m.resolution,extent:p.envelope,spatialReference:p.envelope.spatialReference,bandCount:n.length||1,multidimensionalInfo:f}),supportedFormats:c.supportedFormats,supportedInterpolations:null,coverageDescription:t,version:"2.0.1",useEPSGAxis:!1}}function E(e,t){let n=null;if("string"==typeof e){n=(new DOMParser).parseFromString(e,"text/xml")}else n=e;if("1.0.0"===t){return o(n,"CoverageOffering").map((e=>v(e)))}const i=o(n,"CoverageDescription");return"1.1.0"===t||"1.1.1"===t||"1.1.2"===t?i.map((e=>L(e,t))):i.map((e=>P(e)))}export{E as parseCoverages,c as standardizeInterpolations};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- function n(e,t){if(!e||!t)return[];let l=t;t.indexOf("/")>-1?(l=t.slice(0,t.indexOf("/")),t=t.slice(t.indexOf("/")+1)):t="";const r=[];if(t){const u=n(e,l);for(let e=0;e<u.length;e++){n(u[e],t).forEach((n=>r.push(n)))}return r}const u=e.getElementsByTagNameNS("*",l);if(!u||0===u.length)return[];for(let n=0;n<u.length;n++)r.push(u[n]||u.item[n]);return r}function e(t,l){if(!t||!l)return null;let r=l;l.indexOf("/")>-1?(r=l.slice(0,l.indexOf("/")),l=l.slice(l.indexOf("/")+1)):l="";const u=n(t,r);return u.length>0?l?e(u[0],l):u[0]:null}function t(n,t=null){const l=t?e(n,t):n;let r;return l?(r=l.textContent||l.nodeValue,r?r.trim():null):null}function l(e,t){const l=n(e,t),r=[];let u;for(let n=0;n<l.length;n++)u=l[n].textContent||l[n].nodeValue,u&&(u=u.trim(),""!==u&&r.push(u));return r}function r(n,e=null){const l=t(n,e);return null==l?void 0:l.split(" ").map((n=>Number(n)))}function u(n,e){return l(n,e).map((n=>Number(n)))}function o(n,e){const l=t(n,e);return Number(l)}function i(n,e){var t;const l=null==n||null==(t=n.nodeName)?void 0:t.toLowerCase(),r=e.toLowerCase();return l.slice(l.lastIndexOf(":")+1)===r}function c(n){return n.nodeName.slice(n.nodeName.lastIndexOf(":")+1)}export{e as getElement,o as getElementNumericValue,u as getElementNumericValues,t as getElementValue,l as getElementValues,n as getElements,c as getNodeNameIgnoreNS,r as getSpaceDelimitedNumericValues,i as isSameTagIgnoreNS};
5
+ function n(e,t){if(!e||!t)return[];let l=t;t.includes("/")?(l=t.slice(0,t.indexOf("/")),t=t.slice(t.indexOf("/")+1)):t="";const u=[];if(t){const r=n(e,l);for(let e=0;e<r.length;e++){n(r[e],t).forEach((n=>u.push(n)))}return u}const r=e.getElementsByTagNameNS("*",l);if(!r||0===r.length)return[];for(let n=0;n<r.length;n++)u.push(r[n]||r.item[n]);return u}function e(t,l){if(!t||!l)return null;let u=l;l.includes("/")?(u=l.slice(0,l.indexOf("/")),l=l.slice(l.indexOf("/")+1)):l="";const r=n(t,u);return r.length>0?l?e(r[0],l):r[0]:null}function t(n,t=null){const l=t?e(n,t):n;let u;return l?(u=l.textContent||l.nodeValue,u?u.trim():null):null}function l(e,t){const l=n(e,t),u=[];let r;for(let n=0;n<l.length;n++)r=l[n].textContent||l[n].nodeValue,r&&(r=r.trim(),""!==r&&u.push(r));return u}function u(n,e=null){const l=t(n,e);return null==l?void 0:l.split(" ").map((n=>Number(n)))}function r(n,e){return l(n,e).map((n=>Number(n)))}function o(n,e){const l=t(n,e);return Number(l)}function i(n,e){var t;const l=null==n||null==(t=n.nodeName)?void 0:t.toLowerCase(),u=e.toLowerCase();return l.slice(l.lastIndexOf(":")+1)===u}function c(n){return n.nodeName.slice(n.nodeName.lastIndexOf(":")+1)}export{e as getElement,o as getElementNumericValue,r as getElementNumericValues,t as getElementValue,l as getElementValues,n as getElements,c as getNodeNameIgnoreNS,u as getSpaceDelimitedNumericValues,i as isSameTagIgnoreNS};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import t from"../../../core/Error.js";import e from"../PixelBlock.js";import i from"./ImageCanvasDecoder.js";import a from"./JpgPlus.js";import{load as s,decode as r}from"./Lerc.js";import{decode as n}from"./Lzw.js";import{Z as o}from"../../../chunks/Zlib.js";import h from"./Raw.js";import{decodeTileOrStrip as c,decode as p}from"./TiffDecoder.js";import{isPlatformLittleEndian as l}from"./utils.js";var d=function(t){var e,i,a,s,r,n;function h(t){var e,i,a,s,r,n,o,h,c,p,l,d,f;for(this.data=t,this.pos=8,this.palette=[],this.imgData=[],this.transparency={},this.animation=null,this.text={},r=null;;){switch(e=this.readUInt32(),h=function(){var t,e;for(e=[],t=0;t<4;++t)e.push(String.fromCharCode(this.data[this.pos++]));return e}.call(this).join(""),h){case"IHDR":this.width=this.readUInt32(),this.height=this.readUInt32(),this.bits=this.data[this.pos++],this.colorType=this.data[this.pos++],this.compressionMethod=this.data[this.pos++],this.filterMethod=this.data[this.pos++],this.interlaceMethod=this.data[this.pos++];break;case"acTL":this.animation={numFrames:this.readUInt32(),numPlays:this.readUInt32()||1/0,frames:[]};break;case"PLTE":this.palette=this.read(e);break;case"fcTL":r&&this.animation.frames.push(r),this.pos+=4,r={width:this.readUInt32(),height:this.readUInt32(),xOffset:this.readUInt32(),yOffset:this.readUInt32()},s=this.readUInt16(),a=this.readUInt16()||100,r.delay=1e3*s/a,r.disposeOp=this.data[this.pos++],r.blendOp=this.data[this.pos++],r.data=[];break;case"IDAT":case"fdAT":for("fdAT"===h&&(this.pos+=4,e-=4),t=(null!=r?r.data:void 0)||this.imgData,l=0;0<=e?l<e:l>e;0<=e?++l:--l)t.push(this.data[this.pos++]);break;case"tRNS":switch(this.transparency={},this.colorType){case 3:if(this.transparency.indexed=this.read(e),(c=255-this.transparency.indexed.length)>0)for(d=0;0<=c?d<c:d>c;0<=c?++d:--d)this.transparency.indexed.push(255);break;case 0:this.transparency.grayscale=this.read(e)[0];break;case 2:this.transparency.rgb=this.read(e)}break;case"tEXt":n=(p=this.read(e)).indexOf(0),o=String.fromCharCode.apply(String,p.slice(0,n)),this.text[o]=String.fromCharCode.apply(String,p.slice(n+1));break;case"IEND":return r&&this.animation.frames.push(r),this.colors=function(){switch(this.colorType){case 0:case 3:case 4:return 1;case 2:case 6:return 3}}.call(this),this.hasAlphaChannel=4===(f=this.colorType)||6===f,i=this.colors+(this.hasAlphaChannel?1:0),this.pixelBitlength=this.bits*i,this.colorSpace=function(){switch(this.colors){case 1:return"DeviceGray";case 3:return"DeviceRGB"}}.call(this),void(this.imgData=new Uint8Array(this.imgData));default:this.pos+=e}if(this.pos+=4,this.pos>this.data.length)throw new Error("Incomplete or corrupt PNG file")}}return h.load=function(t,e,i){var a;return"function"==typeof e&&(i=e),(a=new XMLHttpRequest).open("GET",t,!0),a.responseType="arraybuffer",a.onload=function(){var t;return t=new h(new Uint8Array(a.response||a.mozResponseArrayBuffer)),"function"==typeof(null!=e?e.getContext:void 0)&&t.render(e),"function"==typeof i?i(t):void 0},a.send(null)},i=1,a=2,e=0,h.prototype.read=function(t){var e,i;for(i=[],e=0;0<=t?e<t:e>t;0<=t?++e:--e)i.push(this.data[this.pos++]);return i},h.prototype.readUInt32=function(){return this.data[this.pos++]<<24|this.data[this.pos++]<<16|this.data[this.pos++]<<8|this.data[this.pos++]},h.prototype.readUInt16=function(){return this.data[this.pos++]<<8|this.data[this.pos++]},h.prototype.decodePixels=function(t){var e,i,a,s,r,n,h,c,p,l,d,f,u,m,g,w,y,x,b,k,T,U,v;if(null==t&&(t=this.imgData),0===t.length)return new Uint8Array(0);for(t=(t=new o(t)).getBytes(),w=(f=this.pixelBitlength/8)*this.width,u=new Uint8Array(w*this.height),n=t.length,g=0,m=0,i=0;m<n;){switch(t[m++]){case 0:for(s=b=0;b<w;s=b+=1)u[i++]=t[m++];break;case 1:for(s=k=0;k<w;s=k+=1)e=t[m++],r=s<f?0:u[i-f],u[i++]=(e+r)%256;break;case 2:for(s=T=0;T<w;s=T+=1)e=t[m++],a=(s-s%f)/f,y=g&&u[(g-1)*w+a*f+s%f],u[i++]=(y+e)%256;break;case 3:for(s=U=0;U<w;s=U+=1)e=t[m++],a=(s-s%f)/f,r=s<f?0:u[i-f],y=g&&u[(g-1)*w+a*f+s%f],u[i++]=(e+Math.floor((r+y)/2))%256;break;case 4:for(s=v=0;v<w;s=v+=1)e=t[m++],a=(s-s%f)/f,r=s<f?0:u[i-f],0===g?y=x=0:(y=u[(g-1)*w+a*f+s%f],x=a&&u[(g-1)*w+(a-1)*f+s%f]),h=r+y-x,c=Math.abs(h-r),l=Math.abs(h-y),d=Math.abs(h-x),p=c<=l&&c<=d?r:l<=d?y:x,u[i++]=(e+p)%256;break;default:throw new Error("Invalid filter algorithm: "+t[m-1])}g++}return u},h.prototype.decodePalette=function(){var t,e,i,a,s,r,n,o,h;for(i=this.palette,r=this.transparency.indexed||[],s=new Uint8Array((r.length||0)+i.length),a=0,t=0,e=n=0,o=i.length;n<o;e=n+=3)s[a++]=i[e],s[a++]=i[e+1],s[a++]=i[e+2],s[a++]=null!=(h=r[t++])?h:255;return s},h.prototype.copyToImageData=function(t,e){var i,a,s,r,n,o,h,c,p,l,d;if(a=this.colors,p=null,i=this.hasAlphaChannel,this.palette.length&&(p=null!=(d=this._decodedPalette)?d:this._decodedPalette=this.decodePalette(),a=4,i=!0),c=(s=t.data||t).length,n=p||e,r=o=0,1===a)for(;r<c;)h=p?4*e[r/4]:o,l=n[h++],s[r++]=l,s[r++]=l,s[r++]=l,s[r++]=i?n[h++]:this.transparency.grayscale&&this.transparency.grayscale===l?0:255,o=h;else for(;r<c;)h=p?4*e[r/4]:o,s[r++]=n[h++],s[r++]=n[h++],s[r++]=n[h++],s[r++]=i?n[h++]:this.transparency.rgb&&this.transparency.rgb[1]===n[h-3]&&this.transparency.rgb[3]===n[h-2]&&this.transparency.rgb[5]===n[h-1]?0:255,o=h},h.prototype.decode=function(){var t;return t=new Uint8Array(this.width*this.height*4),this.copyToImageData(t,this.decodePixels()),t},r=t.document&&t.document.createElement("canvas"),n=r&&r.getContext("2d"),s=function(t){var e;return n.width=t.width,n.height=t.height,n.clearRect(0,0,t.width,t.height),n.putImageData(t,0,0),(e=new Image).src=r.toDataURL(),e},h.prototype.decodeFrames=function(t){var e,i,a,r,n,o,h,c;if(this.animation){for(c=[],i=n=0,o=(h=this.animation.frames).length;n<o;i=++n)e=h[i],a=t.createImageData(e.width,e.height),r=this.decodePixels(new Uint8Array(e.data)),this.copyToImageData(a,r),e.imageData=a,c.push(e.image=s(a));return c}},h.prototype.renderFrame=function(t,s){var r,n,o;return r=(n=this.animation.frames)[s],o=n[s-1],0===s&&t.clearRect(0,0,this.width,this.height),(null!=o?o.disposeOp:void 0)===i?t.clearRect(o.xOffset,o.yOffset,o.width,o.height):(null!=o?o.disposeOp:void 0)===a&&t.putImageData(o.imageData,o.xOffset,o.yOffset),r.blendOp===e&&t.clearRect(r.xOffset,r.yOffset,r.width,r.height),t.drawImage(r.image,r.xOffset,r.yOffset)},h.prototype.animate=function(t){var e,i,a,s,r,n,o=this;return i=0,n=this.animation,s=n.numFrames,a=n.frames,r=n.numPlays,(e=function(){var n,h;if(n=i++%s,h=a[n],o.renderFrame(t,n),s>1&&i/s<r)return o.animation._timeout=setTimeout(e,h.delay)})()},h.prototype.stopAnimation=function(){var t;return clearTimeout(null!=(t=this.animation)?t._timeout:void 0)},h.prototype.render=function(t){var e,i;return t._png&&t._png.stopAnimation(),t._png=this,t.width=this.width,t.height=this.height,e=t.getContext("2d"),this.animation?(this.decodeFrames(e),this.animate(e)):(i=e.createImageData(this.width,this.height),this.copyToImageData(i,this.decodePixels()),e.putImageData(i,0,0))},h}(self);const f=new Set(["jpg","png","bmp","gif"]),u=new Set(["S8","U8","S16","U16","S32","U32","F32","F64"]);async function m(i,a){var n;if(!l)throw new t("rasterCoded:decode","lerc decoder is not supported on big endian platform");await s();const{offset:o,noDataValue:h}=a;let c=null==(n=a.pixelType)?void 0:n.toUpperCase();c&&!u.has(c)&&(c=null);const{width:p,height:d,pixelType:f,statistics:m,pixels:g,mask:w}=r(i,{inputOffset:o,noDataValue:h,pixelType:c});return new e({width:p,height:d,pixelType:f.toLowerCase(),pixels:g,mask:w,statistics:m})}async function g(t,i){const a=await p(t,i.pyramidLevel||0),s=new e({width:a.width,height:a.height,pixels:a.pixels,pixelType:a.pixelType.toLowerCase(),mask:a.mask,statistics:null});return s.updateStatistics(),s}async function w(t,i){const a=await c(t,i.customOptions),s=new e({width:a.width,height:a.height,pixels:a.pixels,pixelType:a.pixelType.toLowerCase(),mask:a.mask,statistics:null});return s.updateStatistics(),s}function y(t,i){const a=i.pixelType||"u8",s=e.getPixelArrayConstructor(a),r="u8"===a?t:new s(t.buffer),n=[],o=i.planes||1;if(1===o)n.push(r);else for(let e=0;e<o;e++){const a=(i.width||1)*(i.height||t.length),h=new s(a);for(let t=0;t<a;t++)h[t]=r[t*o+e];n.push(h)}const h=new e({width:i.width||1,height:i.height||t.length,pixels:n,pixelType:a,statistics:null});return h.updateStatistics(),h}function x(t,e){return y(new o(new Uint8Array(t)).getBytes(),e)}function b(t,e){return y(n(t,e.offset,e.eof,!e.isInputBigEndian),e)}function k(t,i,a){const{pixelTypeCtor:s}=A(i.pixelType),r=(0,h.decode)(t,{width:i.width,height:i.height,pixelType:s,format:a}),n=new e({width:i.width,height:i.height,pixels:r.pixels,pixelType:i.pixelType,mask:r.mask,statistics:null});return n.updateStatistics(),n}function T(t){const i=a.decode(t),s=new e({width:i.width,height:i.height,pixels:i.pixels,pixelType:"U8",mask:i.mask,statistics:null});return s.updateStatistics(),s}function U(t,i){const a=new Uint8Array(t),s=new d(a),{width:r,height:n}=i,o=r*n,h=s.decode();let c,p=0,l=0;const f=new Uint8Array(o);for(p=0;p<o;p++)f[p]=h[4*p+3];const u=new e({width:r,height:n,pixels:[],pixelType:"U8",mask:f,statistics:[]});for(p=0;p<3;p++){for(c=new Uint8Array(o),l=0;l<o;l++)c[l]=h[4*l+p];u.addData({pixels:c})}return u.updateStatistics(),u}async function v(t,a,s,r){const n=new i,o={applyJpegMask:!1,format:a,...s},h=await n.decode(t,o,r),c=new e(h);return c.updateStatistics(),c}function I(e){if(null==e)throw new t("rasterCodec:decode","parameter encodeddata is required.");const i=new Uint8Array(e,0,10);let a="";return 255===i[0]&&216===i[1]?a="jpg":137===i[0]&&80===i[1]&&78===i[2]&&71===i[3]?a="png":67===i[0]&&110===i[1]&&116===i[2]&&90===i[3]&&73===i[4]&&109===i[5]&&97===i[6]&&103===i[7]&&101===i[8]&&32===i[9]?a="lerc":76===i[0]&&101===i[1]&&114===i[2]&&99===i[3]&&50===i[4]&&32===i[5]?a="lerc2":73===i[0]&&73===i[1]&&42===i[2]&&0===i[3]||77===i[0]&&77===i[1]&&0===i[2]&&42===i[3]||73===i[0]&&73===i[1]&&43===i[2]&&0===i[3]||77===i[0]&&77===i[1]&&0===i[2]&&43===i[3]?a="tiff":71===i[0]&&73===i[1]&&70===i[2]?a="gif":66===i[0]&&77===i[1]?a="bmp":String.fromCharCode.apply(null,i).toLowerCase().indexOf("error")>-1&&(a="error"),a}function C(e){let i=null;switch(e){case"lerc":case"lerc2":i=m;break;case"jpg":i=T;break;case"png":i=U;break;case"bsq":case"bip":i=(t,i)=>k(t,i,e);break;case"tiff":i=g;break;case"deflate":i=x;break;case"lzw":i=b;break;case"error":i=()=>{throw new t("rasterCodec:decode","input data contains error")};break;default:i=()=>{throw new t("rasterCodec:decode","unsupported raster format")}}return i}function A(t){let e=null,i=null;switch(t?t.toLowerCase():"f32"){case"u1":case"u2":case"u4":case"u8":i=255,e=Uint8Array;break;case"u16":i=i||65535,e=Uint16Array;break;case"u32":i=i||2**32-1,e=Uint32Array;break;case"s8":i=i||-128,e=Int8Array;break;case"s16":i=i||-32768,e=Int16Array;break;case"s32":i=i||0-2**31,e=Int32Array;break;default:e=Float32Array}return{pixelTypeCtor:e,noDataValue:i}}function D(t,i=1){if(!t)return;const{pixels:a,width:s,height:r,mask:n}=t;if(!a||0===a.length)return;const o=a.length,h=s-1,c=r-1,p=[];let l,d,f,u,m,g,w;const y=e.getPixelArrayConstructor(t.pixelType);if(0===i){for(l=0;l<o;l++){for(m=a[l],g=new y(h*c),d=0;d<c;d++)for(u=d*s,f=0;f<h;f++)g[d*h+f]=m[u+f];p.push(g)}if(n)for(w=new Uint8Array(h*c),d=0;d<c;d++)for(u=d*s,f=0;f<h;f++)w[d*h+f]=n[u+f]}else{for(l=0;l<o;l++){for(m=a[l],g=new y(h*c),d=0;d<c;d++)for(u=d*s,f=0;f<h;f++)g[d*h+f]=(m[u+f]+m[u+f+1]+m[u+s+f]+m[u+s+f+1])/4;p.push(g)}if(n)for(w=new Uint8Array(h*c),d=0;d<c;d++)for(u=d*s,f=0;f<h;f++)w[d*h+f]=Math.min.apply(null,[n[u+f],n[u+f+1],n[u+s+f],n[u+s+f+1]])}t.width=h,t.height=c,t.mask=w,t.pixels=p}function O(t){let e=I(t);return"lerc2"===e?e="lerc":"error"===e&&(e=""),e}async function S(e,i={},a){if(null==e)throw new t("rasterCodec:decode","missing encodeddata parameter.");let s,r,n=i.format&&i.format.toLowerCase();if(!("bsq"!==n&&"bip"!==n||null!=i.width&&null!=i.height))throw new t("rasterCodec:decode","requires width and height in options parameter.");return"tiff"===n&&i.customOptions?w(e,i):((!n||"bsq"!==n&&"bip"!==n&&"deflate"!==n&&"lzw"!==n)&&(n=I(e)),i.useCanvas&&f.has(n)?r=await v(e,n,i,a):(s=C(n),i.isPoint&&((i={...i}).width++,i.height++),r=await s(e,i),i.isPoint&&D(r)),r)}export{S as decode,O as getFormat};
5
+ import t from"../../../core/Error.js";import e from"../PixelBlock.js";import i from"./ImageCanvasDecoder.js";import a from"./JpgPlus.js";import{load as s,decode as r}from"./Lerc.js";import{decode as n}from"./Lzw.js";import{Z as o}from"../../../chunks/Zlib.js";import h from"./Raw.js";import{decodeTileOrStrip as c,decode as p}from"./TiffDecoder.js";import{isPlatformLittleEndian as l}from"./utils.js";var d=function(t){var e,i,a,s,r,n;function h(t){var e,i,a,s,r,n,o,h,c,p,l,d,u;for(this.data=t,this.pos=8,this.palette=[],this.imgData=[],this.transparency={},this.animation=null,this.text={},r=null;;){switch(e=this.readUInt32(),h=function(){var t,e;for(e=[],t=0;t<4;++t)e.push(String.fromCharCode(this.data[this.pos++]));return e}.call(this).join(""),h){case"IHDR":this.width=this.readUInt32(),this.height=this.readUInt32(),this.bits=this.data[this.pos++],this.colorType=this.data[this.pos++],this.compressionMethod=this.data[this.pos++],this.filterMethod=this.data[this.pos++],this.interlaceMethod=this.data[this.pos++];break;case"acTL":this.animation={numFrames:this.readUInt32(),numPlays:this.readUInt32()||1/0,frames:[]};break;case"PLTE":this.palette=this.read(e);break;case"fcTL":r&&this.animation.frames.push(r),this.pos+=4,r={width:this.readUInt32(),height:this.readUInt32(),xOffset:this.readUInt32(),yOffset:this.readUInt32()},s=this.readUInt16(),a=this.readUInt16()||100,r.delay=1e3*s/a,r.disposeOp=this.data[this.pos++],r.blendOp=this.data[this.pos++],r.data=[];break;case"IDAT":case"fdAT":for("fdAT"===h&&(this.pos+=4,e-=4),t=(null!=r?r.data:void 0)||this.imgData,l=0;0<=e?l<e:l>e;0<=e?++l:--l)t.push(this.data[this.pos++]);break;case"tRNS":switch(this.transparency={},this.colorType){case 3:if(this.transparency.indexed=this.read(e),(c=255-this.transparency.indexed.length)>0)for(d=0;0<=c?d<c:d>c;0<=c?++d:--d)this.transparency.indexed.push(255);break;case 0:this.transparency.grayscale=this.read(e)[0];break;case 2:this.transparency.rgb=this.read(e)}break;case"tEXt":n=(p=this.read(e)).indexOf(0),o=String.fromCharCode.apply(String,p.slice(0,n)),this.text[o]=String.fromCharCode.apply(String,p.slice(n+1));break;case"IEND":return r&&this.animation.frames.push(r),this.colors=function(){switch(this.colorType){case 0:case 3:case 4:return 1;case 2:case 6:return 3}}.call(this),this.hasAlphaChannel=4===(u=this.colorType)||6===u,i=this.colors+(this.hasAlphaChannel?1:0),this.pixelBitlength=this.bits*i,this.colorSpace=function(){switch(this.colors){case 1:return"DeviceGray";case 3:return"DeviceRGB"}}.call(this),void(this.imgData=new Uint8Array(this.imgData));default:this.pos+=e}if(this.pos+=4,this.pos>this.data.length)throw new Error("Incomplete or corrupt PNG file")}}return h.load=function(t,e,i){var a;return"function"==typeof e&&(i=e),(a=new XMLHttpRequest).open("GET",t,!0),a.responseType="arraybuffer",a.onload=function(){var t;return t=new h(new Uint8Array(a.response||a.mozResponseArrayBuffer)),"function"==typeof(null!=e?e.getContext:void 0)&&t.render(e),"function"==typeof i?i(t):void 0},a.send(null)},i=1,a=2,e=0,h.prototype.read=function(t){var e,i;for(i=[],e=0;0<=t?e<t:e>t;0<=t?++e:--e)i.push(this.data[this.pos++]);return i},h.prototype.readUInt32=function(){return this.data[this.pos++]<<24|this.data[this.pos++]<<16|this.data[this.pos++]<<8|this.data[this.pos++]},h.prototype.readUInt16=function(){return this.data[this.pos++]<<8|this.data[this.pos++]},h.prototype.decodePixels=function(t){var e,i,a,s,r,n,h,c,p,l,d,u,f,m,g,w,y,x,b,k,T,U,v;if(null==t&&(t=this.imgData),0===t.length)return new Uint8Array(0);for(t=(t=new o(t)).getBytes(),w=(u=this.pixelBitlength/8)*this.width,f=new Uint8Array(w*this.height),n=t.length,g=0,m=0,i=0;m<n;){switch(t[m++]){case 0:for(s=b=0;b<w;s=b+=1)f[i++]=t[m++];break;case 1:for(s=k=0;k<w;s=k+=1)e=t[m++],r=s<u?0:f[i-u],f[i++]=(e+r)%256;break;case 2:for(s=T=0;T<w;s=T+=1)e=t[m++],a=(s-s%u)/u,y=g&&f[(g-1)*w+a*u+s%u],f[i++]=(y+e)%256;break;case 3:for(s=U=0;U<w;s=U+=1)e=t[m++],a=(s-s%u)/u,r=s<u?0:f[i-u],y=g&&f[(g-1)*w+a*u+s%u],f[i++]=(e+Math.floor((r+y)/2))%256;break;case 4:for(s=v=0;v<w;s=v+=1)e=t[m++],a=(s-s%u)/u,r=s<u?0:f[i-u],0===g?y=x=0:(y=f[(g-1)*w+a*u+s%u],x=a&&f[(g-1)*w+(a-1)*u+s%u]),h=r+y-x,c=Math.abs(h-r),l=Math.abs(h-y),d=Math.abs(h-x),p=c<=l&&c<=d?r:l<=d?y:x,f[i++]=(e+p)%256;break;default:throw new Error("Invalid filter algorithm: "+t[m-1])}g++}return f},h.prototype.decodePalette=function(){var t,e,i,a,s,r,n,o,h;for(i=this.palette,r=this.transparency.indexed||[],s=new Uint8Array((r.length||0)+i.length),a=0,t=0,e=n=0,o=i.length;n<o;e=n+=3)s[a++]=i[e],s[a++]=i[e+1],s[a++]=i[e+2],s[a++]=null!=(h=r[t++])?h:255;return s},h.prototype.copyToImageData=function(t,e){var i,a,s,r,n,o,h,c,p,l,d;if(a=this.colors,p=null,i=this.hasAlphaChannel,this.palette.length&&(p=null!=(d=this._decodedPalette)?d:this._decodedPalette=this.decodePalette(),a=4,i=!0),c=(s=t.data||t).length,n=p||e,r=o=0,1===a)for(;r<c;)h=p?4*e[r/4]:o,l=n[h++],s[r++]=l,s[r++]=l,s[r++]=l,s[r++]=i?n[h++]:this.transparency.grayscale&&this.transparency.grayscale===l?0:255,o=h;else for(;r<c;)h=p?4*e[r/4]:o,s[r++]=n[h++],s[r++]=n[h++],s[r++]=n[h++],s[r++]=i?n[h++]:this.transparency.rgb&&this.transparency.rgb[1]===n[h-3]&&this.transparency.rgb[3]===n[h-2]&&this.transparency.rgb[5]===n[h-1]?0:255,o=h},h.prototype.decode=function(){var t;return t=new Uint8Array(this.width*this.height*4),this.copyToImageData(t,this.decodePixels()),t},r=t.document&&t.document.createElement("canvas"),n=r&&r.getContext("2d"),s=function(t){var e;return n.width=t.width,n.height=t.height,n.clearRect(0,0,t.width,t.height),n.putImageData(t,0,0),(e=new Image).src=r.toDataURL(),e},h.prototype.decodeFrames=function(t){var e,i,a,r,n,o,h,c;if(this.animation){for(c=[],i=n=0,o=(h=this.animation.frames).length;n<o;i=++n)e=h[i],a=t.createImageData(e.width,e.height),r=this.decodePixels(new Uint8Array(e.data)),this.copyToImageData(a,r),e.imageData=a,c.push(e.image=s(a));return c}},h.prototype.renderFrame=function(t,s){var r,n,o;return r=(n=this.animation.frames)[s],o=n[s-1],0===s&&t.clearRect(0,0,this.width,this.height),(null!=o?o.disposeOp:void 0)===i?t.clearRect(o.xOffset,o.yOffset,o.width,o.height):(null!=o?o.disposeOp:void 0)===a&&t.putImageData(o.imageData,o.xOffset,o.yOffset),r.blendOp===e&&t.clearRect(r.xOffset,r.yOffset,r.width,r.height),t.drawImage(r.image,r.xOffset,r.yOffset)},h.prototype.animate=function(t){var e,i,a,s,r,n,o=this;return i=0,n=this.animation,s=n.numFrames,a=n.frames,r=n.numPlays,(e=function(){var n,h;if(n=i++%s,h=a[n],o.renderFrame(t,n),s>1&&i/s<r)return o.animation._timeout=setTimeout(e,h.delay)})()},h.prototype.stopAnimation=function(){var t;return clearTimeout(null!=(t=this.animation)?t._timeout:void 0)},h.prototype.render=function(t){var e,i;return t._png&&t._png.stopAnimation(),t._png=this,t.width=this.width,t.height=this.height,e=t.getContext("2d"),this.animation?(this.decodeFrames(e),this.animate(e)):(i=e.createImageData(this.width,this.height),this.copyToImageData(i,this.decodePixels()),e.putImageData(i,0,0))},h}(self);const u=new Set(["jpg","png","bmp","gif"]),f=new Set(["S8","U8","S16","U16","S32","U32","F32","F64"]);async function m(i,a){var n;if(!l)throw new t("rasterCoded:decode","lerc decoder is not supported on big endian platform");await s();const{offset:o,noDataValue:h}=a;let c=null==(n=a.pixelType)?void 0:n.toUpperCase();c&&!f.has(c)&&(c=null);const{width:p,height:d,pixelType:u,statistics:m,pixels:g,mask:w}=r(i,{inputOffset:o,noDataValue:h,pixelType:c});return new e({width:p,height:d,pixelType:u.toLowerCase(),pixels:g,mask:w,statistics:m})}async function g(t,i){const a=await p(t,i.pyramidLevel||0),s=new e({width:a.width,height:a.height,pixels:a.pixels,pixelType:a.pixelType.toLowerCase(),mask:a.mask,statistics:null});return s.updateStatistics(),s}async function w(t,i){const a=await c(t,i.customOptions),s=new e({width:a.width,height:a.height,pixels:a.pixels,pixelType:a.pixelType.toLowerCase(),mask:a.mask,statistics:null});return s.updateStatistics(),s}function y(t,i){const a=i.pixelType||"u8",s=e.getPixelArrayConstructor(a),r="u8"===a?t:new s(t.buffer),n=[],o=i.planes||1;if(1===o)n.push(r);else for(let e=0;e<o;e++){const a=(i.width||1)*(i.height||t.length),h=new s(a);for(let t=0;t<a;t++)h[t]=r[t*o+e];n.push(h)}const h=new e({width:i.width||1,height:i.height||t.length,pixels:n,pixelType:a,statistics:null});return h.updateStatistics(),h}function x(t,e){return y(new o(new Uint8Array(t)).getBytes(),e)}function b(t,e){return y(n(t,e.offset,e.eof,!e.isInputBigEndian),e)}function k(t,i,a){const{pixelTypeCtor:s}=A(i.pixelType),r=(0,h.decode)(t,{width:i.width,height:i.height,pixelType:s,format:a}),n=new e({width:i.width,height:i.height,pixels:r.pixels,pixelType:i.pixelType,mask:r.mask,statistics:null});return n.updateStatistics(),n}function T(t){const i=a.decode(t),s=new e({width:i.width,height:i.height,pixels:i.pixels,pixelType:"U8",mask:i.mask,statistics:null});return s.updateStatistics(),s}function U(t,i){const a=new Uint8Array(t),s=new d(a),{width:r,height:n}=i,o=r*n,h=s.decode();let c,p=0,l=0;const u=new Uint8Array(o);for(p=0;p<o;p++)u[p]=h[4*p+3];const f=new e({width:r,height:n,pixels:[],pixelType:"U8",mask:u,statistics:[]});for(p=0;p<3;p++){for(c=new Uint8Array(o),l=0;l<o;l++)c[l]=h[4*l+p];f.addData({pixels:c})}return f.updateStatistics(),f}async function v(t,a,s,r){const n=new i,o={applyJpegMask:!1,format:a,...s},h=await n.decode(t,o,r),c=new e(h);return c.updateStatistics(),c}function I(e){if(null==e)throw new t("rasterCodec:decode","parameter encodeddata is required.");const i=new Uint8Array(e,0,10);let a="";return 255===i[0]&&216===i[1]?a="jpg":137===i[0]&&80===i[1]&&78===i[2]&&71===i[3]?a="png":67===i[0]&&110===i[1]&&116===i[2]&&90===i[3]&&73===i[4]&&109===i[5]&&97===i[6]&&103===i[7]&&101===i[8]&&32===i[9]?a="lerc":76===i[0]&&101===i[1]&&114===i[2]&&99===i[3]&&50===i[4]&&32===i[5]?a="lerc2":73===i[0]&&73===i[1]&&42===i[2]&&0===i[3]||77===i[0]&&77===i[1]&&0===i[2]&&42===i[3]||73===i[0]&&73===i[1]&&43===i[2]&&0===i[3]||77===i[0]&&77===i[1]&&0===i[2]&&43===i[3]?a="tiff":71===i[0]&&73===i[1]&&70===i[2]?a="gif":66===i[0]&&77===i[1]?a="bmp":String.fromCharCode.apply(null,i).toLowerCase().includes("error")&&(a="error"),a}function C(e){let i=null;switch(e){case"lerc":case"lerc2":i=m;break;case"jpg":i=T;break;case"png":i=U;break;case"bsq":case"bip":i=(t,i)=>k(t,i,e);break;case"tiff":i=g;break;case"deflate":i=x;break;case"lzw":i=b;break;case"error":i=()=>{throw new t("rasterCodec:decode","input data contains error")};break;default:i=()=>{throw new t("rasterCodec:decode","unsupported raster format")}}return i}function A(t){let e=null,i=null;switch(t?t.toLowerCase():"f32"){case"u1":case"u2":case"u4":case"u8":i=255,e=Uint8Array;break;case"u16":i=i||65535,e=Uint16Array;break;case"u32":i=i||2**32-1,e=Uint32Array;break;case"s8":i=i||-128,e=Int8Array;break;case"s16":i=i||-32768,e=Int16Array;break;case"s32":i=i||0-2**31,e=Int32Array;break;default:e=Float32Array}return{pixelTypeCtor:e,noDataValue:i}}function D(t,i=1){if(!t)return;const{pixels:a,width:s,height:r,mask:n}=t;if(!a||0===a.length)return;const o=a.length,h=s-1,c=r-1,p=[];let l,d,u,f,m,g,w;const y=e.getPixelArrayConstructor(t.pixelType);if(0===i){for(l=0;l<o;l++){for(m=a[l],g=new y(h*c),d=0;d<c;d++)for(f=d*s,u=0;u<h;u++)g[d*h+u]=m[f+u];p.push(g)}if(n)for(w=new Uint8Array(h*c),d=0;d<c;d++)for(f=d*s,u=0;u<h;u++)w[d*h+u]=n[f+u]}else{for(l=0;l<o;l++){for(m=a[l],g=new y(h*c),d=0;d<c;d++)for(f=d*s,u=0;u<h;u++)g[d*h+u]=(m[f+u]+m[f+u+1]+m[f+s+u]+m[f+s+u+1])/4;p.push(g)}if(n)for(w=new Uint8Array(h*c),d=0;d<c;d++)for(f=d*s,u=0;u<h;u++)w[d*h+u]=Math.min.apply(null,[n[f+u],n[f+u+1],n[f+s+u],n[f+s+u+1]])}t.width=h,t.height=c,t.mask=w,t.pixels=p}function S(t){let e=I(t);return"lerc2"===e?e="lerc":"error"===e&&(e=""),e}async function O(e,i={},a){if(null==e)throw new t("rasterCodec:decode","missing encodeddata parameter.");let s,r,n=i.format&&i.format.toLowerCase();if(!("bsq"!==n&&"bip"!==n||null!=i.width&&null!=i.height))throw new t("rasterCodec:decode","requires width and height in options parameter.");return"tiff"===n&&i.customOptions?w(e,i):((!n||"bsq"!==n&&"bip"!==n&&"deflate"!==n&&"lzw"!==n)&&(n=I(e)),i.useCanvas&&u.has(n)?r=await v(e,n,i,a):(s=C(n),i.isPoint&&((i={...i}).width++,i.height++),r=await s(e,i),i.isPoint&&D(r)),r)}export{O as decode,S as getFormat};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{bytesToUTF8 as e}from"../rasterDatasets/byteStreamUtils.js";import{J as t}from"../../../chunks/Jpg.js";import{load as n,decode as a}from"./Lerc.js";import{decode as i}from"./Lzw.js";import s from"./TiffTags.js";import{isPlatformLittleEndian as l}from"./utils.js";import{Z as r}from"../../../chunks/Zlib.js";const o=[0,1,1,2,4,8,1,1,2,4,8,4,8,-1,-1,-1,8,8,8],f=4294967296,u=new Set([1,5,6,7,8,34712,34887]);function c(e,t){let n="unknown";return 3===e?n="f32":1===e?1===t?n="u1":2===t?n="u2":4===t?n="u4":t<=8?n="u8":t<=16?n="u16":t<=32&&(n="u32"):2===e&&(t<=8?n="s8":t<=16?n="s16":t<=32&&(n="s32")),n}function h(e){let t=null;switch(e?e.toLowerCase():"f32"){case"u1":case"u2":case"u4":case"u8":t=Uint8Array;break;case"u16":t=Uint16Array;break;case"u32":t=Uint32Array;break;case"s8":t=Int8Array;break;case"s16":t=Int16Array;break;case"s32":t=Int32Array;break;default:t=Float32Array}return t}function g(e,t){return{x:t[0]*e.x+t[1]*e.y+t[2],y:t[3]*e.x+t[4]*e.y+t[5]}}function w(e,t){var n;return null==(n=e.get(t))?void 0:n.values}function d(e,t){var n;return null==(n=e.get(t))?void 0:n.values}function p(e,t){var n;return null==(n=e.get(t))?void 0:n.values[0]}function I(e,t){var n;return null==(n=e.get(t))?void 0:n.values[0]}function T(e,t,n,a=0,i=s.TIFF_TAGS,l=4){const r=8===l,o=r?U(new DataView(e,n,8),0,t):new DataView(e,n,2).getUint16(0,t),f=4+2*l,u=r?8:2,c=u+o*f;if(n+c>e.byteLength)return{success:!1,ifd:null,nextIFD:null,requiredBufferSize:c};const h=n+c+4<=e.byteLength?L(new DataView(e,n+c,8===l?8:4),0,t,8===l):null,g=n+u,w=new Map;let d,p,I,T,E,y,m;for(let A=0;A<o;A++){p=new DataView(e,g+f*A,f),I=p.getUint16(0,t),E=p.getUint16(2,t),T=s.getTagName(I,i);const n=[];2===l?(y=p.getUint16(4,t),m=p.getUint16(6,t)):4===l?(y=p.getUint32(4,t),m=p.getUint32(8,t)):8===l&&(y=L(p,4,t,!0),m=L(p,12,t,!0),n.push(p.getUint32(12,t)),n.push(p.getUint32(16,t))),d={id:I,type:E,valueCount:y,valueOffset:m,valueOffsets:n,values:null},x(e,t,d,a,!1,l),w.set(T,d)}return{success:!0,ifd:w,nextIFD:h,requiredBufferSize:c}}const E=function(e,t){return a(e,{inputOffset:t}).pixels[0]};async function y(e,a,s,o,f){var u,g;const w=l===a,d=I(s,"BITSPERSAMPLE"),p=c(null!=(u=I(s,"SAMPLEFORMAT"))?u:1,d),T=null!=(g=I(s,"COMPRESSION"))?g:1,y=h(p);let m,A,S,M,x,b,O;if(34887===T)return await n(),E(e,o);if(1===T)S=e.slice(o,o+f),M=new Uint8Array(S);else if(8===T||32946===T)M=new Uint8Array(e,o,f),b=new r(M),O=b.getBytes(),S=new ArrayBuffer(O.length),M=new Uint8Array(S),M.set(O);else if(6===T){M=new Uint8Array(e,o,f);const n=new t;n.parse(M);const a=n.getData(n.width,n.height,!0);S=new ArrayBuffer(a.length),M=new Uint8Array(S),M.set(a)}else if(7===T){const n=s.get("JPEGTABLES").values,a=n.length-2;M=new Uint8Array(a+f-2);for(let e=0;e<a;e++)M[e]=n[e];const i=new Uint8Array(e,o+2,f-2);for(let e=0;e<i.length;e++)M[a+e]=i[e];const l=new t;l.parse(M);const r=l.getData(l.width,l.height,!0);S=new ArrayBuffer(r.length),M=new Uint8Array(S),M.set(r)}else 5===T&&(M=i(e,o,f,a),S=M.buffer);if("u8"===p||"s8"===p||w)A=new y(S);else{switch(S=new ArrayBuffer(M.length),x=new Uint8Array(S),p){case"u16":case"s16":for(m=0;m<M.length;m+=2)x[m]=M[m+1],x[m+1]=M[m];break;case"u32":case"s32":case"f32":for(m=0;m<M.length;m+=4)x[m]=M[m+3],x[m+1]=M[m+2],x[m+2]=M[m+1],x[m+3]=M[m]}A=new y(S)}return A}async function m(e,t,n){var a;const i=d(n,"TILEOFFSETS");if(void 0===i)return null;const s=d(n,"TILEBYTECOUNTS"),{width:l,height:r,pixelType:o,tileWidth:f,tileHeight:u}=b([n]),c=O(n,t),g=t.planes,w=l*r,p=I(n,"BITSPERSAMPLE"),T=34887===(null!=(a=I(n,"COMPRESSION"))?a:1),E=h(o),m=[];for(let h=0;h<g;h++)m.push(new E(w));let A,S,M,x,D,U,v,L,P,N,k,G,R;const C=Math.ceil(l/f);if(p%8==0)if(T&&c&&g>1){const a=Math.round(i.length/g);for(A=0;A<a;A++){U=Math.floor(A/C)*u,v=A%C*f,L=U*l+v;for(let a=0;a<g;a++){const o=A*g+a;for(M=await y(e,t.littleEndian,n,i[o],s[o]),N=0,P=L,G=Math.min(f,l-v),k=Math.min(u,r-U),R=m[a],x=0;x<k;x++)for(P=L+x*l,N=x*f,D=0;D<G;D++,P++,N++)R[P]=M[N]}}}else for(A=0;A<i.length;A++)for(U=Math.floor(A/C)*u,v=A%C*f,L=U*l+v,M=await y(e,t.littleEndian,n,i[A],s[A]),N=0,P=L,G=Math.min(f,l-v),k=Math.min(u,r-U),S=0;S<g;S++)if(R=m[S],c||T)for(x=0;x<k;x++)for(P=L+x*l,N=f*u*S+x*f,D=0;D<G;D++,P++,N++)R[P]=M[N];else for(x=0;x<k;x++)for(P=L+x*l,N=x*f*g+S,D=0;D<G;D++,P++,N+=g)R[P]=M[N];return{width:l,height:r,pixelType:o,pixels:m}}const A=function(e,n,a){var s;const o=l===n.littleEndian,f=d(a,"STRIPOFFSETS");if(void 0===f)return null;const{width:u,height:c,pixelType:g}=b([a]),w=n.planes,p=u*c,T=I(a,"BITSPERSAMPLE"),E=h(g),y=new E(p*w),m=d(a,"STRIPBYTECOUNTS"),A=I(a,"ROWSPERSTRIP"),S=null!=(s=I(a,"COMPRESSION"))?s:1;let M,x,O,D,U,v,L,P,N,k,G,R=A;if(T%8==0)for(M=0;M<f.length;M++){if(U=M*(A*u)*w,R=(M+1)*A>c?c-M*A:A,"u8"===g||"s8"===g||o){if(8===S||32946===S)L=new Uint8Array(e,f[M],m[M]),k=new r(L),G=k.getBytes(),v=new ArrayBuffer(G.length),L=new Uint8Array(v),L.set(G),L.length!==R*u*w*T/8&&console.log("strip byte counts is different than expected");else if(6===S){L=new Uint8Array(e,f[M],m[M]);const n=new t;n.parse(L);const a=n.getData(n.width,n.height,!0);v=new ArrayBuffer(a.length),L=new Uint8Array(v),L.set(a)}else 5===S?(L=i(e,f[M],m[M],n.littleEndian),v=L.buffer):1===S&&(m[M]!==R*u*w*T/8&&console.log("strip byte counts is different than expected"),v=e.slice(f[M],f[M]+m[M]));D=new E(v)}else{switch(6===S||8===S||32946===S?(L=new Uint8Array(e,f[M],m[M]),k=new r(L),L=k.getBytes(),v=new ArrayBuffer(L.length),P=new Uint8Array(v),L.length!==R*u*w*T/8&&console.log("strip byte counts is different than expected")):1===S&&(m[M]!==R*u*w*T/8&&console.log("strip byte counts is different than expected"),v=new ArrayBuffer(m[M]),L=new Uint8Array(e,f[M],m[M]),P=new Uint8Array(v)),g){case"u16":case"s16":for(O=0;O<L.length;O+=2)P[O]=L[O+1],P[O+1]=L[O];break;case"u32":case"s32":case"f32":for(O=0;O<L.length;O+=4)P[O]=L[O+3],P[O+1]=L[O+2],P[O+2]=L[O+1],P[O+3]=L[O]}D=new E(v)}y.set(D,U)}const C=[];if(1===w)C.push(y);else for(M=0;M<w;M++){for(N=new E(p),x=0;x<p;x++)N[x]=y[x*w+M];C.push(N)}return{width:u,height:c,pixelType:g,pixels:C}},S=function(e,t,n){if(!(e&&e.length>0&&t&&n))return null;let a,i,s;const l=e[0].length,r=e.length,o=new Uint8Array(l);for(let f=0;f<r;f++)if(a=e[f],i=t[f],s=n[f],0===f)for(let e=0;e<l;e++)o[e]=a[e]<i||a[e]>s?0:1;else for(let e=0;e<l;e++)o[e]&&(o[e]=a[e]<i||a[e]>s?0:1);return o},M=function(e){if(!e)return null;const t=e.match(/<Item(.*?)Item>/gi);if(!t||0===t.length)return null;const n=new Map;let a,i,s,l,r;for(let I=0;I<t.length;I++)a=t[I],i=a.slice("<Item ".length,a.indexOf(">")),l=a.indexOf("sample="),l>-1&&(r=a.slice(l+'sample="'.length,a.indexOf('"',l+'sample="'.length))),l=a.indexOf("name="),l>-1&&(i=a.slice(l+'name="'.length,a.indexOf('"',l+'name="'.length))),i&&(s=a.slice(a.indexOf(">")+1,a.indexOf("</Item>")).trim(),null!=r?n.has(i)?n.get(i)[r]=s:n.set(i,[s]):n.set(i,s)),r=null;const o=n.get("STATISTICS_MINIMUM"),f=n.get("STATISTICS_MAXIMUM"),u=n.get("STATISTICS_MEAN"),c=n.get("STATISTICS_STDDEV");let h=null;if(o&&f){h=[];for(let e=0;e<o.length;e++)h.push({min:parseFloat(o[e]),max:parseFloat(f[e]),avg:u&&parseFloat(u[e]),stddev:c&&parseFloat(c[e])})}const g=n.get("BandName"),w=n.get("WavelengthMin"),d=n.get("WavelengthMax");let p=null;if(g){p=[];for(let e=0;e<g.length;e++)p.push({BandName:g[e],WavelengthMin:w&&parseFloat(w[e]),WavelengthMax:d&&parseFloat(d[e])})}return{statistics:h,bandProperties:p,dataType:n.get("DataType"),rawMetadata:n}};function x(e,t,n,a=0,i=!1,s=4){if(n.values)return!0;const l=n.type,r=n.valueCount;let u=n.valueOffset,c=[];const h=o[l],g=8*h,w=r*h,d=r*o[l]*8;let p,I;const T=8===s?64:32,E=n.valueOffsets;if(d>T){if(w>(i?e.byteLength:e?e.byteLength-u+a:0))return n.offlineOffsetSize=[u,w],n.values=null,!1}if(d<=T){if(!t)if(T<=32)u>>>=32-d;else{const e=null!=E&&E.length?E[0]:u>>>0,t=null!=E&&E.length?E[1]:Math.round((u-e)/f);d<=32?(u=e>>>32-d,E[0]=u):(u=e*2**(32-d)+(t>>>32-d),E[0]=e,E[1]=t>>>32-d)}if(1===r&&g===T)c=[u];else if(64===T){const e=null!=E&&E.length?E[0]:u>>>0,t=null!=E&&E.length?E[1]:Math.round((u-e)/f);let n=e,a=32;for(I=1;I<=r;I++){const e=32-g*I%32;if(a<g){const i=n<<e>>>32-a,s=t<<32-a>>>32-a;n=t,c.push(i+s*2**(g-a)),a-=32-(g-a)}else c.push(n<<e>>>32-g),a-=g;0===a&&(a=32,n=t)}}else for(I=1;I<=r;I++){const e=32-g*I;c.push(u<<e>>>32-g)}}else{u-=a,i&&(u=0);for(let n=u;n<u+w;n+=h){switch(l){case 1:case 2:case 7:p=new DataView(e,n,1).getUint8(0);break;case 3:p=new DataView(e,n,2).getUint16(0,t);break;case 4:case 13:p=new DataView(e,n,4).getUint32(0,t);break;case 5:p=new DataView(e,n,4).getUint32(0,t)/new DataView(e,n+4,4).getUint32(0,t);break;case 6:p=new DataView(e,n,1).getInt8(0);break;case 8:p=new DataView(e,n,2).getInt16(0,t);break;case 9:p=new DataView(e,n,4).getInt32(0,t);break;case 10:p=new DataView(e,n,4).getInt32(0,t)/new DataView(e,n+4,4).getInt32(0,t);break;case 11:p=new DataView(e,n,4).getFloat32(0,t);break;case 12:p=new DataView(e,n,8).getFloat64(0,t);break;case 16:case 18:p=U(new DataView(e,n,8),0,t);break;case 17:p=v(new DataView(e,n,8),0,t);break;default:p=null}c.push(p)}}if(2===l){let e="";const t=c;for(c=[],I=0;I<t.length;I++)0===t[I]&&""!==e?(c.push(e),e=""):e+=String.fromCharCode(t[I]);""===e&&0!==c.length||c.push(e)}return n.values=c,!0}function b(e){var t,n;const a=e[0],i=I(a,"TILEWIDTH"),s=I(a,"TILELENGTH"),l=I(a,"IMAGEWIDTH"),r=I(a,"IMAGELENGTH"),o=I(a,"BITSPERSAMPLE"),f=I(a,"SAMPLESPERPIXEL"),h=null!=(t=I(a,"SAMPLEFORMAT"))?t:1,T=c(h,o),E=O(a),y=w(a,"GDAL_NODATA");let m;null!=y&&y.length&&(m=y.map((e=>parseFloat(e))),m.some((e=>isNaN(e)))&&(m=null));const A=null!=(n=I(a,"COMPRESSION"))?n:1;let S;switch(A){case 1:S="NONE";break;case 2:case 3:case 4:case 32771:S="CCITT";break;case 5:S="LZW";break;case 6:case 7:S="JPEG";break;case 32773:S="PACKBITS";break;case 8:case 32946:S="DEFLATE";break;case 34712:S="JPEG2000";break;case 34887:S="LERC";break;default:S=String(A)}let x=!0,b="";u.has(A)||(x=!1,b+="unsupported tag compression "+A),h>3&&(x=!1,b+="unsupported tag sampleFormat "+h),o%8!=0&&(x=!1,b+="unsupported tag bitsPerSample "+o);const D=p(a,"GEOASCIIPARAMS");let U;if(D){const e=D.split("|").find((e=>e.indexOf("ESRI PE String = ")>-1)),t=e?e.replace("ESRI PE String = ",""):"";U=t.startsWith("COMPD_CS")||t.startsWith("PROJCS")||t.startsWith("GEOGCS")?{wkid:null,wkt:t}:null}const v=d(a,"GEOTIEPOINTS"),L=d(a,"GEOPIXELSCALE"),P=d(a,"GEOTRANSMATRIX"),N=a.has("GEOKEYDIRECTORY")?a.get("GEOKEYDIRECTORY").data:null;let G,R,C=!1;if(N){C=2===I(N,"GTRasterTypeGeoKey");const e=I(N,"GTModelTypeGeoKey");if(2===e){const e=I(N,"GeographicTypeGeoKey");e>=1024&&e<=32766&&(U={wkid:e})}else if(1===e){const e=I(N,"ProjectedCSTypeGeoKey");e>=1024&&e<=32766&&(U={wkid:e})}}if(L&&v&&v.length>=6?(G=[L[0],0,v[3]-v[0]*L[0],0,-Math.abs(L[1]),v[4]-v[1]*L[1]],C&&(G[2]-=.5*G[0]+.5*G[1],G[5]-=.5*G[3]+.5*G[4])):P&&16===P.length&&(G=C?[P[0],P[1],P[3]-.5*P[0],P[4],P[5],P[7]-.5*P[5]]:[P[0],P[1],P[3],P[4],P[5],P[7]]),G){const e=[{x:0,y:r},{x:0,y:0},{x:l,y:r},{x:l,y:0}];let t,n=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY,s=Number.NEGATIVE_INFINITY;for(let l=0;l<e.length;l++)t=g(e[l],G),n=t.x>n?n:t.x,i=t.x<i?i:t.x,a=t.y>a?a:t.y,s=t.y<s?s:t.y;R={xmin:n,xmax:i,ymin:a,ymax:s,spatialReference:U}}else R={xmin:-.5,ymin:.5-r,xmax:l-.5,ymax:.5,spatialReference:U};const F=e.filter((e=>1===p(e,"NEWSUBFILETYPE")));let B,V,W,H,Y;if(F.length>0){B=Math.round(Math.log(l/I(F[0],"IMAGEWIDTH"))/Math.LN2);const e=F[F.length-1];V=Math.round(Math.log(l/I(e,"IMAGEWIDTH"))/Math.LN2),W=I(e,"TILEWIDTH"),H=I(e,"TILELENGTH")}W=V>0?W||i:null,H=V>0?H||s:null,i&&(Y=[{maxCol:Math.ceil(l/i)-1,maxRow:Math.ceil(r/s)-1,minRow:0,minCol:0}],F.forEach((e=>{Y.push({maxCol:Math.ceil(I(e,"IMAGEWIDTH")/I(e,"TILEWIDTH"))-1,maxRow:Math.ceil(I(e,"IMAGELENGTH")/I(e,"TILELENGTH"))-1,minRow:0,minCol:0})})));const _=p(e[0],"GDAL_METADATA"),K=M(_);return b+=" "+k({width:l,height:r,tileWidth:i,tileHeight:s,planes:f,ifds:e}),{width:l,height:r,tileWidth:i,tileHeight:s,planes:f,isBSQ:E,pixelType:T,compression:S,noData:m,isSupported:x,message:b,extent:R,affine:L?null:G,firstPyramidLevel:B,maximumPyramidLevel:V,pyramidBlockWidth:W,pyramidBlockHeight:H,tileBoundary:Y,metadata:K}}function O(e,t){const n=w(e,"PLANARCONFIGURATION");return n?2===n[0]:!!t&&t.isBSQ}function D(e){const{littleEndian:t,isBigTiff:n,firstIFD:a}=P(e);let i=a;const l=[];do{const a=N(e,t,i,0,s.TIFF_TAGS,n?8:4);if(!a.success)break;l.push(a.ifd),i=a.nextIFD}while(i>0);return{...b(l),littleEndian:t,isBigTiff:n,ifds:l}}function U(e,t,n){const a=e.getUint32(t,n),i=e.getUint32(t+4,n);return n?i*f+a:a*f+i}function v(e,t,n){let a=n?e.getInt32(t,n):e.getUint32(t,n),i=n?e.getUint32(t+4,n):e.getInt32(t+4,n);const s=(n?a:i)>=0?1:-1;n?a*=s:i*=s;return s*(n?i*f+a:a*f+i)}function L(e,t,n,a){return a?U(e,t,n):e.getUint32(t,n)}function P(e){const t=new DataView(e,0,16),n=t.getUint16(0,!1);let a=null;if(18761===n)a=!0;else{if(19789!==n)throw"unexpected endianess byte";a=!1}const i=t.getUint16(2,a);if(42!==i&&43!==i)throw"unexpected tiff identifier";let s=4;const l=43===i;if(l){const e=t.getUint16(s,a);if(s+=2,8!==e)throw"unsupported bigtiff version";if(0!==t.getUint16(s,a))throw"unsupported bigtiff version";s+=2}return{littleEndian:a,isBigTiff:l,firstIFD:L(t,s,a,l)}}function N(t,n,a,i=0,l=s.TIFF_TAGS,r=4){const o=T(t,n,a,i,l,r);let f;const u=o.ifd;if(u){if(s.ifdTags.forEach(((e,a)=>{u.has(a)&&(f=u.get(a),f.data=T(t,n,f.valueOffset-i,i,e).ifd)})),u.has("GEOKEYDIRECTORY")){f=u.get("GEOKEYDIRECTORY");const e=f.values;if(e&&e.length>4){const a=e[0]+"."+e[1]+"."+e[2];f.data=T(t,n,f.valueOffset+6-i,i,s.GEO_KEYS,2).ifd,f.data&&f.data.set("GEOTIFFVersion",{id:0,type:2,valueCount:1,valueOffset:null,values:[a]})}}if(u.has("XMP")){f=u.get("XMP");const t=f.values;"number"==typeof t[0]&&7===f.type&&(f.values=[e(new Uint8Array(t))])}}return o}function k(e){const{width:t,height:n,tileHeight:a,tileWidth:i}=e,s=e.planes,l=i?i*a:t*n,r=I(e.ifds[0],"BITSPERSAMPLE");let o="";return l*s>2**30/(r>8?r/8:1)&&(o=i?"tiled tiff exceeding 1 gigabits per tile is not supported":"scanline tiff exceeding 1 gigabits is not supported"),o}async function G(e,t){var n;const{headerInfo:a,ifd:i,offsets:s,sizes:l}=t,r=[];for(let h=0;h<s.length;h++){const t=await y(e,a.littleEndian,i,s[h],l[h]||e.byteLength);r.push(t)}const o=O(i,a),{pixelType:f,planes:u}=a,c=h(f),g=I(i,"TILEWIDTH"),w=I(i,"TILELENGTH"),d=null!=(n=I(i,"COMPRESSION"))?n:1,p=g*w;let T;const E=[];let m=r[0];const A=34887===d;for(let h=0;h<u;h++){if(T=new c(p),o&&A){m=r[h];for(let e=0;e<p;e++)T[e]=m[h][e+h]}else if(o||A&&!o)T=m.slice(p*h,p*(h+1));else for(let e=0;e<p;e++)T[e]=m[e*u+h];E.push(T)}const M=a.noData?a.noData[0]:null,x=a.metadata?a.metadata.statistics:null,b=x?x.map((e=>e.min)):null,D=x?x.map((e=>e.max)):null;let U,v;if(null!=M)if(U=new Uint8Array(p),Math.abs(M)>1e24)for(v=0;v<p;v++)Math.abs((E[0][v]-M)/M)<1e-6?U[v]=0:U[v]=1;else for(v=0;v<p;v++)E[0][v]===M?U[v]=0:U[v]=1;else b&&D&&t.applyMinMaxConstraint&&(U=S(E,b,D));return{pixelType:f,width:g,height:w,pixels:E,mask:U,noDataValue:M}}async function R(e,t=0,n){n=n||D(e);const{ifds:a,noData:i}=n;if(0===a.length)throw"no valid image file directory";const s=k(n);if(s)throw s;let l,r;const o=-1===t?a[a.length-1]:a[t],f=i?i[0]:null;if(r=n.tileWidth?await m(e,n,o):await A(e,n,o),null!==f){if(r.mask=new Uint8Array(r.width*r.height),Math.abs(f)>1e24)for(l=0;l<r.width*r.height;l++)Math.abs((r.pixels[0][l]-f)/f)<1e-6?r.mask[l]=0:r.mask[l]=1;else for(l=0;l<r.width*r.height;l++)r.pixels[0][l]===f?r.mask[l]=0:r.mask[l]=1;r.noDataValue=f}return r}export{R as decode,G as decodeTileOrStrip,b as getImageInfo,O as isBSQConfig,x as parseFieldValues,D as parseHeader,N as parseIFD,P as parseSignature};
5
+ import{bytesToUTF8 as e}from"../rasterDatasets/byteStreamUtils.js";import{J as t}from"../../../chunks/Jpg.js";import{load as n,decode as a}from"./Lerc.js";import{decode as i}from"./Lzw.js";import s from"./TiffTags.js";import{isPlatformLittleEndian as l}from"./utils.js";import{Z as r}from"../../../chunks/Zlib.js";const o=[0,1,1,2,4,8,1,1,2,4,8,4,8,-1,-1,-1,8,8,8],f=4294967296,u=new Set([1,5,6,7,8,34712,34887]);function c(e,t){let n="unknown";return 3===e?n="f32":1===e?1===t?n="u1":2===t?n="u2":4===t?n="u4":t<=8?n="u8":t<=16?n="u16":t<=32&&(n="u32"):2===e&&(t<=8?n="s8":t<=16?n="s16":t<=32&&(n="s32")),n}function h(e){let t=null;switch(e?e.toLowerCase():"f32"){case"u1":case"u2":case"u4":case"u8":t=Uint8Array;break;case"u16":t=Uint16Array;break;case"u32":t=Uint32Array;break;case"s8":t=Int8Array;break;case"s16":t=Int16Array;break;case"s32":t=Int32Array;break;default:t=Float32Array}return t}function g(e,t){return{x:t[0]*e.x+t[1]*e.y+t[2],y:t[3]*e.x+t[4]*e.y+t[5]}}function w(e,t){var n;return null==(n=e.get(t))?void 0:n.values}function d(e,t){var n;return null==(n=e.get(t))?void 0:n.values}function p(e,t){var n;return null==(n=e.get(t))?void 0:n.values[0]}function I(e,t){var n;return null==(n=e.get(t))?void 0:n.values[0]}function T(e,t,n,a=0,i=s.TIFF_TAGS,l=4){const r=8===l,o=r?U(new DataView(e,n,8),0,t):new DataView(e,n,2).getUint16(0,t),f=4+2*l,u=r?8:2,c=u+o*f;if(n+c>e.byteLength)return{success:!1,ifd:null,nextIFD:null,requiredBufferSize:c};const h=n+c+4<=e.byteLength?L(new DataView(e,n+c,8===l?8:4),0,t,8===l):null,g=n+u,w=new Map;let d,p,I,T,E,y,m;for(let A=0;A<o;A++){p=new DataView(e,g+f*A,f),I=p.getUint16(0,t),E=p.getUint16(2,t),T=s.getTagName(I,i);const n=[];2===l?(y=p.getUint16(4,t),m=p.getUint16(6,t)):4===l?(y=p.getUint32(4,t),m=p.getUint32(8,t)):8===l&&(y=L(p,4,t,!0),m=L(p,12,t,!0),n.push(p.getUint32(12,t)),n.push(p.getUint32(16,t))),d={id:I,type:E,valueCount:y,valueOffset:m,valueOffsets:n,values:null},x(e,t,d,a,!1,l),w.set(T,d)}return{success:!0,ifd:w,nextIFD:h,requiredBufferSize:c}}const E=function(e,t){return a(e,{inputOffset:t}).pixels[0]};async function y(e,a,s,o,f){var u,g;const w=l===a,d=I(s,"BITSPERSAMPLE"),p=c(null!=(u=I(s,"SAMPLEFORMAT"))?u:1,d),T=null!=(g=I(s,"COMPRESSION"))?g:1,y=h(p);let m,A,S,M,x,b,O;if(34887===T)return await n(),E(e,o);if(1===T)S=e.slice(o,o+f),M=new Uint8Array(S);else if(8===T||32946===T)M=new Uint8Array(e,o,f),b=new r(M),O=b.getBytes(),S=new ArrayBuffer(O.length),M=new Uint8Array(S),M.set(O);else if(6===T){M=new Uint8Array(e,o,f);const n=new t;n.parse(M);const a=n.getData(n.width,n.height,!0);S=new ArrayBuffer(a.length),M=new Uint8Array(S),M.set(a)}else if(7===T){const n=s.get("JPEGTABLES").values,a=n.length-2;M=new Uint8Array(a+f-2);for(let e=0;e<a;e++)M[e]=n[e];const i=new Uint8Array(e,o+2,f-2);for(let e=0;e<i.length;e++)M[a+e]=i[e];const l=new t;l.parse(M);const r=l.getData(l.width,l.height,!0);S=new ArrayBuffer(r.length),M=new Uint8Array(S),M.set(r)}else 5===T&&(M=i(e,o,f,a),S=M.buffer);if("u8"===p||"s8"===p||w)A=new y(S);else{switch(S=new ArrayBuffer(M.length),x=new Uint8Array(S),p){case"u16":case"s16":for(m=0;m<M.length;m+=2)x[m]=M[m+1],x[m+1]=M[m];break;case"u32":case"s32":case"f32":for(m=0;m<M.length;m+=4)x[m]=M[m+3],x[m+1]=M[m+2],x[m+2]=M[m+1],x[m+3]=M[m]}A=new y(S)}return A}async function m(e,t,n){var a;const i=d(n,"TILEOFFSETS");if(void 0===i)return null;const s=d(n,"TILEBYTECOUNTS"),{width:l,height:r,pixelType:o,tileWidth:f,tileHeight:u}=b([n]),c=O(n,t),g=t.planes,w=l*r,p=I(n,"BITSPERSAMPLE"),T=34887===(null!=(a=I(n,"COMPRESSION"))?a:1),E=h(o),m=[];for(let h=0;h<g;h++)m.push(new E(w));let A,S,M,x,D,U,v,L,P,N,k,G,R;const C=Math.ceil(l/f);if(p%8==0)if(T&&c&&g>1){const a=Math.round(i.length/g);for(A=0;A<a;A++){U=Math.floor(A/C)*u,v=A%C*f,L=U*l+v;for(let a=0;a<g;a++){const o=A*g+a;for(M=await y(e,t.littleEndian,n,i[o],s[o]),N=0,P=L,G=Math.min(f,l-v),k=Math.min(u,r-U),R=m[a],x=0;x<k;x++)for(P=L+x*l,N=x*f,D=0;D<G;D++,P++,N++)R[P]=M[N]}}}else for(A=0;A<i.length;A++)for(U=Math.floor(A/C)*u,v=A%C*f,L=U*l+v,M=await y(e,t.littleEndian,n,i[A],s[A]),N=0,P=L,G=Math.min(f,l-v),k=Math.min(u,r-U),S=0;S<g;S++)if(R=m[S],c||T)for(x=0;x<k;x++)for(P=L+x*l,N=f*u*S+x*f,D=0;D<G;D++,P++,N++)R[P]=M[N];else for(x=0;x<k;x++)for(P=L+x*l,N=x*f*g+S,D=0;D<G;D++,P++,N+=g)R[P]=M[N];return{width:l,height:r,pixelType:o,pixels:m}}const A=function(e,n,a){var s;const o=l===n.littleEndian,f=d(a,"STRIPOFFSETS");if(void 0===f)return null;const{width:u,height:c,pixelType:g}=b([a]),w=n.planes,p=u*c,T=I(a,"BITSPERSAMPLE"),E=h(g),y=new E(p*w),m=d(a,"STRIPBYTECOUNTS"),A=I(a,"ROWSPERSTRIP"),S=null!=(s=I(a,"COMPRESSION"))?s:1;let M,x,O,D,U,v,L,P,N,k,G,R=A;if(T%8==0)for(M=0;M<f.length;M++){if(U=M*(A*u)*w,R=(M+1)*A>c?c-M*A:A,"u8"===g||"s8"===g||o){if(8===S||32946===S)L=new Uint8Array(e,f[M],m[M]),k=new r(L),G=k.getBytes(),v=new ArrayBuffer(G.length),L=new Uint8Array(v),L.set(G),L.length!==R*u*w*T/8&&console.log("strip byte counts is different than expected");else if(6===S){L=new Uint8Array(e,f[M],m[M]);const n=new t;n.parse(L);const a=n.getData(n.width,n.height,!0);v=new ArrayBuffer(a.length),L=new Uint8Array(v),L.set(a)}else 5===S?(L=i(e,f[M],m[M],n.littleEndian),v=L.buffer):1===S&&(m[M]!==R*u*w*T/8&&console.log("strip byte counts is different than expected"),v=e.slice(f[M],f[M]+m[M]));D=new E(v)}else{switch(6===S||8===S||32946===S?(L=new Uint8Array(e,f[M],m[M]),k=new r(L),L=k.getBytes(),v=new ArrayBuffer(L.length),P=new Uint8Array(v),L.length!==R*u*w*T/8&&console.log("strip byte counts is different than expected")):1===S&&(m[M]!==R*u*w*T/8&&console.log("strip byte counts is different than expected"),v=new ArrayBuffer(m[M]),L=new Uint8Array(e,f[M],m[M]),P=new Uint8Array(v)),g){case"u16":case"s16":for(O=0;O<L.length;O+=2)P[O]=L[O+1],P[O+1]=L[O];break;case"u32":case"s32":case"f32":for(O=0;O<L.length;O+=4)P[O]=L[O+3],P[O+1]=L[O+2],P[O+2]=L[O+1],P[O+3]=L[O]}D=new E(v)}y.set(D,U)}const C=[];if(1===w)C.push(y);else for(M=0;M<w;M++){for(N=new E(p),x=0;x<p;x++)N[x]=y[x*w+M];C.push(N)}return{width:u,height:c,pixelType:g,pixels:C}},S=function(e,t,n){if(!(e&&e.length>0&&t&&n))return null;let a,i,s;const l=e[0].length,r=e.length,o=new Uint8Array(l);for(let f=0;f<r;f++)if(a=e[f],i=t[f],s=n[f],0===f)for(let e=0;e<l;e++)o[e]=a[e]<i||a[e]>s?0:1;else for(let e=0;e<l;e++)o[e]&&(o[e]=a[e]<i||a[e]>s?0:1);return o},M=function(e){if(!e)return null;const t=e.match(/<Item(.*?)Item>/gi);if(!t||0===t.length)return null;const n=new Map;let a,i,s,l,r;for(let I=0;I<t.length;I++)a=t[I],i=a.slice("<Item ".length,a.indexOf(">")),l=a.indexOf("sample="),l>-1&&(r=a.slice(l+'sample="'.length,a.indexOf('"',l+'sample="'.length))),l=a.indexOf("name="),l>-1&&(i=a.slice(l+'name="'.length,a.indexOf('"',l+'name="'.length))),i&&(s=a.slice(a.indexOf(">")+1,a.indexOf("</Item>")).trim(),null!=r?n.has(i)?n.get(i)[r]=s:n.set(i,[s]):n.set(i,s)),r=null;const o=n.get("STATISTICS_MINIMUM"),f=n.get("STATISTICS_MAXIMUM"),u=n.get("STATISTICS_MEAN"),c=n.get("STATISTICS_STDDEV");let h=null;if(o&&f){h=[];for(let e=0;e<o.length;e++)h.push({min:parseFloat(o[e]),max:parseFloat(f[e]),avg:u&&parseFloat(u[e]),stddev:c&&parseFloat(c[e])})}const g=n.get("BandName"),w=n.get("WavelengthMin"),d=n.get("WavelengthMax");let p=null;if(g){p=[];for(let e=0;e<g.length;e++)p.push({BandName:g[e],WavelengthMin:w&&parseFloat(w[e]),WavelengthMax:d&&parseFloat(d[e])})}return{statistics:h,bandProperties:p,dataType:n.get("DataType"),rawMetadata:n}};function x(e,t,n,a=0,i=!1,s=4){if(n.values)return!0;const l=n.type,r=n.valueCount;let u=n.valueOffset,c=[];const h=o[l],g=8*h,w=r*h,d=r*o[l]*8;let p,I;const T=8===s?64:32,E=n.valueOffsets;if(d>T){if(w>(i?e.byteLength:e?e.byteLength-u+a:0))return n.offlineOffsetSize=[u,w],n.values=null,!1}if(d<=T){if(!t)if(T<=32)u>>>=32-d;else{const e=null!=E&&E.length?E[0]:u>>>0,t=null!=E&&E.length?E[1]:Math.round((u-e)/f);d<=32?(u=e>>>32-d,E[0]=u):(u=e*2**(32-d)+(t>>>32-d),E[0]=e,E[1]=t>>>32-d)}if(1===r&&g===T)c=[u];else if(64===T){const e=null!=E&&E.length?E[0]:u>>>0,t=null!=E&&E.length?E[1]:Math.round((u-e)/f);let n=e,a=32;for(I=1;I<=r;I++){const e=32-g*I%32;if(a<g){const i=n<<e>>>32-a,s=t<<32-a>>>32-a;n=t,c.push(i+s*2**(g-a)),a-=32-(g-a)}else c.push(n<<e>>>32-g),a-=g;0===a&&(a=32,n=t)}}else for(I=1;I<=r;I++){const e=32-g*I;c.push(u<<e>>>32-g)}}else{u-=a,i&&(u=0);for(let n=u;n<u+w;n+=h){switch(l){case 1:case 2:case 7:p=new DataView(e,n,1).getUint8(0);break;case 3:p=new DataView(e,n,2).getUint16(0,t);break;case 4:case 13:p=new DataView(e,n,4).getUint32(0,t);break;case 5:p=new DataView(e,n,4).getUint32(0,t)/new DataView(e,n+4,4).getUint32(0,t);break;case 6:p=new DataView(e,n,1).getInt8(0);break;case 8:p=new DataView(e,n,2).getInt16(0,t);break;case 9:p=new DataView(e,n,4).getInt32(0,t);break;case 10:p=new DataView(e,n,4).getInt32(0,t)/new DataView(e,n+4,4).getInt32(0,t);break;case 11:p=new DataView(e,n,4).getFloat32(0,t);break;case 12:p=new DataView(e,n,8).getFloat64(0,t);break;case 16:case 18:p=U(new DataView(e,n,8),0,t);break;case 17:p=v(new DataView(e,n,8),0,t);break;default:p=null}c.push(p)}}if(2===l){let e="";const t=c;for(c=[],I=0;I<t.length;I++)0===t[I]&&""!==e?(c.push(e),e=""):e+=String.fromCharCode(t[I]);""===e&&0!==c.length||c.push(e)}return n.values=c,!0}function b(e){var t,n;const a=e[0],i=I(a,"TILEWIDTH"),s=I(a,"TILELENGTH"),l=I(a,"IMAGEWIDTH"),r=I(a,"IMAGELENGTH"),o=I(a,"BITSPERSAMPLE"),f=I(a,"SAMPLESPERPIXEL"),h=null!=(t=I(a,"SAMPLEFORMAT"))?t:1,T=c(h,o),E=O(a),y=w(a,"GDAL_NODATA");let m;null!=y&&y.length&&(m=y.map((e=>parseFloat(e))),m.some((e=>isNaN(e)))&&(m=null));const A=null!=(n=I(a,"COMPRESSION"))?n:1;let S;switch(A){case 1:S="NONE";break;case 2:case 3:case 4:case 32771:S="CCITT";break;case 5:S="LZW";break;case 6:case 7:S="JPEG";break;case 32773:S="PACKBITS";break;case 8:case 32946:S="DEFLATE";break;case 34712:S="JPEG2000";break;case 34887:S="LERC";break;default:S=String(A)}let x=!0,b="";u.has(A)||(x=!1,b+="unsupported tag compression "+A),h>3&&(x=!1,b+="unsupported tag sampleFormat "+h),o%8!=0&&(x=!1,b+="unsupported tag bitsPerSample "+o);const D=p(a,"GEOASCIIPARAMS");let U;if(D){const e=D.split("|").find((e=>e.includes("ESRI PE String = "))),t=e?e.replace("ESRI PE String = ",""):"";U=t.startsWith("COMPD_CS")||t.startsWith("PROJCS")||t.startsWith("GEOGCS")?{wkid:null,wkt:t}:null}const v=d(a,"GEOTIEPOINTS"),L=d(a,"GEOPIXELSCALE"),P=d(a,"GEOTRANSMATRIX"),N=a.has("GEOKEYDIRECTORY")?a.get("GEOKEYDIRECTORY").data:null;let G,R,C=!1;if(N){C=2===I(N,"GTRasterTypeGeoKey");const e=I(N,"GTModelTypeGeoKey");if(2===e){const e=I(N,"GeographicTypeGeoKey");e>=1024&&e<=32766&&(U={wkid:e})}else if(1===e){const e=I(N,"ProjectedCSTypeGeoKey");e>=1024&&e<=32766&&(U={wkid:e})}}if(L&&v&&v.length>=6?(G=[L[0],0,v[3]-v[0]*L[0],0,-Math.abs(L[1]),v[4]-v[1]*L[1]],C&&(G[2]-=.5*G[0]+.5*G[1],G[5]-=.5*G[3]+.5*G[4])):P&&16===P.length&&(G=C?[P[0],P[1],P[3]-.5*P[0],P[4],P[5],P[7]-.5*P[5]]:[P[0],P[1],P[3],P[4],P[5],P[7]]),G){const e=[{x:0,y:r},{x:0,y:0},{x:l,y:r},{x:l,y:0}];let t,n=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY,s=Number.NEGATIVE_INFINITY;for(let l=0;l<e.length;l++)t=g(e[l],G),n=t.x>n?n:t.x,i=t.x<i?i:t.x,a=t.y>a?a:t.y,s=t.y<s?s:t.y;R={xmin:n,xmax:i,ymin:a,ymax:s,spatialReference:U}}else R={xmin:-.5,ymin:.5-r,xmax:l-.5,ymax:.5,spatialReference:U};const F=e.filter((e=>1===p(e,"NEWSUBFILETYPE")));let B,V,W,H,Y;if(F.length>0){B=Math.round(Math.log(l/I(F[0],"IMAGEWIDTH"))/Math.LN2);const e=F[F.length-1];V=Math.round(Math.log(l/I(e,"IMAGEWIDTH"))/Math.LN2),W=I(e,"TILEWIDTH"),H=I(e,"TILELENGTH")}W=V>0?W||i:null,H=V>0?H||s:null,i&&(Y=[{maxCol:Math.ceil(l/i)-1,maxRow:Math.ceil(r/s)-1,minRow:0,minCol:0}],F.forEach((e=>{Y.push({maxCol:Math.ceil(I(e,"IMAGEWIDTH")/I(e,"TILEWIDTH"))-1,maxRow:Math.ceil(I(e,"IMAGELENGTH")/I(e,"TILELENGTH"))-1,minRow:0,minCol:0})})));const _=p(e[0],"GDAL_METADATA"),K=M(_);return b+=" "+k({width:l,height:r,tileWidth:i,tileHeight:s,planes:f,ifds:e}),{width:l,height:r,tileWidth:i,tileHeight:s,planes:f,isBSQ:E,pixelType:T,compression:S,noData:m,isSupported:x,message:b,extent:R,affine:L?null:G,firstPyramidLevel:B,maximumPyramidLevel:V,pyramidBlockWidth:W,pyramidBlockHeight:H,tileBoundary:Y,metadata:K}}function O(e,t){const n=w(e,"PLANARCONFIGURATION");return n?2===n[0]:!!t&&t.isBSQ}function D(e){const{littleEndian:t,isBigTiff:n,firstIFD:a}=P(e);let i=a;const l=[];do{const a=N(e,t,i,0,s.TIFF_TAGS,n?8:4);if(!a.success)break;l.push(a.ifd),i=a.nextIFD}while(i>0);return{...b(l),littleEndian:t,isBigTiff:n,ifds:l}}function U(e,t,n){const a=e.getUint32(t,n),i=e.getUint32(t+4,n);return n?i*f+a:a*f+i}function v(e,t,n){let a=n?e.getInt32(t,n):e.getUint32(t,n),i=n?e.getUint32(t+4,n):e.getInt32(t+4,n);const s=(n?a:i)>=0?1:-1;n?a*=s:i*=s;return s*(n?i*f+a:a*f+i)}function L(e,t,n,a){return a?U(e,t,n):e.getUint32(t,n)}function P(e){const t=new DataView(e,0,16),n=t.getUint16(0,!1);let a=null;if(18761===n)a=!0;else{if(19789!==n)throw"unexpected endianess byte";a=!1}const i=t.getUint16(2,a);if(42!==i&&43!==i)throw"unexpected tiff identifier";let s=4;const l=43===i;if(l){const e=t.getUint16(s,a);if(s+=2,8!==e)throw"unsupported bigtiff version";if(0!==t.getUint16(s,a))throw"unsupported bigtiff version";s+=2}return{littleEndian:a,isBigTiff:l,firstIFD:L(t,s,a,l)}}function N(t,n,a,i=0,l=s.TIFF_TAGS,r=4){const o=T(t,n,a,i,l,r);let f;const u=o.ifd;if(u){if(s.ifdTags.forEach(((e,a)=>{u.has(a)&&(f=u.get(a),f.data=T(t,n,f.valueOffset-i,i,e).ifd)})),u.has("GEOKEYDIRECTORY")){f=u.get("GEOKEYDIRECTORY");const e=f.values;if(e&&e.length>4){const a=e[0]+"."+e[1]+"."+e[2];f.data=T(t,n,f.valueOffset+6-i,i,s.GEO_KEYS,2).ifd,f.data&&f.data.set("GEOTIFFVersion",{id:0,type:2,valueCount:1,valueOffset:null,values:[a]})}}if(u.has("XMP")){f=u.get("XMP");const t=f.values;"number"==typeof t[0]&&7===f.type&&(f.values=[e(new Uint8Array(t))])}}return o}function k(e){const{width:t,height:n,tileHeight:a,tileWidth:i}=e,s=e.planes,l=i?i*a:t*n,r=I(e.ifds[0],"BITSPERSAMPLE");let o="";return l*s>2**30/(r>8?r/8:1)&&(o=i?"tiled tiff exceeding 1 gigabits per tile is not supported":"scanline tiff exceeding 1 gigabits is not supported"),o}async function G(e,t){var n;const{headerInfo:a,ifd:i,offsets:s,sizes:l}=t,r=[];for(let h=0;h<s.length;h++){const t=await y(e,a.littleEndian,i,s[h],l[h]||e.byteLength);r.push(t)}const o=O(i,a),{pixelType:f,planes:u}=a,c=h(f),g=I(i,"TILEWIDTH"),w=I(i,"TILELENGTH"),d=null!=(n=I(i,"COMPRESSION"))?n:1,p=g*w;let T;const E=[];let m=r[0];const A=34887===d;for(let h=0;h<u;h++){if(T=new c(p),o&&A){m=r[h];for(let e=0;e<p;e++)T[e]=m[h][e+h]}else if(o||A&&!o)T=m.slice(p*h,p*(h+1));else for(let e=0;e<p;e++)T[e]=m[e*u+h];E.push(T)}const M=a.noData?a.noData[0]:null,x=a.metadata?a.metadata.statistics:null,b=x?x.map((e=>e.min)):null,D=x?x.map((e=>e.max)):null;let U,v;if(null!=M)if(U=new Uint8Array(p),Math.abs(M)>1e24)for(v=0;v<p;v++)Math.abs((E[0][v]-M)/M)<1e-6?U[v]=0:U[v]=1;else for(v=0;v<p;v++)E[0][v]===M?U[v]=0:U[v]=1;else b&&D&&t.applyMinMaxConstraint&&(U=S(E,b,D));return{pixelType:f,width:g,height:w,pixels:E,mask:U,noDataValue:M}}async function R(e,t=0,n){n=n||D(e);const{ifds:a,noData:i}=n;if(0===a.length)throw"no valid image file directory";const s=k(n);if(s)throw s;let l,r;const o=-1===t?a[a.length-1]:a[t],f=i?i[0]:null;if(r=n.tileWidth?await m(e,n,o):await A(e,n,o),null!==f){if(r.mask=new Uint8Array(r.width*r.height),Math.abs(f)>1e24)for(l=0;l<r.width*r.height;l++)Math.abs((r.pixels[0][l]-f)/f)<1e-6?r.mask[l]=0:r.mask[l]=1;else for(l=0;l<r.width*r.height;l++)r.pixels[0][l]===f?r.mask[l]=0:r.mask[l]=1;r.noDataValue=f}return r}export{R as decode,G as decodeTileOrStrip,b as getImageInfo,O as isBSQConfig,x as parseFieldValues,D as parseHeader,N as parseIFD,P as parseSignature};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{isSome as t,isNone as e}from"../../../core/maybe.js";import n from"../PixelBlock.js";function i(e){return t(e)&&"esri.layers.support.PixelBlock"===e.declaredClass&&e.pixels&&e.pixels.length>0}function l(t,e){if(null==e||!e.length||!i(t))return t;const l=t.pixels.length;return e&&e.some((t=>t>=l))||1===l&&1===e.length&&0===e[0]?t:l!==e.length||e.some(((t,e)=>t!==e))?new n({pixelType:t.pixelType,width:t.width,height:t.height,mask:t.mask,validPixelCount:t.validPixelCount,maskIsAlpha:t.maskIsAlpha,pixels:e.map((e=>t.pixels[e])),statistics:t.statistics&&e.map((e=>t.statistics[e]))}):t}function o(t){if(!t)return;const e=t.colormap;if(!e||0===e.length)return;const n=e.sort(((t,e)=>t[0]-e[0]));let i=0;n[0][0]<0&&(i=n[0][0]);const l=Math.max(256,n[n.length-1][0]-i+1),o=new Uint8Array(4*l),r=[];let s,a=0,f=0;const h=5===n[0].length;if(l>65536)return n.forEach((t=>{r[t[0]-i]=h?t.slice(1):t.slice(1).concat([255])})),{indexed2DColormap:r,offset:i,alphaSpecified:h};if(t.fillUnspecified)for(s=n[f],a=s[0]-i;a<l;a++)o[4*a]=s[1],o[4*a+1]=s[2],o[4*a+2]=s[3],o[4*a+3]=h?s[4]:255,a===s[0]-i&&(s=f===n.length-1?s:n[++f]);else for(a=0;a<n.length;a++)s=n[a],f=4*(s[0]-i),o[f]=s[1],o[f+1]=s[2],o[f+2]=s[3],o[f+3]=h?s[4]:255;return{indexedColormap:o,offset:i,alphaSpecified:h}}function r(t,e){if(!i(t))return t;if(!e&&(e.indexedColormap||e.indexed2DColormap))return t;const n=t.clone(),l=n.pixels;let o=n.mask;const r=n.width*n.height;if(1!==l.length)return t;const{indexedColormap:s,indexed2DColormap:a,offset:f,alphaSpecified:h}=e,c=s.length-1;let u=0;const x=l[0],p=new Uint8Array(x.length),m=new Uint8Array(x.length),d=new Uint8Array(x.length);let g,y=0;if(s)if(o)for(u=0;u<r;u++)o[u]&&(y=4*(x[u]-f),y<f||y>c?o[u]=0:(p[u]=s[y],m[u]=s[y+1],d[u]=s[y+2],o[u]=s[y+3]));else{for(o=new Uint8Array(r),u=0;u<r;u++)y=4*(x[u]-f),y<f||y>c?o[u]=0:(p[u]=s[y],m[u]=s[y+1],d[u]=s[y+2],o[u]=s[y+3]);n.mask=o}else if(o)for(u=0;u<r;u++)o[u]&&(g=a[x[u]],p[u]=g[0],m[u]=g[1],d[u]=g[2],o[u]=g[3]);else{for(o=new Uint8Array(r),u=0;u<r;u++)g=a[x[u]],p[u]=g[0],m[u]=g[1],d[u]=g[2],o[u]=g[3];n.mask=o}return n.pixels=[p,m,d],n.statistics=null,n.pixelType="u8",n.maskIsAlpha=h,n}function s(t){if(!i(t))return null;t.statistics||t.updateStatistics();const{pixels:e,mask:n,pixelType:l,statistics:o}=t,r=t.width*t.height,s=e.length;let a,f,h,c,u;const x=[],p=[];let m,d,g,y,w,M,k,A,U,C;const T=256;for(c=0;c<s;c++){if(m=new Uint32Array(T),g=e[c],"u8"===l)if(a=-.5,f=255.5,n)for(u=0;u<r;u++)n[u]&&m[g[u]]++;else for(u=0;u<r;u++)m[g[u]]++;else{if(a=o[c].minValue,f=o[c].maxValue,h=(f-a)/T,d=new Uint32Array(T+1),n)for(u=0;u<r;u++)n[u]&&d[Math.floor((g[u]-a)/h)]++;else for(u=0;u<r;u++)d[Math.floor((g[u]-a)/h)]++;for(u=0;u<255;u++)m[u]=d[u];m[255]=d[255]+d[256]}for(x.push({min:a,max:f,size:T,counts:m}),y=0,w=0,A=0,u=0;u<T;u++)y+=m[u],w+=u*m[u];for(U=w/y,u=0;u<T;u++)A+=m[u]*(u-U)**2;C=Math.sqrt(A/(y-1)),h=(f-a)/T,M=(U+.5)*h+a,k=C*h,p.push({min:a,max:f,avg:M,stddev:k})}return{statistics:p,histograms:x}}function a(t){const e=[];for(let n=0;n<t.length;n++){const{min:i,max:l,size:o,counts:r}=t[n];let s=0,a=0;for(let t=0;t<o;t++)s+=r[t],a+=t*r[t];const f=a/s;let h=0;for(let t=0;t<o;t++)h+=r[t]*(t-f)**2;const c=(l-i)/o,u=(f+.5)*c+i,x=Math.sqrt(h/(s-1))*c;e.push({min:i,max:l,avg:u,stddev:x})}return e}function f(t){const{minCutOff:e,maxCutOff:n,gamma:i,pixelType:l}=t,o=t.outMin||0,r=t.outMax||255;if(-1===["u8","u16","s8","s16"].indexOf(l))return null;const s=e.length;let a,f,c=0;"s8"===l?c=-127:"s16"===l&&(c=-32767);let u=256;["u16","s16"].indexOf(l)>-1&&(u=65536);const x=[],p=[],m=r-o;for(a=0;a<s;a++)p[a]=n[a]-e[a],x[a]=m/(n[a]-e[a]);const d=i&&i.length>=s,g=[];if(d)for(a=0;a<s;a++)i[a]>1?i[a]>2?g[a]=6.5+(i[a]-2)**2.5:g[a]=6.5+100*(2-i[a])**4:g[a]=1;let y;const w=[];let M,k,A;if(d)for(a=0;a<s;a++){for(A=[],f=0;f<u;f++)M=f+c,y=(M-e[a])/p[a],k=1,i[a]>1&&(k-=(1/m)**(y*g[a])),M<n[a]&&M>e[a]?A[f]=Math.floor(k*m*y**(1/i[a]))+o:M>=n[a]?A[f]=r:A[f]=o;w[a]=A}else for(a=0;a<s;a++){for(A=[],f=0;f<u;f++)M=f+c,M<=e[a]?A[f]=o:M>=n[a]?A[f]=r:A[f]=Math.floor((M-e[a])/p[a]*m)+o;w[a]=A}if(null!=t.contrastOffset){const e=h(t.contrastOffset,t.brightnessOffset);for(a=0;a<s;a++)for(A=w[a],f=0;f<u;f++)A[f]=e[A[f]]}return{lut:w,offset:c}}function h(t,e){const n=Math.min(Math.max(t,-100),100),i=Math.min(Math.max(e,-100),100),l=255,o=128;let r,s;const a=new Uint8Array(256);for(r=0;r<256;r++)n>0&&n<100?s=(200*r-100*l+2*l*i)/(2*(100-n))+o:n<=0&&n>-100?s=(200*r-100*l+2*l*i)*(100+n)/2e4+o:100===n?(s=200*r-100*l+(l+1)*(100-n)+2*l*i,s=s>0?l:0):-100===n&&(s=o),a[r]=s>l?l:s<0?0:s;return a}function c(t,e=256){e=Math.min(e,256);const{size:n,counts:i}=t,l=new Uint8Array(n),o=i.reduce(((t,n)=>t+n/e),0);let r=0,s=0,a=0,f=o;for(let h=0;h<n;h++)if(a+=i[h],!(h<n-1&&a+i[h+1]<f)){for(;r<e-1&&f<a;)r++,f+=o;for(let t=s;t<=h;t++)l[t]=r;s=h+1}for(let h=s;h<n;h++)l[h]=e-1;return l}function u(t,e){if(!i(t))return null;const n=t.clone(),{pixels:l,mask:o}=n,{minCutOff:r,maxCutOff:s,gamma:a}=e,f=e.outMin||0,h=e.outMax||255,c=n.width*n.height,u=l.length;let x,p,m,d,g;const y=h-f,w=[],M=[];for(x=0;x<u;x++)M[x]=s[x]-r[x],w[x]=y/(s[x]-r[x]);const k=a&&a.length>=u,A=[];if(k)for(x=0;x<u;x++)a[x]>1?a[x]>2?A[x]=6.5+(a[x]-2)**2.5:A[x]=6.5+100*(2-a[x])**4:A[x]=1;if(k)if(null!=o){for(p=0;p<c;p++)if(o[p])for(x=0;x<u;x++)m=l[x][p],g=(m-r[x])/M[x],d=1,a[x]>1&&(d-=(1/y)**(g*A[x])),m<s[x]&&m>r[x]?l[x][p]=Math.floor(d*y*g**(1/a[x]))+f:m>=s[x]?l[x][p]=h:l[x][p]=f}else for(p=0;p<c;p++)for(x=0;x<u;x++)m=l[x][p],g=(m-r[x])/M[x],d=1,a[x]>1&&(d-=(1/y)**(g*A[x])),m<s[x]&&m>r[x]?l[x][p]=Math.floor(d*y*g**(1/a[x]))+f:m>=s[x]?l[x][p]=h:l[x][p]=f;else if(null!=o){for(p=0;p<c;p++)if(o[p])for(x=0;x<u;x++)m=l[x][p],m<s[x]&&m>r[x]?l[x][p]=Math.floor((m-r[x])/M[x]*y)+f:m>=s[x]?l[x][p]=h:l[x][p]=f}else for(p=0;p<c;p++)for(x=0;x<u;x++)m=l[x][p],m<s[x]&&m>r[x]?l[x][p]=Math.floor((m-r[x])/M[x]*y)+f:m>=s[x]?l[x][p]=h:l[x][p]=f;return n.pixelType="u8",n.updateStatistics(),n}function x(t,e){if(!i(t))return null;const{pixels:l,mask:o}=t,r=t.width*t.height,s=l.length;let a=e.lut;const{offset:f}=e;let h,c;a&&1===a[0].length&&(a=l.map((()=>a)));const u=[];let x,p,m;if(f)if(null==o)for(h=0;h<s;h++){for(x=l[h],p=a[h],m=new Uint8Array(r),c=0;c<r;c++)m[c]=p[x[c]-f];u.push(m)}else for(h=0;h<s;h++){for(x=l[h],p=a[h],m=new Uint8Array(r),c=0;c<r;c++)o[c]&&(m[c]=p[x[c]-f]);u.push(m)}else if(null==o)for(h=0;h<s;h++){for(x=l[h],p=a[h],m=new Uint8Array(r),c=0;c<r;c++)m[c]=p[x[c]];u.push(m)}else for(h=0;h<s;h++){for(x=l[h],p=a[h],m=new Uint8Array(r),c=0;c<r;c++)o[c]&&(m[c]=p[x[c]]);u.push(m)}const d=new n({width:t.width,height:t.height,pixels:u,mask:o,pixelType:"u8"});return d.updateStatistics(),d}function p(t,e){if(!i(t))return null;const n=t.clone(),{pixels:l}=n,o=n.width*n.height,r=e.length,s=Math.floor(r/2),a=e[Math.floor(s)],f=l[0];let h,c,u,x,p,m,d=!1;const g=new Uint8Array(o),y=new Uint8Array(o),w=new Uint8Array(o);let M=n.mask;const k=4===e[0].mappedColor.length;for(M||(M=new Uint8Array(o),M.fill(k?255:1),n.mask=M),p=0;p<o;p++)if(M[p]){for(h=f[p],d=!1,m=s,c=a,u=0,x=r-1;x-u>1;){if(h===c.value){d=!0;break}h>c.value?u=m:x=m,m=Math.floor((u+x)/2),c=e[Math.floor(m)]}d||(h===e[u].value?(c=e[u],d=!0):h===e[x].value?(c=e[x],d=!0):h<e[u].value?(d=!1,c=null):h>e[u].value&&(h<e[x].value?(c=e[u],d=!0):x===r-1?(d=!1,c=null):(c=e[x],d=!0))),d?(g[p]=c.mappedColor[0],y[p]=c.mappedColor[1],w[p]=c.mappedColor[2],M[p]=c.mappedColor[3]):g[p]=y[p]=w[p]=M[p]=0}return n.pixels=[g,y,w],n.mask=M,n.pixelType="u8",n.maskIsAlpha=k,n}function m(t,e,n,i,l,o,r,s){return{xmin:l<=n*t?0:l<n*t+t?l-n*t:t,ymin:o<=i*e?0:o<i*e+e?o-i*e:e,xmax:l+r<=n*t?0:l+r<n*t+t?l+r-n*t:t,ymax:o+s<=i*e?0:o+s<i*e+e?o+s-i*e:e}}function d(t,n){if(!t||0===t.length)return null;const i=t.find((t=>t.pixelBlock));if(!i||e(i.pixelBlock))return null;const l=(i.extent.xmax-i.extent.xmin)/i.pixelBlock.width,o=(i.extent.ymax-i.extent.ymin)/i.pixelBlock.height,r=.01*Math.min(l,o),s=t.sort(((t,e)=>Math.abs(t.extent.ymax-e.extent.ymax)>r?e.extent.ymax-t.extent.ymax:Math.abs(t.extent.xmin-e.extent.xmin)>r?t.extent.xmin-e.extent.xmin:0)),a=Math.min.apply(null,s.map((t=>t.extent.xmin))),f=Math.min.apply(null,s.map((t=>t.extent.ymin))),h=Math.max.apply(null,s.map((t=>t.extent.xmax))),c=Math.max.apply(null,s.map((t=>t.extent.ymax))),u={x:Math.round((n.xmin-a)/l),y:Math.round((c-n.ymax)/o)},x={width:Math.round((h-a)/l),height:Math.round((c-f)/o)},p={width:Math.round((n.xmax-n.xmin)/l),height:Math.round((n.ymax-n.ymin)/o)};if(Math.round(x.width/i.pixelBlock.width)*Math.round(x.height/i.pixelBlock.height)!==s.length||u.x<0||u.y<0||x.width<p.width||x.height<p.height)return null;return{extent:n,pixelBlock:y(s.map((t=>t.pixelBlock)),x,{clipOffset:u,clipSize:p})}}function g(t,e,n,i,l,o){const{width:r,height:s}=n.block,{x:a,y:f}=n.offset,{width:h,height:c}=n.mosaic,u=m(r,s,i,l,a,f,h,c);let x=0,p=0;if(o){const t=o.hasGCSSShiftTransform?360:o.halfWorldWidth,e=r*o.resolutionX,n=o.startX+i*e,l=n+e;n<t&&l>t?p=o.rightPadding:n>=t&&(x=o.leftMargin-o.rightPadding,p=0)}if(u.xmax-=p,"number"!=typeof e)for(let m=u.ymin;m<u.ymax;m++){const n=(l*s+m-f)*h+(i*r-a)+x,o=m*r;for(let i=u.xmin;i<u.xmax;i++)t[n+i]=e[o+i]}else for(let m=u.ymin;m<u.ymax;m++){const n=(l*s+m-f)*h+(i*r-a)+x;for(let i=u.xmin;i<u.xmax;i++)t[n+i]=e}}function y(l,o,r={}){const{clipOffset:s,clipSize:a,alignmentInfo:f,blockWidths:h}=r;if(h)return w(l,o,{blockWidths:h});const c=l.find((t=>i(t)));if(e(c))return null;const u=a?a.width:o.width,x=a?a.height:o.height,p=c.width,m=c.height,d=o.width/p,y=o.height/m,M={offset:s||{x:0,y:0},mosaic:a||o,block:{width:p,height:m}},k=c.pixelType,A=n.getPixelArrayConstructor(k),U=c.pixels.length,C=[];let T,S;for(let t=0;t<U;t++){S=new A(u*x);for(let e=0;e<y;e++)for(let n=0;n<d;n++){const o=l[e*d+n];i(o)&&(T=o.pixels[t],g(S,T,M,n,e,f))}C.push(S)}let v;if(l.some((t=>e(t)||t.mask&&t.mask.length>0))){v=new Uint8Array(u*x);for(let e=0;e<y;e++)for(let n=0;n<d;n++){const i=l[e*d+n],o=t(i)?i.mask:null;g(v,o||(i?1:0),M,n,e,f)}}const B=new n({width:u,height:x,pixels:C,pixelType:k,mask:v});return B.updateStatistics(),B}function w(l,o,r){const s=l.find((e=>t(e)));if(e(s))return null;const a=l.some((e=>!t(e)||!!e.mask)),{width:f,height:h}=o,c=a?new Uint8Array(f*h):null,{blockWidths:u}=r,x=[],p=s.getPlaneCount(),m=n.getPixelArrayConstructor(s.pixelType);if(a)for(let t=0,e=0;t<l.length;e+=u[t],t++){const n=l[t];if(!i(n))continue;const o=n.mask;for(let i=0;i<h;i++)for(let l=0;l<u[t];l++)c[i*f+l+e]=null==o?255:o[i*n.width+l]}for(let t=0;t<p;t++){const e=new m(f*h);for(let n=0,o=0;n<l.length;o+=u[n],n++){const r=l[n];if(!i(r))continue;const s=r.pixels[t];if(null!=s)for(let t=0;t<h;t++)for(let i=0;i<u[n];i++)e[t*f+i+o]=s[t*r.width+i]}x.push(e)}const d=new n({width:f,height:h,mask:c,pixels:x,pixelType:s.pixelType});return d.updateStatistics(),d}function M(t,e,n){if(!i(t))return null;const{width:l,height:o}=t,r=e.x,s=e.y,a=n.width+r,f=n.height+s;if(r<0||s<0||a>l||f>o)return t;if(0===r&&0===s&&a===l&&f===o)return t;t.mask||(t.mask=new Uint8Array(l*o));const h=t.mask;for(let i=0;i<o;i++){const t=i*l;for(let e=0;e<l;e++)h[t+e]=i<s||i>=f||e<r||e>=a?0:1}return t.updateStatistics(),t}function k(t){if(!i(t))return null;const e=t.clone(),{width:n,height:l,pixels:o,mask:r}=t,s=o[0],a=e.pixels[0];for(let i=2;i<l-1;i++){const t=new Map;for(let l=i-2;l<i+2;l++)for(let e=0;e<4;e++){const i=l*n+e;C(t,s[i],r?r[i]:1)}a[i*n]=A(t),a[i*n+1]=a[i*n+2]=a[i*n];let e=3;for(;e<n-1;e++){let l=(i-2)*n+e+1;C(t,s[l],r?r[l]:1),l=(i-1)*n+e+1,C(t,s[l],r?r[l]:1),l=i*n+e+1,C(t,s[l],r?r[l]:1),l=(i+1)*n+e+1,C(t,s[l],r?r[l]:1),l=(i-2)*n+e-3,U(t,s[l],r?r[l]:1),l=(i-1)*n+e-3,U(t,s[l],r?r[l]:1),l=i*n+e-3,U(t,s[l],r?r[l]:1),l=(i+1)*n+e-3,U(t,s[l],r?r[l]:1),a[i*n+e]=A(t)}a[i*n+e+1]=a[i*n+e]}for(let i=0;i<n;i++)a[i]=a[n+i]=a[2*n+i],a[(l-1)*n+i]=a[(l-2)*n+i];return e.updateStatistics(),e}function A(t){if(0===t.size)return 0;let e=0,n=-1,i=0;const l=t.keys();let o=l.next();for(;!o.done;)i=t.get(o.value),i>e&&(n=o.value,e=i),o=l.next();return n}function U(t,e,n){if(0===n)return;const i=t.get(e);1===i?t.delete(e):t.set(e,i-1)}function C(t,e,n){0!==n&&t.set(e,t.has(e)?t.get(e)+1:1)}function T(t,e,l){let{x:o,y:r}=e;const{width:s,height:a}=l;if(0===o&&0===r&&a===t.height&&s===t.width)return t;const{width:f,height:h}=t,c=Math.max(0,r),u=Math.max(0,o),x=Math.min(o+s,f),p=Math.min(r+a,h);if(x<0||p<0||!i(t))return null;o=Math.max(0,-o),r=Math.max(0,-r);const{pixels:m,mask:d}=t,g=s*a,y=m.length,w=[];for(let i=0;i<y;i++){const e=m[i],l=n.createEmptyBand(t.pixelType,g);for(let t=c;t<p;t++){const n=t*f;let i=(t+r-c)*s+o;for(let t=u;t<x;t++)l[i++]=e[n+t]}w.push(l)}const M=new Uint8Array(g);for(let n=c;n<p;n++){const t=n*f;let e=(n+r-c)*s+o;for(let n=u;n<x;n++)M[e++]=d?d[t+n]:1}const k=new n({width:l.width,height:l.height,pixelType:t.pixelType,pixels:w,mask:M});return k.updateStatistics(),k}function S(t,e=!0){if(!i(t))return null;const{pixels:l,width:o,height:r,mask:s,pixelType:a}=t,f=[],h=Math.round(o/2),c=Math.round(r/2),u=r-1,x=o-1;for(let i=0;i<l.length;i++){const t=l[i],s=n.createEmptyBand(a,h*c);let p=0;for(let n=0;n<r;n+=2)for(let i=0;i<o;i+=2){const l=t[n*o+i];if(e){const e=i===x?l:t[n*o+i+1],r=n===u?l:t[n*o+i+o],a=i===x?r:n===u?e:t[n*o+i+o+1];s[p++]=(l+e+r+a)/4}else s[p++]=l}f.push(s)}let p=null;if(s){p=new Uint8Array(h*c);let t=0;for(let n=0;n<r;n+=2)for(let i=0;i<o;i+=2){const l=s[n*o+i];if(e){const e=i===x?l:s[n*o+i+1],r=n===u?l:s[n*o+i+o],a=i===x?r:n===u?e:s[n*o+i+o+1];p[t++]=l*e*r*a?1:0}else p[t++]=l}}return new n({width:h,height:c,pixelType:a,pixels:f,mask:p})}function v(t,e,n){if(!i(t))return null;const{width:l,height:o}=e;let{width:r,height:s}=t;const a=new Map,f={x:0,y:0},h=null==n?1:1+n;let c=t;for(let i=0;i<h;i++){const t=Math.ceil(r/l),n=Math.ceil(s/o);for(let r=0;r<n;r++){f.y=r*o;for(let n=0;n<t;n++){f.x=n*l;const t=T(c,f,e);a.set(`${i}/${r}/${n}`,t)}}i<h-1&&(c=S(c)),r=Math.round(r/2),s=Math.round(s/2)}return a}function B(t,e,n,i,l=.5){const{width:o,height:r}=t,{width:s,height:a}=e,f=i.cols,h=i.rows,c=Math.ceil(s/f-.1/f),u=Math.ceil(a/h-.1/h);let x,p,m,d,g,y,w;const M=c*f,k=M*u*h,A=new Float32Array(k),U=new Float32Array(k),C=new Uint32Array(k),T=new Uint32Array(k);let S,v,B=0;for(let b=0;b<u;b++)for(let t=0;t<c;t++){x=12*(b*c+t),p=n[x],m=n[x+1],d=n[x+2],g=n[x+3],y=n[x+4],w=n[x+5];for(let e=0;e<h;e++){B=(b*h+e)*M+t*f,v=(e+.5)/h;for(let t=0;t<e;t++)S=(t+.5)/f,A[B+t]=(p*S+m*v+d)*o-l,U[B+t]=(g*S+y*v+w)*r-l,C[B+t]=Math.round(A[B+t]),T[B+t]=Math.round(U[B+t])}x+=6,p=n[x],m=n[x+1],d=n[x+2],g=n[x+3],y=n[x+4],w=n[x+5];for(let e=0;e<h;e++){B=(b*h+e)*M+t*f,v=(e+.5)/h;for(let t=e;t<f;t++)S=(t+.5)/f,A[B+t]=(p*S+m*v+d)*o-l,U[B+t]=(g*S+y*v+w)*r-l,C[B+t]=Math.round(A[B+t]),T[B+t]=Math.round(U[B+t])}}return{offsets_x:A,offsets_y:U,offsets_xi:C,offsets_yi:T,gridWidth:M}}function b(t,e){const{coefficients:n,spacing:i}=e,{offsets_x:l,offsets_y:o,gridWidth:r}=B(t,t,n,{rows:i[0],cols:i[1]},.5),{width:s,height:a}=t,f=new Float32Array(s*a),h=180/Math.PI;for(let c=0;c<a;c++)for(let t=0;t<s;t++){const e=c*r+t,n=0===c?e:e-r,i=c===a-1?e:e+r,u=l[n]-l[i],x=o[i]-o[n];if(isNaN(u)||isNaN(x))f[c*s+t]=90;else{let e=Math.atan2(x,u)*h;e=(360+e)%360,f[c*s+t]=e}}return f}function O(t,e,l,o,r="nearest"){if(!i(t))return null;"majority"===r&&(t=k(t));const{pixels:s,mask:a,pixelType:f}=t,h=t.width,c=t.height,u=n.getPixelArrayConstructor(f),x=s.length,{width:p,height:m}=e;let d=!1;for(let n=0;n<l.length;n+=3)-1===l[n]&&-1===l[n+1]&&-1===l[n+2]&&(d=!0);const{offsets_x:g,offsets_y:y,offsets_xi:w,offsets_yi:M,gridWidth:A}=B({width:h,height:c},e,l,o,"majority"===r?0:.5);let U;const C=(t,e,n)=>{const i=t instanceof Float32Array||t instanceof Float64Array?0:.5;for(let l=0;l<m;l++){U=l*A;for(let o=0;o<p;o++){if(g[U]<0||y[U]<0)t[l*p+o]=0;else if(n)t[l*p+o]=e[w[U]+M[U]*h];else{const n=Math.floor(g[U]),r=Math.floor(y[U]),s=Math.ceil(g[U]),f=Math.ceil(y[U]),c=g[U]-n,u=y[U]-r;if(!a||a[n+r*h]&&a[n+r*h]&&a[n+f*h]&&a[s+f*h]){const a=(1-c)*e[n+r*h]+c*e[s+r*h],x=(1-c)*e[n+f*h]+c*e[s+f*h];t[l*p+o]=(1-u)*a+u*x+i}else t[l*p+o]=e[w[U]+M[U]*h]}U++}}},T=[];let S;for(let n=0;n<x;n++)S=new u(p*m),C(S,s[n],"nearest"===r||"majority"===r),T.push(S);const v=new n({width:p,height:m,pixelType:f,pixels:T});if(a)v.mask=new Uint8Array(p*m),C(v.mask,a,!0);else if(d){v.mask=new Uint8Array(p*m);for(let t=0;t<p*m;t++)v.mask[t]=g[t]<0||y[t]<0?0:1}return v.updateStatistics(),v}export{O as approximateTransform,T as clip,r as colorize,o as createColormapLUT,h as createContrastBrightnessLUT,c as createHistogramEqualizationLUT,f as createStretchLUT,a as estimateStatisticsFromHistograms,s as estimateStatisticsHistograms,l as extractBands,m as getClipBounds,b as getLocalArithmeticNorthRotations,i as isValidPixelBlock,x as lookupPixels,y as mosaic,d as mosaicPixelData,p as remapColor,k as resampleByMajority,M as setValidBoundary,v as split,u as stretch};
5
+ import{isSome as t,isNone as e}from"../../../core/maybe.js";import n from"../PixelBlock.js";function i(e){return t(e)&&"esri.layers.support.PixelBlock"===e.declaredClass&&e.pixels&&e.pixels.length>0}function l(t,e){if(null==e||!e.length||!i(t))return t;const l=t.pixels.length;return e&&e.some((t=>t>=l))||1===l&&1===e.length&&0===e[0]?t:l!==e.length||e.some(((t,e)=>t!==e))?new n({pixelType:t.pixelType,width:t.width,height:t.height,mask:t.mask,validPixelCount:t.validPixelCount,maskIsAlpha:t.maskIsAlpha,pixels:e.map((e=>t.pixels[e])),statistics:t.statistics&&e.map((e=>t.statistics[e]))}):t}function o(t){if(!t)return;const e=t.colormap;if(!e||0===e.length)return;const n=e.sort(((t,e)=>t[0]-e[0]));let i=0;n[0][0]<0&&(i=n[0][0]);const l=Math.max(256,n[n.length-1][0]-i+1),o=new Uint8Array(4*l),r=[];let s,a=0,f=0;const h=5===n[0].length;if(l>65536)return n.forEach((t=>{r[t[0]-i]=h?t.slice(1):t.slice(1).concat([255])})),{indexed2DColormap:r,offset:i,alphaSpecified:h};if(t.fillUnspecified)for(s=n[f],a=s[0]-i;a<l;a++)o[4*a]=s[1],o[4*a+1]=s[2],o[4*a+2]=s[3],o[4*a+3]=h?s[4]:255,a===s[0]-i&&(s=f===n.length-1?s:n[++f]);else for(a=0;a<n.length;a++)s=n[a],f=4*(s[0]-i),o[f]=s[1],o[f+1]=s[2],o[f+2]=s[3],o[f+3]=h?s[4]:255;return{indexedColormap:o,offset:i,alphaSpecified:h}}function r(t,e){if(!i(t))return t;if(!e&&(e.indexedColormap||e.indexed2DColormap))return t;const n=t.clone(),l=n.pixels;let o=n.mask;const r=n.width*n.height;if(1!==l.length)return t;const{indexedColormap:s,indexed2DColormap:a,offset:f,alphaSpecified:h}=e,c=s.length-1;let u=0;const p=l[0],x=new Uint8Array(p.length),m=new Uint8Array(p.length),d=new Uint8Array(p.length);let g,y=0;if(s)if(o)for(u=0;u<r;u++)o[u]&&(y=4*(p[u]-f),y<f||y>c?o[u]=0:(x[u]=s[y],m[u]=s[y+1],d[u]=s[y+2],o[u]=s[y+3]));else{for(o=new Uint8Array(r),u=0;u<r;u++)y=4*(p[u]-f),y<f||y>c?o[u]=0:(x[u]=s[y],m[u]=s[y+1],d[u]=s[y+2],o[u]=s[y+3]);n.mask=o}else if(o)for(u=0;u<r;u++)o[u]&&(g=a[p[u]],x[u]=g[0],m[u]=g[1],d[u]=g[2],o[u]=g[3]);else{for(o=new Uint8Array(r),u=0;u<r;u++)g=a[p[u]],x[u]=g[0],m[u]=g[1],d[u]=g[2],o[u]=g[3];n.mask=o}return n.pixels=[x,m,d],n.statistics=null,n.pixelType="u8",n.maskIsAlpha=h,n}function s(t){if(!i(t))return null;t.statistics||t.updateStatistics();const{pixels:e,mask:n,pixelType:l,statistics:o}=t,r=t.width*t.height,s=e.length;let a,f,h,c,u;const p=[],x=[];let m,d,g,y,w,M,k,A,U,C;const T=256;for(c=0;c<s;c++){if(m=new Uint32Array(T),g=e[c],"u8"===l)if(a=-.5,f=255.5,n)for(u=0;u<r;u++)n[u]&&m[g[u]]++;else for(u=0;u<r;u++)m[g[u]]++;else{if(a=o[c].minValue,f=o[c].maxValue,h=(f-a)/T,d=new Uint32Array(T+1),n)for(u=0;u<r;u++)n[u]&&d[Math.floor((g[u]-a)/h)]++;else for(u=0;u<r;u++)d[Math.floor((g[u]-a)/h)]++;for(u=0;u<255;u++)m[u]=d[u];m[255]=d[255]+d[256]}for(p.push({min:a,max:f,size:T,counts:m}),y=0,w=0,A=0,u=0;u<T;u++)y+=m[u],w+=u*m[u];for(U=w/y,u=0;u<T;u++)A+=m[u]*(u-U)**2;C=Math.sqrt(A/(y-1)),h=(f-a)/T,M=(U+.5)*h+a,k=C*h,x.push({min:a,max:f,avg:M,stddev:k})}return{statistics:x,histograms:p}}function a(t){const e=[];for(let n=0;n<t.length;n++){const{min:i,max:l,size:o,counts:r}=t[n];let s=0,a=0;for(let t=0;t<o;t++)s+=r[t],a+=t*r[t];const f=a/s;let h=0;for(let t=0;t<o;t++)h+=r[t]*(t-f)**2;const c=(l-i)/o,u=(f+.5)*c+i,p=Math.sqrt(h/(s-1))*c;e.push({min:i,max:l,avg:u,stddev:p})}return e}function f(t){const{minCutOff:e,maxCutOff:n,gamma:i,pixelType:l}=t,o=t.outMin||0,r=t.outMax||255;if(!["u8","u16","s8","s16"].includes(l))return null;const s=e.length;let a,f,c=0;"s8"===l?c=-127:"s16"===l&&(c=-32767);let u=256;["u16","s16"].includes(l)&&(u=65536);const p=[],x=[],m=r-o;for(a=0;a<s;a++)x[a]=n[a]-e[a],p[a]=m/(n[a]-e[a]);const d=i&&i.length>=s,g=[];if(d)for(a=0;a<s;a++)i[a]>1?i[a]>2?g[a]=6.5+(i[a]-2)**2.5:g[a]=6.5+100*(2-i[a])**4:g[a]=1;let y;const w=[];let M,k,A;if(d)for(a=0;a<s;a++){for(A=[],f=0;f<u;f++)M=f+c,y=(M-e[a])/x[a],k=1,i[a]>1&&(k-=(1/m)**(y*g[a])),M<n[a]&&M>e[a]?A[f]=Math.floor(k*m*y**(1/i[a]))+o:M>=n[a]?A[f]=r:A[f]=o;w[a]=A}else for(a=0;a<s;a++){for(A=[],f=0;f<u;f++)M=f+c,M<=e[a]?A[f]=o:M>=n[a]?A[f]=r:A[f]=Math.floor((M-e[a])/x[a]*m)+o;w[a]=A}if(null!=t.contrastOffset){const e=h(t.contrastOffset,t.brightnessOffset);for(a=0;a<s;a++)for(A=w[a],f=0;f<u;f++)A[f]=e[A[f]]}return{lut:w,offset:c}}function h(t,e){const n=Math.min(Math.max(t,-100),100),i=Math.min(Math.max(e,-100),100),l=255,o=128;let r,s;const a=new Uint8Array(256);for(r=0;r<256;r++)n>0&&n<100?s=(200*r-100*l+2*l*i)/(2*(100-n))+o:n<=0&&n>-100?s=(200*r-100*l+2*l*i)*(100+n)/2e4+o:100===n?(s=200*r-100*l+(l+1)*(100-n)+2*l*i,s=s>0?l:0):-100===n&&(s=o),a[r]=s>l?l:s<0?0:s;return a}function c(t,e=256){e=Math.min(e,256);const{size:n,counts:i}=t,l=new Uint8Array(n),o=i.reduce(((t,n)=>t+n/e),0);let r=0,s=0,a=0,f=o;for(let h=0;h<n;h++)if(a+=i[h],!(h<n-1&&a+i[h+1]<f)){for(;r<e-1&&f<a;)r++,f+=o;for(let t=s;t<=h;t++)l[t]=r;s=h+1}for(let h=s;h<n;h++)l[h]=e-1;return l}function u(t,e){if(!i(t))return null;const n=t.clone(),{pixels:l,mask:o}=n,{minCutOff:r,maxCutOff:s,gamma:a}=e,f=e.outMin||0,h=e.outMax||255,c=n.width*n.height,u=l.length;let p,x,m,d,g;const y=h-f,w=[],M=[];for(p=0;p<u;p++)M[p]=s[p]-r[p],w[p]=y/(s[p]-r[p]);const k=a&&a.length>=u,A=[];if(k)for(p=0;p<u;p++)a[p]>1?a[p]>2?A[p]=6.5+(a[p]-2)**2.5:A[p]=6.5+100*(2-a[p])**4:A[p]=1;if(k)if(null!=o){for(x=0;x<c;x++)if(o[x])for(p=0;p<u;p++)m=l[p][x],g=(m-r[p])/M[p],d=1,a[p]>1&&(d-=(1/y)**(g*A[p])),m<s[p]&&m>r[p]?l[p][x]=Math.floor(d*y*g**(1/a[p]))+f:m>=s[p]?l[p][x]=h:l[p][x]=f}else for(x=0;x<c;x++)for(p=0;p<u;p++)m=l[p][x],g=(m-r[p])/M[p],d=1,a[p]>1&&(d-=(1/y)**(g*A[p])),m<s[p]&&m>r[p]?l[p][x]=Math.floor(d*y*g**(1/a[p]))+f:m>=s[p]?l[p][x]=h:l[p][x]=f;else if(null!=o){for(x=0;x<c;x++)if(o[x])for(p=0;p<u;p++)m=l[p][x],m<s[p]&&m>r[p]?l[p][x]=Math.floor((m-r[p])/M[p]*y)+f:m>=s[p]?l[p][x]=h:l[p][x]=f}else for(x=0;x<c;x++)for(p=0;p<u;p++)m=l[p][x],m<s[p]&&m>r[p]?l[p][x]=Math.floor((m-r[p])/M[p]*y)+f:m>=s[p]?l[p][x]=h:l[p][x]=f;return n.pixelType="u8",n.updateStatistics(),n}function p(t,e){if(!i(t))return null;const{pixels:l,mask:o}=t,r=t.width*t.height,s=l.length;let a=e.lut;const{offset:f}=e;let h,c;a&&1===a[0].length&&(a=l.map((()=>a)));const u=[];let p,x,m;if(f)if(null==o)for(h=0;h<s;h++){for(p=l[h],x=a[h],m=new Uint8Array(r),c=0;c<r;c++)m[c]=x[p[c]-f];u.push(m)}else for(h=0;h<s;h++){for(p=l[h],x=a[h],m=new Uint8Array(r),c=0;c<r;c++)o[c]&&(m[c]=x[p[c]-f]);u.push(m)}else if(null==o)for(h=0;h<s;h++){for(p=l[h],x=a[h],m=new Uint8Array(r),c=0;c<r;c++)m[c]=x[p[c]];u.push(m)}else for(h=0;h<s;h++){for(p=l[h],x=a[h],m=new Uint8Array(r),c=0;c<r;c++)o[c]&&(m[c]=x[p[c]]);u.push(m)}const d=new n({width:t.width,height:t.height,pixels:u,mask:o,pixelType:"u8"});return d.updateStatistics(),d}function x(t,e){if(!i(t))return null;const n=t.clone(),{pixels:l}=n,o=n.width*n.height,r=e.length,s=Math.floor(r/2),a=e[Math.floor(s)],f=l[0];let h,c,u,p,x,m,d=!1;const g=new Uint8Array(o),y=new Uint8Array(o),w=new Uint8Array(o);let M=n.mask;const k=4===e[0].mappedColor.length;for(M||(M=new Uint8Array(o),M.fill(k?255:1),n.mask=M),x=0;x<o;x++)if(M[x]){for(h=f[x],d=!1,m=s,c=a,u=0,p=r-1;p-u>1;){if(h===c.value){d=!0;break}h>c.value?u=m:p=m,m=Math.floor((u+p)/2),c=e[Math.floor(m)]}d||(h===e[u].value?(c=e[u],d=!0):h===e[p].value?(c=e[p],d=!0):h<e[u].value?(d=!1,c=null):h>e[u].value&&(h<e[p].value?(c=e[u],d=!0):p===r-1?(d=!1,c=null):(c=e[p],d=!0))),d?(g[x]=c.mappedColor[0],y[x]=c.mappedColor[1],w[x]=c.mappedColor[2],M[x]=c.mappedColor[3]):g[x]=y[x]=w[x]=M[x]=0}return n.pixels=[g,y,w],n.mask=M,n.pixelType="u8",n.maskIsAlpha=k,n}function m(t,e,n,i,l,o,r,s){return{xmin:l<=n*t?0:l<n*t+t?l-n*t:t,ymin:o<=i*e?0:o<i*e+e?o-i*e:e,xmax:l+r<=n*t?0:l+r<n*t+t?l+r-n*t:t,ymax:o+s<=i*e?0:o+s<i*e+e?o+s-i*e:e}}function d(t,n){if(!t||0===t.length)return null;const i=t.find((t=>t.pixelBlock));if(!i||e(i.pixelBlock))return null;const l=(i.extent.xmax-i.extent.xmin)/i.pixelBlock.width,o=(i.extent.ymax-i.extent.ymin)/i.pixelBlock.height,r=.01*Math.min(l,o),s=t.sort(((t,e)=>Math.abs(t.extent.ymax-e.extent.ymax)>r?e.extent.ymax-t.extent.ymax:Math.abs(t.extent.xmin-e.extent.xmin)>r?t.extent.xmin-e.extent.xmin:0)),a=Math.min.apply(null,s.map((t=>t.extent.xmin))),f=Math.min.apply(null,s.map((t=>t.extent.ymin))),h=Math.max.apply(null,s.map((t=>t.extent.xmax))),c=Math.max.apply(null,s.map((t=>t.extent.ymax))),u={x:Math.round((n.xmin-a)/l),y:Math.round((c-n.ymax)/o)},p={width:Math.round((h-a)/l),height:Math.round((c-f)/o)},x={width:Math.round((n.xmax-n.xmin)/l),height:Math.round((n.ymax-n.ymin)/o)};if(Math.round(p.width/i.pixelBlock.width)*Math.round(p.height/i.pixelBlock.height)!==s.length||u.x<0||u.y<0||p.width<x.width||p.height<x.height)return null;return{extent:n,pixelBlock:y(s.map((t=>t.pixelBlock)),p,{clipOffset:u,clipSize:x})}}function g(t,e,n,i,l,o){const{width:r,height:s}=n.block,{x:a,y:f}=n.offset,{width:h,height:c}=n.mosaic,u=m(r,s,i,l,a,f,h,c);let p=0,x=0;if(o){const t=o.hasGCSSShiftTransform?360:o.halfWorldWidth,e=r*o.resolutionX,n=o.startX+i*e,l=n+e;n<t&&l>t?x=o.rightPadding:n>=t&&(p=o.leftMargin-o.rightPadding,x=0)}if(u.xmax-=x,"number"!=typeof e)for(let m=u.ymin;m<u.ymax;m++){const n=(l*s+m-f)*h+(i*r-a)+p,o=m*r;for(let i=u.xmin;i<u.xmax;i++)t[n+i]=e[o+i]}else for(let m=u.ymin;m<u.ymax;m++){const n=(l*s+m-f)*h+(i*r-a)+p;for(let i=u.xmin;i<u.xmax;i++)t[n+i]=e}}function y(l,o,r={}){const{clipOffset:s,clipSize:a,alignmentInfo:f,blockWidths:h}=r;if(h)return w(l,o,{blockWidths:h});const c=l.find((t=>i(t)));if(e(c))return null;const u=a?a.width:o.width,p=a?a.height:o.height,x=c.width,m=c.height,d=o.width/x,y=o.height/m,M={offset:s||{x:0,y:0},mosaic:a||o,block:{width:x,height:m}},k=c.pixelType,A=n.getPixelArrayConstructor(k),U=c.pixels.length,C=[];let T,S;for(let t=0;t<U;t++){S=new A(u*p);for(let e=0;e<y;e++)for(let n=0;n<d;n++){const o=l[e*d+n];i(o)&&(T=o.pixels[t],g(S,T,M,n,e,f))}C.push(S)}let v;if(l.some((t=>e(t)||t.mask&&t.mask.length>0))){v=new Uint8Array(u*p);for(let e=0;e<y;e++)for(let n=0;n<d;n++){const i=l[e*d+n],o=t(i)?i.mask:null;g(v,o||(i?1:0),M,n,e,f)}}const B=new n({width:u,height:p,pixels:C,pixelType:k,mask:v});return B.updateStatistics(),B}function w(l,o,r){const s=l.find((e=>t(e)));if(e(s))return null;const a=l.some((e=>!t(e)||!!e.mask)),{width:f,height:h}=o,c=a?new Uint8Array(f*h):null,{blockWidths:u}=r,p=[],x=s.getPlaneCount(),m=n.getPixelArrayConstructor(s.pixelType);if(a)for(let t=0,e=0;t<l.length;e+=u[t],t++){const n=l[t];if(!i(n))continue;const o=n.mask;for(let i=0;i<h;i++)for(let l=0;l<u[t];l++)c[i*f+l+e]=null==o?255:o[i*n.width+l]}for(let t=0;t<x;t++){const e=new m(f*h);for(let n=0,o=0;n<l.length;o+=u[n],n++){const r=l[n];if(!i(r))continue;const s=r.pixels[t];if(null!=s)for(let t=0;t<h;t++)for(let i=0;i<u[n];i++)e[t*f+i+o]=s[t*r.width+i]}p.push(e)}const d=new n({width:f,height:h,mask:c,pixels:p,pixelType:s.pixelType});return d.updateStatistics(),d}function M(t,e,n){if(!i(t))return null;const{width:l,height:o}=t,r=e.x,s=e.y,a=n.width+r,f=n.height+s;if(r<0||s<0||a>l||f>o)return t;if(0===r&&0===s&&a===l&&f===o)return t;t.mask||(t.mask=new Uint8Array(l*o));const h=t.mask;for(let i=0;i<o;i++){const t=i*l;for(let e=0;e<l;e++)h[t+e]=i<s||i>=f||e<r||e>=a?0:1}return t.updateStatistics(),t}function k(t){if(!i(t))return null;const e=t.clone(),{width:n,height:l,pixels:o,mask:r}=t,s=o[0],a=e.pixels[0];for(let i=2;i<l-1;i++){const t=new Map;for(let l=i-2;l<i+2;l++)for(let e=0;e<4;e++){const i=l*n+e;C(t,s[i],r?r[i]:1)}a[i*n]=A(t),a[i*n+1]=a[i*n+2]=a[i*n];let e=3;for(;e<n-1;e++){let l=(i-2)*n+e+1;C(t,s[l],r?r[l]:1),l=(i-1)*n+e+1,C(t,s[l],r?r[l]:1),l=i*n+e+1,C(t,s[l],r?r[l]:1),l=(i+1)*n+e+1,C(t,s[l],r?r[l]:1),l=(i-2)*n+e-3,U(t,s[l],r?r[l]:1),l=(i-1)*n+e-3,U(t,s[l],r?r[l]:1),l=i*n+e-3,U(t,s[l],r?r[l]:1),l=(i+1)*n+e-3,U(t,s[l],r?r[l]:1),a[i*n+e]=A(t)}a[i*n+e+1]=a[i*n+e]}for(let i=0;i<n;i++)a[i]=a[n+i]=a[2*n+i],a[(l-1)*n+i]=a[(l-2)*n+i];return e.updateStatistics(),e}function A(t){if(0===t.size)return 0;let e=0,n=-1,i=0;const l=t.keys();let o=l.next();for(;!o.done;)i=t.get(o.value),i>e&&(n=o.value,e=i),o=l.next();return n}function U(t,e,n){if(0===n)return;const i=t.get(e);1===i?t.delete(e):t.set(e,i-1)}function C(t,e,n){0!==n&&t.set(e,t.has(e)?t.get(e)+1:1)}function T(t,e,l){let{x:o,y:r}=e;const{width:s,height:a}=l;if(0===o&&0===r&&a===t.height&&s===t.width)return t;const{width:f,height:h}=t,c=Math.max(0,r),u=Math.max(0,o),p=Math.min(o+s,f),x=Math.min(r+a,h);if(p<0||x<0||!i(t))return null;o=Math.max(0,-o),r=Math.max(0,-r);const{pixels:m,mask:d}=t,g=s*a,y=m.length,w=[];for(let i=0;i<y;i++){const e=m[i],l=n.createEmptyBand(t.pixelType,g);for(let t=c;t<x;t++){const n=t*f;let i=(t+r-c)*s+o;for(let t=u;t<p;t++)l[i++]=e[n+t]}w.push(l)}const M=new Uint8Array(g);for(let n=c;n<x;n++){const t=n*f;let e=(n+r-c)*s+o;for(let n=u;n<p;n++)M[e++]=d?d[t+n]:1}const k=new n({width:l.width,height:l.height,pixelType:t.pixelType,pixels:w,mask:M});return k.updateStatistics(),k}function S(t,e=!0){if(!i(t))return null;const{pixels:l,width:o,height:r,mask:s,pixelType:a}=t,f=[],h=Math.round(o/2),c=Math.round(r/2),u=r-1,p=o-1;for(let i=0;i<l.length;i++){const t=l[i],s=n.createEmptyBand(a,h*c);let x=0;for(let n=0;n<r;n+=2)for(let i=0;i<o;i+=2){const l=t[n*o+i];if(e){const e=i===p?l:t[n*o+i+1],r=n===u?l:t[n*o+i+o],a=i===p?r:n===u?e:t[n*o+i+o+1];s[x++]=(l+e+r+a)/4}else s[x++]=l}f.push(s)}let x=null;if(s){x=new Uint8Array(h*c);let t=0;for(let n=0;n<r;n+=2)for(let i=0;i<o;i+=2){const l=s[n*o+i];if(e){const e=i===p?l:s[n*o+i+1],r=n===u?l:s[n*o+i+o],a=i===p?r:n===u?e:s[n*o+i+o+1];x[t++]=l*e*r*a?1:0}else x[t++]=l}}return new n({width:h,height:c,pixelType:a,pixels:f,mask:x})}function v(t,e,n){if(!i(t))return null;const{width:l,height:o}=e;let{width:r,height:s}=t;const a=new Map,f={x:0,y:0},h=null==n?1:1+n;let c=t;for(let i=0;i<h;i++){const t=Math.ceil(r/l),n=Math.ceil(s/o);for(let r=0;r<n;r++){f.y=r*o;for(let n=0;n<t;n++){f.x=n*l;const t=T(c,f,e);a.set(`${i}/${r}/${n}`,t)}}i<h-1&&(c=S(c)),r=Math.round(r/2),s=Math.round(s/2)}return a}function B(t,e,n,i,l=.5){const{width:o,height:r}=t,{width:s,height:a}=e,f=i.cols,h=i.rows,c=Math.ceil(s/f-.1/f),u=Math.ceil(a/h-.1/h);let p,x,m,d,g,y,w;const M=c*f,k=M*u*h,A=new Float32Array(k),U=new Float32Array(k),C=new Uint32Array(k),T=new Uint32Array(k);let S,v,B=0;for(let b=0;b<u;b++)for(let t=0;t<c;t++){p=12*(b*c+t),x=n[p],m=n[p+1],d=n[p+2],g=n[p+3],y=n[p+4],w=n[p+5];for(let e=0;e<h;e++){B=(b*h+e)*M+t*f,v=(e+.5)/h;for(let t=0;t<e;t++)S=(t+.5)/f,A[B+t]=(x*S+m*v+d)*o-l,U[B+t]=(g*S+y*v+w)*r-l,C[B+t]=Math.round(A[B+t]),T[B+t]=Math.round(U[B+t])}p+=6,x=n[p],m=n[p+1],d=n[p+2],g=n[p+3],y=n[p+4],w=n[p+5];for(let e=0;e<h;e++){B=(b*h+e)*M+t*f,v=(e+.5)/h;for(let t=e;t<f;t++)S=(t+.5)/f,A[B+t]=(x*S+m*v+d)*o-l,U[B+t]=(g*S+y*v+w)*r-l,C[B+t]=Math.round(A[B+t]),T[B+t]=Math.round(U[B+t])}}return{offsets_x:A,offsets_y:U,offsets_xi:C,offsets_yi:T,gridWidth:M}}function b(t,e){const{coefficients:n,spacing:i}=e,{offsets_x:l,offsets_y:o,gridWidth:r}=B(t,t,n,{rows:i[0],cols:i[1]},.5),{width:s,height:a}=t,f=new Float32Array(s*a),h=180/Math.PI;for(let c=0;c<a;c++)for(let t=0;t<s;t++){const e=c*r+t,n=0===c?e:e-r,i=c===a-1?e:e+r,u=l[n]-l[i],p=o[i]-o[n];if(isNaN(u)||isNaN(p))f[c*s+t]=90;else{let e=Math.atan2(p,u)*h;e=(360+e)%360,f[c*s+t]=e}}return f}function P(t,e,l,o,r="nearest"){if(!i(t))return null;"majority"===r&&(t=k(t));const{pixels:s,mask:a,pixelType:f}=t,h=t.width,c=t.height,u=n.getPixelArrayConstructor(f),p=s.length,{width:x,height:m}=e;let d=!1;for(let n=0;n<l.length;n+=3)-1===l[n]&&-1===l[n+1]&&-1===l[n+2]&&(d=!0);const{offsets_x:g,offsets_y:y,offsets_xi:w,offsets_yi:M,gridWidth:A}=B({width:h,height:c},e,l,o,"majority"===r?0:.5);let U;const C=(t,e,n)=>{const i=t instanceof Float32Array||t instanceof Float64Array?0:.5;for(let l=0;l<m;l++){U=l*A;for(let o=0;o<x;o++){if(g[U]<0||y[U]<0)t[l*x+o]=0;else if(n)t[l*x+o]=e[w[U]+M[U]*h];else{const n=Math.floor(g[U]),r=Math.floor(y[U]),s=Math.ceil(g[U]),f=Math.ceil(y[U]),c=g[U]-n,u=y[U]-r;if(!a||a[n+r*h]&&a[n+r*h]&&a[n+f*h]&&a[s+f*h]){const a=(1-c)*e[n+r*h]+c*e[s+r*h],p=(1-c)*e[n+f*h]+c*e[s+f*h];t[l*x+o]=(1-u)*a+u*p+i}else t[l*x+o]=e[w[U]+M[U]*h]}U++}}},T=[];let S;for(let n=0;n<p;n++)S=new u(x*m),C(S,s[n],"nearest"===r||"majority"===r),T.push(S);const v=new n({width:x,height:m,pixelType:f,pixels:T});if(a)v.mask=new Uint8Array(x*m),C(v.mask,a,!0);else if(d){v.mask=new Uint8Array(x*m);for(let t=0;t<x*m;t++)v.mask[t]=g[t]<0||y[t]<0?0:1}return v.updateStatistics(),v}export{P as approximateTransform,T as clip,r as colorize,o as createColormapLUT,h as createContrastBrightnessLUT,c as createHistogramEqualizationLUT,f as createStretchLUT,a as estimateStatisticsFromHistograms,s as estimateStatisticsHistograms,l as extractBands,m as getClipBounds,b as getLocalArithmeticNorthRotations,i as isValidPixelBlock,p as lookupPixels,y as mosaic,d as mosaicPixelData,x as remapColor,k as resampleByMajority,M as setValidBoundary,v as split,u as stretch};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../config.js";import r from"../../request.js";import{throwIfAborted as s}from"../../core/promiseUtils.js";import{removeTrailingSlash as t,getOrigin as o,isProtocolRelative as l,isAbsolute as i,join as n,normalize as u,removeFile as c,getAppBaseUrl as a,addQueryParameters as f}from"../../core/urlUtils.js";import p from"../../views/2d/engine/vectorTiles/style/VectorTileSource.js";const m=e.defaults&&e.defaults.io.corsEnabledServers;async function y(e,r){const s={source:null,sourceBase:null,sourceUrl:null,validatedSource:null,style:null,styleBase:null,styleUrl:null,sourceNameToSource:{},primarySourceName:"",spriteFormat:"png"},[t,o]="string"==typeof e?[e,null]:[null,e.jsonUrl];await h(s,"esri",e,o,r);const l={layerDefinition:s.validatedSource,url:t,serviceUrl:s.sourceUrl,style:s.style,styleUrl:s.styleUrl,spriteUrl:s.style.sprite&&S(s.styleBase,s.style.sprite),spriteFormat:s.spriteFormat,glyphsUrl:s.style.glyphs&&S(s.styleBase,s.style.glyphs),sourceNameToSource:s.sourceNameToSource,primarySourceName:s.primarySourceName};return d(l.spriteUrl),d(l.glyphsUrl),l}function d(e){if(!e)return;const r=o(e);m&&!m.includes(r)&&m.push(r)}function S(...e){let r;for(let s=0;s<e.length;++s)if(l(e[s])){if(r){const t=r.split("://")[0];r=t+":"+e[s].trim()}}else r=i(e[s])?e[s]:n(r,e[s]);return t(r)}async function h(e,t,o,l,i){let n,c,a;if(s(i),"string"==typeof o){const e=u(o);d(e),a=await r(e,{...i,responseType:"json",query:{f:"json",...null==i?void 0:i.query}}),a.ssl&&(n&&(n=n.replace(/^http:/i,"https:")),c&&(c=c.replace(/^http:/i,"https:"))),n=e,c=e}else a={data:o},n=o.jsonUrl||null,c=l;const f=a.data;return U(f)?(e.styleUrl=n||null,v(e,f,c,i)):x(f)?e.sourceUrl?w(e,f,c,!1,t,i):(e.sourceUrl=n||null,w(e,f,c,!0,t,i)):Promise.reject("You must specify the URL or the JSON for a service or for a style.")}function U(e){return!!e.sources}function x(e){return!U(e)}async function v(e,r,s,t){const o=s?c(s):a();e.styleBase=o,e.style=r,e.styleUrl&&d(e.styleUrl),r["sprite-format"]&&"webp"===r["sprite-format"].toLowerCase()&&(e.spriteFormat="webp");const l=[];if(r.sources&&r.sources.esri){const s=r.sources.esri;s.url?await h(e,"esri",S(o,s.url),void 0,t):l.push(h(e,"esri",s,o,t))}for(const i of Object.keys(r.sources))"esri"!==i&&"vector"===r.sources[i].type&&(r.sources[i].url?l.push(h(e,i,S(o,r.sources[i].url),void 0,t)):r.sources[i].tiles&&l.push(h(e,i,r.sources[i],o,t)));await Promise.all(l)}async function w(e,r,s,o,l,i){const n=s?t(s)+"/":a(),u=g(r,n),c=new p(l,f(n,null==i?void 0:i.query),u);if(!o&&e.primarySourceName in e.sourceNameToSource){const r=e.sourceNameToSource[e.primarySourceName];if(!r.isCompatibleWith(c))return Promise.resolve();null!=c.fullExtent&&(null!=r.fullExtent?r.fullExtent.union(c.fullExtent):r.fullExtent=c.fullExtent.clone()),r.tileInfo.lods.length<c.tileInfo.lods.length&&(r.tileInfo=c.tileInfo)}if(o?(e.sourceBase=n,e.source=r,e.validatedSource=u,e.primarySourceName=l,e.sourceUrl&&d(e.sourceUrl)):d(n),e.sourceNameToSource[l]=c,!e.style)return null==r.defaultStyles?Promise.reject():"string"==typeof r.defaultStyles?h(e,"",S(n,r.defaultStyles,"root.json"),void 0,i):h(e,"",r.defaultStyles,S(n,"root.json"),i)}function g(e,r){if(e.hasOwnProperty("tileInfo"))return e;const s={xmin:-20037507.067161843,ymin:-20037507.067161843,xmax:20037507.067161843,ymax:20037507.067161843,spatialReference:{wkid:102100}},t=512;let o=78271.51696400007,l=295828763.7957775;const i=[],n=e.hasOwnProperty("minzoom")?+e.minzoom:0,u=e.hasOwnProperty("maxzoom")?+e.maxzoom:22;for(let c=0;c<=u;c++)c>=n&&i.push({level:c,scale:l,resolution:o}),o/=2,l/=2;for(const c of e.tiles)d(S(r,c));return{capabilities:"TilesOnly",initialExtent:s,fullExtent:s,minScale:0,maxScale:0,tiles:e.tiles,tileInfo:{rows:t,cols:t,dpi:96,format:"pbf",origin:{x:-20037508.342787,y:20037508.342787},lods:i,spatialReference:{wkid:102100}}}}export{y as loadMetadata};
5
+ import e from"../../config.js";import r from"../../request.js";import{throwIfAborted as t}from"../../core/promiseUtils.js";import{removeTrailingSlash as s,getOrigin as o,isProtocolRelative as l,isAbsolute as n,join as i,normalize as u,removeFile as c,getAppBaseUrl as a,addQueryParameters as f}from"../../core/urlUtils.js";import p from"../../views/2d/engine/vectorTiles/style/VectorTileSource.js";const y=e.defaults&&e.defaults.io.corsEnabledServers;async function m(e,r){const t={source:null,sourceBase:null,sourceUrl:null,validatedSource:null,style:null,styleBase:null,styleUrl:null,sourceNameToSource:{},primarySourceName:"",spriteFormat:"png"},[s,o]="string"==typeof e?[e,null]:[null,e.jsonUrl];await S(t,"esri",e,o,r);const l={layerDefinition:t.validatedSource,url:s,serviceUrl:t.sourceUrl,style:t.style,styleUrl:t.styleUrl,spriteUrl:t.style.sprite&&h(t.styleBase,t.style.sprite),spriteFormat:t.spriteFormat,glyphsUrl:t.style.glyphs&&h(t.styleBase,t.style.glyphs),sourceNameToSource:t.sourceNameToSource,primarySourceName:t.primarySourceName};return d(l.spriteUrl),d(l.glyphsUrl),l}function d(e){if(!e)return;const r=o(e);y&&!y.includes(r)&&y.push(r)}function h(...e){let r;for(let t=0;t<e.length;++t)if(l(e[t])){if(r){const s=r.split("://")[0];r=s+":"+e[t].trim()}}else r=n(e[t])?e[t]:i(r,e[t]);return s(r)}async function S(e,s,o,l,n){let i,c,a;if(t(n),"string"==typeof o){const e=u(o);d(e),a=await r(e,{...n,responseType:"json",query:{f:"json",...null==n?void 0:n.query}}),a.ssl&&(i&&(i=i.replace(/^http:/i,"https:")),c&&(c=c.replace(/^http:/i,"https:"))),i=e,c=e}else a={data:o},i=o.jsonUrl||null,c=l;const f=a.data;if(U(f))return e.styleUrl=i||null,x(e,f,c,n);if(w(f))return e.sourceUrl?v(e,f,c,!1,s,n):(e.sourceUrl=i||null,v(e,f,c,!0,s,n));throw new Error("You must specify the URL or the JSON for a service or for a style.")}function U(e){return!!e.sources}function w(e){return!U(e)}async function x(e,r,t,s){const o=t?c(t):a();e.styleBase=o,e.style=r,e.styleUrl&&d(e.styleUrl),r["sprite-format"]&&"webp"===r["sprite-format"].toLowerCase()&&(e.spriteFormat="webp");const l=[];if(r.sources&&r.sources.esri){const t=r.sources.esri;t.url?await S(e,"esri",h(o,t.url),void 0,s):l.push(S(e,"esri",t,o,s))}for(const n of Object.keys(r.sources))"esri"!==n&&"vector"===r.sources[n].type&&(r.sources[n].url?l.push(S(e,n,h(o,r.sources[n].url),void 0,s)):r.sources[n].tiles&&l.push(S(e,n,r.sources[n],o,s)));await Promise.all(l)}async function v(e,r,t,o,l,n){const i=t?s(t)+"/":a(),u=g(r,i),c=new p(l,f(i,null==n?void 0:n.query),u);if(!o&&e.primarySourceName in e.sourceNameToSource){const r=e.sourceNameToSource[e.primarySourceName];if(!r.isCompatibleWith(c))return;null!=c.fullExtent&&(null!=r.fullExtent?r.fullExtent.union(c.fullExtent):r.fullExtent=c.fullExtent.clone()),r.tileInfo.lods.length<c.tileInfo.lods.length&&(r.tileInfo=c.tileInfo)}if(o?(e.sourceBase=i,e.source=r,e.validatedSource=u,e.primarySourceName=l,e.sourceUrl&&d(e.sourceUrl)):d(i),e.sourceNameToSource[l]=c,!e.style){if(null==r.defaultStyles)throw new Error;return"string"==typeof r.defaultStyles?S(e,"",h(i,r.defaultStyles,"root.json"),void 0,n):S(e,"",r.defaultStyles,h(i,"root.json"),n)}}function g(e,r){if(e.hasOwnProperty("tileInfo"))return e;const t={xmin:-20037507.067161843,ymin:-20037507.067161843,xmax:20037507.067161843,ymax:20037507.067161843,spatialReference:{wkid:102100}},s=512;let o=78271.51696400007,l=295828763.7957775;const n=[],i=e.hasOwnProperty("minzoom")?+e.minzoom:0,u=e.hasOwnProperty("maxzoom")?+e.maxzoom:22;for(let c=0;c<=u;c++)c>=i&&n.push({level:c,scale:l,resolution:o}),o/=2,l/=2;for(const c of e.tiles)d(h(r,c));return{capabilities:"TilesOnly",initialExtent:t,fullExtent:t,minScale:0,maxScale:0,tiles:e.tiles,tileInfo:{rows:s,cols:s,dpi:96,format:"pbf",origin:{x:-20037508.342787,y:20037508.342787},lods:n,spatialReference:{wkid:102100}}}}export{m as loadMetadata};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../core/Error.js";import{isNone as t}from"../../core/maybe.js";import{urlToObject as n}from"../../core/urlUtils.js";import r from"../../geometry/Extent.js";import i from"../../geometry/SpatialReference.js";import{isAxesOrderReversedForWkid as s}from"../ogc/crsUtils.js";const a={84:4326,83:4269,27:4267};function o(t){if(!t)return null;const n={idCounter:-1};if("string"==typeof t){t=(new DOMParser).parseFromString(t,"text/xml")}const i=t.documentElement;if("ServiceExceptionReport"===i.nodeName){const t=Array.prototype.slice.call(i.childNodes).map((e=>e.textContent)).join("\r\n");throw new e("wmslayer:wms-capabilities-xml-is-not-valid","The server returned errors when the WMS capabilities were requested.",t)}const s=d("Capability",i),a=d("Service",i),o=d("Request",s);if(!s||!a||!o)return null;const l=d("Layer",s);if(!l)return null;const m="WMS_Capabilities"===i.nodeName||"WMT_MS_Capabilities"===i.nodeName?i.getAttribute("version"):"1.3.0",f=h("Title",a,"")||h("Name",a,""),p=h("AccessConstraints",a,""),x=h("Abstract",a,""),b=parseInt(h("MaxWidth",a,"5000"),10),E=parseInt(h("MaxHeight",a,"5000"),10),S=g(o,"GetMap"),w=N(o,"GetMap"),I=y(l,m,n);let F,M=0;if(Array.prototype.slice.call(s.childNodes).forEach((e=>{"Layer"===e.nodeName&&(0===M?F=e:1===M?(I.name&&(I.name="",I.sublayers.push(y(F,m,n))),I.sublayers.push(y(e,m,n))):I.sublayers.push(y(e,m,n)),M++)})),!I)return null;let O,C;const T=I.fullExtents;if(O=I.sublayers,O||(O=[]),0===O.length&&O.push(I),C=I.extent,!C){const e=new r(O[0].extent);I.extent=e.toJSON(),C=I.extent}const R=I.spatialReferences.length>0?I.spatialReferences:u(I),v=N(o,"GetFeatureInfo");let V;if(v){const e=g(o,"GetFeatureInfo");e.indexOf("text/html")>-1?V="text/html":e.indexOf("text/plain")>-1&&(V="text/plain")}if(!V){const e=function(t){t&&(t.queryable=!1,t.sublayers&&t.sublayers.forEach((t=>{e(t)})))};e(I)}const U=c(O),_=I.minScale||0,q=I.maxScale||0,B=I.dimensions,D=U.reduce(((e,t)=>e.concat(t.dimensions)),[]),j=B.concat(D).filter(L);let k=null;if(j.length>0){let e=Number.POSITIVE_INFINITY,t=Number.NEGATIVE_INFINITY;j.forEach((n=>{const{extent:r}=n;A(r)?r.forEach((n=>{e=Math.min(e,n.getTime()),t=Math.max(t,n.getTime())})):r.forEach((n=>{e=Math.min(e,n.min.getTime()),t=Math.max(t,n.max.getTime())}))})),k={startTimeField:null,endTimeField:null,trackIdField:null,timeExtent:[e,t]}}return{copyright:p,description:x,dimensions:B,extent:C,fullExtents:T,featureInfoFormat:V,featureInfoUrl:v,mapUrl:w,maxWidth:b,maxHeight:E,maxScale:q,minScale:_,layers:U,spatialReferences:R,supportedImageFormatTypes:S,timeInfo:k,title:f,version:m}}function l(e){return e.length?e.filter((e=>e.popupEnabled&&e.name&&e.queryable)).map((e=>e.name)).join(","):""}function u(e){if(e.spatialReferences.length>0)return e.spatialReferences;if(e.sublayers)for(const t of e.sublayers){const e=u(t);if(e.length>0)return e}return[]}function c(e){let t=[];return e.forEach((e=>{t.push(e),e.sublayers&&e.sublayers.length&&(t=t.concat(c(e.sublayers)),delete e.sublayers)})),t}function m(e,t,n){var r;return null!=(r=t.getAttribute(e))?r:n}function f(e,t,n,r){const i=d(e,n);return i?m(t,i,r):r}function d(e,t){for(let n=0;n<t.childNodes.length;n++){const r=t.childNodes[n];if(E(r)&&r.nodeName===e)return r}return null}function p(e,t){const n=[];for(let r=0;r<t.childNodes.length;r++){const i=t.childNodes[r];E(i)&&i.nodeName===e&&n.push(i)}return n}function h(e,t,n){const r=d(e,t);return r?r.textContent:n}function x(e,t,n){if(!e)return null;const s=parseFloat(e.getAttribute("minx")),a=parseFloat(e.getAttribute("miny")),o=parseFloat(e.getAttribute("maxx")),l=parseFloat(e.getAttribute("maxy"));let u,c,m,f;n?(u=isNaN(a)?-Number.MAX_VALUE:a,c=isNaN(s)?-Number.MAX_VALUE:s,m=isNaN(l)?Number.MAX_VALUE:l,f=isNaN(o)?Number.MAX_VALUE:o):(u=isNaN(s)?-Number.MAX_VALUE:s,c=isNaN(a)?-Number.MAX_VALUE:a,m=isNaN(o)?Number.MAX_VALUE:o,f=isNaN(l)?Number.MAX_VALUE:l);const d=new i({wkid:t});return new r({xmin:u,ymin:c,xmax:m,ymax:f,spatialReference:d})}function N(e,t){const n=d(t,e);if(n){const e=d("DCPType",n);if(e){const t=d("HTTP",e);if(t){const e=d("Get",t);if(e){let t=f("OnlineResource","xlink:href",e,null);if(t)return t.indexOf("&")===t.length-1&&(t=t.substring(0,t.length-1)),F(t,["service","request"])}}}}return null}function g(e,t){const n=p("Operation",e);if(0===n.length){return p("Format",d(t,e)).map((e=>e.textContent))}const r=[];return n.forEach((e=>{if(e.getAttribute("name")===t){p("Format",e).forEach((e=>{r.push(e.textContent)}))}})),r}function b(e,t,n){const r=d(t,e);if(!r)return n;const{textContent:i}=r;if(null==i||""===i)return n;const s=Number(i);return isNaN(s)?n:s}function y(e,t,n){var o;if(!e)return null;const l={id:n.idCounter++,fullExtents:[],parentLayerId:null,queryable:"1"===e.getAttribute("queryable"),spatialReferences:[],sublayers:null},u=d("LatLonBoundingBox",e),c=d("EX_GeographicBoundingBox",e);let f=null;u&&(f=x(u,4326)),c&&(f=new r(0,0,0,0,new i({wkid:4326})),f.xmin=parseFloat(h("westBoundLongitude",c,"0")),f.ymin=parseFloat(h("southBoundLatitude",c,"0")),f.xmax=parseFloat(h("eastBoundLongitude",c,"0")),f.ymax=parseFloat(h("northBoundLatitude",c,"0"))),u||c||(f=new r(-180,-90,180,90,new i({wkid:4326}))),l.minScale=b(e,"MaxScaleDenominator",0),l.maxScale=b(e,"MinScaleDenominator",0);const N=["1.0.0","1.1.0","1.1.1"].indexOf(t)>-1?"SRS":"CRS";return Array.prototype.slice.call(e.childNodes).forEach((e=>{if("Name"===e.nodeName)l.name=e.textContent||"";else if("Title"===e.nodeName)l.title=e.textContent||"";else if("Abstract"===e.nodeName)l.description=e.textContent||"";else if("BoundingBox"===e.nodeName){const n=e.getAttribute(N);if(n&&0===n.indexOf("EPSG:")){const r=parseInt(n.substring(5),10);0===r||isNaN(r)||f||(f="1.3.0"===t?x(e,r,s(r)):x(e,r))}const r=n&&n.indexOf(":");if(r&&r>-1){let i=parseInt(n.substring(r+1,n.length),10);0===i||isNaN(i)||(i=a[i]?a[i]:i);const o="1.3.0"===t?x(e,i,s(i)):x(e,i);l.fullExtents.push(o)}}else if(e.nodeName===N){e.textContent.split(" ").forEach((e=>{const t=e.includes(":")?parseInt(e.split(":")[1],10):parseInt(e,10);if(0!==t&&!isNaN(t)){const e=a[t]?a[t]:t;l.spatialReferences.includes(e)||l.spatialReferences.push(e)}}))}else if("Style"!==e.nodeName||l.legendURL){if("Layer"===e.nodeName){const r=y(e,t,n);r&&(r.parentLayerId=l.id,l.sublayers||(l.sublayers=[]),l.sublayers.push(r))}}else{const t=d("LegendURL",e);if(t){const e=d("OnlineResource",t);e&&(l.legendURL=e.getAttribute("xlink:href"))}}})),l.extent=null==(o=f)?void 0:o.toJSON(),l.dimensions=p("Dimension",e).filter((e=>e.getAttribute("name")&&e.getAttribute("units")&&e.textContent)).map((e=>{const t=e.getAttribute("name"),n=e.getAttribute("units"),r=e.textContent,i=e.getAttribute("unitSymbol"),s=e.getAttribute("default"),a="0"!==m("default",e,"0"),o="0"!==m("nearestValue",e,"0"),l="0"!==m("current",e,"0");if(L({name:t,units:n})){return{name:"time",units:"ISO8601",extent:C(r),default:C(s),multipleValues:a,nearestValue:o,current:l}}if(w({name:t,units:n})){return{name:"elevation",units:n,extent:M(r),unitSymbol:i,default:M(s),multipleValues:a,nearestValue:o}}return{name:t,units:n,extent:O(r),unitSymbol:i,default:O(s),multipleValues:a,nearestValue:o}})),l}function A(e){return Array.isArray(e)&&e.length>0&&e[0]instanceof Date}function E(e){return e.nodeType===Node.ELEMENT_NODE}function S(e){return void 0!==e.min&&void 0!==e.max}function w(e){return/^elevation$/i.test(e.name)&&/^(epsg|crs):\d+$/i.test(e.units)}function I(e){return!L(e)&&!w(e)}function L(e){return/^time$/i.test(e.name)&&/^iso8601$/i.test(e.units)}function F(e,t){const r=[],i=n(e);for(const n in i.query)i.query.hasOwnProperty(n)&&-1===t.indexOf(n.toLowerCase())&&r.push(n+"="+i.query[n]);return i.path+(r.length?"?"+r.join("&"):"")}function M(e){if(!e)return null;const t=-1!==e.indexOf("/"),n=e.split(",");return t?n.map((e=>{const t=e.split("/");if(t.length<2)return null;return{min:parseFloat(t[0]),max:parseFloat(t[1]),resolution:t.length>=3&&"0"!==t[2]?parseFloat(t[2]):void 0}})).filter((e=>e)):n.map((e=>parseFloat(e)))}function O(e){if(!e)return null;const t=-1!==e.indexOf("/"),n=e.split(",");return t?n.map((e=>{const t=e.split("/");if(t.length<2)return null;return{min:t[0],max:t[1],resolution:t.length>=3&&"0"!==t[2]?t[2]:void 0}})).filter((e=>e)):n}function C(e){if(!e)return null;const t=-1!==e.indexOf("/"),n=e.split(",");return t?n.map((e=>{const t=e.split("/");if(t.length<2)return null;return{min:new Date(t[0]),max:new Date(t[1]),resolution:t.length>=3&&"0"!==t[2]?T(t[2]):void 0}})).filter((e=>e)):n.map((e=>new Date(e)))}function T(e){const t=/(?:p(\d+y|\d+(?:.|,)\d+y)?(\d+m|\d+(?:.|,)\d+m)?(\d+d|\d+(?:.|,)\d+d)?)?(?:t(\d+h|\d+(?:.|,)\d+h)?(\d+m|\d+(?:.|,)\d+m)?(\d+s|\d+(?:.|,)\d+s)?)?/i,n=e.match(t);if(!n)return null;return{years:R(n[1]),months:R(n[2]),days:R(n[3]),hours:R(n[4]),minutes:R(n[5]),seconds:R(n[6])}}function R(e){if(!e)return 0;const t=/(?:\d+(?:.|,)\d+|\d+)/,n=e.match(t);if(!n)return 0;const r=n[0].replace(",",".");return Number(r)}function v(e){return e.toISOString().replace(/\.[0-9]{3}/,"")}const V=new Set([102100,3857,102113,900913]),U=new Set([3395,54004]);function _(e,n){let r=e.wkid;return t(n)?r:(!n.includes(r)&&e.latestWkid&&(r=e.latestWkid),V.has(r)?n.find((e=>V.has(e)))||n.find((e=>U.has(e)))||102100:r)}export{T as fromISODuration,l as getPopupLayers,S as isDimensionInterval,w as isElevationDimension,I as isGenericDimension,L as isTimeDimension,_ as normalizeWKID,o as parseCapabilities,v as toISOString};
5
+ import e from"../../core/Error.js";import{isNone as t}from"../../core/maybe.js";import{urlToObject as n}from"../../core/urlUtils.js";import r from"../../geometry/Extent.js";import i from"../../geometry/SpatialReference.js";import{isAxesOrderReversedForWkid as s}from"../ogc/crsUtils.js";const a={84:4326,83:4269,27:4267};function o(t){if(!t)return null;const n={idCounter:-1};if("string"==typeof t){t=(new DOMParser).parseFromString(t,"text/xml")}const i=t.documentElement;if("ServiceExceptionReport"===i.nodeName){const t=Array.prototype.slice.call(i.childNodes).map((e=>e.textContent)).join("\r\n");throw new e("wmslayer:wms-capabilities-xml-is-not-valid","The server returned errors when the WMS capabilities were requested.",t)}const s=d("Capability",i),a=d("Service",i),o=d("Request",s);if(!s||!a||!o)return null;const l=d("Layer",s);if(!l)return null;const m="WMS_Capabilities"===i.nodeName||"WMT_MS_Capabilities"===i.nodeName?i.getAttribute("version"):"1.3.0",f=h("Title",a,"")||h("Name",a,""),p=h("AccessConstraints",a,""),x=h("Abstract",a,""),b=parseInt(h("MaxWidth",a,"5000"),10),E=parseInt(h("MaxHeight",a,"5000"),10),S=g(o,"GetMap"),w=N(o,"GetMap"),I=y(l,m,n);let F,M=0;if(Array.prototype.slice.call(s.childNodes).forEach((e=>{"Layer"===e.nodeName&&(0===M?F=e:1===M?(I.name&&(I.name="",I.sublayers.push(y(F,m,n))),I.sublayers.push(y(e,m,n))):I.sublayers.push(y(e,m,n)),M++)})),!I)return null;let C,T;const R=I.fullExtents;if(C=I.sublayers,C||(C=[]),0===C.length&&C.push(I),T=I.extent,!T){const e=new r(C[0].extent);I.extent=e.toJSON(),T=I.extent}const v=I.spatialReferences.length>0?I.spatialReferences:u(I),V=N(o,"GetFeatureInfo");let U;if(V){const e=g(o,"GetFeatureInfo");e.includes("text/html")?U="text/html":e.includes("text/plain")&&(U="text/plain")}if(!U){const e=function(t){t&&(t.queryable=!1,t.sublayers&&t.sublayers.forEach((t=>{e(t)})))};e(I)}const _=c(C),O=I.minScale||0,q=I.maxScale||0,B=I.dimensions,D=_.reduce(((e,t)=>e.concat(t.dimensions)),[]),j=B.concat(D).filter(L);let k=null;if(j.length>0){let e=Number.POSITIVE_INFINITY,t=Number.NEGATIVE_INFINITY;j.forEach((n=>{const{extent:r}=n;A(r)?r.forEach((n=>{e=Math.min(e,n.getTime()),t=Math.max(t,n.getTime())})):r.forEach((n=>{e=Math.min(e,n.min.getTime()),t=Math.max(t,n.max.getTime())}))})),k={startTimeField:null,endTimeField:null,trackIdField:null,timeExtent:[e,t]}}return{copyright:p,description:x,dimensions:B,extent:T,fullExtents:R,featureInfoFormat:U,featureInfoUrl:V,mapUrl:w,maxWidth:b,maxHeight:E,maxScale:q,minScale:O,layers:_,spatialReferences:v,supportedImageFormatTypes:S,timeInfo:k,title:f,version:m}}function l(e){return e.length?e.filter((e=>e.popupEnabled&&e.name&&e.queryable)).map((e=>e.name)).join(","):""}function u(e){if(e.spatialReferences.length>0)return e.spatialReferences;if(e.sublayers)for(const t of e.sublayers){const e=u(t);if(e.length>0)return e}return[]}function c(e){let t=[];return e.forEach((e=>{t.push(e),e.sublayers&&e.sublayers.length&&(t=t.concat(c(e.sublayers)),delete e.sublayers)})),t}function m(e,t,n){var r;return null!=(r=t.getAttribute(e))?r:n}function f(e,t,n,r){const i=d(e,n);return i?m(t,i,r):r}function d(e,t){for(let n=0;n<t.childNodes.length;n++){const r=t.childNodes[n];if(E(r)&&r.nodeName===e)return r}return null}function p(e,t){const n=[];for(let r=0;r<t.childNodes.length;r++){const i=t.childNodes[r];E(i)&&i.nodeName===e&&n.push(i)}return n}function h(e,t,n){const r=d(e,t);return r?r.textContent:n}function x(e,t,n){if(!e)return null;const s=parseFloat(e.getAttribute("minx")),a=parseFloat(e.getAttribute("miny")),o=parseFloat(e.getAttribute("maxx")),l=parseFloat(e.getAttribute("maxy"));let u,c,m,f;n?(u=isNaN(a)?-Number.MAX_VALUE:a,c=isNaN(s)?-Number.MAX_VALUE:s,m=isNaN(l)?Number.MAX_VALUE:l,f=isNaN(o)?Number.MAX_VALUE:o):(u=isNaN(s)?-Number.MAX_VALUE:s,c=isNaN(a)?-Number.MAX_VALUE:a,m=isNaN(o)?Number.MAX_VALUE:o,f=isNaN(l)?Number.MAX_VALUE:l);const d=new i({wkid:t});return new r({xmin:u,ymin:c,xmax:m,ymax:f,spatialReference:d})}function N(e,t){const n=d(t,e);if(n){const e=d("DCPType",n);if(e){const t=d("HTTP",e);if(t){const e=d("Get",t);if(e){let t=f("OnlineResource","xlink:href",e,null);if(t)return t.indexOf("&")===t.length-1&&(t=t.substring(0,t.length-1)),F(t,["service","request"])}}}}return null}function g(e,t){const n=p("Operation",e);if(0===n.length){return p("Format",d(t,e)).map((e=>e.textContent))}const r=[];return n.forEach((e=>{if(e.getAttribute("name")===t){p("Format",e).forEach((e=>{r.push(e.textContent)}))}})),r}function b(e,t,n){const r=d(t,e);if(!r)return n;const{textContent:i}=r;if(null==i||""===i)return n;const s=Number(i);return isNaN(s)?n:s}function y(e,t,n){var o;if(!e)return null;const l={id:n.idCounter++,fullExtents:[],parentLayerId:null,queryable:"1"===e.getAttribute("queryable"),spatialReferences:[],sublayers:null},u=d("LatLonBoundingBox",e),c=d("EX_GeographicBoundingBox",e);let f=null;u&&(f=x(u,4326)),c&&(f=new r(0,0,0,0,new i({wkid:4326})),f.xmin=parseFloat(h("westBoundLongitude",c,"0")),f.ymin=parseFloat(h("southBoundLatitude",c,"0")),f.xmax=parseFloat(h("eastBoundLongitude",c,"0")),f.ymax=parseFloat(h("northBoundLatitude",c,"0"))),u||c||(f=new r(-180,-90,180,90,new i({wkid:4326}))),l.minScale=b(e,"MaxScaleDenominator",0),l.maxScale=b(e,"MinScaleDenominator",0);const N=["1.0.0","1.1.0","1.1.1"].includes(t)?"SRS":"CRS";return Array.prototype.slice.call(e.childNodes).forEach((e=>{if("Name"===e.nodeName)l.name=e.textContent||"";else if("Title"===e.nodeName)l.title=e.textContent||"";else if("Abstract"===e.nodeName)l.description=e.textContent||"";else if("BoundingBox"===e.nodeName){const n=e.getAttribute(N);if(n&&0===n.indexOf("EPSG:")){const r=parseInt(n.substring(5),10);0===r||isNaN(r)||f||(f="1.3.0"===t?x(e,r,s(r)):x(e,r))}const r=n&&n.indexOf(":");if(r&&r>-1){let i=parseInt(n.substring(r+1,n.length),10);0===i||isNaN(i)||(i=a[i]?a[i]:i);const o="1.3.0"===t?x(e,i,s(i)):x(e,i);l.fullExtents.push(o)}}else if(e.nodeName===N){e.textContent.split(" ").forEach((e=>{const t=e.includes(":")?parseInt(e.split(":")[1],10):parseInt(e,10);if(0!==t&&!isNaN(t)){const e=a[t]?a[t]:t;l.spatialReferences.includes(e)||l.spatialReferences.push(e)}}))}else if("Style"!==e.nodeName||l.legendURL){if("Layer"===e.nodeName){const r=y(e,t,n);r&&(r.parentLayerId=l.id,l.sublayers||(l.sublayers=[]),l.sublayers.push(r))}}else{const t=d("LegendURL",e);if(t){const e=d("OnlineResource",t);e&&(l.legendURL=e.getAttribute("xlink:href"))}}})),l.extent=null==(o=f)?void 0:o.toJSON(),l.dimensions=p("Dimension",e).filter((e=>e.getAttribute("name")&&e.getAttribute("units")&&e.textContent)).map((e=>{const t=e.getAttribute("name"),n=e.getAttribute("units"),r=e.textContent,i=e.getAttribute("unitSymbol"),s=e.getAttribute("default"),a="0"!==m("default",e,"0"),o="0"!==m("nearestValue",e,"0"),l="0"!==m("current",e,"0");if(L({name:t,units:n})){return{name:"time",units:"ISO8601",extent:T(r),default:T(s),multipleValues:a,nearestValue:o,current:l}}if(w({name:t,units:n})){return{name:"elevation",units:n,extent:M(r),unitSymbol:i,default:M(s),multipleValues:a,nearestValue:o}}return{name:t,units:n,extent:C(r),unitSymbol:i,default:C(s),multipleValues:a,nearestValue:o}})),l}function A(e){return Array.isArray(e)&&e.length>0&&e[0]instanceof Date}function E(e){return e.nodeType===Node.ELEMENT_NODE}function S(e){return void 0!==e.min&&void 0!==e.max}function w(e){return/^elevation$/i.test(e.name)&&/^(epsg|crs):\d+$/i.test(e.units)}function I(e){return!L(e)&&!w(e)}function L(e){return/^time$/i.test(e.name)&&/^iso8601$/i.test(e.units)}function F(e,t){const r=[],i=n(e);for(const n in i.query)i.query.hasOwnProperty(n)&&(t.includes(n.toLowerCase())||r.push(n+"="+i.query[n]));return i.path+(r.length?"?"+r.join("&"):"")}function M(e){if(!e)return null;const t=e.includes("/"),n=e.split(",");return t?n.map((e=>{const t=e.split("/");if(t.length<2)return null;return{min:parseFloat(t[0]),max:parseFloat(t[1]),resolution:t.length>=3&&"0"!==t[2]?parseFloat(t[2]):void 0}})).filter((e=>e)):n.map((e=>parseFloat(e)))}function C(e){if(!e)return null;const t=e.includes("/"),n=e.split(",");return t?n.map((e=>{const t=e.split("/");if(t.length<2)return null;return{min:t[0],max:t[1],resolution:t.length>=3&&"0"!==t[2]?t[2]:void 0}})).filter((e=>e)):n}function T(e){if(!e)return null;const t=e.includes("/"),n=e.split(",");return t?n.map((e=>{const t=e.split("/");if(t.length<2)return null;return{min:new Date(t[0]),max:new Date(t[1]),resolution:t.length>=3&&"0"!==t[2]?R(t[2]):void 0}})).filter((e=>e)):n.map((e=>new Date(e)))}function R(e){const t=/(?:p(\d+y|\d+(?:.|,)\d+y)?(\d+m|\d+(?:.|,)\d+m)?(\d+d|\d+(?:.|,)\d+d)?)?(?:t(\d+h|\d+(?:.|,)\d+h)?(\d+m|\d+(?:.|,)\d+m)?(\d+s|\d+(?:.|,)\d+s)?)?/i,n=e.match(t);if(!n)return null;return{years:v(n[1]),months:v(n[2]),days:v(n[3]),hours:v(n[4]),minutes:v(n[5]),seconds:v(n[6])}}function v(e){if(!e)return 0;const t=/(?:\d+(?:.|,)\d+|\d+)/,n=e.match(t);if(!n)return 0;const r=n[0].replace(",",".");return Number(r)}function V(e){return e.toISOString().replace(/\.[0-9]{3}/,"")}const U=new Set([102100,3857,102113,900913]),_=new Set([3395,54004]);function O(e,n){let r=e.wkid;return t(n)?r:(!n.includes(r)&&e.latestWkid&&(r=e.latestWkid),U.has(r)?n.find((e=>U.has(e)))||n.find((e=>_.has(e)))||102100:r)}export{R as fromISODuration,l as getPopupLayers,S as isDimensionInterval,w as isElevationDimension,I as isGenericDimension,L as isTimeDimension,O as normalizeWKID,o as parseCapabilities,V as toISOString};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../core/Error.js";import{isSome as t}from"../../core/maybe.js";import n from"../../geometry/Extent.js";import i from"../../geometry/Point.js";import{getReferenceEllipsoidFromWKID as r}from"../../geometry/projectionEllipsoid.js";import o from"../../geometry/support/WKIDUnitConversion.js";import{isAxesOrderReversedForWkid as l}from"../ogc/crsUtils.js";import{visitXML as s}from"../ogc/xmlUtils.js";import a from"./TileInfo.js";const c=90.71428571428571;function u(t,n){var i,r;t=t.replace(/ows:/gi,"");const o=(new DOMParser).parseFromString(t,"text/xml").documentElement,l=new Map,s=new Map,a=f("Contents",o);if(!a)throw new e("wmtslayer:wmts-capabilities-xml-is-not-valid");const c=f("OperationsMetadata",o),u=null==c?void 0:c.querySelector("[name='GetTile']"),p=null==u?void 0:u.getElementsByTagName("Get"),d=p&&Array.prototype.slice.call(p),g=null!=(i=(null==n||null==(r=n.url)?void 0:r.indexOf("https"))>-1)&&i;let C,M,T=n.serviceMode,y=n&&n.url;if(d&&d.length&&d.some((e=>{const t=f("Constraint",e);return!t||h("AllowedValues","Value",T,t)?(y=e.attributes[0].nodeValue,!0):(!t||h("AllowedValues","Value","RESTful",t)||h("AllowedValues","Value","REST",t)?M=e.attributes[0].nodeValue:t&&!h("AllowedValues","Value","KVP",t)||(C=e.attributes[0].nodeValue),!1)})),!y)if(M)y=M,T="RESTful";else if(C)y=C,T="KVP";else{const e=f("ServiceMetadataURL",o);y=e&&e.getAttribute("xlink:href")}const R=y.indexOf("1.0.0/");-1===R&&"RESTful"===T?y+="/":R>-1&&(y=y.substring(0,R)),"KVP"===T&&(y+=R>-1?"":"?"),g&&(y=y.replace(/^http:/i,"https:"));const S=x("ServiceIdentification>ServiceTypeVersion",o),V=x("ServiceIdentification>AccessConstraints",o),v=/^none$/i.test(V)?null:V,b=m("Layer",a),E=m("TileMatrixSet",a),L=b.map((e=>{const t=x("Identifier",e);return l.set(t,e),w(t,e,E,g,S)}));return{copyright:v,dimensionMap:s,layerMap:l,layers:L,serviceMode:T,tileUrl:y}}function p(e){return e.layers.forEach((e=>{e.tileMatrixSets.forEach((e=>{const t=e.tileInfo;96!==t.dpi&&(t.lods.forEach((n=>{n.scale=96*n.scale/t.dpi,n.resolution=U(t.spatialReference.wkid,n.scale*c/96,e.id)})),t.dpi=96)}))})),e}function d(e){return e.nodeType===Node.ELEMENT_NODE}function f(e,t){for(let n=0;n<t.childNodes.length;n++){const i=t.childNodes[n];if(d(i)&&i.nodeName===e)return i}return null}function m(e,t){const n=[];for(let i=0;i<t.childNodes.length;i++){const r=t.childNodes[i];d(r)&&r.nodeName===e&&n.push(r)}return n}function g(e,t){const n=[];for(let i=0;i<t.childNodes.length;i++){const r=t.childNodes[i];d(r)&&r.nodeName===e&&n.push(r)}return n.map((e=>e.textContent))}function x(e,t){return e.split(">").forEach((e=>{t&&(t=f(e,t))})),t&&t.textContent}function h(e,t,n,i){let r;return Array.prototype.slice.call(i.childNodes).some((i=>{if(i.nodeName.indexOf(e)>-1){const e=f(t,i),o=e&&e.textContent;if(o===n||n.split(":")&&n.split(":")[1]===o)return r=i,!0}return!1})),r}function w(e,t,n,i,r){const o=x("Abstract",t),l=g("Format",t);return{id:e,fullExtent:R(t),fullExtents:S(t),description:o,formats:l,styles:V(t,i),title:x("Title",t),tileMatrixSets:v(r,t,n)}}function C(e,t){var n;const i=[],r=null==(n=e.layerMap)?void 0:n.get(t);if(!r)return;const o=m("ResourceURL",r),l=m("Dimension",r);let s,a,c,u;return l.length&&(s=x("Identifier",l[0]),a=g("Default",l[0])||g("Value",l[0])),l.length>1&&(c=x("Identifier",l[1]),u=g("Default",l[1])||g("Value",l[1])),e.dimensionMap.set(t,{dimensions:a,dimensions2:u}),o.forEach((e=>{let t=e.getAttribute("template");if("tile"===e.getAttribute("resourceType")){if(s&&a.length)if(t.indexOf("{"+s+"}")>-1)t=t.replace("{"+s+"}","{dimensionValue}");else{const e=t.toLowerCase().indexOf("{"+s.toLowerCase()+"}");e>-1&&(t=t.substring(0,e)+"{dimensionValue}"+t.substring(e+s.length+2))}if(c&&u.length)if(t.indexOf("{"+c+"}")>-1)t=t.replace("{"+c+"}","{dimensionValue2}");else{const e=t.toLowerCase().indexOf("{"+c.toLowerCase()+"}");e>-1&&(t=t.substring(0,e)+"{dimensionValue2}"+t.substring(e+c.length+2))}i.push({template:t,format:e.getAttribute("format"),resourceType:"tile"})}})),i}function M(e,t,n,i,r,o,l,s){var a,c;const u=T(e,t,i);if(!((null==u?void 0:u.length)>0))return"";const{dimensionMap:p}=e,d=null==(a=p.get(t).dimensions)?void 0:a[0],f=null==(c=p.get(t).dimensions2)?void 0:c[0];return u[l%u.length].template.replace(/\{Style\}/gi,r).replace(/\{TileMatrixSet\}/gi,n).replace(/\{TileMatrix\}/gi,o).replace(/\{TileRow\}/gi,""+l).replace(/\{TileCol\}/gi,""+s).replace(/\{dimensionValue\}/gi,d).replace(/\{dimensionValue2\}/gi,f)}function T(e,t,n){const i=C(e,t),r=i.filter((e=>e.format===n));return r.length?r:i}function y(e,t,n,i){const{dimensionMap:r}=e,o=C(e,t);let l="";if(o&&o.length>0){const e=r.get(t).dimensions&&r.get(t).dimensions[0],s=r.get(t).dimensions2&&r.get(t).dimensions2[0];l=o[0].template,l.indexOf(".xxx")===l.length-4&&(l=l.slice(0,l.length-4)),l=l.replace(/\{Style\}/gi,i),l=l.replace(/\{TileMatrixSet\}/gi,n),l=l.replace(/\{TileMatrix\}/gi,"{level}"),l=l.replace(/\{TileRow\}/gi,"{row}"),l=l.replace(/\{TileCol\}/gi,"{col}"),l=l.replace(/\{dimensionValue\}/gi,e),l=l.replace(/\{dimensionValue2\}/gi,s)}return l}function R(e){const t=f("WGS84BoundingBox",e),n=t?x("LowerCorner",t).split(" "):["-180","-90"],i=t?x("UpperCorner",t).split(" "):["180","90"];return{xmin:parseFloat(n[0]),ymin:parseFloat(n[1]),xmax:parseFloat(i[0]),ymax:parseFloat(i[1]),spatialReference:{wkid:4326}}}function S(e){const t=[];return s(e,{BoundingBox:e=>{if(!e.getAttribute("crs"))return;const n=e.getAttribute("crs").toLowerCase(),i=E(n),r=n.includes("epsg")&&l(i.wkid);let o,a,c,u;s(e,{LowerCorner:e=>{[o,a]=e.textContent.split(" ").map((e=>Number.parseFloat(e))),r&&([o,a]=[a,o])},UpperCorner:e=>{[c,u]=e.textContent.split(" ").map((e=>Number.parseFloat(e))),r&&([c,u]=[u,c])}}),t.push({xmin:o,ymin:a,xmax:c,ymax:u,spatialReference:i})}}),t}function V(e,t){return m("Style",e).map((e=>{const n=f("LegendURL",e),i=f("Keywords",e),r=i&&g("Keyword",i);let o=n&&n.getAttribute("xlink:href");t&&(o=o&&o.replace(/^http:/i,"https:"));return{abstract:x("Abstract",e),id:x("Identifier",e),isDefault:"true"===e.getAttribute("isDefault"),keywords:r,legendUrl:o,title:x("Title",e)}}))}function v(e,t,n){return m("TileMatrixSetLink",t).map((t=>b(e,t,n)))}function b(e,t,n){const i=f("TileMatrixSet",t).textContent,r=g("TileMatrix",t),o=n.find((e=>{const t=f("Identifier",e),n=t&&t.textContent;return!!(n===i||i.split(":")&&i.split(":")[1]===n)})),l=f("TileMatrixSetLimits",t),s=l&&m("TileMatrixLimits",l),c=new Map;if(null!=s&&s.length)for(const a of s){const e=f("TileMatrix",a).textContent,t=+f("MinTileRow",a).textContent,n=+f("MaxTileRow",a).textContent,i=+f("MinTileCol",a).textContent,r=+f("MaxTileCol",a).textContent;c.set(e,{minCol:i,maxCol:r,minRow:t,maxRow:n})}const u=x("SupportedCRS",o).toLowerCase(),p=L(o,u),d=p.spatialReference,w=f("TileMatrix",o),C=[parseInt(x("TileWidth",w),10),parseInt(x("TileHeight",w),10)],M=[];if(r.length)r.forEach(((e,t)=>{const n=h("TileMatrix","Identifier",e,o);M.push(k(n,u,t,i,c))}));else{m("TileMatrix",o).forEach(((e,t)=>{M.push(k(e,u,t,i,c))}))}const T=N(e,o,p,C,M[0]).toJSON(),y=new a({dpi:96,spatialReference:d,size:C,origin:p,lods:M}).toJSON();return{id:i,fullExtent:T,tileInfo:y}}function E(e){e=e.toLowerCase();let n=parseInt(e.split(":").pop(),10);900913!==n&&3857!==n||(n=102100);const i=O(e);return t(i)&&(n=i),{wkid:n}}function L(e,t){return I(f("TileMatrix",e),t)}function I(e,t){const n=E(t),[r,o]=x("TopLeftCorner",e).split(" ").map((e=>parseFloat(e))),s=t.includes("epsg")&&l(n.wkid);return new i(s?{x:o,y:r,spatialReference:n}:{x:r,y:o,spatialReference:n})}function N(e,t,i,r,o){const l=f("BoundingBox",t);let s,a,c,u,p,d;if(l&&(s=x("LowerCorner",l).split(" "),a=x("UpperCorner",l).split(" ")),s&&s.length>1&&a&&a.length>1)c=parseFloat(s[0]),p=parseFloat(s[1]),u=parseFloat(a[0]),d=parseFloat(a[1]);else{const e=f("TileMatrix",t),n=parseInt(x("MatrixWidth",e),10),l=parseInt(x("MatrixHeight",e),10);c=i.x,d=i.y,u=c+n*r[0]*o.resolution,p=d-l*r[1]*o.resolution}return A(e,i.spatialReference)?new n(p,c,d,u,i.spatialReference):new n(c,p,u,d,i.spatialReference)}function A(e,t){return"1.0.0"===e&&l(t.wkid)}var F;function O(e){return e.includes("crs84")||e.includes("crs:84")?F.CRS84:e.includes("crs83")||e.includes("crs:83")?F.CRS83:e.includes("crs27")||e.includes("crs:27")?F.CRS27:null}function k(e,t,n,i,r){var o;const l=E(t),s=x("Identifier",e);let a=parseFloat(x("ScaleDenominator",e));const u=U(l.wkid,a,i);a*=96/c;const p=+x("MatrixWidth",e),d=+x("MatrixHeight",e),{maxCol:f=p-1,maxRow:m=d-1,minCol:g=0,minRow:h=0}=null!=(o=r.get(s))?o:{},{x:w,y:C}=I(e,t);return{cols:[g,f],level:n,levelValue:s,origin:[w,C],scale:a,resolution:u,rows:[h,m]}}function U(e,t,n){let i;return i=o.hasOwnProperty(""+e)?o.values[o[e]]:"default028mm"===n?6370997*Math.PI/180:r(e).metersPerDegree,7*t/25e3/i}!function(e){e[e.CRS84=4326]="CRS84",e[e.CRS83=4269]="CRS83",e[e.CRS27=4267]="CRS27"}(F||(F={}));export{M as getTileUrlFromResourceUrls,y as getTileUrlTemplateFromResourceUrls,T as getTileUrlTemplates,u as parseCapabilities,p as parseResourceInfo};
5
+ import e from"../../core/Error.js";import{isSome as t}from"../../core/maybe.js";import n from"../../geometry/Extent.js";import i from"../../geometry/Point.js";import{getReferenceEllipsoidFromWKID as r}from"../../geometry/projectionEllipsoid.js";import o from"../../geometry/support/WKIDUnitConversion.js";import{isAxesOrderReversedForWkid as l}from"../ogc/crsUtils.js";import{visitXML as s}from"../ogc/xmlUtils.js";import a from"./TileInfo.js";const c=90.71428571428571;function u(t,n){var i,r;t=t.replace(/ows:/gi,"");const o=(new DOMParser).parseFromString(t,"text/xml").documentElement,l=new Map,s=new Map,a=f("Contents",o);if(!a)throw new e("wmtslayer:wmts-capabilities-xml-is-not-valid");const c=f("OperationsMetadata",o),u=null==c?void 0:c.querySelector("[name='GetTile']"),p=null==u?void 0:u.getElementsByTagName("Get"),d=p&&Array.prototype.slice.call(p),g=null!=(i=(null==n||null==(r=n.url)?void 0:r.indexOf("https"))>-1)&&i;let C,M,T=n.serviceMode,y=n&&n.url;if(d&&d.length&&d.some((e=>{const t=f("Constraint",e);return!t||h("AllowedValues","Value",T,t)?(y=e.attributes[0].nodeValue,!0):(!t||h("AllowedValues","Value","RESTful",t)||h("AllowedValues","Value","REST",t)?M=e.attributes[0].nodeValue:t&&!h("AllowedValues","Value","KVP",t)||(C=e.attributes[0].nodeValue),!1)})),!y)if(M)y=M,T="RESTful";else if(C)y=C,T="KVP";else{const e=f("ServiceMetadataURL",o);y=e&&e.getAttribute("xlink:href")}const R=y.indexOf("1.0.0/");-1===R&&"RESTful"===T?y+="/":R>-1&&(y=y.substring(0,R)),"KVP"===T&&(y+=R>-1?"":"?"),g&&(y=y.replace(/^http:/i,"https:"));const S=x("ServiceIdentification>ServiceTypeVersion",o),V=x("ServiceIdentification>AccessConstraints",o),v=/^none$/i.test(V)?null:V,b=m("Layer",a),E=m("TileMatrixSet",a),L=b.map((e=>{const t=x("Identifier",e);return l.set(t,e),w(t,e,E,g,S)}));return{copyright:v,dimensionMap:s,layerMap:l,layers:L,serviceMode:T,tileUrl:y}}function p(e){return e.layers.forEach((e=>{e.tileMatrixSets.forEach((e=>{const t=e.tileInfo;96!==t.dpi&&(t.lods.forEach((n=>{n.scale=96*n.scale/t.dpi,n.resolution=U(t.spatialReference.wkid,n.scale*c/96,e.id)})),t.dpi=96)}))})),e}function d(e){return e.nodeType===Node.ELEMENT_NODE}function f(e,t){for(let n=0;n<t.childNodes.length;n++){const i=t.childNodes[n];if(d(i)&&i.nodeName===e)return i}return null}function m(e,t){const n=[];for(let i=0;i<t.childNodes.length;i++){const r=t.childNodes[i];d(r)&&r.nodeName===e&&n.push(r)}return n}function g(e,t){const n=[];for(let i=0;i<t.childNodes.length;i++){const r=t.childNodes[i];d(r)&&r.nodeName===e&&n.push(r)}return n.map((e=>e.textContent))}function x(e,t){return e.split(">").forEach((e=>{t&&(t=f(e,t))})),t&&t.textContent}function h(e,t,n,i){let r;return Array.prototype.slice.call(i.childNodes).some((i=>{if(i.nodeName.includes(e)){const e=f(t,i),o=e&&e.textContent;if(o===n||n.split(":")&&n.split(":")[1]===o)return r=i,!0}return!1})),r}function w(e,t,n,i,r){const o=x("Abstract",t),l=g("Format",t);return{id:e,fullExtent:R(t),fullExtents:S(t),description:o,formats:l,styles:V(t,i),title:x("Title",t),tileMatrixSets:v(r,t,n)}}function C(e,t){var n;const i=[],r=null==(n=e.layerMap)?void 0:n.get(t);if(!r)return;const o=m("ResourceURL",r),l=m("Dimension",r);let s,a,c,u;return l.length&&(s=x("Identifier",l[0]),a=g("Default",l[0])||g("Value",l[0])),l.length>1&&(c=x("Identifier",l[1]),u=g("Default",l[1])||g("Value",l[1])),e.dimensionMap.set(t,{dimensions:a,dimensions2:u}),o.forEach((e=>{let t=e.getAttribute("template");if("tile"===e.getAttribute("resourceType")){if(s&&a.length)if(t.includes("{"+s+"}"))t=t.replace("{"+s+"}","{dimensionValue}");else{const e=t.toLowerCase().indexOf("{"+s.toLowerCase()+"}");e>-1&&(t=t.substring(0,e)+"{dimensionValue}"+t.substring(e+s.length+2))}if(c&&u.length)if(t.includes("{"+c+"}"))t=t.replace("{"+c+"}","{dimensionValue2}");else{const e=t.toLowerCase().indexOf("{"+c.toLowerCase()+"}");e>-1&&(t=t.substring(0,e)+"{dimensionValue2}"+t.substring(e+c.length+2))}i.push({template:t,format:e.getAttribute("format"),resourceType:"tile"})}})),i}function M(e,t,n,i,r,o,l,s){var a,c;const u=T(e,t,i);if(!((null==u?void 0:u.length)>0))return"";const{dimensionMap:p}=e,d=null==(a=p.get(t).dimensions)?void 0:a[0],f=null==(c=p.get(t).dimensions2)?void 0:c[0];return u[l%u.length].template.replace(/\{Style\}/gi,r).replace(/\{TileMatrixSet\}/gi,n).replace(/\{TileMatrix\}/gi,o).replace(/\{TileRow\}/gi,""+l).replace(/\{TileCol\}/gi,""+s).replace(/\{dimensionValue\}/gi,d).replace(/\{dimensionValue2\}/gi,f)}function T(e,t,n){const i=C(e,t),r=i.filter((e=>e.format===n));return r.length?r:i}function y(e,t,n,i){const{dimensionMap:r}=e,o=C(e,t);let l="";if(o&&o.length>0){const e=r.get(t).dimensions&&r.get(t).dimensions[0],s=r.get(t).dimensions2&&r.get(t).dimensions2[0];l=o[0].template,l.indexOf(".xxx")===l.length-4&&(l=l.slice(0,l.length-4)),l=l.replace(/\{Style\}/gi,i),l=l.replace(/\{TileMatrixSet\}/gi,n),l=l.replace(/\{TileMatrix\}/gi,"{level}"),l=l.replace(/\{TileRow\}/gi,"{row}"),l=l.replace(/\{TileCol\}/gi,"{col}"),l=l.replace(/\{dimensionValue\}/gi,e),l=l.replace(/\{dimensionValue2\}/gi,s)}return l}function R(e){const t=f("WGS84BoundingBox",e),n=t?x("LowerCorner",t).split(" "):["-180","-90"],i=t?x("UpperCorner",t).split(" "):["180","90"];return{xmin:parseFloat(n[0]),ymin:parseFloat(n[1]),xmax:parseFloat(i[0]),ymax:parseFloat(i[1]),spatialReference:{wkid:4326}}}function S(e){const t=[];return s(e,{BoundingBox:e=>{if(!e.getAttribute("crs"))return;const n=e.getAttribute("crs").toLowerCase(),i=E(n),r=n.includes("epsg")&&l(i.wkid);let o,a,c,u;s(e,{LowerCorner:e=>{[o,a]=e.textContent.split(" ").map((e=>Number.parseFloat(e))),r&&([o,a]=[a,o])},UpperCorner:e=>{[c,u]=e.textContent.split(" ").map((e=>Number.parseFloat(e))),r&&([c,u]=[u,c])}}),t.push({xmin:o,ymin:a,xmax:c,ymax:u,spatialReference:i})}}),t}function V(e,t){return m("Style",e).map((e=>{const n=f("LegendURL",e),i=f("Keywords",e),r=i&&g("Keyword",i);let o=n&&n.getAttribute("xlink:href");t&&(o=o&&o.replace(/^http:/i,"https:"));return{abstract:x("Abstract",e),id:x("Identifier",e),isDefault:"true"===e.getAttribute("isDefault"),keywords:r,legendUrl:o,title:x("Title",e)}}))}function v(e,t,n){return m("TileMatrixSetLink",t).map((t=>b(e,t,n)))}function b(e,t,n){const i=f("TileMatrixSet",t).textContent,r=g("TileMatrix",t),o=n.find((e=>{const t=f("Identifier",e),n=t&&t.textContent;return!!(n===i||i.split(":")&&i.split(":")[1]===n)})),l=f("TileMatrixSetLimits",t),s=l&&m("TileMatrixLimits",l),c=new Map;if(null!=s&&s.length)for(const a of s){const e=f("TileMatrix",a).textContent,t=+f("MinTileRow",a).textContent,n=+f("MaxTileRow",a).textContent,i=+f("MinTileCol",a).textContent,r=+f("MaxTileCol",a).textContent;c.set(e,{minCol:i,maxCol:r,minRow:t,maxRow:n})}const u=x("SupportedCRS",o).toLowerCase(),p=L(o,u),d=p.spatialReference,w=f("TileMatrix",o),C=[parseInt(x("TileWidth",w),10),parseInt(x("TileHeight",w),10)],M=[];if(r.length)r.forEach(((e,t)=>{const n=h("TileMatrix","Identifier",e,o);M.push(O(n,u,t,i,c))}));else{m("TileMatrix",o).forEach(((e,t)=>{M.push(O(e,u,t,i,c))}))}const T=N(e,o,p,C,M[0]).toJSON(),y=new a({dpi:96,spatialReference:d,size:C,origin:p,lods:M}).toJSON();return{id:i,fullExtent:T,tileInfo:y}}function E(e){e=e.toLowerCase();let n=parseInt(e.split(":").pop(),10);900913!==n&&3857!==n||(n=102100);const i=k(e);return t(i)&&(n=i),{wkid:n}}function L(e,t){return I(f("TileMatrix",e),t)}function I(e,t){const n=E(t),[r,o]=x("TopLeftCorner",e).split(" ").map((e=>parseFloat(e))),s=t.includes("epsg")&&l(n.wkid);return new i(s?{x:o,y:r,spatialReference:n}:{x:r,y:o,spatialReference:n})}function N(e,t,i,r,o){const l=f("BoundingBox",t);let s,a,c,u,p,d;if(l&&(s=x("LowerCorner",l).split(" "),a=x("UpperCorner",l).split(" ")),s&&s.length>1&&a&&a.length>1)c=parseFloat(s[0]),p=parseFloat(s[1]),u=parseFloat(a[0]),d=parseFloat(a[1]);else{const e=f("TileMatrix",t),n=parseInt(x("MatrixWidth",e),10),l=parseInt(x("MatrixHeight",e),10);c=i.x,d=i.y,u=c+n*r[0]*o.resolution,p=d-l*r[1]*o.resolution}return A(e,i.spatialReference)?new n(p,c,d,u,i.spatialReference):new n(c,p,u,d,i.spatialReference)}function A(e,t){return"1.0.0"===e&&l(t.wkid)}var F;function k(e){return e.includes("crs84")||e.includes("crs:84")?F.CRS84:e.includes("crs83")||e.includes("crs:83")?F.CRS83:e.includes("crs27")||e.includes("crs:27")?F.CRS27:null}function O(e,t,n,i,r){var o;const l=E(t),s=x("Identifier",e);let a=parseFloat(x("ScaleDenominator",e));const u=U(l.wkid,a,i);a*=96/c;const p=+x("MatrixWidth",e),d=+x("MatrixHeight",e),{maxCol:f=p-1,maxRow:m=d-1,minCol:g=0,minRow:h=0}=null!=(o=r.get(s))?o:{},{x:w,y:C}=I(e,t);return{cols:[g,f],level:n,levelValue:s,origin:[w,C],scale:a,resolution:u,rows:[h,m]}}function U(e,t,n){let i;return i=o.hasOwnProperty(""+e)?o.values[o[e]]:"default028mm"===n?6370997*Math.PI/180:r(e).metersPerDegree,7*t/25e3/i}!function(e){e[e.CRS84=4326]="CRS84",e[e.CRS83=4269]="CRS83",e[e.CRS27=4267]="CRS27"}(F||(F={}));export{M as getTileUrlFromResourceUrls,y as getTileUrlTemplateFromResourceUrls,T as getTileUrlTemplates,u as parseCapabilities,p as parseResourceInfo};