@arcgis/core 5.0.0-next.43 → 5.0.0-next.44

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 (305) hide show
  1. package/applications/Components/imageryUtils.js +1 -1
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/{f97a7cb367634353177d.js → 001a7a4cf6fe74432ed6.js} +1 -1
  4. package/assets/esri/core/workers/chunks/{324d66962aeec17d3e28.js → 1e0e7cef7ef947894bbe.js} +1 -1
  5. package/assets/esri/core/workers/chunks/20ad34f9d45c64392022.js +1 -0
  6. package/assets/esri/core/workers/chunks/23396a6318edf9264c1f.js +1 -0
  7. package/assets/esri/core/workers/chunks/{ad891ac388fa6c1c9b94.js → 2b34a010f76e5f289868.js} +1 -1
  8. package/assets/esri/core/workers/chunks/2ef4c0092c59a98a5532.js +1 -0
  9. package/assets/esri/core/workers/chunks/35272810c2ed04eb403d.js +1 -0
  10. package/assets/esri/core/workers/chunks/{d1f4152b2b8d47cbf586.js → 72fbee59d5d909615408.js} +1 -1
  11. package/assets/esri/core/workers/chunks/75c66e38bdc1c786c599.js +1 -0
  12. package/assets/esri/core/workers/chunks/7d3c2a063598bdd015e2.js +1 -0
  13. package/assets/esri/core/workers/chunks/897ce6fc9cefb1e14a64.js +1 -0
  14. package/assets/esri/core/workers/chunks/992e9bbdf9d3787ddb0e.js +1 -0
  15. package/assets/esri/core/workers/chunks/a2442549c5daf3653eb4.js +1 -0
  16. package/assets/esri/core/workers/chunks/a7cd795042ebb8585906.js +1 -0
  17. package/assets/esri/core/workers/chunks/{385cfd3087f00dbd1146.js → ca1c65eb7f5900c60170.js} +1 -1
  18. package/assets/esri/core/workers/chunks/cddce67919e13e2f365e.js +1 -0
  19. package/assets/esri/core/workers/chunks/e6784251bbb8b71ead93.js +1 -0
  20. package/assets/esri/core/workers/chunks/{96f798ee286b59396131.js → ea3cba01c60d9bc72719.js} +1 -1
  21. package/assets/esri/libs/lyr3d/lyr3DMain.wasm +0 -0
  22. package/assets/esri/libs/lyr3d/lyr3DWorker.wasm +0 -0
  23. package/config.js +1 -1
  24. package/interfaces.d.ts +78 -2
  25. package/kernel.js +1 -1
  26. package/layers/ImageryTileLayer.js +1 -1
  27. package/layers/Lyr3DWasmPerSceneView.js +1 -1
  28. package/layers/WCSLayer.js +1 -1
  29. package/layers/mixins/ArcGISImageService.js +1 -1
  30. package/layers/mixins/ImageryTileMixin.js +1 -1
  31. package/layers/mixins/RasterJobHandlerMixin.js +1 -1
  32. package/layers/ogc/wcsUtils.js +1 -1
  33. package/layers/raster/datasets/BaseRaster.js +5 -0
  34. package/layers/raster/datasets/CovJSONRaster.js +5 -0
  35. package/layers/raster/datasets/FunctionRaster.js +5 -0
  36. package/layers/raster/datasets/ImageAuxRaster.js +5 -0
  37. package/layers/raster/datasets/ImageServerRaster.js +5 -0
  38. package/layers/raster/datasets/InMemoryRaster.js +5 -0
  39. package/layers/raster/datasets/MRFRaster.js +5 -0
  40. package/layers/raster/datasets/RawBlockCache.js +5 -0
  41. package/layers/raster/datasets/TIFFRaster.js +5 -0
  42. package/layers/raster/datasets/WCSRaster.js +5 -0
  43. package/layers/raster/datasets/covJSONParser.js +5 -0
  44. package/layers/raster/datasets/multidimensionalUtils.js +5 -0
  45. package/layers/raster/datasets/pamParser.js +5 -0
  46. package/layers/raster/datasets/pixelReader.js +5 -0
  47. package/layers/raster/datasets/wcsCoverageParser.js +5 -0
  48. package/layers/raster/formats/Lerc.js +5 -0
  49. package/layers/raster/formats/Qb3.js +5 -0
  50. package/layers/raster/formats/RasterCodec.js +5 -0
  51. package/layers/raster/formats/TiffDecoder.js +5 -0
  52. package/layers/raster/functions/ArithmeticFunction.js +5 -0
  53. package/layers/{support/rasterFunctions → raster/functions}/ArithmeticFunctionArguments.js +1 -1
  54. package/layers/{support/rasterFunctions → raster/functions}/AspectFunction.js +1 -1
  55. package/layers/{support/rasterFunctions → raster/functions}/AspectFunctionArguments.js +1 -1
  56. package/layers/raster/functions/BandArithmeticFunction.js +5 -0
  57. package/layers/{support/rasterFunctions → raster/functions}/BandArithmeticFunctionArguments.js +1 -1
  58. package/layers/{support/rasterFunctions → raster/functions}/BaseFunctionArguments.js +1 -1
  59. package/layers/raster/functions/BaseRasterFunction.js +5 -0
  60. package/layers/{support/rasterFunctions → raster/functions}/ClipFunction.js +1 -1
  61. package/layers/{support/rasterFunctions → raster/functions}/ClipFunctionArguments.js +1 -1
  62. package/layers/raster/functions/ColormapFunction.js +5 -0
  63. package/layers/{support/rasterFunctions → raster/functions}/ColormapFunctionArguments.js +1 -1
  64. package/layers/raster/functions/ColormapToRGBFunction.js +5 -0
  65. package/layers/{support/rasterFunctions → raster/functions}/ColormapToRGBFunctionArguments.js +1 -1
  66. package/layers/raster/functions/CompositeBandFunction.js +5 -0
  67. package/layers/raster/functions/CompositeBandFunctionArguments.js +5 -0
  68. package/layers/raster/functions/ComputeChangeFunction.js +5 -0
  69. package/layers/{support/rasterFunctions → raster/functions}/ComputeChangeFunctionArguments.js +1 -1
  70. package/layers/{support/rasterFunctions → raster/functions}/ContrastBrightnessFunction.js +1 -1
  71. package/layers/{support/rasterFunctions → raster/functions}/ContrastBrightnessFunctionArguments.js +1 -1
  72. package/layers/raster/functions/ConvolutionFunction.js +5 -0
  73. package/layers/raster/functions/ConvolutionFunctionArguments.js +5 -0
  74. package/layers/{support/rasterFunctions → raster/functions}/CurvatureFunction.js +1 -1
  75. package/layers/{support/rasterFunctions → raster/functions}/CurvatureFunctionArguments.js +1 -1
  76. package/layers/{support/rasterFunctions → raster/functions}/ExtractBandFunction.js +1 -1
  77. package/layers/{support/rasterFunctions → raster/functions}/ExtractBandFunctionArguments.js +1 -1
  78. package/layers/{support/rasterFunctions → raster/functions}/GrayscaleFunction.js +1 -1
  79. package/layers/{support/rasterFunctions → raster/functions}/GrayscaleFunctionArguments.js +1 -1
  80. package/layers/raster/functions/HillshadeFunction.js +5 -0
  81. package/layers/{support/rasterFunctions → raster/functions}/HillshadeFunctionArguments.js +1 -1
  82. package/layers/raster/functions/LocalFunction.js +5 -0
  83. package/layers/{support/rasterFunctions → raster/functions}/LocalFunctionArguments.js +1 -1
  84. package/layers/{support/rasterFunctions → raster/functions}/MaskFunction.js +1 -1
  85. package/layers/{support/rasterFunctions → raster/functions}/MaskFunctionArguments.js +1 -1
  86. package/layers/{support/rasterFunctions → raster/functions}/NDVIFunction.js +1 -1
  87. package/layers/{support/rasterFunctions → raster/functions}/NDVIFunctionArguments.js +1 -1
  88. package/layers/raster/functions/RemapFunction.js +5 -0
  89. package/layers/{support/rasterFunctions → raster/functions}/RemapFunctionArguments.js +1 -1
  90. package/layers/raster/functions/ShadedReliefFunction.js +5 -0
  91. package/layers/{support/rasterFunctions → raster/functions}/ShadedReliefFunctionArguments.js +1 -1
  92. package/layers/raster/functions/SlopeFunction.js +5 -0
  93. package/layers/{support/rasterFunctions → raster/functions}/SlopeFunctionArguments.js +1 -1
  94. package/layers/raster/functions/StatisticsFunction.js +5 -0
  95. package/layers/{support/rasterFunctions → raster/functions}/StatisticsFunctionArguments.js +1 -1
  96. package/layers/{support/rasterFunctions → raster/functions}/StatisticsHistogramFunction.js +1 -1
  97. package/layers/{support/rasterFunctions → raster/functions}/StatisticsHistogramFunctionArguments.js +1 -1
  98. package/layers/raster/functions/StretchFunction.js +5 -0
  99. package/layers/{support/rasterFunctions → raster/functions}/StretchFunctionArguments.js +1 -1
  100. package/layers/{support/rasterFunctions → raster/functions}/TableFunction.js +1 -1
  101. package/layers/{support/rasterFunctions → raster/functions}/TableFunctionArguments.js +1 -1
  102. package/layers/raster/functions/bandIndexUtils.js +5 -0
  103. package/layers/raster/functions/changeDetectionUtils.js +5 -0
  104. package/layers/raster/functions/clipUtils.js +5 -0
  105. package/layers/raster/functions/conversionUtils.js +5 -0
  106. package/layers/raster/functions/convolutionUtils.js +5 -0
  107. package/layers/raster/functions/creators/createDataManagementFunctions.js +5 -0
  108. package/layers/raster/functions/creators/utils.js +5 -0
  109. package/layers/raster/functions/focalStatUtils.js +5 -0
  110. package/layers/raster/functions/localUtils.js +5 -0
  111. package/layers/raster/functions/pixelTransformUtils.js +5 -0
  112. package/layers/raster/functions/pixelUtils.js +5 -0
  113. package/layers/raster/functions/stretchUtils.js +5 -0
  114. package/layers/raster/functions/surfaceUtils.js +5 -0
  115. package/layers/raster/functions/vectorFieldUtils.js +5 -0
  116. package/layers/raster/transforms/BaseRasterTransform.js +5 -0
  117. package/layers/{support/rasterTransforms → raster/transforms}/GCSShiftTransform.js +1 -1
  118. package/layers/{support/rasterTransforms → raster/transforms}/IdentityTransform.js +1 -1
  119. package/layers/{support/rasterTransforms → raster/transforms}/PolynomialTransform.js +1 -1
  120. package/layers/save/imageryUtils.js +1 -1
  121. package/layers/support/PixelBlock.js +1 -1
  122. package/layers/support/RasterWorker.js +1 -1
  123. package/layers/support/imageryRendererUtils.js +1 -1
  124. package/layers/support/rasterFunctionUtils.js +1 -1
  125. package/package.json +1 -1
  126. package/renderers/VectorFieldRenderer.js +1 -1
  127. package/renderers/support/RasterSymbolizer.js +1 -1
  128. package/renderers/support/rasterRendererHelper.js +1 -1
  129. package/rest/locator/addressToLocations.js +1 -1
  130. package/rest/locator/addressesToLocations.js +1 -1
  131. package/rest/locator/suggestLocations.js +1 -1
  132. package/rest/networks/support/Association.js +1 -1
  133. package/smartMapping/raster/support/adapters/ImageryLayerAdapter.js +1 -1
  134. package/smartMapping/raster/support/adapters/ImageryTileLayerAdapter.js +1 -1
  135. package/support/revision.js +1 -1
  136. package/views/2d/engine/imagery/RasterVFDisplayObject.js +1 -1
  137. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/RasterRangeHighlightShader.js +1 -1
  138. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/processor/MaskShader.js +1 -1
  139. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/processor/RemapShader.js +1 -1
  140. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/processor/math.js +1 -1
  141. package/views/2d/layers/ImageryLayerView2D.js +1 -1
  142. package/views/2d/layers/ImageryTileLayerView2D.js +1 -1
  143. package/views/2d/layers/imagery/BaseImageryTileSubView2D.js +1 -1
  144. package/views/2d/layers/imagery/ImageryTileView2D.js +1 -1
  145. package/views/2d/layers/imagery/ImageryView2D.js +1 -1
  146. package/views/2d/layers/imagery/VectorFieldTileView2D.js +1 -1
  147. package/views/2d/layers/imagery/VectorFieldView2D.js +1 -1
  148. package/views/3d/layers/ImageryTileLayerView3D.js +1 -1
  149. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  150. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  151. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
  152. package/views/3d/webgl-engine/core/shaderLibrary/ShaderOutput.js +1 -1
  153. package/views/3d/webgl-engine/lib/TextureBackedBuffer/TextureBackedBufferLayout.js +1 -1
  154. package/views/3d/webgl-engine/lib/TextureBackedBuffer/TextureBufferView.js +1 -1
  155. package/views/3d/webgl-engine/materials/ColorMaterial.js +1 -1
  156. package/views/3d/webgl-engine/materials/DrawParameters.js +1 -1
  157. package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
  158. package/views/3d/webgl-engine/materials/ImageMaterial.js +1 -1
  159. package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
  160. package/views/3d/webgl-engine/materials/NativeLineMaterial.js +1 -1
  161. package/views/3d/webgl-engine/materials/PatternMaterial.js +1 -1
  162. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  163. package/views/3d/webgl-engine/materials/ShadedColorMaterial.js +1 -1
  164. package/views/3d/webgl-engine/materials/WaterMaterial.js +1 -1
  165. package/views/3d/webgl-engine/materials/renderers/Instance.js +1 -1
  166. package/views/3d/webgl-engine/materials/renderers/MergedBuffer.js +1 -1
  167. package/views/3d/webgl-engine/materials/renderers/PerBufferData.js +1 -1
  168. package/views/3d/webgl-engine/materials/renderers/PerOriginData.js +1 -1
  169. package/views/3d/webgl-engine/materials/renderers/VaoRenderer.js +1 -1
  170. package/views/3d/webgl-engine/materials/renderers/VaoWriter.js +1 -1
  171. package/views/DOMContainer.js +1 -1
  172. package/views/GroundView.js +1 -1
  173. package/views/layers/ImageryLayerViewMixin.js +1 -1
  174. package/views/layers/ImageryTileLayerViewMixin.js +1 -1
  175. package/views/support/imageReprojection.js +1 -1
  176. package/widgets/BatchAttributeForm.js +1 -1
  177. package/widgets/BuildingExplorer/BuildingExplorerViewModel.js +1 -1
  178. package/widgets/CoordinateConversion/CoordinateConversionViewModel.js +1 -1
  179. package/widgets/CoordinateConversion.js +1 -1
  180. package/widgets/DirectLineMeasurement3D.js +1 -1
  181. package/widgets/DistanceMeasurement2D.js +1 -1
  182. package/widgets/Editor/EditorViewModel.js +1 -1
  183. package/widgets/Editor.js +1 -1
  184. package/widgets/ElevationProfile.js +1 -1
  185. package/widgets/Feature.js +1 -1
  186. package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
  187. package/widgets/FeatureForm.js +1 -1
  188. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  189. package/widgets/FeatureTable/Grid/GridViewModel.js +1 -1
  190. package/widgets/FeatureTable/support/GroupColumnTemplate.js +1 -1
  191. package/widgets/FeatureTable/support/TableTemplate.js +1 -1
  192. package/widgets/FeatureTable.js +1 -1
  193. package/widgets/FeatureTemplates.js +1 -1
  194. package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
  195. package/widgets/Legend.js +1 -1
  196. package/widgets/LineOfSight.js +1 -1
  197. package/widgets/Locate.js +1 -1
  198. package/widgets/OrientedImageryViewer/galleryUtils.js +1 -1
  199. package/widgets/OrientedImageryViewer/services/DepthImageService.js +1 -1
  200. package/widgets/PanoramicViewer/support/importUtils.js +1 -1
  201. package/widgets/Print.js +1 -1
  202. package/widgets/ScaleBar.js +1 -1
  203. package/widgets/ScaleRangeSlider.js +1 -1
  204. package/widgets/Search/SearchResultRenderer.js +1 -1
  205. package/widgets/Search/SearchViewModel.js +1 -1
  206. package/widgets/Search/types.js +1 -1
  207. package/widgets/Search.js +1 -1
  208. package/widgets/ShadowCast.js +1 -1
  209. package/widgets/Sketch/SketchViewModel.js +1 -1
  210. package/widgets/Sketch.js +1 -1
  211. package/assets/esri/core/workers/chunks/1f6ead46b723630db897.js +0 -1
  212. package/assets/esri/core/workers/chunks/3a16347e17312556e02c.js +0 -1
  213. package/assets/esri/core/workers/chunks/478def691ae6763686f3.js +0 -1
  214. package/assets/esri/core/workers/chunks/4c4a55be41ba105c091c.js +0 -1
  215. package/assets/esri/core/workers/chunks/4cbf5a97b2b3c6553f6f.js +0 -1
  216. package/assets/esri/core/workers/chunks/646f58b69d2354f1ef27.js +0 -1
  217. package/assets/esri/core/workers/chunks/93d11075f65a5b6625ea.js +0 -1
  218. package/assets/esri/core/workers/chunks/9f2a8445a5848502c7e7.js +0 -1
  219. package/assets/esri/core/workers/chunks/a1b08aab73747f4e7e25.js +0 -1
  220. package/assets/esri/core/workers/chunks/ba59568e748f0ba53b78.js +0 -1
  221. package/assets/esri/core/workers/chunks/f21cb5b34d4d1e3af1a9.js +0 -1
  222. package/assets/esri/core/workers/chunks/f93f0586ce10cb5d98b3.js +0 -1
  223. package/layers/support/rasterDatasets/BaseRaster.js +0 -5
  224. package/layers/support/rasterDatasets/CovJSONRaster.js +0 -5
  225. package/layers/support/rasterDatasets/FunctionRaster.js +0 -5
  226. package/layers/support/rasterDatasets/ImageAuxRaster.js +0 -5
  227. package/layers/support/rasterDatasets/ImageServerRaster.js +0 -5
  228. package/layers/support/rasterDatasets/InMemoryRaster.js +0 -5
  229. package/layers/support/rasterDatasets/MRFRaster.js +0 -5
  230. package/layers/support/rasterDatasets/RawBlockCache.js +0 -5
  231. package/layers/support/rasterDatasets/TIFFRaster.js +0 -5
  232. package/layers/support/rasterDatasets/WCSRaster.js +0 -5
  233. package/layers/support/rasterDatasets/covJSONParser.js +0 -5
  234. package/layers/support/rasterDatasets/multidimensionalUtils.js +0 -5
  235. package/layers/support/rasterDatasets/pamParser.js +0 -5
  236. package/layers/support/rasterDatasets/pixelReader.js +0 -5
  237. package/layers/support/rasterDatasets/wcsCoverageParser.js +0 -5
  238. package/layers/support/rasterFormats/Lerc.js +0 -5
  239. package/layers/support/rasterFormats/Qb3.js +0 -5
  240. package/layers/support/rasterFormats/RasterCodec.js +0 -5
  241. package/layers/support/rasterFormats/TiffDecoder.js +0 -5
  242. package/layers/support/rasterFunctions/ArithmeticFunction.js +0 -5
  243. package/layers/support/rasterFunctions/BandArithmeticFunction.js +0 -5
  244. package/layers/support/rasterFunctions/BaseRasterFunction.js +0 -5
  245. package/layers/support/rasterFunctions/ColormapFunction.js +0 -5
  246. package/layers/support/rasterFunctions/ColormapToRGBFunction.js +0 -5
  247. package/layers/support/rasterFunctions/CompositeBandFunction.js +0 -5
  248. package/layers/support/rasterFunctions/CompositeBandFunctionArguments.js +0 -5
  249. package/layers/support/rasterFunctions/ComputeChangeFunction.js +0 -5
  250. package/layers/support/rasterFunctions/ConvolutionFunction.js +0 -5
  251. package/layers/support/rasterFunctions/ConvolutionFunctionArguments.js +0 -5
  252. package/layers/support/rasterFunctions/HillshadeFunction.js +0 -5
  253. package/layers/support/rasterFunctions/LocalFunction.js +0 -5
  254. package/layers/support/rasterFunctions/RemapFunction.js +0 -5
  255. package/layers/support/rasterFunctions/ShadedReliefFunction.js +0 -5
  256. package/layers/support/rasterFunctions/SlopeFunction.js +0 -5
  257. package/layers/support/rasterFunctions/StatisticsFunction.js +0 -5
  258. package/layers/support/rasterFunctions/StretchFunction.js +0 -5
  259. package/layers/support/rasterFunctions/bandIndexUtils.js +0 -5
  260. package/layers/support/rasterFunctions/changeDetectionUtils.js +0 -5
  261. package/layers/support/rasterFunctions/clipUtils.js +0 -5
  262. package/layers/support/rasterFunctions/conversionUtils.js +0 -5
  263. package/layers/support/rasterFunctions/convolutionUtils.js +0 -5
  264. package/layers/support/rasterFunctions/creators/createDataManagementFunctions.js +0 -5
  265. package/layers/support/rasterFunctions/creators/utils.js +0 -5
  266. package/layers/support/rasterFunctions/focalStatUtils.js +0 -5
  267. package/layers/support/rasterFunctions/localUtils.js +0 -5
  268. package/layers/support/rasterFunctions/pixelTransformUtils.js +0 -5
  269. package/layers/support/rasterFunctions/pixelUtils.js +0 -5
  270. package/layers/support/rasterFunctions/stretchUtils.js +0 -5
  271. package/layers/support/rasterFunctions/surfaceUtils.js +0 -5
  272. package/layers/support/rasterFunctions/vectorFieldUtils.js +0 -5
  273. package/layers/support/rasterTransforms/BaseRasterTransform.js +0 -5
  274. /package/assets/esri/layers/{support/rasterFormats → raster/formats}/lerc-wasm.wasm +0 -0
  275. /package/assets/esri/layers/{support/rasterFormats → raster/formats}/qb3-wasm.wasm +0 -0
  276. /package/layers/{support/rasterDatasets → raster/datasets}/DBFParser.js +0 -0
  277. /package/layers/{support/rasterDatasets → raster/datasets}/EphemeralBlockCache.js +0 -0
  278. /package/layers/{support/rasterDatasets → raster/datasets}/RasterFactory.js +0 -0
  279. /package/layers/{support/rasterDatasets → raster/datasets}/byteStreamUtils.js +0 -0
  280. /package/layers/{support/rasterDatasets → raster/datasets}/datasetUtils.js +0 -0
  281. /package/layers/{support/rasterDatasets → raster/datasets}/multipartParser.js +0 -0
  282. /package/layers/{support/rasterDatasets → raster/datasets}/wcsCapabilitiesParser.js +0 -0
  283. /package/layers/{support/rasterDatasets → raster/datasets}/xmlUtilities.js +0 -0
  284. /package/layers/{support/rasterFormats → raster/formats}/ImageCanvasDecoder.js +0 -0
  285. /package/layers/{support/rasterFormats → raster/formats}/JpgPlus.js +0 -0
  286. /package/layers/{support/rasterFormats → raster/formats}/Lzw.js +0 -0
  287. /package/layers/{support/rasterFormats → raster/formats}/Raw.js +0 -0
  288. /package/layers/{support/rasterFormats → raster/formats}/pixelRangeUtils.js +0 -0
  289. /package/layers/{support/rasterFormats → raster/formats}/tiffTag.js +0 -0
  290. /package/layers/{support/rasterFormats → raster/formats}/utils.js +0 -0
  291. /package/layers/{support/rasterFunctions → raster/functions}/colormaps.js +0 -0
  292. /package/layers/{support/rasterFunctions → raster/functions}/creators/createAppearenceFunctions.js +0 -0
  293. /package/layers/{support/rasterFunctions → raster/functions}/creators/createBandIndexFunctions.js +0 -0
  294. /package/layers/{support/rasterFunctions → raster/functions}/creators/createChangeFunctions.js +0 -0
  295. /package/layers/{support/rasterFunctions → raster/functions}/creators/createConversionFunctions.js +0 -0
  296. /package/layers/{support/rasterFunctions → raster/functions}/creators/createLocalFunctions.js +0 -0
  297. /package/layers/{support/rasterFunctions → raster/functions}/creators/createMultiRasterAnalysisFunctions.js +0 -0
  298. /package/layers/{support/rasterFunctions → raster/functions}/creators/createStatisticsFunctions.js +0 -0
  299. /package/layers/{support/rasterFunctions → raster/functions}/creators/createSurfaceFunctions.js +0 -0
  300. /package/layers/{support/rasterFunctions → raster/functions}/customBandIndexUtils.js +0 -0
  301. /package/layers/{support/rasterFunctions → raster/functions}/mirror.js +0 -0
  302. /package/layers/{support/rasterFunctions → raster/functions}/rasterFunctionHelper.js +0 -0
  303. /package/layers/{support/rasterFunctions → raster/functions}/rasterFunctionSchema.js +0 -0
  304. /package/layers/{support/rasterFunctions → raster/functions}/rasterProjectionHelper.js +0 -0
  305. /package/layers/{support/rasterTransforms → raster/transforms}/utils.js +0 -0
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../../Color.js";import{addTokenParameter as i}from"../../../kernel.js";import s from"../../../request.js";import l from"../../../core/Accessor.js";import{isSome as r}from"../../../core/arrayUtils.js";import n from"../../../core/Collection.js";import has from"../../../core/has.js";import{JSONMap as a}from"../../../core/jsonMap.js";import o from"../../../core/Logger.js";import{clamp as u}from"../../../core/mathUtils.js";import{debounce as c}from"../../../core/promiseUtils.js";import{on as d,watch as y,initial as h,whenOnce as f}from"../../../core/reactiveUtils.js";import{px2pt as m}from"../../../core/screenUtils.js";import{parseWhereClause as p}from"../../../core/sql.js";import{addQueryParameters as g}from"../../../core/urlUtils.js";import{property as b,subclass as _}from"../../../core/accessorSupport/decorators.js";import{EffectView as S}from"../../../layers/effects/EffectView.js";import{getEffectiveDisplayFilter as w}from"../../../layers/support/displayFilterUtils.js";import{ExportImageParameters as v}from"../../../layers/support/ExportImageParameters.js";import{collectFields as L,collectArcadeFieldNames as E}from"../../../layers/support/fieldUtils.js";import{isFeatureLayer as F,supportsFieldConfiguration as C}from"../../../layers/support/layerUtils.js";import{getPixelValueRange as I}from"../../../layers/support/rasterFormats/pixelRangeUtils.js";import{fromJSON as R}from"../../../renderers/support/jsonUtils.js";import{isSupportedRenderer3D as V}from"../../../renderers/support/rendererConversion.js";import D from"../../../renderers/visualVariables/SizeVariable.js";import x from"../../../renderers/visualVariables/support/SizeVariableLegendOptions.js";import{updateReferenceSizeSymbol as z}from"../../../smartMapping/renderers/support/referenceSizeUtils.js";import T from"../../../symbols/SimpleFillSymbol.js";import j from"../../../symbols/SimpleMarkerSymbol.js";import{applyCIMSymbolColor as O}from"../../../symbols/support/cimSymbolUtils.js";import{renderSymbol as k}from"../../../symbols/support/renderUtils.js";import{renderColorRampPreviewHTML as M,renderDotDensityPreviewHTML as P,renderPieChartPreviewHTML as U,renderPreviewHTML as A}from"../../../symbols/support/symbolUtils.js";import{getCSSFilterFromEffectList as B,isVolumetricSymbol as N}from"../../../symbols/support/utils.js";import{getEffectiveClusterSizeVariable as $}from"./clusterUtils.js";import{getColorFromPointCloudStops as H,getRampStopsForPointCloud as q,getStretchRampStops as W,getRampStops as G}from"./colorRampUtils.js";import{getHeatmapRampStops as J}from"./heatmapRampUtils.js";import{getRotationAngleForFocus as Z,getRelationshipRampElement as Q}from"./relationshipRampUtils.js";import{getRampStops as K,realWorldMaxSize as X,realWorldMinSize as Y}from"./sizeRampUtils.js";import{specialCharsLessThan as ee,specialCharsGreaterThan as te,getAuthoringInfoVisualVariableByTheme as ie,getSymbolForFlowRenderer as se,formatValue as le,getFormatOptions as re,mergeWhereClauses as ne,getMedianColor as ae,rgbImgSource as oe,getFormatOptionsForVisualVariable as ue}from"./utils.js";import{formatNumberLabel as ce}from"../../smartMapping/support/utils.js";const de=16,ye="https://utility.arcgis.com/sharing/tools/legend",he="esri.layers.ImageryLayer",fe="esri.layers.ImageryTileLayer",me="esri.layers.WCSLayer",pe=/^\s*(return\s+)?\$view\.scale\s*(;)?\s*$/i,ge=new a({esriGeometryPoint:"point",esriGeometryMultipoint:"multipoint",esriGeometryPolyline:"polyline",esriGeometryPolygon:"polygon",esriGeometryMultiPatch:"multipatch"}),be=new j({size:6,outline:{color:[128,128,128,.5],width:.5}}),_e=new T({style:"solid"});function Se(e){return"flow"===e.type}function we(e){return"vector-field"===e.type}function ve(e){return"raster-colormap"===e.type}function Le(e){return"raster-stretch"===e.type}function Ee(e){return"raster-shaded-relief"===e.type}function Fe(e){return"esri.renderers.SimpleRenderer"===e.declaredClass}function Ce(e){return"esri.renderers.ClassBreaksRenderer"===e.declaredClass}function Ie(e){return"esri.renderers.UniqueValueRenderer"===e.declaredClass}function Re(e){return"esri.renderers.HeatmapRenderer"===e.declaredClass}function Ve(e){return xe(e)||ze(e)||Te(e)||De(e)}function De(e){return"esri.renderers.PointCloudRGBRenderer"===e.declaredClass}function xe(e){return"esri.renderers.PointCloudClassBreaksRenderer"===e.declaredClass}function ze(e){return"esri.renderers.PointCloudStretchRenderer"===e.declaredClass}function Te(e){return"esri.renderers.PointCloudUniqueValueRenderer"===e.declaredClass}function je(e){return"esri.renderers.DotDensityRenderer"===e.declaredClass}function Oe(e){return"esri.renderers.PieChartRenderer"===e.declaredClass}function ke(e,t){return Fe(e)||Ce(e)||Ie(e)||Re(e)||je(e)||Oe(e)?"2d"===t.type||V(e):Le(e)||ve(e)||Ee(e)||xe(e)||ze(e)||Te(e)||we(e)||Se(e)}function Me(e){return"esri.layers.BuildingSceneLayer"===e.declaredClass}function Pe(e){return"esri.layers.SubtypeGroupLayer"===e.declaredClass}function Ue(e){return"esri.layers.VoxelLayer"===e.declaredClass}function Ae(e){return"esri.layers.WMSLayer"===e.declaredClass}function Be(e){return"esri.layers.WMTSLayer"===e.declaredClass}function Ne(e){return"esri.layers.MapImageLayer"===e.declaredClass}function $e(e){return"esri.layers.TileLayer"===e.declaredClass}function He(e){return e.declaredClass===he}function qe(e){return e.declaredClass===fe}function We(e){return e.declaredClass===me}function Ge(e){return"stretch-ramp"===e.type}function Je(e){const t="authoringInfo"in e?e?.authoringInfo:null;return"univariate-color-size"===t?.type}function Ze(e){const t="authoringInfo"in e?e?.authoringInfo:null;return"univariate-color-size"===t?.type&&"above-and-below"===t?.univariateTheme}function Qe(e){return"sublayers"in e}function Ke(e){return e&&"symbol"in e}function Xe(e,t){const{field:i,field2:s,field3:l,fieldDelimiter:r,valueExpression:n}=e;if(!i)return null;const a=!(!i&&!n||!s&&!l)?t?.toString().split(r||""):[t],o=i?{[i]:a?.[0]}:null;return o&&(s&&(o[s]=a?.[1]),l&&(o[l]=a?.[2])),o}const Ye=new j({style:"path",path:"M10,5 L5,0 0,5 M5,0 L5,15",size:15,outline:{width:1,color:[85,85,85,1]}});let et={};const tt=new WeakMap;let it=class extends l{constructor(e){super(e),this._hasColorRamp=!1,this._hasOpacityRamp=!1,this._hasSizeRamp=!1,this._loading=!1,this._webStyleSymbolCache=new Map,this._dotDensityUrlCache=new Map,this._scaleDrivenSizeVariable=null,this._clusterSizeVariable=null,this._layerDefinitionExpression=null,this._layerDefinitionExpressionClause=null,this._layerDisplayFilter=null,this._layerDisplayFilterClause=null,this.children=new n,this.layerView=null,this.layer=null,this.legendElements=[],this.parent=null,this.hideLayersNotInCurrentView=!1,this.keepCacheOnDestroy=!1,this.respectLayerDefinitionExpression=!1,this.respectLayerVisibility=!0,this.sublayerIds=[],this.title=null,this.view=null}initialize(){const e=()=>this.notifyChange("ready");this.addHandles([d(()=>this.children,"change",t=>{const{added:i,removed:s}=t;i.forEach(t=>{const i=`activeLayerInfo-ready-watcher-${t.layer.uid}`;this.addHandles(y(()=>t.ready,e,h),i)}),s.forEach(e=>this.removeHandles(e.layer.uid)),e()})]),this.keepCacheOnDestroy||(et={})}destroy(){this._webStyleSymbolCache=null,this._dotDensityUrlCache=null,this._scaleDrivenSizeVariable=null,this.keepCacheOnDestroy||(et=null),this._layerDefinitionExpressionClause=null}get cssEffectFilter(){const{layer:e,scale:t}=this,i="effect"in e?e.effect:null;if(!i)return null;const s=new S({effect:i});return s.endTransition(),s.scale=t,B(s,!0)}get loading(){return this.children.length>0?this.children.some(e=>e.loading):this._loading}get opacity(){const e=this.layer.opacity,t=this.parent?.opacity,i=this.layer.parent,s=i&&"uid"in i?this._getParentLayerOpacity(i):null;return null!=t?t*e:null!=s?s*e:e}get ready(){return null===this.layer||(this.children.length>0?this._isGroupActive():this.legendElements.length>0)}get scale(){return this.view?.scale??0}get isScaleDriven(){const e=this.layer;if(null===e)return!1;if("effect"in e&&e.effect&&Array.isArray(e.effect))return!0;if("featureReduction"in e&&e.featureReduction){if("cluster"===e.featureReduction.type)return!0;if("binning"===e.featureReduction.type&&"renderer"in e.featureReduction&&e.featureReduction.renderer)return this._isRendererScaleDriven(e.featureReduction.renderer)}return"renderer"in e&&e.renderer?!!("displayFilterInfo"in e&&e.displayFilterInfo&&Ie(e.renderer))||this._isRendererScaleDriven(e.renderer):this._isLayerScaleDriven(this.layer)}get version(){return this._get("version")+1}async buildLegendElementsForFeatureCollections(e){this._loading=!0;if(!(!this.hideLayersNotInCurrentView||await this._isLayerInCurrentView()))return this.legendElements=[],this._loading=!1,void this.notifyChange("ready");const t=Array.from(e,e=>{if(F(e))return this._getRendererLegendElements(e.renderer,{title:e.title});if(e.featureSet?.features.length){const t=e.layerDefinition,i=t?.drawingInfo,s=i&&R(i.renderer),l=ge.read(t.geometryType);return s?this._getRendererLegendElements(s,{title:e.name,geometryType:l}):(o.getLogger(this).warn("drawingInfo not available!"),null)}return null});try{const e=[],i=await Promise.allSettled(t);for(const t of i)if("fulfilled"===t.status)for(const i of t.value??[])e.push(i);this.legendElements=e}catch(i){o.getLogger(this).warn("error while building legend for layer!",i)}finally{this._loading=!1,this.notifyChange("ready")}}async buildLegendElementsForRenderer(e){try{this._loading=!0;const t=!this.hideLayersNotInCurrentView||await this._isLayerInCurrentView();this.legendElements=t?await this._getRendererLegendElements(e):[]}catch(t){o.getLogger(this).warn("error while building legend for layer!",t)}finally{this._loading=!1,this.notifyChange("ready")}}async buildLegendElementsForFeatureReduction(e){try{this._loading=!0,await this._waitForLayerViewUpdate(this.layerView);const t=!this.hideLayersNotInCurrentView||await this._isLayerInCurrentView();this.legendElements=t?await this._getLegendElementsForFeatureReduction(e):[]}catch(t){o.getLogger(this).warn("error while building legend for layer!",t)}finally{this._loading=!1,this.notifyChange("ready")}}async buildLegendElementsForTools(){this._loading=!0;const e=this.layer;if(Ue(e))await this._constructLegendElementsForVoxelLayer();else if(Be(e))this._constructLegendElementsForWMTSlayer();else if(Ae(e))await this._constructLegendElementsForWMSSublayers();else if(Me(e))await this._constructLegendElementsForBuildingSceneLayer();else if(Ne(e)||$e(e)||Pe(e))await this._constructLegendElementsForSublayers();else{this.removeHandles("imageryLayers-watcher");let t="default";if(He(e)){const i=e;t=(i?.rasterFunction?.functionName||"default")+"_"+(e.bandIds?.length?e.bandIds.join(""):"###")}if(qe(e)||"link-chart"===e.type)return;await this._getLegendLayers(`${e.uid}-${t}`).then(async t=>{this.legendElements=[];const i=t.map(async t=>{if(He(e)){const t=y(()=>[e.rasterFunction,e.bandIds],()=>c(async()=>{et.default=null,e.renderer?await this.buildLegendElementsForRenderer(e.renderer):await this.buildLegendElementsForTools()})());this.addHandles(t,"imageryLayers-watcher")}const i=this._generateSymbolTableElementForLegendLayer(t);i?.infos.length&&(He(e)&&(i.title=e.title),this.legendElements.push(i))});await Promise.allSettled(i)}).catch(e=>{o.getLogger(this).warn("Request to server for legend has failed!",e)})}this._loading=!1,this.notifyChange("ready")}async _isLayerInCurrentView(e){return this._checkFeatureCountForExpression(e,this.view.extent)}_getParentLayerOpacity(e){let t=1;const i=e.parent;return i&&"uid"in i&&(t=this._getParentLayerOpacity(i)),e.opacity*t}_isGroupActive(){return this.children.some(e=>e.ready)}_isRendererScaleDriven(e){if("dot-density"===e.type)return!0;const t="valueExpression"in e?e.valueExpression:null;if(pe.test(t))return!0;const i="visualVariables"in e?e.visualVariables:null;return!!i?.some(e=>this._isScaleDrivenSizeVariable(e))||this._hasScaleDrivenSymbols(e)}_hasScaleDrivenSymbols(e){switch(e.type){case"simple":return this._isScaleDrivenSymbol(e.symbol);case"class-breaks":return this._isScaleDrivenSymbol(e.defaultSymbol)||e.classBreakInfos.some(e=>this._isScaleDrivenSymbol(e.symbol));case"unique-value":return this._isScaleDrivenSymbol(e.defaultSymbol)||!!e.uniqueValueInfos?.some(e=>this._isScaleDrivenSymbol(e.symbol))}return!1}_isScaleDrivenSymbol(e){if("cim"===e?.type){const{primitiveOverrides:t,minScale:i,maxScale:s}=e.data,l=t?.some(e=>(e.valueExpressionInfo?.expression||"").includes("$view.scale"))??!1;return null!=i||null!=s||l}return!1}_isScaleDrivenSizeVariable(e){if(e&&"size"!==e.type)return!1;const t=e,i=t.minSize,s=t.maxSize;return!("object"!=typeof i||!i||!this._isScaleDrivenSizeVariable(i))||(!("object"!=typeof s||!s||!this._isScaleDrivenSizeVariable(s))||pe.test(t.valueExpression))}_isLayerScaleDriven(e){if("minScale"in e&&e.minScale>0||"maxScale"in e&&e.maxScale>0)return!0;if("sublayers"in e&&e.sublayers)return e.sublayers.some(e=>this._isLayerScaleDriven(e));const t=e.parent;if(!1===e.loaded&&t&&Ne(t)&&"source"in e&&e.source&&"map-layer"===e.source.type)for(const i of t.sourceJSON.layers??[])if(i.id===e.source.mapLayerId&&(i.minScale>0||i.maxScale>0))return!0;return!1}async _constructLegendElementsForVoxelLayer(){this._loading=!0,this.legendElements=[],this.removeHandles("voxel-style-watcher"),this.removeHandles("voxel-current-variable");const e=this.layer;this.addHandles(y(()=>e.currentVariableId,()=>this._constructLegendElementsForVoxelLayer()),"voxel-current-variable"),this.addHandles(y(()=>e.getVariableStyles(),()=>this._constructLegendElementsForVoxelLayer()),"voxel-style-watcher");const t=e.getVariableStyle(null),i=[];if(t)if(t.uniqueValues?.length){const e=[];t.uniqueValues.forEach(t=>{t.enabled&&e.push({label:t.label||`${t.value}`,value:t.value,symbol:new T({color:t.color,outline:null})})}),e.length&&i.push({type:"symbol-table",title:t.label,infos:e})}else if(t.transferFunction){const{colorStops:e,stretchRange:s}=t.transferFunction,l=e.toArray().reverse(),r=s.map((e,t)=>`${0===t?ee:te} ${ce(e)}`).reverse(),n=l.map(e=>({color:e.color,value:null,label:null}));n[0].label=r[0],n[n.length-1].label=r[1],i.push({type:"color-ramp",title:t.label,infos:n,preview:M(l.map(e=>e.color))})}await this._generatePreviewsForLegendElements(i,{opacity:e.opacity}),this.legendElements=i,this._loading=!1,this.notifyChange("ready")}_constructLegendElementsForWMTSlayer(){this._loading=!0,this.legendElements=[],this.removeHandles("wmts-activeLayer-watcher");const e=this.layer.activeLayer;this.addHandles(y(()=>{const{layer:e}=this;return e&&"activeLayer"in e&&e.activeLayer},()=>this._constructLegendElementsForWMTSlayer()),"wmts-activeLayer-watcher");const t=e.styleId?e.styles?.find(({id:t})=>t===e.styleId)?.legendUrl:void 0;t&&(this.legendElements=[{type:"symbol-table",title:e.title,infos:[{src:t,opacity:this.opacity}]}]),this._loading=!1,this.notifyChange("ready")}async _constructLegendElementsForWMSSublayers(){this._loading=!0,this.legendElements=[],this.removeHandles("wms-sublayers-watcher");const e=this.layer;let t=null;(e.customParameters||e.customLayerParameters)&&(t={...e.customParameters,...e.customLayerParameters}),this.addHandles(y(()=>{const{layer:e}=this;return e&&"sublayers"in e&&e.sublayers},()=>this._constructLegendElementsForWMSSublayers()),"wms-sublayers-watcher"),this.legendElements=await this._generateLegendElementsForWMSSublayers(e.sublayers,t),this._loading=!1,this.notifyChange("ready")}async _generateLegendElementsForWMSSublayers(e,t){const i=this.layer,s=[];this.addHandles(e.on("change",()=>this._constructLegendElementsForWMSSublayers()),"wms-sublayers-watcher");const l=this.sublayerIds?.map(e=>i.findSublayerById(e))?.filter(r)??[],n=l.length?l:e.toArray();for(const r of n){const e=y(()=>[r.title,r.visible,r.legendEnabled],()=>this._constructLegendElementsForWMSSublayers());if(this.addHandles(e,"wms-sublayers-watcher"),!this.respectLayerVisibility||r.visible&&r.legendEnabled){const e=await this._generateSymbolTableElementForWMSSublayer(r,t);e?.infos.length&&s.unshift(e)}}return s}async _generateSymbolTableElementForWMSSublayer(e,t){if(!e.legendUrl&&e.sublayers){const i=(await this._generateLegendElementsForWMSSublayers(e.sublayers,t)).filter(e=>e);return{type:"symbol-table",title:e.title,infos:i}}return this._generateSymbolTableElementForLegendUrl(e,t)}async _generateSymbolTableElementForLegendUrl(e,t){let i=e.legendUrl;if(!i)return;const l={type:"symbol-table",title:e.title||e.name||String(e.id??""),infos:[]};t&&(i=g(i,t));let r=null;const n=e.layer?.opacity;try{r=(await s(i,{responseType:"image"})).data,r&&(r.style.opacity=n)}catch{}return l.infos.push({src:i,preview:r,opacity:n}),l}_getLegendLayers(e,t){const i=et&&et[e];return i?Promise.resolve(i):this._legendRequest(t).then(t=>{const i=t.layers;return et[e]=i,i})}_legendRequest(e){const t=this.layer;let i={f:"json",dynamicLayers:e};if(He(t)){const e=t.exportImageServiceParameters.rasterFunction;if(e&&(i.renderingRule=JSON.stringify(e.functionDefinition?.toJSON()||e.toJSON())),t.bandIds&&(i.bandIds=t.bandIds.join()),t.raster||t.viewId||t.customParameters){const{raster:e,viewId:s,customParameters:l}=t;i={raster:e,viewId:s,...i,...l}}}let l=t.url.replace(/(\/)+$/,"");if("version"in t&&+t.version>=10.01){const e=l.indexOf("?");e>-1?l=l.slice(0,e)+"/legend"+l.slice(e):l+="/legend"}else{const e=l.toLowerCase().indexOf("/rest/"),t=-1===e?l:l.slice(0,e)+l.slice(e+5);l=ye+"?soapUrl="+encodeURI(t)+"&returnbytes=true"}return s(l,{query:i}).then(e=>e.data)}async _constructLegendElementsForBuildingSceneLayer(){this._loading=!0,this.legendElements=[],this.removeHandles("sublayers-watcher");const e=this.layer;this.addHandles(y(()=>e.sublayers,()=>this._constructLegendElementsForBuildingSceneLayer()),"sublayers-watcher");try{this.legendElements=await this._generateLegendElementsForBuildingSublayers(e.sublayers,this.opacity)}catch(t){o.getLogger(this).warn("Request to server for legend has failed!",t)}finally{this._loading=!1,this.notifyChange("ready")}}async _generateLegendElementsForBuildingSublayers(e,t){let i=[];this.addHandles(e.on("change",()=>this._constructLegendElementsForBuildingSceneLayer()),"sublayers-watcher");const s=e.toArray();for(const l of s){const e=y(()=>["renderer"in l&&l.renderer,l.opacity,l.title,l.visible],()=>this._constructLegendElementsForBuildingSceneLayer());if(this.addHandles(e,"sublayers-watcher"),!this.respectLayerVisibility||l.visible){const e=null!=l?.opacity?l.opacity:null,s=null!=e?e*t:t;if("building-group"===l.type){const e={type:"symbol-table",title:l.title,infos:[]},t=await this._generateLegendElementsForBuildingSublayers(l.sublayers,s);e.infos.push(...t),i=[e,...i]}else if(l.renderer){i=[...await this._getRendererLegendElements(l.renderer,{title:l.title,opacity:s,sublayer:l}),...i]}}}return i.filter(e=>!!e&&(!("infos"in e)||!e.infos||e.infos.length>0))}async _constructLegendElementsForSublayers(){this._loading=!0,this.removeHandles("sublayers-watcher");const e=this.layer;if(!(Ne(e)||$e(e)||Pe(e))||this.hideLayersNotInCurrentView&&!await this._isLayerInCurrentView())return this.legendElements=[],this._loading=!1,void this.notifyChange("ready");this.addHandles(y(()=>e.sublayers,()=>this._constructLegendElementsForSublayers),"sublayers-watcher");try{this.legendElements=await this._generateLegendElementsForSublayers(e.sublayers,this.opacity)}catch(t){o.getLogger(this).warn("Request to server for legend has failed!",t)}finally{this._loading=!1,this.notifyChange("ready")}}async _generateLegendElementsForSublayers(e,t,i){const s=this.layer;let l=[];this.addHandles(e.on("change",()=>this._constructLegendElementsForSublayers()),"sublayers-watcher");let n=e.toArray();!i&&this.sublayerIds&&this.sublayerIds.length&&(n=Pe(s)?this.sublayerIds.map(e=>s.findSublayerForSubtypeCode(e)).filter(r):this.sublayerIds.map(e=>s.findSublayerById(e)).filter(r));for(const r of n){const e=y(()=>[r.renderer,r.opacity,r.title,r.visible,r.legendEnabled],()=>this._constructLegendElementsForSublayers());this.addHandles(e,"sublayers-watcher");const s=r.createQuery().where,n=!this.hideLayersNotInCurrentView||await this._isLayerInCurrentView(s),a=!this.respectLayerVisibility||r.visible&&r.legendEnabled&&this._isSublayerInScale(r);if(n&&a){const e=null!=r?.opacity?r.opacity:null,s=null!=e?e*t:t,n=!Qe(r)||r.originIdOf("renderer")>2&&!r.sublayers;if(r.renderer&&n){await r.load();l=[...await this._getRendererLegendElements(r.renderer,{title:r.title,opacity:s,sublayer:r}),...l]}else if(Qe(r)){const e=await this._generateSymbolTableElementForSublayer(r,s,i);e&&l.unshift(e)}}}return l.filter(e=>!!e&&(!("infos"in e)||!e.infos||e.infos.length>0))}async _generateSymbolTableElementForSublayer(e,t,i){if(!i){i=new Map;const t=this.layer,s=e.source;let l=null;if(!(!s||"map-layer"===s.type&&s.mapLayerId===e.id&&(!s.gdbVersion||s.gdbVersion===("gdbVersion"in t&&t.gdbVersion)))||e.originIdOf("renderer")>2||e.originIdOf("labelingInfo")>2||e.originIdOf("labelsVisible")>2){const e=new v({layer:this.layer});l=e.hasDynamicLayers?e.dynamicLayers:null,e.destroy()}const r=l||`${t.uid}-default`;(await this._getLegendLayers(r,l)).forEach(e=>i.set(e.layerId,e))}const s=i.get(e.id);if((!s||s?.subLayerIds&&s.defaultVisibility)&&e.sublayers){const s=await this._generateLegendElementsForSublayers(e.sublayers,t,i);return{type:"symbol-table",title:e.title,infos:s}}return this._generateSymbolTableElementForLegendLayer(s,e,t)}_generateSymbolTableElementForLegendLayer(e,t,i){if(!e?.legend||this.respectLayerVisibility&&!this._isLegendLayerInScale(e,t))return null;const s=t?.renderer;let l=t?.title||e.layerName;if(s&&(!t||t?.originIdOf("renderer")>2)){const e=t?.title||this._getRendererTitle(s,t);e&&(l&&"string"!=typeof e&&"title"in e&&(e.title=l),l=e)}const r={type:"symbol-table",title:l,legendType:e.legendType||null,infos:[]},n=t?this._sanitizeLegendForSublayer(e.legend.slice(),t):e.legend;return e.legendGroups&&e.legendGroups.length>0?e.legendGroups.forEach(s=>{const l={type:"symbol-table",title:s.heading,legendType:e.legendType||null,infos:this._generateSymbolTableElementInfosForLegendLayer(n.filter(e=>e.groupId===s.id),e.layerId,s.heading||r.title||t?.title,i)};l.infos?.length>0&&r.infos.push(l)}):r.infos=this._generateSymbolTableElementInfosForLegendLayer(n,e.layerId,r.title||t?.title,i),r.infos.length>0?r:null}_generateSymbolTableElementInfosForLegendLayer(e,t,s,l){return e.map(e=>{let r=e.url;if(e.imageData&&e.imageData.length>0)r=`data:image/png;base64,${e.imageData}`;else{if(r.startsWith("http"))return null;r=i(`${this.layer.url}/${t}/images/${r}`)}let n=e.label;return"<all other values>"===n&&(n="others"),{previewAriaLabel:n||s,label:n,src:r,opacity:l??this.opacity,width:e.width,height:e.height}}).filter(r)}_isSublayerInScale(e){const t=e.minScale||0,i=e.maxScale||0;return!(t>0&&t<this.scale||i>this.scale)}_isLegendLayerInScale(e,t){const i=t||this.layer;let s=null,l=null,r=!0;return!i.minScale&&0!==i.minScale||!i.maxScale&&0!==i.maxScale?(0===e.minScale&&i.tileInfo&&(s=i.tileInfo.lods[0].scale),0===e.maxScale&&i.tileInfo&&(l=i.tileInfo.lods[i.tileInfo.lods.length-1].scale)):(s=Math.min(i.minScale,e.minScale)||i.minScale||e.minScale,l=Math.max(i.maxScale,e.maxScale)),(s>0&&s<this.scale||l>this.scale)&&(r=!1),r}_sanitizeLegendForSublayer(e,t){if("version"in this.layer&&+this.layer.version<10.1||0===e.length)return e;const i=t.renderer,s=e.some(e=>e.values);let l=0,r=null;return s&&e.some((e,t)=>(e.values||(l=t,r=e,r.label||(r.label="others")),null!=r)),i?"unique-value"===i.type?r&&(e.splice(l,1),e.push(r)):"class-breaks"===i.type&&(r&&e.splice(l,1),i.legendOptions?.order||e.reverse(),r&&e.push(r)):r&&(e.splice(l,1),e.push(r)),e}async _getRendererLegendElements(e,t={}){if(!ke(e,this.view))return o.getLogger(this).warn(`Renderer of type '${e.type}' not supported!`),[];if(Ve(e))return this._constructPointCloudRendererLegendElements(e,t);if(je(e))return this._constructDotDensityRendererLegendElements(e);const i=await this._loadRenderer(e);return Oe(i)?this._constructPieChartRendererLegendElements(i):this._constructRendererLegendElements(i,t)}async _getLegendElementsForFeatureReduction(e){let t=null;return"binning"===e.type?t=e.renderer:"cluster"===e.type&&(t=this._getClusterRenderer(e)),t?this._getRendererLegendElements(t,{isFeatureReductionRenderer:!0}):[]}_getPointCloudRendererTitle(e){return(e.legendOptions?.title||e.field)??""}async _constructPointCloudRendererLegendElements(e,t={}){const i=t.title,s=[];let l=null,r=null;if(xe(e))l={type:"symbol-table",title:i||this._getPointCloudRendererTitle(e),infos:[]},e.colorClassBreakInfos.forEach(e=>{l.infos.unshift({label:e.label||e.minValue+" - "+e.maxValue,value:[e.minValue,e.maxValue],symbol:this._getAppliedCloneSymbol(be,e.color)})});else if(ze(e)){const t=e.stops;let s=null;if(t?.length&&(1===t.length&&(s=t[0].color),!s)){const e=t[0].value,i=t[t.length-1].value;if(null!=e&&null!=i){s=H(e+(i-e)/2,t)}}l={type:"symbol-table",title:null,infos:[{label:null,value:null,symbol:this._getAppliedCloneSymbol(be,s||be.color)}]};const n=q(e.stops??[])??[];r={type:"color-ramp",title:i||this._getPointCloudRendererTitle(e),infos:n,preview:M(n.map(e=>e.color))}}else Te(e)&&(l={type:"symbol-table",title:i||this._getPointCloudRendererTitle(e),infos:[]},e.colorUniqueValueInfos?.forEach(e=>{l.infos.push({label:e.label||e.values.join(", "),value:e.values.join(", "),symbol:this._getAppliedCloneSymbol(be,e.color)})}));return l?.infos.length&&s.push(l),r?.infos.length&&s.push(r),await this._generatePreviewsForLegendElements(s,{opacity:this.opacity,symbolConfig:{applyColorModulation:!!e.colorModulation}}),s}async _getElementInfoForDotDensity(e,t){const{color:i,label:s,valueExpressionTitle:l}=t,{backgroundColor:r,outline:n,dotSize:a}=e,o=this.cssEffectFilter,u=a+"-"+i+"-"+r+"-"+(n&&JSON.stringify(n.toJSON()))+"-"+o,c=this._dotDensityUrlCache,d=c.has(u)?c.get(u):P(e,i);c.set(u,d);const y={shape:{type:"image",x:0,y:0,width:d.width,height:d.height,src:d.src},fill:null,stroke:null,offset:[0,0]},h=k([[y]],[d.width,d.height],{cssEffectFilter:this.cssEffectFilter});return{opacity:1,src:d.src,preview:h,width:d.width,height:d.height,previewAriaLabel:s||l}}async _constructDotDensityRendererLegendElements(e){const t=e.calculateDotValue(this.view.scale),i=e.legendOptions?.unit,s={type:"symbol-table",title:{value:t&&Math.round(t),unit:i||""},infos:[]};for(const l of e.attributes){const t=await this._getElementInfoForDotDensity(e,l);t.label=l.label||l.valueExpressionTitle||l.field,s.infos.push(t)}return[s]}async _constructPieChartRendererLegendElements(e){const t=[];let i=null;const s=e.outline;e.attributes.forEach(e=>{const i=new j({color:e.color,outline:s}),l=e.label||e.valueExpressionTitle||e.field;t.push({label:l,symbol:i})});const l=t.length?[...t]:[];if(e.othersCategory?.color&&0!==e.othersCategory?.threshold){const l=new j({color:e.othersCategory.color,outline:s});i=e.othersCategory.label||"Other",t.push({label:i,symbol:l})}if(e.defaultColor?.a){const i=new j({color:e.defaultColor,outline:s});t.push({label:e.defaultLabel,symbol:i})}const r=await this._getVisualVariableLegendElements(e,this.layer)||[];if(t.length){r.unshift({type:"symbol-table",title:null,infos:t});const n=l.filter(e=>e.label!==i).map(e=>e.symbol.color).filter(Boolean),a=U(n,{holePercentage:e.holePercentage,backgroundColor:e.backgroundFillSymbol?.color,cssEffectFilter:this.cssEffectFilter,outline:s});r.unshift({type:"pie-chart-ramp",title:this._getRendererTitle(e,this.layer),infos:t,preview:a})}return await this._generatePreviewsForLegendElements(r,{opacity:this.layer.opacity,cssEffectFilter:this.cssEffectFilter}),r}async _getWhereClause(e,t,i){const s=await p(e,i),l=new Set,{field:r,field2:n,field3:a}=t;L(l,i,[r,n,a]),await E(l,i,null,t.valueExpression);const o=new Set(Array.from(l,e=>e.toLowerCase())),u=s?.fieldNames.map(e=>e.toLowerCase());return u?.some(e=>!o.has(e))?null:s}async _processDefinitionExpression(e,t){if(!("definitionExpression"in e))return;const i=e.definitionExpression;i&&this.respectLayerDefinitionExpression?this._layerDefinitionExpression!==i&&(this._layerDefinitionExpressionClause=await this._getWhereClause(i,t,e.fieldsIndex)):this._layerDefinitionExpressionClause=null,this._layerDefinitionExpression=i}async _processDisplayFilter(e,t){if(!("displayFilterInfo"in e))return;const i=e.displayFilterInfo?w(e.displayFilterInfo,this.view):null;return i?.where?this._layerDisplayFilter?.id!==i?.id&&(this._layerDisplayFilterClause=await this._getWhereClause(i.where,t,e.fieldsIndex)):this._layerDisplayFilterClause=null,this._layerDisplayFilter=i,i}async _constructRendererLegendElements(e,t={}){const{title:i,sublayer:s,isFeatureReductionRenderer:l}=t,r=s||this.layer,n=ie(e,"reference-size"),a=ie(e,"spike"),o=l&&"renderer"in r&&r.renderer?r.renderer:e;let u=null;Ie(o)&&(await this._processDefinitionExpression(r,o),u=await this._processDisplayFilter(r,o)),this._hasColorRamp=!1,this._hasOpacityRamp=!1,this._hasSizeRamp=!1,this._scaleDrivenSizeVariable=null;const c=await this._getVisualVariableLegendElements(e,r)||[],d={type:"symbol-table",title:i||this._getRendererTitle(e,r),infos:[]};let y=null,h=!1;const f=new Set;if(Se(e)&&!this._hasSizeRamp){const t=await se(e);d.infos.push({label:null,symbol:t})}else if(Je(e)){let t=i;const s=Ze(e)?"univariate-above-and-below-ramp":"univariate-color-size-ramp",l=c.findIndex(e=>"color-ramp"===e.type),r=-1!==l?c.splice(l,1)[0]:null,n=c.findIndex(e=>"size-ramp"===e.type),a=-1!==n?c.splice(n,1)[0]:null,o=[];r&&(t=r.title,o.push(r)),a&&(t=a.title,o.push(a)),o.length>0&&c.push({type:s,title:t,infos:o})}else if(Re(e)){const t=J(e);c.push({type:"heatmap-ramp",title:i||this._getRendererTitle(e,r),infos:t,preview:M(t.map(e=>e.color),{cssEffectFilter:this.cssEffectFilter})})}else if(Ie(e)){const t=e.authoringInfo;if("relationship"===t?.type){const{numClasses:i,field1:s,field2:l}=t,n=t.focus;if(i&&s&&l){const t=[s,l];let a=Z(n)||0;for(const e of t){const{field:t,normalizationField:i,label:s}=e,l=s||{field:this._getFieldAlias(t,r),normField:i&&this._getFieldAlias(i,r)},n=Ye.clone();n.angle=a,d.infos.push({label:l,symbol:n}),f.add(n),a+=90}const o=Q({focus:n,numClasses:i,infos:e.uniqueValueInfos??[]});c.unshift(o)}}else if(He(this.layer)||qe(this.layer)){const{uniqueValueInfos:t}=e;if(t)for(const e of t)e.symbol&&await this._checkClausesForUVR(o,e.value)&&d.infos.push({label:e.label||e.value,value:e.value,symbol:e.symbol})}else{const{field:t,field2:s,field3:l,fieldDelimiter:a,valueExpression:c,defaultSymbol:y}=e,f=!(!t&&!c||!s&&!l),m=u?u.title:null,p=[],{uniqueValueGroups:g}=e;if(g)for(const e of g){const i={type:"symbol-table",title:m||e.heading,infos:[]},{classes:u}=e;if(u)for(const e of u){const{symbol:u,values:d}=e;if(u){const y=[],h=[];for(const e of d??[]){const{value:i,value2:n,value3:o}=e,u=[],d=[];(t||c)&&(u.push(i),d.push(this._getDomainName(t,i,r)??le(i,re(r,t,this.view.timeZone)))),s&&(u.push(n),d.push(this._getDomainName(s,n,r)??le(n,re(r,s,this.view.timeZone)))),l&&(u.push(o),d.push(this._getDomainName(l,o,r)??le(o,re(r,l,this.view.timeZone)))),y.push(f?u.join(a||""):u[0]),h.push(d.join(" - "))}const m=y.join(", ");let p=e.label;if(!p){const e=h.filter(Boolean);p=e.length?e.join(", "):m}let g=u;"cim"===g.type&&n&&(g=g.clone(),z(g,{innerDotSize:.5*de,outerRingSize:de}));let b=!1;for(const e of y)if(b=await this._checkClausesForUVR(o,e),b)break;b&&i.infos.push({label:p,value:m,symbol:g})}}i.infos.length&&p.push(i)}if(p.length){const t=p[0];if(1===p.length&&"title"in t&&!t.title){const e=t.infos?.filter(Ke)??[];d.infos.push(...e)}else y&&(p.push({type:"symbol-table",infos:[{label:e.defaultLabel||"others",symbol:y}]}),h=!0),d.infos.push(...p);i||e.legendOptions?.title||e.valueExpressionTitle||(d.title=null)}}e.defaultSymbol&&!h&&(d.infos.push({label:e.defaultLabel||"others",symbol:e.defaultSymbol}),h=!0)}else if(Ce(e)){if(!n&&!a){y=this._isUnclassedRenderer(e);if(!y||!this._hasSizeRamp){const t=e.classBreakInfos.filter(({symbol:e})=>e),i="ascending-values"===e.legendOptions?.order;for(const{label:e,minValue:s,maxValue:l,symbol:n}of t){const t=e||(y?null:`${s} - ${l}`),a={previewAriaLabel:t||d.title||r.title,label:t,value:[s,l],symbol:n};i?d.infos.push(a):d.infos.unshift(a)}y&&(d.title=null),this._updateInfosForClassedSizeRenderer(e,d.infos)}e.defaultSymbol&&!y&&(d.infos.push({label:e.defaultLabel||"others",symbol:e.defaultSymbol}),h=!0)}}else if(Le(e))if(qe(this.layer)||We(this.layer)){const t=await this._constructTileImageryStretchRendererElements(e);Ge(t)?c.push(t):d.infos=t}else{const t=this.layer;let i,s;e.customStatistics?.length&&({min:i,max:s}=e.customStatistics[0]);let l=[],r=t.serviceRasterInfo;if(t.rasterFunction)try{r=await t.generateRasterInfo(t.rasterFunction)}catch{}const n=I(r.pixelType);if(1===r.bandCount){const l=t.bandIds?.[0]||0;i=null!=i?i:r.statistics?r.statistics[l].min:n[0],s=null!=s?s:r.statistics?r.statistics[l].max:n[1],i||s?c.push(await this._getStretchLegendElements(e,{min:i,max:s})):this._getServerSideLegend()}else if(1===t.bandIds?.length)i=null!=i?i:r.statistics?r.statistics[t.bandIds[0]].min:n[0],s=null!=s?s:r.statistics?r.statistics[t.bandIds[0]].max:n[1],i||s?c.push(await this._getStretchLegendElements(e,{min:i,max:s})):this._getServerSideLegend();else if(r.bandCount>=3){const{bandInfos:e}=r,{bandIds:i}=t;e.length>=r.bandCount?3===i?.length?(l=i.map(t=>e[t].name),d.infos=this._createSymbolTableElementMultiBand(l)):"lerc"===t.format?(l=[0,1,2].map(t=>e[t].name),d.infos=this._createSymbolTableElementMultiBand(l)):this._getServerSideLegend():"lerc"===t.format?(l=["band1","band2","band3"],d.infos=this._createSymbolTableElementMultiBand(l)):this._getServerSideLegend()}else this._getServerSideLegend()}else if(ve(e))e.colormapInfos.forEach(e=>{d.infos.push({label:e.label,value:e.value,symbol:this._getAppliedCloneSymbol(_e,e.color)})});else if(Fe(e)){let i=e.symbol;switch(t.geometryType){case"point":i="pointSymbol"in r?r.pointSymbol:null;break;case"polyline":i="lineSymbol"in r?r.lineSymbol:null;break;case"polygon":i="polygonSymbol"in r?r.polygonSymbol:null}const s=this._clusterSizeVariable&&this._getClusterSymbol()||!this._hasSizeRamp;e.symbol&&s&&d.infos.push({previewAriaLabel:e.label||d.title||r.title,label:e.label,symbol:i})}else if(we(e)){e.outputUnit&&(this.title="("+e.toJSON().outputUnit+")"),d.title=e.attributeField;const t=e.getClassBreakInfos();t?.length?t.forEach(e=>{d.infos.push({label:e.minValue+" - "+e.maxValue,symbol:e.symbol})}):d.infos.push({label:e.attributeField,symbol:e.getDefaultSymbol()})}else Ee(e)&&c.push(await this._getStretchLegendElements(e,{min:0,max:255}));const m=e.defaultSymbol;!m||h||Fe(e)||y&&!this._hasColorRamp&&!this._hasSizeRamp&&!this._hasOpacityRamp||c.push({type:"symbol-table",infos:[{label:e.defaultLabel||"others",symbol:m}]}),d.infos.length&&c.unshift(d);const p=null==t.opacity?this.opacity:t.opacity,g=this._isTallSymbol("visualVariables"in e?e.visualVariables:null),b=He(this.layer)||qe(this.layer);return await this._generatePreviewsForLegendElements(c,{opacity:p,symbolConfig:{isTall:g,isSquareFill:b},cssEffectFilter:this.cssEffectFilter},{arrowMarkerSymbols:f}),e=null,c}async _waitForLayerViewUpdate(e){await f(()=>!e.updating)}async _checkFeatureCountForExpression(e,t){const i=this.layerView;if(!(i&&"createQuery"in i&&"queryFeatureCount"in i))return!0;try{await this._waitForLayerViewUpdate(i);const s=i.createQuery();e&&(s.where=ne(s.where,e)),t&&(s.geometry=t);return await i.queryFeatureCount(s)>0}catch{return!0}}async _checkClausesForUVR(e,t){const i=Xe(e,t);if(!i)return!0;return(!!!(!this._layerDefinitionExpressionClause&&this._layerDefinitionExpression&&this.respectLayerDefinitionExpression||!this._layerDisplayFilterClause&&this._layerDisplayFilter?.where)||await this._checkFeatureCountForExpression(`${e.field} = ${t}`))&&(!this._layerDefinitionExpressionClause||this._layerDefinitionExpressionClause.testFeature(i))&&(!this._layerDisplayFilterClause||this._layerDisplayFilterClause.testFeature(i))}_getServerSideLegend(){setTimeout(()=>this.buildLegendElementsForTools(),0)}_getAllInfos(e){const t=e?.infos;return t?t.reduce((e,t)=>e.concat(this._getAllInfos(t)),[]):[e]}async _constructTileImageryStretchRendererElements(e){const t=this.layer,i=t.symbolizer.rasterInfo??t.raster.rasterInfo;let s,l;const r=e?.customStatistics?.length?e.customStatistics:i?.statistics;if(r)({min:s,max:l}=r[0]);else{const e=I(i.pixelType);s=e[0],l=e[1]}if(t.hasStandardTime()&&(s=t.getStandardTimeValue(s),l=t.getStandardTimeValue(l)),1===i.bandCount||1===t.bandIds?.length)return this._getStretchLegendElements(e,{min:s,max:l});const n=(t?.bandIds?.length?t.bandIds:Array.from(Array(Math.min(i.bandCount,3)).keys())).map(e=>i.bandInfos[e].name);return n.length<3?n.push(n[1]):n.length>3&&n.splice(3),this._createSymbolTableElementMultiBand(n)}async _getStretchLegendElements(e,t){const i=e.colorRamp?.toJSON(),s=W(i,t);return{type:"stretch-ramp",title:"",infos:s,preview:M(s.map(e=>e.color))}}_getClusterSymbol(){const e=this.layer,t="featureReduction"in e&&e.featureReduction,i=t&&"symbol"in t&&t.renderer;return i&&!0!==i?.authoringInfo?.isAutoGenerated?null:t&&"symbol"in t?t.symbol:null}async _getSizeLegendElement(e,t,i,s){return{type:"size-ramp",title:this._clusterSizeVariable?this._getClusterTitle(t):e,infos:await K(i,t,await ae(i),this.scale,this.view,s,this._clusterSizeVariable?this._getClusterSymbol():null)}}_createSymbolTableElementMultiBand(e){const t=[],i=["red","green","blue"];return e.forEach((e,s)=>{t.push({label:{colorName:i[s],bandName:e},src:oe[s],opacity:this.opacity??1})}),t}_updateInfosForClassedSizeRenderer(e,t){const i="class-breaks-size"===e.authoringInfo?.type,s=e.classBreakInfos.some(e=>N(e.symbol));if(i&&s){const i=X,s=Y,l=e.classBreakInfos.length,r=(i-s)/(l>1?l-1:l);t.forEach((e,t)=>{e.size=i-r*t})}}_isTallSymbol(e){let t=!1,i=!1;if(e)for(let s=0;s<e.length&&(!t||!i);s++){const l=e[s];"size"===l.type&&("height"===l.axis&&(t=!0),"width-and-depth"===l.axis&&(i=!0))}return t&&i}async _generatePreviewsForLegendElements(e,t,i){const s=[];for(const l of e)for(const e of l.infos??[])if("infos"in e&&e.infos&&s.push(this._generatePreviewsForLegendElements([e],t,i)),Ke(e)&&e.symbol&&!e.preview){let r=!0;if("cim"===e.symbol.type){const{minScale:t,maxScale:i}=e.symbol.data;(t&&t<this.scale||i&&i>this.scale)&&(r=!1)}r&&s.push(this._generateSymbolPreviewForInfo(e,{...t,clipBloomEffect:"theme"in l&&"spike"===l.theme,cssEffectFilter:i?.arrowMarkerSymbols?.has(e.symbol)?null:t.cssEffectFilter},i?{applyScaleDrivenSize:!i.arrowMarkerSymbols?.has(e.symbol)}:void 0))}await Promise.all(s)}async _getSize(e,t){let i=null==e.size&&this._hasSizeRamp?m(22):e.size;if(this._scaleDrivenSizeVariable&&t?.applyScaleDrivenSize){const{getSize:t}=await import("../../../renderers/visualVariables/support/visualVariableUtils.js");i=t(this._scaleDrivenSizeVariable,null,{view:this.view.type,scale:this.scale,shape:"simple-marker"===e.symbol.type?e.symbol.style:null})}return i}_getPreviewCIMOptions(e){return{style:"legend",cimOptions:{allowScalingUp:this._hasSizeRamp||!(!this._scaleDrivenSizeVariable||!e?.applyScaleDrivenSize),viewParams:this.isScaleDriven?{viewingMode:"2d"===this.view?.type?"map":this.view?.viewingMode,scale:this.view?.scale}:null}}}async _generateSymbolPreviewForInfo(e,t={},i){const{symbol:s}=e;try{if(t.size=await this._getSize(e,i),t.scale=!1,"cim"===s.type){const e=this._getPreviewCIMOptions(i);t={...t,...e}}e.preview=await A(s,t)}catch{e.preview=null,o.getLogger(this).warn(`Generating symbol preview failed for symbol type: ${s?.type}`)}}_getClusterRenderer(e){this._clusterSizeVariable=null;const t="renderer"in this.layer?this.layer.renderer:null,i=e.renderer?.clone()||t?.clone(),s=$(e,this.layerView,this.view);if(s&&null!=i&&"visualVariables"in i){const t=i.visualVariables?.some(e=>"size"===e.type&&"outline"!==e.target&&!pe.test(e.valueExpression));if(!t){if("clusterMinSize"in e&&"clusterMaxSize"in e){const{clusterMinSize:t,clusterMaxSize:i}=e;s.legendOptions=new x({showLegend:t!==i})}const t=i.visualVariables||[];i.visualVariables=t.concat([s]),this._clusterSizeVariable=s}}return i}async _loadRenderer(e){if(tt.has(e))return tt.get(e);const t=[],i=e.clone(),s=await ae(i);if(Ce(i)||Ie(i)){const e=(i.classBreakInfos||i.uniqueValueInfos).map(e=>this._fetchSymbol(e.symbol,s).then(t=>{e.symbol=t}).catch(()=>{e.symbol=null}));Array.prototype.push.apply(t,e)}return t.push(this._fetchSymbol(i.symbol||i.defaultSymbol,i.defaultSymbol?null:s).then(e=>{this._applySymbolToRenderer(i,e,Fe(i))}).catch(()=>{this._applySymbolToRenderer(i,null,Fe(i))})),await Promise.allSettled(t),tt.set(e,i),i}_applySymbolToRenderer(e,t,i){i?e.symbol=t:e.defaultSymbol=t}async _fetchSymbol(e,t){if(!e)throw new Error;if("web-style"===e.type){const i=this._webStyleSymbolCache;try{const s=await e.fetchSymbol({cache:i});return this._getAppliedCloneSymbol(s,t)}catch{throw o.getLogger(this).warn("Fetching web-style failed!"),new Error}}return this._getAppliedCloneSymbol(e,t)}_getAppliedCloneSymbol(e,i){if(!e||!i)return e;const s=e.clone(),l=i&&i.toRgba();return s.type.includes("3d")?this._applyColorTo3dSymbol(s,l):"cim"===s.type?O(s,i):s.color&&(s.color=new t(l||s.color)),s}_applyColorTo3dSymbol(e,i){i&&e.symbolLayers.forEach(e=>{e&&(e.material||(e.material={}),e.material.color=new t(i))})}async _getVisualVariableLegendElements(e,t){if(!("visualVariables"in e)||"vector-field"===e.type)return null;const i=e.visualVariables??[],s=[],l=[],n=[],a=ie(e,"reference-size")??ie(e,"spike");let o;const c=this._clusterSizeVariable;if(2===a?.sizeStops?.length&&(Ce(e)||Ie(e))){const[e,t]=a.sizeStops,i=c?c.minDataValue:e.value,s=c?c.maxDataValue:t.value;o=new D({field:a.field??void 0,normalizationField:a.normalizationField,minSize:u(e.size,10,100),maxSize:u(t.size,50,150),minDataValue:i,maxDataValue:s}),l.push(o)}for(const r of i)if("color"===r.type)s.push(r);else if("size"===r.type){if("cluster_count"===r.field&&o)continue;l.push(r)}else"opacity"===r.type&&n.push(r);const d=[...s,...l,...n];let y,h;if(0===s.length&&Ce(e)&&e.classBreakInfos&&1===e.classBreakInfos.length){const t=e.classBreakInfos[0];y=t&&t.symbol}if(0===s.length&&Fe(e)&&(y=e.symbol),y)if(y.type.includes("3d")){const e=y.symbolLayers.at(0);"water"===e.type?null!=e.color&&(h=e.color):null!=e.material?.color&&(h=e.material.color)}else y.url||(h=y.color);const f=this.cssEffectFilter;return(await Promise.all(d.map(async i=>{if(!1!==i.legendOptions?.showLegend){const s=Se(e)?i.field:this._getRampTitle(i,t);let l=null;const r=ue(t,i,this.view.timeZone);if("color"===i.type){const e=await G(i,null,r)??[];l={type:"color-ramp",title:s,infos:e,preview:M(e.map(e=>e.color),{cssEffectFilter:f})},this._hasColorRamp||(this._hasColorRamp=e.length>0)}else if("size"===i.type&&"outline"!==i.target)pe.test(i.valueExpression)?this._clusterSizeVariable||(this._scaleDrivenSizeVariable=i):(l=await this._getSizeLegendElement(s,i,e,r),o===i&&"spike"===a?.theme&&(l.theme=a.theme),this._hasSizeRamp||(this._hasSizeRamp=!(null==l.infos||!l.infos.length)));else if("opacity"===i.type){const e=await G(i,h,r)??[];l={type:"opacity-ramp",title:s,infos:e,preview:M(e.map(e=>e.color),{cssEffectFilter:f})},this._hasOpacityRamp||(this._hasOpacityRamp=e.length>0)}return l?.infos?l:null}}))).filter(r)}_getDomainName(e,t,i){if(e&&"function"!=typeof e){const s="getField"in i&&i.getField?.(e),l=s&&"getFieldDomain"in i&&i.getFieldDomain?i.getFieldDomain(s.name,{excludeImpliedDomains:has("esri-widget-legacy-field-domain-calculation")}):null;return"coded-value"===l?.type?l.getName(t):null}return null}_getClusterTitle(e){const t=this.layer,i=e.field;if("featureReduction"in t&&"cluster"===t.featureReduction?.type){const e=t.featureReduction,s="popupTemplate"in e&&e.popupTemplate,l=s&&s.fieldInfos;if(l)for(const t of l)if(t.fieldName===i)return"cluster_count"===i?t.label||{showCount:!0}:t.label}return{showCount:!0}}_getRampTitle(e,t){let i=e.field,s=e.normalizationField,l=!1,r=!1,n=!1,a=null;i="function"==typeof i?null:i,s="function"==typeof s?null:s;const o=e.legendOptions?.title;if(null!=o)a=o;else if(e.valueExpressionTitle)a=e.valueExpressionTitle;else{if("renderer"in t&&t.renderer&&"authoringInfo"in t.renderer&&t.renderer.authoringInfo?.visualVariables){const e=t.renderer.authoringInfo.visualVariables;for(let t=0;t<e.length;t++){const i=e[t];if("color"===i.type){if("ratio"===i.style){l=!0;break}if("percent"===i.style){r=!0;break}if("percent-of-total"===i.style){n=!0;break}}}}a={field:i&&this._getFieldAlias(i,t),normField:s&&this._getFieldAlias(s,t),ratio:l,ratioPercent:r,ratioPercentTotal:n}}return a}_getRendererTitle(e,t){const i=e;if(i.legendOptions?.title)return i.legendOptions.title;if(i.valueExpressionTitle)return i.valueExpressionTitle;let s=i.field,l=null,r=null;if(Ce(i)&&(l=i.normalizationField,r="percent-of-total"===i.normalizationType),s="function"==typeof s?null:s,l="function"==typeof l?null:l,Ie(i)){const{field2:e,field3:l,fieldDelimiter:r}=i;let n=s&&this._getFieldAlias(s,t);return e&&(n=`<${n}>${r}<${this._getFieldAlias(e,t)}>`,l&&(n=`${n}${r}<${this._getFieldAlias(l,t)}>`)),n}let n=null;return(s||l)&&(n={field:s&&this._getFieldAlias(s,t),normField:l&&this._getFieldAlias(l,t),normByPct:r}),n}_getFieldAlias(e,t){const i="featureReduction"in t&&t.featureReduction;if(C(t)&&!i)return t.getFieldAlias(e)||e;const s="popupTemplate"in t?t.popupTemplate:null,l=s?.fieldInfos;let r=l?.find(t=>e===t.fieldName),n=null;"getField"in t&&t.getField?n=t.getField(e):"fieldsIndex"in t&&t.fieldsIndex&&(n=t.fieldsIndex.get(e));let a=null;i&&(r??="popupTemplate"in i?i.popupTemplate?.fieldInfos?.find(t=>e?.toLowerCase()===t.fieldName?.toLowerCase()):void 0,"fields"in i&&i.fields&&(a=i.fields.find(t=>t.name?.toLowerCase()===e?.toLowerCase())));const o=r||n||a;let u=null;return o&&(u=r?.label||n?.alias||a?.alias||"name"in o&&o.name||"fieldName"in o&&o.fieldName||null),u}_isUnclassedRenderer(e){const t=e.visualVariables;let i=!1;return Ce(e)&&e.classBreakInfos&&1===e.classBreakInfos.length&&t&&(i=e.field?t.some(t=>!(!t||e.field!==t.field||(e.normalizationField||t.normalizationField)&&e.normalizationField!==t.normalizationField)):!!t.length),i}};e([b()],it.prototype,"_loading",void 0),e([b()],it.prototype,"children",void 0),e([b({readOnly:!0})],it.prototype,"cssEffectFilter",null),e([b()],it.prototype,"layerView",void 0),e([b()],it.prototype,"layer",void 0),e([b()],it.prototype,"legendElements",void 0),e([b({readOnly:!0})],it.prototype,"loading",null),e([b({readOnly:!0})],it.prototype,"opacity",null),e([b()],it.prototype,"parent",void 0),e([b({readOnly:!0,dependsOn:[]})],it.prototype,"ready",null),e([b()],it.prototype,"hideLayersNotInCurrentView",void 0),e([b()],it.prototype,"keepCacheOnDestroy",void 0),e([b()],it.prototype,"respectLayerDefinitionExpression",void 0),e([b()],it.prototype,"respectLayerVisibility",void 0),e([b({readOnly:!0})],it.prototype,"scale",null),e([b()],it.prototype,"sublayerIds",void 0),e([b({readOnly:!0})],it.prototype,"isScaleDriven",null),e([b()],it.prototype,"title",void 0),e([b({readOnly:!0,dependsOn:["ready"],value:0})],it.prototype,"version",null),e([b()],it.prototype,"view",void 0),it=e([_("esri.widgets.Legend.support.ActiveLayerInfo")],it);export{it as default};
5
+ import{__decorate as e}from"tslib";import t from"../../../Color.js";import{addTokenParameter as i}from"../../../kernel.js";import s from"../../../request.js";import l from"../../../core/Accessor.js";import{isSome as r}from"../../../core/arrayUtils.js";import n from"../../../core/Collection.js";import has from"../../../core/has.js";import{JSONMap as a}from"../../../core/jsonMap.js";import o from"../../../core/Logger.js";import{clamp as u}from"../../../core/mathUtils.js";import{debounce as c}from"../../../core/promiseUtils.js";import{on as d,watch as y,initial as h,whenOnce as f}from"../../../core/reactiveUtils.js";import{px2pt as m}from"../../../core/screenUtils.js";import{parseWhereClause as p}from"../../../core/sql.js";import{addQueryParameters as g}from"../../../core/urlUtils.js";import{property as b,subclass as _}from"../../../core/accessorSupport/decorators.js";import{EffectView as S}from"../../../layers/effects/EffectView.js";import{getPixelValueRange as w}from"../../../layers/raster/formats/pixelRangeUtils.js";import{getEffectiveDisplayFilter as v}from"../../../layers/support/displayFilterUtils.js";import{ExportImageParameters as L}from"../../../layers/support/ExportImageParameters.js";import{collectFields as E,collectArcadeFieldNames as F}from"../../../layers/support/fieldUtils.js";import{isFeatureLayer as C,supportsFieldConfiguration as I}from"../../../layers/support/layerUtils.js";import{fromJSON as R}from"../../../renderers/support/jsonUtils.js";import{isSupportedRenderer3D as V}from"../../../renderers/support/rendererConversion.js";import D from"../../../renderers/visualVariables/SizeVariable.js";import x from"../../../renderers/visualVariables/support/SizeVariableLegendOptions.js";import{updateReferenceSizeSymbol as z}from"../../../smartMapping/renderers/support/referenceSizeUtils.js";import T from"../../../symbols/SimpleFillSymbol.js";import j from"../../../symbols/SimpleMarkerSymbol.js";import{applyCIMSymbolColor as O}from"../../../symbols/support/cimSymbolUtils.js";import{renderSymbol as k}from"../../../symbols/support/renderUtils.js";import{renderColorRampPreviewHTML as M,renderDotDensityPreviewHTML as P,renderPieChartPreviewHTML as U,renderPreviewHTML as A}from"../../../symbols/support/symbolUtils.js";import{getCSSFilterFromEffectList as B,isVolumetricSymbol as N}from"../../../symbols/support/utils.js";import{getEffectiveClusterSizeVariable as $}from"./clusterUtils.js";import{getColorFromPointCloudStops as H,getRampStopsForPointCloud as q,getStretchRampStops as W,getRampStops as G}from"./colorRampUtils.js";import{getHeatmapRampStops as J}from"./heatmapRampUtils.js";import{getRotationAngleForFocus as Z,getRelationshipRampElement as Q}from"./relationshipRampUtils.js";import{getRampStops as K,realWorldMaxSize as X,realWorldMinSize as Y}from"./sizeRampUtils.js";import{specialCharsLessThan as ee,specialCharsGreaterThan as te,getAuthoringInfoVisualVariableByTheme as ie,getSymbolForFlowRenderer as se,formatValue as le,getFormatOptions as re,mergeWhereClauses as ne,getMedianColor as ae,rgbImgSource as oe,getFormatOptionsForVisualVariable as ue}from"./utils.js";import{formatNumberLabel as ce}from"../../smartMapping/support/utils.js";const de=16,ye="https://utility.arcgis.com/sharing/tools/legend",he="esri.layers.ImageryLayer",fe="esri.layers.ImageryTileLayer",me="esri.layers.WCSLayer",pe=/^\s*(return\s+)?\$view\.scale\s*(;)?\s*$/i,ge=new a({esriGeometryPoint:"point",esriGeometryMultipoint:"multipoint",esriGeometryPolyline:"polyline",esriGeometryPolygon:"polygon",esriGeometryMultiPatch:"multipatch"}),be=new j({size:6,outline:{color:[128,128,128,.5],width:.5}}),_e=new T({style:"solid"});function Se(e){return"flow"===e.type}function we(e){return"vector-field"===e.type}function ve(e){return"raster-colormap"===e.type}function Le(e){return"raster-stretch"===e.type}function Ee(e){return"raster-shaded-relief"===e.type}function Fe(e){return"esri.renderers.SimpleRenderer"===e.declaredClass}function Ce(e){return"esri.renderers.ClassBreaksRenderer"===e.declaredClass}function Ie(e){return"esri.renderers.UniqueValueRenderer"===e.declaredClass}function Re(e){return"esri.renderers.HeatmapRenderer"===e.declaredClass}function Ve(e){return xe(e)||ze(e)||Te(e)||De(e)}function De(e){return"esri.renderers.PointCloudRGBRenderer"===e.declaredClass}function xe(e){return"esri.renderers.PointCloudClassBreaksRenderer"===e.declaredClass}function ze(e){return"esri.renderers.PointCloudStretchRenderer"===e.declaredClass}function Te(e){return"esri.renderers.PointCloudUniqueValueRenderer"===e.declaredClass}function je(e){return"esri.renderers.DotDensityRenderer"===e.declaredClass}function Oe(e){return"esri.renderers.PieChartRenderer"===e.declaredClass}function ke(e,t){return Fe(e)||Ce(e)||Ie(e)||Re(e)||je(e)||Oe(e)?"2d"===t.type||V(e):Le(e)||ve(e)||Ee(e)||xe(e)||ze(e)||Te(e)||we(e)||Se(e)}function Me(e){return"esri.layers.BuildingSceneLayer"===e.declaredClass}function Pe(e){return"esri.layers.SubtypeGroupLayer"===e.declaredClass}function Ue(e){return"esri.layers.VoxelLayer"===e.declaredClass}function Ae(e){return"esri.layers.WMSLayer"===e.declaredClass}function Be(e){return"esri.layers.WMTSLayer"===e.declaredClass}function Ne(e){return"esri.layers.MapImageLayer"===e.declaredClass}function $e(e){return"esri.layers.TileLayer"===e.declaredClass}function He(e){return e.declaredClass===he}function qe(e){return e.declaredClass===fe}function We(e){return e.declaredClass===me}function Ge(e){return"stretch-ramp"===e.type}function Je(e){const t="authoringInfo"in e?e?.authoringInfo:null;return"univariate-color-size"===t?.type}function Ze(e){const t="authoringInfo"in e?e?.authoringInfo:null;return"univariate-color-size"===t?.type&&"above-and-below"===t?.univariateTheme}function Qe(e){return"sublayers"in e}function Ke(e){return e&&"symbol"in e}function Xe(e,t){const{field:i,field2:s,field3:l,fieldDelimiter:r,valueExpression:n}=e;if(!i)return null;const a=!(!i&&!n||!s&&!l)?t?.toString().split(r||""):[t],o=i?{[i]:a?.[0]}:null;return o&&(s&&(o[s]=a?.[1]),l&&(o[l]=a?.[2])),o}const Ye=new j({style:"path",path:"M10,5 L5,0 0,5 M5,0 L5,15",size:15,outline:{width:1,color:[85,85,85,1]}});let et={};const tt=new WeakMap;let it=class extends l{constructor(e){super(e),this._hasColorRamp=!1,this._hasOpacityRamp=!1,this._hasSizeRamp=!1,this._loading=!1,this._webStyleSymbolCache=new Map,this._dotDensityUrlCache=new Map,this._scaleDrivenSizeVariable=null,this._clusterSizeVariable=null,this._layerDefinitionExpression=null,this._layerDefinitionExpressionClause=null,this._layerDisplayFilter=null,this._layerDisplayFilterClause=null,this.children=new n,this.layerView=null,this.layer=null,this.legendElements=[],this.parent=null,this.hideLayersNotInCurrentView=!1,this.keepCacheOnDestroy=!1,this.respectLayerDefinitionExpression=!1,this.respectLayerVisibility=!0,this.sublayerIds=[],this.title=null,this.view=null}initialize(){const e=()=>this.notifyChange("ready");this.addHandles([d(()=>this.children,"change",t=>{const{added:i,removed:s}=t;i.forEach(t=>{const i=`activeLayerInfo-ready-watcher-${t.layer.uid}`;this.addHandles(y(()=>t.ready,e,h),i)}),s.forEach(e=>this.removeHandles(e.layer.uid)),e()})]),this.keepCacheOnDestroy||(et={})}destroy(){this._webStyleSymbolCache=null,this._dotDensityUrlCache=null,this._scaleDrivenSizeVariable=null,this.keepCacheOnDestroy||(et=null),this._layerDefinitionExpressionClause=null}get cssEffectFilter(){const{layer:e,scale:t}=this,i="effect"in e?e.effect:null;if(!i)return null;const s=new S({effect:i});return s.endTransition(),s.scale=t,B(s,!0)}get loading(){return this.children.length>0?this.children.some(e=>e.loading):this._loading}get opacity(){const e=this.layer.opacity,t=this.parent?.opacity,i=this.layer.parent,s=i&&"uid"in i?this._getParentLayerOpacity(i):null;return null!=t?t*e:null!=s?s*e:e}get ready(){return null===this.layer||(this.children.length>0?this._isGroupActive():this.legendElements.length>0)}get scale(){return this.view?.scale??0}get isScaleDriven(){const e=this.layer;if(null===e)return!1;if("effect"in e&&e.effect&&Array.isArray(e.effect))return!0;if("featureReduction"in e&&e.featureReduction){if("cluster"===e.featureReduction.type)return!0;if("binning"===e.featureReduction.type&&"renderer"in e.featureReduction&&e.featureReduction.renderer)return this._isRendererScaleDriven(e.featureReduction.renderer)}return"renderer"in e&&e.renderer?!!("displayFilterInfo"in e&&e.displayFilterInfo&&Ie(e.renderer))||this._isRendererScaleDriven(e.renderer):this._isLayerScaleDriven(this.layer)}get version(){return this._get("version")+1}async buildLegendElementsForFeatureCollections(e){this._loading=!0;if(!(!this.hideLayersNotInCurrentView||await this._isLayerInCurrentView()))return this.legendElements=[],this._loading=!1,void this.notifyChange("ready");const t=Array.from(e,e=>{if(C(e))return this._getRendererLegendElements(e.renderer,{title:e.title});if(e.featureSet?.features.length){const t=e.layerDefinition,i=t?.drawingInfo,s=i&&R(i.renderer),l=ge.read(t.geometryType);return s?this._getRendererLegendElements(s,{title:e.name,geometryType:l}):(o.getLogger(this).warn("drawingInfo not available!"),null)}return null});try{const e=[],i=await Promise.allSettled(t);for(const t of i)if("fulfilled"===t.status)for(const i of t.value??[])e.push(i);this.legendElements=e}catch(i){o.getLogger(this).warn("error while building legend for layer!",i)}finally{this._loading=!1,this.notifyChange("ready")}}async buildLegendElementsForRenderer(e){try{this._loading=!0;const t=!this.hideLayersNotInCurrentView||await this._isLayerInCurrentView();this.legendElements=t?await this._getRendererLegendElements(e):[]}catch(t){o.getLogger(this).warn("error while building legend for layer!",t)}finally{this._loading=!1,this.notifyChange("ready")}}async buildLegendElementsForFeatureReduction(e){try{this._loading=!0,await this._waitForLayerViewUpdate(this.layerView);const t=!this.hideLayersNotInCurrentView||await this._isLayerInCurrentView();this.legendElements=t?await this._getLegendElementsForFeatureReduction(e):[]}catch(t){o.getLogger(this).warn("error while building legend for layer!",t)}finally{this._loading=!1,this.notifyChange("ready")}}async buildLegendElementsForTools(){this._loading=!0;const e=this.layer;if(Ue(e))await this._constructLegendElementsForVoxelLayer();else if(Be(e))this._constructLegendElementsForWMTSlayer();else if(Ae(e))await this._constructLegendElementsForWMSSublayers();else if(Me(e))await this._constructLegendElementsForBuildingSceneLayer();else if(Ne(e)||$e(e)||Pe(e))await this._constructLegendElementsForSublayers();else{this.removeHandles("imageryLayers-watcher");let t="default";if(He(e)){const i=e;t=(i?.rasterFunction?.functionName||"default")+"_"+(e.bandIds?.length?e.bandIds.join(""):"###")}if(qe(e)||"link-chart"===e.type)return;await this._getLegendLayers(`${e.uid}-${t}`).then(async t=>{this.legendElements=[];const i=t.map(async t=>{if(He(e)){const t=y(()=>[e.rasterFunction,e.bandIds],()=>c(async()=>{et.default=null,e.renderer?await this.buildLegendElementsForRenderer(e.renderer):await this.buildLegendElementsForTools()})());this.addHandles(t,"imageryLayers-watcher")}const i=this._generateSymbolTableElementForLegendLayer(t);i?.infos.length&&(He(e)&&(i.title=e.title),this.legendElements.push(i))});await Promise.allSettled(i)}).catch(e=>{o.getLogger(this).warn("Request to server for legend has failed!",e)})}this._loading=!1,this.notifyChange("ready")}async _isLayerInCurrentView(e){return this._checkFeatureCountForExpression(e,this.view.extent)}_getParentLayerOpacity(e){let t=1;const i=e.parent;return i&&"uid"in i&&(t=this._getParentLayerOpacity(i)),e.opacity*t}_isGroupActive(){return this.children.some(e=>e.ready)}_isRendererScaleDriven(e){if("dot-density"===e.type)return!0;const t="valueExpression"in e?e.valueExpression:null;if(pe.test(t))return!0;const i="visualVariables"in e?e.visualVariables:null;return!!i?.some(e=>this._isScaleDrivenSizeVariable(e))||this._hasScaleDrivenSymbols(e)}_hasScaleDrivenSymbols(e){switch(e.type){case"simple":return this._isScaleDrivenSymbol(e.symbol);case"class-breaks":return this._isScaleDrivenSymbol(e.defaultSymbol)||e.classBreakInfos.some(e=>this._isScaleDrivenSymbol(e.symbol));case"unique-value":return this._isScaleDrivenSymbol(e.defaultSymbol)||!!e.uniqueValueInfos?.some(e=>this._isScaleDrivenSymbol(e.symbol))}return!1}_isScaleDrivenSymbol(e){if("cim"===e?.type){const{primitiveOverrides:t,minScale:i,maxScale:s}=e.data,l=t?.some(e=>(e.valueExpressionInfo?.expression||"").includes("$view.scale"))??!1;return null!=i||null!=s||l}return!1}_isScaleDrivenSizeVariable(e){if(e&&"size"!==e.type)return!1;const t=e,i=t.minSize,s=t.maxSize;return!("object"!=typeof i||!i||!this._isScaleDrivenSizeVariable(i))||(!("object"!=typeof s||!s||!this._isScaleDrivenSizeVariable(s))||pe.test(t.valueExpression))}_isLayerScaleDriven(e){if("minScale"in e&&e.minScale>0||"maxScale"in e&&e.maxScale>0)return!0;if("sublayers"in e&&e.sublayers)return e.sublayers.some(e=>this._isLayerScaleDriven(e));const t=e.parent;if(!1===e.loaded&&t&&Ne(t)&&"source"in e&&e.source&&"map-layer"===e.source.type)for(const i of t.sourceJSON.layers??[])if(i.id===e.source.mapLayerId&&(i.minScale>0||i.maxScale>0))return!0;return!1}async _constructLegendElementsForVoxelLayer(){this._loading=!0,this.legendElements=[],this.removeHandles("voxel-style-watcher"),this.removeHandles("voxel-current-variable");const e=this.layer;this.addHandles(y(()=>e.currentVariableId,()=>this._constructLegendElementsForVoxelLayer()),"voxel-current-variable"),this.addHandles(y(()=>e.getVariableStyles(),()=>this._constructLegendElementsForVoxelLayer()),"voxel-style-watcher");const t=e.getVariableStyle(null),i=[];if(t)if(t.uniqueValues?.length){const e=[];t.uniqueValues.forEach(t=>{t.enabled&&e.push({label:t.label||`${t.value}`,value:t.value,symbol:new T({color:t.color,outline:null})})}),e.length&&i.push({type:"symbol-table",title:t.label,infos:e})}else if(t.transferFunction){const{colorStops:e,stretchRange:s}=t.transferFunction,l=e.toArray().reverse(),r=s.map((e,t)=>`${0===t?ee:te} ${ce(e)}`).reverse(),n=l.map(e=>({color:e.color,value:null,label:null}));n[0].label=r[0],n[n.length-1].label=r[1],i.push({type:"color-ramp",title:t.label,infos:n,preview:M(l.map(e=>e.color))})}await this._generatePreviewsForLegendElements(i,{opacity:e.opacity}),this.legendElements=i,this._loading=!1,this.notifyChange("ready")}_constructLegendElementsForWMTSlayer(){this._loading=!0,this.legendElements=[],this.removeHandles("wmts-activeLayer-watcher");const e=this.layer.activeLayer;this.addHandles(y(()=>{const{layer:e}=this;return e&&"activeLayer"in e&&e.activeLayer},()=>this._constructLegendElementsForWMTSlayer()),"wmts-activeLayer-watcher");const t=e.styleId?e.styles?.find(({id:t})=>t===e.styleId)?.legendUrl:void 0;t&&(this.legendElements=[{type:"symbol-table",title:e.title,infos:[{src:t,opacity:this.opacity}]}]),this._loading=!1,this.notifyChange("ready")}async _constructLegendElementsForWMSSublayers(){this._loading=!0,this.legendElements=[],this.removeHandles("wms-sublayers-watcher");const e=this.layer;let t=null;(e.customParameters||e.customLayerParameters)&&(t={...e.customParameters,...e.customLayerParameters}),this.addHandles(y(()=>{const{layer:e}=this;return e&&"sublayers"in e&&e.sublayers},()=>this._constructLegendElementsForWMSSublayers()),"wms-sublayers-watcher"),this.legendElements=await this._generateLegendElementsForWMSSublayers(e.sublayers,t),this._loading=!1,this.notifyChange("ready")}async _generateLegendElementsForWMSSublayers(e,t){const i=this.layer,s=[];this.addHandles(e.on("change",()=>this._constructLegendElementsForWMSSublayers()),"wms-sublayers-watcher");const l=this.sublayerIds?.map(e=>i.findSublayerById(e))?.filter(r)??[],n=l.length?l:e.toArray();for(const r of n){const e=y(()=>[r.title,r.visible,r.legendEnabled],()=>this._constructLegendElementsForWMSSublayers());if(this.addHandles(e,"wms-sublayers-watcher"),!this.respectLayerVisibility||r.visible&&r.legendEnabled){const e=await this._generateSymbolTableElementForWMSSublayer(r,t);e?.infos.length&&s.unshift(e)}}return s}async _generateSymbolTableElementForWMSSublayer(e,t){if(!e.legendUrl&&e.sublayers){const i=(await this._generateLegendElementsForWMSSublayers(e.sublayers,t)).filter(e=>e);return{type:"symbol-table",title:e.title,infos:i}}return this._generateSymbolTableElementForLegendUrl(e,t)}async _generateSymbolTableElementForLegendUrl(e,t){let i=e.legendUrl;if(!i)return;const l={type:"symbol-table",title:e.title||e.name||String(e.id??""),infos:[]};t&&(i=g(i,t));let r=null;const n=e.layer?.opacity;try{r=(await s(i,{responseType:"image"})).data,r&&(r.style.opacity=n)}catch{}return l.infos.push({src:i,preview:r,opacity:n}),l}_getLegendLayers(e,t){const i=et&&et[e];return i?Promise.resolve(i):this._legendRequest(t).then(t=>{const i=t.layers;return et[e]=i,i})}_legendRequest(e){const t=this.layer;let i={f:"json",dynamicLayers:e};if(He(t)){const e=t.exportImageServiceParameters.rasterFunction;if(e&&(i.renderingRule=JSON.stringify(e.functionDefinition?.toJSON()||e.toJSON())),t.bandIds&&(i.bandIds=t.bandIds.join()),t.raster||t.viewId||t.customParameters){const{raster:e,viewId:s,customParameters:l}=t;i={raster:e,viewId:s,...i,...l}}}let l=t.url.replace(/(\/)+$/,"");if("version"in t&&+t.version>=10.01){const e=l.indexOf("?");e>-1?l=l.slice(0,e)+"/legend"+l.slice(e):l+="/legend"}else{const e=l.toLowerCase().indexOf("/rest/"),t=-1===e?l:l.slice(0,e)+l.slice(e+5);l=ye+"?soapUrl="+encodeURI(t)+"&returnbytes=true"}return s(l,{query:i}).then(e=>e.data)}async _constructLegendElementsForBuildingSceneLayer(){this._loading=!0,this.legendElements=[],this.removeHandles("sublayers-watcher");const e=this.layer;this.addHandles(y(()=>e.sublayers,()=>this._constructLegendElementsForBuildingSceneLayer()),"sublayers-watcher");try{this.legendElements=await this._generateLegendElementsForBuildingSublayers(e.sublayers,this.opacity)}catch(t){o.getLogger(this).warn("Request to server for legend has failed!",t)}finally{this._loading=!1,this.notifyChange("ready")}}async _generateLegendElementsForBuildingSublayers(e,t){let i=[];this.addHandles(e.on("change",()=>this._constructLegendElementsForBuildingSceneLayer()),"sublayers-watcher");const s=e.toArray();for(const l of s){const e=y(()=>["renderer"in l&&l.renderer,l.opacity,l.title,l.visible],()=>this._constructLegendElementsForBuildingSceneLayer());if(this.addHandles(e,"sublayers-watcher"),!this.respectLayerVisibility||l.visible){const e=null!=l?.opacity?l.opacity:null,s=null!=e?e*t:t;if("building-group"===l.type){const e={type:"symbol-table",title:l.title,infos:[]},t=await this._generateLegendElementsForBuildingSublayers(l.sublayers,s);e.infos.push(...t),i=[e,...i]}else if(l.renderer){i=[...await this._getRendererLegendElements(l.renderer,{title:l.title,opacity:s,sublayer:l}),...i]}}}return i.filter(e=>!!e&&(!("infos"in e)||!e.infos||e.infos.length>0))}async _constructLegendElementsForSublayers(){this._loading=!0,this.removeHandles("sublayers-watcher");const e=this.layer;if(!(Ne(e)||$e(e)||Pe(e))||this.hideLayersNotInCurrentView&&!await this._isLayerInCurrentView())return this.legendElements=[],this._loading=!1,void this.notifyChange("ready");this.addHandles(y(()=>e.sublayers,()=>this._constructLegendElementsForSublayers),"sublayers-watcher");try{this.legendElements=await this._generateLegendElementsForSublayers(e.sublayers,this.opacity)}catch(t){o.getLogger(this).warn("Request to server for legend has failed!",t)}finally{this._loading=!1,this.notifyChange("ready")}}async _generateLegendElementsForSublayers(e,t,i){const s=this.layer;let l=[];this.addHandles(e.on("change",()=>this._constructLegendElementsForSublayers()),"sublayers-watcher");let n=e.toArray();!i&&this.sublayerIds&&this.sublayerIds.length&&(n=Pe(s)?this.sublayerIds.map(e=>s.findSublayerForSubtypeCode(e)).filter(r):this.sublayerIds.map(e=>s.findSublayerById(e)).filter(r));for(const r of n){const e=y(()=>[r.renderer,r.opacity,r.title,r.visible,r.legendEnabled],()=>this._constructLegendElementsForSublayers());this.addHandles(e,"sublayers-watcher");const s=r.createQuery().where,n=!this.hideLayersNotInCurrentView||await this._isLayerInCurrentView(s),a=!this.respectLayerVisibility||r.visible&&r.legendEnabled&&this._isSublayerInScale(r);if(n&&a){const e=null!=r?.opacity?r.opacity:null,s=null!=e?e*t:t,n=!Qe(r)||r.originIdOf("renderer")>2&&!r.sublayers;if(r.renderer&&n){await r.load();l=[...await this._getRendererLegendElements(r.renderer,{title:r.title,opacity:s,sublayer:r}),...l]}else if(Qe(r)){const e=await this._generateSymbolTableElementForSublayer(r,s,i);e&&l.unshift(e)}}}return l.filter(e=>!!e&&(!("infos"in e)||!e.infos||e.infos.length>0))}async _generateSymbolTableElementForSublayer(e,t,i){if(!i){i=new Map;const t=this.layer,s=e.source;let l=null;if(!(!s||"map-layer"===s.type&&s.mapLayerId===e.id&&(!s.gdbVersion||s.gdbVersion===("gdbVersion"in t&&t.gdbVersion)))||e.originIdOf("renderer")>2||e.originIdOf("labelingInfo")>2||e.originIdOf("labelsVisible")>2){const e=new L({layer:this.layer});l=e.hasDynamicLayers?e.dynamicLayers:null,e.destroy()}const r=l||`${t.uid}-default`;(await this._getLegendLayers(r,l)).forEach(e=>i.set(e.layerId,e))}const s=i.get(e.id);if((!s||s?.subLayerIds&&s.defaultVisibility)&&e.sublayers){const s=await this._generateLegendElementsForSublayers(e.sublayers,t,i);return{type:"symbol-table",title:e.title,infos:s}}return this._generateSymbolTableElementForLegendLayer(s,e,t)}_generateSymbolTableElementForLegendLayer(e,t,i){if(!e?.legend||this.respectLayerVisibility&&!this._isLegendLayerInScale(e,t))return null;const s=t?.renderer;let l=t?.title||e.layerName;if(s&&(!t||t?.originIdOf("renderer")>2)){const e=t?.title||this._getRendererTitle(s,t);e&&(l&&"string"!=typeof e&&"title"in e&&(e.title=l),l=e)}const r={type:"symbol-table",title:l,legendType:e.legendType||null,infos:[]},n=t?this._sanitizeLegendForSublayer(e.legend.slice(),t):e.legend;return e.legendGroups&&e.legendGroups.length>0?e.legendGroups.forEach(s=>{const l={type:"symbol-table",title:s.heading,legendType:e.legendType||null,infos:this._generateSymbolTableElementInfosForLegendLayer(n.filter(e=>e.groupId===s.id),e.layerId,s.heading||r.title||t?.title,i)};l.infos?.length>0&&r.infos.push(l)}):r.infos=this._generateSymbolTableElementInfosForLegendLayer(n,e.layerId,r.title||t?.title,i),r.infos.length>0?r:null}_generateSymbolTableElementInfosForLegendLayer(e,t,s,l){return e.map(e=>{let r=e.url;if(e.imageData&&e.imageData.length>0)r=`data:image/png;base64,${e.imageData}`;else{if(r.startsWith("http"))return null;r=i(`${this.layer.url}/${t}/images/${r}`)}let n=e.label;return"<all other values>"===n&&(n="others"),{previewAriaLabel:n||s,label:n,src:r,opacity:l??this.opacity,width:e.width,height:e.height}}).filter(r)}_isSublayerInScale(e){const t=e.minScale||0,i=e.maxScale||0;return!(t>0&&t<this.scale||i>this.scale)}_isLegendLayerInScale(e,t){const i=t||this.layer;let s=null,l=null,r=!0;return!i.minScale&&0!==i.minScale||!i.maxScale&&0!==i.maxScale?(0===e.minScale&&i.tileInfo&&(s=i.tileInfo.lods[0].scale),0===e.maxScale&&i.tileInfo&&(l=i.tileInfo.lods[i.tileInfo.lods.length-1].scale)):(s=Math.min(i.minScale,e.minScale)||i.minScale||e.minScale,l=Math.max(i.maxScale,e.maxScale)),(s>0&&s<this.scale||l>this.scale)&&(r=!1),r}_sanitizeLegendForSublayer(e,t){if("version"in this.layer&&+this.layer.version<10.1||0===e.length)return e;const i=t.renderer,s=e.some(e=>e.values);let l=0,r=null;return s&&e.some((e,t)=>(e.values||(l=t,r=e,r.label||(r.label="others")),null!=r)),i?"unique-value"===i.type?r&&(e.splice(l,1),e.push(r)):"class-breaks"===i.type&&(r&&e.splice(l,1),i.legendOptions?.order||e.reverse(),r&&e.push(r)):r&&(e.splice(l,1),e.push(r)),e}async _getRendererLegendElements(e,t={}){if(!ke(e,this.view))return o.getLogger(this).warn(`Renderer of type '${e.type}' not supported!`),[];if(Ve(e))return this._constructPointCloudRendererLegendElements(e,t);if(je(e))return this._constructDotDensityRendererLegendElements(e);const i=await this._loadRenderer(e);return Oe(i)?this._constructPieChartRendererLegendElements(i):this._constructRendererLegendElements(i,t)}async _getLegendElementsForFeatureReduction(e){let t=null;return"binning"===e.type?t=e.renderer:"cluster"===e.type&&(t=this._getClusterRenderer(e)),t?this._getRendererLegendElements(t,{isFeatureReductionRenderer:!0}):[]}_getPointCloudRendererTitle(e){return(e.legendOptions?.title||e.field)??""}async _constructPointCloudRendererLegendElements(e,t={}){const i=t.title,s=[];let l=null,r=null;if(xe(e))l={type:"symbol-table",title:i||this._getPointCloudRendererTitle(e),infos:[]},e.colorClassBreakInfos.forEach(e=>{l.infos.unshift({label:e.label||e.minValue+" - "+e.maxValue,value:[e.minValue,e.maxValue],symbol:this._getAppliedCloneSymbol(be,e.color)})});else if(ze(e)){const t=e.stops;let s=null;if(t?.length&&(1===t.length&&(s=t[0].color),!s)){const e=t[0].value,i=t[t.length-1].value;if(null!=e&&null!=i){s=H(e+(i-e)/2,t)}}l={type:"symbol-table",title:null,infos:[{label:null,value:null,symbol:this._getAppliedCloneSymbol(be,s||be.color)}]};const n=q(e.stops??[])??[];r={type:"color-ramp",title:i||this._getPointCloudRendererTitle(e),infos:n,preview:M(n.map(e=>e.color))}}else Te(e)&&(l={type:"symbol-table",title:i||this._getPointCloudRendererTitle(e),infos:[]},e.colorUniqueValueInfos?.forEach(e=>{l.infos.push({label:e.label||e.values.join(", "),value:e.values.join(", "),symbol:this._getAppliedCloneSymbol(be,e.color)})}));return l?.infos.length&&s.push(l),r?.infos.length&&s.push(r),await this._generatePreviewsForLegendElements(s,{opacity:this.opacity,symbolConfig:{applyColorModulation:!!e.colorModulation}}),s}async _getElementInfoForDotDensity(e,t){const{color:i,label:s,valueExpressionTitle:l}=t,{backgroundColor:r,outline:n,dotSize:a}=e,o=this.cssEffectFilter,u=a+"-"+i+"-"+r+"-"+(n&&JSON.stringify(n.toJSON()))+"-"+o,c=this._dotDensityUrlCache,d=c.has(u)?c.get(u):P(e,i);c.set(u,d);const y={shape:{type:"image",x:0,y:0,width:d.width,height:d.height,src:d.src},fill:null,stroke:null,offset:[0,0]},h=k([[y]],[d.width,d.height],{cssEffectFilter:this.cssEffectFilter});return{opacity:1,src:d.src,preview:h,width:d.width,height:d.height,previewAriaLabel:s||l}}async _constructDotDensityRendererLegendElements(e){const t=e.calculateDotValue(this.view.scale),i=e.legendOptions?.unit,s={type:"symbol-table",title:{value:t&&Math.round(t),unit:i||""},infos:[]};for(const l of e.attributes){const t=await this._getElementInfoForDotDensity(e,l);t.label=l.label||l.valueExpressionTitle||l.field,s.infos.push(t)}return[s]}async _constructPieChartRendererLegendElements(e){const t=[];let i=null;const s=e.outline;e.attributes.forEach(e=>{const i=new j({color:e.color,outline:s}),l=e.label||e.valueExpressionTitle||e.field;t.push({label:l,symbol:i})});const l=t.length?[...t]:[];if(e.othersCategory?.color&&0!==e.othersCategory?.threshold){const l=new j({color:e.othersCategory.color,outline:s});i=e.othersCategory.label||"Other",t.push({label:i,symbol:l})}if(e.defaultColor?.a){const i=new j({color:e.defaultColor,outline:s});t.push({label:e.defaultLabel,symbol:i})}const r=await this._getVisualVariableLegendElements(e,this.layer)||[];if(t.length){r.unshift({type:"symbol-table",title:null,infos:t});const n=l.filter(e=>e.label!==i).map(e=>e.symbol.color).filter(Boolean),a=U(n,{holePercentage:e.holePercentage,backgroundColor:e.backgroundFillSymbol?.color,cssEffectFilter:this.cssEffectFilter,outline:s});r.unshift({type:"pie-chart-ramp",title:this._getRendererTitle(e,this.layer),infos:t,preview:a})}return await this._generatePreviewsForLegendElements(r,{opacity:this.layer.opacity,cssEffectFilter:this.cssEffectFilter}),r}async _getWhereClause(e,t,i){const s=await p(e,i),l=new Set,{field:r,field2:n,field3:a}=t;E(l,i,[r,n,a]),await F(l,i,null,t.valueExpression);const o=new Set(Array.from(l,e=>e.toLowerCase())),u=s?.fieldNames.map(e=>e.toLowerCase());return u?.some(e=>!o.has(e))?null:s}async _processDefinitionExpression(e,t){if(!("definitionExpression"in e))return;const i=e.definitionExpression;i&&this.respectLayerDefinitionExpression?this._layerDefinitionExpression!==i&&(this._layerDefinitionExpressionClause=await this._getWhereClause(i,t,e.fieldsIndex)):this._layerDefinitionExpressionClause=null,this._layerDefinitionExpression=i}async _processDisplayFilter(e,t){if(!("displayFilterInfo"in e))return;const i=e.displayFilterInfo?v(e.displayFilterInfo,this.view):null;return i?.where?this._layerDisplayFilter?.id!==i?.id&&(this._layerDisplayFilterClause=await this._getWhereClause(i.where,t,e.fieldsIndex)):this._layerDisplayFilterClause=null,this._layerDisplayFilter=i,i}async _constructRendererLegendElements(e,t={}){const{title:i,sublayer:s,isFeatureReductionRenderer:l}=t,r=s||this.layer,n=ie(e,"reference-size"),a=ie(e,"spike"),o=l&&"renderer"in r&&r.renderer?r.renderer:e;let u=null;Ie(o)&&(await this._processDefinitionExpression(r,o),u=await this._processDisplayFilter(r,o)),this._hasColorRamp=!1,this._hasOpacityRamp=!1,this._hasSizeRamp=!1,this._scaleDrivenSizeVariable=null;const c=await this._getVisualVariableLegendElements(e,r)||[],d={type:"symbol-table",title:i||this._getRendererTitle(e,r),infos:[]};let y=null,h=!1;const f=new Set;if(Se(e)&&!this._hasSizeRamp){const t=await se(e);d.infos.push({label:null,symbol:t})}else if(Je(e)){let t=i;const s=Ze(e)?"univariate-above-and-below-ramp":"univariate-color-size-ramp",l=c.findIndex(e=>"color-ramp"===e.type),r=-1!==l?c.splice(l,1)[0]:null,n=c.findIndex(e=>"size-ramp"===e.type),a=-1!==n?c.splice(n,1)[0]:null,o=[];r&&(t=r.title,o.push(r)),a&&(t=a.title,o.push(a)),o.length>0&&c.push({type:s,title:t,infos:o})}else if(Re(e)){const t=J(e);c.push({type:"heatmap-ramp",title:i||this._getRendererTitle(e,r),infos:t,preview:M(t.map(e=>e.color),{cssEffectFilter:this.cssEffectFilter})})}else if(Ie(e)){const t=e.authoringInfo;if("relationship"===t?.type){const{numClasses:i,field1:s,field2:l}=t,n=t.focus;if(i&&s&&l){const t=[s,l];let a=Z(n)||0;for(const e of t){const{field:t,normalizationField:i,label:s}=e,l=s||{field:this._getFieldAlias(t,r),normField:i&&this._getFieldAlias(i,r)},n=Ye.clone();n.angle=a,d.infos.push({label:l,symbol:n}),f.add(n),a+=90}const o=Q({focus:n,numClasses:i,infos:e.uniqueValueInfos??[]});c.unshift(o)}}else if(He(this.layer)||qe(this.layer)){const{uniqueValueInfos:t}=e;if(t)for(const e of t)e.symbol&&await this._checkClausesForUVR(o,e.value)&&d.infos.push({label:e.label||e.value,value:e.value,symbol:e.symbol})}else{const{field:t,field2:s,field3:l,fieldDelimiter:a,valueExpression:c,defaultSymbol:y}=e,f=!(!t&&!c||!s&&!l),m=u?u.title:null,p=[],{uniqueValueGroups:g}=e;if(g)for(const e of g){const i={type:"symbol-table",title:m||e.heading,infos:[]},{classes:u}=e;if(u)for(const e of u){const{symbol:u,values:d}=e;if(u){const y=[],h=[];for(const e of d??[]){const{value:i,value2:n,value3:o}=e,u=[],d=[];(t||c)&&(u.push(i),d.push(this._getDomainName(t,i,r)??le(i,re(r,t,this.view.timeZone)))),s&&(u.push(n),d.push(this._getDomainName(s,n,r)??le(n,re(r,s,this.view.timeZone)))),l&&(u.push(o),d.push(this._getDomainName(l,o,r)??le(o,re(r,l,this.view.timeZone)))),y.push(f?u.join(a||""):u[0]),h.push(d.join(" - "))}const m=y.join(", ");let p=e.label;if(!p){const e=h.filter(Boolean);p=e.length?e.join(", "):m}let g=u;"cim"===g.type&&n&&(g=g.clone(),z(g,{innerDotSize:.5*de,outerRingSize:de}));let b=!1;for(const e of y)if(b=await this._checkClausesForUVR(o,e),b)break;b&&i.infos.push({label:p,value:m,symbol:g})}}i.infos.length&&p.push(i)}if(p.length){const t=p[0];if(1===p.length&&"title"in t&&!t.title){const e=t.infos?.filter(Ke)??[];d.infos.push(...e)}else y&&(p.push({type:"symbol-table",infos:[{label:e.defaultLabel||"others",symbol:y}]}),h=!0),d.infos.push(...p);i||e.legendOptions?.title||e.valueExpressionTitle||(d.title=null)}}e.defaultSymbol&&!h&&(d.infos.push({label:e.defaultLabel||"others",symbol:e.defaultSymbol}),h=!0)}else if(Ce(e)){if(!n&&!a){y=this._isUnclassedRenderer(e);if(!y||!this._hasSizeRamp){const t=e.classBreakInfos.filter(({symbol:e})=>e),i="ascending-values"===e.legendOptions?.order;for(const{label:e,minValue:s,maxValue:l,symbol:n}of t){const t=e||(y?null:`${s} - ${l}`),a={previewAriaLabel:t||d.title||r.title,label:t,value:[s,l],symbol:n};i?d.infos.push(a):d.infos.unshift(a)}y&&(d.title=null),this._updateInfosForClassedSizeRenderer(e,d.infos)}e.defaultSymbol&&!y&&(d.infos.push({label:e.defaultLabel||"others",symbol:e.defaultSymbol}),h=!0)}}else if(Le(e))if(qe(this.layer)||We(this.layer)){const t=await this._constructTileImageryStretchRendererElements(e);Ge(t)?c.push(t):d.infos=t}else{const t=this.layer;let i,s;e.customStatistics?.length&&({min:i,max:s}=e.customStatistics[0]);let l=[],r=t.serviceRasterInfo;if(t.rasterFunction)try{r=await t.generateRasterInfo(t.rasterFunction)}catch{}const n=w(r.pixelType);if(1===r.bandCount){const l=t.bandIds?.[0]||0;i=null!=i?i:r.statistics?r.statistics[l].min:n[0],s=null!=s?s:r.statistics?r.statistics[l].max:n[1],i||s?c.push(await this._getStretchLegendElements(e,{min:i,max:s})):this._getServerSideLegend()}else if(1===t.bandIds?.length)i=null!=i?i:r.statistics?r.statistics[t.bandIds[0]].min:n[0],s=null!=s?s:r.statistics?r.statistics[t.bandIds[0]].max:n[1],i||s?c.push(await this._getStretchLegendElements(e,{min:i,max:s})):this._getServerSideLegend();else if(r.bandCount>=3){const{bandInfos:e}=r,{bandIds:i}=t;e.length>=r.bandCount?3===i?.length?(l=i.map(t=>e[t].name),d.infos=this._createSymbolTableElementMultiBand(l)):"lerc"===t.format?(l=[0,1,2].map(t=>e[t].name),d.infos=this._createSymbolTableElementMultiBand(l)):this._getServerSideLegend():"lerc"===t.format?(l=["band1","band2","band3"],d.infos=this._createSymbolTableElementMultiBand(l)):this._getServerSideLegend()}else this._getServerSideLegend()}else if(ve(e))e.colormapInfos.forEach(e=>{d.infos.push({label:e.label,value:e.value,symbol:this._getAppliedCloneSymbol(_e,e.color)})});else if(Fe(e)){let i=e.symbol;switch(t.geometryType){case"point":i="pointSymbol"in r?r.pointSymbol:null;break;case"polyline":i="lineSymbol"in r?r.lineSymbol:null;break;case"polygon":i="polygonSymbol"in r?r.polygonSymbol:null}const s=this._clusterSizeVariable&&this._getClusterSymbol()||!this._hasSizeRamp;e.symbol&&s&&d.infos.push({previewAriaLabel:e.label||d.title||r.title,label:e.label,symbol:i})}else if(we(e)){e.outputUnit&&(this.title="("+e.toJSON().outputUnit+")"),d.title=e.attributeField;const t=e.getClassBreakInfos();t?.length?t.forEach(e=>{d.infos.push({label:e.minValue+" - "+e.maxValue,symbol:e.symbol})}):d.infos.push({label:e.attributeField,symbol:e.getDefaultSymbol()})}else Ee(e)&&c.push(await this._getStretchLegendElements(e,{min:0,max:255}));const m=e.defaultSymbol;!m||h||Fe(e)||y&&!this._hasColorRamp&&!this._hasSizeRamp&&!this._hasOpacityRamp||c.push({type:"symbol-table",infos:[{label:e.defaultLabel||"others",symbol:m}]}),d.infos.length&&c.unshift(d);const p=null==t.opacity?this.opacity:t.opacity,g=this._isTallSymbol("visualVariables"in e?e.visualVariables:null),b=He(this.layer)||qe(this.layer);return await this._generatePreviewsForLegendElements(c,{opacity:p,symbolConfig:{isTall:g,isSquareFill:b},cssEffectFilter:this.cssEffectFilter},{arrowMarkerSymbols:f}),e=null,c}async _waitForLayerViewUpdate(e){await f(()=>!e.updating)}async _checkFeatureCountForExpression(e,t){const i=this.layerView;if(!(i&&"createQuery"in i&&"queryFeatureCount"in i))return!0;try{await this._waitForLayerViewUpdate(i);const s=i.createQuery();e&&(s.where=ne(s.where,e)),t&&(s.geometry=t);return await i.queryFeatureCount(s)>0}catch{return!0}}async _checkClausesForUVR(e,t){const i=Xe(e,t);if(!i)return!0;return(!!!(!this._layerDefinitionExpressionClause&&this._layerDefinitionExpression&&this.respectLayerDefinitionExpression||!this._layerDisplayFilterClause&&this._layerDisplayFilter?.where)||await this._checkFeatureCountForExpression(`${e.field} = ${t}`))&&(!this._layerDefinitionExpressionClause||this._layerDefinitionExpressionClause.testFeature(i))&&(!this._layerDisplayFilterClause||this._layerDisplayFilterClause.testFeature(i))}_getServerSideLegend(){setTimeout(()=>this.buildLegendElementsForTools(),0)}_getAllInfos(e){const t=e?.infos;return t?t.reduce((e,t)=>e.concat(this._getAllInfos(t)),[]):[e]}async _constructTileImageryStretchRendererElements(e){const t=this.layer,i=t.symbolizer.rasterInfo??t.raster.rasterInfo;let s,l;const r=e?.customStatistics?.length?e.customStatistics:i?.statistics;if(r)({min:s,max:l}=r[0]);else{const e=w(i.pixelType);s=e[0],l=e[1]}if(t.hasStandardTime()&&(s=t.getStandardTimeValue(s),l=t.getStandardTimeValue(l)),1===i.bandCount||1===t.bandIds?.length)return this._getStretchLegendElements(e,{min:s,max:l});const n=(t?.bandIds?.length?t.bandIds:Array.from(Array(Math.min(i.bandCount,3)).keys())).map(e=>i.bandInfos[e].name);return n.length<3?n.push(n[1]):n.length>3&&n.splice(3),this._createSymbolTableElementMultiBand(n)}async _getStretchLegendElements(e,t){const i=e.colorRamp?.toJSON(),s=W(i,t);return{type:"stretch-ramp",title:"",infos:s,preview:M(s.map(e=>e.color))}}_getClusterSymbol(){const e=this.layer,t="featureReduction"in e&&e.featureReduction,i=t&&"symbol"in t&&t.renderer;return i&&!0!==i?.authoringInfo?.isAutoGenerated?null:t&&"symbol"in t?t.symbol:null}async _getSizeLegendElement(e,t,i,s){return{type:"size-ramp",title:this._clusterSizeVariable?this._getClusterTitle(t):e,infos:await K(i,t,await ae(i),this.scale,this.view,s,this._clusterSizeVariable?this._getClusterSymbol():null)}}_createSymbolTableElementMultiBand(e){const t=[],i=["red","green","blue"];return e.forEach((e,s)=>{t.push({label:{colorName:i[s],bandName:e},src:oe[s],opacity:this.opacity??1})}),t}_updateInfosForClassedSizeRenderer(e,t){const i="class-breaks-size"===e.authoringInfo?.type,s=e.classBreakInfos.some(e=>N(e.symbol));if(i&&s){const i=X,s=Y,l=e.classBreakInfos.length,r=(i-s)/(l>1?l-1:l);t.forEach((e,t)=>{e.size=i-r*t})}}_isTallSymbol(e){let t=!1,i=!1;if(e)for(let s=0;s<e.length&&(!t||!i);s++){const l=e[s];"size"===l.type&&("height"===l.axis&&(t=!0),"width-and-depth"===l.axis&&(i=!0))}return t&&i}async _generatePreviewsForLegendElements(e,t,i){const s=[];for(const l of e)for(const e of l.infos??[])if("infos"in e&&e.infos&&s.push(this._generatePreviewsForLegendElements([e],t,i)),Ke(e)&&e.symbol&&!e.preview){let r=!0;if("cim"===e.symbol.type){const{minScale:t,maxScale:i}=e.symbol.data;(t&&t<this.scale||i&&i>this.scale)&&(r=!1)}r&&s.push(this._generateSymbolPreviewForInfo(e,{...t,clipBloomEffect:"theme"in l&&"spike"===l.theme,cssEffectFilter:i?.arrowMarkerSymbols?.has(e.symbol)?null:t.cssEffectFilter},i?{applyScaleDrivenSize:!i.arrowMarkerSymbols?.has(e.symbol)}:void 0))}await Promise.all(s)}async _getSize(e,t){let i=null==e.size&&this._hasSizeRamp?m(22):e.size;if(this._scaleDrivenSizeVariable&&t?.applyScaleDrivenSize){const{getSize:t}=await import("../../../renderers/visualVariables/support/visualVariableUtils.js");i=t(this._scaleDrivenSizeVariable,null,{view:this.view.type,scale:this.scale,shape:"simple-marker"===e.symbol.type?e.symbol.style:null})}return i}_getPreviewCIMOptions(e){return{style:"legend",cimOptions:{allowScalingUp:this._hasSizeRamp||!(!this._scaleDrivenSizeVariable||!e?.applyScaleDrivenSize),viewParams:this.isScaleDriven?{viewingMode:"2d"===this.view?.type?"map":this.view?.viewingMode,scale:this.view?.scale}:null}}}async _generateSymbolPreviewForInfo(e,t={},i){const{symbol:s}=e;try{if(t.size=await this._getSize(e,i),t.scale=!1,"cim"===s.type){const e=this._getPreviewCIMOptions(i);t={...t,...e}}e.preview=await A(s,t)}catch{e.preview=null,o.getLogger(this).warn(`Generating symbol preview failed for symbol type: ${s?.type}`)}}_getClusterRenderer(e){this._clusterSizeVariable=null;const t="renderer"in this.layer?this.layer.renderer:null,i=e.renderer?.clone()||t?.clone(),s=$(e,this.layerView,this.view);if(s&&null!=i&&"visualVariables"in i){const t=i.visualVariables?.some(e=>"size"===e.type&&"outline"!==e.target&&!pe.test(e.valueExpression));if(!t){if("clusterMinSize"in e&&"clusterMaxSize"in e){const{clusterMinSize:t,clusterMaxSize:i}=e;s.legendOptions=new x({showLegend:t!==i})}const t=i.visualVariables||[];i.visualVariables=t.concat([s]),this._clusterSizeVariable=s}}return i}async _loadRenderer(e){if(tt.has(e))return tt.get(e);const t=[],i=e.clone(),s=await ae(i);if(Ce(i)||Ie(i)){const e=(i.classBreakInfos||i.uniqueValueInfos).map(e=>this._fetchSymbol(e.symbol,s).then(t=>{e.symbol=t}).catch(()=>{e.symbol=null}));Array.prototype.push.apply(t,e)}return t.push(this._fetchSymbol(i.symbol||i.defaultSymbol,i.defaultSymbol?null:s).then(e=>{this._applySymbolToRenderer(i,e,Fe(i))}).catch(()=>{this._applySymbolToRenderer(i,null,Fe(i))})),await Promise.allSettled(t),tt.set(e,i),i}_applySymbolToRenderer(e,t,i){i?e.symbol=t:e.defaultSymbol=t}async _fetchSymbol(e,t){if(!e)throw new Error;if("web-style"===e.type){const i=this._webStyleSymbolCache;try{const s=await e.fetchSymbol({cache:i});return this._getAppliedCloneSymbol(s,t)}catch{throw o.getLogger(this).warn("Fetching web-style failed!"),new Error}}return this._getAppliedCloneSymbol(e,t)}_getAppliedCloneSymbol(e,i){if(!e||!i)return e;const s=e.clone(),l=i&&i.toRgba();return s.type.includes("3d")?this._applyColorTo3dSymbol(s,l):"cim"===s.type?O(s,i):s.color&&(s.color=new t(l||s.color)),s}_applyColorTo3dSymbol(e,i){i&&e.symbolLayers.forEach(e=>{e&&(e.material||(e.material={}),e.material.color=new t(i))})}async _getVisualVariableLegendElements(e,t){if(!("visualVariables"in e)||"vector-field"===e.type)return null;const i=e.visualVariables??[],s=[],l=[],n=[],a=ie(e,"reference-size")??ie(e,"spike");let o;const c=this._clusterSizeVariable;if(2===a?.sizeStops?.length&&(Ce(e)||Ie(e))){const[e,t]=a.sizeStops,i=c?c.minDataValue:e.value,s=c?c.maxDataValue:t.value;o=new D({field:a.field??void 0,normalizationField:a.normalizationField,minSize:u(e.size,10,100),maxSize:u(t.size,50,150),minDataValue:i,maxDataValue:s}),l.push(o)}for(const r of i)if("color"===r.type)s.push(r);else if("size"===r.type){if("cluster_count"===r.field&&o)continue;l.push(r)}else"opacity"===r.type&&n.push(r);const d=[...s,...l,...n];let y,h;if(0===s.length&&Ce(e)&&e.classBreakInfos&&1===e.classBreakInfos.length){const t=e.classBreakInfos[0];y=t&&t.symbol}if(0===s.length&&Fe(e)&&(y=e.symbol),y)if(y.type.includes("3d")){const e=y.symbolLayers.at(0);"water"===e.type?null!=e.color&&(h=e.color):null!=e.material?.color&&(h=e.material.color)}else y.url||(h=y.color);const f=this.cssEffectFilter;return(await Promise.all(d.map(async i=>{if(!1!==i.legendOptions?.showLegend){const s=Se(e)?i.field:this._getRampTitle(i,t);let l=null;const r=ue(t,i,this.view.timeZone);if("color"===i.type){const e=await G(i,null,r)??[];l={type:"color-ramp",title:s,infos:e,preview:M(e.map(e=>e.color),{cssEffectFilter:f})},this._hasColorRamp||(this._hasColorRamp=e.length>0)}else if("size"===i.type&&"outline"!==i.target)pe.test(i.valueExpression)?this._clusterSizeVariable||(this._scaleDrivenSizeVariable=i):(l=await this._getSizeLegendElement(s,i,e,r),o===i&&"spike"===a?.theme&&(l.theme=a.theme),this._hasSizeRamp||(this._hasSizeRamp=!(null==l.infos||!l.infos.length)));else if("opacity"===i.type){const e=await G(i,h,r)??[];l={type:"opacity-ramp",title:s,infos:e,preview:M(e.map(e=>e.color),{cssEffectFilter:f})},this._hasOpacityRamp||(this._hasOpacityRamp=e.length>0)}return l?.infos?l:null}}))).filter(r)}_getDomainName(e,t,i){if(e&&"function"!=typeof e){const s="getField"in i&&i.getField?.(e),l=s&&"getFieldDomain"in i&&i.getFieldDomain?i.getFieldDomain(s.name,{excludeImpliedDomains:has("esri-widget-legacy-field-domain-calculation")}):null;return"coded-value"===l?.type?l.getName(t):null}return null}_getClusterTitle(e){const t=this.layer,i=e.field;if("featureReduction"in t&&"cluster"===t.featureReduction?.type){const e=t.featureReduction,s="popupTemplate"in e&&e.popupTemplate,l=s&&s.fieldInfos;if(l)for(const t of l)if(t.fieldName===i)return"cluster_count"===i?t.label||{showCount:!0}:t.label}return{showCount:!0}}_getRampTitle(e,t){let i=e.field,s=e.normalizationField,l=!1,r=!1,n=!1,a=null;i="function"==typeof i?null:i,s="function"==typeof s?null:s;const o=e.legendOptions?.title;if(null!=o)a=o;else if(e.valueExpressionTitle)a=e.valueExpressionTitle;else{if("renderer"in t&&t.renderer&&"authoringInfo"in t.renderer&&t.renderer.authoringInfo?.visualVariables){const e=t.renderer.authoringInfo.visualVariables;for(let t=0;t<e.length;t++){const i=e[t];if("color"===i.type){if("ratio"===i.style){l=!0;break}if("percent"===i.style){r=!0;break}if("percent-of-total"===i.style){n=!0;break}}}}a={field:i&&this._getFieldAlias(i,t),normField:s&&this._getFieldAlias(s,t),ratio:l,ratioPercent:r,ratioPercentTotal:n}}return a}_getRendererTitle(e,t){const i=e;if(i.legendOptions?.title)return i.legendOptions.title;if(i.valueExpressionTitle)return i.valueExpressionTitle;let s=i.field,l=null,r=null;if(Ce(i)&&(l=i.normalizationField,r="percent-of-total"===i.normalizationType),s="function"==typeof s?null:s,l="function"==typeof l?null:l,Ie(i)){const{field2:e,field3:l,fieldDelimiter:r}=i;let n=s&&this._getFieldAlias(s,t);return e&&(n=`<${n}>${r}<${this._getFieldAlias(e,t)}>`,l&&(n=`${n}${r}<${this._getFieldAlias(l,t)}>`)),n}let n=null;return(s||l)&&(n={field:s&&this._getFieldAlias(s,t),normField:l&&this._getFieldAlias(l,t),normByPct:r}),n}_getFieldAlias(e,t){const i="featureReduction"in t&&t.featureReduction;if(I(t)&&!i)return t.getFieldAlias(e)||e;const s="popupTemplate"in t?t.popupTemplate:null,l=s?.fieldInfos;let r=l?.find(t=>e===t.fieldName),n=null;"getField"in t&&t.getField?n=t.getField(e):"fieldsIndex"in t&&t.fieldsIndex&&(n=t.fieldsIndex.get(e));let a=null;i&&(r??="popupTemplate"in i?i.popupTemplate?.fieldInfos?.find(t=>e?.toLowerCase()===t.fieldName?.toLowerCase()):void 0,"fields"in i&&i.fields&&(a=i.fields.find(t=>t.name?.toLowerCase()===e?.toLowerCase())));const o=r||n||a;let u=null;return o&&(u=r?.label||n?.alias||a?.alias||"name"in o&&o.name||"fieldName"in o&&o.fieldName||null),u}_isUnclassedRenderer(e){const t=e.visualVariables;let i=!1;return Ce(e)&&e.classBreakInfos&&1===e.classBreakInfos.length&&t&&(i=e.field?t.some(t=>!(!t||e.field!==t.field||(e.normalizationField||t.normalizationField)&&e.normalizationField!==t.normalizationField)):!!t.length),i}};e([b()],it.prototype,"_loading",void 0),e([b()],it.prototype,"children",void 0),e([b({readOnly:!0})],it.prototype,"cssEffectFilter",null),e([b()],it.prototype,"layerView",void 0),e([b()],it.prototype,"layer",void 0),e([b()],it.prototype,"legendElements",void 0),e([b({readOnly:!0})],it.prototype,"loading",null),e([b({readOnly:!0})],it.prototype,"opacity",null),e([b()],it.prototype,"parent",void 0),e([b({readOnly:!0,dependsOn:[]})],it.prototype,"ready",null),e([b()],it.prototype,"hideLayersNotInCurrentView",void 0),e([b()],it.prototype,"keepCacheOnDestroy",void 0),e([b()],it.prototype,"respectLayerDefinitionExpression",void 0),e([b()],it.prototype,"respectLayerVisibility",void 0),e([b({readOnly:!0})],it.prototype,"scale",null),e([b()],it.prototype,"sublayerIds",void 0),e([b({readOnly:!0})],it.prototype,"isScaleDriven",null),e([b()],it.prototype,"title",void 0),e([b({readOnly:!0,dependsOn:["ready"],value:0})],it.prototype,"version",null),e([b()],it.prototype,"view",void 0),it=e([_("esri.widgets.Legend.support.ActiveLayerInfo")],it);export{it as default};
package/widgets/Legend.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import{deprecateWidget as t}from"../core/deprecate.js";import i from"../core/Logger.js";import{on as s,watch as r,initial as n}from"../core/reactiveUtils.js";import{property as o,subclass as l}from"../core/accessorSupport/decorators.js";import a from"./Widget.js";import d from"./Legend/LegendViewModel.js";import y from"./Legend/styles/card/CardView.js";import h from"./Legend/styles/classic/ClassicView.js";import{globalCss as p}from"./support/globalCss.js";import{tsx as c,messageBundle as g}from"./support/widget.js";const v={base:"esri-legend"};let L=class extends a{constructor(e,s){super(e,s),this.headingLevel=3,this.messages=null,this.viewModel=new d,this.style=new h,t(i.getLogger(this),"Legend","arcgis-legend",{version:"4.34"})}initialize(){this.addHandles([s(()=>this.view,"resize",()=>this.scheduleRender()),s(()=>this.activeLayerInfos,"change",()=>this._refreshActiveLayerInfos(this.activeLayerInfos)),r(()=>this.headingLevel,e=>{const{style:t}=this;t&&(t.headingLevel=e)}),r(()=>this.style,(e,t)=>{t&&e!==t&&t.destroy(),e&&(e.activeLayerInfos=this.activeLayerInfos,"card"===e.type&&(e.view=this.view),e.headingLevel=this.headingLevel)},n)])}destroy(){this.style?.destroy()}get activeLayerInfos(){return this.viewModel.activeLayerInfos}set activeLayerInfos(e){this.viewModel.activeLayerInfos=e}get basemapLegendVisible(){return this.viewModel.basemapLegendVisible}set basemapLegendVisible(e){this.viewModel.basemapLegendVisible=e}get groundLegendVisible(){return this.viewModel.groundLegendVisible}set groundLegendVisible(e){this.viewModel.groundLegendVisible=e}get hideLayersNotInCurrentView(){return this.viewModel.hideLayersNotInCurrentView}set hideLayersNotInCurrentView(e){this.viewModel.hideLayersNotInCurrentView=e}get keepCacheOnDestroy(){return this.viewModel.keepCacheOnDestroy}set keepCacheOnDestroy(e){this.viewModel.keepCacheOnDestroy=e}get respectLayerDefinitionExpression(){return this.viewModel.respectLayerDefinitionExpression}set respectLayerDefinitionExpression(e){this.viewModel.respectLayerDefinitionExpression=e}get respectLayerVisibility(){return this.viewModel.respectLayerVisibility}set respectLayerVisibility(e){this.viewModel.respectLayerVisibility=e}get icon(){return"legend"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get layerInfos(){return this.viewModel.layerInfos}set layerInfos(e){this.viewModel.layerInfos=e}get style(){return this._get("style")}set style(e){const t=this._get("style");if(e!==t&&t?.destroy(),!(e instanceof y||e instanceof h))if("string"==typeof e)e="card"===e?new y:new h;else if(e&&"string"==typeof e.type){const t={...e};delete t.type,e="card"===e.type?new y(t):new h(t)}else e=new h;this._set("style",e)}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}render(){return c("div",{class:this.classes(v.base,p.widget,this.style instanceof h?p.panel:null)},this.style.render())}_refreshActiveLayerInfos(e){e.forEach(e=>{this.removeHandles(`version_${e.layer.uid}`),this._renderOnActiveLayerInfoChange(e)}),this.scheduleRender()}_renderOnActiveLayerInfoChange(e){const t=r(()=>e.version,()=>this.scheduleRender());this.addHandles(t,`version_${e.layer.uid}`);const i=s(()=>e.children,"change",()=>e.children.forEach(e=>this._renderOnActiveLayerInfoChange(e)),n);this.addHandles(i,`version_${e.layer.uid}`),e.children.forEach(e=>this._renderOnActiveLayerInfoChange(e))}};e([o()],L.prototype,"activeLayerInfos",null),e([o()],L.prototype,"basemapLegendVisible",null),e([o()],L.prototype,"groundLegendVisible",null),e([o()],L.prototype,"headingLevel",void 0),e([o()],L.prototype,"hideLayersNotInCurrentView",null),e([o()],L.prototype,"keepCacheOnDestroy",null),e([o()],L.prototype,"respectLayerDefinitionExpression",null),e([o()],L.prototype,"respectLayerVisibility",null),e([o()],L.prototype,"icon",null),e([o()],L.prototype,"label",null),e([o()],L.prototype,"layerInfos",null),e([o(),g("esri/widgets/Legend/t9n/Legend")],L.prototype,"messages",void 0),e([o()],L.prototype,"style",null),e([o()],L.prototype,"view",null),e([o()],L.prototype,"viewModel",void 0),L=e([l("esri.widgets.Legend")],L);const f=L;export{f as default};
5
+ import{__decorate as e}from"tslib";import t from"../core/Collection.js";import{deprecateWidget as i}from"../core/deprecate.js";import s from"../core/Logger.js";import{on as r,watch as o,initial as n}from"../core/reactiveUtils.js";import{property as l,subclass as a}from"../core/accessorSupport/decorators.js";import d from"./Widget.js";import y from"./Legend/LegendViewModel.js";import p from"./Legend/styles/card/CardView.js";import h from"./Legend/styles/classic/ClassicView.js";import c from"./Legend/support/ActiveLayerInfo.js";import{globalCss as g}from"./support/globalCss.js";import{tsx as v,messageBundle as L}from"./support/widget.js";const f={base:"esri-legend"};let u=class extends d{constructor(e,t){super(e,t),this.headingLevel=3,this.messages=null,this.viewModel=new y,this.style=new h,i(s.getLogger(this),"Legend","arcgis-legend",{version:"4.34"})}initialize(){this.addHandles([r(()=>this.view,"resize",()=>this.scheduleRender()),r(()=>this.activeLayerInfos,"change",()=>this._refreshActiveLayerInfos(this.activeLayerInfos)),o(()=>this.headingLevel,e=>{const{style:t}=this;t&&(t.headingLevel=e)}),o(()=>this.style,(e,t)=>{t&&e!==t&&t.destroy(),e&&(e.activeLayerInfos=this.activeLayerInfos,"card"===e.type&&(e.view=this.view),e.headingLevel=this.headingLevel)},n)])}destroy(){this.style?.destroy()}get activeLayerInfos(){return this.viewModel.activeLayerInfos}set activeLayerInfos(e){this.viewModel.activeLayerInfos=e}get basemapLegendVisible(){return this.viewModel.basemapLegendVisible}set basemapLegendVisible(e){this.viewModel.basemapLegendVisible=e}get groundLegendVisible(){return this.viewModel.groundLegendVisible}set groundLegendVisible(e){this.viewModel.groundLegendVisible=e}get hideLayersNotInCurrentView(){return this.viewModel.hideLayersNotInCurrentView}set hideLayersNotInCurrentView(e){this.viewModel.hideLayersNotInCurrentView=e}get keepCacheOnDestroy(){return this.viewModel.keepCacheOnDestroy}set keepCacheOnDestroy(e){this.viewModel.keepCacheOnDestroy=e}get respectLayerDefinitionExpression(){return this.viewModel.respectLayerDefinitionExpression}set respectLayerDefinitionExpression(e){this.viewModel.respectLayerDefinitionExpression=e}get respectLayerVisibility(){return this.viewModel.respectLayerVisibility}set respectLayerVisibility(e){this.viewModel.respectLayerVisibility=e}get icon(){return"legend"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get layerInfos(){return this.viewModel.layerInfos}set layerInfos(e){this.viewModel.layerInfos=e}get style(){return this._get("style")}set style(e){const t=this._get("style");if(e!==t&&t?.destroy(),!(e instanceof p||e instanceof h))if("string"==typeof e)e="card"===e?new p:new h;else if(e&&"string"==typeof e.type){const t={...e};delete t.type,e="card"===e.type?new p(t):new h(t)}else e=new h;this._set("style",e)}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}render(){return v("div",{class:this.classes(f.base,g.widget,this.style instanceof h?g.panel:null)},this.style.render())}_refreshActiveLayerInfos(e){e.forEach(e=>{this.removeHandles(`version_${e.layer.uid}`),this._renderOnActiveLayerInfoChange(e)}),this.scheduleRender()}_renderOnActiveLayerInfoChange(e){const t=o(()=>e.version,()=>this.scheduleRender());this.addHandles(t,`version_${e.layer.uid}`);const i=r(()=>e.children,"change",()=>e.children.forEach(e=>this._renderOnActiveLayerInfoChange(e)),n);this.addHandles(i,`version_${e.layer.uid}`),e.children.forEach(e=>this._renderOnActiveLayerInfoChange(e))}};e([l({type:t.ofType(c)})],u.prototype,"activeLayerInfos",null),e([l()],u.prototype,"basemapLegendVisible",null),e([l()],u.prototype,"groundLegendVisible",null),e([l()],u.prototype,"headingLevel",void 0),e([l()],u.prototype,"hideLayersNotInCurrentView",null),e([l()],u.prototype,"keepCacheOnDestroy",null),e([l()],u.prototype,"respectLayerDefinitionExpression",null),e([l()],u.prototype,"respectLayerVisibility",null),e([l()],u.prototype,"icon",null),e([l()],u.prototype,"label",null),e([l()],u.prototype,"layerInfos",null),e([l(),L("esri/widgets/Legend/t9n/Legend")],u.prototype,"messages",void 0),e([l()],u.prototype,"style",null),e([l()],u.prototype,"view",null),e([l({type:y})],u.prototype,"viewModel",void 0),u=e([a("esri.widgets.Legend")],u);const w=u;export{w 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/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import{deprecateWidget as t}from"../core/deprecate.js";import"../core/has.js";import i from"../core/Logger.js";import{ignoreAbortErrors as s}from"../core/promiseUtils.js";import{property as n,subclass as o}from"../core/accessorSupport/decorators.js";import r from"./Widget.js";import l from"./LineOfSight/LineOfSightViewModel.js";import{loadCalciteComponents as a}from"./support/componentsUtils.js";import{globalCss as d}from"./support/globalCss.js";import{messageBundle as u,tsx as h}from"./support/widget.js";const p="esri-line-of-sight",c={base:p,actions:`${p}__actions`,container:`${p}__container`,error:`${p}__error`,hint:`${p}__hint`,hintText:`${p}__hint-text`,newAnalysisButton:`${p}__new-analysis-button`},g={newAnalysisButton:`${p}__new-button`,doneButton:`${p}__done-button`};let _=class extends r{constructor(e,n){super(e,n),this.messages=null,this.viewModel=new l({isDefaultViewModel:!0}),this._onNewAnalysis=()=>{s(this.viewModel.start())},this._onDone=()=>{this.viewModel.stop()},this._onContinue=()=>{this.viewModel.continue()},t(i.getLogger(this),"Line Of Sight","arcgis-line-of-sight",{version:"4.33"})}loadDependencies(){return a({button:()=>import("@esri/calcite-components/dist/components/calcite-button")})}get active(){return this.viewModel.active}get analysis(){return this.viewModel.analysis}set analysis(e){this.viewModel.analysis=e}get icon(){return"line-of-sight"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get visible(){return this.viewModel.visible}set visible(e){this.viewModel.visible=e}render(){return h("div",{class:this.classes(c.base,d.widget,d.panel),role:"presentation"},this._renderContainerNode())}_renderContainerNode(){if(!this.visible)return null;if(!this.viewModel.supported)return this._renderUnsupportedMessage();let e=null;const t=[this._renderNewAnalysisButton()];return"creating"===this.viewModel.state?(e=this._renderHint(),t.unshift(this._renderDoneButton())):"created"===this.viewModel.state&&this.viewModel.targets.length>0&&t.unshift(this._renderContinueButton()),h("div",{class:c.container},e,h("div",{class:c.actions},t))}_renderUnsupportedMessage(){return h("div",{class:c.error,key:"esri-line-of-sight__unsupported"},h("p",null,this.messages.unsupported))}_renderHint(){return h("div",{class:c.hint,key:"esri-line-of-sight__hint"},h("p",{class:c.hintText},this.messages.hint))}_renderNewAnalysisButton(){return this._renderButton({className:c.newAnalysisButton,id:g.newAnalysisButton,label:this.messages.newAnalysis,onClick:this._onNewAnalysis,primary:!0})}_renderDoneButton(){return this._renderButton({id:g.doneButton,label:this.messages.done,onClick:this._onDone,primary:!1})}_renderContinueButton(){return this._renderButton({id:g.newAnalysisButton,label:this.messages.continueAnalysis,onClick:this._onContinue,primary:!1})}_renderButton({className:e,id:t,label:i,onClick:s,primary:n}){const o="disabled"===this.viewModel.state;return h("calcite-button",{appearance:n?"solid":"outline-fill",class:e,"data-id":t,disabled:o,key:t,onclick:s},i)}get test(){}};e([n()],_.prototype,"active",null),e([n({nonNullable:!0})],_.prototype,"analysis",null),e([n()],_.prototype,"icon",null),e([n()],_.prototype,"label",null),e([n(),u("esri/widgets/LineOfSight/t9n/LineOfSight")],_.prototype,"messages",void 0),e([n()],_.prototype,"view",null),e([n({type:l})],_.prototype,"viewModel",void 0),e([n()],_.prototype,"visible",null),_=e([o("esri.widgets.LineOfSight")],_);const m=_;export{m as default};
5
+ import{__decorate as e}from"tslib";import t from"../analysis/LineOfSightAnalysis.js";import{deprecateWidget as i}from"../core/deprecate.js";import"../core/has.js";import s from"../core/Logger.js";import{ignoreAbortErrors as n}from"../core/promiseUtils.js";import{property as o,subclass as r}from"../core/accessorSupport/decorators.js";import l from"./Widget.js";import a from"./LineOfSight/LineOfSightViewModel.js";import{loadCalciteComponents as d}from"./support/componentsUtils.js";import{globalCss as u}from"./support/globalCss.js";import{messageBundle as p,tsx as h}from"./support/widget.js";const c="esri-line-of-sight",g={base:c,actions:`${c}__actions`,container:`${c}__container`,error:`${c}__error`,hint:`${c}__hint`,hintText:`${c}__hint-text`,newAnalysisButton:`${c}__new-analysis-button`},m={newAnalysisButton:`${c}__new-button`,doneButton:`${c}__done-button`};let _=class extends l{constructor(e,t){super(e,t),this.messages=null,this.viewModel=new a({isDefaultViewModel:!0}),this._onNewAnalysis=()=>{n(this.viewModel.start())},this._onDone=()=>{this.viewModel.stop()},this._onContinue=()=>{this.viewModel.continue()},i(s.getLogger(this),"Line Of Sight","arcgis-line-of-sight",{version:"4.33"})}loadDependencies(){return d({button:()=>import("@esri/calcite-components/dist/components/calcite-button")})}get active(){return this.viewModel.active}get analysis(){return this.viewModel.analysis}set analysis(e){this.viewModel.analysis=e}get icon(){return"line-of-sight"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get visible(){return this.viewModel.visible}set visible(e){this.viewModel.visible=e}render(){return h("div",{class:this.classes(g.base,u.widget,u.panel),role:"presentation"},this._renderContainerNode())}_renderContainerNode(){if(!this.visible)return null;if(!this.viewModel.supported)return this._renderUnsupportedMessage();let e=null;const t=[this._renderNewAnalysisButton()];return"creating"===this.viewModel.state?(e=this._renderHint(),t.unshift(this._renderDoneButton())):"created"===this.viewModel.state&&this.viewModel.targets.length>0&&t.unshift(this._renderContinueButton()),h("div",{class:g.container},e,h("div",{class:g.actions},t))}_renderUnsupportedMessage(){return h("div",{class:g.error,key:"esri-line-of-sight__unsupported"},h("p",null,this.messages.unsupported))}_renderHint(){return h("div",{class:g.hint,key:"esri-line-of-sight__hint"},h("p",{class:g.hintText},this.messages.hint))}_renderNewAnalysisButton(){return this._renderButton({className:g.newAnalysisButton,id:m.newAnalysisButton,label:this.messages.newAnalysis,onClick:this._onNewAnalysis,primary:!0})}_renderDoneButton(){return this._renderButton({id:m.doneButton,label:this.messages.done,onClick:this._onDone,primary:!1})}_renderContinueButton(){return this._renderButton({id:m.newAnalysisButton,label:this.messages.continueAnalysis,onClick:this._onContinue,primary:!1})}_renderButton({className:e,id:t,label:i,onClick:s,primary:n}){const o="disabled"===this.viewModel.state;return h("calcite-button",{appearance:n?"solid":"outline-fill",class:e,"data-id":t,disabled:o,key:t,onclick:s},i)}get test(){}};e([o()],_.prototype,"active",null),e([o({type:t,nonNullable:!0})],_.prototype,"analysis",null),e([o()],_.prototype,"icon",null),e([o()],_.prototype,"label",null),e([o(),p("esri/widgets/LineOfSight/t9n/LineOfSight")],_.prototype,"messages",void 0),e([o()],_.prototype,"view",null),e([o({type:a})],_.prototype,"viewModel",void 0),e([o()],_.prototype,"visible",null),_=e([r("esri.widgets.LineOfSight")],_);const w=_;export{w as default};
package/widgets/Locate.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import{deprecateWidget as o}from"../core/deprecate.js";import t from"../core/Logger.js";import{property as i,subclass as s}from"../core/accessorSupport/decorators.js";import r from"./Widget.js";import l from"./Locate/LocateViewModel.js";import{loadCalciteComponents as n}from"./support/componentsUtils.js";import{globalCss as a}from"./support/globalCss.js";import{messageBundle as c,vmEvent as p,tsx as d}from"./support/widget.js";const g={base:"esri-locate"};let m=class extends r{constructor(e,i){super(e,i),this.messages=null,this.messagesCommon=null,this.viewModel=new l,this._locate=()=>{const{viewModel:e}=this;"locating"===e.state?e.cancelLocate():e.locate().catch(()=>{})},o(t.getLogger(this),"Locate","arcgis-locate",{version:"4.32"})}loadDependencies(){return n({button:()=>import("@esri/calcite-components/dist/components/calcite-button"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip")})}get geolocationOptions(){return this.viewModel.geolocationOptions}set geolocationOptions(e){this.viewModel.geolocationOptions=e}get goToLocationEnabled(){return this.viewModel.goToLocationEnabled}set goToLocationEnabled(e){this.viewModel.goToLocationEnabled=e}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(e){this.viewModel.goToOverride=e}get graphic(){return this.viewModel.graphic}set graphic(e){this.viewModel.graphic=e}get icon(){return"gps-off"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get popupEnabled(){return this.viewModel.popupEnabled}set popupEnabled(e){this.viewModel.popupEnabled=e}get scale(){return this.viewModel.scale}set scale(e){this.viewModel.scale=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}cancelLocate(){this.viewModel.cancelLocate()}locate(){return this.viewModel.locate()}render(){const{viewModel:e,icon:o}=this,{state:t}=e,i="locating"===t,s=i?this.messagesCommon.cancel:this.messages.title,r="feature-unsupported"===t,l=this._localizeError(this.viewModel?.error);return d("div",{class:this.classes(g.base,a.widget)},!r&&d("calcite-button",{class:a.widgetButton,disabled:"disabled"===t,iconStart:i?void 0:o,kind:"neutral",label:s,onclick:this._locate,title:s},i?d("calcite-loader",{inline:!0,label:""}):null),l?d("calcite-tooltip",{open:!0,overlayPositioning:"fixed",placement:this._getPlacement(),referenceElement:this.container},l):null)}_getPlacement(){const{container:e,view:o}=this,t=e&&o?o.ui.getPosition(e):null;if(!t||"manual"===t)return"auto";const[i,s]=t.split("-");return`${"right"===s?"left":"right"}-${"bottom"===i?"end":"start"}`}_localizeError(e){return e instanceof GeolocationPositionError?e.code===GeolocationPositionError.PERMISSION_DENIED?this.messages?.permissionError:e.code===GeolocationPositionError.TIMEOUT?this.messages?.timeoutError:this.messages?.positionUnavailable:e instanceof Error?e.message:void 0}};e([i()],m.prototype,"geolocationOptions",null),e([i()],m.prototype,"goToLocationEnabled",null),e([i()],m.prototype,"goToOverride",null),e([i()],m.prototype,"graphic",null),e([i()],m.prototype,"icon",null),e([i()],m.prototype,"label",null),e([i(),c("esri/widgets/Locate/t9n/Locate")],m.prototype,"messages",void 0),e([i(),c("esri/t9n/common")],m.prototype,"messagesCommon",void 0),e([i()],m.prototype,"popupEnabled",null),e([i()],m.prototype,"scale",null),e([i()],m.prototype,"view",null),e([i({type:l}),p(["locate","locate-error"])],m.prototype,"viewModel",void 0),m=e([s("esri.widgets.Locate")],m);const u=m;export{u as default};
5
+ import{__decorate as e}from"tslib";import o from"../Graphic.js";import{deprecateWidget as t}from"../core/deprecate.js";import i from"../core/Logger.js";import{property as s,subclass as r}from"../core/accessorSupport/decorators.js";import l from"./Widget.js";import n from"./Locate/LocateViewModel.js";import{loadCalciteComponents as a}from"./support/componentsUtils.js";import{globalCss as c}from"./support/globalCss.js";import{messageBundle as p,vmEvent as d,tsx as g}from"./support/widget.js";const m={base:"esri-locate"};let u=class extends l{constructor(e,o){super(e,o),this.messages=null,this.messagesCommon=null,this.viewModel=new n,this._locate=()=>{const{viewModel:e}=this;"locating"===e.state?e.cancelLocate():e.locate().catch(()=>{})},t(i.getLogger(this),"Locate","arcgis-locate",{version:"4.32"})}loadDependencies(){return a({button:()=>import("@esri/calcite-components/dist/components/calcite-button"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip")})}get geolocationOptions(){return this.viewModel.geolocationOptions}set geolocationOptions(e){this.viewModel.geolocationOptions=e}get goToLocationEnabled(){return this.viewModel.goToLocationEnabled}set goToLocationEnabled(e){this.viewModel.goToLocationEnabled=e}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(e){this.viewModel.goToOverride=e}get graphic(){return this.viewModel.graphic}set graphic(e){this.viewModel.graphic=e}get icon(){return"gps-off"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get popupEnabled(){return this.viewModel.popupEnabled}set popupEnabled(e){this.viewModel.popupEnabled=e}get scale(){return this.viewModel.scale}set scale(e){this.viewModel.scale=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}cancelLocate(){this.viewModel.cancelLocate()}locate(){return this.viewModel.locate()}render(){const{viewModel:e,icon:o}=this,{state:t}=e,i="locating"===t,s=i?this.messagesCommon.cancel:this.messages.title,r="feature-unsupported"===t,l=this._localizeError(this.viewModel?.error);return g("div",{class:this.classes(m.base,c.widget)},!r&&g("calcite-button",{class:c.widgetButton,disabled:"disabled"===t,iconStart:i?void 0:o,kind:"neutral",label:s,onclick:this._locate,title:s},i?g("calcite-loader",{inline:!0,label:""}):null),l?g("calcite-tooltip",{open:!0,overlayPositioning:"fixed",placement:this._getPlacement(),referenceElement:this.container},l):null)}_getPlacement(){const{container:e,view:o}=this,t=e&&o?o.ui.getPosition(e):null;if(!t||"manual"===t)return"auto";const[i,s]=t.split("-");return`${"right"===s?"left":"right"}-${"bottom"===i?"end":"start"}`}_localizeError(e){return e instanceof GeolocationPositionError?e.code===GeolocationPositionError.PERMISSION_DENIED?this.messages?.permissionError:e.code===GeolocationPositionError.TIMEOUT?this.messages?.timeoutError:this.messages?.positionUnavailable:e instanceof Error?e.message:void 0}};e([s()],u.prototype,"geolocationOptions",null),e([s()],u.prototype,"goToLocationEnabled",null),e([s()],u.prototype,"goToOverride",null),e([s({type:o})],u.prototype,"graphic",null),e([s()],u.prototype,"icon",null),e([s()],u.prototype,"label",null),e([s(),p("esri/widgets/Locate/t9n/Locate")],u.prototype,"messages",void 0),e([s(),p("esri/t9n/common")],u.prototype,"messagesCommon",void 0),e([s()],u.prototype,"popupEnabled",null),e([s()],u.prototype,"scale",null),e([s()],u.prototype,"view",null),e([s({type:n}),d(["locate","locate-error"])],u.prototype,"viewModel",void 0),u=e([r("esri.widgets.Locate")],u);const h=u;export{h 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/5.0/esri/copyright.txt for details.
4
4
  */
5
- import t from"../../request.js";import e from"../../core/Error.js";import{deg2rad as a}from"../../core/mathUtils.js";import{throwIfAborted as r}from"../../core/promiseUtils.js";import{getPathExtension as o}from"../../core/urlUtils.js";import{rotatePixel as n}from"../../layers/orientedImagery/transformations/utils.js";import{imageGalleryThumbnailSize as s}from"./constants.js";import{validateTifOrMrfExtension as i,getContentType as m}from"./utils.js";const c=t=>"FA"===t,h=async(t,a,r)=>{const o=new(await import("../../rest/support/AttachmentQuery.js").then(t=>t.default))({objectIds:[a]}),n=await t.queryAttachments(o,r),s=n[`${a}`]?.[0],i=s?.url;if(!i)throw new e("NoAttachmentError","no attachments found",{[t.objectIdField]:a,layer:t});return{datasetFormat:s.contentType.split("/")[1].toUpperCase(),url:i}};async function l(t,e){const a="string"==typeof t,r=a?t:t.url,{pathname:n,searchParams:s,origin:i}=new URL(r);let c=a?o(n):t.datasetFormat;c||(c=await m(r));const h=await import("../../layers/support/rasterDatasets/RasterFactory.js").then(t=>t.default),l=await h.open({ioConfig:{customFetchParameters:Object.fromEntries(s),skipMapInfo:!0},datasetFormat:c?.toUpperCase(),url:`${i}${n}`,signal:e?.signal});return l?u(l,{signal:e?.signal}):null}async function u(t,e){const{level:a,offset:o,size:n}=p(t),{pixelBlock:s}=await t.fetchRawPixels(a,o,n,e);return r(e),s}function p(t){const{storageInfo:e,width:a,height:r}=t.rasterInfo,{maximumPyramidLevel:o,pyramidScalingFactor:n}=e,s=n??2;return{level:o,offset:{x:0,y:0},size:{width:Math.ceil(a/s**o),height:Math.ceil(r/s**o)}}}async function d(a,r,o){if(!a)throw new e("NoLayerError","No layer provided, cannot load image from attachment",{layer:a,objectId:r});const{datasetFormat:n,url:m}=await h(a,+r,o);return i(n)?await l({datasetFormat:n,url:m},o):(await t(m,{...o,useQueue:!0,responseType:"image",query:{w:s}})).data}function f(t,e,a=0){const{height:r,width:o}=t;e.width=o,e.height=r;const n=e.getContext("2d");if(!n)return;const s=g(t,e,n);s.getContext("2d")&&(a>0?w(n,s,o,r,a):n.drawImage(s,0,0))}function g(t,e,a){const r=document.createElement("canvas"),o=r.getContext("2d");if(t instanceof HTMLImageElement)r.width=t.width,r.height=t.height,o?.drawImage(t,0,0);else{const n=a.createImageData(e.width,e.height);n&&(n.data.set(t.getAsRGBA()),r.width=n.width,r.height=n.height,o?.putImageData(n,0,0))}return r}function w(t,e,r,o,s){const i=a(s),m=[n(0,0,i),n(r,0,i),n(r,o,i),n(0,o,i)],c=Math.max(...m.map(t=>t[0]))-Math.min(...m.map(t=>t[0])),h=Math.max(...m.map(t=>t[1]))-Math.min(...m.map(t=>t[1])),l=Math.min(r/c,o/h);t.save(),t.clearRect(0,0,r,o),t.translate(r/2,o/2),t.rotate(i),t.scale(l,l),t.drawImage(e,-r/2,-o/2,r,o),t.restore()}export{h as getImageSourceFromAttachment,l as getThumbnailPixelBlock,c as isFeatureAttachment,d as loadImageForAttachment,f as renderImageWithRotation};
5
+ import t from"../../request.js";import e from"../../core/Error.js";import{deg2rad as a}from"../../core/mathUtils.js";import{throwIfAborted as r}from"../../core/promiseUtils.js";import{getPathExtension as o}from"../../core/urlUtils.js";import{rotatePixel as n}from"../../layers/orientedImagery/transformations/utils.js";import{imageGalleryThumbnailSize as s}from"./constants.js";import{validateTifOrMrfExtension as i,getContentType as m}from"./utils.js";const c=t=>"FA"===t,h=async(t,a,r)=>{const o=new(await import("../../rest/support/AttachmentQuery.js").then(t=>t.default))({objectIds:[a]}),n=await t.queryAttachments(o,r),s=n[`${a}`]?.[0],i=s?.url;if(!i)throw new e("NoAttachmentError","no attachments found",{[t.objectIdField]:a,layer:t});return{datasetFormat:s.contentType.split("/")[1].toUpperCase(),url:i}};async function l(t,e){const a="string"==typeof t,r=a?t:t.url,{pathname:n,searchParams:s,origin:i}=new URL(r);let c=a?o(n):t.datasetFormat;c||(c=await m(r));const h=await import("../../layers/raster/datasets/RasterFactory.js").then(t=>t.default),l=await h.open({ioConfig:{customFetchParameters:Object.fromEntries(s),skipMapInfo:!0},datasetFormat:c?.toUpperCase(),url:`${i}${n}`,signal:e?.signal});return l?u(l,{signal:e?.signal}):null}async function u(t,e){const{level:a,offset:o,size:n}=d(t),{pixelBlock:s}=await t.fetchRawPixels(a,o,n,e);return r(e),s}function d(t){const{storageInfo:e,width:a,height:r}=t.rasterInfo,{maximumPyramidLevel:o,pyramidScalingFactor:n}=e,s=n??2;return{level:o,offset:{x:0,y:0},size:{width:Math.ceil(a/s**o),height:Math.ceil(r/s**o)}}}async function f(a,r,o){if(!a)throw new e("NoLayerError","No layer provided, cannot load image from attachment",{layer:a,objectId:r});const{datasetFormat:n,url:m}=await h(a,+r,o);return i(n)?await l({datasetFormat:n,url:m},o):(await t(m,{...o,useQueue:!0,responseType:"image",query:{w:s}})).data}function p(t,e,a=0){const{height:r,width:o}=t;e.width=o,e.height=r;const n=e.getContext("2d");if(!n)return;const s=g(t,e,n);s.getContext("2d")&&(a>0?w(n,s,o,r,a):n.drawImage(s,0,0))}function g(t,e,a){const r=document.createElement("canvas"),o=r.getContext("2d");if(t instanceof HTMLImageElement)r.width=t.width,r.height=t.height,o?.drawImage(t,0,0);else{const n=a.createImageData(e.width,e.height);n&&(n.data.set(t.getAsRGBA()),r.width=n.width,r.height=n.height,o?.putImageData(n,0,0))}return r}function w(t,e,r,o,s){const i=a(s),m=[n(0,0,i),n(r,0,i),n(r,o,i),n(0,o,i)],c=Math.max(...m.map(t=>t[0]))-Math.min(...m.map(t=>t[0])),h=Math.max(...m.map(t=>t[1]))-Math.min(...m.map(t=>t[1])),l=Math.min(r/c,o/h);t.save(),t.clearRect(0,0,r,o),t.translate(r/2,o/2),t.rotate(i),t.scale(l,l),t.drawImage(e,-r/2,-o/2,r,o),t.restore()}export{h as getImageSourceFromAttachment,l as getThumbnailPixelBlock,c as isFeatureAttachment,f as loadImageForAttachment,p as renderImageWithRotation};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as t}from"tslib";import e from"../../../core/Error.js";import{Loadable as i}from"../../../core/Loadable.js";import{throwIfAborted as r}from"../../../core/promiseUtils.js";import{property as s,subclass as o}from"../../../core/accessorSupport/decorators.js";import{RasterJobHandlerMixin as h}from"../../../layers/mixins/RasterJobHandlerMixin.js";let a=class extends(h(i)){constructor(t){super(t)}load(t){return this.addResolvingPromise(this._fetchPixels(t)),Promise.resolve(this)}destroy(){this._source=null}get height(){return this._get("height")}get width(){return this._get("width")}async _fetchPixels(t){const i=(await import("../../../layers/support/rasterDatasets/RasterFactory.js")).default,s=await i.open({url:this.url,ioConfig:{skipExtensions:["jgw","aux.xml"],skipMapInfo:!0},signal:t?.signal});if(r(t),null==s)throw new e("depth-image-service:open-error","Failed to open depth image raster.",{url:this.url});const{width:o,height:h}=s.rasterInfo;await this._initJobHandler(),r(t),s.rasterJobHandler=this._rasterJobHandler;const{pixelBlock:a}=await s.fetchPixels(s.rasterInfo.nativeExtent.clone(),o,h,{noClip:!1,signal:t?.signal});if(r(t),null==a)throw new e("depth-image-service:fetch-error","Failed to fetch depth image pixels.");this._set("width",a.width),this._set("height",a.height),this._source=a.pixels[0]}_getDepthValue(t,e){const i=Math.max(1,Math.min(this.width,t)),r=Math.max(1,Math.min(this.height,e));return this._source[(r-1)*this.width+(i-1)]}_interpolateDepth(t,e){const i=Math.floor(e),r=Math.ceil(e),s=Math.floor(t),o=Math.ceil(t),h=e-i,a=t-s;return(this._getDepthValue(i,s)*(1-h)+this._getDepthValue(r,s)*h)*(1-a)+(this._getDepthValue(i,o)*(1-h)+this._getDepthValue(r,o)*h)*a}depthAt(t,e){if(!this.loaded||!this._source)throw new Error("DepthImageService must be loaded before sampling depth.");const i=t.x/e.width*this.width,r=t.y/e.height*this.height;return this._interpolateDepth(r,i)}};t([s({readOnly:!0,value:0})],a.prototype,"height",null),t([s()],a.prototype,"url",void 0),t([s({readOnly:!0,value:0})],a.prototype,"width",null),a=t([o("esri.widgets.OrientedImageryViewer.services.DepthImageService")],a);const l=a;export{l as default};
5
+ import{__decorate as t}from"tslib";import e from"../../../core/Error.js";import{Loadable as i}from"../../../core/Loadable.js";import{throwIfAborted as r}from"../../../core/promiseUtils.js";import{property as s,subclass as h}from"../../../core/accessorSupport/decorators.js";import{RasterJobHandlerMixin as o}from"../../../layers/mixins/RasterJobHandlerMixin.js";let a=class extends(o(i)){constructor(t){super(t)}load(t){return this.addResolvingPromise(this._fetchPixels(t)),Promise.resolve(this)}destroy(){this._source=null}get height(){return this._get("height")}get width(){return this._get("width")}async _fetchPixels(t){const i=(await import("../../../layers/raster/datasets/RasterFactory.js")).default,s=await i.open({url:this.url,ioConfig:{skipExtensions:["jgw","aux.xml"],skipMapInfo:!0},signal:t?.signal});if(r(t),null==s)throw new e("depth-image-service:open-error","Failed to open depth image raster.",{url:this.url});const{width:h,height:o}=s.rasterInfo;await this._initJobHandler(),r(t),s.rasterJobHandler=this._rasterJobHandler;const{pixelBlock:a}=await s.fetchPixels(s.rasterInfo.nativeExtent.clone(),h,o,{noClip:!1,signal:t?.signal});if(r(t),null==a)throw new e("depth-image-service:fetch-error","Failed to fetch depth image pixels.");this._set("width",a.width),this._set("height",a.height),this._source=a.pixels[0]}_getDepthValue(t,e){const i=Math.max(1,Math.min(this.width,t)),r=Math.max(1,Math.min(this.height,e));return this._source[(r-1)*this.width+(i-1)]}_interpolateDepth(t,e){const i=Math.floor(e),r=Math.ceil(e),s=Math.floor(t),h=Math.ceil(t),o=e-i,a=t-s;return(this._getDepthValue(i,s)*(1-o)+this._getDepthValue(r,s)*o)*(1-a)+(this._getDepthValue(i,h)*(1-o)+this._getDepthValue(r,h)*o)*a}depthAt(t,e){if(!this.loaded||!this._source)throw new Error("DepthImageService must be loaded before sampling depth.");const i=t.x/e.width*this.width,r=t.y/e.height*this.height;return this._interpolateDepth(r,i)}};t([s({readOnly:!0,value:0})],a.prototype,"height",null),t([s()],a.prototype,"url",void 0),t([s({readOnly:!0,value:0})],a.prototype,"width",null),a=t([h("esri.widgets.OrientedImageryViewer.services.DepthImageService")],a);const l=a;export{l 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/5.0/esri/copyright.txt for details.
4
4
  */
5
- async function t(t){const e=(await import("./PanoramicMeshManager.js").then(t=>t.default)).getInstance();return await e.load(t)}async function e(){return i(await import("../../../geometry/Mesh.js"))}async function r(){return i(await import("../../../geometry/support/MeshComponent.js"))}async function a(){return i(await import("../../../geometry/support/MeshLocalVertexSpace.js"))}async function n(){return i(await import("../../../geometry/support/MeshMaterial.js"))}async function s(){return i(await import("../../../geometry/support/MeshTexture.js"))}async function o(){return(await import("../../../geometry/support/MeshVertexAttributes.js")).MeshVertexAttributes}function i(t){return t.default??t}async function u(){const[a,i,u,c,p,m]=await Promise.all([e(),r(),n(),s(),o(),t()]);return{Mesh:a,MeshComponent:i,MeshMaterial:u,MeshTexture:c,MeshVertexAttributes:p,panoramicMeshManager:m}}async function c(){return i(await import("./PanoramicTileNode.js"))}async function p(){return i(await import("./PanoramicTilePyramid.js"))}async function m(){return i(await import("../../../layers/support/rasterDatasets/RasterFactory.js"))}export{i as extractDefault,e as loadMesh,r as loadMeshComponent,u as loadMeshDependencies,a as loadMeshLocalVertexSpace,t as loadMeshManager,n as loadMeshMaterial,s as loadMeshTexture,o as loadMeshVertexAttributes,c as loadPanoramicTileNode,p as loadPanoramicTilePyramid,m as loadRasterFactory};
5
+ async function t(t){const e=(await import("./PanoramicMeshManager.js").then(t=>t.default)).getInstance();return await e.load(t)}async function e(){return i(await import("../../../geometry/Mesh.js"))}async function r(){return i(await import("../../../geometry/support/MeshComponent.js"))}async function a(){return i(await import("../../../geometry/support/MeshLocalVertexSpace.js"))}async function n(){return i(await import("../../../geometry/support/MeshMaterial.js"))}async function s(){return i(await import("../../../geometry/support/MeshTexture.js"))}async function o(){return(await import("../../../geometry/support/MeshVertexAttributes.js")).MeshVertexAttributes}function i(t){return t.default??t}async function u(){const[a,i,u,c,p,m]=await Promise.all([e(),r(),n(),s(),o(),t()]);return{Mesh:a,MeshComponent:i,MeshMaterial:u,MeshTexture:c,MeshVertexAttributes:p,panoramicMeshManager:m}}async function c(){return i(await import("./PanoramicTileNode.js"))}async function p(){return i(await import("./PanoramicTilePyramid.js"))}async function m(){return i(await import("../../../layers/raster/datasets/RasterFactory.js"))}export{i as extractDefault,e as loadMesh,r as loadMeshComponent,u as loadMeshDependencies,a as loadMeshLocalVertexSpace,t as loadMeshManager,n as loadMeshMaterial,s as loadMeshTexture,o as loadMeshVertexAttributes,c as loadPanoramicTileNode,p as loadPanoramicTilePyramid,m as loadRasterFactory};
package/widgets/Print.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import{formatNumber as t}from"../intl.js";import{deprecateWidget as i}from"../core/deprecate.js";import{JSONMap as a}from"../core/jsonMap.js";import l from"../core/Logger.js";import{watch as o,on as n,whenOnce as s}from"../core/reactiveUtils.js";import{unitName as r}from"../core/unitFormatUtils.js";import{addProxy as c,hasSameOrigin as p}from"../core/urlUtils.js";import{property as d,subclass as m}from"../core/accessorSupport/decorators.js";import{ensureInteger as u}from"../core/accessorSupport/ensureType.js";import h from"../geometry/SpatialReference.js";import{isValid as b}from"../geometry/support/spatialReferenceUtils.js";import{reArcGISOnlineDomain as _}from"../portal/support/urlUtils.js";import{findToken as v}from"../rest/utils.js";import{formatJsonMap as g}from"../rest/support/fileFormat.js";import f from"./Widget.js";import y from"./Print/PrintViewModel.js";import{loadCalciteComponents as T}from"./support/componentsUtils.js";import{globalCss as w}from"./support/globalCss.js";import{Heading as x}from"./support/Heading.js";import{legacyIcon as k}from"./support/legacyIcon.js";import{messageBundle as C,tsx as S,isRTL as I,tsxFragment as O,isActivationKey as E}from"./support/widget.js";const $="map-only",L="esri-print",M={base:L,headerTitle:`${L}__header-title`,layoutTabList:`${L}__layout-tab-list`,layoutTab:`${L}__layout-tab`,layoutSection:`${L}__layout-section`,mapOnlySection:`${L}__map-only-section`,panelItemsCentered:`${L}__panel-items--centered`,loader:`${L}__loader`,swapButton:`${L}__swap-button`,printButton:`${L}__export-button`,printButtonSection:`${L}__export-button-section`,printButtonSectionDivider:`${L}__export-button-section--divider`,templateSelectContainer:`${L}__template-select-container`,templateSelectIcon:`${L}__template-select-icon`,templateSelectError:`${L}__template-select-error`,templateSelectArrow:`${L}__template-select-arrow`,formSectionContainer:`${L}__form-section-container`,advancedOptionsSection:`${L}__advanced-options-section`,advancedOptionsContainer:`${L}__advanced-options-container`,browseTemplateButtonContainer:`${L}__browse-template-button-container`,browseTemplateButtonContainerFilter:`${L}__browse-template-button-container-filter`,exportedFilesContainer:`${L}__export-panel-container`,exportedFilesTitle:`${L}__export-title`,exportedFile:`${L}__exported-file`,exportedFileLinkTitle:`${L}__exported-file-link-title`,exportedFileLinkDescription:`${L}__exported-file-link-description`,exportedFilesEmpty:`${L}__exported-files-empty`,printWidgetContainer:`${L}__container`,content:`${L}__content`,panelContainer:`${L}__panel-container`,scaleInfoContainer:`${L}__scale-info-container`,scaleInputContainer:`${L}__scale-input-container`,scaleInput:`${L}__scale-input`,sizeContainer:`${L}__size-container`,panelError:`${L}__panel--error`,exportedFileLoader:`${L}__exported-file--loader`,exportSection:`${L}__export-section`,exportSectionCentered:`${L}__export-section--centered`,templateButtonContainer:`${L}__template-button-container`,templateDoneButton:`${L}__template-done-button`,templateSelectFlowItemContainer:`${L}__template-select-flow-item-container`,templateSelectFlowItemContent:`${L}__template-select-flow-item-content`,templateSelectFlowItemListHeading:`${L}__template-select-flow-item-list-heading`,srLabel:`${L}__sr-label`,invalidWkidText:`${L}__invalid-wkid-text`};function F(e){return!isNaN(e)&&e>0&&Number.isFinite(e)}function P(e){return e?.toLowerCase()===$}function A(e){const{state:t,extension:i}=e;switch(t){case"pending":return"spinner";case"error":return"exclamation-mark-circle";default:return i?.toLowerCase()?.includes("pdf")?"file-pdf":"file"}}const R=new a({inch:"inches",foot:"feet",yard:"yards",mile:"miles","nautical-mile":"nautical-miles",millimeter:"millimeters",centimeter:"centimeters",decimeter:"decimeters",meter:"meters",kilometer:"kilometers"}),B=new Map([["a3-landscape","a3-landscape"],["a3-portrait","a3-portrait"],["a4-landscape","a4-landscape"],["a4-portrait","a4-portrait"],["letter-ansi-a-landscape","ansi-a-landscape"],["letter-ansi-a-portrait","ansi-a-portrait"],["tabloid-ansi-b-landscape","ansi-b-landscape"],["tabloid-ansi-b-portrait","ansi-b-portrait"]]);let N=class extends f{constructor(e,t){super(e,t),this._activeTabFocusRequested=!1,this._awaitingServerResponse=!1,this._selectedTab="layoutTab",this._pendingExportScroll=!1,this._rootNode=null,this._selectedTemplate=null,this._formats=[],this._showTemplates=!1,this._isValidSpatialReference=!0,this.allowedFormatsForSaving=null,this.browseTemplateButtonOnClick=null,this.headerVisible=!0,this.headingLevel=3,this.includeOrganizationTemplates=!0,this.messagesCommon=null,this.messagesUnits=null,this.saveExportHidden=!0,this.saveAsButtonCallback=null,this.viewModel=new y,this._onInput=e=>{"layoutTab"===this._selectedTab?this.templateOptions.title=e.currentTarget.value:"mapOnlyTab"===this._selectedTab&&(this.templateOptions.fileName=e.currentTarget.value)},this._handleLinkClick=e=>{const t=e.currentTarget["data-item"];if(!t||"ready"!==t.state||!t.url)return;const i=v(this.viewModel.effectivePrintServiceUrl),a=t.url,l=document.createElement("a");if(l.target="_blank",l.href=a,l.rel="noreferrer",l.download=t.formattedName??"",!i)return l.click(),void e.stopPropagation();e.preventDefault();const o=new URL(a);o.searchParams.set("token",i),l.href=o.href,l.click(),l.href=a},i(l.getLogger(this),"Print","arcgis-print",{version:"4.33"}),this._focusOnTabChange=this._focusOnTabChange.bind(this)}initialize(){this.addHandles([o(()=>[this.templateOptions.format,this.viewModel.templatesInfo?.format],()=>{const{templatesInfo:e}=this.viewModel;if(!e)return;if(this._formats.length!==e.format.choiceList.length){const t=g.apiValues;this._formats=e.format.choiceList.map(e=>{const i=t.find(t=>new RegExp(`\\b${t}\\b`,"i").test(e))??e;return{value:i,label:e===i?e.toUpperCase():e}}).sort((e,t)=>e.label.localeCompare(t.label))}const t=this._formats.some(({value:e})=>new RegExp(`\\b${e}\\b`,"i").test(this.templateOptions.format));if(e.format.defaultValue&&!t){const t=this._formats.find(({value:t})=>new RegExp(`\\b${t}\\b`,"i").test(e.format.defaultValue))?.value;return void(t&&(this.templateOptions.format=t))}}),o(()=>[this.templateOptions.id,this.viewModel.loaded],()=>{const{layout:e}=this.templateOptions;this._selectedTab=P(e)?"mapOnlyTab":"layoutTab","layoutTab"===this._selectedTab&&this.viewModel.loaded&&(this._selectedTemplate=this.viewModel.getLayoutTemplateById(this.templateOptions.id))}),o(()=>this.templateOptions.dpi,e=>{e<=0&&(this.templateOptions.dpi=1)}),o(()=>this.viewModel.view?.scale,e=>{!e||this.templateOptions.scaleEnabled&&this.templateOptions.scale||(this.templateOptions.scale=e)}),n(()=>this.viewModel,"submit",e=>this.emit("submit",e)),n(()=>this.viewModel,"complete",e=>this.emit("complete",e))]);const{height:e,width:t}=this.templateOptions;this.templateOptions.width=t||800,this.templateOptions.height=e||1100;const i=setTimeout(()=>{this._awaitingServerResponse=!0,this.scheduleRender()},500);this.viewModel.load().then(()=>{clearTimeout(i),this._awaitingServerResponse=!1})}loadDependencies(){return T({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),block:()=>import("@esri/calcite-components/dist/components/calcite-block"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),checkbox:()=>import("@esri/calcite-components/dist/components/calcite-checkbox"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),input:()=>import("@esri/calcite-components/dist/components/calcite-input"),"input-number":()=>import("@esri/calcite-components/dist/components/calcite-input-number"),label:()=>import("@esri/calcite-components/dist/components/calcite-label"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch"),chip:()=>import("@esri/calcite-components/dist/components/calcite-chip"),popover:()=>import("@esri/calcite-components/dist/components/calcite-popover"),link:()=>import("@esri/calcite-components/dist/components/calcite-link")})}destroy(){this.viewModel.destroy()}get allowedFormats(){return this.viewModel.allowedFormats}set allowedFormats(e){this.viewModel.allowedFormats=e}get allowedLayouts(){return this.viewModel.allowedLayouts}set allowedLayouts(e){this.viewModel.allowedLayouts=e}get error(){return this.viewModel.error}get exportedLinks(){return this.viewModel.exportedLinks}set exportedLinks(e){this.viewModel.exportedLinks=e}get extraParameters(){return this.viewModel.extraParameters}set extraParameters(e){this.viewModel.extraParameters=e}get icon(){return"print"}set icon(e){this._overrideIfSome("icon",e)}get includeDefaultTemplates(){return this.viewModel.includeDefaultTemplates}set includeDefaultTemplates(e){this.viewModel.includeDefaultTemplates=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get outSpatialReference(){return this.viewModel.outSpatialReference}set outSpatialReference(e){this.viewModel.outSpatialReference=e}get portal(){return this.viewModel.portal}set portal(e){this.viewModel.portal=e}get saveExportEnabled(){return this.viewModel.saveExportEnabled}set saveExportEnabled(e){this.viewModel.saveExportEnabled=e}get showPrintAreaEnabled(){return this.viewModel.showPrintAreaEnabled}set showPrintAreaEnabled(e){this.viewModel.showPrintAreaEnabled=e}get printServiceUrl(){return this.viewModel.printServiceUrl}set printServiceUrl(e){this.viewModel.printServiceUrl=e}get templateCustomTextElements(){return this.viewModel.templateCustomTextElements}set templateCustomTextElements(e){this.viewModel.templateCustomTextElements=e}get templateOptions(){return this.viewModel.templateOptions}set templateOptions(e){this.viewModel.templateOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}render(){const{messages:e,templateOptions:t,viewModel:i,view:a}=this,{attributionEnabled:l,author:o,copyright:n,dpi:s,format:r,height:c,layout:p,layoutItem:d,legendEnabled:m,northArrowEnabled:_,scaleBarEnabled:v,scaleEnabled:g,scale:f,width:y}=t,T="ready"!==i.state||this._awaitingServerResponse||!(p||d),C=this._renderTitleOrFileNameSection(),O=S("div",{class:M.formSectionContainer},S("calcite-label",null,e.fileFormatTitle,S("calcite-combobox",{clearDisabled:!0,label:e.formatDefaultOption,maxItems:6,placeholder:e.formatDefaultOption,selectionMode:"single-persist",onCalciteComboboxChange:({currentTarget:e})=>{this.templateOptions.format=e.selectedItems[0]?.value??"pdf"}},this._formats.map(({value:e,label:t},i)=>S("calcite-combobox-item",{key:`file-format-${i}`,selected:e===this.templateOptions.format,textLabel:t,value:e}))))),E=S("calcite-label",{layout:"inline"},S("calcite-switch",{checked:this.showPrintAreaEnabled,onCalciteSwitchChange:e=>{this.showPrintAreaEnabled=!!e.currentTarget.checked}}),e.printPreview),$=S("div",null,S("div",{class:M.formSectionContainer},S("calcite-label",null,e.template,S("calcite-block",{class:M.templateSelectContainer,collapsible:!1,description:this._getPageSizeLabel(this._selectedTemplate),heading:this._getTemplateLabel(this._selectedTemplate,!0),key:"template-select-block",label:e.template,loading:"loading"===this._selectedTemplate?.state,onclick:()=>this._showTemplates=!0,onkeydown:e=>{"Enter"!==e.key&&" "!==e.key||(this._showTemplates=!0)},tabIndex:0},S("calcite-icon",{class:M.templateSelectIcon,icon:(this._selectedTemplate?.layout?B.get(this._selectedTemplate.layout):null)||"custom-print",key:"template-select-icon",scale:"l",slot:"content-start"}),"error"===this._selectedTemplate?.state?S("calcite-icon",{class:M.templateSelectError,icon:"exclamation-mark-circle",key:"template-select-error",scale:"s",slot:"actions-end"}):null,S("calcite-icon",{class:M.templateSelectArrow,icon:I()?"chevron-left":"chevron-right",key:"template-select-arrow",scale:"s",slot:"actions-end"})))),E),L=S("div",{class:M.formSectionContainer},S("calcite-label",null,e.dpi,S("calcite-input-number",{bind:this,"data-input-name":"dpi",min:1,value:`${s}`,onCalciteInputNumberInput:this._updateNumberInputValue}))),F=S("div",{class:M.formSectionContainer},S("calcite-label",null,S("div",{class:M.srLabel},e.outSpatialReference,S("calcite-link",{href:"https://developers.arcgis.com/rest/services-reference/enterprise/using-spatial-references/",target:"_blank"},"(WKID)")),S("calcite-input-number",{bind:this,"data-input-name":"outSpatialReference",integer:!0,numberButtonType:"none",value:i.outSpatialReference?.wkid?.toString()??"",onCalciteInputNumberInput:({currentTarget:e})=>{const t=u(e.value);i.outSpatialReference=Number.isNaN(t)||null==t?null:new h({wkid:t}),this._isValidSpatialReference=!i.outSpatialReference||b(i.outSpatialReference)}}),this._isValidSpatialReference?null:S("div",{class:M.invalidWkidText,key:`out-sr-${i.outSpatialReference?.wkid}`},e.invalidWkid))),P=S("div",{class:this.classes(M.scaleInfoContainer,M.formSectionContainer)},S("calcite-label",{layout:"inline"},S("calcite-checkbox",{bind:this,checked:g,"data-option-name":"scaleEnabled",onCalciteCheckboxChange:this._toggleInputValue}),e.scale),S("div",{class:M.scaleInputContainer},S("calcite-input-number",{"aria-label":e.scaleLabel,"aria-valuenow":`${f}`,bind:this,class:M.scaleInput,"data-input-name":"scale",disabled:!g,value:`${f}`,onCalciteInputNumberInput:this._updateNumberInputValue}),S("calcite-button",{appearance:"outline","aria-label":e.reset,bind:this,disabled:!g,iconStart:"refresh",kind:"neutral",onclick:this._resetToCurrentScale}))),A=S("div",{"aria-labelledby":`${this.id}__advancedOptionsForLayout`,class:M.advancedOptionsContainer,key:"advanced-section-for-layout"},P,this._selectedTemplate?.layoutTemplateInfo?.layoutOptions?.hasAuthorText??1?S("div",{class:M.formSectionContainer,key:"author-info"},S("calcite-label",null,e.author,S("calcite-input",{bind:this,"data-input-name":"author",value:o??"",onCalciteInputInput:this._updateInputValue}))):null,this._selectedTemplate?.layoutTemplateInfo?.layoutOptions?.hasCopyrightText??1?S("div",{class:M.formSectionContainer,key:"copyright-text"},S("calcite-label",null,e.copyright,S("calcite-input",{bind:this,"data-input-name":"copyright",value:n??"",onCalciteInputInput:this._updateInputValue}))):null,L,F,this._renderCustomTextElementSection(),this._selectedTemplate?.layoutTemplateInfo?.layoutOptions?.hasLegend??1?S("div",{class:M.formSectionContainer,key:"legend-info"},S("calcite-label",{layout:"inline"},S("calcite-checkbox",{bind:this,checked:!!m,"data-option-name":"legendEnabled",onCalciteCheckboxChange:this._toggleInputValue}),e.legend)):null,this._selectedTemplate?.mapSurroundInfoOptions?.northArrow.length?S("div",{class:M.formSectionContainer,key:"north-arrow"},S("calcite-label",{layout:"inline"},S("calcite-checkbox",{bind:this,checked:!!_,"data-option-name":"northArrowEnabled",onCalciteCheckboxChange:this._toggleInputValue}),e.northArrow)):null,this._selectedTemplate?.mapSurroundInfoOptions?.scaleBar.length?S("div",{class:M.formSectionContainer,key:"scale-bar"},S("calcite-label",{layout:"inline"},S("calcite-checkbox",{bind:this,checked:!!v,"data-option-name":"scaleBarEnabled",onCalciteCheckboxChange:this._toggleInputValue}),e.scaleBar)):null),R=S("div",{"aria-labelledby":`${this.id}__advancedOptionsForMapOnly`,class:M.advancedOptionsContainer},P,L,F,S("div",{class:M.formSectionContainer},S("calcite-label",{layout:"inline"},S("calcite-checkbox",{bind:this,checked:l,"data-option-name":"attributionEnabled",onCalciteCheckboxChange:this._toggleInputValue}),e.attribution)),this._renderCustomTextElementSection()),N=this.exportedLinks.toArray(),V=this._renderExportedLinkItems(N),D={[M.exportSectionCentered]:!N.length},U="layoutTab"===this._selectedTab?S("section",{"aria-labelledby":`${this.id}__layoutTab`,class:M.layoutSection,id:`${this.id}__layoutContent`,key:"esri-print__layoutContent",role:"tabpanel"},S("div",{class:M.panelContainer},this._selectedTemplate?.layoutTemplateInfo?.layoutOptions?.hasTitleText??1?C:null,$,"layoutTab"===this._selectedTab?O:null,S("calcite-block",{"aria-label":e.advancedOptions,class:this.classes(M.panelContainer,M.advancedOptionsSection),collapsible:!0,disabled:!(p||d?.id),heading:e.advancedOptions,id:"advancedOptionsForLayout",key:"advanced-options-for-layout"},A))):"mapOnlyTab"===this._selectedTab?S("section",{"aria-labelledby":`${this.id}__mapOnlyTab`,class:M.mapOnlySection,id:`${this.id}__mapOnlyContent`,key:"esri-print__mapOnlyContent",role:"tabpanel"},S("div",{class:M.panelContainer},C,O,S("div",null,S("div",{class:this.classes(M.sizeContainer,M.formSectionContainer)},S("calcite-label",null,e.width,S("calcite-input-number",{bind:this,"data-input-name":"width",value:`${y}`,onCalciteInputNumberInput:this._updateNumberInputValue})),S("calcite-label",null,e.height,S("calcite-input-number",{bind:this,"data-input-name":"height",value:`${c}`,onCalciteInputNumberInput:this._updateNumberInputValue})),S("button",{"aria-label":e.swap,bind:this,class:this.classes(w.widgetButton,M.swapButton,k.swap),onclick:this._switchInput,type:"button"})),E),S("calcite-block",{"aria-label":e.advancedOptions,class:this.classes(M.panelContainer,M.advancedOptionsSection),collapsible:!0,heading:e.advancedOptions,id:"advancedOptionsForMapOnly",key:"advanced-options-for-map-only"},R))):S("section",{"aria-labelledby":`${this.id}__exportTab`,class:this.classes(M.exportSection,D),id:`${this.id}__exportContent`,key:"esri-print__exportContent",role:"tabpanel"},S("div",{class:M.panelContainer},S("div",{afterUpdate:this._scrollExportIntoView,bind:this,class:M.exportedFilesContainer},0===N.length?S("div",{class:M.exportedFilesEmpty},S("calcite-icon",{icon:"file",scale:"l"}),S("div",null,S(x,{class:M.exportedFilesTitle,level:this.headingLevel},e.noExportedFiles),S("div",null,e.exportHint))):V))),j="2d"!==a?.type,H=S("div",{class:M.panelError},a?j?e.sceneViewError:e.serviceError:e.noViewError),z=N.some(({state:e})=>"pending"===e),W=S("div",{class:M.content,key:"panel"},S("div",null,S("ul",{bind:this,class:M.layoutTabList,onclick:this._toggleLayoutPanel,onkeydown:this._handleLayoutPanelKeyDown,role:"tablist"},S("li",{afterCreate:this._focusOnTabChange,afterUpdate:this._focusOnTabChange,"aria-selected":`${"layoutTab"===this._selectedTab}`,class:M.layoutTab,"data-tab-id":"layoutTab",id:`${this.id}__layoutTab`,role:"tab",tabIndex:0},e.layoutTab),S("li",{afterCreate:this._focusOnTabChange,afterUpdate:this._focusOnTabChange,"aria-selected":`${"mapOnlyTab"===this._selectedTab}`,class:M.layoutTab,"data-tab-id":"mapOnlyTab",id:`${this.id}__mapOnlyTab`,role:"tab",tabIndex:0},e.mapOnlyTab),S("li",{afterCreate:this._focusOnTabChange,afterUpdate:this._focusOnTabChange,"aria-selected":`${"exportTab"===this._selectedTab}`,class:M.layoutTab,"data-tab-id":"exportTab",id:`${this.id}__exportedFilesTab`,role:"tab",tabIndex:0},z?S("calcite-loader",{inline:!0,label:"loading",scale:"s"}):null,e.exportsTab)),U),"exportTab"!==this._selectedTab?S("div",{class:this.classes(M.printButtonSection,!this.saveExportHidden&&this.portal?M.printButtonSectionDivider:null),key:"export-button-section"},!this.saveExportHidden&&this.portal?S("calcite-label",{layout:"inline"},S("calcite-checkbox",{bind:this,checked:this.saveExportEnabled,onCalciteCheckboxChange:e=>{this.saveExportEnabled=!!e.currentTarget.checked}}),e.saveExportToMyContent):null,S("calcite-button",{"aria-label":e.exportDescription,bind:this,class:this.classes(M.printButton),disabled:T||!(p||d?.id)&&!r,onclick:this._handlePrintMap,scale:"l",width:"full"},e.export)):null),q=S("calcite-flow",{key:"root-flow"},S("calcite-flow-item",{bind:this,key:"root-flow-item",selected:!this._showTemplates},S("div",{class:M.printWidgetContainer},this.headerVisible?S("header",{class:M.headerTitle},e.export):null,this.error||j||!a?H:W)),this._renderChooseTemplateFlowItem()),K="initializing"===i.state,J=K?this._renderLoader():q,G={[M.panelItemsCentered]:K};return S("div",{bind:this,class:this.classes(M.base,w.widget,w.panel,G)},J)}_getPageSizeLabel(e){if(!e)return;const i=e.layoutTemplateInfo;if(!i)return;const a=R.fromJSON(i.pageUnits.toLowerCase());return`${t(i.pageSize[0])} × ${t(i.pageSize[1])} ${r(this.messagesUnits,a,"abbr")}`}_getTemplateLabel(e,t=!1){if(!e)return t?this.messages.selectTemplate:this.messages.untitled;const{label:i,layout:a,layoutItem:l,type:o}=e;if("print-service-template"===o&&this.messages[a])return this.messages[a];const n=i??a??l?.id;return n?.replaceAll("_"," ")??this.messages.untitled}_getPortalTemplates(){const{portalTemplateIds:e}=this.viewModel;return this.includeDefaultTemplates&&this.includeOrganizationTemplates?this.viewModel.defaultTemplates.toArray().filter(({layout:t,layoutItem:i})=>!P(t)&&!!i?.id&&e.includes(i.id)):[]}_getDefaultTemplates(){const{portalTemplateIds:e}=this.viewModel;return this.includeDefaultTemplates?this.viewModel.defaultTemplates.toArray().filter(({layout:t,layoutItem:i})=>!(P(t)||i?.id&&e.includes(i.id))):[]}_getPrintServiceTemplates(){return this.includeDefaultTemplates&&this._getDefaultTemplates().length?[]:this.viewModel.printServiceTemplates.toArray().filter(({layout:e})=>!P(e))}_renderLayoutTemplates(e,t=!1,i=!1){return t&&e.sort((e,t)=>(e.label??"")>(t.label??"")?1:-1),e.map(e=>S("calcite-list-item",{description:this._getPageSizeLabel(e),key:`template-${e.id}-${e.id===this.templateOptions.id}`,label:this._getTemplateLabel(e),selected:e.id===this.templateOptions.id,title:e.description??"",value:e},S("calcite-icon",{icon:(e.layout?B.get(e.layout):null)||"custom-print",slot:"content-start"}),"loading"===e.state?S("calcite-loader",{inline:!0,key:`template-loader-${e.id}`,label:"loading",scale:"s",slot:"content-end"}):null,"error"===e?.state?S("calcite-icon",{class:M.templateSelectError,icon:"exclamation-mark-circle",key:`template-error-${e.id}`,scale:"s",slot:"content-end"}):null,i?S("calcite-action",{icon:"trash",onclick:()=>this.viewModel.removePortalTemplate(e),slot:"actions-end",text:"delete"}):null))}_renderChooseTemplateFlowItem(){if(!this._showTemplates)return null;const{messages:e}=this,t=_.test(this.portal?.url),i=this.viewModel.browseTemplates.toArray(),a=this._getPortalTemplates(),l=this._getDefaultTemplates(),o=this._getPrintServiceTemplates(),n=i.length+a.length+l.length+o.length>15,s=this.browseTemplateButtonOnClick?S("calcite-button",{appearance:"outline",class:n?M.browseTemplateButtonContainerFilter:M.browseTemplateButtonContainer,iconStart:"folder",key:"browse-template-button",onclick:this.browseTemplateButtonOnClick,slot:n?"filter-actions-end":"default"},n?null:e.browseTemplates):null;return S("calcite-flow-item",{bind:this,closable:!1,heading:e.chooseTemplate,key:"template-flow-item",selected:this._showTemplates,onCalciteFlowItemBack:e=>{e.preventDefault(),this._showTemplates=!1}},S("div",{class:M.templateSelectFlowItemContainer},S("div",{class:M.templateSelectFlowItemContent},n?null:s,S("calcite-list",{filterEnabled:n,filterProps:["label"],key:"template-list",label:e.templateList,selectionMode:"single-persist",onCalciteListChange:({currentTarget:e})=>this.viewModel.applyTemplate(e.selectedItems[0]?.value)},n?s:null,i.length?S("div",{key:"my-templates"},S("div",{class:M.templateSelectFlowItemListHeading},e.myTemplates,t?S("calcite-chip",{appearance:"outline",kind:"neutral",label:e.beta,scale:"s"},e.beta):null),this._renderLayoutTemplates(i,!0,!0)):null,a.length?S("div",{key:"org-templates"},S("div",{class:M.templateSelectFlowItemListHeading},e.organizationTemplates,t?S("calcite-chip",{appearance:"outline",kind:"neutral",label:e.beta,scale:"s"},e.beta):null),this._renderLayoutTemplates(a)):null,i.length||a.length?l.length?S("div",{key:"default-templates"},S("div",{class:M.templateSelectFlowItemListHeading},e.defaultTemplates),this._renderLayoutTemplates(l,!0)):null:this._renderLayoutTemplates(l,!0),i.length||a.length?o.length?S("div",{key:"service-templates"},S("div",{class:M.templateSelectFlowItemListHeading},e.defaultTemplates),this._renderLayoutTemplates(o)):null:this._renderLayoutTemplates(o))),S("div",{class:M.templateButtonContainer},S("calcite-button",{class:M.templateDoneButton,onclick:()=>this._showTemplates=!1},this.messagesCommon.done))))}_renderCustomTextElementSection(){const{customTextElements:e}=this.templateOptions;return e?S("div",{class:M.formSectionContainer,key:"custom-text-elements"},e.map((e,t)=>{const[i,a]=Object.entries(e)[0];return"date"===i?null:S("calcite-label",{key:`custom-text-elements-${i}-${t}`},i,S("calcite-input",{bind:this,"data-input-custom":!0,"data-input-name":i,value:a??"",onCalciteInputInput:this._updateInputValue}))})):null}_renderTitleOrFileNameSection(){const{title:e,fileName:t,titlePlaceHolder:i,fileNamePlaceHolder:a}=this.messages,l="layoutTab"===this._selectedTab?e:t,o="layoutTab"===this._selectedTab?i:a,n="layoutTab"===this._selectedTab?this.templateOptions.title:this.templateOptions.fileName;return S("div",{class:M.formSectionContainer,key:l},S("calcite-label",null,l,S("calcite-input",{placeholder:o,value:n??"",onCalciteInputInput:this._onInput})))}_focusOnTabChange(e){if(!this._activeTabFocusRequested)return;const t=e.getAttribute("data-tab-id");("layoutTab"===t&&"layoutTab"===this._selectedTab||"mapOnlyTab"===t&&"mapOnlyTab"===this._selectedTab||"exportTab"===t&&"exportTab"===this._selectedTab)&&(e.focus(),this._activeTabFocusRequested=!1)}_renderLoader(){const e={[M.loader]:this._awaitingServerResponse};return S("div",{class:this.classes(e),key:"loader"})}_resetToCurrentScale(){this.templateOptions.scale=this.viewModel.view?.scale}_updateCustomTextElementValue(e,t,i){e.find(e=>{const[i]=Object.entries(e)[0];return i===t})[t]=i}_updateInputValue(e){const t=e.currentTarget,i=t.getAttribute("data-input-name"),a=!!t["data-input-custom"],{templateOptions:l}=this;a?this._updateCustomTextElementValue(l.customTextElements,i,t.value):l[i]=t.value}_updateNumberInputValue(e){const t=e.currentTarget,i=t.getAttribute("data-input-name"),{templateOptions:a}=this,l=Number(t.value);if(!F(l)){const e=a[i];return void(t.value=`${e}`)}a[i]=l}_handlePrintMap(){this._pendingExportScroll=!0;const{templateOptions:e}=this,t="layoutTab"===this._selectedTab?e.title:e.fileName,{promise:i}=this.viewModel.export(t||this.messages.untitled);this._selectedTab="exportTab",i.then(()=>this.scheduleRender())}_switchInput(){[this.templateOptions.width,this.templateOptions.height]=[this.templateOptions.height,this.templateOptions.width]}_scrollExportIntoView(){if(!this._pendingExportScroll)return;this._pendingExportScroll=!1;const e=this._rootNode;if(!e)return;const{clientHeight:t,scrollHeight:i}=e,a=i-t;a>0&&(e.scrollTop=a)}_toggleInputValue(e){const t=e.target,i=t.getAttribute("data-option-name");this.templateOptions[i]=t.checked,"scaleEnabled"===i&&this._resetToCurrentScale()}_renderExportedLinkItemPopover(e){const t=this.messages,i=e.formattedName??"",{state:a}=e,l=this.saveAsButtonCallback&&"error"!==a&&this._isFormatAllowedForSaving(e.extension);return"pending"!==a&&l?S("calcite-popover",{autoClose:!0,key:`${i}-popover`,label:"Popover",offsetDistance:1,overlayPositioning:"fixed",pointerDisabled:!0,referenceElement:`${i}-popover-button`,scale:"s"},S("calcite-list",{label:""},e.portalItem?S("calcite-list-item",{label:t.openItem,onCalciteListItemSelect:()=>{const t=e.portalItem;if(!t||!t.itemPageUrl)return;const i=document.createElement("a");i.target="_blank",i.href=t.itemPageUrl,i.rel="noreferrer",i.click()}},S("calcite-icon",{icon:"launch2",key:`${i}-launch-icon`,scale:"s",slot:"content-start"})):S("calcite-list-item",{label:t.saveAs,onCalciteListItemSelect:async()=>{this.saveAsButtonCallback&&(s(()=>e.portalItem).then(e=>{e.itemPageUrl&&this.scheduleRender()}),await this.saveAsButtonCallback(e))}},S("calcite-icon",{icon:"save",key:`${i}-save-icon`,scale:"s",slot:"content-start"})),S("calcite-list-item",{label:this.messagesCommon.delete,onCalciteListItemSelect:()=>this.exportedLinks.remove(e)},S("calcite-icon",{icon:"trash",key:`${i}-delete-icon`,scale:"s",slot:"content-start"})))):null}_renderExportedLinkItemContent(e){const t=this.messages,{url:i,state:a,error:l}=e,o=e.formattedName??"";let n=i||null;n&&(n=c(n));const s=p(n,location.href),r="error"===a?"print-task:cim-symbol-unsupported"===l?.name?t.exportWebMapCIMError:t.exportWebMapError:null;return S("div",{class:M.exportedFile,"data-item":e,onclick:this._handleLinkClick,slot:"content"},S("div",null,S("div",{class:M.exportedFileLinkTitle},o),S("div",{class:M.exportedFileLinkDescription},"pending"===a?t.generatingExport:r||(s?t.ready:t.linkReady))),"ready"===a?S("calcite-icon",{"aria-label":`${o}. ${t.linkReady}`,icon:s?"download-to":"launch",key:`${o}-end-icon`,scale:"s",slot:"content-end"}):null)}_renderExportedLinkItemIcon(e){const t=e.formattedName??"";return"pending"===e.state?S("calcite-loader",{class:M.exportedFileLoader,inline:!0,key:`${t}-loader`,label:this.messages.generatingExport,scale:"m",slot:"content-start"}):S("calcite-icon",{icon:A(e),key:`${t}-start-icon`,scale:"s",slot:"content-start"})}_renderExportedLinkItemAction(e){const{state:t}=e,i=e.formattedName??"",a=this.saveAsButtonCallback&&"error"!==t&&this._isFormatAllowedForSaving(e.extension);return"pending"!==t?S("calcite-action",{icon:a?"ellipsis":"x",id:a?`${i}-popover-button`:void 0,key:a?`${i}-saveAs-action`:`${i}-action`,onclick:a?void 0:()=>{this.exportedLinks.remove(e)},slot:"actions-end",text:a?this.messagesCommon.options:this.messagesCommon.remove}):null}_renderExportedLinkItem(e){const t=e.formattedName??"";return S(O,null,S("calcite-list-item",{key:t,label:t},this._renderExportedLinkItemContent(e),this._renderExportedLinkItemIcon(e),this._renderExportedLinkItemAction(e)),this._renderExportedLinkItemPopover(e))}_renderExportedLinkItems(e){return S("calcite-list",{filterEnabled:e?.length>10,label:this.messages.exportedLinksList,selectionMode:"none"},e.map(this._renderExportedLinkItem.bind(this)))}_isFormatAllowedForSaving(e){return!this.allowedFormatsForSaving||"all"===this.allowedFormatsForSaving||!(!e||!this.allowedFormatsForSaving.includes(e))}_toggleLayoutPanel(e){const t=e.target;this._toggleTab(t.getAttribute("data-tab-id"))}_toggleTab(e,t=!0){if(this._selectedTab=e,"mapOnlyTab"===this._selectedTab)this.viewModel.applyTemplate($);else if("layoutTab"===this._selectedTab){const e=this._selectedTemplate??this.viewModel.defaultTemplate;this.viewModel.applyTemplate(e)}t&&(this._activeTabFocusRequested=!0)}_handleLayoutPanelKeyDown(e){const{key:t}=e,i=e.target.getAttribute("data-tab-id");if(E(t))return this._toggleTab(i),e.preventDefault(),void e.stopPropagation();if("ArrowLeft"===t||"ArrowRight"===t){switch(i){case"layoutTab":this._toggleTab("ArrowLeft"===t?"exportTab":"mapOnlyTab");break;case"mapOnlyTab":this._toggleTab("ArrowLeft"===t?"layoutTab":"exportTab");break;case"exportTab":this._toggleTab("ArrowLeft"===t?"mapOnlyTab":"layoutTab")}e.preventDefault(),e.stopPropagation()}}};e([d()],N.prototype,"_showTemplates",void 0),e([d()],N.prototype,"_isValidSpatialReference",void 0),e([d()],N.prototype,"allowedFormats",null),e([d()],N.prototype,"allowedFormatsForSaving",void 0),e([d()],N.prototype,"allowedLayouts",null),e([d()],N.prototype,"browseTemplateButtonOnClick",void 0),e([d()],N.prototype,"error",null),e([d()],N.prototype,"exportedLinks",null),e([d()],N.prototype,"extraParameters",null),e([d()],N.prototype,"headerVisible",void 0),e([d()],N.prototype,"headingLevel",void 0),e([d()],N.prototype,"icon",null),e([d()],N.prototype,"includeDefaultTemplates",null),e([d()],N.prototype,"includeOrganizationTemplates",void 0),e([d()],N.prototype,"label",null),e([d(),C("esri/widgets/Print/t9n/Print")],N.prototype,"messages",void 0),e([d(),C("esri/t9n/common")],N.prototype,"messagesCommon",void 0),e([d(),C("esri/core/t9n/Units")],N.prototype,"messagesUnits",void 0),e([d({type:h})],N.prototype,"outSpatialReference",null),e([d()],N.prototype,"portal",null),e([d()],N.prototype,"saveExportEnabled",null),e([d()],N.prototype,"saveExportHidden",void 0),e([d()],N.prototype,"showPrintAreaEnabled",null),e([d()],N.prototype,"printServiceUrl",null),e([d()],N.prototype,"saveAsButtonCallback",void 0),e([d()],N.prototype,"templateCustomTextElements",null),e([d()],N.prototype,"templateOptions",null),e([d()],N.prototype,"view",null),e([d({type:y})],N.prototype,"viewModel",void 0),N=e([m("esri.widgets.Print")],N);const V=N;export{V as default};
5
+ import{__decorate as e}from"tslib";import{formatNumber as t}from"../intl.js";import i from"../core/Collection.js";import{deprecateWidget as a}from"../core/deprecate.js";import{JSONMap as l}from"../core/jsonMap.js";import o from"../core/Logger.js";import{watch as n,on as s,whenOnce as r}from"../core/reactiveUtils.js";import{unitName as c}from"../core/unitFormatUtils.js";import{addProxy as p,hasSameOrigin as d}from"../core/urlUtils.js";import{property as m,subclass as u}from"../core/accessorSupport/decorators.js";import{ensureInteger as h}from"../core/accessorSupport/ensureType.js";import b from"../geometry/SpatialReference.js";import{isValid as _}from"../geometry/support/spatialReferenceUtils.js";import v from"../portal/Portal.js";import{reArcGISOnlineDomain as g}from"../portal/support/urlUtils.js";import{findToken as f}from"../rest/utils.js";import{formatJsonMap as y}from"../rest/support/fileFormat.js";import T from"./Widget.js";import w from"./Print/FileLink.js";import k from"./Print/PrintViewModel.js";import x from"./Print/TemplateOptions.js";import{loadCalciteComponents as C}from"./support/componentsUtils.js";import{globalCss as S}from"./support/globalCss.js";import{Heading as I}from"./support/Heading.js";import{legacyIcon as O}from"./support/legacyIcon.js";import{messageBundle as E,tsx as L,isRTL as $,tsxFragment as M,isActivationKey as F}from"./support/widget.js";const P="map-only",A="esri-print",R={base:A,headerTitle:`${A}__header-title`,layoutTabList:`${A}__layout-tab-list`,layoutTab:`${A}__layout-tab`,layoutSection:`${A}__layout-section`,mapOnlySection:`${A}__map-only-section`,panelItemsCentered:`${A}__panel-items--centered`,loader:`${A}__loader`,swapButton:`${A}__swap-button`,printButton:`${A}__export-button`,printButtonSection:`${A}__export-button-section`,printButtonSectionDivider:`${A}__export-button-section--divider`,templateSelectContainer:`${A}__template-select-container`,templateSelectIcon:`${A}__template-select-icon`,templateSelectError:`${A}__template-select-error`,templateSelectArrow:`${A}__template-select-arrow`,formSectionContainer:`${A}__form-section-container`,advancedOptionsSection:`${A}__advanced-options-section`,advancedOptionsContainer:`${A}__advanced-options-container`,browseTemplateButtonContainer:`${A}__browse-template-button-container`,browseTemplateButtonContainerFilter:`${A}__browse-template-button-container-filter`,exportedFilesContainer:`${A}__export-panel-container`,exportedFilesTitle:`${A}__export-title`,exportedFile:`${A}__exported-file`,exportedFileLinkTitle:`${A}__exported-file-link-title`,exportedFileLinkDescription:`${A}__exported-file-link-description`,exportedFilesEmpty:`${A}__exported-files-empty`,printWidgetContainer:`${A}__container`,content:`${A}__content`,panelContainer:`${A}__panel-container`,scaleInfoContainer:`${A}__scale-info-container`,scaleInputContainer:`${A}__scale-input-container`,scaleInput:`${A}__scale-input`,sizeContainer:`${A}__size-container`,panelError:`${A}__panel--error`,exportedFileLoader:`${A}__exported-file--loader`,exportSection:`${A}__export-section`,exportSectionCentered:`${A}__export-section--centered`,templateButtonContainer:`${A}__template-button-container`,templateDoneButton:`${A}__template-done-button`,templateSelectFlowItemContainer:`${A}__template-select-flow-item-container`,templateSelectFlowItemContent:`${A}__template-select-flow-item-content`,templateSelectFlowItemListHeading:`${A}__template-select-flow-item-list-heading`,srLabel:`${A}__sr-label`,invalidWkidText:`${A}__invalid-wkid-text`};function B(e){return!isNaN(e)&&e>0&&Number.isFinite(e)}function N(e){return e?.toLowerCase()===P}function V(e){const{state:t,extension:i}=e;switch(t){case"pending":return"spinner";case"error":return"exclamation-mark-circle";default:return i?.toLowerCase()?.includes("pdf")?"file-pdf":"file"}}const D=new l({inch:"inches",foot:"feet",yard:"yards",mile:"miles","nautical-mile":"nautical-miles",millimeter:"millimeters",centimeter:"centimeters",decimeter:"decimeters",meter:"meters",kilometer:"kilometers"}),j=new Map([["a3-landscape","a3-landscape"],["a3-portrait","a3-portrait"],["a4-landscape","a4-landscape"],["a4-portrait","a4-portrait"],["letter-ansi-a-landscape","ansi-a-landscape"],["letter-ansi-a-portrait","ansi-a-portrait"],["tabloid-ansi-b-landscape","ansi-b-landscape"],["tabloid-ansi-b-portrait","ansi-b-portrait"]]);let U=class extends T{constructor(e,t){super(e,t),this._activeTabFocusRequested=!1,this._awaitingServerResponse=!1,this._selectedTab="layoutTab",this._pendingExportScroll=!1,this._rootNode=null,this._selectedTemplate=null,this._formats=[],this._showTemplates=!1,this._isValidSpatialReference=!0,this.allowedFormatsForSaving=null,this.browseTemplateButtonOnClick=null,this.headerVisible=!0,this.headingLevel=3,this.includeOrganizationTemplates=!0,this.messagesCommon=null,this.messagesUnits=null,this.saveExportHidden=!0,this.saveAsButtonCallback=null,this.viewModel=new k,this._onInput=e=>{"layoutTab"===this._selectedTab?this.templateOptions.title=e.currentTarget.value:"mapOnlyTab"===this._selectedTab&&(this.templateOptions.fileName=e.currentTarget.value)},this._handleLinkClick=e=>{const t=e.currentTarget["data-item"];if(!t||"ready"!==t.state||!t.url)return;const i=f(this.viewModel.effectivePrintServiceUrl),a=t.url,l=document.createElement("a");if(l.target="_blank",l.href=a,l.rel="noreferrer",l.download=t.formattedName??"",!i)return l.click(),void e.stopPropagation();e.preventDefault();const o=new URL(a);o.searchParams.set("token",i),l.href=o.href,l.click(),l.href=a},a(o.getLogger(this),"Print","arcgis-print",{version:"4.33"}),this._focusOnTabChange=this._focusOnTabChange.bind(this)}initialize(){this.addHandles([n(()=>[this.templateOptions.format,this.viewModel.templatesInfo?.format],()=>{const{templatesInfo:e}=this.viewModel;if(!e)return;if(this._formats.length!==e.format.choiceList.length){const t=y.apiValues;this._formats=e.format.choiceList.map(e=>{const i=t.find(t=>new RegExp(`\\b${t}\\b`,"i").test(e))??e;return{value:i,label:e===i?e.toUpperCase():e}}).sort((e,t)=>e.label.localeCompare(t.label))}const t=this._formats.some(({value:e})=>new RegExp(`\\b${e}\\b`,"i").test(this.templateOptions.format));if(e.format.defaultValue&&!t){const t=this._formats.find(({value:t})=>new RegExp(`\\b${t}\\b`,"i").test(e.format.defaultValue))?.value;return void(t&&(this.templateOptions.format=t))}}),n(()=>[this.templateOptions.id,this.viewModel.loaded],()=>{const{layout:e}=this.templateOptions;this._selectedTab=N(e)?"mapOnlyTab":"layoutTab","layoutTab"===this._selectedTab&&this.viewModel.loaded&&(this._selectedTemplate=this.viewModel.getLayoutTemplateById(this.templateOptions.id))}),n(()=>this.templateOptions.dpi,e=>{e<=0&&(this.templateOptions.dpi=1)}),n(()=>this.viewModel.view?.scale,e=>{!e||this.templateOptions.scaleEnabled&&this.templateOptions.scale||(this.templateOptions.scale=e)}),s(()=>this.viewModel,"submit",e=>this.emit("submit",e)),s(()=>this.viewModel,"complete",e=>this.emit("complete",e))]);const{height:e,width:t}=this.templateOptions;this.templateOptions.width=t||800,this.templateOptions.height=e||1100;const i=setTimeout(()=>{this._awaitingServerResponse=!0,this.scheduleRender()},500);this.viewModel.load().then(()=>{clearTimeout(i),this._awaitingServerResponse=!1})}loadDependencies(){return C({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),block:()=>import("@esri/calcite-components/dist/components/calcite-block"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),checkbox:()=>import("@esri/calcite-components/dist/components/calcite-checkbox"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),input:()=>import("@esri/calcite-components/dist/components/calcite-input"),"input-number":()=>import("@esri/calcite-components/dist/components/calcite-input-number"),label:()=>import("@esri/calcite-components/dist/components/calcite-label"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch"),chip:()=>import("@esri/calcite-components/dist/components/calcite-chip"),popover:()=>import("@esri/calcite-components/dist/components/calcite-popover"),link:()=>import("@esri/calcite-components/dist/components/calcite-link")})}destroy(){this.viewModel.destroy()}get allowedFormats(){return this.viewModel.allowedFormats}set allowedFormats(e){this.viewModel.allowedFormats=e}get allowedLayouts(){return this.viewModel.allowedLayouts}set allowedLayouts(e){this.viewModel.allowedLayouts=e}get error(){return this.viewModel.error}get exportedLinks(){return this.viewModel.exportedLinks}set exportedLinks(e){this.viewModel.exportedLinks=e}get extraParameters(){return this.viewModel.extraParameters}set extraParameters(e){this.viewModel.extraParameters=e}get icon(){return"print"}set icon(e){this._overrideIfSome("icon",e)}get includeDefaultTemplates(){return this.viewModel.includeDefaultTemplates}set includeDefaultTemplates(e){this.viewModel.includeDefaultTemplates=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get outSpatialReference(){return this.viewModel.outSpatialReference}set outSpatialReference(e){this.viewModel.outSpatialReference=e}get portal(){return this.viewModel.portal}set portal(e){this.viewModel.portal=e}get saveExportEnabled(){return this.viewModel.saveExportEnabled}set saveExportEnabled(e){this.viewModel.saveExportEnabled=e}get showPrintAreaEnabled(){return this.viewModel.showPrintAreaEnabled}set showPrintAreaEnabled(e){this.viewModel.showPrintAreaEnabled=e}get printServiceUrl(){return this.viewModel.printServiceUrl}set printServiceUrl(e){this.viewModel.printServiceUrl=e}get templateCustomTextElements(){return this.viewModel.templateCustomTextElements}set templateCustomTextElements(e){this.viewModel.templateCustomTextElements=e}get templateOptions(){return this.viewModel.templateOptions}set templateOptions(e){this.viewModel.templateOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}render(){const{messages:e,templateOptions:t,viewModel:i,view:a}=this,{attributionEnabled:l,author:o,copyright:n,dpi:s,format:r,height:c,layout:p,layoutItem:d,legendEnabled:m,northArrowEnabled:u,scaleBarEnabled:v,scaleEnabled:g,scale:f,width:y}=t,T="ready"!==i.state||this._awaitingServerResponse||!(p||d),w=this._renderTitleOrFileNameSection(),k=L("div",{class:R.formSectionContainer},L("calcite-label",null,e.fileFormatTitle,L("calcite-combobox",{clearDisabled:!0,label:e.formatDefaultOption,maxItems:6,placeholder:e.formatDefaultOption,selectionMode:"single-persist",onCalciteComboboxChange:({currentTarget:e})=>{this.templateOptions.format=e.selectedItems[0]?.value??"pdf"}},this._formats.map(({value:e,label:t},i)=>L("calcite-combobox-item",{key:`file-format-${i}`,selected:e===this.templateOptions.format,textLabel:t,value:e}))))),x=L("calcite-label",{layout:"inline"},L("calcite-switch",{checked:this.showPrintAreaEnabled,onCalciteSwitchChange:e=>{this.showPrintAreaEnabled=!!e.currentTarget.checked}}),e.printPreview),C=L("div",null,L("div",{class:R.formSectionContainer},L("calcite-label",null,e.template,L("calcite-block",{class:R.templateSelectContainer,collapsible:!1,description:this._getPageSizeLabel(this._selectedTemplate),heading:this._getTemplateLabel(this._selectedTemplate,!0),key:"template-select-block",label:e.template,loading:"loading"===this._selectedTemplate?.state,onclick:()=>this._showTemplates=!0,onkeydown:e=>{"Enter"!==e.key&&" "!==e.key||(this._showTemplates=!0)},tabIndex:0},L("calcite-icon",{class:R.templateSelectIcon,icon:(this._selectedTemplate?.layout?j.get(this._selectedTemplate.layout):null)||"custom-print",key:"template-select-icon",scale:"l",slot:"content-start"}),"error"===this._selectedTemplate?.state?L("calcite-icon",{class:R.templateSelectError,icon:"exclamation-mark-circle",key:"template-select-error",scale:"s",slot:"actions-end"}):null,L("calcite-icon",{class:R.templateSelectArrow,icon:$()?"chevron-left":"chevron-right",key:"template-select-arrow",scale:"s",slot:"actions-end"})))),x),E=L("div",{class:R.formSectionContainer},L("calcite-label",null,e.dpi,L("calcite-input-number",{bind:this,"data-input-name":"dpi",min:1,value:`${s}`,onCalciteInputNumberInput:this._updateNumberInputValue}))),M=L("div",{class:R.formSectionContainer},L("calcite-label",null,L("div",{class:R.srLabel},e.outSpatialReference,L("calcite-link",{href:"https://developers.arcgis.com/rest/services-reference/enterprise/using-spatial-references/",target:"_blank"},"(WKID)")),L("calcite-input-number",{bind:this,"data-input-name":"outSpatialReference",integer:!0,numberButtonType:"none",value:i.outSpatialReference?.wkid?.toString()??"",onCalciteInputNumberInput:({currentTarget:e})=>{const t=h(e.value);i.outSpatialReference=Number.isNaN(t)||null==t?null:new b({wkid:t}),this._isValidSpatialReference=!i.outSpatialReference||_(i.outSpatialReference)}}),this._isValidSpatialReference?null:L("div",{class:R.invalidWkidText,key:`out-sr-${i.outSpatialReference?.wkid}`},e.invalidWkid))),F=L("div",{class:this.classes(R.scaleInfoContainer,R.formSectionContainer)},L("calcite-label",{layout:"inline"},L("calcite-checkbox",{bind:this,checked:g,"data-option-name":"scaleEnabled",onCalciteCheckboxChange:this._toggleInputValue}),e.scale),L("div",{class:R.scaleInputContainer},L("calcite-input-number",{"aria-label":e.scaleLabel,"aria-valuenow":`${f}`,bind:this,class:R.scaleInput,"data-input-name":"scale",disabled:!g,value:`${f}`,onCalciteInputNumberInput:this._updateNumberInputValue}),L("calcite-button",{appearance:"outline","aria-label":e.reset,bind:this,disabled:!g,iconStart:"refresh",kind:"neutral",onclick:this._resetToCurrentScale}))),P=L("div",{"aria-labelledby":`${this.id}__advancedOptionsForLayout`,class:R.advancedOptionsContainer,key:"advanced-section-for-layout"},F,this._selectedTemplate?.layoutTemplateInfo?.layoutOptions?.hasAuthorText??1?L("div",{class:R.formSectionContainer,key:"author-info"},L("calcite-label",null,e.author,L("calcite-input",{bind:this,"data-input-name":"author",value:o??"",onCalciteInputInput:this._updateInputValue}))):null,this._selectedTemplate?.layoutTemplateInfo?.layoutOptions?.hasCopyrightText??1?L("div",{class:R.formSectionContainer,key:"copyright-text"},L("calcite-label",null,e.copyright,L("calcite-input",{bind:this,"data-input-name":"copyright",value:n??"",onCalciteInputInput:this._updateInputValue}))):null,E,M,this._renderCustomTextElementSection(),this._selectedTemplate?.layoutTemplateInfo?.layoutOptions?.hasLegend??1?L("div",{class:R.formSectionContainer,key:"legend-info"},L("calcite-label",{layout:"inline"},L("calcite-checkbox",{bind:this,checked:!!m,"data-option-name":"legendEnabled",onCalciteCheckboxChange:this._toggleInputValue}),e.legend)):null,this._selectedTemplate?.mapSurroundInfoOptions?.northArrow.length?L("div",{class:R.formSectionContainer,key:"north-arrow"},L("calcite-label",{layout:"inline"},L("calcite-checkbox",{bind:this,checked:!!u,"data-option-name":"northArrowEnabled",onCalciteCheckboxChange:this._toggleInputValue}),e.northArrow)):null,this._selectedTemplate?.mapSurroundInfoOptions?.scaleBar.length?L("div",{class:R.formSectionContainer,key:"scale-bar"},L("calcite-label",{layout:"inline"},L("calcite-checkbox",{bind:this,checked:!!v,"data-option-name":"scaleBarEnabled",onCalciteCheckboxChange:this._toggleInputValue}),e.scaleBar)):null),A=L("div",{"aria-labelledby":`${this.id}__advancedOptionsForMapOnly`,class:R.advancedOptionsContainer},F,E,M,L("div",{class:R.formSectionContainer},L("calcite-label",{layout:"inline"},L("calcite-checkbox",{bind:this,checked:l,"data-option-name":"attributionEnabled",onCalciteCheckboxChange:this._toggleInputValue}),e.attribution)),this._renderCustomTextElementSection()),B=this.exportedLinks.toArray(),N=this._renderExportedLinkItems(B),V={[R.exportSectionCentered]:!B.length},D="layoutTab"===this._selectedTab?L("section",{"aria-labelledby":`${this.id}__layoutTab`,class:R.layoutSection,id:`${this.id}__layoutContent`,key:"esri-print__layoutContent",role:"tabpanel"},L("div",{class:R.panelContainer},this._selectedTemplate?.layoutTemplateInfo?.layoutOptions?.hasTitleText??1?w:null,C,"layoutTab"===this._selectedTab?k:null,L("calcite-block",{"aria-label":e.advancedOptions,class:this.classes(R.panelContainer,R.advancedOptionsSection),collapsible:!0,disabled:!(p||d?.id),heading:e.advancedOptions,id:"advancedOptionsForLayout",key:"advanced-options-for-layout"},P))):"mapOnlyTab"===this._selectedTab?L("section",{"aria-labelledby":`${this.id}__mapOnlyTab`,class:R.mapOnlySection,id:`${this.id}__mapOnlyContent`,key:"esri-print__mapOnlyContent",role:"tabpanel"},L("div",{class:R.panelContainer},w,k,L("div",null,L("div",{class:this.classes(R.sizeContainer,R.formSectionContainer)},L("calcite-label",null,e.width,L("calcite-input-number",{bind:this,"data-input-name":"width",value:`${y}`,onCalciteInputNumberInput:this._updateNumberInputValue})),L("calcite-label",null,e.height,L("calcite-input-number",{bind:this,"data-input-name":"height",value:`${c}`,onCalciteInputNumberInput:this._updateNumberInputValue})),L("button",{"aria-label":e.swap,bind:this,class:this.classes(S.widgetButton,R.swapButton,O.swap),onclick:this._switchInput,type:"button"})),x),L("calcite-block",{"aria-label":e.advancedOptions,class:this.classes(R.panelContainer,R.advancedOptionsSection),collapsible:!0,heading:e.advancedOptions,id:"advancedOptionsForMapOnly",key:"advanced-options-for-map-only"},A))):L("section",{"aria-labelledby":`${this.id}__exportTab`,class:this.classes(R.exportSection,V),id:`${this.id}__exportContent`,key:"esri-print__exportContent",role:"tabpanel"},L("div",{class:R.panelContainer},L("div",{afterUpdate:this._scrollExportIntoView,bind:this,class:R.exportedFilesContainer},0===B.length?L("div",{class:R.exportedFilesEmpty},L("calcite-icon",{icon:"file",scale:"l"}),L("div",null,L(I,{class:R.exportedFilesTitle,level:this.headingLevel},e.noExportedFiles),L("div",null,e.exportHint))):N))),U="2d"!==a?.type,H=L("div",{class:R.panelError},a?U?e.sceneViewError:e.serviceError:e.noViewError),z=B.some(({state:e})=>"pending"===e),W=L("div",{class:R.content,key:"panel"},L("div",null,L("ul",{bind:this,class:R.layoutTabList,onclick:this._toggleLayoutPanel,onkeydown:this._handleLayoutPanelKeyDown,role:"tablist"},L("li",{afterCreate:this._focusOnTabChange,afterUpdate:this._focusOnTabChange,"aria-selected":`${"layoutTab"===this._selectedTab}`,class:R.layoutTab,"data-tab-id":"layoutTab",id:`${this.id}__layoutTab`,role:"tab",tabIndex:0},e.layoutTab),L("li",{afterCreate:this._focusOnTabChange,afterUpdate:this._focusOnTabChange,"aria-selected":`${"mapOnlyTab"===this._selectedTab}`,class:R.layoutTab,"data-tab-id":"mapOnlyTab",id:`${this.id}__mapOnlyTab`,role:"tab",tabIndex:0},e.mapOnlyTab),L("li",{afterCreate:this._focusOnTabChange,afterUpdate:this._focusOnTabChange,"aria-selected":`${"exportTab"===this._selectedTab}`,class:R.layoutTab,"data-tab-id":"exportTab",id:`${this.id}__exportedFilesTab`,role:"tab",tabIndex:0},z?L("calcite-loader",{inline:!0,label:"loading",scale:"s"}):null,e.exportsTab)),D),"exportTab"!==this._selectedTab?L("div",{class:this.classes(R.printButtonSection,!this.saveExportHidden&&this.portal?R.printButtonSectionDivider:null),key:"export-button-section"},!this.saveExportHidden&&this.portal?L("calcite-label",{layout:"inline"},L("calcite-checkbox",{bind:this,checked:this.saveExportEnabled,onCalciteCheckboxChange:e=>{this.saveExportEnabled=!!e.currentTarget.checked}}),e.saveExportToMyContent):null,L("calcite-button",{"aria-label":e.exportDescription,bind:this,class:this.classes(R.printButton),disabled:T||!(p||d?.id)&&!r,onclick:this._handlePrintMap,scale:"l",width:"full"},e.export)):null),q=L("calcite-flow",{key:"root-flow"},L("calcite-flow-item",{bind:this,key:"root-flow-item",selected:!this._showTemplates},L("div",{class:R.printWidgetContainer},this.headerVisible?L("header",{class:R.headerTitle},e.export):null,this.error||U||!a?H:W)),this._renderChooseTemplateFlowItem()),K="initializing"===i.state,J=K?this._renderLoader():q,G={[R.panelItemsCentered]:K};return L("div",{bind:this,class:this.classes(R.base,S.widget,S.panel,G)},J)}_getPageSizeLabel(e){if(!e)return;const i=e.layoutTemplateInfo;if(!i)return;const a=D.fromJSON(i.pageUnits.toLowerCase());return`${t(i.pageSize[0])} × ${t(i.pageSize[1])} ${c(this.messagesUnits,a,"abbr")}`}_getTemplateLabel(e,t=!1){if(!e)return t?this.messages.selectTemplate:this.messages.untitled;const{label:i,layout:a,layoutItem:l,type:o}=e;if("print-service-template"===o&&this.messages[a])return this.messages[a];const n=i??a??l?.id;return n?.replaceAll("_"," ")??this.messages.untitled}_getPortalTemplates(){const{portalTemplateIds:e}=this.viewModel;return this.includeDefaultTemplates&&this.includeOrganizationTemplates?this.viewModel.defaultTemplates.toArray().filter(({layout:t,layoutItem:i})=>!N(t)&&!!i?.id&&e.includes(i.id)):[]}_getDefaultTemplates(){const{portalTemplateIds:e}=this.viewModel;return this.includeDefaultTemplates?this.viewModel.defaultTemplates.toArray().filter(({layout:t,layoutItem:i})=>!(N(t)||i?.id&&e.includes(i.id))):[]}_getPrintServiceTemplates(){return this.includeDefaultTemplates&&this._getDefaultTemplates().length?[]:this.viewModel.printServiceTemplates.toArray().filter(({layout:e})=>!N(e))}_renderLayoutTemplates(e,t=!1,i=!1){return t&&e.sort((e,t)=>(e.label??"")>(t.label??"")?1:-1),e.map(e=>L("calcite-list-item",{description:this._getPageSizeLabel(e),key:`template-${e.id}-${e.id===this.templateOptions.id}`,label:this._getTemplateLabel(e),selected:e.id===this.templateOptions.id,title:e.description??"",value:e},L("calcite-icon",{icon:(e.layout?j.get(e.layout):null)||"custom-print",slot:"content-start"}),"loading"===e.state?L("calcite-loader",{inline:!0,key:`template-loader-${e.id}`,label:"loading",scale:"s",slot:"content-end"}):null,"error"===e?.state?L("calcite-icon",{class:R.templateSelectError,icon:"exclamation-mark-circle",key:`template-error-${e.id}`,scale:"s",slot:"content-end"}):null,i?L("calcite-action",{icon:"trash",onclick:()=>this.viewModel.removePortalTemplate(e),slot:"actions-end",text:"delete"}):null))}_renderChooseTemplateFlowItem(){if(!this._showTemplates)return null;const{messages:e}=this,t=g.test(this.portal?.url),i=this.viewModel.browseTemplates.toArray(),a=this._getPortalTemplates(),l=this._getDefaultTemplates(),o=this._getPrintServiceTemplates(),n=i.length+a.length+l.length+o.length>15,s=this.browseTemplateButtonOnClick?L("calcite-button",{appearance:"outline",class:n?R.browseTemplateButtonContainerFilter:R.browseTemplateButtonContainer,iconStart:"folder",key:"browse-template-button",onclick:this.browseTemplateButtonOnClick,slot:n?"filter-actions-end":"default"},n?null:e.browseTemplates):null;return L("calcite-flow-item",{bind:this,closable:!1,heading:e.chooseTemplate,key:"template-flow-item",selected:this._showTemplates,onCalciteFlowItemBack:e=>{e.preventDefault(),this._showTemplates=!1}},L("div",{class:R.templateSelectFlowItemContainer},L("div",{class:R.templateSelectFlowItemContent},n?null:s,L("calcite-list",{filterEnabled:n,filterProps:["label"],key:"template-list",label:e.templateList,selectionMode:"single-persist",onCalciteListChange:({currentTarget:e})=>this.viewModel.applyTemplate(e.selectedItems[0]?.value)},n?s:null,i.length?L("div",{key:"my-templates"},L("div",{class:R.templateSelectFlowItemListHeading},e.myTemplates,t?L("calcite-chip",{appearance:"outline",kind:"neutral",label:e.beta,scale:"s"},e.beta):null),this._renderLayoutTemplates(i,!0,!0)):null,a.length?L("div",{key:"org-templates"},L("div",{class:R.templateSelectFlowItemListHeading},e.organizationTemplates,t?L("calcite-chip",{appearance:"outline",kind:"neutral",label:e.beta,scale:"s"},e.beta):null),this._renderLayoutTemplates(a)):null,i.length||a.length?l.length?L("div",{key:"default-templates"},L("div",{class:R.templateSelectFlowItemListHeading},e.defaultTemplates),this._renderLayoutTemplates(l,!0)):null:this._renderLayoutTemplates(l,!0),i.length||a.length?o.length?L("div",{key:"service-templates"},L("div",{class:R.templateSelectFlowItemListHeading},e.defaultTemplates),this._renderLayoutTemplates(o)):null:this._renderLayoutTemplates(o))),L("div",{class:R.templateButtonContainer},L("calcite-button",{class:R.templateDoneButton,onclick:()=>this._showTemplates=!1},this.messagesCommon.done))))}_renderCustomTextElementSection(){const{customTextElements:e}=this.templateOptions;return e?L("div",{class:R.formSectionContainer,key:"custom-text-elements"},e.map((e,t)=>{const[i,a]=Object.entries(e)[0];return"date"===i?null:L("calcite-label",{key:`custom-text-elements-${i}-${t}`},i,L("calcite-input",{bind:this,"data-input-custom":!0,"data-input-name":i,value:a??"",onCalciteInputInput:this._updateInputValue}))})):null}_renderTitleOrFileNameSection(){const{title:e,fileName:t,titlePlaceHolder:i,fileNamePlaceHolder:a}=this.messages,l="layoutTab"===this._selectedTab?e:t,o="layoutTab"===this._selectedTab?i:a,n="layoutTab"===this._selectedTab?this.templateOptions.title:this.templateOptions.fileName;return L("div",{class:R.formSectionContainer,key:l},L("calcite-label",null,l,L("calcite-input",{placeholder:o,value:n??"",onCalciteInputInput:this._onInput})))}_focusOnTabChange(e){if(!this._activeTabFocusRequested)return;const t=e.getAttribute("data-tab-id");("layoutTab"===t&&"layoutTab"===this._selectedTab||"mapOnlyTab"===t&&"mapOnlyTab"===this._selectedTab||"exportTab"===t&&"exportTab"===this._selectedTab)&&(e.focus(),this._activeTabFocusRequested=!1)}_renderLoader(){const e={[R.loader]:this._awaitingServerResponse};return L("div",{class:this.classes(e),key:"loader"})}_resetToCurrentScale(){this.templateOptions.scale=this.viewModel.view?.scale}_updateCustomTextElementValue(e,t,i){e.find(e=>{const[i]=Object.entries(e)[0];return i===t})[t]=i}_updateInputValue(e){const t=e.currentTarget,i=t.getAttribute("data-input-name"),a=!!t["data-input-custom"],{templateOptions:l}=this;a?this._updateCustomTextElementValue(l.customTextElements,i,t.value):l[i]=t.value}_updateNumberInputValue(e){const t=e.currentTarget,i=t.getAttribute("data-input-name"),{templateOptions:a}=this,l=Number(t.value);if(!B(l)){const e=a[i];return void(t.value=`${e}`)}a[i]=l}_handlePrintMap(){this._pendingExportScroll=!0;const{templateOptions:e}=this,t="layoutTab"===this._selectedTab?e.title:e.fileName,{promise:i}=this.viewModel.export(t||this.messages.untitled);this._selectedTab="exportTab",i.then(()=>this.scheduleRender())}_switchInput(){[this.templateOptions.width,this.templateOptions.height]=[this.templateOptions.height,this.templateOptions.width]}_scrollExportIntoView(){if(!this._pendingExportScroll)return;this._pendingExportScroll=!1;const e=this._rootNode;if(!e)return;const{clientHeight:t,scrollHeight:i}=e,a=i-t;a>0&&(e.scrollTop=a)}_toggleInputValue(e){const t=e.target,i=t.getAttribute("data-option-name");this.templateOptions[i]=t.checked,"scaleEnabled"===i&&this._resetToCurrentScale()}_renderExportedLinkItemPopover(e){const t=this.messages,i=e.formattedName??"",{state:a}=e,l=this.saveAsButtonCallback&&"error"!==a&&this._isFormatAllowedForSaving(e.extension);return"pending"!==a&&l?L("calcite-popover",{autoClose:!0,key:`${i}-popover`,label:"Popover",offsetDistance:1,overlayPositioning:"fixed",pointerDisabled:!0,referenceElement:`${i}-popover-button`,scale:"s"},L("calcite-list",{label:""},e.portalItem?L("calcite-list-item",{label:t.openItem,onCalciteListItemSelect:()=>{const t=e.portalItem;if(!t||!t.itemPageUrl)return;const i=document.createElement("a");i.target="_blank",i.href=t.itemPageUrl,i.rel="noreferrer",i.click()}},L("calcite-icon",{icon:"launch2",key:`${i}-launch-icon`,scale:"s",slot:"content-start"})):L("calcite-list-item",{label:t.saveAs,onCalciteListItemSelect:async()=>{this.saveAsButtonCallback&&(r(()=>e.portalItem).then(e=>{e.itemPageUrl&&this.scheduleRender()}),await this.saveAsButtonCallback(e))}},L("calcite-icon",{icon:"save",key:`${i}-save-icon`,scale:"s",slot:"content-start"})),L("calcite-list-item",{label:this.messagesCommon.delete,onCalciteListItemSelect:()=>this.exportedLinks.remove(e)},L("calcite-icon",{icon:"trash",key:`${i}-delete-icon`,scale:"s",slot:"content-start"})))):null}_renderExportedLinkItemContent(e){const t=this.messages,{url:i,state:a,error:l}=e,o=e.formattedName??"";let n=i||null;n&&(n=p(n));const s=d(n,location.href),r="error"===a?"print-task:cim-symbol-unsupported"===l?.name?t.exportWebMapCIMError:t.exportWebMapError:null;return L("div",{class:R.exportedFile,"data-item":e,onclick:this._handleLinkClick,slot:"content"},L("div",null,L("div",{class:R.exportedFileLinkTitle},o),L("div",{class:R.exportedFileLinkDescription},"pending"===a?t.generatingExport:r||(s?t.ready:t.linkReady))),"ready"===a?L("calcite-icon",{"aria-label":`${o}. ${t.linkReady}`,icon:s?"download-to":"launch",key:`${o}-end-icon`,scale:"s",slot:"content-end"}):null)}_renderExportedLinkItemIcon(e){const t=e.formattedName??"";return"pending"===e.state?L("calcite-loader",{class:R.exportedFileLoader,inline:!0,key:`${t}-loader`,label:this.messages.generatingExport,scale:"m",slot:"content-start"}):L("calcite-icon",{icon:V(e),key:`${t}-start-icon`,scale:"s",slot:"content-start"})}_renderExportedLinkItemAction(e){const{state:t}=e,i=e.formattedName??"",a=this.saveAsButtonCallback&&"error"!==t&&this._isFormatAllowedForSaving(e.extension);return"pending"!==t?L("calcite-action",{icon:a?"ellipsis":"x",id:a?`${i}-popover-button`:void 0,key:a?`${i}-saveAs-action`:`${i}-action`,onclick:a?void 0:()=>{this.exportedLinks.remove(e)},slot:"actions-end",text:a?this.messagesCommon.options:this.messagesCommon.remove}):null}_renderExportedLinkItem(e){const t=e.formattedName??"";return L(M,null,L("calcite-list-item",{key:t,label:t},this._renderExportedLinkItemContent(e),this._renderExportedLinkItemIcon(e),this._renderExportedLinkItemAction(e)),this._renderExportedLinkItemPopover(e))}_renderExportedLinkItems(e){return L("calcite-list",{filterEnabled:e?.length>10,label:this.messages.exportedLinksList,selectionMode:"none"},e.map(this._renderExportedLinkItem.bind(this)))}_isFormatAllowedForSaving(e){return!this.allowedFormatsForSaving||"all"===this.allowedFormatsForSaving||!(!e||!this.allowedFormatsForSaving.includes(e))}_toggleLayoutPanel(e){const t=e.target;this._toggleTab(t.getAttribute("data-tab-id"))}_toggleTab(e,t=!0){if(this._selectedTab=e,"mapOnlyTab"===this._selectedTab)this.viewModel.applyTemplate(P);else if("layoutTab"===this._selectedTab){const e=this._selectedTemplate??this.viewModel.defaultTemplate;this.viewModel.applyTemplate(e)}t&&(this._activeTabFocusRequested=!0)}_handleLayoutPanelKeyDown(e){const{key:t}=e,i=e.target.getAttribute("data-tab-id");if(F(t))return this._toggleTab(i),e.preventDefault(),void e.stopPropagation();if("ArrowLeft"===t||"ArrowRight"===t){switch(i){case"layoutTab":this._toggleTab("ArrowLeft"===t?"exportTab":"mapOnlyTab");break;case"mapOnlyTab":this._toggleTab("ArrowLeft"===t?"layoutTab":"exportTab");break;case"exportTab":this._toggleTab("ArrowLeft"===t?"mapOnlyTab":"layoutTab")}e.preventDefault(),e.stopPropagation()}}};e([m()],U.prototype,"_showTemplates",void 0),e([m()],U.prototype,"_isValidSpatialReference",void 0),e([m()],U.prototype,"allowedFormats",null),e([m()],U.prototype,"allowedFormatsForSaving",void 0),e([m()],U.prototype,"allowedLayouts",null),e([m()],U.prototype,"browseTemplateButtonOnClick",void 0),e([m()],U.prototype,"error",null),e([m({type:i.ofType(w)})],U.prototype,"exportedLinks",null),e([m()],U.prototype,"extraParameters",null),e([m()],U.prototype,"headerVisible",void 0),e([m()],U.prototype,"headingLevel",void 0),e([m()],U.prototype,"icon",null),e([m()],U.prototype,"includeDefaultTemplates",null),e([m()],U.prototype,"includeOrganizationTemplates",void 0),e([m()],U.prototype,"label",null),e([m(),E("esri/widgets/Print/t9n/Print")],U.prototype,"messages",void 0),e([m(),E("esri/t9n/common")],U.prototype,"messagesCommon",void 0),e([m(),E("esri/core/t9n/Units")],U.prototype,"messagesUnits",void 0),e([m({type:b})],U.prototype,"outSpatialReference",null),e([m({type:v})],U.prototype,"portal",null),e([m()],U.prototype,"saveExportEnabled",null),e([m()],U.prototype,"saveExportHidden",void 0),e([m()],U.prototype,"showPrintAreaEnabled",null),e([m()],U.prototype,"printServiceUrl",null),e([m()],U.prototype,"saveAsButtonCallback",void 0),e([m()],U.prototype,"templateCustomTextElements",null),e([m({type:x})],U.prototype,"templateOptions",null),e([m()],U.prototype,"view",null),e([m({type:k})],U.prototype,"viewModel",void 0),U=e([u("esri.widgets.Print")],U);const H=U;export{H as default};