@arcgis/core 4.24.0-next.20220403 → 4.24.0-next.20220406

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 (388) hide show
  1. package/WebMap.js +1 -1
  2. package/WebScene.js +1 -1
  3. package/arcade/featureset/sources/FeatureLayerDynamic.js +1 -1
  4. package/assets/esri/core/workers/RemoteClient.js +1 -1
  5. package/assets/esri/core/workers/chunks/03ee49f9c0d3c7c696a2.js +1 -0
  6. package/assets/esri/core/workers/chunks/04a88084f2546a317c81.js +1 -0
  7. package/assets/esri/core/workers/chunks/{3fd5b2d6eccd9098d492.js → 091c60750f75d52d07b6.js} +1 -1
  8. package/assets/esri/core/workers/chunks/19a4bf366c809cdacaa4.js +1 -0
  9. package/assets/esri/core/workers/chunks/21ecf85529c5c5ec66a7.js +1 -0
  10. package/assets/esri/core/workers/chunks/27216e60b82b657fc157.js +1 -0
  11. package/assets/esri/core/workers/chunks/2865fd0e3f87f8ff996d.js +1 -0
  12. package/assets/esri/core/workers/chunks/28f90140fb451efb858e.js +1 -0
  13. package/assets/esri/core/workers/chunks/2b3549adc1acd27b09e6.js +1 -0
  14. package/assets/esri/core/workers/chunks/2f97efb8abead77c821c.js +1 -0
  15. package/assets/esri/core/workers/chunks/{c665e9b7d09fe516f138.js → 2fe10c5c01056babeae5.js} +1 -1
  16. package/assets/esri/core/workers/chunks/{ca6356e9eda262ba33ec.js → 31c1ae0532dd991da63d.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{8771296b537f366596c4.js → 37aa4532e25d54055e40.js} +54 -54
  18. package/assets/esri/core/workers/chunks/46ad3255bb3f5be60cd4.js +1 -0
  19. package/assets/esri/core/workers/chunks/49b327523a43232b3b18.js +1 -0
  20. package/assets/esri/core/workers/chunks/4b643f501819a7df2f69.js +1 -0
  21. package/assets/esri/core/workers/chunks/528033aa0d663b4d41bf.js +1 -0
  22. package/assets/esri/core/workers/chunks/5687474e19f99225f48e.js +1 -0
  23. package/assets/esri/core/workers/chunks/586ede983ab00d69fd1f.js +1 -0
  24. package/assets/esri/core/workers/chunks/64c785190d52c0001b29.js +1 -0
  25. package/assets/esri/core/workers/chunks/69af5851bc586fb1103f.js +1 -0
  26. package/assets/esri/core/workers/chunks/6a4fc1bea4ae5f09072a.js +1 -0
  27. package/assets/esri/core/workers/chunks/{0e29250c24a3a7b1ce13.js → 6de5a790c14f04c6c302.js} +1 -1
  28. package/assets/esri/core/workers/chunks/72483a52f82861441832.js +1 -0
  29. package/assets/esri/core/workers/chunks/88193e61072d7bf957f5.js +1 -0
  30. package/assets/esri/core/workers/chunks/{c58aa209492bd94b7aad.js → 8a5ff16ace69c6d89608.js} +1 -1
  31. package/assets/esri/core/workers/chunks/8ac516a4bc47987e186c.js +1 -0
  32. package/assets/esri/core/workers/chunks/{90dcd86cdef90099abfa.js → 8c50af01668496e1fec2.js} +1 -1
  33. package/assets/esri/core/workers/chunks/8e4dd5f46c5279bb5ba9.js +1 -0
  34. package/assets/esri/core/workers/chunks/b36068341e0cd79e7a75.js +1 -0
  35. package/assets/esri/core/workers/chunks/{2f6bff1aa485cf22527d.js → c181ac91bafa0a0d81e2.js} +1 -1
  36. package/assets/esri/core/workers/chunks/c7edd26be4d3c0852082.js +1 -0
  37. package/assets/esri/core/workers/chunks/ccb626429247093dfc7d.js +1 -0
  38. package/assets/esri/core/workers/chunks/cf2ce08bf9fe46336971.js +1 -0
  39. package/assets/esri/core/workers/chunks/d121fa4dbc49f39d78bf.js +1 -0
  40. package/assets/esri/core/workers/chunks/e2639b37c0153e7fcdd3.js +1 -0
  41. package/assets/esri/core/workers/chunks/f22616ef2a94990a049e.js +1 -0
  42. package/assets/esri/core/workers/chunks/fde6e26af42911e49e58.js +1 -0
  43. package/assets/esri/themes/dark/main.css +1 -1
  44. package/assets/esri/themes/dark-blue/main.css +1 -1
  45. package/assets/esri/themes/dark-green/main.css +1 -1
  46. package/assets/esri/themes/dark-purple/main.css +1 -1
  47. package/assets/esri/themes/dark-red/main.css +1 -1
  48. package/assets/esri/themes/light/main.css +1 -1
  49. package/assets/esri/themes/light/view.css +1 -1
  50. package/assets/esri/themes/light-blue/main.css +1 -1
  51. package/assets/esri/themes/light-green/main.css +1 -1
  52. package/assets/esri/themes/light-purple/main.css +1 -1
  53. package/assets/esri/themes/light-red/main.css +1 -1
  54. package/chunks/BlendLayers.glsl.js +1 -1
  55. package/chunks/DefaultMaterial.glsl.js +26 -26
  56. package/chunks/HUDMaterial.glsl.js +37 -37
  57. package/chunks/HighlightDownsample.glsl.js +1 -1
  58. package/chunks/ImageMaterial.glsl.js +10 -10
  59. package/chunks/LineMarker.glsl.js +75 -32
  60. package/chunks/RealisticTree.glsl.js +26 -26
  61. package/chunks/SMAA.glsl.js +2 -2
  62. package/chunks/SSAO.glsl.js +2 -2
  63. package/chunks/SimpleAtmosphere.glsl.js +10 -10
  64. package/chunks/TextureOnly.glsl.js +2 -2
  65. package/core/has.js +1 -1
  66. package/core/sql.js +1 -1
  67. package/geometry/support/meshUtils/primitives.js +1 -1
  68. package/interfaces.d.ts +346 -6172
  69. package/layers/MapNotesLayer.js +1 -1
  70. package/layers/SubtypeGroupLayer.js +1 -1
  71. package/layers/mixins/ArcGISImageService.js +1 -1
  72. package/layers/support/ElevationSampler.js +1 -1
  73. package/layers/support/ElevationTile.js +1 -1
  74. package/layers/support/ExportImageParameters.js +1 -1
  75. package/layers/support/Sublayer.js +1 -1
  76. package/layers/support/floorFilterUtils.js +5 -0
  77. package/layers/support/sublayerUtils.js +1 -1
  78. package/package.json +1 -1
  79. package/rest/identify.js +1 -1
  80. package/rest/operations/identify.js +1 -1
  81. package/rest/print.js +1 -1
  82. package/rest/support/IdentifyParameters.js +1 -1
  83. package/rest/utils.js +1 -1
  84. package/smartMapping/renderers/color.js +1 -1
  85. package/smartMapping/renderers/dotDensity.js +1 -1
  86. package/smartMapping/renderers/heatmap.js +1 -1
  87. package/smartMapping/renderers/location.js +1 -1
  88. package/smartMapping/renderers/predominance.js +1 -1
  89. package/smartMapping/renderers/relationship.js +1 -1
  90. package/smartMapping/renderers/size.js +1 -1
  91. package/smartMapping/renderers/type.js +1 -1
  92. package/smartMapping/symbology/color.js +1 -1
  93. package/smartMapping/symbology/dotDensity.js +1 -1
  94. package/smartMapping/symbology/flow.js +1 -1
  95. package/smartMapping/symbology/heatmap.js +1 -1
  96. package/smartMapping/symbology/location.js +1 -1
  97. package/smartMapping/symbology/predominance.js +1 -1
  98. package/smartMapping/symbology/relationship.js +1 -1
  99. package/smartMapping/symbology/size.js +1 -1
  100. package/smartMapping/symbology/type.js +1 -1
  101. package/support/revision.js +1 -1
  102. package/symbols/cim/ExpandedCIM.js +1 -1
  103. package/views/2d/engine/Stage.js +1 -1
  104. package/views/2d/engine/webgl/TileData.js +1 -1
  105. package/views/2d/engine/webgl/Utils.js +1 -1
  106. package/views/2d/engine/webgl/brushes/WGLGeometryBrushFill.js +1 -1
  107. package/views/2d/engine/webgl/enums.js +1 -1
  108. package/views/2d/engine/webgl/materialKey/MaterialKey.js +1 -1
  109. package/views/2d/engine/webgl/mesh/MeshData.js +1 -1
  110. package/views/2d/engine/webgl/mesh/templates/WGLBaseFillTemplate.js +1 -1
  111. package/views/2d/engine/webgl/mesh/templates/WGLBaseLineTemplate.js +1 -1
  112. package/views/2d/engine/webgl/mesh/templates/WGLLineTemplate.js +1 -1
  113. package/views/2d/engine/webgl/mesh/templates/WGLTemplateStore.js +1 -1
  114. package/views/2d/engine/webgl/shaders/MaterialPrograms.js +1 -1
  115. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  116. package/views/2d/input/MapViewInputManager.js +1 -1
  117. package/views/2d/input/handlers/GamepadNavigation.js +1 -1
  118. package/views/2d/layers/GeoRSSLayerView2D.js +1 -1
  119. package/views/2d/layers/MapNotesLayerView2D.js +1 -1
  120. package/views/2d/layers/SubtypeGroupLayerView2D.js +1 -1
  121. package/views/2d/layers/VectorTileLayerView2D.js +1 -1
  122. package/views/2d/layers/features/createSymbolSchema.js +1 -1
  123. package/views/2d/layers/features/processors/SymbolProcessor.js +1 -1
  124. package/views/2d/layers/features/schemaUtils.js +1 -1
  125. package/views/2d/layers/graphics/GraphicsView2D.js +1 -1
  126. package/views/2d/magnifier/MagnifierView2D.js +1 -1
  127. package/views/3d/environment/CloudsComposition.js +1 -1
  128. package/views/3d/environment/PanoramicAtmosphere.js +1 -1
  129. package/views/3d/environment/SimpleAtmosphere.glsl.js +1 -1
  130. package/views/3d/environment/SimpleAtmosphere.js +1 -1
  131. package/views/3d/environment/SimpleAtmosphereTechnique.js +1 -1
  132. package/views/3d/layers/SceneLayerView3D.js +1 -1
  133. package/views/3d/layers/graphics/Graphics3DFilterVisibility.js +1 -1
  134. package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
  135. package/views/3d/state/ConstraintsManager.js +1 -1
  136. package/views/3d/state/GoToOperation.js +1 -1
  137. package/views/3d/state/ViewStateManager.js +1 -1
  138. package/views/3d/support/ResourceController.js +1 -1
  139. package/views/3d/support/pointsOfInterest/CameraOnSurface.js +1 -1
  140. package/views/3d/support/pointsOfInterest/PointsOfInterest.js +1 -1
  141. package/views/3d/terrain/TerrainRenderer.js +1 -1
  142. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
  143. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechnique.js +1 -1
  144. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
  145. package/views/3d/webgl-engine/core/material/MaterialBase.js +1 -1
  146. package/views/3d/webgl-engine/core/material/RenderTexture.js +1 -1
  147. package/views/3d/webgl-engine/core/shaderLibrary/Slice.glsl.js +6 -6
  148. package/views/3d/webgl-engine/core/shaderLibrary/attributes/VertexTextureCoordinates.glsl.js +6 -6
  149. package/views/3d/webgl-engine/core/shaderLibrary/default/DefaultMaterialAuxiliaryPasses.glsl.js +3 -3
  150. package/views/3d/webgl-engine/core/shaderLibrary/shading/ComputeNormalTexture.glsl.js +5 -5
  151. package/views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateSceneLighting.glsl.js +12 -12
  152. package/views/3d/webgl-engine/core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js +7 -7
  153. package/views/3d/webgl-engine/core/shaderLibrary/shading/ReadBaseColorTexture.glsl.js +4 -9
  154. package/views/3d/webgl-engine/core/shaderModules/BooleanUniform.js +1 -1
  155. package/views/3d/webgl-engine/core/shaderModules/Float2Uniform.js +1 -1
  156. package/views/3d/webgl-engine/core/shaderModules/Float4Uniform.js +1 -1
  157. package/views/3d/webgl-engine/core/shaderModules/Float4sUniform.js +1 -1
  158. package/views/3d/webgl-engine/core/shaderModules/FloatUniform.js +1 -1
  159. package/views/3d/webgl-engine/core/shaderModules/FloatsUniform.js +1 -1
  160. package/views/3d/webgl-engine/core/shaderModules/IntegerUniform.js +1 -1
  161. package/views/3d/webgl-engine/core/shaderModules/Matrix3Uniform.js +1 -1
  162. package/views/3d/webgl-engine/core/shaderModules/Texture2DUniform.js +1 -1
  163. package/views/3d/webgl-engine/core/shaderModules/Uniform.js +1 -1
  164. package/views/3d/webgl-engine/core/shaderTechnique/BindType.js +1 -1
  165. package/views/3d/webgl-engine/lib/GLTextureMaterial.js +1 -1
  166. package/views/3d/webgl-engine/lib/Intersector.js +1 -1
  167. package/views/3d/webgl-engine/lib/Program.js +1 -1
  168. package/views/3d/webgl-engine/lighting/SceneLighting.js +1 -1
  169. package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
  170. package/views/3d/webgl-engine/materials/DefaultTechniqueConfiguration.js +1 -1
  171. package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
  172. package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
  173. package/views/3d/webgl-engine/materials/PathTechnique.js +1 -1
  174. package/views/3d/webgl-engine/materials/WaterTechnique.js +1 -1
  175. package/views/3d/webgl-engine/parts/RenderView.js +1 -1
  176. package/views/3d/webgl-engine/parts/ScreenshotManager.js +1 -1
  177. package/views/3d/webgl-engine/shaders/DefaultMaterial.glsl.js +1 -1
  178. package/views/3d/webgl-engine/shaders/DefaultMaterialTechnique.js +1 -1
  179. package/views/3d/webgl-engine/shaders/DefaultMaterialTechniqueConfiguration.js +1 -1
  180. package/views/3d/webgl-engine/shaders/HUDMaterial.glsl.js +1 -1
  181. package/views/3d/webgl-engine/shaders/HUDMaterialTechnique.js +1 -1
  182. package/views/3d/webgl-engine/shaders/ImageMaterial.glsl.js +1 -1
  183. package/views/3d/webgl-engine/shaders/ImageMaterialTechnique.js +1 -1
  184. package/views/3d/webgl-engine/shaders/LineMarkerTechnique.js +1 -1
  185. package/views/3d/webgl-engine/shaders/LineMarkerTechniqueConfiguration.js +1 -1
  186. package/views/3d/webgl-engine/shaders/RealisticTree.glsl.js +1 -1
  187. package/views/3d/webgl-engine/shaders/TerrainTechniqueConfiguration.js +1 -1
  188. package/views/MapView.js +1 -1
  189. package/views/SceneView.js +1 -1
  190. package/views/draw/support/GraphicMover.js +1 -1
  191. package/views/draw/support/layerUtils.js +1 -1
  192. package/views/layers/FeatureLayerView.js +1 -1
  193. package/views/layers/MapImageLayerView.js +1 -1
  194. package/views/support/GroundViewElevationSampler.js +1 -1
  195. package/views/support/screenshotUtils.js +1 -1
  196. package/views/webgl/programUtils.js +1 -1
  197. package/widgets/BuildingExplorer/BuildingPhasePicker/BuildingPhasePicker.js +1 -1
  198. package/widgets/Editor.js +1 -1
  199. package/widgets/Feature/support/relatedFeatureUtils.js +1 -1
  200. package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
  201. package/widgets/FeatureForm/InputField.js +1 -1
  202. package/widgets/FeatureForm.js +1 -1
  203. package/widgets/FeatureTable/Grid/Grid.js +1 -1
  204. package/widgets/FeatureTable/support/FeatureStore.js +1 -1
  205. package/widgets/LayerList/LayerListViewModel.js +1 -1
  206. package/widgets/Print/PrintViewModel.js +1 -1
  207. package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
  208. package/widgets/UtilityNetworkTrace.js +1 -1
  209. package/widgets/support/geolocationUtils.js +1 -1
  210. package/assets/esri/core/workers/chunks/03eb97a65feec8f8d8c6.js +0 -1
  211. package/assets/esri/core/workers/chunks/0eb9c9477d36cd212f8b.js +0 -1
  212. package/assets/esri/core/workers/chunks/10779a256841c37f2429.js +0 -1
  213. package/assets/esri/core/workers/chunks/1591bd575c3f6ceed900.js +0 -1
  214. package/assets/esri/core/workers/chunks/1e439b68af3b6a9a908c.js +0 -1
  215. package/assets/esri/core/workers/chunks/3480f2723f9132145b95.js +0 -1
  216. package/assets/esri/core/workers/chunks/396b2171d7d600a6fac3.js +0 -1
  217. package/assets/esri/core/workers/chunks/3e3eebaa0844742db2f2.js +0 -1
  218. package/assets/esri/core/workers/chunks/4f1637d496f31371dbd8.js +0 -1
  219. package/assets/esri/core/workers/chunks/52a0e387073ea264e194.js +0 -1
  220. package/assets/esri/core/workers/chunks/560234694f3e53802aff.js +0 -1
  221. package/assets/esri/core/workers/chunks/5633710daeb3bbb79bcf.js +0 -1
  222. package/assets/esri/core/workers/chunks/5bdd4df2b0ea60dba368.js +0 -1
  223. package/assets/esri/core/workers/chunks/60553206e233bf18a0a2.js +0 -1
  224. package/assets/esri/core/workers/chunks/6d7fa026f58fd0c68a39.js +0 -1
  225. package/assets/esri/core/workers/chunks/6f7917da7166e8c6854b.js +0 -1
  226. package/assets/esri/core/workers/chunks/6faa075df1295f753bf0.js +0 -1
  227. package/assets/esri/core/workers/chunks/79bdb26244ec7b4472fe.js +0 -1
  228. package/assets/esri/core/workers/chunks/831dc0187f71e658550c.js +0 -1
  229. package/assets/esri/core/workers/chunks/8fb2fb11646d3973e8da.js +0 -1
  230. package/assets/esri/core/workers/chunks/93067e27eea5844edc6c.js +0 -1
  231. package/assets/esri/core/workers/chunks/acc1a4acd57f5657e782.js +0 -1
  232. package/assets/esri/core/workers/chunks/c415af3787d6af66fc9e.js +0 -1
  233. package/assets/esri/core/workers/chunks/caf94491b49c176c39ae.js +0 -1
  234. package/assets/esri/core/workers/chunks/cd3679fa86129ebabfdf.js +0 -1
  235. package/assets/esri/core/workers/chunks/d03cb1afbe74d36db401.js +0 -1
  236. package/assets/esri/core/workers/chunks/daa266bb1ec239837c42.js +0 -1
  237. package/assets/esri/core/workers/chunks/e06ad3a3d71154fed654.js +0 -1
  238. package/assets/esri/core/workers/chunks/f4fc165420d449e442b8.js +0 -1
  239. package/assets/esri/core/workers/chunks/fb6844daeb9403f68ca7.js +0 -1
  240. package/chunks/color.js +0 -5
  241. package/chunks/dotDensity.js +0 -5
  242. package/chunks/heatmap.js +0 -5
  243. package/chunks/location.js +0 -5
  244. package/chunks/predominance.js +0 -5
  245. package/chunks/relationship.js +0 -5
  246. package/chunks/size.js +0 -5
  247. package/chunks/type.js +0 -5
  248. package/renderers/smartMapping/creators/color.js +0 -5
  249. package/renderers/smartMapping/creators/dotDensity.js +0 -5
  250. package/renderers/smartMapping/creators/heatmap.js +0 -5
  251. package/renderers/smartMapping/creators/location.js +0 -5
  252. package/renderers/smartMapping/creators/opacity.js +0 -5
  253. package/renderers/smartMapping/creators/predominance.js +0 -5
  254. package/renderers/smartMapping/creators/relationship.js +0 -5
  255. package/renderers/smartMapping/creators/size.js +0 -5
  256. package/renderers/smartMapping/creators/support/utils.js +0 -5
  257. package/renderers/smartMapping/creators/type.js +0 -5
  258. package/renderers/smartMapping/creators/univariateColorSize.js +0 -5
  259. package/renderers/smartMapping/heuristics/scaleRange.js +0 -5
  260. package/renderers/smartMapping/heuristics/sizeRange.js +0 -5
  261. package/renderers/smartMapping/statistics/classBreaks.js +0 -5
  262. package/renderers/smartMapping/statistics/heatmapStatistics.js +0 -5
  263. package/renderers/smartMapping/statistics/histogram.js +0 -5
  264. package/renderers/smartMapping/statistics/predominantCategories.js +0 -5
  265. package/renderers/smartMapping/statistics/summaryStatistics.js +0 -5
  266. package/renderers/smartMapping/statistics/summaryStatisticsForAge.js +0 -5
  267. package/renderers/smartMapping/statistics/support/ageUtils.js +0 -5
  268. package/renderers/smartMapping/statistics/uniqueValues.js +0 -5
  269. package/renderers/smartMapping/symbology/color.js +0 -5
  270. package/renderers/smartMapping/symbology/dotDensity.js +0 -5
  271. package/renderers/smartMapping/symbology/heatmap.js +0 -5
  272. package/renderers/smartMapping/symbology/location.js +0 -5
  273. package/renderers/smartMapping/symbology/predominance.js +0 -5
  274. package/renderers/smartMapping/symbology/relationship.js +0 -5
  275. package/renderers/smartMapping/symbology/size.js +0 -5
  276. package/renderers/smartMapping/symbology/support/colorRamps.js +0 -5
  277. package/renderers/smartMapping/symbology/support/utils.js +0 -5
  278. package/renderers/smartMapping/symbology/type.js +0 -5
  279. package/tasks/support/AddressCandidate.d.ts +0 -4
  280. package/tasks/support/AddressCandidate.js +0 -5
  281. package/tasks/support/AddressToLocationsParameters.js +0 -5
  282. package/tasks/support/AddressesToLocationsParameters.js +0 -5
  283. package/tasks/support/AlgorithmicColorRamp.d.ts +0 -4
  284. package/tasks/support/AlgorithmicColorRamp.js +0 -5
  285. package/tasks/support/AreasAndLengthsParameters.d.ts +0 -4
  286. package/tasks/support/AreasAndLengthsParameters.js +0 -5
  287. package/tasks/support/AttachmentQuery.d.ts +0 -4
  288. package/tasks/support/AttachmentQuery.js +0 -5
  289. package/tasks/support/BufferParameters.d.ts +0 -4
  290. package/tasks/support/BufferParameters.js +0 -5
  291. package/tasks/support/ClassBreaksDefinition.js +0 -5
  292. package/tasks/support/ClassificationDefinition.js +0 -5
  293. package/tasks/support/ClosestFacilityParameters.d.ts +0 -4
  294. package/tasks/support/ClosestFacilityParameters.js +0 -5
  295. package/tasks/support/ClosestFacilitySolveResult.d.ts +0 -4
  296. package/tasks/support/ClosestFacilitySolveResult.js +0 -5
  297. package/tasks/support/ColorRamp.d.ts +0 -4
  298. package/tasks/support/ColorRamp.js +0 -5
  299. package/tasks/support/DataFile.d.ts +0 -4
  300. package/tasks/support/DataFile.js +0 -5
  301. package/tasks/support/DataLayer.d.ts +0 -4
  302. package/tasks/support/DataLayer.js +0 -5
  303. package/tasks/support/DensifyParameters.d.ts +0 -4
  304. package/tasks/support/DensifyParameters.js +0 -5
  305. package/tasks/support/DirectionsFeatureSet.d.ts +0 -4
  306. package/tasks/support/DirectionsFeatureSet.js +0 -5
  307. package/tasks/support/DistanceParameters.d.ts +0 -4
  308. package/tasks/support/DistanceParameters.js +0 -5
  309. package/tasks/support/FeatureSet.d.ts +0 -4
  310. package/tasks/support/FeatureSet.js +0 -5
  311. package/tasks/support/FindParameters.d.ts +0 -4
  312. package/tasks/support/FindParameters.js +0 -5
  313. package/tasks/support/FindResult.d.ts +0 -4
  314. package/tasks/support/FindResult.js +0 -5
  315. package/tasks/support/GPMessage.d.ts +0 -4
  316. package/tasks/support/GPMessage.js +0 -5
  317. package/tasks/support/GeneralizeParameters.d.ts +0 -4
  318. package/tasks/support/GeneralizeParameters.js +0 -5
  319. package/tasks/support/GenerateRendererParameters.js +0 -5
  320. package/tasks/support/IdentifyParameters.d.ts +0 -4
  321. package/tasks/support/IdentifyParameters.js +0 -5
  322. package/tasks/support/IdentifyResult.d.ts +0 -4
  323. package/tasks/support/IdentifyResult.js +0 -5
  324. package/tasks/support/ImageHistogramParameters.d.ts +0 -4
  325. package/tasks/support/ImageHistogramParameters.js +0 -5
  326. package/tasks/support/ImageIdentifyParameters.d.ts +0 -4
  327. package/tasks/support/ImageIdentifyParameters.js +0 -5
  328. package/tasks/support/ImageIdentifyResult.d.ts +0 -4
  329. package/tasks/support/ImageIdentifyResult.js +0 -5
  330. package/tasks/support/JobInfo.d.ts +0 -4
  331. package/tasks/support/JobInfo.js +0 -5
  332. package/tasks/support/LegendLayer.d.ts +0 -4
  333. package/tasks/support/LegendLayer.js +0 -5
  334. package/tasks/support/LengthsParameters.d.ts +0 -4
  335. package/tasks/support/LengthsParameters.js +0 -5
  336. package/tasks/support/LinearUnit.d.ts +0 -4
  337. package/tasks/support/LinearUnit.js +0 -5
  338. package/tasks/support/LocationToAddressParameters.js +0 -5
  339. package/tasks/support/MultipartColorRamp.d.ts +0 -4
  340. package/tasks/support/MultipartColorRamp.js +0 -5
  341. package/tasks/support/NAMessage.d.ts +0 -4
  342. package/tasks/support/NAMessage.js +0 -5
  343. package/tasks/support/OffsetParameters.d.ts +0 -4
  344. package/tasks/support/OffsetParameters.js +0 -5
  345. package/tasks/support/ParameterValue.d.ts +0 -4
  346. package/tasks/support/ParameterValue.js +0 -5
  347. package/tasks/support/PrintParameters.d.ts +0 -4
  348. package/tasks/support/PrintParameters.js +0 -5
  349. package/tasks/support/PrintTemplate.d.ts +0 -4
  350. package/tasks/support/PrintTemplate.js +0 -5
  351. package/tasks/support/ProjectParameters.d.ts +0 -4
  352. package/tasks/support/ProjectParameters.js +0 -5
  353. package/tasks/support/QuantizationParameters.js +0 -5
  354. package/tasks/support/Query.d.ts +0 -4
  355. package/tasks/support/Query.js +0 -5
  356. package/tasks/support/RasterData.d.ts +0 -4
  357. package/tasks/support/RasterData.js +0 -5
  358. package/tasks/support/RelationParameters.d.ts +0 -4
  359. package/tasks/support/RelationParameters.js +0 -5
  360. package/tasks/support/RelationshipQuery.d.ts +0 -4
  361. package/tasks/support/RelationshipQuery.js +0 -5
  362. package/tasks/support/RouteParameters.d.ts +0 -4
  363. package/tasks/support/RouteParameters.js +0 -5
  364. package/tasks/support/RouteResult.d.ts +0 -4
  365. package/tasks/support/RouteResult.js +0 -5
  366. package/tasks/support/RouteSolveResult.d.ts +0 -4
  367. package/tasks/support/RouteSolveResult.js +0 -5
  368. package/tasks/support/ServiceAreaParameters.d.ts +0 -4
  369. package/tasks/support/ServiceAreaParameters.js +0 -5
  370. package/tasks/support/ServiceAreaSolveResult.d.ts +0 -4
  371. package/tasks/support/ServiceAreaSolveResult.js +0 -5
  372. package/tasks/support/StatisticDefinition.d.ts +0 -4
  373. package/tasks/support/StatisticDefinition.js +0 -5
  374. package/tasks/support/SuggestLocationsParameters.js +0 -5
  375. package/tasks/support/SuggestionCandidate.js +0 -5
  376. package/tasks/support/TopFeaturesQuery.js +0 -5
  377. package/tasks/support/TopFilter.js +0 -5
  378. package/tasks/support/TrimExtendParameters.d.ts +0 -4
  379. package/tasks/support/TrimExtendParameters.js +0 -5
  380. package/tasks/support/UniqueValueDefinition.js +0 -5
  381. package/tasks/support/colorRamps.js +0 -5
  382. package/tasks/support/commonProperties.js +0 -5
  383. package/tasks/support/fileFormat.js +0 -5
  384. package/tasks/support/generateRendererUtils.js +0 -5
  385. package/tasks/support/layoutTemplate.js +0 -5
  386. package/tasks/support/meshFeatureSet.js +0 -5
  387. package/tasks/support/printTaskUtils.js +0 -5
  388. package/views/support/floorFilterUtils.js +0 -5
package/WebMap.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/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"./chunks/tslib.es6.js";import{version as t}from"./kernel.js";import r from"./Map.js";import i from"./Viewpoint.js";import{flatten as o}from"./core/arrayUtils.js";import a from"./core/Collection.js";import s from"./core/Error.js";import n from"./core/Loadable.js";import{loadAll as l}from"./core/loadAll.js";import p from"./core/Logger.js";import{unwrap as m,isSome as u}from"./core/maybe.js";import{MultiOriginJSONMixin as h,MultiOriginJSONSupport as d}from"./core/MultiOriginJSONSupport.js";import{EsriPromiseMixin as c}from"./core/Promise.js";import{eachAlways as y}from"./core/promiseUtils.js";import{whenOnce as w}from"./core/reactiveUtils.js";import{urlToObject as f,isDataProtocol as g,dataComponents as b,addQueryParameter as _}from"./core/urlUtils.js";import{property as v}from"./core/accessorSupport/decorators/property.js";import"./core/has.js";import"./core/accessorSupport/ensureType.js";import{reader as S}from"./core/accessorSupport/decorators/reader.js";import{subclass as I}from"./core/accessorSupport/decorators/subclass.js";import{writer as A}from"./core/accessorSupport/decorators/writer.js";import{updateOrigins as j}from"./core/accessorSupport/originUtils.js";import{readLoadable as L}from"./core/accessorSupport/read.js";import O from"./geometry/SpatialReference.js";import{equals as P}from"./geometry/support/spatialReferenceUtils.js";import{geographicToWebMercator as V,webMercatorToGeographic as U}from"./geometry/support/webMercatorUtils.js";import{isServerOrServicesAGOLUrl as F}from"./layers/support/arcgisLayerUrl.js";import T from"./networks/UtilityNetwork.js";import W from"./portal/Portal.js";import R from"./portal/PortalItem.js";import{removeTypeKeyword as N,addTypeKeyword as x,hasTypeKeyword as M}from"./portal/support/portalItemUtils.js";import{project as k}from"./rest/geometryService/project.js";import C from"./rest/support/ProjectParameters.js";import{hasDeveloperBasemapLayer as E,isDeveloperBasemapLayer as B,findSpatialReference as G}from"./support/basemapUtils.js";import J from"./support/MapFloorInfo.js";import D from"./webdoc/RangeInfo.js";import K from"./webdoc/Widgets.js";import{getOptimalThumbnailSize as $}from"./webdoc/support/thumbnailUtils.js";import{getLayerJSON as z}from"./webdoc/support/writeUtils.js";import q from"./webmap/ApplicationProperties.js";import H from"./webmap/Bookmark.js";import Q from"./webmap/InitialViewProperties.js";import{Version as X}from"./webmap/Version.js";import Y from"./webmap/background/ColorBackground.js";const Z=new X(2,24),ee="Web Map",te=a.ofType(H),re=a.ofType(T),ie=p.getLogger("esri.WebMap"),oe=new Map;oe.set("image/jpeg","jpeg"),oe.set("image/jpg","jpg"),oe.set("image/png","png"),oe.set("image/gif","gif");const ae="ArcGIS Pro",se="ArcGIS API for JavaScript",ne="CollectorDisabled",le="Collector",pe="Data Editing",me="OfflineDisabled",ue="Offline",he="Workforce Project",de="Workforce Worker",ce="Workforce Dispatcher",ye="Offline Map Areas",we="FieldMapsDisabled",fe="DeveloperBasemap",ge=["NatGeo_World_Map","Ocean_Basemap","USA_Topo_Maps","World_Imagery","World_Street_Map","World_Terrain_Base","World_Topo_Map","World_Hillshade","Canvas/World_Light_Gray_Base","Canvas/World_Light_Gray_Reference","Canvas/World_Dark_Gray_Base","Canvas/World_Dark_Gray_Reference","Ocean/World_Ocean_Base","Ocean/World_Ocean_Reference","Reference/World_Boundaries_and_Places","Reference/World_Reference_Overlay","Reference/World_Transportation"].map((e=>e.toLowerCase()));let be=class extends(h(n.LoadableMixin(c(r)))){constructor(e){super(e),this.applicationProperties=null,this.bookmarks=new te,this.floorInfo=null,this.initialViewProperties=new Q,this.portalItem=null,this.presentation=null,this.sourceVersion=null,this.widgets=null,this.utilityNetworks=null,this.authoringApp=this.authoringAppVersion=null,this._isAuthoringAppSetByUser=this._isAuthoringAppVersionSetByUser=!1}destroy(){const e=this.portalItem;this.portalItem=null,null==e||e.destroy()}initialize(){if(this.when().catch((e=>{ie.error("#load()","Failed to load web map",e)})),this.resourceInfo){let t;try{t=this._validateJSON(this.resourceInfo)}catch(e){return void this.addResolvingPromise(Promise.reject(e))}this.read(t)}}set authoringApp(e){this._isAuthoringAppSetByUser=!0,this._set("authoringApp",e)}writeAuthoringApp(e,t){e&&this._isAuthoringAppSetByUser?t.authoringApp=e:t.authoringApp=se}set authoringAppVersion(e){this._isAuthoringAppVersionSetByUser=!0,this._set("authoringAppVersion",e)}writeAuthoringAppVersion(e,r){e&&this._isAuthoringAppVersionSetByUser?r.authoringAppVersion=e:r.authoringAppVersion=t}readInitialViewProperties(e,t){var r;const o=new Q;t.background&&(o.background=Y.fromJSON(t.background));const a=null==(r=t.initialState)?void 0:r.viewpoint;if(a){if(a.rotation){X.parse(t.version||"","webmap").lessThan(2,20)&&t.authoringApp===ae&&(a.rotation*=-1)}o.viewpoint=i.fromJSON(a)}return t.mapRangeInfo&&(o.rangeInfo=D.fromJSON(t.mapRangeInfo)),t.spatialReference&&(o.spatialReference=O.fromJSON(t.spatialReference)),o}writeInitialViewProperties(e,t,r,i){if(!e)return;const o=e.background;o&&o.color&&(t.background=o.write({},i)),e.viewpoint&&(t.initialState={viewpoint:e.viewpoint.write({},i)}),e.rangeInfo&&(t.mapRangeInfo=e.rangeInfo.toJSON(i)),e.spatialReference&&(t.spatialReference=e.spatialReference.write({},i))}writeLayers(e,t,r,i){t[r]=this._writeLayers(e,i,"operational-layers")}readSourceVersion(e,t){const[r,i]=t.version.split(".");return new X(parseInt(r,10),parseInt(i,10))}writeSourceVersion(e,t,r){t[r]=`${Z.major}.${Z.minor}`}writeTables(e,t,r,i){const o=this._writeLayers(e,i,"tables");o.length&&(t[r]=o)}get thumbnailUrl(){return this.portalItem&&this.portalItem.thumbnailUrl||null}set thumbnailUrl(e){e?(this._override("thumbnailUrl",e),this._thumbnailFilename=this._generateCustomThumbnailFilename(e)):this._clearThumbnailOverride()}load(e){return this.addResolvingPromise(this._loadFromSource()),Promise.resolve(this)}loadAll(){return l(this,(e=>{e(this.ground,this.basemap,this.layers,this.tables)}))}read(e,t){t={...t,origin:"web-map"};const r=this._getAuthoringPropsState();L(this,e,(t=>super.read(e,t)),t),this._restoreAuthoringPropsFromState(r)}write(e,t){if("loaded"!==this.loadStatus){const e=new s("webmap:not-loaded","Web map must be loaded before it can be serialized");throw ie.error("#toJSON()","Web map must be loaded before it can be serialized",this.loadError||this.loadStatus),e}return this._removeDanglingLayerRefs(),t={...t,origin:"web-map",restrictedWebMapWriting:!0,webmap:this},super.write(e,t)}async save(e){e=e||{},this._validateItem(),await this._updateFromPromise,await this.load(),await this._loadLayerContainers(),await this._beforeSave(),await this._validateMap();const t=this.portalItem,r={origin:"web-map",messages:[],writtenProperties:[],url:t.itemUrl&&f(t.itemUrl),portal:t.portal||W.getDefault()},i=this.write({},r);return this._validateJSONForWriting(r,e),await this._updateItemProperties(t),await this._updateItem(t,i,r),await this._updateItemThumbnail(),t}async saveAs(e,t){t=t||{};const r=this._getPortalItem(e);await this._updateFromPromise,await this.load(),await this._loadLayerContainers(),await this._beforeSave(),await this._validateMap();const i={origin:"web-map",messages:[],writtenProperties:[],url:null,portal:r.portal},o=this.write({},i);this._validateJSONForWriting(i,t),await this._updateItemPropertiesForSaveAs(r);const a=this._getThumbnailState();return await this._createItem(r,o,i,t),this._restoreThumbnailFromState(a),await this._updateItemThumbnail(),r}async updateFrom(e,t){const r=this._updateFromInternal(e,t);this._updateFromPromise=r,await r;r===this._updateFromPromise&&(this._updateFromPromise=null)}getLayerJSONFromResourceInfo(e){var t,r,i,a;const s=this.resourceInfo;return this._collectAllLayersJSON(o([null==s||null==(t=s.baseMap)?void 0:t.baseMapLayers,null==s?void 0:s.operationalLayers,null==(r=this.basemap)||null==(i=r.resourceInfo)||null==(a=i.data)?void 0:a.baseMapLayers])).find((t=>t.id===e.id))}_collectAllLayersJSON(e){return e.reduce(((e,t)=>(e.push(t),"GroupLayer"===t.layerType&&(e=e.concat(this._collectAllLayersJSON(t.layers||[]))),e)),[])}_writeLayers(e,t,r){t={...t,layerContainerType:r};return e.map((e=>m(z(e,"tables"===r?null:this.getLayerJSONFromResourceInfo(e),t)))).filter(Boolean).toArray()}_loadFromSource(){return this.resourceInfo?this._loadFromJSON(this.resourceInfo,{origin:"web-map"}):this.portalItem&&this.portalItem.id?this._loadFromItem(this.portalItem):Promise.resolve(null)}_loadFromItem(e){return e.load().catch((e=>{throw new s("webmap:load-portal-item","Failed to load portal item",{error:e})})).then((()=>{if("Web Map"!==e.type)throw new s("webmap:invalid-portal-item","Invalid portal item type '${type}', expected 'Web Map'",{type:e.type})})).then((()=>e.fetchData())).then((t=>(this.resourceInfo=t,this._readAndLoadFromJSON(t,{origin:"web-map",portal:e.portal||W.getDefault()})))).then((()=>this._computeInitialViewpoint()))}_readAndLoadFromJSON(e,t){const r=this._validateJSON(e);return this.read(r,t),this._loadFromJSON(r,t)}_validateJSON(e){const t=X.parse(e.version||"","webmap");return Z.validate(t),e.version=`${t.major}.${t.minor}`,e}_loadFromJSON(e,t){const r={context:{...t,layerContainerType:"operational-layers"}};return this.portalItem&&(r.context.portal=this.portalItem.portal||W.getDefault()),import("./layers/support/layersCreator.js").then((({populateOperationalLayers:t})=>{const i=[],o=e.operationalLayers;o&&o.length&&i.push(t(this.layers,o,r));const a={...r,context:{...r.context,layerContainerType:"tables"},defaultLayerType:"ArcGISFeatureLayer"},s=e.tables;return s&&s.length&&i.push(t(this.tables,s,a)),y(i).then((()=>{}))}))}async _computeInitialViewpoint(){var e,t;let r=this.initialViewProperties;if(null==(e=r)||null==(t=e.viewpoint)?void 0:t.targetGeometry)return;const o=await this._getExtentFromItem();o&&(r=r?r.clone():new Q,r.viewpoint=new i,r.viewpoint.targetGeometry=o,this.initialViewProperties=r)}async _getExtentFromItem(){var e,t;const r=null==(e=this.initialViewProperties)?void 0:e.spatialReference,i=null==(t=this.portalItem)?void 0:t.extent;if(r&&i){if(r.isWGS84)return i.clone();if(r.isWebMercator)return V(i);return(await import("./portal/support/geometryServiceUtils.js")).getGeometryServiceURL(this.portalItem).then((e=>{const t=new C;return t.geometries=[i],t.outSpatialReference=r,k(e,t)})).then((e=>e[0])).catch((e=>(ie.error("Error projecting item's extent:",e),null)))}return null}_removeDanglingLayerRefs(){const e=this.applicationProperties,t=e&&e.viewing&&e.viewing.search,r=e=>!!this.allLayers.find((t=>t.id===e));t&&t.layers&&(t.layers=t.layers.filter((e=>r(e.id)))),t&&t.tables&&(t.tables=t.tables.filter((e=>!!this.tables.find((t=>t.id===e.id)))));const i=e&&e.editing&&e.editing.locationTracking;i&&i.info&&!r(i.info.layerId)&&(e.editing=null);const o=this.presentation&&this.presentation.slides;o&&o.forEach((e=>{e.visibleLayers&&(e.visibleLayers=e.visibleLayers.filter((e=>r(e.id))))}))}async _validateMap(){var e;if(null==(e=this.basemap)||!e.baseLayers.length)throw new s("webmap:save","Map does not have a valid basemap with a base layer.");let t=null;if(await w((()=>{const e=G(this.initialViewProperties,this.basemap);return t=e.spatialReference,!e.updating})),!P(t,this.initialViewProperties.spatialReference))throw new s("webmap:save","The spatial reference of the basemap is not compatible with the one from the map.",{expected:this.initialViewProperties.spatialReference,actual:t})}_validateItem(){if(!this.portalItem)throw ie.error("save: requires the portalItem property to be set"),new s("webmap:portal-item-not-set","Portal item to save to has not been set on the WebMap");this._validateItemType(this.portalItem)}_validateItemType(e){if(e.type!==ee)throw new s("webmap:portal-item-wrong-type",`Portal item needs to have type "${ee}"`)}_loadLayerContainers(){const e=[];return this.basemap&&e.push(this.basemap.load()),this.ground&&e.push(this.ground.load()),y(e).then((()=>{}))}async _beforeSave(){const e=[];for(const t of this.allLayers)if("beforeSave"in t&&"function"==typeof t.beforeSave){const r=t.beforeSave();r&&e.push(r)}await y(e)}_loadAllLayers(){const e=this._getAllLayersAndTables().map((e=>e.load()));return y(e).then((()=>{}))}_getAllLayersAndTables(){return this.allLayers.concat(this.allTables)}_validateJSONForWriting(e,t){let r=e.messages.filter((e=>"error"===e.type)).map((e=>new s(e.name,e.message,e.details)));if(t.ignoreUnsupported&&(r=r.filter((e=>"layer:unsupported"!==e.name&&"symbol:unsupported"!==e.name&&"symbol-layer:unsupported"!==e.name&&"property:unsupported"!==e.name&&"url:unsupported"!==e.name))),r.length>0)throw new s("webmap:save","Failed to save webmap due to unsupported or invalid content. See 'details.errors' for more detailed information",{errors:r})}async _updateItemProperties(e){e.extent=await this._getWGS84Extent(this.initialViewProperties.viewpoint.targetGeometry),await this._updateTypeKeywords(e)}async _updateItemPropertiesForSaveAs(e){N(e,ne),N(e,me),N(e,he),N(e,de),N(e,ce),N(e,ye),N(e,we),await this._updateItemProperties(e)}async _getWGS84Extent(e){const t=e.clone().normalize();let r;if(t.length>1)for(const i of t)r?i.width>r.width&&(r=i):r=i;else r=t[0];return this._projectToWGS84(r)}async _projectToWGS84(e){const t=e.spatialReference;if(t.isWGS84)return e.clone();if(t.isWebMercator)return U(e);const r=await import("./portal/support/geometryServiceUtils.js"),i=await r.getGeometryServiceURL(this.portalItem),o=new C;o.geometries=[e],o.outSpatialReference=O.WGS84;return(await k(i,o))[0]}async _updateTypeKeywords(e){x(e,se),await this._loadAllLayers(),this._evalCollectorKeyword(e),this._evalDataEditingKeyword(e),this._evalOfflineKeyword(e),this._evalDeveloperBasemapKeyword(e),e.typeKeywords&&(e.typeKeywords=e.typeKeywords.filter(((e,t,r)=>r.indexOf(e)===t)))}_evalCollectorKeyword(e){M(e,ne)||M(e,he)||M(e,de)||M(e,ce)||!this._hasEditableFeatureLayer()?N(e,le):x(e,le)}_evalDataEditingKeyword(e){this._hasEditableFeatureLayer()?x(e,pe):N(e,pe)}_evalOfflineKeyword(e){!M(e,me)&&this._isOfflineCapableMap()?x(e,ue):N(e,ue)}_evalDeveloperBasemapKeyword(e){E(this.basemap)?x(e,fe):N(e,fe)}_hasEditableFeatureLayer(){return this._getAllLayersAndTables().some((e=>e.loaded&&this._isFeatureServiceLayer(e)&&e.capabilities.operations.supportsEditing&&e.editingEnabled))}_isFeatureServiceLayer(e){return!("feature"!==e.type||!e.source||"feature-layer"!==e.source.type)}_isOfflineCapableMap(){return this._getAllLayersAndTables().filter((e=>"group"!==e.type)).every((e=>e.loaded&&this._isOfflineCapableLayer(e)))}_isOfflineCapableLayer(e){return this._isFeatureServiceLayer(e)&&e.capabilities.operations.supportsSync||("tile"===e.type||"vector-tile"===e.type)&&(e.capabilities.operations.supportsExportTiles||this._isExportableAGOLTileLayer(e)||B(e))&&e.spatialReference.equals(this.initialViewProperties.spatialReference)}_isExportableAGOLTileLayer(e){return"tile"===e.type&&(F(e.url)&&ge.some((t=>e.url.toLowerCase().includes("/"+t+"/"))))}async _updateItem(e,t,r){await e.update({data:t}),this._syncUpInstanceWithItem(e,t,r)}async _createItem(e,t,r,i){const o=this.portalItem,a=!!(o&&o.id&&o.portal.user),n=e.portal;if(await n._signIn(),!await this._canCopyItem(o,a,n))throw new s("webmap:save-as-copy-not-allowed","Owner of this map does not allow others to save a copy");await n.user.addItem({item:e,folder:i.folder,data:t}),this.portalItem=e,this._syncUpInstanceWithItem(e,t,r)}async _canCopyItem(e,t,r){return!(u(e)&&e.id&&e.typeKeywords&&e.typeKeywords.includes("useOnly"))||e.portal.portalHostname===r.portalHostname&&(t||await e.reload(),"admin"===e.itemControl||"update"===e.itemControl)}_syncUpInstanceWithItem(e,t,r){d.prototype.read.call(this,{version:t.version,authoringApp:t.authoringApp,authoringAppVersion:t.authoringAppVersion},{origin:"web-map",ignoreDefaults:!0,url:e.itemUrl&&f(e.itemUrl)}),j(r),this.resourceInfo=t}async _updateItemThumbnail(){this.thumbnailUrl&&this._isOverridden("thumbnailUrl")&&(await this.portalItem.updateThumbnail({thumbnail:this.thumbnailUrl,filename:this._thumbnailFilename}),this._clearThumbnailOverride())}_getPortalItem(e){let t=R.from(e);return t.id&&(t=t.clone(),t.id=null),t.type||(t.type=ee),t.portal||(t.portal=W.getDefault()),this._validateItemType(t),t}async _updateFromInternal(e,t){if(t=t||{},await w((()=>e.ready)),this._updateInitialViewProperties(e,t),e.map===this)for(const r of e.allLayerViews)for(const e of["visible","featureEffect"])e in r&&e in r.layer&&r._isOverridden(e)&&(r.layer[e]=r[e]);await this._updateThumbnailUrl(e,t)}_updateInitialViewProperties(e,t){var r;t.backgroundExcluded||(this.initialViewProperties.background=null==(r=e.background)?void 0:r.clone());if(this.initialViewProperties.spatialReference=e.spatialReference.clone(),t.viewpointExcluded||(this.initialViewProperties.viewpoint=new i({rotation:e.rotation,scale:t.scalePreserved?e.scale:null,targetGeometry:this._getViewExtent(e)})),!t.widgetsExcluded)for(const i of e.persistableViewModels)i.updateWebDocument(this)}_getViewExtent(e){const t=e.center.clone().normalize(),r=e.extent.clone(),i=r.width/2;return r.xmin=t.x-i,r.xmax=t.x+i,r}async _updateThumbnailUrl(e,t){if(t.thumbnailExcluded)return;const r=$(e,t.thumbnailSize),i=await e.takeScreenshot({format:"png",width:r.width,height:r.height});this._setAutoGeneratedThumbnail(i.dataUrl)}_setAutoGeneratedThumbnail(e){this.thumbnailUrl=e,this._thumbnailFilename=null}_clearThumbnailOverride(){this._clearOverride("thumbnailUrl"),this.clear("thumbnailUrl","user"),this._thumbnailFilename=null}_generateCustomThumbnailFilename(e){if(g(e)){const t=b(e),r=t&&t.mediaType,i=r&&oe.get(r.toLowerCase())||null,o=`thumbnail${Date.now()}`;return i?`${o}.${i}`:o}return null}_getThumbnailState(){let e=this.thumbnailUrl;return e&&(e=this._isOverridden("thumbnailUrl")?e:_(e,"w","8192")),{thumbnailUrl:e,filename:this._thumbnailFilename}}_restoreThumbnailFromState(e){this.thumbnailUrl=e.thumbnailUrl,this._thumbnailFilename=e.filename}_getAuthoringPropsState(){return{authoringApp:this.authoringApp,authoringAppVersion:this.authoringAppVersion,isAuthoringAppSetByUser:this._isAuthoringAppSetByUser,isAuthoringAppVersionSetByUser:this._isAuthoringAppVersionSetByUser}}_restoreAuthoringPropsFromState(e){e.isAuthoringAppSetByUser?this.authoringApp=e.authoringApp:this._isAuthoringAppSetByUser=!1,e.isAuthoringAppVersionSetByUser?this.authoringAppVersion=e.authoringAppVersion:this._isAuthoringAppVersionSetByUser=!1}static fromJSON(e){const t=e;if(!t)throw new s("webmap:empty-resource","Expected a JSON resource but got nothing");return new this({resourceInfo:t})}};be.VERSION=Z,e([v({type:q,json:{write:!0}})],be.prototype,"applicationProperties",void 0),e([v({type:String,json:{write:{allowNull:!0,ignoreOrigin:!0}}})],be.prototype,"authoringApp",null),e([A("authoringApp")],be.prototype,"writeAuthoringApp",null),e([v({type:String,json:{write:{allowNull:!0,ignoreOrigin:!0}}})],be.prototype,"authoringAppVersion",null),e([A("authoringAppVersion")],be.prototype,"writeAuthoringAppVersion",null),e([v({json:{read:{source:"baseMap"},write:{target:"baseMap"}}})],be.prototype,"basemap",void 0),e([v({type:te,json:{write:{overridePolicy:e=>({enabled:!!(e&&e.length>0),ignoreOrigin:!0})}}})],be.prototype,"bookmarks",void 0),e([v({type:J,json:{read:{source:"mapFloorInfo"},write:{target:"mapFloorInfo"}}})],be.prototype,"floorInfo",void 0),e([v({type:Q,nonNullable:!0,json:{read:{source:["background","initialState.viewpoint","mapRangeInfo","spatialReference"]},write:{ignoreOrigin:!0,target:{background:{type:Y},"initialState.viewpoint":{type:i},mapRangeInfo:{type:D},spatialReference:{type:O}}}}})],be.prototype,"initialViewProperties",void 0),e([S("initialViewProperties")],be.prototype,"readInitialViewProperties",null),e([A("initialViewProperties")],be.prototype,"writeInitialViewProperties",null),e([v({json:{read:!1,write:{target:"operationalLayers",ignoreOrigin:!0}}})],be.prototype,"layers",void 0),e([A("layers")],be.prototype,"writeLayers",null),e([v({type:R})],be.prototype,"portalItem",void 0),e([v({json:{write:!0}})],be.prototype,"presentation",void 0),e([v()],be.prototype,"resourceInfo",void 0),e([v({readOnly:!0,type:X,json:{read:{source:"version"},write:{allowNull:!0,ignoreOrigin:!0,target:"version",isRequired:!0}}})],be.prototype,"sourceVersion",void 0),e([S("sourceVersion")],be.prototype,"readSourceVersion",null),e([A("sourceVersion")],be.prototype,"writeSourceVersion",null),e([v({json:{read:!1,write:{ignoreOrigin:!0}}})],be.prototype,"tables",void 0),e([A("tables")],be.prototype,"writeTables",null),e([v()],be.prototype,"thumbnailUrl",null),e([v({type:K,json:{write:!0}})],be.prototype,"widgets",void 0),e([v({type:re,json:{read:!0,write:!0}})],be.prototype,"utilityNetworks",void 0),be=e([I("esri.WebMap")],be);const _e=be;export{_e as default};
5
+ import{_ as e}from"./chunks/tslib.es6.js";import{version as t}from"./kernel.js";import r from"./Map.js";import i from"./Viewpoint.js";import{flatten as o}from"./core/arrayUtils.js";import a from"./core/Collection.js";import s from"./core/Error.js";import n from"./core/Loadable.js";import{loadAll as l}from"./core/loadAll.js";import p from"./core/Logger.js";import{unwrap as m,isSome as u}from"./core/maybe.js";import{MultiOriginJSONMixin as h,MultiOriginJSONSupport as c}from"./core/MultiOriginJSONSupport.js";import{EsriPromiseMixin as d}from"./core/Promise.js";import{eachAlways as y}from"./core/promiseUtils.js";import{whenOnce as w}from"./core/reactiveUtils.js";import{urlToObject as f,isDataProtocol as g,dataComponents as b,addQueryParameter as _}from"./core/urlUtils.js";import{property as v}from"./core/accessorSupport/decorators/property.js";import"./core/has.js";import"./core/accessorSupport/ensureType.js";import{reader as S}from"./core/accessorSupport/decorators/reader.js";import{subclass as I}from"./core/accessorSupport/decorators/subclass.js";import{writer as A}from"./core/accessorSupport/decorators/writer.js";import{updateOrigins as j}from"./core/accessorSupport/originUtils.js";import{readLoadable as L}from"./core/accessorSupport/read.js";import O from"./geometry/SpatialReference.js";import{equals as P}from"./geometry/support/spatialReferenceUtils.js";import{geographicToWebMercator as V,webMercatorToGeographic as U}from"./geometry/support/webMercatorUtils.js";import{isServerOrServicesAGOLUrl as F}from"./layers/support/arcgisLayerUrl.js";import T from"./networks/UtilityNetwork.js";import W from"./portal/Portal.js";import R from"./portal/PortalItem.js";import{removeTypeKeyword as N,addTypeKeyword as x,hasTypeKeyword as M}from"./portal/support/portalItemUtils.js";import{project as k}from"./rest/geometryService/project.js";import C from"./rest/support/ProjectParameters.js";import{hasDeveloperBasemapLayer as E,isDeveloperBasemapLayer as B,findSpatialReference as G}from"./support/basemapUtils.js";import J from"./support/MapFloorInfo.js";import D from"./webdoc/RangeInfo.js";import K from"./webdoc/Widgets.js";import{getOptimalThumbnailSize as $}from"./webdoc/support/thumbnailUtils.js";import{getLayerJSON as z}from"./webdoc/support/writeUtils.js";import q from"./webmap/ApplicationProperties.js";import H from"./webmap/Bookmark.js";import Q from"./webmap/InitialViewProperties.js";import{Version as X}from"./webmap/Version.js";import Y from"./webmap/background/ColorBackground.js";const Z=new X(2,24),ee="Web Map",te=a.ofType(H),re=a.ofType(T),ie=p.getLogger("esri.WebMap"),oe=new Map;oe.set("image/jpeg","jpeg"),oe.set("image/jpg","jpg"),oe.set("image/png","png"),oe.set("image/gif","gif");const ae="ArcGIS Pro",se="ArcGIS API for JavaScript",ne="CollectorDisabled",le="Collector",pe="Data Editing",me="OfflineDisabled",ue="Offline",he="Workforce Project",ce="Workforce Worker",de="Workforce Dispatcher",ye="Offline Map Areas",we="FieldMapsDisabled",fe="DeveloperBasemap",ge=["NatGeo_World_Map","Ocean_Basemap","USA_Topo_Maps","World_Imagery","World_Street_Map","World_Terrain_Base","World_Topo_Map","World_Hillshade","Canvas/World_Light_Gray_Base","Canvas/World_Light_Gray_Reference","Canvas/World_Dark_Gray_Base","Canvas/World_Dark_Gray_Reference","Ocean/World_Ocean_Base","Ocean/World_Ocean_Reference","Reference/World_Boundaries_and_Places","Reference/World_Reference_Overlay","Reference/World_Transportation"].map((e=>e.toLowerCase()));let be=class extends(h(n.LoadableMixin(d(r)))){constructor(e){super(e),this.applicationProperties=null,this.bookmarks=new te,this.floorInfo=null,this.initialViewProperties=new Q,this.portalItem=null,this.presentation=null,this.sourceVersion=null,this.widgets=null,this.utilityNetworks=null,this.authoringApp=this.authoringAppVersion=null,this._isAuthoringAppSetByUser=this._isAuthoringAppVersionSetByUser=!1}destroy(){const e=this.portalItem;this.portalItem=null,null==e||e.destroy()}initialize(){if(this.when().catch((e=>{ie.error("#load()","Failed to load web map",e)})),this.resourceInfo){let t;try{t=this._validateJSON(this.resourceInfo)}catch(e){return void this.addResolvingPromise(Promise.reject(e))}this.read(t)}}set authoringApp(e){this._isAuthoringAppSetByUser=!0,this._set("authoringApp",e)}writeAuthoringApp(e,t){e&&this._isAuthoringAppSetByUser?t.authoringApp=e:t.authoringApp=se}set authoringAppVersion(e){this._isAuthoringAppVersionSetByUser=!0,this._set("authoringAppVersion",e)}writeAuthoringAppVersion(e,r){e&&this._isAuthoringAppVersionSetByUser?r.authoringAppVersion=e:r.authoringAppVersion=t}readInitialViewProperties(e,t){var r;const o=new Q;t.background&&(o.background=Y.fromJSON(t.background));const a=null==(r=t.initialState)?void 0:r.viewpoint;if(a){if(a.rotation){X.parse(t.version||"","webmap").lessThan(2,20)&&t.authoringApp===ae&&(a.rotation*=-1)}o.viewpoint=i.fromJSON(a)}return t.mapRangeInfo&&(o.rangeInfo=D.fromJSON(t.mapRangeInfo)),t.spatialReference&&(o.spatialReference=O.fromJSON(t.spatialReference)),o}writeInitialViewProperties(e,t,r,i){if(!e)return;const o=e.background;o&&o.color&&(t.background=o.write({},i)),e.viewpoint&&(t.initialState={viewpoint:e.viewpoint.write({},i)}),e.rangeInfo&&(t.mapRangeInfo=e.rangeInfo.toJSON(i)),e.spatialReference&&(t.spatialReference=e.spatialReference.write({},i))}writeLayers(e,t,r,i){t[r]=this._writeLayers(e,i,"operational-layers")}readSourceVersion(e,t){const[r,i]=t.version.split(".");return new X(parseInt(r,10),parseInt(i,10))}writeSourceVersion(e,t,r){t[r]=`${Z.major}.${Z.minor}`}writeTables(e,t,r,i){const o=this._writeLayers(e,i,"tables");o.length&&(t[r]=o)}get thumbnailUrl(){return this.portalItem&&this.portalItem.thumbnailUrl||null}set thumbnailUrl(e){e?(this._override("thumbnailUrl",e),this._thumbnailFilename=this._generateCustomThumbnailFilename(e)):this._clearThumbnailOverride()}load(e){return this.addResolvingPromise(this._loadFromSource()),Promise.resolve(this)}loadAll(){return l(this,(e=>{e(this.ground,this.basemap,this.layers,this.tables)}))}read(e,t){t={...t,origin:"web-map"};const r=this._getAuthoringPropsState();L(this,e,(t=>super.read(e,t)),t),this._restoreAuthoringPropsFromState(r)}write(e,t){if("loaded"!==this.loadStatus){const e=new s("webmap:not-loaded","Web map must be loaded before it can be serialized");throw ie.error("#toJSON()","Web map must be loaded before it can be serialized",this.loadError||this.loadStatus),e}return this._removeDanglingLayerRefs(),t={...t,origin:"web-map",restrictedWebMapWriting:!0,webmap:this},super.write(e,t)}async save(e){e=e||{},this._validateItem(),await this._updateFromPromise,await this.load(),await this._loadLayerContainers(),await this._beforeSave(),await this._validateMap();const t=this.portalItem,r={origin:"web-map",messages:[],writtenProperties:[],url:t.itemUrl&&f(t.itemUrl),portal:t.portal||W.getDefault()},i=this.write({},r);return this._validateJSONForWriting(r,e),await this._updateItemProperties(t),await this._updateItem(t,i,r),await this._updateItemThumbnail(),t}async saveAs(e,t){t=t||{};const r=this._getPortalItem(e);await this._updateFromPromise,await this.load(),await this._loadLayerContainers(),await this._beforeSave(),await this._validateMap();const i={origin:"web-map",messages:[],writtenProperties:[],url:null,portal:r.portal},o=this.write({},i);this._validateJSONForWriting(i,t),await this._updateItemPropertiesForSaveAs(r);const a=this._getThumbnailState();return await this._createItem(r,o,i,t),this._restoreThumbnailFromState(a),await this._updateItemThumbnail(),r}async updateFrom(e,t){const r=this._updateFromInternal(e,t);this._updateFromPromise=r,await r;r===this._updateFromPromise&&(this._updateFromPromise=null)}getLayerJSONFromResourceInfo(e){var t,r,i,a;const s=this.resourceInfo;return this._collectAllLayersJSON(o([null==s||null==(t=s.baseMap)?void 0:t.baseMapLayers,null==s?void 0:s.operationalLayers,null==(r=this.basemap)||null==(i=r.resourceInfo)||null==(a=i.data)?void 0:a.baseMapLayers])).find((t=>t.id===e.id))}_collectAllLayersJSON(e){return e.reduce(((e,t)=>(e.push(t),"GroupLayer"===t.layerType&&(e=e.concat(this._collectAllLayersJSON(t.layers||[]))),e)),[])}_writeLayers(e,t,r){t={...t,layerContainerType:r};return e.map((e=>m(z(e,"tables"===r?null:this.getLayerJSONFromResourceInfo(e),t)))).filter(Boolean).toArray()}_loadFromSource(){return this.resourceInfo?this._loadFromJSON(this.resourceInfo,{origin:"web-map"}):this.portalItem&&this.portalItem.id?this._loadFromItem(this.portalItem):Promise.resolve(null)}_loadFromItem(e){return e.load().catch((e=>{throw new s("webmap:load-portal-item","Failed to load portal item",{error:e})})).then((()=>{if("Web Map"!==e.type)throw new s("webmap:invalid-portal-item","Invalid portal item type '${type}', expected 'Web Map'",{type:e.type})})).then((()=>e.fetchData())).then((t=>(this.resourceInfo=t,this._readAndLoadFromJSON(t,{origin:"web-map",portal:e.portal||W.getDefault()})))).then((()=>this._computeInitialViewpoint()))}_readAndLoadFromJSON(e,t){const r=this._validateJSON(e);return this.read(r,t),this._loadFromJSON(r,t)}_validateJSON(e){const t=X.parse(e.version||"","webmap");return Z.validate(t),e.version=`${t.major}.${t.minor}`,e}_loadFromJSON(e,t){const r={context:{...t,layerContainerType:"operational-layers"}};return this.portalItem&&(r.context.portal=this.portalItem.portal||W.getDefault()),import("./layers/support/layersCreator.js").then((({populateOperationalLayers:t})=>{const i=[],o=e.operationalLayers;o&&o.length&&i.push(t(this.layers,o,r));const a={...r,context:{...r.context,layerContainerType:"tables"},defaultLayerType:"ArcGISFeatureLayer"},s=e.tables;return s&&s.length&&i.push(t(this.tables,s,a)),y(i).then((()=>{}))}))}async _computeInitialViewpoint(){var e,t;let r=this.initialViewProperties;if(null==(e=r)||null==(t=e.viewpoint)?void 0:t.targetGeometry)return;const o=await this._getExtentFromItem();o&&(r=r?r.clone():new Q,r.viewpoint=new i,r.viewpoint.targetGeometry=o,this.initialViewProperties=r)}async _getExtentFromItem(){var e,t;const r=null==(e=this.initialViewProperties)?void 0:e.spatialReference,i=null==(t=this.portalItem)?void 0:t.extent;if(r&&i){if(r.isWGS84)return i.clone();if(r.isWebMercator)return V(i);return(await import("./portal/support/geometryServiceUtils.js")).getGeometryServiceURL(this.portalItem).then((e=>{const t=new C;return t.geometries=[i],t.outSpatialReference=r,k(e,t)})).then((e=>e[0])).catch((e=>(ie.error("Error projecting item's extent:",e),null)))}return null}_removeDanglingLayerRefs(){const e=this.applicationProperties,t=e&&e.viewing&&e.viewing.search,r=e=>this.allLayers.some((t=>t.id===e));t&&t.layers&&(t.layers=t.layers.filter((e=>r(e.id)))),t&&t.tables&&(t.tables=t.tables.filter((e=>this.tables.some((t=>t.id===e.id)))));const i=e&&e.editing&&e.editing.locationTracking;i&&i.info&&!r(i.info.layerId)&&(e.editing=null);const o=this.presentation&&this.presentation.slides;o&&o.forEach((e=>{e.visibleLayers&&(e.visibleLayers=e.visibleLayers.filter((e=>r(e.id))))}))}async _validateMap(){var e;if(null==(e=this.basemap)||!e.baseLayers.length)throw new s("webmap:save","Map does not have a valid basemap with a base layer.");let t=null;if(await w((()=>{const e=G(this.initialViewProperties,this.basemap);return t=e.spatialReference,!e.updating})),!P(t,this.initialViewProperties.spatialReference))throw new s("webmap:save","The spatial reference of the basemap is not compatible with the one from the map.",{expected:this.initialViewProperties.spatialReference,actual:t})}_validateItem(){if(!this.portalItem)throw ie.error("save: requires the portalItem property to be set"),new s("webmap:portal-item-not-set","Portal item to save to has not been set on the WebMap");this._validateItemType(this.portalItem)}_validateItemType(e){if(e.type!==ee)throw new s("webmap:portal-item-wrong-type",`Portal item needs to have type "${ee}"`)}_loadLayerContainers(){const e=[];return this.basemap&&e.push(this.basemap.load()),this.ground&&e.push(this.ground.load()),y(e).then((()=>{}))}async _beforeSave(){const e=[];for(const t of this.allLayers)if("beforeSave"in t&&"function"==typeof t.beforeSave){const r=t.beforeSave();r&&e.push(r)}await y(e)}_loadAllLayers(){const e=this._getAllLayersAndTables().map((e=>e.load()));return y(e).then((()=>{}))}_getAllLayersAndTables(){return this.allLayers.concat(this.allTables)}_validateJSONForWriting(e,t){let r=e.messages.filter((e=>"error"===e.type)).map((e=>new s(e.name,e.message,e.details)));if(t.ignoreUnsupported&&(r=r.filter((e=>"layer:unsupported"!==e.name&&"symbol:unsupported"!==e.name&&"symbol-layer:unsupported"!==e.name&&"property:unsupported"!==e.name&&"url:unsupported"!==e.name))),r.length>0)throw new s("webmap:save","Failed to save webmap due to unsupported or invalid content. See 'details.errors' for more detailed information",{errors:r})}async _updateItemProperties(e){e.extent=await this._getWGS84Extent(this.initialViewProperties.viewpoint.targetGeometry),await this._updateTypeKeywords(e)}async _updateItemPropertiesForSaveAs(e){N(e,ne),N(e,me),N(e,he),N(e,ce),N(e,de),N(e,ye),N(e,we),await this._updateItemProperties(e)}async _getWGS84Extent(e){const t=e.clone().normalize();let r;if(t.length>1)for(const i of t)r?i.width>r.width&&(r=i):r=i;else r=t[0];return this._projectToWGS84(r)}async _projectToWGS84(e){const t=e.spatialReference;if(t.isWGS84)return e.clone();if(t.isWebMercator)return U(e);const r=await import("./portal/support/geometryServiceUtils.js"),i=await r.getGeometryServiceURL(this.portalItem),o=new C;o.geometries=[e],o.outSpatialReference=O.WGS84;return(await k(i,o))[0]}async _updateTypeKeywords(e){x(e,se),await this._loadAllLayers(),this._evalCollectorKeyword(e),this._evalDataEditingKeyword(e),this._evalOfflineKeyword(e),this._evalDeveloperBasemapKeyword(e),e.typeKeywords&&(e.typeKeywords=e.typeKeywords.filter(((e,t,r)=>r.indexOf(e)===t)))}_evalCollectorKeyword(e){M(e,ne)||M(e,he)||M(e,ce)||M(e,de)||!this._hasEditableFeatureLayer()?N(e,le):x(e,le)}_evalDataEditingKeyword(e){this._hasEditableFeatureLayer()?x(e,pe):N(e,pe)}_evalOfflineKeyword(e){!M(e,me)&&this._isOfflineCapableMap()?x(e,ue):N(e,ue)}_evalDeveloperBasemapKeyword(e){E(this.basemap)?x(e,fe):N(e,fe)}_hasEditableFeatureLayer(){return this._getAllLayersAndTables().some((e=>e.loaded&&this._isFeatureServiceLayer(e)&&e.capabilities.operations.supportsEditing&&e.editingEnabled))}_isFeatureServiceLayer(e){return!("feature"!==e.type||!e.source||"feature-layer"!==e.source.type)}_isOfflineCapableMap(){return this._getAllLayersAndTables().filter((e=>"group"!==e.type)).every((e=>e.loaded&&this._isOfflineCapableLayer(e)))}_isOfflineCapableLayer(e){return this._isFeatureServiceLayer(e)&&e.capabilities.operations.supportsSync||("tile"===e.type||"vector-tile"===e.type)&&(e.capabilities.operations.supportsExportTiles||this._isExportableAGOLTileLayer(e)||B(e))&&e.spatialReference.equals(this.initialViewProperties.spatialReference)}_isExportableAGOLTileLayer(e){return"tile"===e.type&&(F(e.url)&&ge.some((t=>e.url.toLowerCase().includes("/"+t+"/"))))}async _updateItem(e,t,r){await e.update({data:t}),this._syncUpInstanceWithItem(e,t,r)}async _createItem(e,t,r,i){const o=this.portalItem,a=!!(o&&o.id&&o.portal.user),n=e.portal;if(await n._signIn(),!await this._canCopyItem(o,a,n))throw new s("webmap:save-as-copy-not-allowed","Owner of this map does not allow others to save a copy");await n.user.addItem({item:e,folder:i.folder,data:t}),this.portalItem=e,this._syncUpInstanceWithItem(e,t,r)}async _canCopyItem(e,t,r){return!(u(e)&&e.id&&e.typeKeywords&&e.typeKeywords.includes("useOnly"))||e.portal.portalHostname===r.portalHostname&&(t||await e.reload(),"admin"===e.itemControl||"update"===e.itemControl)}_syncUpInstanceWithItem(e,t,r){c.prototype.read.call(this,{version:t.version,authoringApp:t.authoringApp,authoringAppVersion:t.authoringAppVersion},{origin:"web-map",ignoreDefaults:!0,url:e.itemUrl&&f(e.itemUrl)}),j(r),this.resourceInfo=t}async _updateItemThumbnail(){this.thumbnailUrl&&this._isOverridden("thumbnailUrl")&&(await this.portalItem.updateThumbnail({thumbnail:this.thumbnailUrl,filename:this._thumbnailFilename}),this._clearThumbnailOverride())}_getPortalItem(e){let t=R.from(e);return t.id&&(t=t.clone(),t.id=null),t.type||(t.type=ee),t.portal||(t.portal=W.getDefault()),this._validateItemType(t),t}async _updateFromInternal(e,t){if(t=t||{},await w((()=>e.ready)),this._updateInitialViewProperties(e,t),e.map===this)for(const r of e.allLayerViews)for(const e of["visible","featureEffect"])e in r&&e in r.layer&&r._isOverridden(e)&&(r.layer[e]=r[e]);await this._updateThumbnailUrl(e,t)}_updateInitialViewProperties(e,t){var r;t.backgroundExcluded||(this.initialViewProperties.background=null==(r=e.background)?void 0:r.clone());if(this.initialViewProperties.spatialReference=e.spatialReference.clone(),t.viewpointExcluded||(this.initialViewProperties.viewpoint=new i({rotation:e.rotation,scale:t.scalePreserved?e.scale:null,targetGeometry:this._getViewExtent(e)})),!t.widgetsExcluded)for(const i of e.persistableViewModels)i.updateWebDocument(this)}_getViewExtent(e){const t=e.center.clone().normalize(),r=e.extent.clone(),i=r.width/2;return r.xmin=t.x-i,r.xmax=t.x+i,r}async _updateThumbnailUrl(e,t){if(t.thumbnailExcluded)return;const r=$(e,t.thumbnailSize),i=await e.takeScreenshot({format:"png",width:r.width,height:r.height});this._setAutoGeneratedThumbnail(i.dataUrl)}_setAutoGeneratedThumbnail(e){this.thumbnailUrl=e,this._thumbnailFilename=null}_clearThumbnailOverride(){this._clearOverride("thumbnailUrl"),this.clear("thumbnailUrl","user"),this._thumbnailFilename=null}_generateCustomThumbnailFilename(e){if(g(e)){const t=b(e),r=t&&t.mediaType,i=r&&oe.get(r.toLowerCase())||null,o=`thumbnail${Date.now()}`;return i?`${o}.${i}`:o}return null}_getThumbnailState(){let e=this.thumbnailUrl;return e&&(e=this._isOverridden("thumbnailUrl")?e:_(e,"w","8192")),{thumbnailUrl:e,filename:this._thumbnailFilename}}_restoreThumbnailFromState(e){this.thumbnailUrl=e.thumbnailUrl,this._thumbnailFilename=e.filename}_getAuthoringPropsState(){return{authoringApp:this.authoringApp,authoringAppVersion:this.authoringAppVersion,isAuthoringAppSetByUser:this._isAuthoringAppSetByUser,isAuthoringAppVersionSetByUser:this._isAuthoringAppVersionSetByUser}}_restoreAuthoringPropsFromState(e){e.isAuthoringAppSetByUser?this.authoringApp=e.authoringApp:this._isAuthoringAppSetByUser=!1,e.isAuthoringAppVersionSetByUser?this.authoringAppVersion=e.authoringAppVersion:this._isAuthoringAppVersionSetByUser=!1}static fromJSON(e){const t=e;if(!t)throw new s("webmap:empty-resource","Expected a JSON resource but got nothing");return new this({resourceInfo:t})}};be.VERSION=Z,e([v({type:q,json:{write:!0}})],be.prototype,"applicationProperties",void 0),e([v({type:String,json:{write:{allowNull:!0,ignoreOrigin:!0}}})],be.prototype,"authoringApp",null),e([A("authoringApp")],be.prototype,"writeAuthoringApp",null),e([v({type:String,json:{write:{allowNull:!0,ignoreOrigin:!0}}})],be.prototype,"authoringAppVersion",null),e([A("authoringAppVersion")],be.prototype,"writeAuthoringAppVersion",null),e([v({json:{read:{source:"baseMap"},write:{target:"baseMap"}}})],be.prototype,"basemap",void 0),e([v({type:te,json:{write:{overridePolicy:e=>({enabled:!!(e&&e.length>0),ignoreOrigin:!0})}}})],be.prototype,"bookmarks",void 0),e([v({type:J,json:{read:{source:"mapFloorInfo"},write:{target:"mapFloorInfo"}}})],be.prototype,"floorInfo",void 0),e([v({type:Q,nonNullable:!0,json:{read:{source:["background","initialState.viewpoint","mapRangeInfo","spatialReference"]},write:{ignoreOrigin:!0,target:{background:{type:Y},"initialState.viewpoint":{type:i},mapRangeInfo:{type:D},spatialReference:{type:O}}}}})],be.prototype,"initialViewProperties",void 0),e([S("initialViewProperties")],be.prototype,"readInitialViewProperties",null),e([A("initialViewProperties")],be.prototype,"writeInitialViewProperties",null),e([v({json:{read:!1,write:{target:"operationalLayers",ignoreOrigin:!0}}})],be.prototype,"layers",void 0),e([A("layers")],be.prototype,"writeLayers",null),e([v({type:R})],be.prototype,"portalItem",void 0),e([v({json:{write:!0}})],be.prototype,"presentation",void 0),e([v()],be.prototype,"resourceInfo",void 0),e([v({readOnly:!0,type:X,json:{read:{source:"version"},write:{allowNull:!0,ignoreOrigin:!0,target:"version",isRequired:!0}}})],be.prototype,"sourceVersion",void 0),e([S("sourceVersion")],be.prototype,"readSourceVersion",null),e([A("sourceVersion")],be.prototype,"writeSourceVersion",null),e([v({json:{read:!1,write:{ignoreOrigin:!0}}})],be.prototype,"tables",void 0),e([A("tables")],be.prototype,"writeTables",null),e([v()],be.prototype,"thumbnailUrl",null),e([v({type:K,json:{write:!0}})],be.prototype,"widgets",void 0),e([v({type:re,json:{read:!0,write:!0}})],be.prototype,"utilityNetworks",void 0),be=e([I("esri.WebMap")],be);const _e=be;export{_e as default};
package/WebScene.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/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"./chunks/tslib.es6.js";import{version as t}from"./kernel.js";import r from"./Map.js";import i from"./Viewpoint.js";import o from"./core/Collection.js";import s from"./core/Error.js";import a from"./core/Handles.js";import"./core/has.js";import{clone as n}from"./core/lang.js";import l from"./core/Loadable.js";import{loadAll as p}from"./core/loadAll.js";import c from"./core/Logger.js";import{isSome as d}from"./core/maybe.js";import{MultiOriginJSONMixin as h,MultiOriginJSONSupport as u}from"./core/MultiOriginJSONSupport.js";import{EsriPromiseMixin as m}from"./core/Promise.js";import{debounce as y,eachAlways as w}from"./core/promiseUtils.js";import{urlToObject as g,addQueryParameter as f}from"./core/urlUtils.js";import{property as v}from"./core/accessorSupport/decorators/property.js";import"./core/accessorSupport/ensureType.js";import{reader as b}from"./core/accessorSupport/decorators/reader.js";import{subclass as S}from"./core/accessorSupport/decorators/subclass.js";import{writer as A}from"./core/accessorSupport/decorators/writer.js";import{updateOrigins as I}from"./core/accessorSupport/originUtils.js";import{readLoadable as _}from"./core/accessorSupport/read.js";import j from"./geometry/Extent.js";import R from"./geometry/HeightModelInfo.js";import{canProjectWithoutEngine as V}from"./geometry/projection.js";import L from"./geometry/SpatialReference.js";import{validateWebSceneError as P}from"./geometry/support/heightModelInfoUtils.js";import{fromJSON as U}from"./geometry/support/jsonUtils.js";import{isEarth as M}from"./geometry/support/spatialReferenceUtils.js";import O from"./portal/Portal.js";import E from"./portal/PortalItem.js";import N from"./support/MapFloorInfo.js";import{createSchemaValidationError as C,createCopyError as T}from"./support/webSceneUtils.js";import{ViewingMode as G}from"./views/ViewingMode.js";import{isSpatialReferenceSupported as F}from"./views/support/spatialReferenceSupport.js";import{saveResources as W}from"./webdoc/support/saveUtils.js";import{getOptimalThumbnailSize as $}from"./webdoc/support/thumbnailUtils.js";import J from"./webscene/ApplicationProperties.js";import x from"./webscene/Environment.js";import k from"./webscene/InitialViewProperties.js";import B from"./webscene/Presentation.js";import q from"./webscene/TransportationNetwork.js";import{Version as K}from"./webscene/Version.js";const D=c.getLogger("esri.WebScene"),H=new K(1,28),z=()=>{const e=8,t=[],r=H.major;for(let i=e;i<=H.minor;i++)t.push(`${r}.${i}`);return t},Q="Web Scene",X="ViewingMode-Local";let Y=class extends(l.LoadableMixin(m(h(r)))){constructor(e){super(e),this._handles=new a,this.applicationProperties=null,this.clippingArea=null,this.clippingEnabled=!1,this.floorInfo=null,this.heightModelInfo=null,this.sourceVersion=null,this.transportationNetworks=null,this.presentation=new B,this.initialViewProperties=new k,this.portalItem=null,this.resourceInfo=null,this._debouncedSaveOperations=y((async(e,t,r)=>{switch(e){case Z.SAVE:return this._saveImpl(t);case Z.SAVE_AS:return this._saveAsImpl(r,t)}})),this.resourceReferences={portalItem:null,paths:[]},this.authoringApp=null,this.authoringAppVersion=null,this._isAuthoringAppSetByUser=!1,this._isAuthoringAppVersionSetByUser=!1}initialize(){if(this.when().catch((e=>{D.error("#load()","Failed to load web scene",e)})),this.resourceInfo){let t;try{t=this._validateJSON(this.resourceInfo)}catch(e){return void this.addResolvingPromise(Promise.reject(e))}this.read(t),this.addResolvingPromise(this._validateSpatialReference()),this.addResolvingPromise(this._validateHeightModelInfo())}this._handles.add(this.allLayers.on("change",(()=>this._scheduleLayersIdGC())))}destroy(){this._unscheduleLayersIdGC(),this._handles.destroy(),this.presentation&&this.presentation.destroy();const e=this.portalItem;this.portalItem=null,null==e||e.destroy()}writeClippingArea(e,t){t.clippingArea||(t.clippingArea={}),t.clippingArea.geometry=e.toJSON()}readClippingEnabled(e,t){return!!t.clippingArea&&!!t.clippingArea.clip}writeClippingEnabled(e,t){this.clippingArea&&(t.clippingArea||(t.clippingArea={}),t.clippingArea.clip=e)}writeLayers(e,t,r,i){const o={...i,layerContainerType:"operational-layers"},s=e.map((e=>this.verifyWriteLayer(e,i)?e.write({},o):null)).filter((e=>!!e));t[r]=s.toArray()}verifyWriteLayer(e,t){return"write"in e||(t&&t.messages&&t.messages.push(new s("layer:unsupported",`Layers (${e.title}, ${e.id}) of type '${e.declaredClass}' cannot be persisted in web scenes`,{layer:e})),!1)}readSourceVersion(e,t){const[r,i]=t.version.split(".");return new K(parseInt(r,10),parseInt(i,10))}writeSourceVersion(e,t,r){t[r]=`${H.major}.${H.minor}`}get thumbnailUrl(){return this.portalItem&&this.portalItem.thumbnailUrl||null}set thumbnailUrl(e){e?this._override("thumbnailUrl",e):(this._clearOverride("thumbnailUrl"),this.clear("thumbnailUrl","user"))}set authoringApp(e){this._isAuthoringAppSetByUser=!0,this._set("authoringApp",e)}writeAuthoringApp(e,t){e&&this._isAuthoringAppSetByUser?t.authoringApp=e:t.authoringApp="ArcGIS API for JavaScript"}set authoringAppVersion(e){this._isAuthoringAppVersionSetByUser=!0,this._set("authoringAppVersion",e)}writeAuthoringAppVersion(e,r){e&&this._isAuthoringAppVersionSetByUser?r.authoringAppVersion=e:r.authoringAppVersion=t}writeGround(e,t,r,i){t[r]=e?e.write({},i):{transparency:0,layers:[]}}readInitialViewProperties(e,t){const r={};return t.initialState&&t.initialState.environment&&(r.environment=x.fromJSON(t.initialState.environment)),t.spatialReference?r.spatialReference=L.fromJSON(t.spatialReference):r.spatialReference=L.WebMercator,r.viewingMode=t.viewingMode||"global",t.initialState&&t.initialState.viewpoint&&(r.viewpoint=i.fromJSON(t.initialState.viewpoint)),new k(r)}get spatialReference(){var e,t;return null!=(e=null==(t=this.initialViewProperties)?void 0:t.spatialReference)?e:L.WebMercator}get viewingMode(){var e,t;return null!=(e=null==(t=this.initialViewProperties)?void 0:t.viewingMode)?e:"global"}load(e){return this.addResolvingPromise(this._loadFromSource()),Promise.resolve(this)}loadAll(){return p(this,(e=>{const t=this.presentation&&this.presentation.slides;e(this.ground,this.basemap,this.layers,t&&t.map((e=>e.basemap)))}))}read(e,t){t={...t,origin:"web-scene"};const r=this._isAuthoringAppVersionSetByUser,i=this._isAuthoringAppSetByUser;if(_(this,e,(t=>super.read(e,t)),t),i||(this._isAuthoringAppSetByUser=!1),r||(this._isAuthoringAppVersionSetByUser=!1),e.baseMap&&Array.isArray(e.baseMap.elevationLayers)&&this.sourceVersion.supportsVisibleElevationLayersInSlides){const t=e.baseMap.elevationLayers.map((e=>({id:e.id}))),r=this.presentation.slides,i=(e,t)=>e.visibleLayers.some((e=>e.id===t)),o=t.filter((e=>!r.some((t=>i(t,e.id)))));r.forEach((e=>{e.visibleLayers.addMany(o)}))}}_writeBasemapElevationLayers(e){const t=e.ground&&e.ground.layers;!e.baseMap&&t&&t.length&&(e.baseMap={title:"Basemap",baseMapLayers:[]}),e.baseMap&&(e.baseMap.elevationLayers=n(t))}write(e,t){var r;if("loaded"!==this.loadStatus){const e=new s("webscene:not-loaded","Web scene must be loaded before it can be serialized");throw D.error("#toJSON()","Web scene must be loaded before it can be serialized",this.loadError||this.loadStatus),e}this._runLayersIdGC();const i=!(null!=(r=t)&&r.messages);t={messages:[],...t,origin:"web-scene"};const o=super.write(e,t);if(i){const e=t.messages.filter((e=>"web-document-write:property-required"===e.name));if(e.length){const t=new s("web-document:property-required","One or more properties that are required in the webscene JSON are missing, see details for the specific errors",{errors:e});throw D.error("#toJSON()","One or more properties that are required in the webscene JSON are missing",e),t}}return this._writeBasemapElevationLayers(o),o}async save(e){return this._debouncedSaveOperations(Z.SAVE,e)}async _saveImpl(e){this.portalItem||(D.error("save(): requires the .portalItem property to be set"),await Promise.reject(new s("webscene:portal-item-not-set","Portal item to save to has not been set on the WebScene"))),this.portalItem.type!==Q&&await Promise.reject(new s("webscene:portal-item-wrong-type",`Portal item needs to have type "${Q}"`));const t=this._updateFromPromise;await this._ensureLoadBeforeSave();const r=this._enableVerifyItemRelativeUrls({origin:"web-scene",url:this.portalItem.itemUrl&&g(this.portalItem.itemUrl),messages:[],portal:this.portalItem.portal||O.getDefault(),portalItem:this.portalItem,writtenProperties:[],blockedRelativeUrls:[],resources:{toAdd:[],toUpdate:[],toKeep:[],pendingOperations:[]}}),i=this.write({},r);return await Promise.all(r.resources.pendingOperations),await this._verifySave(i,r,e),this._updateTypeKeywords(this.portalItem),await this.portalItem.update({data:i}),await W(this.resourceReferences,r,null),I(r),t&&await t,await this._saveThumbnail(),this.portalItem}async saveAs(e,t){return this._debouncedSaveOperations(Z.SAVE_AS,t,e)}async _saveAsImpl(e,t){let r=E.from(e);r||(D.error("saveAs(portalItem): requires a portal item parameter"),await Promise.reject(new s("webscene:portal-item-required","saveAs requires a portal item to save to"))),r.id&&(r=r.clone(),r.id=null);const i=r.portal||O.getDefault();await this._ensureLoadBeforeSave(),r.type=Q,r.portal=i;const o=this._enableVerifyItemRelativeUrls({origin:"web-scene",url:null,messages:[],portal:i,portalItem:r,writtenProperties:[],blockedRelativeUrls:[],resources:{toAdd:[],toUpdate:[],toKeep:[],pendingOperations:[]}}),a=this.write({},o);await Promise.all(o.resources.pendingOperations),await this._verifySaveAs(a,o,t);const n=this.thumbnailUrl,l=!this._isOverridden("thumbnailUrl");return this._updateTypeKeywords(r),await i._signIn(),await i.user.addItem({item:r,folder:t&&t.folder,data:a}),await W(this.resourceReferences,o,null),this.portalItem=r,u.prototype.read.call(this,{version:a.version,authoringApp:a.authoringApp,authoringAppVersion:a.authoringAppVersion},{name:"web-scene",ignoreDefaults:!0,url:r.itemUrl&&g(r.itemUrl)}),I(o),n&&(this.thumbnailUrl=l?f(n,"w","8192"):n),o.portalItem=r,await this._saveThumbnail(),r}async _saveThumbnail(){this._isOverridden("thumbnailUrl")&&(await this.portalItem.updateThumbnail({thumbnail:this.thumbnailUrl}),this._clearOverride("thumbnailUrl"),this.clear("thumbnailUrl","user"))}_verifySave(e,t,r,i=!1){if(!M(this.spatialReference))return Promise.reject(new s("webscene:unsupported-spatial-reference","Webscenes using spatial reference systems from Mars or Moon can not be saved currently."));let o,a=t.messages.filter((e=>"error"===e.type)).map((e=>new s(e.name,e.message,e.details)));t.blockedRelativeUrls&&(a=a.concat(t.blockedRelativeUrls.map((e=>new s("url:unsupported",`Relative url '${e}' is not supported in Web Scene`))))),r&&r.ignoreUnsupported&&(a=a.filter((e=>"layer:unsupported"!==e.name&&"symbol:unsupported"!==e.name&&"symbol-layer:unsupported"!==e.name&&"property:unsupported"!==e.name&&"url:unsupported"!==e.name&&"scenemodification:unsupported"!==e.name))),null!=r&&r.requiredPropertyChecksDisabled&&(a=a.filter((e=>"web-document-write:property-required"!==e.name)));const n=r&&r.strictSchemaValidationEnabled;return o=n?import("./webscene/support/schemaValidator.js").then((t=>{const r=t.validate(e);if(r.length>0){const e=`webscene did not validate:\n${r.join("\n")}`;D.error(`${i?"saveAs":"save"}(): ${e}`)}return r.map((e=>new s("webscene:schema-validation",e)))})).then((e=>{if(n&&e.length>0){throw C(e.concat(a))}return a})):Promise.resolve(a),o.then((e=>{if(e.length>0)throw new s("webscene:save","Failed to save webscene due to unsupported or invalid content. See 'details.errors' for more detailed information",{errors:e})}))}_verifySaveAs(e,t,r){return this.canNotSaveAs(t)?Promise.reject(T()):this._verifySave(e,t,r,!0)}verifySaveAs(e){const t=this._enableVerifyItemRelativeUrls({origin:"web-scene",messages:[]}),r=this.write({},t);return this._verifySaveAs(r,t,e)}canNotSaveAs(e){return e||(e=this._enableVerifyItemRelativeUrls({origin:"web-scene",messages:[]}),this.write({},e)),e.verifyItemRelativeUrls&&e.verifyItemRelativeUrls.writtenUrls.length>0}async updateFrom(e,t={}){const r=this._updateFrom(e,t);this._updateFromPromise=r,await r;this._updateFromPromise===r&&(this._updateFromPromise=null)}async _updateFrom(e,t={}){if(await e.whenReady(),!t.environmentExcluded&&e.environment){if(e.environment.lighting.type&&"sun"!==e.environment.lighting.type)throw new s("lighting:unsupported",`${e.environment.lighting.type} lighting cannot be stored in WebScene`);this.initialViewProperties.environment=x.prototype.clone.apply(e.environment)}if(!t.viewpointExcluded&&e.viewpoint&&(this.initialViewProperties.viewpoint=e.viewpoint.clone()),this.initialViewProperties.spatialReference=e.spatialReference.clone(),this.initialViewProperties.viewingMode=e.viewingMode,d(e.clippingArea)?e.clippingArea!==this.clippingArea&&(this.clippingArea=e.clippingArea.clone(),this.clippingEnabled=!0):this.clippingEnabled=!1,e.heightModelInfo&&(this.heightModelInfo=e.heightModelInfo.clone()),e.map===this)for(const r of e.allLayerViews){const e="visible";e in r&&e in r.layer&&r._isOverridden(e)&&(r.layer[e]=r[e])}(!1===t.thumbnailExcluded||null==t.thumbnailExcluded&&!t.viewpointExcluded)&&await this._updateFromThumbnail(e,t.thumbnailSize||void 0)}async _updateFromThumbnail(e,t){const r=$(e,t),i=await e.takeScreenshot({format:"jpg",width:r.width,height:r.height,disableDecorations:!0});this.thumbnailUrl=i.dataUrl}_loadFromSource(){return this.resourceInfo?this._loadFromJSON(this.resourceInfo,{origin:"web-scene"}):this.portalItem&&this.portalItem.id?this._loadFromItem(this.portalItem):this._loadObjectsWithLayers()}_readAndLoadFromJSON(e,t){const r=this._validateJSON(e);return this.read(r,t),this._loadFromJSON(r,t)}_extractOperationalLayers(e){const t=[];if(!this.sourceVersion.supportsGround&&e.baseMap&&Array.isArray(e.baseMap.elevationLayers))for(const o of e.baseMap.elevationLayers)t.push(o);const r=[],i=e=>(e.layers&&(e.layers=e.layers.filter(i)),"ArcGISTiledElevationServiceLayer"!==e.layerType||(this.sourceVersion.supportsGround||r.push(e),!1));return{operationalLayers:e.operationalLayers?e.operationalLayers.filter(i):[],operationalElevationLayers:r,basemapElevationLayers:t}}_loadFromJSON(e,t){const r=new o;return this._validateSpatialReference().then((()=>this._validateHeightModelInfo())).then((()=>import("./layers/support/layersCreator.js"))).then((({populateOperationalLayers:i})=>{const{operationalLayers:o,operationalElevationLayers:s,basemapElevationLayers:a}=this._extractOperationalLayers(e),n=[],l={context:{...t,layerContainerType:"operational-layers"}};if(this.portalItem&&(l.context.portal=this.portalItem.portal||O.getDefault()),a.length>0){const e={...l,context:{...l.context,layerContainerType:"ground"}};e.defaultLayerType="ArcGISTiledElevationServiceLayer",n.push(i(this.ground.layers,a,e))}if(s.length>0){const e={...l,context:{...l.context,layerContainerType:"ground"}};e.defaultLayerType="ArcGISTiledElevationServiceLayer",n.push(i(r,s,e))}return o&&o.length>0&&n.push(i(this.layers,o,l)),w(n).then((()=>{}))})).then((()=>this._loadObjectsWithLayers())).then((()=>{this.ground.layers.addMany(r)}))}async _ensureLoadBeforeSave(){await this.load(),await this._loadObjectsWithLayers();const e=[];for(const t of this.allLayers.items)if("beforeSave"in t&&"function"==typeof t.beforeSave){const r=t.beforeSave();r&&e.push(r)}await w(e)}async _loadObjectsWithLayers(){const e=[];this.ground&&e.push(this.ground.load()),this.basemap&&e.push(this.basemap.load()),this.presentation.slides.forEach((t=>{t.basemap&&e.push(t.basemap.load())})),await w(e)}async _loadFromItem(e){if(await e.load().catch((e=>{throw new s("webscene:load-portal-item","Failed to load portal item",{error:e})})),"Web Scene"!==e.type)throw new s("webscene:invalid-portal-item","Invalid portal item type '${type}', expected 'Web Scene'",{type:e.type});const t=await e.fetchData();this.resourceInfo=t;const r={origin:"web-scene",url:g(e.itemUrl),portal:e.portal||O.getDefault(),portalItem:e,readResourcePaths:[]};await this._readAndLoadFromJSON(t,r),this.resourceReferences={portalItem:e,paths:r.readResourcePaths}}_validateSpatialReference(){const e=this.initialViewProperties,t=this._sceneSpatialReference;let r;if("local"!==e.viewingMode){if(!F(t,G.Global))return Promise.reject(new s("webscene:unsupported-spatial-reference","Unsupported spatial reference (${spatialReference.wkid}) in global mode, only Web Mercator, WGS84 GCS or CGCS2000 are supported",{spatialReference:t,viewingMode:e.viewingMode}));r=e=>!e||V(e,t)}else{if(!F(t,G.Local))return Promise.reject(new s("webscene:unsupported-spatial-reference","Unsupported spatial reference (${spatialReference.wkid}) in local mode, only projected coordinate systems are supported",{spatialReference:t,viewingMode:e.viewingMode}));r=e=>!e||e.equals(t)}const i=e=>e&&(d(e.camera)&&e.camera.position&&e.camera.position.spatialReference||d(e.targetGeometry)&&e.targetGeometry.spatialReference),o=e.viewpoint,a=i(o);if(a&&!r(a))return Promise.reject(new s("webscene:incompatible-camera-spatial-reference","Camera spatial reference (${cameraSpatialReference.wkid}) is incompatible with the scene spatial reference (${sceneSpatialReference.wkid})",{cameraSpatialReference:a,sceneSpatialReference:t,viewingMode:e.viewingMode}));const n=this.presentation.slides.find((e=>!r(i(e.viewpoint))));if(n){const r=i(n.viewpoint);return Promise.reject(new s("webscene:incompatible-slide-spatial-reference","Slide spatial reference (${slideSpatialReference.wkid}) is incompatible with the scene spatial reference (${sceneSpatialReference.wkid})",{slideSpatialReference:r,sceneSpatialReference:t,viewingMode:e.viewingMode}))}return Promise.resolve()}_validateHeightModelInfo(){const e=this._sceneSpatialReference,t=P(this.heightModelInfo,e);return t?Promise.reject(t):Promise.resolve()}_validateJSON(e){const t=K.parse(e.version||"","webscene");return H.validate(t),e.version=`${t.major}.${t.minor}`,1===t.major&&t.minor<=2&&(e.spatialReference=L.WebMercator.toJSON()),e}_updateTypeKeywords(e){"local"===this.initialViewProperties.viewingMode?e.typeKeywords?e.typeKeywords.includes(X)||e.typeKeywords.push(X):e.typeKeywords=[X]:"global"===this.initialViewProperties.viewingMode&&e.typeKeywords&&(e.typeKeywords=e.typeKeywords.filter((e=>e!==X))),e.typeKeywords&&(e.typeKeywords=e.typeKeywords.filter(((e,t,r)=>r.indexOf(e)===t)))}get _sceneSpatialReference(){return this.initialViewProperties.spatialReference||L.WebMercator}get _verifyItemRelativeRootPath(){return this.portalItem&&this.portalItem.itemUrl?g(this.portalItem.itemUrl).path:null}_enableVerifyItemRelativeUrls(e){const t=this._verifyItemRelativeRootPath;return t&&(e.verifyItemRelativeUrls={rootPath:t,writtenUrls:[]}),e}_unscheduleLayersIdGC(){this._layersIdGCTimeoutId&&(clearTimeout(this._layersIdGCTimeoutId),this._layersIdGCTimeoutId=0)}_scheduleLayersIdGC(){this._unscheduleLayersIdGC(),this._layersIdGCTimeoutId=setTimeout((()=>{this._layersIdGCTimeoutId=0,this._runLayersIdGC()}),3e3)}_runLayersIdGC(){this._unscheduleLayersIdGC();const e=this.applicationProperties&&this.applicationProperties.viewing&&this.applicationProperties.viewing.search,t=e=>!!this.allLayers.find((t=>t.id===e));e&&e.layers&&(e.layers=e.layers.filter((e=>t(e.id))));const r=this.presentation&&this.presentation.slides;r&&r.forEach((e=>{e.visibleLayers&&(e.visibleLayers=e.visibleLayers.filter((e=>t(e.id))))}))}static fromJSON(e){if(!e)throw new s("webscene:empty-resource","Expected a JSON resource but got nothing");return new this({resourceInfo:e})}};var Z;Y.VERSION=H,e([v({type:J,json:{write:!0}})],Y.prototype,"applicationProperties",void 0),e([v({json:{read:{source:"baseMap"},write:{target:"baseMap"}}})],Y.prototype,"basemap",void 0),e([v({type:j,json:{read:{source:"clippingArea.geometry",reader:U},write:{target:"clippingArea.geometry"}}})],Y.prototype,"clippingArea",void 0),e([A("clippingArea")],Y.prototype,"writeClippingArea",null),e([v({type:Boolean,json:{write:{target:"clippingArea.clip"}}})],Y.prototype,"clippingEnabled",void 0),e([b("clippingEnabled",["clippingArea"])],Y.prototype,"readClippingEnabled",null),e([A("clippingEnabled")],Y.prototype,"writeClippingEnabled",null),e([v({type:N,json:{read:{source:"mapFloorInfo"},write:{target:"mapFloorInfo"}}})],Y.prototype,"floorInfo",void 0),e([v({type:R,json:{write:!0}})],Y.prototype,"heightModelInfo",void 0),e([v({json:{write:{target:"operationalLayers",ignoreOrigin:!0}}})],Y.prototype,"layers",void 0),e([A("layers")],Y.prototype,"writeLayers",null),e([v({readOnly:!0,type:K,json:{type:z(),write:{ignoreOrigin:!0,target:"version",isRequired:!0,overridePolicy:()=>({enabled:!0,allowNull:!0,ignoreOrigin:!0})}}})],Y.prototype,"sourceVersion",void 0),e([b("sourceVersion",["version"])],Y.prototype,"readSourceVersion",null),e([A("sourceVersion")],Y.prototype,"writeSourceVersion",null),e([v({json:{read:!1,write:!1}})],Y.prototype,"tables",void 0),e([v()],Y.prototype,"thumbnailUrl",null),e([v({type:String,json:{write:{writerEnsuresNonNull:!0,ignoreOrigin:!0}}})],Y.prototype,"authoringApp",null),e([A("authoringApp")],Y.prototype,"writeAuthoringApp",null),e([v({type:String,json:{write:{writerEnsuresNonNull:!0,ignoreOrigin:!0}}})],Y.prototype,"authoringAppVersion",null),e([A("authoringAppVersion")],Y.prototype,"writeAuthoringAppVersion",null),e([v({json:{write:{isRequired:!0,allowNull:!0,ignoreOrigin:!0,enabled:!0}}})],Y.prototype,"ground",void 0),e([A("ground")],Y.prototype,"writeGround",null),e([v({type:o.ofType(q),json:{write:!0}})],Y.prototype,"transportationNetworks",void 0),e([v({type:B,nonNullable:!0,json:{write:{ignoreOrigin:!0,writer:(e,t,r,i)=>{if(e.slides&&e.slides.length>0){const r={...i,isPresentation:!0};t.presentation=e.write({},r)}}}}})],Y.prototype,"presentation",void 0),e([v({type:k,nonNullable:!0,json:{write:{target:"initialState",isRequired:!0,ignoreOrigin:!0},default:()=>new k({viewingMode:"global",spatialReference:L.WebMercator})}})],Y.prototype,"initialViewProperties",void 0),e([b("initialViewProperties",["initialState.environment","spatialReference","viewingMode","initialState.viewpoint"])],Y.prototype,"readInitialViewProperties",null),e([v({type:L,json:{read:!1,write:{isRequired:!0,ignoreOrigin:!0}}})],Y.prototype,"spatialReference",null),e([v({type:["local","global"],json:{read:!1,write:{isRequired:!0,ignoreOrigin:!0}}})],Y.prototype,"viewingMode",null),e([v({type:E})],Y.prototype,"portalItem",void 0),e([v()],Y.prototype,"resourceInfo",void 0),Y=e([S("esri.WebScene")],Y),function(e){e[e.SAVE=0]="SAVE",e[e.SAVE_AS=1]="SAVE_AS"}(Z||(Z={}));const ee=Y;export{ee as default};
5
+ import{_ as e}from"./chunks/tslib.es6.js";import{version as t}from"./kernel.js";import r from"./Map.js";import i from"./Viewpoint.js";import o from"./core/Collection.js";import s from"./core/Error.js";import a from"./core/Handles.js";import"./core/has.js";import{clone as n}from"./core/lang.js";import l from"./core/Loadable.js";import{loadAll as p}from"./core/loadAll.js";import c from"./core/Logger.js";import{isSome as d}from"./core/maybe.js";import{MultiOriginJSONMixin as h,MultiOriginJSONSupport as u}from"./core/MultiOriginJSONSupport.js";import{EsriPromiseMixin as m}from"./core/Promise.js";import{debounce as y,eachAlways as w}from"./core/promiseUtils.js";import{urlToObject as g,addQueryParameter as f}from"./core/urlUtils.js";import{property as v}from"./core/accessorSupport/decorators/property.js";import"./core/accessorSupport/ensureType.js";import{reader as b}from"./core/accessorSupport/decorators/reader.js";import{subclass as S}from"./core/accessorSupport/decorators/subclass.js";import{writer as A}from"./core/accessorSupport/decorators/writer.js";import{updateOrigins as I}from"./core/accessorSupport/originUtils.js";import{readLoadable as _}from"./core/accessorSupport/read.js";import j from"./geometry/Extent.js";import R from"./geometry/HeightModelInfo.js";import{canProjectWithoutEngine as V}from"./geometry/projection.js";import L from"./geometry/SpatialReference.js";import{validateWebSceneError as P}from"./geometry/support/heightModelInfoUtils.js";import{fromJSON as U}from"./geometry/support/jsonUtils.js";import{isEarth as M}from"./geometry/support/spatialReferenceUtils.js";import O from"./portal/Portal.js";import E from"./portal/PortalItem.js";import N from"./support/MapFloorInfo.js";import{createSchemaValidationError as C,createCopyError as T}from"./support/webSceneUtils.js";import{ViewingMode as G}from"./views/ViewingMode.js";import{isSpatialReferenceSupported as F}from"./views/support/spatialReferenceSupport.js";import{saveResources as W}from"./webdoc/support/saveUtils.js";import{getOptimalThumbnailSize as $}from"./webdoc/support/thumbnailUtils.js";import J from"./webscene/ApplicationProperties.js";import x from"./webscene/Environment.js";import k from"./webscene/InitialViewProperties.js";import B from"./webscene/Presentation.js";import q from"./webscene/TransportationNetwork.js";import{Version as K}from"./webscene/Version.js";const D=c.getLogger("esri.WebScene"),H=new K(1,28),z=()=>{const e=8,t=[],r=H.major;for(let i=e;i<=H.minor;i++)t.push(`${r}.${i}`);return t},Q="Web Scene",X="ViewingMode-Local";let Y=class extends(l.LoadableMixin(m(h(r)))){constructor(e){super(e),this._handles=new a,this.applicationProperties=null,this.clippingArea=null,this.clippingEnabled=!1,this.floorInfo=null,this.heightModelInfo=null,this.sourceVersion=null,this.transportationNetworks=null,this.presentation=new B,this.initialViewProperties=new k,this.portalItem=null,this.resourceInfo=null,this._debouncedSaveOperations=y((async(e,t,r)=>{switch(e){case Z.SAVE:return this._saveImpl(t);case Z.SAVE_AS:return this._saveAsImpl(r,t)}})),this.resourceReferences={portalItem:null,paths:[]},this.authoringApp=null,this.authoringAppVersion=null,this._isAuthoringAppSetByUser=!1,this._isAuthoringAppVersionSetByUser=!1}initialize(){if(this.when().catch((e=>{D.error("#load()","Failed to load web scene",e)})),this.resourceInfo){let t;try{t=this._validateJSON(this.resourceInfo)}catch(e){return void this.addResolvingPromise(Promise.reject(e))}this.read(t),this.addResolvingPromise(this._validateSpatialReference()),this.addResolvingPromise(this._validateHeightModelInfo())}this._handles.add(this.allLayers.on("change",(()=>this._scheduleLayersIdGC())))}destroy(){this._unscheduleLayersIdGC(),this._handles.destroy(),this.presentation&&this.presentation.destroy();const e=this.portalItem;this.portalItem=null,null==e||e.destroy()}writeClippingArea(e,t){t.clippingArea||(t.clippingArea={}),t.clippingArea.geometry=e.toJSON()}readClippingEnabled(e,t){return!!t.clippingArea&&!!t.clippingArea.clip}writeClippingEnabled(e,t){this.clippingArea&&(t.clippingArea||(t.clippingArea={}),t.clippingArea.clip=e)}writeLayers(e,t,r,i){const o={...i,layerContainerType:"operational-layers"},s=e.map((e=>this.verifyWriteLayer(e,i)?e.write({},o):null)).filter((e=>!!e));t[r]=s.toArray()}verifyWriteLayer(e,t){return"write"in e||(t&&t.messages&&t.messages.push(new s("layer:unsupported",`Layers (${e.title}, ${e.id}) of type '${e.declaredClass}' cannot be persisted in web scenes`,{layer:e})),!1)}readSourceVersion(e,t){const[r,i]=t.version.split(".");return new K(parseInt(r,10),parseInt(i,10))}writeSourceVersion(e,t,r){t[r]=`${H.major}.${H.minor}`}get thumbnailUrl(){return this.portalItem&&this.portalItem.thumbnailUrl||null}set thumbnailUrl(e){e?this._override("thumbnailUrl",e):(this._clearOverride("thumbnailUrl"),this.clear("thumbnailUrl","user"))}set authoringApp(e){this._isAuthoringAppSetByUser=!0,this._set("authoringApp",e)}writeAuthoringApp(e,t){e&&this._isAuthoringAppSetByUser?t.authoringApp=e:t.authoringApp="ArcGIS API for JavaScript"}set authoringAppVersion(e){this._isAuthoringAppVersionSetByUser=!0,this._set("authoringAppVersion",e)}writeAuthoringAppVersion(e,r){e&&this._isAuthoringAppVersionSetByUser?r.authoringAppVersion=e:r.authoringAppVersion=t}writeGround(e,t,r,i){t[r]=e?e.write({},i):{transparency:0,layers:[]}}readInitialViewProperties(e,t){const r={};return t.initialState&&t.initialState.environment&&(r.environment=x.fromJSON(t.initialState.environment)),t.spatialReference?r.spatialReference=L.fromJSON(t.spatialReference):r.spatialReference=L.WebMercator,r.viewingMode=t.viewingMode||"global",t.initialState&&t.initialState.viewpoint&&(r.viewpoint=i.fromJSON(t.initialState.viewpoint)),new k(r)}get spatialReference(){var e,t;return null!=(e=null==(t=this.initialViewProperties)?void 0:t.spatialReference)?e:L.WebMercator}get viewingMode(){var e,t;return null!=(e=null==(t=this.initialViewProperties)?void 0:t.viewingMode)?e:"global"}load(e){return this.addResolvingPromise(this._loadFromSource()),Promise.resolve(this)}loadAll(){return p(this,(e=>{const t=this.presentation&&this.presentation.slides;e(this.ground,this.basemap,this.layers,t&&t.map((e=>e.basemap)))}))}read(e,t){t={...t,origin:"web-scene"};const r=this._isAuthoringAppVersionSetByUser,i=this._isAuthoringAppSetByUser;if(_(this,e,(t=>super.read(e,t)),t),i||(this._isAuthoringAppSetByUser=!1),r||(this._isAuthoringAppVersionSetByUser=!1),e.baseMap&&Array.isArray(e.baseMap.elevationLayers)&&this.sourceVersion.supportsVisibleElevationLayersInSlides){const t=e.baseMap.elevationLayers.map((e=>({id:e.id}))),r=this.presentation.slides,i=(e,t)=>e.visibleLayers.some((e=>e.id===t)),o=t.filter((e=>!r.some((t=>i(t,e.id)))));r.forEach((e=>{e.visibleLayers.addMany(o)}))}}_writeBasemapElevationLayers(e){const t=e.ground&&e.ground.layers;!e.baseMap&&t&&t.length&&(e.baseMap={title:"Basemap",baseMapLayers:[]}),e.baseMap&&(e.baseMap.elevationLayers=n(t))}write(e,t){var r;if("loaded"!==this.loadStatus){const e=new s("webscene:not-loaded","Web scene must be loaded before it can be serialized");throw D.error("#toJSON()","Web scene must be loaded before it can be serialized",this.loadError||this.loadStatus),e}this._runLayersIdGC();const i=!(null!=(r=t)&&r.messages);t={messages:[],...t,origin:"web-scene"};const o=super.write(e,t);if(i){const e=t.messages.filter((e=>"web-document-write:property-required"===e.name));if(e.length){const t=new s("web-document:property-required","One or more properties that are required in the webscene JSON are missing, see details for the specific errors",{errors:e});throw D.error("#toJSON()","One or more properties that are required in the webscene JSON are missing",e),t}}return this._writeBasemapElevationLayers(o),o}async save(e){return this._debouncedSaveOperations(Z.SAVE,e)}async _saveImpl(e){this.portalItem||(D.error("save(): requires the .portalItem property to be set"),await Promise.reject(new s("webscene:portal-item-not-set","Portal item to save to has not been set on the WebScene"))),this.portalItem.type!==Q&&await Promise.reject(new s("webscene:portal-item-wrong-type",`Portal item needs to have type "${Q}"`));const t=this._updateFromPromise;await this._ensureLoadBeforeSave();const r=this._enableVerifyItemRelativeUrls({origin:"web-scene",url:this.portalItem.itemUrl&&g(this.portalItem.itemUrl),messages:[],portal:this.portalItem.portal||O.getDefault(),portalItem:this.portalItem,writtenProperties:[],blockedRelativeUrls:[],resources:{toAdd:[],toUpdate:[],toKeep:[],pendingOperations:[]}}),i=this.write({},r);return await Promise.all(r.resources.pendingOperations),await this._verifySave(i,r,e),this._updateTypeKeywords(this.portalItem),await this.portalItem.update({data:i}),await W(this.resourceReferences,r,null),I(r),t&&await t,await this._saveThumbnail(),this.portalItem}async saveAs(e,t){return this._debouncedSaveOperations(Z.SAVE_AS,t,e)}async _saveAsImpl(e,t){let r=E.from(e);r||(D.error("saveAs(portalItem): requires a portal item parameter"),await Promise.reject(new s("webscene:portal-item-required","saveAs requires a portal item to save to"))),r.id&&(r=r.clone(),r.id=null);const i=r.portal||O.getDefault();await this._ensureLoadBeforeSave(),r.type=Q,r.portal=i;const o=this._enableVerifyItemRelativeUrls({origin:"web-scene",url:null,messages:[],portal:i,portalItem:r,writtenProperties:[],blockedRelativeUrls:[],resources:{toAdd:[],toUpdate:[],toKeep:[],pendingOperations:[]}}),a=this.write({},o);await Promise.all(o.resources.pendingOperations),await this._verifySaveAs(a,o,t);const n=this.thumbnailUrl,l=!this._isOverridden("thumbnailUrl");return this._updateTypeKeywords(r),await i._signIn(),await i.user.addItem({item:r,folder:t&&t.folder,data:a}),await W(this.resourceReferences,o,null),this.portalItem=r,u.prototype.read.call(this,{version:a.version,authoringApp:a.authoringApp,authoringAppVersion:a.authoringAppVersion},{name:"web-scene",ignoreDefaults:!0,url:r.itemUrl&&g(r.itemUrl)}),I(o),n&&(this.thumbnailUrl=l?f(n,"w","8192"):n),o.portalItem=r,await this._saveThumbnail(),r}async _saveThumbnail(){this._isOverridden("thumbnailUrl")&&(await this.portalItem.updateThumbnail({thumbnail:this.thumbnailUrl}),this._clearOverride("thumbnailUrl"),this.clear("thumbnailUrl","user"))}_verifySave(e,t,r,i=!1){if(!M(this.spatialReference))return Promise.reject(new s("webscene:unsupported-spatial-reference","Webscenes using spatial reference systems from Mars or Moon can not be saved currently."));let o,a=t.messages.filter((e=>"error"===e.type)).map((e=>new s(e.name,e.message,e.details)));t.blockedRelativeUrls&&(a=a.concat(t.blockedRelativeUrls.map((e=>new s("url:unsupported",`Relative url '${e}' is not supported in Web Scene`))))),r&&r.ignoreUnsupported&&(a=a.filter((e=>"layer:unsupported"!==e.name&&"symbol:unsupported"!==e.name&&"symbol-layer:unsupported"!==e.name&&"property:unsupported"!==e.name&&"url:unsupported"!==e.name&&"scenemodification:unsupported"!==e.name))),null!=r&&r.requiredPropertyChecksDisabled&&(a=a.filter((e=>"web-document-write:property-required"!==e.name)));const n=r&&r.strictSchemaValidationEnabled;return o=n?import("./webscene/support/schemaValidator.js").then((t=>{const r=t.validate(e);if(r.length>0){const e=`webscene did not validate:\n${r.join("\n")}`;D.error(`${i?"saveAs":"save"}(): ${e}`)}return r.map((e=>new s("webscene:schema-validation",e)))})).then((e=>{if(n&&e.length>0){throw C(e.concat(a))}return a})):Promise.resolve(a),o.then((e=>{if(e.length>0)throw new s("webscene:save","Failed to save webscene due to unsupported or invalid content. See 'details.errors' for more detailed information",{errors:e})}))}_verifySaveAs(e,t,r){return this.canNotSaveAs(t)?Promise.reject(T()):this._verifySave(e,t,r,!0)}verifySaveAs(e){const t=this._enableVerifyItemRelativeUrls({origin:"web-scene",messages:[]}),r=this.write({},t);return this._verifySaveAs(r,t,e)}canNotSaveAs(e){return e||(e=this._enableVerifyItemRelativeUrls({origin:"web-scene",messages:[]}),this.write({},e)),e.verifyItemRelativeUrls&&e.verifyItemRelativeUrls.writtenUrls.length>0}async updateFrom(e,t={}){const r=this._updateFrom(e,t);this._updateFromPromise=r,await r;this._updateFromPromise===r&&(this._updateFromPromise=null)}async _updateFrom(e,t={}){if(await e.whenReady(),!t.environmentExcluded&&e.environment){if(e.environment.lighting.type&&"sun"!==e.environment.lighting.type)throw new s("lighting:unsupported",`${e.environment.lighting.type} lighting cannot be stored in WebScene`);this.initialViewProperties.environment=x.prototype.clone.apply(e.environment)}if(!t.viewpointExcluded&&e.viewpoint&&(this.initialViewProperties.viewpoint=e.viewpoint.clone()),this.initialViewProperties.spatialReference=e.spatialReference.clone(),this.initialViewProperties.viewingMode=e.viewingMode,d(e.clippingArea)?e.clippingArea!==this.clippingArea&&(this.clippingArea=e.clippingArea.clone(),this.clippingEnabled=!0):this.clippingEnabled=!1,e.heightModelInfo&&(this.heightModelInfo=e.heightModelInfo.clone()),e.map===this)for(const r of e.allLayerViews){const e="visible";e in r&&e in r.layer&&r._isOverridden(e)&&(r.layer[e]=r[e])}(!1===t.thumbnailExcluded||null==t.thumbnailExcluded&&!t.viewpointExcluded)&&await this._updateFromThumbnail(e,t.thumbnailSize||void 0)}async _updateFromThumbnail(e,t){const r=$(e,t),i=await e.takeScreenshot({format:"jpg",width:r.width,height:r.height,disableDecorations:!0});this.thumbnailUrl=i.dataUrl}_loadFromSource(){return this.resourceInfo?this._loadFromJSON(this.resourceInfo,{origin:"web-scene"}):this.portalItem&&this.portalItem.id?this._loadFromItem(this.portalItem):this._loadObjectsWithLayers()}_readAndLoadFromJSON(e,t){const r=this._validateJSON(e);return this.read(r,t),this._loadFromJSON(r,t)}_extractOperationalLayers(e){const t=[];if(!this.sourceVersion.supportsGround&&e.baseMap&&Array.isArray(e.baseMap.elevationLayers))for(const o of e.baseMap.elevationLayers)t.push(o);const r=[],i=e=>(e.layers&&(e.layers=e.layers.filter(i)),"ArcGISTiledElevationServiceLayer"!==e.layerType||(this.sourceVersion.supportsGround||r.push(e),!1));return{operationalLayers:e.operationalLayers?e.operationalLayers.filter(i):[],operationalElevationLayers:r,basemapElevationLayers:t}}_loadFromJSON(e,t){const r=new o;return this._validateSpatialReference().then((()=>this._validateHeightModelInfo())).then((()=>import("./layers/support/layersCreator.js"))).then((({populateOperationalLayers:i})=>{const{operationalLayers:o,operationalElevationLayers:s,basemapElevationLayers:a}=this._extractOperationalLayers(e),n=[],l={context:{...t,layerContainerType:"operational-layers"}};if(this.portalItem&&(l.context.portal=this.portalItem.portal||O.getDefault()),a.length>0){const e={...l,context:{...l.context,layerContainerType:"ground"}};e.defaultLayerType="ArcGISTiledElevationServiceLayer",n.push(i(this.ground.layers,a,e))}if(s.length>0){const e={...l,context:{...l.context,layerContainerType:"ground"}};e.defaultLayerType="ArcGISTiledElevationServiceLayer",n.push(i(r,s,e))}return o&&o.length>0&&n.push(i(this.layers,o,l)),w(n).then((()=>{}))})).then((()=>this._loadObjectsWithLayers())).then((()=>{this.ground.layers.addMany(r)}))}async _ensureLoadBeforeSave(){await this.load(),await this._loadObjectsWithLayers();const e=[];for(const t of this.allLayers.items)if("beforeSave"in t&&"function"==typeof t.beforeSave){const r=t.beforeSave();r&&e.push(r)}await w(e)}async _loadObjectsWithLayers(){const e=[];this.ground&&e.push(this.ground.load()),this.basemap&&e.push(this.basemap.load()),this.presentation.slides.forEach((t=>{t.basemap&&e.push(t.basemap.load())})),await w(e)}async _loadFromItem(e){if(await e.load().catch((e=>{throw new s("webscene:load-portal-item","Failed to load portal item",{error:e})})),"Web Scene"!==e.type)throw new s("webscene:invalid-portal-item","Invalid portal item type '${type}', expected 'Web Scene'",{type:e.type});const t=await e.fetchData();this.resourceInfo=t;const r={origin:"web-scene",url:g(e.itemUrl),portal:e.portal||O.getDefault(),portalItem:e,readResourcePaths:[]};await this._readAndLoadFromJSON(t,r),this.resourceReferences={portalItem:e,paths:r.readResourcePaths}}_validateSpatialReference(){const e=this.initialViewProperties,t=this._sceneSpatialReference;let r;if("local"!==e.viewingMode){if(!F(t,G.Global))return Promise.reject(new s("webscene:unsupported-spatial-reference","Unsupported spatial reference (${spatialReference.wkid}) in global mode, only Web Mercator, WGS84 GCS or CGCS2000 are supported",{spatialReference:t,viewingMode:e.viewingMode}));r=e=>!e||V(e,t)}else{if(!F(t,G.Local))return Promise.reject(new s("webscene:unsupported-spatial-reference","Unsupported spatial reference (${spatialReference.wkid}) in local mode, only projected coordinate systems are supported",{spatialReference:t,viewingMode:e.viewingMode}));r=e=>!e||e.equals(t)}const i=e=>e&&(d(e.camera)&&e.camera.position&&e.camera.position.spatialReference||d(e.targetGeometry)&&e.targetGeometry.spatialReference),o=e.viewpoint,a=i(o);if(a&&!r(a))return Promise.reject(new s("webscene:incompatible-camera-spatial-reference","Camera spatial reference (${cameraSpatialReference.wkid}) is incompatible with the scene spatial reference (${sceneSpatialReference.wkid})",{cameraSpatialReference:a,sceneSpatialReference:t,viewingMode:e.viewingMode}));const n=this.presentation.slides.find((e=>!r(i(e.viewpoint))));if(n){const r=i(n.viewpoint);return Promise.reject(new s("webscene:incompatible-slide-spatial-reference","Slide spatial reference (${slideSpatialReference.wkid}) is incompatible with the scene spatial reference (${sceneSpatialReference.wkid})",{slideSpatialReference:r,sceneSpatialReference:t,viewingMode:e.viewingMode}))}return Promise.resolve()}_validateHeightModelInfo(){const e=this._sceneSpatialReference,t=P(this.heightModelInfo,e);return t?Promise.reject(t):Promise.resolve()}_validateJSON(e){const t=K.parse(e.version||"","webscene");return H.validate(t),e.version=`${t.major}.${t.minor}`,1===t.major&&t.minor<=2&&(e.spatialReference=L.WebMercator.toJSON()),e}_updateTypeKeywords(e){"local"===this.initialViewProperties.viewingMode?e.typeKeywords?e.typeKeywords.includes(X)||e.typeKeywords.push(X):e.typeKeywords=[X]:"global"===this.initialViewProperties.viewingMode&&e.typeKeywords&&(e.typeKeywords=e.typeKeywords.filter((e=>e!==X))),e.typeKeywords&&(e.typeKeywords=e.typeKeywords.filter(((e,t,r)=>r.indexOf(e)===t)))}get _sceneSpatialReference(){return this.initialViewProperties.spatialReference||L.WebMercator}get _verifyItemRelativeRootPath(){return this.portalItem&&this.portalItem.itemUrl?g(this.portalItem.itemUrl).path:null}_enableVerifyItemRelativeUrls(e){const t=this._verifyItemRelativeRootPath;return t&&(e.verifyItemRelativeUrls={rootPath:t,writtenUrls:[]}),e}_unscheduleLayersIdGC(){this._layersIdGCTimeoutId&&(clearTimeout(this._layersIdGCTimeoutId),this._layersIdGCTimeoutId=0)}_scheduleLayersIdGC(){this._unscheduleLayersIdGC(),this._layersIdGCTimeoutId=setTimeout((()=>{this._layersIdGCTimeoutId=0,this._runLayersIdGC()}),3e3)}_runLayersIdGC(){this._unscheduleLayersIdGC();const e=this.applicationProperties&&this.applicationProperties.viewing&&this.applicationProperties.viewing.search,t=e=>this.allLayers.some((t=>t.id===e));e&&e.layers&&(e.layers=e.layers.filter((e=>t(e.id))));const r=this.presentation&&this.presentation.slides;r&&r.forEach((e=>{e.visibleLayers&&(e.visibleLayers=e.visibleLayers.filter((e=>t(e.id))))}))}static fromJSON(e){if(!e)throw new s("webscene:empty-resource","Expected a JSON resource but got nothing");return new this({resourceInfo:e})}};var Z;Y.VERSION=H,e([v({type:J,json:{write:!0}})],Y.prototype,"applicationProperties",void 0),e([v({json:{read:{source:"baseMap"},write:{target:"baseMap"}}})],Y.prototype,"basemap",void 0),e([v({type:j,json:{read:{source:"clippingArea.geometry",reader:U},write:{target:"clippingArea.geometry"}}})],Y.prototype,"clippingArea",void 0),e([A("clippingArea")],Y.prototype,"writeClippingArea",null),e([v({type:Boolean,json:{write:{target:"clippingArea.clip"}}})],Y.prototype,"clippingEnabled",void 0),e([b("clippingEnabled",["clippingArea"])],Y.prototype,"readClippingEnabled",null),e([A("clippingEnabled")],Y.prototype,"writeClippingEnabled",null),e([v({type:N,json:{read:{source:"mapFloorInfo"},write:{target:"mapFloorInfo"}}})],Y.prototype,"floorInfo",void 0),e([v({type:R,json:{write:!0}})],Y.prototype,"heightModelInfo",void 0),e([v({json:{write:{target:"operationalLayers",ignoreOrigin:!0}}})],Y.prototype,"layers",void 0),e([A("layers")],Y.prototype,"writeLayers",null),e([v({readOnly:!0,type:K,json:{type:z(),write:{ignoreOrigin:!0,target:"version",isRequired:!0,overridePolicy:()=>({enabled:!0,allowNull:!0,ignoreOrigin:!0})}}})],Y.prototype,"sourceVersion",void 0),e([b("sourceVersion",["version"])],Y.prototype,"readSourceVersion",null),e([A("sourceVersion")],Y.prototype,"writeSourceVersion",null),e([v({json:{read:!1,write:!1}})],Y.prototype,"tables",void 0),e([v()],Y.prototype,"thumbnailUrl",null),e([v({type:String,json:{write:{writerEnsuresNonNull:!0,ignoreOrigin:!0}}})],Y.prototype,"authoringApp",null),e([A("authoringApp")],Y.prototype,"writeAuthoringApp",null),e([v({type:String,json:{write:{writerEnsuresNonNull:!0,ignoreOrigin:!0}}})],Y.prototype,"authoringAppVersion",null),e([A("authoringAppVersion")],Y.prototype,"writeAuthoringAppVersion",null),e([v({json:{write:{isRequired:!0,allowNull:!0,ignoreOrigin:!0,enabled:!0}}})],Y.prototype,"ground",void 0),e([A("ground")],Y.prototype,"writeGround",null),e([v({type:o.ofType(q),json:{write:!0}})],Y.prototype,"transportationNetworks",void 0),e([v({type:B,nonNullable:!0,json:{write:{ignoreOrigin:!0,writer:(e,t,r,i)=>{if(e.slides&&e.slides.length>0){const r={...i,isPresentation:!0};t.presentation=e.write({},r)}}}}})],Y.prototype,"presentation",void 0),e([v({type:k,nonNullable:!0,json:{write:{target:"initialState",isRequired:!0,ignoreOrigin:!0},default:()=>new k({viewingMode:"global",spatialReference:L.WebMercator})}})],Y.prototype,"initialViewProperties",void 0),e([b("initialViewProperties",["initialState.environment","spatialReference","viewingMode","initialState.viewpoint"])],Y.prototype,"readInitialViewProperties",null),e([v({type:L,json:{read:!1,write:{isRequired:!0,ignoreOrigin:!0}}})],Y.prototype,"spatialReference",null),e([v({type:["local","global"],json:{read:!1,write:{isRequired:!0,ignoreOrigin:!0}}})],Y.prototype,"viewingMode",null),e([v({type:E})],Y.prototype,"portalItem",void 0),e([v()],Y.prototype,"resourceInfo",void 0),Y=e([S("esri.WebScene")],Y),function(e){e[e.SAVE=0]="SAVE",e[e.SAVE_AS=1]="SAVE_AS"}(Z||(Z={}));const ee=Y;export{ee as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../Graphic.js";import t from"../../../request.js";import r from"../../Attachment.js";import i from"../support/FeatureSet.js";import s from"../support/IdSet.js";import{defaultMaxRecords as a,stableStringify as n,FeatureServiceDatabaseType as l,IdState as o,extractServiceUrl as u}from"../support/shared.js";import{toWhereClause as d,isSingleField as h}from"../support/sqlUtils.js";import{decodeStatType as p}from"../support/stats.js";import{createMD5Hash as c,outputTypes as y}from"../../../core/MD5.js";import{id as f}from"../../../kernel.js";import{create as _,resolve as m,reject as g}from"../../../core/promiseUtils.js";import{fromJSON as F}from"../../../geometry/support/jsonUtils.js";import S from"../../../layers/FeatureLayer.js";import{convertToFeatureSet as b}from"../../../layers/graphics/featureConversionUtils.js";import"../../../core/urlUtils.js";import"../../../core/unitUtils.js";import"../../../rest/query/support/AttachmentInfo.js";import"../../../rest/support/AttachmentQuery.js";import{executeForCount as R}from"../../../rest/query/executeForCount.js";import"../../../geometry.js";import{executeQueryPBF as D}from"../../../rest/query/operations/query.js";import x from"../../../rest/support/Query.js";import{executeForIds as w}from"../../../rest/query/executeForIds.js";import{executeQueryJSON as I}from"../../../rest/query/executeQueryJSON.js";import"../../../core/has.js";import"../../../geometry/support/spatialReferenceUtils.js";import q from"../../../rest/support/FeatureSet.js";import"../../../rest/support/RelationshipQuery.js";import"../../../geometry/support/normalizeUtils.js";import"../../../rest/support/TopFeaturesQuery.js";import{OptimizedFeatureSetParserContext as P}from"../../../rest/query/operations/pbfOptimizedFeatureSet.js";import v from"../../../rest/support/StatisticDefinition.js";import C from"../../Dictionary.js";class j extends i{constructor(e){super(e),this.declaredClass="esri.arcade.featureset.sources.FeatureLayerDynamic",this._removeGeometry=!1,this._overrideFields=null,this.formulaCredential=null,this._pageJustIds=!1,this._requestStandardised=!1,this._useDefinitionExpression=!0,e.spatialReference&&(this.spatialReference=e.spatialReference),this._transparent=!0,this._maxProcessing=1e3,this._layer=e.layer,this._wset=null,void 0!==e.outFields&&(this._overrideFields=e.outFields),void 0!==e.includeGeometry&&(this._removeGeometry=!1===e.includeGeometry)}_maxQueryRate(){return a}end(){return this._layer}optimisePagingFeatureQueries(e){this._pageJustIds=e}convertQueryToLruCacheKey(e){const t=n(e.toJSON());return c(t,y.String)}load(){return null===this._loadPromise&&(this._loadPromise=_(((e,t)=>{try{if(!0===this._layer.loaded)return this._initialiseFeatureSet(),void e(this);this._layer.when().then((()=>{try{this._initialiseFeatureSet(),e(this)}catch(r){t(r)}}),t),this._layer.load()}catch(r){t(r)}}))),this._loadPromise}_initialiseFeatureSet(){if(null==this.spatialReference&&(this.spatialReference=this._layer.spatialReference),this.geometryType=this._layer.geometryType,this.fields=this._layer.fields.slice(0),this._layer.outFields)if(1===this._layer.outFields.length&&"*"===this._layer.outFields[0]);else{const e=[];for(const t of this.fields)if("oid"===t.type)e.push(t);else for(const r of this._layer.outFields)if(r.toLowerCase()===t.name.toLowerCase()){e.push(t);break}this.fields=e}else;if(null!==this._overrideFields)if(1===this._overrideFields.length&&"*"===this._overrideFields[0])this._overrideFields=null;else{const e=[],t=[];for(const r of this.fields)if("oid"===r.type)e.push(r),t.push(r.name);else for(const i of this._overrideFields)if(i.toLowerCase()===r.name.toLowerCase()){e.push(r),t.push(r.name);break}this.fields=e,this._overrideFields=t}if(this._layer.source&&this._layer.source.sourceJSON){const e=this._layer.source.sourceJSON.currentVersion;!0===this._layer.source.sourceJSON.useStandardizedQueries?(this._databaseType=l.StandardisedNoInterval,null!=e&&e>=10.61&&(this._databaseType=l.Standardised)):null!=e&&(e>=10.5&&(this._databaseType=l.StandardisedNoInterval,this._requestStandardised=!0),e>=10.61&&(this._databaseType=l.Standardised))}this.objectIdField=this._layer.objectIdField;for(const e of this.fields)"global-id"===e.type&&(this.globalIdField=e.name);this.hasM=this._layer.supportsM,this.hasZ=this._layer.supportsZ,this.typeIdField=this._layer.typeIdField,this.types=this._layer.types}_isInFeatureSet(){return o.InFeatureSet}_refineSetBlock(e){return m(e)}_candidateIdTransform(e){return e}_getSet(e){return null===this._wset?this._ensureLoaded().then((()=>this._getFilteredSet("",null,null,null,e))).then((e=>(this._wset=e,e))):m(this._wset)}_runDatabaseProbe(e){return _(((t,r)=>{try{this._ensureLoaded().then((()=>{try{const i=new x;i.where=e.replace("OBJECTID",this._layer.objectIdField),this._layer.queryObjectIds(i).then((()=>{t(!0)}),(()=>{try{t(!1)}catch(e){r(e)}}))}catch(i){r(i)}}))}catch(i){r(i)}}))}_canUsePagination(){return!(!this._layer.capabilities||!this._layer.capabilities.query||!0!==this._layer.capabilities.query.supportsPagination)}_cacheableFeatureSetSourceKey(){return this._layer.url}pbfSupportedForQuery(e){return!e.outStatistics&&this._layer&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsFormatPBF&&!0===this._layer.capabilities.query.supportsQuantizationEditMode}queryPBF(e){return e.quantizationParameters={mode:"edit"},D(this._layer.parsedUrl,e,new P({})).then((e=>q.fromJSON(b(e.data)).unquantize()))}get gdbVersion(){return this._layer&&this._layer.capabilities&&this._layer.capabilities.data&&this._layer.capabilities.data.isVersioned?this._layer.gdbVersion?this._layer.gdbVersion:"SDE.DEFAULT":""}nativeCapabilities(){return{title:this._layer.title,source:this,canQueryRelated:!0,capabilities:this._layer.capabilities,databaseType:this._databaseType,requestStandardised:this._requestStandardised}}executeQuery(e,t){const r="execute"===t?I:"executeForCount"===t?R:w,i="execute"===t&&this.pbfSupportedForQuery(e);let s=null;if(this.recentlyUsedQueries){const t=this.convertQueryToLruCacheKey(e);s=this.recentlyUsedQueries.getFromCache(t),null===s&&(s=!0!==i?r(this._layer.parsedUrl.path,e):this.queryPBF(e),this.recentlyUsedQueries.addToCache(t,s),s=s.catch((e=>{throw this.recentlyUsedQueries.removeFromCache(t),e})))}return this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preLayerQueryCallback({layer:this._layer,query:e,method:t}),null===s&&(s=!0!==i?r(this._layer.parsedUrl.path,e):this.queryPBF(e)),s}_getFilteredSet(e,t,r,i,a){return this.databaseType().then((n=>{if(this.isTable()&&t&&null!==e&&""!==e){return new s([],[],!0,null)}if(this._canUsePagination())return this._getFilteredSetUsingPaging(e,t,r,i,a);let l="",o=!1;null!==i&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsOrderBy&&(l=i.constructClause(),o=!0);const u=new x;return u.where=null===r?null===t?"1=1":"":d(r,n),this._requestStandardised&&(u.sqlFormat="standard"),u.spatialRelationship=this._makeRelationshipEnum(e),u.outSpatialReference=this.spatialReference,u.orderByFields=""!==l?l.split(","):null,u.geometry=null===t?null:t,u.relationParameter=this._makeRelationshipParam(e),this.executeQuery(u,"executeForIds").then((e=>{null===e&&(e=[]),this._checkCancelled(a);return new s([],e,o,null)}))}))}_expandPagedSet(e,t,r,i,s){return this._expandPagedSetFeatureSet(e,t,r,i,s)}_getFilteredSetUsingPaging(e,t,r,i,a){try{let n="",l=!1;return null!==i&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsOrderBy&&(n=i.constructClause(),l=!0),this.databaseType().then((i=>{let o=null===r?null===t?"1=1":"":d(r,i);this._layer.definitionExpression&&this._useDefinitionExpression&&(o=""!==o?"(("+this._layer.definitionExpression+") AND ("+o+"))":this._layer.definitionExpression);let u=this._maxQueryRate();const h=this._layer.capabilities.query.maxRecordCount;void 0!==h&&h<u&&(u=h);let p=null;if(!0===this._pageJustIds)p=new s([],["GETPAGES"],l,{spatialRel:this._makeRelationshipEnum(e),relationParam:this._makeRelationshipParam(e),outFields:this._layer.objectIdField,resultRecordCount:u,resultOffset:0,geometry:null===t?null:t,where:o,orderByFields:n,returnGeometry:!1,returnIdsOnly:"false",internal:{set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}});else{let r=!0;!0===this._removeGeometry&&(r=!1);const i=null!==this._overrideFields?this._overrideFields:this._fieldsIncludingObjectId(this._layer.outFields?this._layer.outFields:["*"]);p=new s([],["GETPAGES"],l,{spatialRel:this._makeRelationshipEnum(e),relationParam:this._makeRelationshipParam(e),outFields:i.join(","),resultRecordCount:u,resultOffset:0,geometry:null===t?null:t,where:o,orderByFields:n,returnGeometry:r,returnIdsOnly:"false",internal:{set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}})}return this._expandPagedSet(p,u,0,1,a).then((()=>p))}))}catch(n){return g(n)}}_clonePageDefinition(e){return null===e?null:!0!==e.groupbypage?{groupbypage:!1,spatialRel:e.spatialRel,relationParam:e.relationParam,outFields:e.outFields,resultRecordCount:e.resultRecordCount,resultOffset:e.resultOffset,geometry:e.geometry,where:e.where,orderByFields:e.orderByFields,returnGeometry:e.returnGeometry,returnIdsOnly:e.returnIdsOnly,internal:e.internal}:{groupbypage:!0,spatialRel:e.spatialRel,relationParam:e.relationParam,outFields:e.outFields,resultRecordCount:e.resultRecordCount,useOIDpagination:e.useOIDpagination,generatedOid:e.generatedOid,groupByFieldsForStatistics:e.groupByFieldsForStatistics,resultOffset:e.resultOffset,outStatistics:e.outStatistics,geometry:e.geometry,where:e.where,orderByFields:e.orderByFields,returnGeometry:e.returnGeometry,returnIdsOnly:e.returnIdsOnly,internal:e.internal}}_getPhysicalPage(e,t,r){try{const t=e.pagesDefinition.internal.lastRetrieved,i=t,s=e.pagesDefinition.internal.lastPage,a=new x;return this._requestStandardised&&(a.sqlFormat="standard"),a.spatialRelationship=e.pagesDefinition.spatialRel,a.relationParameter=e.pagesDefinition.relationParam,a.outFields=e.pagesDefinition.outFields.split(","),a.num=e.pagesDefinition.resultRecordCount,a.start=e.pagesDefinition.internal.lastPage,a.geometry=e.pagesDefinition.geometry,a.where=e.pagesDefinition.where,a.orderByFields=""!==e.pagesDefinition.orderByFields?e.pagesDefinition.orderByFields.split(","):null,a.returnGeometry=e.pagesDefinition.returnGeometry,a.outSpatialReference=this.spatialReference,this.executeQuery(a,"execute").then((a=>{if(this._checkCancelled(r),e.pagesDefinition.internal.lastPage!==s)return"done";for(let t=0;t<a.features.length;t++)e.pagesDefinition.internal.set[i+t]=a.features[t].attributes[this._layer.objectIdField];if(!1===this._pageJustIds)for(let e=0;e<a.features.length;e++)this._featureCache[a.features[e].attributes[this._layer.objectIdField]]=a.features[e];return(void 0===a.exceededTransferLimit&&a.features.length!==e.pagesDefinition.resultRecordCount||!1===a.exceededTransferLimit)&&(e.pagesDefinition.internal.fullyResolved=!0),e.pagesDefinition.internal.lastRetrieved=t+a.features.length,e.pagesDefinition.internal.lastPage+=e.pagesDefinition.resultRecordCount,"done"}))}catch(i){return g(i)}}_fieldsIncludingObjectId(e){if(null===e)return[this.objectIdField];const t=e.slice(0);if(t.includes("*"))return t;let r=!1;for(const i of t)if(i.toUpperCase()===this.objectIdField.toUpperCase()){r=!0;break}return!1===r&&t.push(this.objectIdField),t}_getFeatures(e,t,r,i){const s=[];try{if(-1!==t&&void 0===this._featureCache[t]&&s.push(t),!0===this._checkIfNeedToExpandKnownPage(e,this._maxProcessingRate()))return this._expandPagedSet(e,this._maxProcessingRate(),0,0,i).then((()=>this._getFeatures(e,t,r,i)));let n=0;for(let i=e._lastFetchedIndex;i<e._known.length;i++){if(e._lastFetchedIndex+=1,n++,void 0===this._featureCache[e._known[i]]){let r=!1;if(null!==this._layer._mode&&void 0!==this._layer._mode){const t=this._layer._mode;if(void 0!==t._featureMap[e._known[i]]){const s=t._featureMap[e._known[i]];null!==s&&(r=!0,this._featureCache[e._known[i]]=s)}}if(!1===r&&(e._known[i]!==t&&s.push(e._known[i]),s.length>=this._maxProcessingRate()-1))break}if(n>=r&&0===s.length)break}if(0===s.length)return m("success");try{const e=new x;return this._requestStandardised&&(e.sqlFormat="standard"),e.objectIds=s,e.outFields=null!==this._overrideFields?this._overrideFields:this._fieldsIncludingObjectId(this._layer.outFields?this._layer.outFields:["*"]),e.returnGeometry=!0,!0===this._removeGeometry&&(e.returnGeometry=!1),e.outSpatialReference=this.spatialReference,this.executeQuery(e,"execute").then((e=>{if(this._checkCancelled(i),void 0!==e.error)return g(new Error(e.error));for(let t=0;t<e.features.length;t++)this._featureCache[e.features[t].attributes[this._layer.objectIdField]]=e.features[t];return"success"}))}catch(a){return g(a)}}catch(a){return g(a)}}_getDistinctPages(e,t,r,i,s,a,n,l,o){return this._ensureLoaded().then((()=>this.databaseType())).then((u=>{let h=r.parseTree.column;for(let e=0;e<this._layer.fields.length;e++)if(this._layer.fields[e].name.toLowerCase()===h.toLowerCase()){h=this._layer.fields[e].name;break}const p=new x;this._requestStandardised&&(p.sqlFormat="standard");let c=null===a?null===s?"1=1":"":d(a,u);return this._layer.definitionExpression&&this._useDefinitionExpression&&(c=""!==c?"(("+this._layer.definitionExpression+") AND ("+c+"))":this._layer.definitionExpression),p.where=c,p.spatialRelationship=this._makeRelationshipEnum(i),p.relationParameter=this._makeRelationshipParam(i),p.geometry=null===s?null:s,p.returnDistinctValues=!0,p.returnGeometry=!1,p.outFields=[h],this.executeQuery(p,"execute").then((u=>{if(this._checkCancelled(o),!u.hasOwnProperty("features"))return g(new Error("Unnexected Result querying statistics from layer"));let d=!1;for(let e=0;e<this._layer.fields.length;e++)if(this._layer.fields[e].name===h){"date"===this._layer.fields[e].type&&(d=!0);break}for(let e=0;e<u.features.length;e++){if(d){const t=u.features[e].attributes[h];null!==t?l.push(new Date(t)):l.push(t)}else l.push(u.features[e].attributes[h]);if(l.length>=n)break}return 0===u.features.length?l:u.features.length===this._layer.capabilities.query.maxRecordCount&&l.length<n?this._getDistinctPages(e+u.features.length,t,r,i,s,a,n,l,o).then((e=>({calculated:!0,result:e}))):l}))}))}_distinctStat(e,t,r,i,s,a,n){return this._getDistinctPages(0,e,t,r,i,s,a,[],n).then((e=>({calculated:!0,result:e})))}isTable(){return this._layer.isTable||null===this._layer.geometryType||"table"===this._layer.type||""===this._layer.geometryType}_countstat(e,t,r,i){return this.databaseType().then((e=>{const s=new x;if(this._requestStandardised&&(s.sqlFormat="standard"),this.isTable()&&r&&null!==t&&""!==t)return{calculated:!0,result:0};let a=null===i?null===r?"1=1":"":d(i,e);return this._layer.definitionExpression&&this._useDefinitionExpression&&(a=""!==a?"(("+this._layer.definitionExpression+") AND ("+a+"))":this._layer.definitionExpression),s.where=a,s.where=a,s.spatialRelationship=this._makeRelationshipEnum(t),s.relationParameter=this._makeRelationshipParam(t),s.geometry=null===r?null:r,s.returnGeometry=!1,this.executeQuery(s,"executeForCount").then((e=>({calculated:!0,result:e})))}))}_stats(e,t,r,i,s,a,n){return this._ensureLoaded().then((()=>{const l=this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsSqlExpression,o=this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsStatistics,u=this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsDistinct;return"count"===e?u?this._countstat(e,r,i,s):{calculated:!1}:!1===o||!1===h(t)&&!1===l||!1===t.isStandardized?""!==r||null!==s?{calculated:!1}:this._manualStat(e,t,a,n):"distinct"===e?!1===u?""!==r||null!==s?{calculated:!1}:this._manualStat(e,t,a,n):this._distinctStat(e,t,r,i,s,a,n):this.databaseType().then((a=>{if(this.isTable()&&i&&null!==r&&""!==r)return{calculated:!0,result:null};const n=new x;this._requestStandardised&&(n.sqlFormat="standard");let l=null===s?null===i?"1=1":"":d(s,a);this._layer.definitionExpression&&this._useDefinitionExpression&&(l=""!==l?"(("+this._layer.definitionExpression+") AND ("+l+"))":this._layer.definitionExpression),n.where=l,n.spatialRelationship=this._makeRelationshipEnum(r),n.relationParameter=this._makeRelationshipParam(r),n.geometry=null===i?null:i;const o=new v;o.statisticType=p(e),o.onStatisticField=d(t,a),o.outStatisticFieldName="ARCADE_STAT_RESULT",n.returnGeometry=!1;let u="ARCADE_STAT_RESULT";return n.outStatistics=[o],this.executeQuery(n,"execute").then((e=>{if(!e.hasOwnProperty("features")||0===e.features.length)return g(new Error("Unnexected Result querying statistics from layer"));let t=!1;for(let r=0;r<e.fields.length;r++)if("ARCADE_STAT_RESULT"===e.fields[r].name.toUpperCase()){u=e.fields[r].name,"date"===e.fields[r].type&&(t=!0);break}if(t){let t=e.features[0].attributes[u];return null!==t&&(t=new Date(e.features[0].attributes[u])),{calculated:!0,result:t}}return{calculated:!0,result:e.features[0].attributes[u]}}))}))}))}_stat(e,t,r,i,s,a,n){return this._stats(e,t,r,i,s,a,n)}_canDoAggregates(e,t){return this._ensureLoaded().then((()=>{let e=!1;const r=this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsSqlExpression;if(void 0!==this._layer.capabilities&&null!==this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsStatistics&&!0===this._layer.capabilities.query.supportsOrderBy&&(e=!0),e)for(let i=0;i<t.length-1;i++)null!==t[i].workingexpr&&(!1===t[i].workingexpr.isStandardized||!1===h(t[i].workingexpr)&&!1===r)&&(e=!1);return!1!==e}))}_makeRelationshipEnum(e){if(e.includes("esriSpatialRelRelation"))return"relation";switch(e){case"esriSpatialRelRelation":return"relation";case"esriSpatialRelIntersects":return"intersects";case"esriSpatialRelContains":return"contains";case"esriSpatialRelOverlaps":return"overlaps";case"esriSpatialRelWithin":return"within";case"esriSpatialRelTouches":return"touches";case"esriSpatialRelCrosses":return"crosses";case"esriSpatialRelEnvelopeIntersects":return"envelope-intersects"}return e}_makeRelationshipParam(e){return e.includes("esriSpatialRelRelation")?e.split(":")[1]:""}_getAggregatePagesDataSourceDefinition(e,t,r,i,a,n,l){return this._ensureLoaded().then((()=>this.databaseType())).then((o=>{let u="",h=!1,p=!1;null!==n&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsOrderBy&&(u=n.constructClause(),p=!0),this._layer.capabilities&&this._layer.capabilities.query&&!1===this._layer.capabilities.query.supportsPagination&&(p=!1,h=!0,u=this._layer.objectIdField);const c=[];for(let e=0;e<t.length;e++){const r=new v;r.onStatisticField=null!==t[e].workingexpr?d(t[e].workingexpr,o):"",r.outStatisticFieldName=t[e].field,r.statisticType=t[e].toStatisticsName(),c.push(r)}""===u&&(u=e.join(","));let y=this._maxQueryRate();const f=this._layer.capabilities.query.maxRecordCount;void 0!==f&&f<y&&(y=f);let _=null===a?null===i?"1=1":"":d(a,o);this._layer.definitionExpression&&this._useDefinitionExpression&&(_=""!==_?"(("+this._layer.definitionExpression+") AND ("+_+"))":this._layer.definitionExpression);return new s([],["GETPAGES"],p,{groupbypage:!0,spatialRel:this._makeRelationshipEnum(r),relationParam:this._makeRelationshipParam(r),outFields:["*"],useOIDpagination:h,generatedOid:l,resultRecordCount:y,resultOffset:0,groupByFieldsForStatistics:e,outStatistics:c,geometry:null===i?null:i,where:_,orderByFields:u,returnGeometry:!1,returnIdsOnly:!1,internal:{lastMaxId:-1,set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}})}))}_getAgregagtePhysicalPage(t,r,i){try{let r=t.pagesDefinition.where;!0===t.pagesDefinition.useOIDpagination&&(r=""!==r?"("+r+") AND ("+t.pagesDefinition.generatedOid+">"+t.pagesDefinition.internal.lastMaxId.toString()+")":t.pagesDefinition.generatedOid+">"+t.pagesDefinition.internal.lastMaxId.toString());const s=t.pagesDefinition.internal.lastRetrieved,a=s,n=t.pagesDefinition.internal.lastPage,l=new x;return this._requestStandardised&&(l.sqlFormat="standard"),l.where=r,l.spatialRelationship=t.pagesDefinition.spatialRel,l.relationParameter=t.pagesDefinition.relationParam,l.outFields=t.pagesDefinition.outFields,l.outStatistics=t.pagesDefinition.outStatistics,l.geometry=t.pagesDefinition.geometry,l.groupByFieldsForStatistics=t.pagesDefinition.groupByFieldsForStatistics,l.num=t.pagesDefinition.resultRecordCount,l.start=t.pagesDefinition.internal.lastPage,l.returnGeometry=t.pagesDefinition.returnGeometry,l.orderByFields=""!==t.pagesDefinition.orderByFields?t.pagesDefinition.orderByFields.split(","):null,this.isTable()&&l.geometry&&l.spatialRelationship?m([]):this.executeQuery(l,"execute").then((r=>{if(this._checkCancelled(i),!r.hasOwnProperty("features"))return g(new Error("Unnexected Result querying aggregates from layer"));const l=[];if(t.pagesDefinition.internal.lastPage!==n)return[];for(let e=0;e<r.features.length;e++)t.pagesDefinition.internal.set[a+e]=r.features[e].attributes[t.pagesDefinition.generatedOid];for(let t=0;t<r.features.length;t++)l.push(new e({attributes:r.features[t].attributes,geometry:null}));return!0===t.pagesDefinition.useOIDpagination?0===r.features.length?t.pagesDefinition.internal.fullyResolved=!0:t.pagesDefinition.internal.lastMaxId=r.features[r.features.length-1].attributes[t.pagesDefinition.generatedOid]:(void 0===r.exceededTransferLimit&&r.features.length!==t.pagesDefinition.resultRecordCount||!1===r.exceededTransferLimit)&&(t.pagesDefinition.internal.fullyResolved=!0),t.pagesDefinition.internal.lastRetrieved=s+r.features.length,t.pagesDefinition.internal.lastPage+=t.pagesDefinition.resultRecordCount,l}))}catch(s){return g(s)}}static create(e,t,r,i,s){const a=new S({url:e,outFields:null===t?["*"]:t});return new j({layer:a,spatialReference:r,lrucache:i,interceptor:s})}relationshipMetaData(){return this._layer&&this._layer.source&&this._layer.source.sourceJSON&&this._layer.source.sourceJSON.relationships?this._layer.source.sourceJSON.relationships:[]}serviceUrl(){return u(this._layer.parsedUrl.path)}queryAttachments(e,t,i,s,a){if(this._layer.capabilities.data.supportsAttachment&&this._layer.capabilities.operations.supportsQueryAttachments){const n={objectIds:[e],returnMetadata:a};return(t&&t>0||i&&i>0)&&(n.size=[t&&t>0?t:0,i&&i>0?i:t+1]),s&&s.length>0&&(n.attachmentTypes=s),this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preLayerQueryCallback({layer:this._layer,query:n,method:"attachments"}),this._layer.queryAttachments(n).then((t=>{const i=[];return t&&t[e]&&t[e].forEach((t=>{const s=this._layer.parsedUrl.path+"/"+e.toString()+"/attachments/"+t.id.toString();let n=null;a&&t.exifInfo&&(n=C.convertJsonToArcade(t.exifInfo,!0)),i.push(new r(t.id,t.name,t.contentType,t.size,s,n))})),i}))}return m([])}queryRelatedFeatures(r){const i={f:"json",relationshipId:r.relationshipId.toString(),definitionExpression:r.where,outFields:r.outFields.join(","),returnGeometry:r.returnGeometry.toString()};return void 0!==r.resultOffset&&null!==r.resultOffset&&(i.resultOffset=r.resultOffset.toString()),void 0!==r.resultRecordCount&&null!==r.resultRecordCount&&(i.resultRecordCount=r.resultRecordCount.toString()),r.orderByFields&&(i.orderByFields=r.orderByFields.join(",")),r.objectIds.length>0&&(i.objectIds=r.objectIds.join(",")),r.outSpatialReference&&(i.outSR=JSON.stringify(r.outSpatialReference.toJSON())),this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preRequestCallback({layer:this._layer,queryPayload:i,method:"relatedrecords",url:this._layer.parsedUrl.path+"/queryRelatedRecords"}),t(this._layer.parsedUrl.path+"/queryRelatedRecords",{responseType:"json",query:i}).then((t=>{if(t.data){const r={},i=t.data;if(i&&i.relatedRecordGroups){const t=i.spatialReference;for(const s of i.relatedRecordGroups){const a=s.objectId,n=[];for(const r of s.relatedRecords){r.geometry&&(r.geometry.spatialReference=t);const i=new e({geometry:r.geometry?F(r.geometry):null,attributes:r.attributes});n.push(i)}r[a]={features:n,exceededTransferLimit:!0===i.exceededTransferLimit}}}return r}return g("Invalid Request")}))}getFeatureByObjectId(e,t){const r=new x;return r.outFields=t,r.returnGeometry=!1,r.outSpatialReference=this.spatialReference,r.where=this.objectIdField+"="+e.toString(),this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preLayerQueryCallback({layer:this._layer,query:r,method:"execute"}),I(this._layer.parsedUrl.path,r).then((e=>1===e.features.length?e.features[0]:null))}getIdentityUser(){return this.load().then((()=>{var e;const t=null==(e=f)?void 0:e.findCredential(this._layer.url);return t?t.userId:null}))}getOwningSystemUrl(){return this.load().then((()=>{var e;const r=null==(e=f)?void 0:e.findServerInfo(this._layer.url);if(r)return m(r.owningSystemUrl);let i=this._layer.url;const s=i.toLowerCase().indexOf("/rest/services");return i=s>-1?i.substring(0,s):i,i?(i+="/rest/info",_(((e,r)=>{t(i,{query:{f:"json"}}).then((t=>{let r="";t.data&&t.data.owningSystemUrl&&(r=t.data.owningSystemUrl),e(r)}),(t=>{e("")}))}))):m("")}))}getDataSourceFeatureSet(){const e=new j({layer:this._layer,spatialReference:this.spatialReference,outFields:this._overrideFields,includeGeometry:!this._removeGeometry,lrucache:this.recentlyUsedQueries,interceptor:this.featureSetQueryInterceptor});return e._useDefinitionExpression=!1,e}}export{j as default};
5
+ import e from"../../../Graphic.js";import t from"../../../request.js";import r from"../../Attachment.js";import i from"../support/FeatureSet.js";import s from"../support/IdSet.js";import{defaultMaxRecords as a,stableStringify as n,FeatureServiceDatabaseType as l,IdState as o,extractServiceUrl as u}from"../support/shared.js";import{toWhereClause as d,isSingleField as h}from"../support/sqlUtils.js";import{decodeStatType as p}from"../support/stats.js";import{createMD5Hash as c,outputTypes as y}from"../../../core/MD5.js";import{id as f}from"../../../kernel.js";import{create as _,resolve as m,reject as g}from"../../../core/promiseUtils.js";import{fromJSON as F}from"../../../geometry/support/jsonUtils.js";import S from"../../../layers/FeatureLayer.js";import{convertToFeatureSet as b}from"../../../layers/graphics/featureConversionUtils.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/urlUtils.js";import"../../../rest/query/support/AttachmentInfo.js";import"../../../rest/support/AttachmentQuery.js";import{executeForCount as R}from"../../../rest/query/executeForCount.js";import"../../../geometry.js";import{executeQueryPBF as D}from"../../../rest/query/operations/query.js";import x from"../../../rest/support/Query.js";import{executeForIds as w}from"../../../rest/query/executeForIds.js";import{executeQueryJSON as I}from"../../../rest/query/executeQueryJSON.js";import"../../../core/unitUtils.js";import"../../../geometry/support/spatialReferenceUtils.js";import q from"../../../rest/support/FeatureSet.js";import"../../../rest/support/RelationshipQuery.js";import"../../../geometry/support/normalizeUtils.js";import"../../../rest/support/TopFeaturesQuery.js";import{OptimizedFeatureSetParserContext as P}from"../../../rest/query/operations/pbfOptimizedFeatureSet.js";import j from"../../../rest/support/StatisticDefinition.js";import v from"../../Dictionary.js";class C extends i{constructor(e){super(e),this.declaredClass="esri.arcade.featureset.sources.FeatureLayerDynamic",this._removeGeometry=!1,this._overrideFields=null,this.formulaCredential=null,this._pageJustIds=!1,this._requestStandardised=!1,this._useDefinitionExpression=!0,e.spatialReference&&(this.spatialReference=e.spatialReference),this._transparent=!0,this._maxProcessing=1e3,this._layer=e.layer,this._wset=null,void 0!==e.outFields&&(this._overrideFields=e.outFields),void 0!==e.includeGeometry&&(this._removeGeometry=!1===e.includeGeometry)}_maxQueryRate(){return a}end(){return this._layer}optimisePagingFeatureQueries(e){this._pageJustIds=e}convertQueryToLruCacheKey(e){const t=n(e.toJSON());return c(t,y.String)}load(){return null===this._loadPromise&&(this._loadPromise=_(((e,t)=>{try{if(!0===this._layer.loaded)return this._initialiseFeatureSet(),void e(this);this._layer.when().then((()=>{try{this._initialiseFeatureSet(),e(this)}catch(r){t(r)}}),t),this._layer.load()}catch(r){t(r)}}))),this._loadPromise}_initialiseFeatureSet(){if(null==this.spatialReference&&(this.spatialReference=this._layer.spatialReference),this.geometryType=this._layer.geometryType,this.fields=this._layer.fields.slice(0),this._layer.outFields)if(1===this._layer.outFields.length&&"*"===this._layer.outFields[0]);else{const e=[];for(const t of this.fields)if("oid"===t.type)e.push(t);else for(const r of this._layer.outFields)if(r.toLowerCase()===t.name.toLowerCase()){e.push(t);break}this.fields=e}else;if(null!==this._overrideFields)if(1===this._overrideFields.length&&"*"===this._overrideFields[0])this._overrideFields=null;else{const e=[],t=[];for(const r of this.fields)if("oid"===r.type)e.push(r),t.push(r.name);else for(const i of this._overrideFields)if(i.toLowerCase()===r.name.toLowerCase()){e.push(r),t.push(r.name);break}this.fields=e,this._overrideFields=t}if(this._layer.source&&this._layer.source.sourceJSON){const e=this._layer.source.sourceJSON.currentVersion;!0===this._layer.source.sourceJSON.useStandardizedQueries?(this._databaseType=l.StandardisedNoInterval,null!=e&&e>=10.61&&(this._databaseType=l.Standardised)):null!=e&&(e>=10.5&&(this._databaseType=l.StandardisedNoInterval,this._requestStandardised=!0),e>=10.61&&(this._databaseType=l.Standardised))}this.objectIdField=this._layer.objectIdField;for(const e of this.fields)"global-id"===e.type&&(this.globalIdField=e.name);this.hasM=this._layer.supportsM,this.hasZ=this._layer.supportsZ,this.typeIdField=this._layer.typeIdField,this.types=this._layer.types}_isInFeatureSet(){return o.InFeatureSet}_refineSetBlock(e){return m(e)}_candidateIdTransform(e){return e}_getSet(e){return null===this._wset?this._ensureLoaded().then((()=>this._getFilteredSet("",null,null,null,e))).then((e=>(this._wset=e,e))):m(this._wset)}_runDatabaseProbe(e){return _(((t,r)=>{try{this._ensureLoaded().then((()=>{try{const i=new x;i.where=e.replace("OBJECTID",this._layer.objectIdField),this._layer.queryObjectIds(i).then((()=>{t(!0)}),(()=>{try{t(!1)}catch(e){r(e)}}))}catch(i){r(i)}}))}catch(i){r(i)}}))}_canUsePagination(){return!(!this._layer.capabilities||!this._layer.capabilities.query||!0!==this._layer.capabilities.query.supportsPagination)}_cacheableFeatureSetSourceKey(){return this._layer.url}pbfSupportedForQuery(e){return!e.outStatistics&&this._layer&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsFormatPBF&&!0===this._layer.capabilities.query.supportsQuantizationEditMode}queryPBF(e){return e.quantizationParameters={mode:"edit"},D(this._layer.parsedUrl,e,new P({})).then((e=>q.fromJSON(b(e.data)).unquantize()))}get gdbVersion(){return this._layer&&this._layer.capabilities&&this._layer.capabilities.data&&this._layer.capabilities.data.isVersioned?this._layer.gdbVersion?this._layer.gdbVersion:"SDE.DEFAULT":""}nativeCapabilities(){return{title:this._layer.title,source:this,canQueryRelated:!0,capabilities:this._layer.capabilities,databaseType:this._databaseType,requestStandardised:this._requestStandardised}}executeQuery(e,t){const r="execute"===t?I:"executeForCount"===t?R:w,i="execute"===t&&this.pbfSupportedForQuery(e);let s=null;if(this.recentlyUsedQueries){const t=this.convertQueryToLruCacheKey(e);s=this.recentlyUsedQueries.getFromCache(t),null===s&&(s=!0!==i?r(this._layer.parsedUrl.path,e):this.queryPBF(e),this.recentlyUsedQueries.addToCache(t,s),s=s.catch((e=>{throw this.recentlyUsedQueries.removeFromCache(t),e})))}return this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preLayerQueryCallback({layer:this._layer,query:e,method:t}),null===s&&(s=!0!==i?r(this._layer.parsedUrl.path,e):this.queryPBF(e)),s}_getFilteredSet(e,t,r,i,a){return this.databaseType().then((n=>{if(this.isTable()&&t&&null!==e&&""!==e){return new s([],[],!0,null)}if(this._canUsePagination())return this._getFilteredSetUsingPaging(e,t,r,i,a);let l="",o=!1;null!==i&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsOrderBy&&(l=i.constructClause(),o=!0);const u=new x;return u.where=null===r?null===t?"1=1":"":d(r,n),this._requestStandardised&&(u.sqlFormat="standard"),u.spatialRelationship=this._makeRelationshipEnum(e),u.outSpatialReference=this.spatialReference,u.orderByFields=""!==l?l.split(","):null,u.geometry=null===t?null:t,u.relationParameter=this._makeRelationshipParam(e),this.executeQuery(u,"executeForIds").then((e=>{null===e&&(e=[]),this._checkCancelled(a);return new s([],e,o,null)}))}))}_expandPagedSet(e,t,r,i,s){return this._expandPagedSetFeatureSet(e,t,r,i,s)}_getFilteredSetUsingPaging(e,t,r,i,a){try{let n="",l=!1;return null!==i&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsOrderBy&&(n=i.constructClause(),l=!0),this.databaseType().then((i=>{let o=null===r?null===t?"1=1":"":d(r,i);this._layer.definitionExpression&&this._useDefinitionExpression&&(o=""!==o?"(("+this._layer.definitionExpression+") AND ("+o+"))":this._layer.definitionExpression);let u=this._maxQueryRate();const h=this._layer.capabilities.query.maxRecordCount;void 0!==h&&h<u&&(u=h);let p=null;if(!0===this._pageJustIds)p=new s([],["GETPAGES"],l,{spatialRel:this._makeRelationshipEnum(e),relationParam:this._makeRelationshipParam(e),outFields:this._layer.objectIdField,resultRecordCount:u,resultOffset:0,geometry:null===t?null:t,where:o,orderByFields:n,returnGeometry:!1,returnIdsOnly:"false",internal:{set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}});else{let r=!0;!0===this._removeGeometry&&(r=!1);const i=null!==this._overrideFields?this._overrideFields:this._fieldsIncludingObjectId(this._layer.outFields?this._layer.outFields:["*"]);p=new s([],["GETPAGES"],l,{spatialRel:this._makeRelationshipEnum(e),relationParam:this._makeRelationshipParam(e),outFields:i.join(","),resultRecordCount:u,resultOffset:0,geometry:null===t?null:t,where:o,orderByFields:n,returnGeometry:r,returnIdsOnly:"false",internal:{set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}})}return this._expandPagedSet(p,u,0,1,a).then((()=>p))}))}catch(n){return g(n)}}_clonePageDefinition(e){return null===e?null:!0!==e.groupbypage?{groupbypage:!1,spatialRel:e.spatialRel,relationParam:e.relationParam,outFields:e.outFields,resultRecordCount:e.resultRecordCount,resultOffset:e.resultOffset,geometry:e.geometry,where:e.where,orderByFields:e.orderByFields,returnGeometry:e.returnGeometry,returnIdsOnly:e.returnIdsOnly,internal:e.internal}:{groupbypage:!0,spatialRel:e.spatialRel,relationParam:e.relationParam,outFields:e.outFields,resultRecordCount:e.resultRecordCount,useOIDpagination:e.useOIDpagination,generatedOid:e.generatedOid,groupByFieldsForStatistics:e.groupByFieldsForStatistics,resultOffset:e.resultOffset,outStatistics:e.outStatistics,geometry:e.geometry,where:e.where,orderByFields:e.orderByFields,returnGeometry:e.returnGeometry,returnIdsOnly:e.returnIdsOnly,internal:e.internal}}_getPhysicalPage(e,t,r){try{const t=e.pagesDefinition.internal.lastRetrieved,i=t,s=e.pagesDefinition.internal.lastPage,a=new x;return this._requestStandardised&&(a.sqlFormat="standard"),a.spatialRelationship=e.pagesDefinition.spatialRel,a.relationParameter=e.pagesDefinition.relationParam,a.outFields=e.pagesDefinition.outFields.split(","),a.num=e.pagesDefinition.resultRecordCount,a.start=e.pagesDefinition.internal.lastPage,a.geometry=e.pagesDefinition.geometry,a.where=e.pagesDefinition.where,a.orderByFields=""!==e.pagesDefinition.orderByFields?e.pagesDefinition.orderByFields.split(","):null,a.returnGeometry=e.pagesDefinition.returnGeometry,a.outSpatialReference=this.spatialReference,this.executeQuery(a,"execute").then((a=>{if(this._checkCancelled(r),e.pagesDefinition.internal.lastPage!==s)return"done";for(let t=0;t<a.features.length;t++)e.pagesDefinition.internal.set[i+t]=a.features[t].attributes[this._layer.objectIdField];if(!1===this._pageJustIds)for(let e=0;e<a.features.length;e++)this._featureCache[a.features[e].attributes[this._layer.objectIdField]]=a.features[e];return(void 0===a.exceededTransferLimit&&a.features.length!==e.pagesDefinition.resultRecordCount||!1===a.exceededTransferLimit)&&(e.pagesDefinition.internal.fullyResolved=!0),e.pagesDefinition.internal.lastRetrieved=t+a.features.length,e.pagesDefinition.internal.lastPage+=e.pagesDefinition.resultRecordCount,"done"}))}catch(i){return g(i)}}_fieldsIncludingObjectId(e){if(null===e)return[this.objectIdField];const t=e.slice(0);if(t.includes("*"))return t;let r=!1;for(const i of t)if(i.toUpperCase()===this.objectIdField.toUpperCase()){r=!0;break}return!1===r&&t.push(this.objectIdField),t}_getFeatures(e,t,r,i){const s=[];try{if(-1!==t&&void 0===this._featureCache[t]&&s.push(t),!0===this._checkIfNeedToExpandKnownPage(e,this._maxProcessingRate()))return this._expandPagedSet(e,this._maxProcessingRate(),0,0,i).then((()=>this._getFeatures(e,t,r,i)));let n=0;for(let i=e._lastFetchedIndex;i<e._known.length;i++){if(e._lastFetchedIndex+=1,n++,void 0===this._featureCache[e._known[i]]){let r=!1;if(null!==this._layer._mode&&void 0!==this._layer._mode){const t=this._layer._mode;if(void 0!==t._featureMap[e._known[i]]){const s=t._featureMap[e._known[i]];null!==s&&(r=!0,this._featureCache[e._known[i]]=s)}}if(!1===r&&(e._known[i]!==t&&s.push(e._known[i]),s.length>=this._maxProcessingRate()-1))break}if(n>=r&&0===s.length)break}if(0===s.length)return m("success");try{const e=new x;return this._requestStandardised&&(e.sqlFormat="standard"),e.objectIds=s,e.outFields=null!==this._overrideFields?this._overrideFields:this._fieldsIncludingObjectId(this._layer.outFields?this._layer.outFields:["*"]),e.returnGeometry=!0,!0===this._removeGeometry&&(e.returnGeometry=!1),e.outSpatialReference=this.spatialReference,this.executeQuery(e,"execute").then((e=>{if(this._checkCancelled(i),void 0!==e.error)return g(new Error(e.error));for(let t=0;t<e.features.length;t++)this._featureCache[e.features[t].attributes[this._layer.objectIdField]]=e.features[t];return"success"}))}catch(a){return g(a)}}catch(a){return g(a)}}_getDistinctPages(e,t,r,i,s,a,n,l,o){return this._ensureLoaded().then((()=>this.databaseType())).then((u=>{let h=r.parseTree.column;for(let e=0;e<this._layer.fields.length;e++)if(this._layer.fields[e].name.toLowerCase()===h.toLowerCase()){h=this._layer.fields[e].name;break}const p=new x;this._requestStandardised&&(p.sqlFormat="standard");let c=null===a?null===s?"1=1":"":d(a,u);return this._layer.definitionExpression&&this._useDefinitionExpression&&(c=""!==c?"(("+this._layer.definitionExpression+") AND ("+c+"))":this._layer.definitionExpression),p.where=c,p.spatialRelationship=this._makeRelationshipEnum(i),p.relationParameter=this._makeRelationshipParam(i),p.geometry=null===s?null:s,p.returnDistinctValues=!0,p.returnGeometry=!1,p.outFields=[h],this.executeQuery(p,"execute").then((u=>{if(this._checkCancelled(o),!u.hasOwnProperty("features"))return g(new Error("Unnexected Result querying statistics from layer"));let d=!1;for(let e=0;e<this._layer.fields.length;e++)if(this._layer.fields[e].name===h){"date"===this._layer.fields[e].type&&(d=!0);break}for(let e=0;e<u.features.length;e++){if(d){const t=u.features[e].attributes[h];null!==t?l.push(new Date(t)):l.push(t)}else l.push(u.features[e].attributes[h]);if(l.length>=n)break}return 0===u.features.length?l:u.features.length===this._layer.capabilities.query.maxRecordCount&&l.length<n?this._getDistinctPages(e+u.features.length,t,r,i,s,a,n,l,o).then((e=>({calculated:!0,result:e}))):l}))}))}_distinctStat(e,t,r,i,s,a,n){return this._getDistinctPages(0,e,t,r,i,s,a,[],n).then((e=>({calculated:!0,result:e})))}isTable(){return this._layer.isTable||null===this._layer.geometryType||"table"===this._layer.type||""===this._layer.geometryType}_countstat(e,t,r,i){return this.databaseType().then((e=>{const s=new x;if(this._requestStandardised&&(s.sqlFormat="standard"),this.isTable()&&r&&null!==t&&""!==t)return{calculated:!0,result:0};let a=null===i?null===r?"1=1":"":d(i,e);return this._layer.definitionExpression&&this._useDefinitionExpression&&(a=""!==a?"(("+this._layer.definitionExpression+") AND ("+a+"))":this._layer.definitionExpression),s.where=a,s.where=a,s.spatialRelationship=this._makeRelationshipEnum(t),s.relationParameter=this._makeRelationshipParam(t),s.geometry=null===r?null:r,s.returnGeometry=!1,this.executeQuery(s,"executeForCount").then((e=>({calculated:!0,result:e})))}))}_stats(e,t,r,i,s,a,n){return this._ensureLoaded().then((()=>{const l=this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsSqlExpression,o=this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsStatistics,u=this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsDistinct;return"count"===e?u?this._countstat(e,r,i,s):{calculated:!1}:!1===o||!1===h(t)&&!1===l||!1===t.isStandardized?""!==r||null!==s?{calculated:!1}:this._manualStat(e,t,a,n):"distinct"===e?!1===u?""!==r||null!==s?{calculated:!1}:this._manualStat(e,t,a,n):this._distinctStat(e,t,r,i,s,a,n):this.databaseType().then((a=>{if(this.isTable()&&i&&null!==r&&""!==r)return{calculated:!0,result:null};const n=new x;this._requestStandardised&&(n.sqlFormat="standard");let l=null===s?null===i?"1=1":"":d(s,a);this._layer.definitionExpression&&this._useDefinitionExpression&&(l=""!==l?"(("+this._layer.definitionExpression+") AND ("+l+"))":this._layer.definitionExpression),n.where=l,n.spatialRelationship=this._makeRelationshipEnum(r),n.relationParameter=this._makeRelationshipParam(r),n.geometry=null===i?null:i;const o=new j;o.statisticType=p(e),o.onStatisticField=d(t,a),o.outStatisticFieldName="ARCADE_STAT_RESULT",n.returnGeometry=!1;let u="ARCADE_STAT_RESULT";return n.outStatistics=[o],this.executeQuery(n,"execute").then((e=>{if(!e.hasOwnProperty("features")||0===e.features.length)return g(new Error("Unnexected Result querying statistics from layer"));let t=!1;for(let r=0;r<e.fields.length;r++)if("ARCADE_STAT_RESULT"===e.fields[r].name.toUpperCase()){u=e.fields[r].name,"date"===e.fields[r].type&&(t=!0);break}if(t){let t=e.features[0].attributes[u];return null!==t&&(t=new Date(e.features[0].attributes[u])),{calculated:!0,result:t}}return{calculated:!0,result:e.features[0].attributes[u]}}))}))}))}_stat(e,t,r,i,s,a,n){return this._stats(e,t,r,i,s,a,n)}_canDoAggregates(e,t){return this._ensureLoaded().then((()=>{let e=!1;const r=this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsSqlExpression;if(void 0!==this._layer.capabilities&&null!==this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsStatistics&&!0===this._layer.capabilities.query.supportsOrderBy&&(e=!0),e)for(let i=0;i<t.length-1;i++)null!==t[i].workingexpr&&(!1===t[i].workingexpr.isStandardized||!1===h(t[i].workingexpr)&&!1===r)&&(e=!1);return!1!==e}))}_makeRelationshipEnum(e){if(e.includes("esriSpatialRelRelation"))return"relation";switch(e){case"esriSpatialRelRelation":return"relation";case"esriSpatialRelIntersects":return"intersects";case"esriSpatialRelContains":return"contains";case"esriSpatialRelOverlaps":return"overlaps";case"esriSpatialRelWithin":return"within";case"esriSpatialRelTouches":return"touches";case"esriSpatialRelCrosses":return"crosses";case"esriSpatialRelEnvelopeIntersects":return"envelope-intersects"}return e}_makeRelationshipParam(e){return e.includes("esriSpatialRelRelation")?e.split(":")[1]:""}_getAggregatePagesDataSourceDefinition(e,t,r,i,a,n,l){return this._ensureLoaded().then((()=>this.databaseType())).then((o=>{let u="",h=!1,p=!1;null!==n&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsOrderBy&&(u=n.constructClause(),p=!0),this._layer.capabilities&&this._layer.capabilities.query&&!1===this._layer.capabilities.query.supportsPagination&&(p=!1,h=!0,u=this._layer.objectIdField);const c=[];for(let e=0;e<t.length;e++){const r=new j;r.onStatisticField=null!==t[e].workingexpr?d(t[e].workingexpr,o):"",r.outStatisticFieldName=t[e].field,r.statisticType=t[e].toStatisticsName(),c.push(r)}""===u&&(u=e.join(","));let y=this._maxQueryRate();const f=this._layer.capabilities.query.maxRecordCount;void 0!==f&&f<y&&(y=f);let _=null===a?null===i?"1=1":"":d(a,o);this._layer.definitionExpression&&this._useDefinitionExpression&&(_=""!==_?"(("+this._layer.definitionExpression+") AND ("+_+"))":this._layer.definitionExpression);return new s([],["GETPAGES"],p,{groupbypage:!0,spatialRel:this._makeRelationshipEnum(r),relationParam:this._makeRelationshipParam(r),outFields:["*"],useOIDpagination:h,generatedOid:l,resultRecordCount:y,resultOffset:0,groupByFieldsForStatistics:e,outStatistics:c,geometry:null===i?null:i,where:_,orderByFields:u,returnGeometry:!1,returnIdsOnly:!1,internal:{lastMaxId:-1,set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}})}))}_getAgregagtePhysicalPage(t,r,i){try{let r=t.pagesDefinition.where;!0===t.pagesDefinition.useOIDpagination&&(r=""!==r?"("+r+") AND ("+t.pagesDefinition.generatedOid+">"+t.pagesDefinition.internal.lastMaxId.toString()+")":t.pagesDefinition.generatedOid+">"+t.pagesDefinition.internal.lastMaxId.toString());const s=t.pagesDefinition.internal.lastRetrieved,a=s,n=t.pagesDefinition.internal.lastPage,l=new x;return this._requestStandardised&&(l.sqlFormat="standard"),l.where=r,l.spatialRelationship=t.pagesDefinition.spatialRel,l.relationParameter=t.pagesDefinition.relationParam,l.outFields=t.pagesDefinition.outFields,l.outStatistics=t.pagesDefinition.outStatistics,l.geometry=t.pagesDefinition.geometry,l.groupByFieldsForStatistics=t.pagesDefinition.groupByFieldsForStatistics,l.num=t.pagesDefinition.resultRecordCount,l.start=t.pagesDefinition.internal.lastPage,l.returnGeometry=t.pagesDefinition.returnGeometry,l.orderByFields=""!==t.pagesDefinition.orderByFields?t.pagesDefinition.orderByFields.split(","):null,this.isTable()&&l.geometry&&l.spatialRelationship?m([]):this.executeQuery(l,"execute").then((r=>{if(this._checkCancelled(i),!r.hasOwnProperty("features"))return g(new Error("Unnexected Result querying aggregates from layer"));const l=[];if(t.pagesDefinition.internal.lastPage!==n)return[];for(let e=0;e<r.features.length;e++)t.pagesDefinition.internal.set[a+e]=r.features[e].attributes[t.pagesDefinition.generatedOid];for(let t=0;t<r.features.length;t++)l.push(new e({attributes:r.features[t].attributes,geometry:null}));return!0===t.pagesDefinition.useOIDpagination?0===r.features.length?t.pagesDefinition.internal.fullyResolved=!0:t.pagesDefinition.internal.lastMaxId=r.features[r.features.length-1].attributes[t.pagesDefinition.generatedOid]:(void 0===r.exceededTransferLimit&&r.features.length!==t.pagesDefinition.resultRecordCount||!1===r.exceededTransferLimit)&&(t.pagesDefinition.internal.fullyResolved=!0),t.pagesDefinition.internal.lastRetrieved=s+r.features.length,t.pagesDefinition.internal.lastPage+=t.pagesDefinition.resultRecordCount,l}))}catch(s){return g(s)}}static create(e,t,r,i,s){const a=new S({url:e,outFields:null===t?["*"]:t});return new C({layer:a,spatialReference:r,lrucache:i,interceptor:s})}relationshipMetaData(){return this._layer&&this._layer.source&&this._layer.source.sourceJSON&&this._layer.source.sourceJSON.relationships?this._layer.source.sourceJSON.relationships:[]}serviceUrl(){return u(this._layer.parsedUrl.path)}queryAttachments(e,t,i,s,a){if(this._layer.capabilities.data.supportsAttachment&&this._layer.capabilities.operations.supportsQueryAttachments){const n={objectIds:[e],returnMetadata:a};return(t&&t>0||i&&i>0)&&(n.size=[t&&t>0?t:0,i&&i>0?i:t+1]),s&&s.length>0&&(n.attachmentTypes=s),this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preLayerQueryCallback({layer:this._layer,query:n,method:"attachments"}),this._layer.queryAttachments(n).then((t=>{const i=[];return t&&t[e]&&t[e].forEach((t=>{const s=this._layer.parsedUrl.path+"/"+e.toString()+"/attachments/"+t.id.toString();let n=null;a&&t.exifInfo&&(n=v.convertJsonToArcade(t.exifInfo,!0)),i.push(new r(t.id,t.name,t.contentType,t.size,s,n))})),i}))}return m([])}queryRelatedFeatures(r){const i={f:"json",relationshipId:r.relationshipId.toString(),definitionExpression:r.where,outFields:r.outFields.join(","),returnGeometry:r.returnGeometry.toString()};return void 0!==r.resultOffset&&null!==r.resultOffset&&(i.resultOffset=r.resultOffset.toString()),void 0!==r.resultRecordCount&&null!==r.resultRecordCount&&(i.resultRecordCount=r.resultRecordCount.toString()),r.orderByFields&&(i.orderByFields=r.orderByFields.join(",")),r.objectIds.length>0&&(i.objectIds=r.objectIds.join(",")),r.outSpatialReference&&(i.outSR=JSON.stringify(r.outSpatialReference.toJSON())),this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preRequestCallback({layer:this._layer,queryPayload:i,method:"relatedrecords",url:this._layer.parsedUrl.path+"/queryRelatedRecords"}),t(this._layer.parsedUrl.path+"/queryRelatedRecords",{responseType:"json",query:i}).then((t=>{if(t.data){const r={},i=t.data;if(i&&i.relatedRecordGroups){const t=i.spatialReference;for(const s of i.relatedRecordGroups){const a=s.objectId,n=[];for(const r of s.relatedRecords){r.geometry&&(r.geometry.spatialReference=t);const i=new e({geometry:r.geometry?F(r.geometry):null,attributes:r.attributes});n.push(i)}r[a]={features:n,exceededTransferLimit:!0===i.exceededTransferLimit}}}return r}return g("Invalid Request")}))}getFeatureByObjectId(e,t){const r=new x;return r.outFields=t,r.returnGeometry=!1,r.outSpatialReference=this.spatialReference,r.where=this.objectIdField+"="+e.toString(),this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preLayerQueryCallback({layer:this._layer,query:r,method:"execute"}),I(this._layer.parsedUrl.path,r).then((e=>1===e.features.length?e.features[0]:null))}getIdentityUser(){return this.load().then((()=>{var e;const t=null==(e=f)?void 0:e.findCredential(this._layer.url);return t?t.userId:null}))}getOwningSystemUrl(){return this.load().then((()=>{var e;const r=null==(e=f)?void 0:e.findServerInfo(this._layer.url);if(r)return m(r.owningSystemUrl);let i=this._layer.url;const s=i.toLowerCase().indexOf("/rest/services");return i=s>-1?i.substring(0,s):i,i?(i+="/rest/info",_(((e,r)=>{t(i,{query:{f:"json"}}).then((t=>{let r="";t.data&&t.data.owningSystemUrl&&(r=t.data.owningSystemUrl),e(r)}),(t=>{e("")}))}))):m("")}))}getDataSourceFeatureSet(){const e=new C({layer:this._layer,spatialReference:this.spatialReference,outFields:this._overrideFields,includeGeometry:!this._removeGeometry,lrucache:this.recentlyUsedQueries,interceptor:this.featureSetQueryInterceptor});return e._useDefinitionExpression=!1,e}}export{C as default};