@arcgis/core 4.28.0-next.20230818 → 4.28.0-next.20230821

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 (200) hide show
  1. package/arcade/functions/centroid.js +1 -1
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/003744a45b07865f1be9.js +1 -0
  4. package/assets/esri/core/workers/chunks/034accc7cab6c88a3b31.js +1 -0
  5. package/assets/esri/core/workers/chunks/05ab09713d599687afa3.js +1 -0
  6. package/assets/esri/core/workers/chunks/{3724f23b6f5ac8ec2568.js → 12b8fe0374fa9ab4ca09.js} +1 -1
  7. package/assets/esri/core/workers/chunks/16d1a72014074e87ecb9.js +1 -0
  8. package/assets/esri/core/workers/chunks/{e4b6565c16430b28ad93.js → 19857e5420cdf23c5f2e.js} +1 -1
  9. package/assets/esri/core/workers/chunks/{1a804dea42c0fb5e5c07.js → 1bab408eaffd2c18976d.js} +1 -1
  10. package/assets/esri/core/workers/chunks/201365f53509e3f78e17.js +1 -0
  11. package/assets/esri/core/workers/chunks/{2031451b82ff70fb201a.js → 2f48f4a9a0a056ac5e1c.js} +1 -1
  12. package/assets/esri/core/workers/chunks/318b51fdee09c1fd750f.js +1 -0
  13. package/assets/esri/core/workers/chunks/{5b799dc155adeb728c74.js → 3361e3e8385f8de8820c.js} +1 -1
  14. package/assets/esri/core/workers/chunks/3ce1870c28ab6ac3648e.js +1 -0
  15. package/assets/esri/core/workers/chunks/41929e4531787389804b.js +1 -0
  16. package/assets/esri/core/workers/chunks/{55ac725127c5ea9fb942.js → 4e39252f40bc57be9d12.js} +1 -1
  17. package/assets/esri/core/workers/chunks/4e496b03ce24b1206f86.js +1 -0
  18. package/assets/esri/core/workers/chunks/{ee5f17c1790dc07f9d9e.js → 50455c84131b634ca6b4.js} +1 -1
  19. package/assets/esri/core/workers/chunks/54513578f735d274a20e.js +1 -0
  20. package/assets/esri/core/workers/chunks/{d46f8ef92e79d12384c9.js → 587437526ea77f764986.js} +1 -1
  21. package/assets/esri/core/workers/chunks/{ab720e2f0a35138564b2.js → 5ffabd1a90c5b08109aa.js} +1 -1
  22. package/assets/esri/core/workers/chunks/6108d72faf48a592c8ba.js +1 -0
  23. package/assets/esri/core/workers/chunks/6479439afae01f9bb5e6.js +1 -0
  24. package/assets/esri/core/workers/chunks/69306dfc89e877539223.js +1 -0
  25. package/assets/esri/core/workers/chunks/6db4a6f9d25691830829.js +1 -0
  26. package/assets/esri/core/workers/chunks/{61393fd3376ea599a447.js → 76e27cece1559ae815df.js} +1 -1
  27. package/assets/esri/core/workers/chunks/81526909c0fa11639038.js +1 -0
  28. package/assets/esri/core/workers/chunks/873111ddf4813cdd4903.js +1 -0
  29. package/assets/esri/core/workers/chunks/8d4f1170394a8be15da9.js +1 -0
  30. package/assets/esri/core/workers/chunks/8d8bdfda09c24e363f78.js +1 -0
  31. package/assets/esri/core/workers/chunks/9b54b5bdb6367c36f6e9.js +1 -0
  32. package/assets/esri/core/workers/chunks/b2752e038c5fa3c21e49.js +1 -0
  33. package/assets/esri/core/workers/chunks/{dd3b7cfc6f78552249a4.js → b78dc6cbe14e5817b4d9.js} +1 -1
  34. package/assets/esri/core/workers/chunks/{e31d0c7363cbceeb5ac9.js → c35b850fbfcb28133235.js} +1 -1
  35. package/assets/esri/core/workers/chunks/c83e1be4ee64320cf2fe.js +1 -0
  36. package/assets/esri/core/workers/chunks/c88869d2a647c22dc3e6.js +1 -0
  37. package/assets/esri/core/workers/chunks/cb0a5bc6deaa98026bb5.js +1 -0
  38. package/assets/esri/core/workers/chunks/{767467738aeabec14abd.js → d0c4367a197b193e95d4.js} +1 -1
  39. package/assets/esri/core/workers/chunks/{f113141e254505116b82.js → d1cc2c050423595e54e0.js} +1 -1
  40. package/assets/esri/core/workers/chunks/{7f34945036495ad7c3f8.js → d2a8bf2d090b94cb294b.js} +1 -1
  41. package/assets/esri/core/workers/chunks/{08af7f7f1950a59a8e47.js → d6c96a20e9640b433719.js} +4 -4
  42. package/assets/esri/core/workers/chunks/da5453e67d00ff546640.js +1 -0
  43. package/assets/esri/core/workers/chunks/daa79c14150c12d8bc3d.js +1 -0
  44. package/assets/esri/core/workers/chunks/ef03b78659c72de93076.js +1 -0
  45. package/assets/esri/core/workers/chunks/{c3cace5b25b5170228ba.js → f2fe89b6ac6bf6817e71.js} +1 -1
  46. package/assets/esri/core/workers/chunks/f3554627664a419e00fa.js +1 -0
  47. package/assets/esri/themes/base/_core.scss +2 -0
  48. package/assets/esri/themes/base/widgets/_DirectionalPad.scss +76 -0
  49. package/assets/esri/themes/base/widgets/_Editor.scss +65 -4
  50. package/assets/esri/themes/base/widgets/_UtilityNetworkAssociations.scss +97 -39
  51. package/assets/esri/themes/dark/main.css +1 -1
  52. package/assets/esri/themes/light/main.css +1 -1
  53. package/assets/esri/themes/light/view.css +1 -1
  54. package/assets/esri/widgets/DirectionalPad/t9n/DirectionalPad.json +1 -0
  55. package/assets/esri/widgets/DirectionalPad/t9n/DirectionalPad_en.json +1 -0
  56. package/assets/esri/widgets/Editor/t9n/Editor.json +1 -1
  57. package/assets/esri/widgets/Editor/t9n/Editor_en.json +1 -1
  58. package/assets/esri/widgets/UtilityNetworkAssociations/assets/img/line-caps/butt.png +0 -0
  59. package/assets/esri/widgets/UtilityNetworkAssociations/assets/img/line-caps/round.png +0 -0
  60. package/assets/esri/widgets/UtilityNetworkAssociations/assets/img/line-caps/square.png +0 -0
  61. package/assets/esri/widgets/UtilityNetworkAssociations/assets/img/line-patterns/dash-dot.png +0 -0
  62. package/assets/esri/widgets/UtilityNetworkAssociations/assets/img/line-patterns/dash.png +0 -0
  63. package/assets/esri/widgets/UtilityNetworkAssociations/assets/img/line-patterns/dot.png +0 -0
  64. package/assets/esri/widgets/UtilityNetworkAssociations/assets/img/line-patterns/long-dash-dot-dot.png +0 -0
  65. package/assets/esri/widgets/UtilityNetworkAssociations/assets/img/line-patterns/long-dash-dot.png +0 -0
  66. package/assets/esri/widgets/UtilityNetworkAssociations/assets/img/line-patterns/long-dash.png +0 -0
  67. package/assets/esri/widgets/UtilityNetworkAssociations/assets/img/line-patterns/short-dash-dot-dot.png +0 -0
  68. package/assets/esri/widgets/UtilityNetworkAssociations/assets/img/line-patterns/short-dash-dot.png +0 -0
  69. package/assets/esri/widgets/UtilityNetworkAssociations/assets/img/line-patterns/short-dash.png +0 -0
  70. package/assets/esri/widgets/UtilityNetworkAssociations/assets/img/line-patterns/short-dot.png +0 -0
  71. package/assets/esri/widgets/UtilityNetworkAssociations/assets/img/line-patterns/solid.png +0 -0
  72. package/assets/esri/widgets/UtilityNetworkAssociations/t9n/UtilityNetworkAssociations.json +1 -1
  73. package/assets/esri/widgets/UtilityNetworkAssociations/t9n/UtilityNetworkAssociations_en.json +1 -1
  74. package/chunks/HighlightBlur.glsl.js +3 -3
  75. package/chunks/HighlightDownsample.glsl.js +24 -6
  76. package/chunks/SSAO.glsl.js +2 -2
  77. package/core/timeUtils.js +1 -1
  78. package/interfaces.d.ts +182 -2
  79. package/intl/date.js +1 -1
  80. package/layers/FeatureLayer.js +1 -1
  81. package/layers/ImageryLayer.js +1 -1
  82. package/layers/ImageryTileLayer.js +1 -1
  83. package/layers/StreamLayer.js +1 -1
  84. package/layers/SubtypeGroupLayer.js +1 -1
  85. package/layers/VoxelWasmPerSceneView.js +1 -1
  86. package/layers/graphics/sources/support/uploads.js +1 -1
  87. package/layers/mixins/ArcGISImageService.js +1 -1
  88. package/layers/mixins/ImageryTileMixin.js +1 -1
  89. package/layers/save/featureLayerUtils.js +1 -1
  90. package/layers/save/imageryUtils.js +1 -1
  91. package/layers/save/streamLayerUtils.js +1 -1
  92. package/libs/maquette-advanced-projector/utils.js +1 -1
  93. package/package.json +1 -1
  94. package/popup/support/FieldInfoFormat.js +1 -1
  95. package/portal/PortalItem.js +1 -1
  96. package/support/revision.js +1 -1
  97. package/views/2d/navigation/MapViewNavigation.js +1 -1
  98. package/views/3d/environment/EnvironmentRenderer.js +1 -1
  99. package/views/3d/externalRenderers/ExternalRendererStore.js +1 -1
  100. package/views/3d/layers/i3s/PointRenderer.js +1 -1
  101. package/views/3d/support/LaserLineRenderer.js +1 -1
  102. package/views/3d/terrain/OverlayRenderer.js +1 -1
  103. package/views/3d/terrain/TerrainRenderer.js +1 -1
  104. package/views/3d/terrain/TerrainSurface.js +1 -1
  105. package/views/3d/webgl-engine/core/renderPasses/RenderPassManager.js +1 -1
  106. package/views/3d/webgl-engine/effects/RenderPlugin.js +1 -1
  107. package/views/3d/webgl-engine/effects/RenderPluginManager.js +1 -1
  108. package/views/3d/webgl-engine/effects/highlight/Highlight.js +1 -1
  109. package/views/3d/webgl-engine/effects/highlight/ShadowHighlight.js +1 -1
  110. package/views/3d/webgl-engine/effects/smaa/SMAA.js +1 -1
  111. package/views/3d/webgl-engine/effects/ssao/SSAO.js +1 -1
  112. package/views/3d/webgl-engine/lib/GLMaterialRepository.js +1 -1
  113. package/views/3d/webgl-engine/lib/GLMaterials.js +1 -1
  114. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  115. package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
  116. package/views/3d/webgl-engine/materials/CheckerBoardMaterial.js +1 -1
  117. package/views/3d/webgl-engine/materials/ColorMaterial.js +1 -1
  118. package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
  119. package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
  120. package/views/3d/webgl-engine/materials/HeatmapDensityMaterial.js +1 -1
  121. package/views/3d/webgl-engine/materials/ImageMaterial.js +1 -1
  122. package/views/3d/webgl-engine/materials/LineCalloutMaterial.js +1 -1
  123. package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
  124. package/views/3d/webgl-engine/materials/MeasurementArrowMaterial.js +1 -1
  125. package/views/3d/webgl-engine/materials/NativeLineMaterial.js +1 -1
  126. package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
  127. package/views/3d/webgl-engine/materials/PatternMaterial.js +1 -1
  128. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  129. package/views/3d/webgl-engine/materials/ShadedColorMaterial.js +1 -1
  130. package/views/3d/webgl-engine/materials/SlicePlaneMaterial.js +1 -1
  131. package/views/3d/webgl-engine/materials/WaterMaterial.js +1 -1
  132. package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
  133. package/views/3d/webgl-engine/shaders/HighlightDownsample.glsl.js +1 -1
  134. package/views/draw/DrawGraphicTool.js +1 -1
  135. package/views/draw/DrawOperation.js +1 -1
  136. package/views/interactive/sketch/constraints.js +1 -1
  137. package/views/interactive/sketch/normalizedPoint.js +1 -1
  138. package/views/interactive/snapping/SnappingManager.js +1 -1
  139. package/views/interactive/snapping/candidates/IntersectionSnappingCandidate.js +1 -1
  140. package/views/interactive/tooltip/TooltipEditableField.js +1 -1
  141. package/views/interactive/tooltip/TooltipEditableFieldAngle.js +1 -1
  142. package/views/interactive/tooltip/constraintUtils.js +5 -0
  143. package/views/support/angularMeasurementUtils.js +1 -1
  144. package/widgets/Compass/CompassViewModel.js +1 -1
  145. package/widgets/Compass/utils.js +5 -0
  146. package/widgets/DirectionalPad/DirectionalPadViewModel.d.ts +4 -0
  147. package/widgets/DirectionalPad/DirectionalPadViewModel.js +5 -0
  148. package/widgets/DirectionalPad/VisibleElements.js +5 -0
  149. package/widgets/DirectionalPad/constants.js +5 -0
  150. package/widgets/DirectionalPad/css.js +5 -0
  151. package/widgets/DirectionalPad/utils.js +5 -0
  152. package/widgets/DirectionalPad.d.ts +4 -0
  153. package/widgets/DirectionalPad.js +5 -0
  154. package/widgets/Editor/EditorViewModel.js +1 -1
  155. package/widgets/Editor/Upload.js +1 -1
  156. package/widgets/Editor/components/CreateFeaturesPanelContent.js +1 -1
  157. package/widgets/Editor/components/UploadDetails.js +1 -1
  158. package/widgets/Editor/modelUploadUtils.js +1 -1
  159. package/widgets/Editor.js +1 -1
  160. package/widgets/ElevationProfile/support/chartUtils.js +1 -1
  161. package/widgets/ElevationProfile.js +1 -1
  162. package/widgets/Feature/FeatureViewModel.js +1 -1
  163. package/widgets/Feature/support/featureUtils.js +1 -1
  164. package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
  165. package/widgets/FeatureForm/FieldInput.js +1 -1
  166. package/widgets/FeatureForm/FormExpressionsManager.js +1 -1
  167. package/widgets/FeatureForm/InputBase.js +1 -1
  168. package/widgets/FeatureForm.js +1 -1
  169. package/widgets/UtilityNetworkAssociations/UtilityNetworkAssociationsLineSymbolPicker.js +5 -0
  170. package/widgets/UtilityNetworkAssociations/UtilityNetworkAssociationsViewModel.js +1 -1
  171. package/widgets/UtilityNetworkAssociations/VisibleElements.js +5 -0
  172. package/widgets/UtilityNetworkAssociations/VisibleElementsSettingsPane.js +5 -0
  173. package/widgets/UtilityNetworkAssociations.js +1 -1
  174. package/assets/esri/core/workers/chunks/11abbbf97093b55e2417.js +0 -1
  175. package/assets/esri/core/workers/chunks/1b2a081f2c3b97ba7e00.js +0 -1
  176. package/assets/esri/core/workers/chunks/235f333177ed7ea21e01.js +0 -1
  177. package/assets/esri/core/workers/chunks/3725dd14c2da0f47198f.js +0 -1
  178. package/assets/esri/core/workers/chunks/39467e1da18924cfb9b6.js +0 -1
  179. package/assets/esri/core/workers/chunks/42595c4870c673ed451c.js +0 -1
  180. package/assets/esri/core/workers/chunks/481cdd2a4bc40c6fef66.js +0 -1
  181. package/assets/esri/core/workers/chunks/54893132e70c515ea7e3.js +0 -1
  182. package/assets/esri/core/workers/chunks/6509a4198972b323d9b6.js +0 -1
  183. package/assets/esri/core/workers/chunks/68598d2806d4aa3d8acc.js +0 -1
  184. package/assets/esri/core/workers/chunks/718d2e8ea61f3b7b70c5.js +0 -1
  185. package/assets/esri/core/workers/chunks/7bce4b5eec630ef57f1e.js +0 -1
  186. package/assets/esri/core/workers/chunks/81df7304f97d1fc3ba16.js +0 -1
  187. package/assets/esri/core/workers/chunks/8706dc9f852df9b2095d.js +0 -1
  188. package/assets/esri/core/workers/chunks/8ef26aac0fe7feb8c324.js +0 -1
  189. package/assets/esri/core/workers/chunks/91e61da22f258d9e86c5.js +0 -1
  190. package/assets/esri/core/workers/chunks/9f039bf79b34d8fd75ae.js +0 -1
  191. package/assets/esri/core/workers/chunks/a1f3352301472e4b8956.js +0 -1
  192. package/assets/esri/core/workers/chunks/a20fd9e7db37b3c3b041.js +0 -1
  193. package/assets/esri/core/workers/chunks/aa83dce42d64034a0a13.js +0 -1
  194. package/assets/esri/core/workers/chunks/c8c8471b59700914ee9d.js +0 -1
  195. package/assets/esri/core/workers/chunks/cdcf0a5e05283d37b3ac.js +0 -1
  196. package/assets/esri/core/workers/chunks/d4f9106bf2ea5d66d96a.js +0 -1
  197. package/assets/esri/core/workers/chunks/e6bfbc4347fa13db4df2.js +0 -1
  198. package/assets/esri/core/workers/chunks/f1d5487f2d828fb142ba.js +0 -1
  199. package/assets/esri/core/workers/chunks/f97f165d05439e668e05.js +0 -1
  200. package/assets/esri/core/workers/chunks/fe973d8155c22d73a4f9.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import r from"../PopupTemplate.js";import"../renderers/ClassBreaksRenderer.js";import"../renderers/DictionaryRenderer.js";import"../renderers/DotDensityRenderer.js";import"../renderers/HeatmapRenderer.js";import"../renderers/PieChartRenderer.js";import"../renderers/Renderer.js";import"../renderers/SimpleRenderer.js";import"../renderers/UniqueValueRenderer.js";import{read as t}from"../renderers/support/jsonUtils.js";import{rendererTypes as i,webSceneRendererTypes as o}from"../renderers/support/types.js";import s from"../request.js";import{symbolTypes as a}from"../symbols.js";import{ClonableMixin as n}from"../core/Clonable.js";import l from"../core/Collection.js";import p from"../core/Error.js";import{clone as u}from"../core/lang.js";import d from"../core/Logger.js";import{MultiOriginJSONMixin as y}from"../core/MultiOriginJSONSupport.js";import{setDeepValue as c}from"../core/object.js";import{throwIfAbortError as m,whenOrAbort as f}from"../core/promiseUtils.js";import{sqlAnd as h}from"../core/sql.js";import{urlToObject as b,join as g}from"../core/urlUtils.js";import{property as w}from"../core/accessorSupport/decorators/property.js";import{cast as j}from"../core/accessorSupport/decorators/cast.js";import{reader as v}from"../core/accessorSupport/decorators/reader.js";import{subclass as F}from"../core/accessorSupport/decorators/subclass.js";import{writer as S}from"../core/accessorSupport/decorators/writer.js";import I from"../form/FormTemplate.js";import T from"../geometry/SpatialReference.js";import D from"./Layer.js";import{MemorySource as E}from"./graphics/sources/MemorySource.js";import{APIKeyMixin as L}from"./mixins/APIKeyMixin.js";import{ArcGISService as x}from"./mixins/ArcGISService.js";import{BlendLayer as _}from"./mixins/BlendLayer.js";import{CustomParametersMixin as P}from"./mixins/CustomParametersMixin.js";import{EditBusLayer as M}from"./mixins/EditBusLayer.js";import{FeatureEffectLayer as q}from"./mixins/FeatureEffectLayer.js";import{FeatureLayerBase as C}from"./mixins/FeatureLayerBase.js";import{FeatureReductionLayer as O}from"./mixins/FeatureReductionLayer.js";import{OperationalLayer as R}from"./mixins/OperationalLayer.js";import{OrderedLayer as A}from"./mixins/OrderedLayer.js";import{PortalLayer as U}from"./mixins/PortalLayer.js";import{PublishableLayer as Q}from"./mixins/PublishableLayer.js";import{RefreshableLayer as V}from"./mixins/RefreshableLayer.js";import{ScaleRangeLayer as N}from"./mixins/ScaleRangeLayer.js";import{TemporalLayer as G}from"./mixins/TemporalLayer.js";import{titleFromUrlAndName as J,parse as $,cleanTitle as W}from"./support/arcgisLayerUrl.js";import{id as B,labelsVisible as H,opacityDrawingInfo as Z,legendEnabled as k,listMode as z,popupEnabled as K,screenSizePerspectiveEnabled as X}from"./support/commonProperties.js";import{ensureLayerCredential as Y,computeEffectiveEditingEnabled as ee,readGlobalIdField as re,readObjectIdField as te,createDefaultRenderer as ie,addAttachment as oe,updateAttachment as se,applyEdits as ae,uploadAssets as ne,createQuery as le,deleteAttachments as pe,fetchRecomputedExtents as ue,queryAttachments as de,queryObjectIds as ye,queryFeatureCount as ce,queryExtent as me,queryRelatedFeatures as fe,queryRelatedFeaturesCount as he,hasDataChanged as be,geometryTypeKebabDict as ge}from"./support/featureLayerUtils.js";import we from"./support/FeatureTemplate.js";import je from"./support/FeatureType.js";import{defineFieldProperties as ve}from"./support/fieldProperties.js";import{fixRendererFields as Fe,fixTimeInfoFields as Se}from"./support/fieldUtils.js";import Ie from"./support/LabelClass.js";import{reader as Te}from"./support/labelingInfo.js";import{getFeatureLayerCapabilities as De}from"./support/serviceCapabilitiesUtils.js";import Ee from"./support/TimeInfo.js";import{serviceSupportsSpatialReference as Le}from"./support/versionUtils.js";import{DataLayerSource as xe}from"./support/source/DataLayerSource.js";import{loadStyleRenderer as _e}from"../renderers/support/styleUtils.js";import Pe from"../rest/support/FeatureSet.js";import Me from"../rest/support/Query.js";import qe from"../rest/support/TopFeaturesQuery.js";import{createPopupTemplate as Ce}from"../support/popupUtils.js";import{opacityToTransparency as Oe}from"../webdoc/support/opacityUtils.js";const Re="FeatureLayer",Ae="esri.layers.FeatureLayer",Ue=d.getLogger(Ae);function Qe(e,r){return new p("layer:unsupported",`Layer (${e.title}, ${e.id}) of type '${e.declaredClass}' ${r}`,{layer:e})}function Ve(e){return e&&e instanceof l}const Ne=ve();function Ge(e,r,t){const i=!!t?.writeLayerSchema;return{enabled:i,ignoreOrigin:i}}let Je=class extends(C(O(q(Q(M(_(A(G(N(V(x(R(U(y(P(L(n(D)))))))))))))))))){constructor(...e){super(...e),this.charts=null,this.copyright=null,this.displayField=null,this.dynamicDataSource=null,this.fields=null,this.fieldsIndex=null,this.formTemplate=null,this.fullExtent=null,this.geometryType=null,this.hasM=void 0,this.hasZ=void 0,this.infoFor3D=null,this.isTable=!1,this.labelsVisible=!0,this.labelingInfo=null,this.legendEnabled=!0,this.objectIdField=null,this.outFields=null,this.path=null,this.popupEnabled=!0,this.popupTemplate=null,this.screenSizePerspectiveEnabled=!0,this.spatialReference=T.WGS84,this.subtypeCode=null,this.templates=null,this.timeInfo=null,this.title=null,this.sublayerTitleMode="item-title",this.type="feature",this.typeIdField=null,this.types=null,this.visible=!0}destroy(){this.source?.destroy()}normalizeCtorArgs(e,r){return"string"==typeof e?{url:e,...r}:e}load(e){const r=null!=e?e.signal:null;if(this.portalItem?.loaded&&this.source)return this.addResolvingPromise(this.createGraphicsSource(r).then((e=>this.initLayerProperties(e)))),Promise.resolve(this);const t=this.loadFromPortal({supportedTypes:["Feature Service","Feature Collection"]},e).catch(m).then((async()=>{if(this.url&&null==this.layerId&&/FeatureServer|MapServer\/*$/i.test(this.url)){const e=await this._fetchFirstLayerId(r);null!=e&&(this.layerId=e)}if(!this.url&&!this._hasMemorySource())throw new p("feature-layer:missing-url-or-source","Feature layer must be created with either a url or a source");return this.initLayerProperties(await this.createGraphicsSource(r))})).then((()=>Y(this,"load",e)));return this.addResolvingPromise(t),Promise.resolve(this)}readCapabilities(e,r){return r=r.layerDefinition||r,De(r,this.url)}get createQueryVersion(){return this.commitProperty("definitionExpression"),this.commitProperty("dynamicDataSource"),this.commitProperty("timeExtent"),this.commitProperty("timeOffset"),this.commitProperty("geometryType"),this.commitProperty("gdbVersion"),this.commitProperty("historicMoment"),this.commitProperty("returnZ"),this.commitProperty("capabilities"),this.commitProperty("returnM"),(this._get("createQueryVersion")??0)+1}get editingEnabled(){return!(this.loaded&&!this.capabilities?.operations.supportsEditing)&&(this._isOverridden("editingEnabled")?this._get("editingEnabled"):this._hasMemorySource()||this.userHasEditingPrivileges)}set editingEnabled(e){this._overrideIfSome("editingEnabled",e)}readEditingEnabled(e,r){return this._readEditingEnabled(r,!1)}readEditingEnabledFromWebMap(e,r,t){return this._readEditingEnabled(r,!0,t)}writeEditingEnabled(e,r){this._writeEditingEnabled(e,r,!1)}writeEditingEnabledToWebMap(e,r,t,i){this._writeEditingEnabled(e,r,!0,i)}get effectiveEditingEnabled(){return ee(this)}readIsTable(e,r){return"Table"===(r=r?.layerDefinition??r).type||!r.geometryType}writeIsTable(e,r,t,i){i?.writeLayerSchema&&c(t,e?"Table":"Feature Layer",r)}readGlobalIdField(e,r){return re(r.layerDefinition||r)}readObjectIdField(e,r){return te(r.layerDefinition||r)}get parsedUrl(){const e=b(this.url);return null!=e&&(null!=this.dynamicDataSource?e.path=g(e.path,"dynamicLayer"):null!=this.layerId&&(e.path=g(e.path,this.layerId.toString()))),e}get defaultPopupTemplate(){return this.createPopupTemplate()}set renderer(e){Fe(e,this.fieldsIndex),this._set("renderer",e)}readRenderer(e,r,i){r=r.layerDefinition||r;const o=r.drawingInfo?.renderer;if(o){const e=t(o,r,i)??void 0;return e||Ue.error("Failed to create renderer",{rendererDefinition:r.drawingInfo.renderer,layer:this,context:i}),e}return ie(r,i)}set source(e){const r=this._get("source");r!==e&&(Ve(r)&&this._resetMemorySource(r),Ve(e)&&this._initMemorySource(e),this._set("source",e))}castSource(e){return e?Array.isArray(e)||e instanceof l?new E({layer:this,items:e}):e:null}readSource(e,r){const t=Pe.fromJSON(r.featureSet);return new E({layer:this,items:t?.features??[]})}readTemplates(e,r){const t=r.editFieldsInfo,i=t&&t.creatorField,o=t&&t.editorField;return e=e&&e.map((e=>we.fromJSON(e))),this._fixTemplates(e,i),this._fixTemplates(e,o),e}readTitle(e,r){const t=r.layerDefinition?.name??r.name,i=r.title||r.layerDefinition&&r.layerDefinition.title;if(t){const e=this.portalItem&&this.portalItem.title;if("item-title"===this.sublayerTitleMode)return this.url?J(this.url,t):t;let r=t;if(!r&&this.url){const e=$(this.url);null!=e&&(r=e.title)}if(!r)return;return"item-title-and-service-name"===this.sublayerTitleMode&&e&&e!==r&&(r=e+" - "+r),W(r)}if("item-title"===this.sublayerTitleMode&&i)return i}readTitleFromWebMap(e,r){return r.title||r.layerDefinition&&r.layerDefinition.name}readTypeIdField(e,r){let t=(r=r.layerDefinition||r).typeIdField;if(t&&r.fields){t=t.toLowerCase();const e=r.fields.find((e=>e.name.toLowerCase()===t));e&&(t=e.name)}return t}readTypes(e,r){e=(r=r.layerDefinition||r).types;const t=r.editFieldsInfo,i=t&&t.creatorField,o=t&&t.editorField;return e&&e.map((e=>(e=je.fromJSON(e),this._fixTemplates(e.templates,i),this._fixTemplates(e.templates,o),e)))}readVisible(e,r){return r.layerDefinition&&null!=r.layerDefinition.defaultVisibility?!!r.layerDefinition.defaultVisibility:null!=r.visibility?!!r.visibility:void 0}async addAttachment(e,r){return oe(this,e,r,Re)}async updateAttachment(e,r,t){return se(this,e,r,t,Re)}async applyEdits(e,r){return ae(this,e,r)}async uploadAssets(e,r){return ne(this,e,r)}on(e,r){return super.on(e,r)}createPopupTemplate(e){return Ce(this,e)}async createGraphicsSource(e){if(this._hasMemorySource()&&this.source)return this.source.load({signal:e});const{default:r}=await f(import("./graphics/sources/FeatureLayerSource.js"),e);return new r({layer:this}).load({signal:e})}createQuery(){const e=le(this);e.dynamicDataSource=this.dynamicDataSource;const r=null!=this.subtypeCode?`${this.subtypeField} = ${this.subtypeCode}`:null,t=h(this.definitionExpression,r);return e.where=t||"1=1",e}async deleteAttachments(e,r){return pe(this,e,r,Re)}async fetchRecomputedExtents(e){return ue(this,e,Re)}getFeatureType(e){const{typeIdField:r,types:t}=this;if(!r||!e)return null;const i=e.attributes?e.attributes[r]:void 0;if(null==i)return null;let o=null;return t?.some((e=>{const{id:r}=e;return null!=r&&(r.toString()===i.toString()&&(o=e),!!o)})),o}getFieldDomain(e,r){const t=r?.feature,i=this.getFeatureType(t);if(i){const r=i.domains&&i.domains[e];if(r&&"inherited"!==r.type)return r}return this._getLayerDomain(e)}getField(e){return this.fieldsIndex.get(e)}async queryAttachments(e,r){return de(this,e,r,Re)}async queryFeatures(e,r){const t=await this.load(),i=await t.source.queryFeatures(Me.from(e)??t.createQuery(),r);if(i?.features)for(const o of i.features)o.layer=o.sourceLayer=t;return i}async queryObjectIds(e,r){return ye(this,e,r,Re)}async queryFeatureCount(e,r){return ce(this,e,r,Re)}async queryExtent(e,r){return me(this,e,r,Re)}async queryRelatedFeatures(e,r){return fe(this,e,r,Re)}async queryRelatedFeaturesCount(e,r){return he(this,e,r,Re)}async queryTopFeatures(e,r){const{source:t,capabilities:i}=await this.load();if(!t.queryTopFeatures||!i?.query?.supportsTopFeaturesQuery)throw new p(Re,"Layer source does not support queryTopFeatures capability");const o=await t.queryTopFeatures(qe.from(e),r);if(o?.features)for(const s of o.features)s.layer=s.sourceLayer=this;return o}async queryTopObjectIds(e,r){const{source:t,capabilities:i}=await this.load();if(!t.queryTopObjectIds||!i?.query.supportsTopFeaturesQuery)throw new p(Re,"Layer source does not support queryTopObjectIds capability");return t.queryTopObjectIds(qe.from(e),r)}async queryTopFeaturesExtent(e,r){const{source:t,capabilities:i}=await this.load();if(!t.queryTopExtents||!i?.query?.supportsTopFeaturesQuery)throw new p(Re,"Layer source does not support queryTopExtents capability");return t.queryTopExtents(qe.from(e),r)}async queryTopFeatureCount(e,r){const{source:t,capabilities:i}=await this.load();if(!t.queryTopCount||!i?.query?.supportsTopFeaturesQuery)throw new p(Re,"Layer source does not support queryFeatureCount capability");return t.queryTopCount(qe.from(e),r)}read(e,r){const t=e.featureCollection;if(t){const e=t.layers;e&&1===e.length&&(super.read(e[0],r),null!=t.showLegend&&super.read({showLegend:t.showLegend},r))}super.read(e,r),r&&"service"===r.origin&&(this.revert(["objectIdField","fields","timeInfo"],"service"),this.spatialReference||this.revert(["spatialReference"],"service"))}write(e,r){r={...r,origin:r?.origin??void 0,writeLayerSchema:r?.writeLayerSchema??this._hasMemorySource()};const{origin:t,layerContainerType:i,messages:o}=r;if(this.dynamicDataSource)return o?.push(Qe(this,"using a dynamic data source cannot be written to web scenes, web maps and feature service items")),null;if(this.isTable){if("web-scene"===t||"web-map"===t&&"tables"!==i)return o?.push(Qe(this,"using a table source cannot be written to web scenes and web maps")),null;if(this._hasMemorySource())return o?.push(Qe(this,"using an in-memory table source cannot be written to web scenes and web maps")),null}else if(this.loaded&&"web-map"===t&&"tables"===i)return o?.push(Qe(this,"using a non-table source cannot be written to tables in web maps")),null;return super.write(e,r)}clone(){if(this._hasMemorySource())throw new p(Re,`FeatureLayer (title: ${this.title}, id: ${this.id}) created using in-memory source cannot be cloned`);return super.clone()}serviceSupportsSpatialReference(e){return!!this.loaded&&("memory"===this.source?.type||Le(this,e))}async save(e){const{save:r}=await import("./save/featureLayerUtils.js");return r(this,e)}async saveAs(e,r){const{saveAs:t}=await import("./save/featureLayerUtils.js");return t(this,e,r)}_readEditingEnabled(e,r,t){let i=e.layerDefinition?.capabilities;return i?this._hasEditingCapability(i):(i=e.capabilities,r&&"web-map"===t?.origin&&!this._hasMemorySource()&&i?this._hasEditingCapability(i):void 0)}_hasEditingCapability(e){return e.toLowerCase().split(",").map((e=>e.trim())).includes("editing")}_writeEditingEnabled(e,r,t,i){if(!e){const e=this.capabilities?.operations?.supportsSync?"Query,Sync":"Query";c("layerDefinition.capabilities",e,r),t&&!i?.writeLayerSchema&&(r.capabilities=e)}}_getLayerDomain(e){const r=this.fieldsIndex.get(e);return r?r.domain:null}_fetchFirstLayerId(e){return s(this.url,{query:{f:"json",...this.customParameters,token:this.apiKey},responseType:"json",signal:e}).then((e=>{const r=e.data;if(r)return Array.isArray(r.layers)&&r.layers.length>0?r.layers[0].id:Array.isArray(r.tables)&&r.tables.length>0?r.tables[0].id:void 0}))}async initLayerProperties(e){return this._set("source",e),e.sourceJSON&&(this.sourceJSON=e.sourceJSON,this.read(e.sourceJSON,{origin:"service",portalItem:this.portalItem,portal:this.portalItem?.portal,url:this.parsedUrl})),this._verifySource(),this._verifyFields(),Fe(this.renderer,this.fieldsIndex),Se(this.timeInfo,this.fieldsIndex),_e(this,{origin:"service"})}async hasDataChanged(){return be(this)}async fetchPublishingStatus(){const e=this.source;return e?.fetchPublishingStatus?e.fetchPublishingStatus():"unavailable"}_verifyFields(){const e=this.parsedUrl?.path??"undefined";this.objectIdField||console.log("FeatureLayer: 'objectIdField' property is not defined (url: "+e+")"),this.isTable||this._hasMemorySource()||-1!==e.search(/\/FeatureServer\//i)||this.fields?.some((e=>"geometry"===e.type))||console.log("FeatureLayer: unable to find field of type 'geometry' in the layer 'fields' list. If you are using a map service layer, features will not have geometry (url: "+e+")")}_fixTemplates(e,r){e&&e.forEach((e=>{const t=e.prototype&&e.prototype.attributes;t&&r&&delete t[r]}))}_verifySource(){if(this._hasMemorySource()){if(this.url)throw new p("feature-layer:mixed-source-and-url","FeatureLayer cannot be created with both an in-memory source and a url")}else if(!this.url)throw new p("feature-layer:source-or-url-required","FeatureLayer requires either a url, a valid portal item or a source")}_initMemorySource(e){e.forEach((e=>{e.layer=this,e.sourceLayer=this})),this.addHandles([e.on("after-add",(e=>{e.item.layer=this,e.item.sourceLayer=this})),e.on("after-remove",(e=>{e.item.layer=null,e.item.sourceLayer=null}))],"fl-source")}_resetMemorySource(e){e.forEach((e=>{e.layer=null,e.sourceLayer=null})),this.removeHandles("fl-source")}_hasMemorySource(){return!(this.url||!this.source)}};e([v("service","capabilities")],Je.prototype,"readCapabilities",null),e([w({json:{origins:{"web-scene":{write:!1}},write:!0}})],Je.prototype,"charts",void 0),e([w({readOnly:!0})],Je.prototype,"createQueryVersion",null),e([w({json:{read:{source:"layerDefinition.copyrightText"}}})],Je.prototype,"copyright",void 0),e([w({json:{read:{source:"layerDefinition.displayField"}}})],Je.prototype,"displayField",void 0),e([w({types:a,readOnly:!0})],Je.prototype,"defaultSymbol",void 0),e([w({type:xe})],Je.prototype,"dynamicDataSource",void 0),e([w({type:Boolean})],Je.prototype,"editingEnabled",null),e([v(["portal-item","web-scene"],"editingEnabled",["layerDefinition.capabilities"])],Je.prototype,"readEditingEnabled",null),e([v("web-map","editingEnabled",["capabilities","layerDefinition.capabilities"])],Je.prototype,"readEditingEnabledFromWebMap",null),e([S(["portal-item","web-scene"],"editingEnabled",{"layerDefinition.capabilities":{type:String}})],Je.prototype,"writeEditingEnabled",null),e([S("web-map","editingEnabled",{capabilities:{type:String},"layerDefinition.capabilities":{type:String}})],Je.prototype,"writeEditingEnabledToWebMap",null),e([w({readOnly:!0})],Je.prototype,"effectiveEditingEnabled",null),e([w({...Ne.fields,json:{read:{source:"layerDefinition.fields"},origins:{service:{name:"fields"},"web-map":{write:{target:"layerDefinition.fields",overridePolicy:Ge}}}}})],Je.prototype,"fields",void 0),e([w(Ne.fieldsIndex)],Je.prototype,"fieldsIndex",void 0),e([w({type:I,json:{name:"formInfo",write:!0,origins:{"web-scene":{read:!1,write:!1}}}})],Je.prototype,"formTemplate",void 0),e([w({json:{read:{source:"layerDefinition.extent"}}})],Je.prototype,"fullExtent",void 0),e([w({json:{origins:{"web-map":{write:{target:"layerDefinition.geometryType",overridePolicy:Ge,writer(e,r,t){const i=e?ge.toJSON(e):null;i&&c(t,i,r)}}}},read:{source:"layerDefinition.geometryType",reader:ge.read}}})],Je.prototype,"geometryType",void 0),e([w({json:{read:{source:"layerDefinition.hasM"}}})],Je.prototype,"hasM",void 0),e([w({json:{read:{source:"layerDefinition.hasZ"}}})],Je.prototype,"hasZ",void 0),e([w(B)],Je.prototype,"id",void 0),e([w({readOnly:!0,json:{origins:{service:{read:!0}},read:!1}})],Je.prototype,"infoFor3D",void 0),e([w({json:{origins:{"web-map":{write:{target:"layerDefinition.type"}}}}})],Je.prototype,"isTable",void 0),e([v("service","isTable",["type","geometryType"]),v("isTable",["layerDefinition.type","layerDefinition.geometryType"])],Je.prototype,"readIsTable",null),e([S("web-map","isTable")],Je.prototype,"writeIsTable",null),e([w(H)],Je.prototype,"labelsVisible",void 0),e([w({type:[Ie],json:{origins:{service:{read:{source:"drawingInfo.labelingInfo",reader:Te},write:{target:"drawingInfo.labelingInfo",enabled:!1}}},read:{source:"layerDefinition.drawingInfo.labelingInfo",reader:Te},write:{target:"layerDefinition.drawingInfo.labelingInfo"}}})],Je.prototype,"labelingInfo",void 0),e([w((()=>{const e=u(Z);return e.json.origins["portal-item"]={write:{target:"layerDefinition.drawingInfo.transparency",writer(e,r,t){c(t,Oe(e),r)}}},e})())],Je.prototype,"opacity",void 0),e([w(k)],Je.prototype,"legendEnabled",void 0),e([w({type:["show","hide"],json:(()=>{const e=u(z.json);return e.origins["portal-item"]={read:!1,write:!1},e})()})],Je.prototype,"listMode",void 0),e([v("globalIdField",["layerDefinition.globalIdField","layerDefinition.fields"])],Je.prototype,"readGlobalIdField",null),e([w({json:{origins:{"web-map":{write:{target:"layerDefinition.objectIdField",overridePolicy:Ge}}}}})],Je.prototype,"objectIdField",void 0),e([v("objectIdField",["layerDefinition.objectIdField","layerDefinition.fields"])],Je.prototype,"readObjectIdField",null),e([w({value:"ArcGISFeatureLayer",type:["ArcGISFeatureLayer"]})],Je.prototype,"operationalLayerType",void 0),e([w(Ne.outFields)],Je.prototype,"outFields",void 0),e([w({readOnly:!0})],Je.prototype,"parsedUrl",null),e([w({type:String,json:{origins:{"web-scene":{read:!0,write:!0}},read:!1}})],Je.prototype,"path",void 0),e([w(K)],Je.prototype,"popupEnabled",void 0),e([w({type:r,json:{name:"popupInfo",write:!0}})],Je.prototype,"popupTemplate",void 0),e([w({readOnly:!0})],Je.prototype,"defaultPopupTemplate",null),e([w({types:i,json:{origins:{service:{write:{target:"drawingInfo.renderer",enabled:!1}},"web-scene":{types:o,name:"layerDefinition.drawingInfo.renderer",write:{overridePolicy:(e,r,t)=>({ignoreOrigin:t?.writeLayerSchema})}}},write:{target:"layerDefinition.drawingInfo.renderer",overridePolicy:(e,r,t)=>({ignoreOrigin:t?.writeLayerSchema})}}})],Je.prototype,"renderer",null),e([v("service","renderer",["drawingInfo.renderer","defaultSymbol"]),v("renderer",["layerDefinition.drawingInfo.renderer","layerDefinition.defaultSymbol"])],Je.prototype,"readRenderer",null),e([w((()=>{const e=u(X);return e.json.origins["portal-item"]={read:!1,write:!1},e})())],Je.prototype,"screenSizePerspectiveEnabled",void 0),e([w({clonable:!1})],Je.prototype,"source",null),e([j("source")],Je.prototype,"castSource",null),e([v("portal-item","source",["featureSet"]),v("web-map","source",["featureSet"])],Je.prototype,"readSource",null),e([w({json:{read:{source:"layerDefinition.extent.spatialReference"}}})],Je.prototype,"spatialReference",void 0),e([w({type:Number})],Je.prototype,"subtypeCode",void 0),e([w({type:[we]})],Je.prototype,"templates",void 0),e([v("templates",["editFieldsInfo","creatorField","editorField","templates"])],Je.prototype,"readTemplates",null),e([w({type:Ee})],Je.prototype,"timeInfo",void 0),e([w()],Je.prototype,"title",void 0),e([v("service","title",["name"]),v("portal-item","title",["layerDefinition.title","layerDefinition.name","title"])],Je.prototype,"readTitle",null),e([v("web-map","title",["layerDefinition.name","title"])],Je.prototype,"readTitleFromWebMap",null),e([w({type:String})],Je.prototype,"sublayerTitleMode",void 0),e([w({json:{read:!1}})],Je.prototype,"type",void 0),e([w({type:String})],Je.prototype,"typeIdField",void 0),e([v("service","typeIdField"),v("typeIdField",["layerDefinition.typeIdField"])],Je.prototype,"readTypeIdField",null),e([w({type:[je]})],Je.prototype,"types",void 0),e([v("service","types",["types"]),v("types",["layerDefinition.types"])],Je.prototype,"readTypes",null),e([w({type:Boolean,json:{origins:{"portal-item":{write:{target:"layerDefinition.defaultVisibility"}}}}})],Je.prototype,"visible",void 0),e([v("portal-item","visible",["visibility","layerDefinition.defaultVisibility"])],Je.prototype,"readVisible",null),Je=e([F(Ae)],Je);const $e=Je;export{$e as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import r from"../PopupTemplate.js";import"../renderers/ClassBreaksRenderer.js";import"../renderers/DictionaryRenderer.js";import"../renderers/DotDensityRenderer.js";import"../renderers/HeatmapRenderer.js";import"../renderers/PieChartRenderer.js";import"../renderers/Renderer.js";import"../renderers/SimpleRenderer.js";import"../renderers/UniqueValueRenderer.js";import{read as t}from"../renderers/support/jsonUtils.js";import{rendererTypes as i,webSceneRendererTypes as o}from"../renderers/support/types.js";import s from"../request.js";import{symbolTypes as a}from"../symbols.js";import{ClonableMixin as n}from"../core/Clonable.js";import l from"../core/Collection.js";import p from"../core/Error.js";import{clone as u}from"../core/lang.js";import d from"../core/Logger.js";import{MultiOriginJSONMixin as y}from"../core/MultiOriginJSONSupport.js";import{setDeepValue as c}from"../core/object.js";import{debounce as m,throwIfAbortError as f,whenOrAbort as h}from"../core/promiseUtils.js";import{sqlAnd as b}from"../core/sql.js";import{urlToObject as g,join as w}from"../core/urlUtils.js";import{property as v}from"../core/accessorSupport/decorators/property.js";import{cast as j}from"../core/accessorSupport/decorators/cast.js";import{reader as S}from"../core/accessorSupport/decorators/reader.js";import{subclass as F}from"../core/accessorSupport/decorators/subclass.js";import{writer as I}from"../core/accessorSupport/decorators/writer.js";import T from"../form/FormTemplate.js";import E from"../geometry/SpatialReference.js";import D from"./Layer.js";import{MemorySource as L}from"./graphics/sources/MemorySource.js";import{APIKeyMixin as _}from"./mixins/APIKeyMixin.js";import{ArcGISService as x}from"./mixins/ArcGISService.js";import{BlendLayer as P}from"./mixins/BlendLayer.js";import{CustomParametersMixin as M}from"./mixins/CustomParametersMixin.js";import{EditBusLayer as q}from"./mixins/EditBusLayer.js";import{FeatureEffectLayer as O}from"./mixins/FeatureEffectLayer.js";import{FeatureLayerBase as C}from"./mixins/FeatureLayerBase.js";import{FeatureReductionLayer as R}from"./mixins/FeatureReductionLayer.js";import{OperationalLayer as A}from"./mixins/OperationalLayer.js";import{OrderedLayer as U}from"./mixins/OrderedLayer.js";import{PortalLayer as V}from"./mixins/PortalLayer.js";import{PublishableLayer as Q}from"./mixins/PublishableLayer.js";import{RefreshableLayer as N}from"./mixins/RefreshableLayer.js";import{ScaleRangeLayer as G}from"./mixins/ScaleRangeLayer.js";import{TemporalLayer as J}from"./mixins/TemporalLayer.js";import{titleFromUrlAndName as $,parse as W,cleanTitle as B}from"./support/arcgisLayerUrl.js";import{id as H,labelsVisible as Z,opacityDrawingInfo as k,legendEnabled as z,listMode as K,popupEnabled as X,screenSizePerspectiveEnabled as Y}from"./support/commonProperties.js";import{ensureLayerCredential as ee,computeEffectiveEditingEnabled as re,readGlobalIdField as te,readObjectIdField as ie,createDefaultRenderer as oe,addAttachment as se,updateAttachment as ae,applyEdits as ne,uploadAssets as le,createQuery as pe,deleteAttachments as ue,fetchRecomputedExtents as de,queryAttachments as ye,queryObjectIds as ce,queryFeatureCount as me,queryExtent as fe,queryRelatedFeatures as he,queryRelatedFeaturesCount as be,hasDataChanged as ge,geometryTypeKebabDict as we}from"./support/featureLayerUtils.js";import ve from"./support/FeatureTemplate.js";import je from"./support/FeatureType.js";import{defineFieldProperties as Se}from"./support/fieldProperties.js";import{fixRendererFields as Fe,fixTimeInfoFields as Ie}from"./support/fieldUtils.js";import Te from"./support/LabelClass.js";import{reader as Ee}from"./support/labelingInfo.js";import{getFeatureLayerCapabilities as De}from"./support/serviceCapabilitiesUtils.js";import Le from"./support/TimeInfo.js";import{serviceSupportsSpatialReference as _e}from"./support/versionUtils.js";import{DataLayerSource as xe}from"./support/source/DataLayerSource.js";import{loadStyleRenderer as Pe}from"../renderers/support/styleUtils.js";import Me from"../rest/support/FeatureSet.js";import qe from"../rest/support/Query.js";import Oe from"../rest/support/TopFeaturesQuery.js";import{createPopupTemplate as Ce}from"../support/popupUtils.js";import{SaveOperationType as Re}from"../webdoc/interfaces.js";import{opacityToTransparency as Ae}from"../webdoc/support/opacityUtils.js";const Ue="FeatureLayer",Ve="esri.layers.FeatureLayer",Qe=d.getLogger(Ve);function Ne(e,r){return new p("layer:unsupported",`Layer (${e.title}, ${e.id}) of type '${e.declaredClass}' ${r}`,{layer:e})}function Ge(e){return e&&e instanceof l}const Je=Se();function $e(e,r,t){const i=!!t?.writeLayerSchema;return{enabled:i,ignoreOrigin:i}}let We=class extends(C(R(O(Q(q(P(U(J(G(N(x(A(V(y(M(_(n(D)))))))))))))))))){constructor(...e){super(...e),this.charts=null,this.copyright=null,this.displayField=null,this.dynamicDataSource=null,this.fields=null,this.fieldsIndex=null,this.formTemplate=null,this.fullExtent=null,this.geometryType=null,this.hasM=void 0,this.hasZ=void 0,this.infoFor3D=null,this.isTable=!1,this.labelsVisible=!0,this.labelingInfo=null,this.legendEnabled=!0,this.objectIdField=null,this.outFields=null,this.path=null,this.popupEnabled=!0,this.popupTemplate=null,this.screenSizePerspectiveEnabled=!0,this.spatialReference=E.WGS84,this.subtypeCode=null,this.templates=null,this.timeInfo=null,this.title=null,this.sublayerTitleMode="item-title",this.type="feature",this.typeIdField=null,this.types=null,this.visible=!0,this._debouncedSaveOperations=m((async(e,r,t)=>{const{save:i,saveAs:o}=await import("./save/featureLayerUtils.js");switch(e){case Re.SAVE:return i(this,r);case Re.SAVE_AS:return o(this,t,r)}}))}destroy(){this.source?.destroy()}normalizeCtorArgs(e,r){return"string"==typeof e?{url:e,...r}:e}load(e){const r=null!=e?e.signal:null;if(this.portalItem?.loaded&&this.source)return this.addResolvingPromise(this.createGraphicsSource(r).then((e=>this.initLayerProperties(e)))),Promise.resolve(this);const t=this.loadFromPortal({supportedTypes:["Feature Service","Feature Collection"]},e).catch(f).then((async()=>{if(this.url&&null==this.layerId&&/FeatureServer|MapServer\/*$/i.test(this.url)){const e=await this._fetchFirstLayerId(r);null!=e&&(this.layerId=e)}if(!this.url&&!this._hasMemorySource())throw new p("feature-layer:missing-url-or-source","Feature layer must be created with either a url or a source");return this.initLayerProperties(await this.createGraphicsSource(r))})).then((()=>ee(this,"load",e)));return this.addResolvingPromise(t),Promise.resolve(this)}readCapabilities(e,r){return r=r.layerDefinition||r,De(r,this.url)}get createQueryVersion(){return this.commitProperty("definitionExpression"),this.commitProperty("dynamicDataSource"),this.commitProperty("timeExtent"),this.commitProperty("timeOffset"),this.commitProperty("geometryType"),this.commitProperty("gdbVersion"),this.commitProperty("historicMoment"),this.commitProperty("returnZ"),this.commitProperty("capabilities"),this.commitProperty("returnM"),(this._get("createQueryVersion")??0)+1}get editingEnabled(){return!(this.loaded&&!this.capabilities?.operations.supportsEditing)&&(this._isOverridden("editingEnabled")?this._get("editingEnabled"):this._hasMemorySource()||this.userHasEditingPrivileges)}set editingEnabled(e){this._overrideIfSome("editingEnabled",e)}readEditingEnabled(e,r){return this._readEditingEnabled(r,!1)}readEditingEnabledFromWebMap(e,r,t){return this._readEditingEnabled(r,!0,t)}writeEditingEnabled(e,r){this._writeEditingEnabled(e,r,!1)}writeEditingEnabledToWebMap(e,r,t,i){this._writeEditingEnabled(e,r,!0,i)}get effectiveEditingEnabled(){return re(this)}readIsTable(e,r){return"Table"===(r=r?.layerDefinition??r).type||!r.geometryType}writeIsTable(e,r,t,i){i?.writeLayerSchema&&c(t,e?"Table":"Feature Layer",r)}readGlobalIdField(e,r){return te(r.layerDefinition||r)}readObjectIdField(e,r){return ie(r.layerDefinition||r)}get parsedUrl(){const e=g(this.url);return null!=e&&(null!=this.dynamicDataSource?e.path=w(e.path,"dynamicLayer"):null!=this.layerId&&(e.path=w(e.path,this.layerId.toString()))),e}get defaultPopupTemplate(){return this.createPopupTemplate()}set renderer(e){Fe(e,this.fieldsIndex),this._set("renderer",e)}readRenderer(e,r,i){r=r.layerDefinition||r;const o=r.drawingInfo?.renderer;if(o){const e=t(o,r,i)??void 0;return e||Qe.error("Failed to create renderer",{rendererDefinition:r.drawingInfo.renderer,layer:this,context:i}),e}return oe(r,i)}set source(e){const r=this._get("source");r!==e&&(Ge(r)&&this._resetMemorySource(r),Ge(e)&&this._initMemorySource(e),this._set("source",e))}castSource(e){return e?Array.isArray(e)||e instanceof l?new L({layer:this,items:e}):e:null}readSource(e,r){const t=Me.fromJSON(r.featureSet);return new L({layer:this,items:t?.features??[]})}readTemplates(e,r){const t=r.editFieldsInfo,i=t&&t.creatorField,o=t&&t.editorField;return e=e&&e.map((e=>ve.fromJSON(e))),this._fixTemplates(e,i),this._fixTemplates(e,o),e}readTitle(e,r){const t=r.layerDefinition?.name??r.name,i=r.title||r.layerDefinition&&r.layerDefinition.title;if(t){const e=this.portalItem&&this.portalItem.title;if("item-title"===this.sublayerTitleMode)return this.url?$(this.url,t):t;let r=t;if(!r&&this.url){const e=W(this.url);null!=e&&(r=e.title)}if(!r)return;return"item-title-and-service-name"===this.sublayerTitleMode&&e&&e!==r&&(r=e+" - "+r),B(r)}if("item-title"===this.sublayerTitleMode&&i)return i}readTitleFromWebMap(e,r){return r.title||r.layerDefinition&&r.layerDefinition.name}readTypeIdField(e,r){let t=(r=r.layerDefinition||r).typeIdField;if(t&&r.fields){t=t.toLowerCase();const e=r.fields.find((e=>e.name.toLowerCase()===t));e&&(t=e.name)}return t}readTypes(e,r){e=(r=r.layerDefinition||r).types;const t=r.editFieldsInfo,i=t&&t.creatorField,o=t&&t.editorField;return e&&e.map((e=>(e=je.fromJSON(e),this._fixTemplates(e.templates,i),this._fixTemplates(e.templates,o),e)))}readVisible(e,r){return r.layerDefinition&&null!=r.layerDefinition.defaultVisibility?!!r.layerDefinition.defaultVisibility:null!=r.visibility?!!r.visibility:void 0}async addAttachment(e,r){return se(this,e,r,Ue)}async updateAttachment(e,r,t){return ae(this,e,r,t,Ue)}async applyEdits(e,r){return ne(this,e,r)}async uploadAssets(e,r){return le(this,e,r)}on(e,r){return super.on(e,r)}createPopupTemplate(e){return Ce(this,e)}async createGraphicsSource(e){if(this._hasMemorySource()&&this.source)return this.source.load({signal:e});const{default:r}=await h(import("./graphics/sources/FeatureLayerSource.js"),e);return new r({layer:this}).load({signal:e})}createQuery(){const e=pe(this);e.dynamicDataSource=this.dynamicDataSource;const r=null!=this.subtypeCode?`${this.subtypeField} = ${this.subtypeCode}`:null,t=b(this.definitionExpression,r);return e.where=t||"1=1",e}async deleteAttachments(e,r){return ue(this,e,r,Ue)}async fetchRecomputedExtents(e){return de(this,e,Ue)}getFeatureType(e){const{typeIdField:r,types:t}=this;if(!r||!e)return null;const i=e.attributes?e.attributes[r]:void 0;if(null==i)return null;let o=null;return t?.some((e=>{const{id:r}=e;return null!=r&&(r.toString()===i.toString()&&(o=e),!!o)})),o}getFieldDomain(e,r){const t=r?.feature,i=this.getFeatureType(t);if(i){const r=i.domains&&i.domains[e];if(r&&"inherited"!==r.type)return r}return this._getLayerDomain(e)}getField(e){return this.fieldsIndex.get(e)}async queryAttachments(e,r){return ye(this,e,r,Ue)}async queryFeatures(e,r){const t=await this.load(),i=await t.source.queryFeatures(qe.from(e)??t.createQuery(),r);if(i?.features)for(const o of i.features)o.layer=o.sourceLayer=t;return i}async queryObjectIds(e,r){return ce(this,e,r,Ue)}async queryFeatureCount(e,r){return me(this,e,r,Ue)}async queryExtent(e,r){return fe(this,e,r,Ue)}async queryRelatedFeatures(e,r){return he(this,e,r,Ue)}async queryRelatedFeaturesCount(e,r){return be(this,e,r,Ue)}async queryTopFeatures(e,r){const{source:t,capabilities:i}=await this.load();if(!t.queryTopFeatures||!i?.query?.supportsTopFeaturesQuery)throw new p(Ue,"Layer source does not support queryTopFeatures capability");const o=await t.queryTopFeatures(Oe.from(e),r);if(o?.features)for(const s of o.features)s.layer=s.sourceLayer=this;return o}async queryTopObjectIds(e,r){const{source:t,capabilities:i}=await this.load();if(!t.queryTopObjectIds||!i?.query.supportsTopFeaturesQuery)throw new p(Ue,"Layer source does not support queryTopObjectIds capability");return t.queryTopObjectIds(Oe.from(e),r)}async queryTopFeaturesExtent(e,r){const{source:t,capabilities:i}=await this.load();if(!t.queryTopExtents||!i?.query?.supportsTopFeaturesQuery)throw new p(Ue,"Layer source does not support queryTopExtents capability");return t.queryTopExtents(Oe.from(e),r)}async queryTopFeatureCount(e,r){const{source:t,capabilities:i}=await this.load();if(!t.queryTopCount||!i?.query?.supportsTopFeaturesQuery)throw new p(Ue,"Layer source does not support queryFeatureCount capability");return t.queryTopCount(Oe.from(e),r)}read(e,r){const t=e.featureCollection;if(t){const e=t.layers;e&&1===e.length&&(super.read(e[0],r),null!=t.showLegend&&super.read({showLegend:t.showLegend},r))}super.read(e,r),r&&"service"===r.origin&&(this.revert(["objectIdField","fields","timeInfo"],"service"),this.spatialReference||this.revert(["spatialReference"],"service"))}write(e,r){r={...r,origin:r?.origin??void 0,writeLayerSchema:r?.writeLayerSchema??this._hasMemorySource()};const{origin:t,layerContainerType:i,messages:o}=r;if(this.dynamicDataSource)return o?.push(Ne(this,"using a dynamic data source cannot be written to web scenes, web maps and feature service items")),null;if(this.isTable){if("web-scene"===t||"web-map"===t&&"tables"!==i)return o?.push(Ne(this,"using a table source cannot be written to web scenes and web maps")),null;if(this._hasMemorySource())return o?.push(Ne(this,"using an in-memory table source cannot be written to web scenes and web maps")),null}else if(this.loaded&&"web-map"===t&&"tables"===i)return o?.push(Ne(this,"using a non-table source cannot be written to tables in web maps")),null;return super.write(e,r)}clone(){if(this._hasMemorySource())throw new p(Ue,`FeatureLayer (title: ${this.title}, id: ${this.id}) created using in-memory source cannot be cloned`);return super.clone()}serviceSupportsSpatialReference(e){return!!this.loaded&&("memory"===this.source?.type||_e(this,e))}async save(e){return this._debouncedSaveOperations(Re.SAVE,e)}async saveAs(e,r){return this._debouncedSaveOperations(Re.SAVE_AS,r,e)}_readEditingEnabled(e,r,t){let i=e.layerDefinition?.capabilities;return i?this._hasEditingCapability(i):(i=e.capabilities,r&&"web-map"===t?.origin&&!this._hasMemorySource()&&i?this._hasEditingCapability(i):void 0)}_hasEditingCapability(e){return e.toLowerCase().split(",").map((e=>e.trim())).includes("editing")}_writeEditingEnabled(e,r,t,i){if(!e){const e=this.capabilities?.operations?.supportsSync?"Query,Sync":"Query";c("layerDefinition.capabilities",e,r),t&&!i?.writeLayerSchema&&(r.capabilities=e)}}_getLayerDomain(e){const r=this.fieldsIndex.get(e);return r?r.domain:null}_fetchFirstLayerId(e){return s(this.url,{query:{f:"json",...this.customParameters,token:this.apiKey},responseType:"json",signal:e}).then((e=>{const r=e.data;if(r)return Array.isArray(r.layers)&&r.layers.length>0?r.layers[0].id:Array.isArray(r.tables)&&r.tables.length>0?r.tables[0].id:void 0}))}async initLayerProperties(e){return this._set("source",e),e.sourceJSON&&(this.sourceJSON=e.sourceJSON,this.read(e.sourceJSON,{origin:"service",portalItem:this.portalItem,portal:this.portalItem?.portal,url:this.parsedUrl})),this._verifySource(),this._verifyFields(),Fe(this.renderer,this.fieldsIndex),Ie(this.timeInfo,this.fieldsIndex),Pe(this,{origin:"service"})}async hasDataChanged(){return ge(this)}async fetchPublishingStatus(){const e=this.source;return e?.fetchPublishingStatus?e.fetchPublishingStatus():"unavailable"}_verifyFields(){const e=this.parsedUrl?.path??"undefined";this.objectIdField||console.log("FeatureLayer: 'objectIdField' property is not defined (url: "+e+")"),this.isTable||this._hasMemorySource()||-1!==e.search(/\/FeatureServer\//i)||this.fields?.some((e=>"geometry"===e.type))||console.log("FeatureLayer: unable to find field of type 'geometry' in the layer 'fields' list. If you are using a map service layer, features will not have geometry (url: "+e+")")}_fixTemplates(e,r){e&&e.forEach((e=>{const t=e.prototype&&e.prototype.attributes;t&&r&&delete t[r]}))}_verifySource(){if(this._hasMemorySource()){if(this.url)throw new p("feature-layer:mixed-source-and-url","FeatureLayer cannot be created with both an in-memory source and a url")}else if(!this.url)throw new p("feature-layer:source-or-url-required","FeatureLayer requires either a url, a valid portal item or a source")}_initMemorySource(e){e.forEach((e=>{e.layer=this,e.sourceLayer=this})),this.addHandles([e.on("after-add",(e=>{e.item.layer=this,e.item.sourceLayer=this})),e.on("after-remove",(e=>{e.item.layer=null,e.item.sourceLayer=null}))],"fl-source")}_resetMemorySource(e){e.forEach((e=>{e.layer=null,e.sourceLayer=null})),this.removeHandles("fl-source")}_hasMemorySource(){return!(this.url||!this.source)}};e([S("service","capabilities")],We.prototype,"readCapabilities",null),e([v({json:{origins:{"web-scene":{write:!1}},write:!0}})],We.prototype,"charts",void 0),e([v({readOnly:!0})],We.prototype,"createQueryVersion",null),e([v({json:{read:{source:"layerDefinition.copyrightText"}}})],We.prototype,"copyright",void 0),e([v({json:{read:{source:"layerDefinition.displayField"}}})],We.prototype,"displayField",void 0),e([v({types:a,readOnly:!0})],We.prototype,"defaultSymbol",void 0),e([v({type:xe})],We.prototype,"dynamicDataSource",void 0),e([v({type:Boolean})],We.prototype,"editingEnabled",null),e([S(["portal-item","web-scene"],"editingEnabled",["layerDefinition.capabilities"])],We.prototype,"readEditingEnabled",null),e([S("web-map","editingEnabled",["capabilities","layerDefinition.capabilities"])],We.prototype,"readEditingEnabledFromWebMap",null),e([I(["portal-item","web-scene"],"editingEnabled",{"layerDefinition.capabilities":{type:String}})],We.prototype,"writeEditingEnabled",null),e([I("web-map","editingEnabled",{capabilities:{type:String},"layerDefinition.capabilities":{type:String}})],We.prototype,"writeEditingEnabledToWebMap",null),e([v({readOnly:!0})],We.prototype,"effectiveEditingEnabled",null),e([v({...Je.fields,json:{read:{source:"layerDefinition.fields"},origins:{service:{name:"fields"},"web-map":{write:{target:"layerDefinition.fields",overridePolicy:$e}}}}})],We.prototype,"fields",void 0),e([v(Je.fieldsIndex)],We.prototype,"fieldsIndex",void 0),e([v({type:T,json:{name:"formInfo",write:!0,origins:{"web-scene":{read:!1,write:!1}}}})],We.prototype,"formTemplate",void 0),e([v({json:{read:{source:"layerDefinition.extent"}}})],We.prototype,"fullExtent",void 0),e([v({json:{origins:{"web-map":{write:{target:"layerDefinition.geometryType",overridePolicy:$e,writer(e,r,t){const i=e?we.toJSON(e):null;i&&c(t,i,r)}}}},read:{source:"layerDefinition.geometryType",reader:we.read}}})],We.prototype,"geometryType",void 0),e([v({json:{read:{source:"layerDefinition.hasM"}}})],We.prototype,"hasM",void 0),e([v({json:{read:{source:"layerDefinition.hasZ"}}})],We.prototype,"hasZ",void 0),e([v(H)],We.prototype,"id",void 0),e([v({readOnly:!0,json:{origins:{service:{read:!0}},read:!1}})],We.prototype,"infoFor3D",void 0),e([v({json:{origins:{"web-map":{write:{target:"layerDefinition.type"}}}}})],We.prototype,"isTable",void 0),e([S("service","isTable",["type","geometryType"]),S("isTable",["layerDefinition.type","layerDefinition.geometryType"])],We.prototype,"readIsTable",null),e([I("web-map","isTable")],We.prototype,"writeIsTable",null),e([v(Z)],We.prototype,"labelsVisible",void 0),e([v({type:[Te],json:{origins:{service:{read:{source:"drawingInfo.labelingInfo",reader:Ee},write:{target:"drawingInfo.labelingInfo",enabled:!1}}},read:{source:"layerDefinition.drawingInfo.labelingInfo",reader:Ee},write:{target:"layerDefinition.drawingInfo.labelingInfo"}}})],We.prototype,"labelingInfo",void 0),e([v((()=>{const e=u(k);return e.json.origins["portal-item"]={write:{target:"layerDefinition.drawingInfo.transparency",writer(e,r,t){c(t,Ae(e),r)}}},e})())],We.prototype,"opacity",void 0),e([v(z)],We.prototype,"legendEnabled",void 0),e([v({type:["show","hide"],json:(()=>{const e=u(K.json);return e.origins["portal-item"]={read:!1,write:!1},e})()})],We.prototype,"listMode",void 0),e([S("globalIdField",["layerDefinition.globalIdField","layerDefinition.fields"])],We.prototype,"readGlobalIdField",null),e([v({json:{origins:{"web-map":{write:{target:"layerDefinition.objectIdField",overridePolicy:$e}}}}})],We.prototype,"objectIdField",void 0),e([S("objectIdField",["layerDefinition.objectIdField","layerDefinition.fields"])],We.prototype,"readObjectIdField",null),e([v({value:"ArcGISFeatureLayer",type:["ArcGISFeatureLayer"]})],We.prototype,"operationalLayerType",void 0),e([v(Je.outFields)],We.prototype,"outFields",void 0),e([v({readOnly:!0})],We.prototype,"parsedUrl",null),e([v({type:String,json:{origins:{"web-scene":{read:!0,write:!0}},read:!1}})],We.prototype,"path",void 0),e([v(X)],We.prototype,"popupEnabled",void 0),e([v({type:r,json:{name:"popupInfo",write:!0}})],We.prototype,"popupTemplate",void 0),e([v({readOnly:!0})],We.prototype,"defaultPopupTemplate",null),e([v({types:i,json:{origins:{service:{write:{target:"drawingInfo.renderer",enabled:!1}},"web-scene":{types:o,name:"layerDefinition.drawingInfo.renderer",write:{overridePolicy:(e,r,t)=>({ignoreOrigin:t?.writeLayerSchema})}}},write:{target:"layerDefinition.drawingInfo.renderer",overridePolicy:(e,r,t)=>({ignoreOrigin:t?.writeLayerSchema})}}})],We.prototype,"renderer",null),e([S("service","renderer",["drawingInfo.renderer","defaultSymbol"]),S("renderer",["layerDefinition.drawingInfo.renderer","layerDefinition.defaultSymbol"])],We.prototype,"readRenderer",null),e([v((()=>{const e=u(Y);return e.json.origins["portal-item"]={read:!1,write:!1},e})())],We.prototype,"screenSizePerspectiveEnabled",void 0),e([v({clonable:!1})],We.prototype,"source",null),e([j("source")],We.prototype,"castSource",null),e([S("portal-item","source",["featureSet"]),S("web-map","source",["featureSet"])],We.prototype,"readSource",null),e([v({json:{read:{source:"layerDefinition.extent.spatialReference"}}})],We.prototype,"spatialReference",void 0),e([v({type:Number})],We.prototype,"subtypeCode",void 0),e([v({type:[ve]})],We.prototype,"templates",void 0),e([S("templates",["editFieldsInfo","creatorField","editorField","templates"])],We.prototype,"readTemplates",null),e([v({type:Le})],We.prototype,"timeInfo",void 0),e([v()],We.prototype,"title",void 0),e([S("service","title",["name"]),S("portal-item","title",["layerDefinition.title","layerDefinition.name","title"])],We.prototype,"readTitle",null),e([S("web-map","title",["layerDefinition.name","title"])],We.prototype,"readTitleFromWebMap",null),e([v({type:String})],We.prototype,"sublayerTitleMode",void 0),e([v({json:{read:!1}})],We.prototype,"type",void 0),e([v({type:String})],We.prototype,"typeIdField",void 0),e([S("service","typeIdField"),S("typeIdField",["layerDefinition.typeIdField"])],We.prototype,"readTypeIdField",null),e([v({type:[je]})],We.prototype,"types",void 0),e([S("service","types",["types"]),S("types",["layerDefinition.types"])],We.prototype,"readTypes",null),e([v({type:Boolean,json:{origins:{"portal-item":{write:{target:"layerDefinition.defaultVisibility"}}}}})],We.prototype,"visible",void 0),e([S("portal-item","visible",["visibility","layerDefinition.defaultVisibility"])],We.prototype,"readVisible",null),We=e([F(Ve)],We);const Be=We;export{Be 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.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import r from"../PopupTemplate.js";import{MultiOriginJSONMixin as t}from"../core/MultiOriginJSONSupport.js";import{throwIfAbortError as o}from"../core/promiseUtils.js";import{property as s}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as i}from"../core/accessorSupport/decorators/subclass.js";import{writer as a}from"../core/accessorSupport/decorators/writer.js";import p from"./Layer.js";import{ArcGISImageService as n}from"./mixins/ArcGISImageService.js";import{ArcGISService as m}from"./mixins/ArcGISService.js";import{BlendLayer as l}from"./mixins/BlendLayer.js";import{CustomParametersMixin as c}from"./mixins/CustomParametersMixin.js";import{OperationalLayer as y}from"./mixins/OperationalLayer.js";import{PortalLayer as u}from"./mixins/PortalLayer.js";import{RefreshableLayer as d}from"./mixins/RefreshableLayer.js";import{ScaleRangeLayer as f}from"./mixins/ScaleRangeLayer.js";import{TemporalLayer as h}from"./mixins/TemporalLayer.js";import{legendEnabled as v,popupEnabled as g}from"./support/commonProperties.js";import{serviceSupportsSpatialReference as S}from"./support/versionUtils.js";import{createPopupTemplate as j}from"../support/popupUtils.js";let I=class extends(l(h(f(y(u(n(d(c(m(t(p))))))))))){constructor(...e){super(...e),this.legendEnabled=!0,this.isReference=null,this.operationalLayerType="ArcGISImageServiceLayer",this.popupEnabled=!0,this.popupTemplate=null,this.type="imagery"}normalizeCtorArgs(e,r){return"string"==typeof e?{url:e,...r}:e}load(e){const r=null!=e?e.signal:null;return this.addResolvingPromise(this.loadFromPortal({supportedTypes:["Image Service"]},e).catch(o).then((()=>this._fetchService(r)))),Promise.resolve(this)}writeOperationalLayerType(e,r,t){const o="vector-field"===this.renderer?.type;r[t]=o?"ArcGISImageServiceVectorLayer":"ArcGISImageServiceLayer"}get defaultPopupTemplate(){return this.createPopupTemplate()}createPopupTemplate(e){const r=this.rasterFields,t=this.title,o=new Set;let s=!1,i=!1;this.capabilities&&(s=this.capabilities.operations.supportsQuery&&this.fields&&this.fields.length>0,i="esriImageServiceDataTypeVector-UV"===this.serviceDataType||"esriImageServiceDataTypeVector-MagDir"===this.serviceDataType);const a=new Set;s&&a.add("raster.itempixelvalue");for(const p of r){const e=p.name.toLowerCase();a.has(e)||e.includes("raster.servicepixelvalue.")||o.add(p.name)}return i&&o.add("raster.magnitude").add("raster.direction"),j({fields:r,title:t},{...e,visibleFieldNames:o})}queryFeatures(e,r){return this.queryRasters(e,r).then((e=>{if(e?.features)for(const r of e.features)r.layer=r.sourceLayer=this;return e}))}queryFeatureCount(e,r){return this.queryRasterCount(e,r)}redraw(){this.emit("redraw")}async save(e){const{save:r}=await import("./save/imageryUtils.js");return r(this,e)}async saveAs(e,r){const{saveAs:t}=await import("./save/imageryUtils.js");return t(this,e,r)}serviceSupportsSpatialReference(e){return S(this,e)}};e([s(v)],I.prototype,"legendEnabled",void 0),e([s({type:["show","hide"]})],I.prototype,"listMode",void 0),e([s({type:Boolean,json:{read:!1,write:{enabled:!0,overridePolicy:()=>({enabled:!1})}}})],I.prototype,"isReference",void 0),e([s({type:["ArcGISImageServiceLayer"],json:{origins:{"web-map":{type:["ArcGISImageServiceLayer","ArcGISImageServiceVectorLayer"],read:!1,write:{target:"layerType",ignoreOrigin:!0}}}}})],I.prototype,"operationalLayerType",void 0),e([a("web-map","operationalLayerType")],I.prototype,"writeOperationalLayerType",null),e([s(g)],I.prototype,"popupEnabled",void 0),e([s({type:r,json:{read:{source:"popupInfo"},write:{target:"popupInfo"}}})],I.prototype,"popupTemplate",void 0),e([s({readOnly:!0})],I.prototype,"defaultPopupTemplate",null),e([s({readOnly:!0,json:{read:!1}})],I.prototype,"type",void 0),I=e([i("esri.layers.ImageryLayer")],I);const L=I;export{L as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import r from"../PopupTemplate.js";import{ClonableMixin as t}from"../core/Clonable.js";import{MultiOriginJSONMixin as o}from"../core/MultiOriginJSONSupport.js";import{debounce as s,throwIfAbortError as i}from"../core/promiseUtils.js";import{property as a}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as p}from"../core/accessorSupport/decorators/subclass.js";import{writer as n}from"../core/accessorSupport/decorators/writer.js";import m from"./Layer.js";import{ArcGISImageService as c}from"./mixins/ArcGISImageService.js";import{ArcGISService as l}from"./mixins/ArcGISService.js";import{BlendLayer as u}from"./mixins/BlendLayer.js";import{CustomParametersMixin as y}from"./mixins/CustomParametersMixin.js";import{OperationalLayer as d}from"./mixins/OperationalLayer.js";import{PortalLayer as f}from"./mixins/PortalLayer.js";import{RefreshableLayer as h}from"./mixins/RefreshableLayer.js";import{ScaleRangeLayer as S}from"./mixins/ScaleRangeLayer.js";import{TemporalLayer as v}from"./mixins/TemporalLayer.js";import{legendEnabled as g,popupEnabled as j}from"./support/commonProperties.js";import{serviceSupportsSpatialReference as I}from"./support/versionUtils.js";import{createPopupTemplate as L}from"../support/popupUtils.js";import{SaveOperationType as T}from"../webdoc/interfaces.js";let b=class extends(u(v(S(d(f(c(h(y(l(o(t(m)))))))))))){constructor(...e){super(...e),this.legendEnabled=!0,this.isReference=null,this.operationalLayerType="ArcGISImageServiceLayer",this.popupEnabled=!0,this.popupTemplate=null,this.type="imagery",this._debouncedSaveOperations=s((async(e,r,t)=>{const{save:o,saveAs:s}=await import("./save/imageryUtils.js");switch(e){case T.SAVE:return o(this,r);case T.SAVE_AS:return s(this,t,r)}}))}normalizeCtorArgs(e,r){return"string"==typeof e?{url:e,...r}:e}load(e){const r=null!=e?e.signal:null;return this.addResolvingPromise(this.loadFromPortal({supportedTypes:["Image Service"]},e).catch(i).then((()=>this._fetchService(r)))),Promise.resolve(this)}writeOperationalLayerType(e,r,t){const o="vector-field"===this.renderer?.type;r[t]=o?"ArcGISImageServiceVectorLayer":"ArcGISImageServiceLayer"}get defaultPopupTemplate(){return this.createPopupTemplate()}createPopupTemplate(e){const r=this.rasterFields,t=this.title,o=new Set;let s=!1,i=!1;this.capabilities&&(s=this.capabilities.operations.supportsQuery&&this.fields&&this.fields.length>0,i="esriImageServiceDataTypeVector-UV"===this.serviceDataType||"esriImageServiceDataTypeVector-MagDir"===this.serviceDataType);const a=new Set;s&&a.add("raster.itempixelvalue");for(const p of r){const e=p.name.toLowerCase();a.has(e)||e.includes("raster.servicepixelvalue.")||o.add(p.name)}return i&&o.add("raster.magnitude").add("raster.direction"),L({fields:r,title:t},{...e,visibleFieldNames:o})}queryFeatures(e,r){return this.queryRasters(e,r).then((e=>{if(e?.features)for(const r of e.features)r.layer=r.sourceLayer=this;return e}))}queryFeatureCount(e,r){return this.queryRasterCount(e,r)}redraw(){this.emit("redraw")}async save(e){return this._debouncedSaveOperations(T.SAVE,e)}async saveAs(e,r){return this._debouncedSaveOperations(T.SAVE_AS,r,e)}serviceSupportsSpatialReference(e){return I(this,e)}};e([a(g)],b.prototype,"legendEnabled",void 0),e([a({type:["show","hide"]})],b.prototype,"listMode",void 0),e([a({type:Boolean,json:{read:!1,write:{enabled:!0,overridePolicy:()=>({enabled:!1})}}})],b.prototype,"isReference",void 0),e([a({type:["ArcGISImageServiceLayer"],json:{origins:{"web-map":{type:["ArcGISImageServiceLayer","ArcGISImageServiceVectorLayer"],read:!1,write:{target:"layerType",ignoreOrigin:!0}}}}})],b.prototype,"operationalLayerType",void 0),e([n("web-map","operationalLayerType")],b.prototype,"writeOperationalLayerType",null),e([a(j)],b.prototype,"popupEnabled",void 0),e([a({type:r,json:{read:{source:"popupInfo"},write:{target:"popupInfo"}}})],b.prototype,"popupTemplate",void 0),e([a({readOnly:!0})],b.prototype,"defaultPopupTemplate",null),e([a({readOnly:!0,json:{read:!1}})],b.prototype,"type",void 0),b=e([p("esri.layers.ImageryLayer")],b);const w=b;export{w as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import r from"../PopupTemplate.js";import t from"../core/Error.js";import s from"../core/Logger.js";import{MultiOriginJSONMixin as i}from"../core/MultiOriginJSONSupport.js";import{throwIfAbortError as o}from"../core/promiseUtils.js";import{watch as a}from"../core/reactiveUtils.js";import{property as n}from"../core/accessorSupport/decorators/property.js";import{ensureClass as l,Integer as p}from"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{enumeration as m}from"../core/accessorSupport/decorators/enumeration.js";import{subclass as u}from"../core/accessorSupport/decorators/subclass.js";import c from"./Layer.js";import{ArcGISService as d}from"./mixins/ArcGISService.js";import{BlendLayer as h}from"./mixins/BlendLayer.js";import{CustomParametersMixin as y}from"./mixins/CustomParametersMixin.js";import{ImageryTileMixin as f}from"./mixins/ImageryTileMixin.js";import{OperationalLayer as g}from"./mixins/OperationalLayer.js";import{PortalLayer as v}from"./mixins/PortalLayer.js";import{RefreshableLayer as j}from"./mixins/RefreshableLayer.js";import{ScaleRangeLayer as R}from"./mixins/ScaleRangeLayer.js";import{TemporalLayer as S}from"./mixins/TemporalLayer.js";import{legendEnabled as w}from"./support/commonProperties.js";import b from"./support/Field.js";import{interpolationKebab as I}from"./support/rasterEnums.js";import O from"./support/RasterFunction.js";import P from"./support/rasterDatasets/FunctionRaster.js";import T from"./support/rasterDatasets/RasterFactory.js";import{create as x,getPrimaryRasterUrls as N}from"./support/rasterFunctions/rasterFunctionHelper.js";import{createPopupTemplate as F}from"../support/popupUtils.js";let _=class extends(h(R(g(v(y(f(S(d(j(i(c))))))))))){constructor(...e){super(...e),this._primaryRasters=[],this.bandIds=null,this.interpolation=null,this.legendEnabled=!0,this.isReference=null,this.listMode="show",this.sourceJSON=null,this.version=null,this.type="imagery-tile",this.operationalLayerType="ArcGISTiledImageServiceLayer",this.popupEnabled=!0,this.popupTemplate=null,this.fields=null}normalizeCtorArgs(e,r){return"string"==typeof e?{url:e,...r}:e}load(e){const r=null!=e?e.signal:null;return this.addResolvingPromise(this.loadFromPortal({supportedTypes:["Image Service"]},e).catch(o).then((()=>this._openRaster(r)))),Promise.resolve(this)}get defaultPopupTemplate(){return this.createPopupTemplate()}get rasterFields(){const e=[new b({name:"Raster.ServicePixelValue",alias:"Pixel Value",domain:null,editable:!1,length:50,type:"string"}),new b({name:"Raster.ServicePixelValue.Raw",alias:"Raw Pixel Value",domain:null,editable:!1,length:50,type:"string"})],{rasterInfo:r}=this,t=r?.attributeTable,s=null!=t?t.fields:null,i="Raster.";if(s){const r=s.filter((e=>"oid"!==e.type&&"value"!==e.name.toLowerCase())).map((e=>{const r=e.clone();return r.name=i+e.name,r}));e.push(...r)}const o=r?.dataType,a=r?.multidimensionalInfo;if(("vector-magdir"===o||"vector-uv"===o)&&null!=a){const r=a.variables[0].unit?.trim(),t="Magnitude"+(r?` (${r})`:"");e.push(new b({name:"Raster.Magnitude",alias:t,domain:null,editable:!1,type:"double"})),e.push(new b({name:"Raster.Direction",alias:"Direction (°)",domain:null,editable:!1,type:"double"}))}return e}createPopupTemplate(e){const{rasterFields:r}=this,t=new Set(r.map((({name:e})=>e)).filter((e=>"raster.servicepixelvalue.raw"!==e.toLowerCase())));return F({fields:r,title:this.title},{...e,visibleFieldNames:t})}async generateRasterInfo(e,r){if(!(e=l(O,e)))return this.rasterInfo;try{const t={raster:this._primaryRasters[0]};this._primaryRasters.length>1&&this._primaryRasters.forEach((e=>t[e.url]=e));const s=x(e.functionDefinition?.toJSON()??e.toJSON(),t),i=new P({rasterFunction:s});return await i.open(r),i.rasterInfo}catch(s){if(s instanceof t)throw s;throw new t("imagery-tile-layer","the given raster function is not supported")}}async save(e){const{save:r}=await import("./save/imageryUtils.js");return r(this,e)}async saveAs(e,r){const{saveAs:t}=await import("./save/imageryUtils.js");return t(this,e,r)}write(e,r){const s=this._primaryRasters[0]??this.raster;if(this.loaded?"RasterTileServer"===s.datasetFormat&&("Raster"===s.tileType||"Map"===s.tileType):this.url&&/\/ImageServer(\/|\/?$)/i.test(this.url))return super.write(e,r);if(r&&r.messages){const e=`${r.origin}/${r.layerContainerType||"operational-layers"}`;r.messages.push(new t("layer:unsupported",`Layers (${this.title}, ${this.id}) of type '${this.declaredClass}' are not supported in the context of '${e}'`,{layer:this}))}return null}async _openRaster(e){let r=!1;if(this.raster)this.raster.rasterInfo||await this.raster.open(),"Function"===this.raster.datasetFormat?(r=!0,this._primaryRasters=this.raster.primaryRasters.rasters):this._primaryRasters=[this.raster],this.url=this.raster.url;else{const{rasterFunction:r}=this,i=[this.url];r&&N(r.toJSON(),i);const a=await Promise.all(i.map((r=>T.open({url:r,sourceJSON:this.sourceJSON,ioConfig:{sampling:"closest",...this.ioConfig,customFetchParameters:this.customParameters},signal:e})))),n=a.findIndex((e=>null==e));if(n>-1)throw new t("imagery-tile-layer:open",`cannot open raster: ${i[n]}`);if(this._primaryRasters=a,r){const e={raster:this._primaryRasters[0]};this._primaryRasters.length>1&&this._primaryRasters.forEach((r=>e[r.url]=r));const i=x(r.functionDefinition?.toJSON()??r.toJSON(),e),n=new P({rasterFunction:i});try{await n.open(),this.raster=n}catch(o){const e=s.getLogger(this);o instanceof t&&e.error("imagery-tile-layer:open",o.message),e.warn("imagery-tile-layer:open","the raster function cannot be applied and is removed"),this._set("rasterFunction",null),this.raster=a[0]}}else this.raster=a[0]}const i=this.raster.rasterInfo;if(!i)throw new t("imagery-tile-layer:load","cannot load resources on "+this.url);if(this._set("rasterInfo",r?i:this._primaryRasters[0].rasterInfo),this._set("spatialReference",i.spatialReference),this.sourceJSON=this.sourceJSON||this.raster.sourceJSON,null!=this.sourceJSON){const e="Map"===this.raster.tileType&&null!=this.sourceJSON.minLOD&&null!=this.sourceJSON.maxLOD?this.sourceJSON:{...this.sourceJSON,minScale:0,maxScale:0};this.read(e,{origin:"service"})}else this.read({tileInfo:this.rasterInfo.storageInfo.tileInfo.toJSON()},{origin:"service"});this.title||(this.title=this.raster.datasetName),"Map"===this.raster.tileType&&(this.popupEnabled=!1),this._configDefaultSettings(),this.addHandles(a((()=>this.customParameters),(e=>{this.raster&&(this.raster.ioConfig.customFetchParameters=e)})))}};e([n()],_.prototype,"_primaryRasters",void 0),e([n({type:[p],json:{write:{overridePolicy(){return{enabled:!this.loaded||"Raster"===this.raster.tileType||"0,1,2"!==this.bandIds?.join(",")}}}}})],_.prototype,"bandIds",void 0),e([n({json:{write:{overridePolicy(){return{enabled:!this.loaded||"Raster"===this.raster.tileType||"bilinear"!==this.interpolation}}}}}),m(I)],_.prototype,"interpolation",void 0),e([n(w)],_.prototype,"legendEnabled",void 0),e([n({type:Boolean,json:{read:!1,write:{enabled:!0,overridePolicy:()=>({enabled:!1})}}})],_.prototype,"isReference",void 0),e([n({type:["show","hide"]})],_.prototype,"listMode",void 0),e([n({json:{read:!0,write:!0}})],_.prototype,"blendMode",void 0),e([n()],_.prototype,"sourceJSON",void 0),e([n({readOnly:!0,json:{origins:{service:{read:{source:"currentVersion"}}}}})],_.prototype,"version",void 0),e([n({readOnly:!0,json:{read:!1}})],_.prototype,"type",void 0),e([n({type:["ArcGISTiledImageServiceLayer"]})],_.prototype,"operationalLayerType",void 0),e([n({type:Boolean,value:!0,json:{read:{source:"disablePopup",reader:(e,r)=>!r.disablePopup},write:{target:"disablePopup",overridePolicy(){return{enabled:!this.loaded||"Raster"===this.raster.tileType}},writer(e,r,t){r[t]=!e}}}})],_.prototype,"popupEnabled",void 0),e([n({type:r,json:{read:{source:"popupInfo"},write:{target:"popupInfo",overridePolicy(){return{enabled:!this.loaded||"Raster"===this.raster.tileType}}}}})],_.prototype,"popupTemplate",void 0),e([n({readOnly:!0})],_.prototype,"defaultPopupTemplate",null),e([n({readOnly:!0,type:[b]})],_.prototype,"fields",void 0),e([n({readOnly:!0,type:[b]})],_.prototype,"rasterFields",null),_=e([u("esri.layers.ImageryTileLayer")],_);const J=_;export{J as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import r from"../PopupTemplate.js";import{ClonableMixin as t}from"../core/Clonable.js";import s from"../core/Error.js";import i from"../core/Logger.js";import{MultiOriginJSONMixin as o}from"../core/MultiOriginJSONSupport.js";import{debounce as a,throwIfAbortError as n}from"../core/promiseUtils.js";import{watch as l}from"../core/reactiveUtils.js";import{property as p}from"../core/accessorSupport/decorators/property.js";import{ensureClass as m,Integer as u}from"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{enumeration as c}from"../core/accessorSupport/decorators/enumeration.js";import{subclass as d}from"../core/accessorSupport/decorators/subclass.js";import h from"./Layer.js";import{ArcGISService as y}from"./mixins/ArcGISService.js";import{BlendLayer as f}from"./mixins/BlendLayer.js";import{CustomParametersMixin as g}from"./mixins/CustomParametersMixin.js";import{ImageryTileMixin as v}from"./mixins/ImageryTileMixin.js";import{OperationalLayer as S}from"./mixins/OperationalLayer.js";import{PortalLayer as j}from"./mixins/PortalLayer.js";import{RefreshableLayer as R}from"./mixins/RefreshableLayer.js";import{ScaleRangeLayer as b}from"./mixins/ScaleRangeLayer.js";import{TemporalLayer as w}from"./mixins/TemporalLayer.js";import{legendEnabled as O}from"./support/commonProperties.js";import I from"./support/Field.js";import{interpolationKebab as P}from"./support/rasterEnums.js";import T from"./support/RasterFunction.js";import _ from"./support/rasterDatasets/FunctionRaster.js";import x from"./support/rasterDatasets/RasterFactory.js";import{create as N,getPrimaryRasterUrls as F}from"./support/rasterFunctions/rasterFunctionHelper.js";import{createPopupTemplate as J}from"../support/popupUtils.js";import{SaveOperationType as L}from"../webdoc/interfaces.js";let E=class extends(f(b(S(j(g(v(w(y(R(o(t(h)))))))))))){constructor(...e){super(...e),this._primaryRasters=[],this.bandIds=null,this.interpolation=null,this.legendEnabled=!0,this.isReference=null,this.listMode="show",this.sourceJSON=null,this.version=null,this.type="imagery-tile",this.operationalLayerType="ArcGISTiledImageServiceLayer",this.popupEnabled=!0,this.popupTemplate=null,this.fields=null,this._debouncedSaveOperations=a((async(e,r,t)=>{const{save:s,saveAs:i}=await import("./save/imageryUtils.js");switch(e){case L.SAVE:return s(this,r);case L.SAVE_AS:return i(this,t,r)}}))}normalizeCtorArgs(e,r){return"string"==typeof e?{url:e,...r}:e}load(e){const r=null!=e?e.signal:null;return this.addResolvingPromise(this.loadFromPortal({supportedTypes:["Image Service"]},e).catch(n).then((()=>this._openRaster(r)))),Promise.resolve(this)}get defaultPopupTemplate(){return this.createPopupTemplate()}get rasterFields(){const e=[new I({name:"Raster.ServicePixelValue",alias:"Pixel Value",domain:null,editable:!1,length:50,type:"string"}),new I({name:"Raster.ServicePixelValue.Raw",alias:"Raw Pixel Value",domain:null,editable:!1,length:50,type:"string"})],{rasterInfo:r}=this,t=r?.attributeTable,s=null!=t?t.fields:null,i="Raster.";if(s){const r=s.filter((e=>"oid"!==e.type&&"value"!==e.name.toLowerCase())).map((e=>{const r=e.clone();return r.name=i+e.name,r}));e.push(...r)}const o=r?.dataType,a=r?.multidimensionalInfo;if(("vector-magdir"===o||"vector-uv"===o)&&null!=a){const r=a.variables[0].unit?.trim(),t="Magnitude"+(r?` (${r})`:"");e.push(new I({name:"Raster.Magnitude",alias:t,domain:null,editable:!1,type:"double"})),e.push(new I({name:"Raster.Direction",alias:"Direction (°)",domain:null,editable:!1,type:"double"}))}return e}createPopupTemplate(e){const{rasterFields:r}=this,t=new Set(r.map((({name:e})=>e)).filter((e=>"raster.servicepixelvalue.raw"!==e.toLowerCase())));return J({fields:r,title:this.title},{...e,visibleFieldNames:t})}async generateRasterInfo(e,r){if(!(e=m(T,e)))return this.rasterInfo;try{const t={raster:this._primaryRasters[0]};this._primaryRasters.length>1&&this._primaryRasters.forEach((e=>t[e.url]=e));const s=N(e.functionDefinition?.toJSON()??e.toJSON(),t),i=new _({rasterFunction:s});return await i.open(r),i.rasterInfo}catch(t){if(t instanceof s)throw t;throw new s("imagery-tile-layer","the given raster function is not supported")}}async save(e){return this._debouncedSaveOperations(L.SAVE,e)}async saveAs(e,r){return this._debouncedSaveOperations(L.SAVE_AS,r,e)}write(e,r){const t=this._primaryRasters[0]??this.raster;if(this.loaded?"RasterTileServer"===t.datasetFormat&&("Raster"===t.tileType||"Map"===t.tileType):this.url&&/\/ImageServer(\/|\/?$)/i.test(this.url))return super.write(e,r);if(r&&r.messages){const e=`${r.origin}/${r.layerContainerType||"operational-layers"}`;r.messages.push(new s("layer:unsupported",`Layers (${this.title}, ${this.id}) of type '${this.declaredClass}' are not supported in the context of '${e}'`,{layer:this}))}return null}async _openRaster(e){let r=!1;if(this.raster)this.raster.rasterInfo||await this.raster.open(),"Function"===this.raster.datasetFormat?(r=!0,this._primaryRasters=this.raster.primaryRasters.rasters):this._primaryRasters=[this.raster],this.url=this.raster.url;else{const{rasterFunction:r}=this,t=[this.url];r&&F(r.toJSON(),t);const a=await Promise.all(t.map((r=>x.open({url:r,sourceJSON:this.sourceJSON,ioConfig:{sampling:"closest",...this.ioConfig,customFetchParameters:this.customParameters},signal:e})))),n=a.findIndex((e=>null==e));if(n>-1)throw new s("imagery-tile-layer:open",`cannot open raster: ${t[n]}`);if(this._primaryRasters=a,r){const e={raster:this._primaryRasters[0]};this._primaryRasters.length>1&&this._primaryRasters.forEach((r=>e[r.url]=r));const t=N(r.functionDefinition?.toJSON()??r.toJSON(),e),n=new _({rasterFunction:t});try{await n.open(),this.raster=n}catch(o){const e=i.getLogger(this);o instanceof s&&e.error("imagery-tile-layer:open",o.message),e.warn("imagery-tile-layer:open","the raster function cannot be applied and is removed"),this._set("rasterFunction",null),this.raster=a[0]}}else this.raster=a[0]}const t=this.raster.rasterInfo;if(!t)throw new s("imagery-tile-layer:load","cannot load resources on "+this.url);if(this._set("rasterInfo",r?t:this._primaryRasters[0].rasterInfo),this._set("spatialReference",t.spatialReference),this.sourceJSON=this.sourceJSON||this.raster.sourceJSON,null!=this.sourceJSON){const e="Map"===this.raster.tileType&&null!=this.sourceJSON.minLOD&&null!=this.sourceJSON.maxLOD?this.sourceJSON:{...this.sourceJSON,minScale:0,maxScale:0};this.read(e,{origin:"service"})}else this.read({tileInfo:this.rasterInfo.storageInfo.tileInfo.toJSON()},{origin:"service"});this.title||(this.title=this.raster.datasetName),"Map"===this.raster.tileType&&(this.popupEnabled=!1),this._configDefaultSettings(),this.addHandles(l((()=>this.customParameters),(e=>{this.raster&&(this.raster.ioConfig.customFetchParameters=e)})))}};e([p({clonable:!1})],E.prototype,"_primaryRasters",void 0),e([p({type:[u],json:{write:{overridePolicy(){return{enabled:!this.loaded||"Raster"===this.raster.tileType||"0,1,2"!==this.bandIds?.join(",")}}}}})],E.prototype,"bandIds",void 0),e([p({json:{write:{overridePolicy(){return{enabled:!this.loaded||"Raster"===this.raster.tileType||"bilinear"!==this.interpolation}}}}}),c(P)],E.prototype,"interpolation",void 0),e([p(O)],E.prototype,"legendEnabled",void 0),e([p({type:Boolean,json:{read:!1,write:{enabled:!0,overridePolicy:()=>({enabled:!1})}}})],E.prototype,"isReference",void 0),e([p({type:["show","hide"]})],E.prototype,"listMode",void 0),e([p({json:{read:!0,write:!0}})],E.prototype,"blendMode",void 0),e([p()],E.prototype,"sourceJSON",void 0),e([p({readOnly:!0,json:{origins:{service:{read:{source:"currentVersion"}}}}})],E.prototype,"version",void 0),e([p({readOnly:!0,json:{read:!1}})],E.prototype,"type",void 0),e([p({type:["ArcGISTiledImageServiceLayer"]})],E.prototype,"operationalLayerType",void 0),e([p({type:Boolean,value:!0,json:{read:{source:"disablePopup",reader:(e,r)=>!r.disablePopup},write:{target:"disablePopup",overridePolicy(){return{enabled:!this.loaded||"Raster"===this.raster.tileType}},writer(e,r,t){r[t]=!e}}}})],E.prototype,"popupEnabled",void 0),e([p({type:r,json:{read:{source:"popupInfo"},write:{target:"popupInfo",overridePolicy(){return{enabled:!this.loaded||"Raster"===this.raster.tileType}}}}})],E.prototype,"popupTemplate",void 0),e([p({readOnly:!0})],E.prototype,"defaultPopupTemplate",null),e([p({readOnly:!0,type:[I]})],E.prototype,"fields",void 0),e([p({readOnly:!0,type:[I]})],E.prototype,"rasterFields",null),E=e([d("esri.layers.ImageryTileLayer")],E);const A=E;export{A 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.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import"../geometry.js";import t from"../PopupTemplate.js";import"../renderers/ClassBreaksRenderer.js";import"../renderers/DictionaryRenderer.js";import"../renderers/DotDensityRenderer.js";import"../renderers/HeatmapRenderer.js";import"../renderers/PieChartRenderer.js";import"../renderers/Renderer.js";import"../renderers/SimpleRenderer.js";import"../renderers/UniqueValueRenderer.js";import{read as r}from"../renderers/support/jsonUtils.js";import{rendererTypes as i,webSceneRendererTypes as o}from"../renderers/support/types.js";import s from"../request.js";import{ClonableMixin as n}from"../core/Clonable.js";import a from"../core/Error.js";import{handlesGroup as p}from"../core/handleUtils.js";import{clone as l}from"../core/lang.js";import m from"../core/Logger.js";import{MultiOriginJSONMixin as d}from"../core/MultiOriginJSONSupport.js";import{throwIfAbortError as c}from"../core/promiseUtils.js";import{property as u}from"../core/accessorSupport/decorators/property.js";import{Integer as y}from"../core/accessorSupport/ensureType.js";import{reader as f}from"../core/accessorSupport/decorators/reader.js";import{subclass as h}from"../core/accessorSupport/decorators/subclass.js";import{featureGeometryTypeKebabDictionary as g}from"../geometry/support/typeUtils.js";import j from"./Layer.js";import{ArcGISService as v}from"./mixins/ArcGISService.js";import{BlendLayer as w}from"./mixins/BlendLayer.js";import{CustomParametersMixin as b}from"./mixins/CustomParametersMixin.js";import{FeatureEffectLayer as S}from"./mixins/FeatureEffectLayer.js";import{FeatureReductionLayer as I}from"./mixins/FeatureReductionLayer.js";import{OperationalLayer as x}from"./mixins/OperationalLayer.js";import{PortalLayer as R}from"./mixins/PortalLayer.js";import{RefreshableLayer as T}from"./mixins/RefreshableLayer.js";import{ScaleRangeLayer as P}from"./mixins/ScaleRangeLayer.js";import{TemporalLayer as F}from"./mixins/TemporalLayer.js";import{labelsVisible as L,legendEnabled as U,maxScale as k,minScale as D,popupEnabled as E,screenSizePerspectiveEnabled as C,url as O}from"./support/commonProperties.js";import{createDefaultRenderer as A}from"./support/featureLayerUtils.js";import _ from"./support/Field.js";import{defineFieldProperties as N}from"./support/fieldProperties.js";import{fixRendererFields as G,fixTimeInfoFields as J}from"./support/fieldUtils.js";import M from"./support/LabelClass.js";import{reader as V}from"./support/labelingInfo.js";import q from"./support/PurgeOptions.js";import{loadStyleRenderer as z}from"../renderers/support/styleUtils.js";import $ from"../rest/support/Query.js";import{createPopupTemplate as W}from"../support/popupUtils.js";import B from"../symbols/support/ElevationInfo.js";import Q from"../geometry/SpatialReference.js";import H from"../geometry/Extent.js";const K=N();function X(e,t){return new a("layer:unsupported",`Layer (${e.title}, ${e.id}) of type '${e.declaredClass}' ${t}`,{layer:e})}let Y=class extends(I(S(w(F(P(T(v(x(R(d(b(n(j))))))))))))){constructor(...e){super(...e),this.copyright=null,this.definitionExpression=null,this.displayField=null,this.elevationInfo=null,this.fields=null,this.fieldsIndex=null,this.geometryDefinition=null,this.geometryType=null,this.labelsVisible=!0,this.labelingInfo=null,this.legendEnabled=!0,this.maxReconnectionAttempts=0,this.maxReconnectionInterval=20,this.maxScale=0,this.minScale=0,this.objectIdField=null,this.operationalLayerType="ArcGISStreamLayer",this.popupEnabled=!0,this.popupTemplate=null,this.purgeOptions=new q,this.refreshInterval=0,this.screenSizePerspectiveEnabled=!0,this.sourceJSON=null,this.spatialReference=Q.WGS84,this.type="stream",this.url=null,this.updateInterval=300,this.useViewTime=!0,this.webSocketUrl=null}normalizeCtorArgs(e,t){return"string"==typeof e?{url:e,...t}:e}load(e){if(!("WebSocket"in globalThis))return this.addResolvingPromise(Promise.reject(new a("stream-layer:websocket-unsupported","WebSocket is not supported in this browser. StreamLayer will not have real-time connection with the stream service."))),Promise.resolve(this);const t=null!=e?e.signal:null;return this.addResolvingPromise(this.loadFromPortal({supportedTypes:["Stream Service","Feed"]},e).catch(c).then((()=>this._fetchService(t)))),Promise.resolve(this)}get defaultPopupTemplate(){return this.createPopupTemplate()}set featureReduction(e){const t=this._normalizeFeatureReduction(e);this._set("featureReduction",t)}set renderer(e){G(e,this.fieldsIndex),this._set("renderer",e)}readRenderer(e,t,i){t=t.layerDefinition||t;const o=t.drawingInfo?.renderer;if(o){const e=r(o,t,i)||void 0;return e||m.getLogger(this).error("Failed to create renderer",{rendererDefinition:t.drawingInfo.renderer,layer:this,context:i}),e}return A(t,i)}async connect(e){const[{createConnection:t}]=await Promise.all([import("./graphics/sources/connections/createConnection.js"),this.load()]),r=this.geometryType?g.toJSON(this.geometryType):null,{customParameters:i=null,definitionExpression:o=null,geometryDefinition:s=null,maxReconnectionAttempts:n=0,maxReconnectionInterval:a=20,spatialReference:l=this.spatialReference}=e||this.createConnectionParameters(),m=t(this.parsedUrl,this.spatialReference,l,r,{geometry:s,where:o},n,a,i??void 0),d=p([this.on("send-message-to-socket",(e=>m.sendMessageToSocket(e))),this.on("send-message-to-client",(e=>m.sendMessageToClient(e)))]);return m.once("destroy",d.remove),m}createConnectionParameters(){return{spatialReference:this.spatialReference,customParameters:this.customParameters,definitionExpression:this.definitionExpression,geometryDefinition:this.geometryDefinition,maxReconnectionAttempts:this.maxReconnectionAttempts,maxReconnectionInterval:this.maxReconnectionInterval}}createPopupTemplate(e){return W(this,e)}createQuery(){const e=new $;return e.returnGeometry=!0,e.outFields=["*"],e.where=this.definitionExpression||"1=1",e}getFieldDomain(e,t){if(!this.fields)return null;let r=null;return this.fields.some((t=>(t.name===e&&(r=t.domain),!!r))),r}getField(e){return this.fieldsIndex.get(e)}serviceSupportsSpatialReference(e){return!0}sendMessageToSocket(e){this.emit("send-message-to-socket",e)}sendMessageToClient(e){this.emit("send-message-to-client",e)}async save(e){const{save:t}=await import("./save/streamLayerUtils.js");return t(this,e)}async saveAs(e,t){const{saveAs:r}=await import("./save/streamLayerUtils.js");return r(this,e,t)}write(e,t){const r=t?.messages;return this.webSocketUrl?(r?.push(X(this,"using a custom websocket connection cannot be written to web scenes and web maps")),null):this.parsedUrl?super.write(e,t):(r?.push(X(this,"using a client-side only connection without a url cannot be written to web scenes and web maps")),null)}async _fetchService(e){if(!!!this.webSocketUrl&&this.parsedUrl){if(!this.sourceJSON){const{data:t}=await s(this.parsedUrl.path,{query:{f:"json",...this.customParameters,...this.parsedUrl.query},responseType:"json",signal:e});this.sourceJSON=t}}else{if(!this.timeInfo?.trackIdField)throw new a("stream-layer:missing-metadata","The stream layer trackIdField must be specified.");if(!this.objectIdField){const e=this.fields.find((e=>"oid"===e.type))?.name;if(!e)throw new a("stream-layer:missing-metadata","The stream layer objectIdField must be specified.");this.objectIdField=e}if(!this.fields)throw new a("stream-layer:missing-metadata","The stream layer fields must be specified.");if(this.fields.some((e=>e.name===this.objectIdField))||this.fields.push(new _({name:this.objectIdField,alias:this.objectIdField,type:"oid"})),!this.geometryType)throw new a("stream-layer:missing-metadata","The stream layer geometryType must be specified.");this.webSocketUrl&&(this.url=this.webSocketUrl)}return this.read(this.sourceJSON,{origin:"service",portalItem:this.portalItem,portal:this.portalItem?.portal,url:this.parsedUrl}),G(this.renderer,this.fieldsIndex),J(this.timeInfo,this.fieldsIndex),this.objectIdField||(this.objectIdField="__esri_stream_id__"),z(this,{origin:"service"})}};e([u({type:String})],Y.prototype,"copyright",void 0),e([u({readOnly:!0})],Y.prototype,"defaultPopupTemplate",null),e([u({type:String,json:{name:"layerDefinition.definitionExpression",write:{enabled:!0,allowNull:!0}}})],Y.prototype,"definitionExpression",void 0),e([u({type:String})],Y.prototype,"displayField",void 0),e([u({type:B})],Y.prototype,"elevationInfo",void 0),e([u({json:{origins:{"web-map":{read:!1,write:!1},"portal-item":{read:!1,write:!1},"web-scene":{read:!1,write:!1}}}})],Y.prototype,"featureReduction",null),e([u(K.fields)],Y.prototype,"fields",void 0),e([u(K.fieldsIndex)],Y.prototype,"fieldsIndex",void 0),e([u({type:H,json:{name:"layerDefinition.definitionGeometry",write:!0}})],Y.prototype,"geometryDefinition",void 0),e([u({type:g.apiValues,json:{read:{reader:g.read}}})],Y.prototype,"geometryType",void 0),e([u(L)],Y.prototype,"labelsVisible",void 0),e([u({type:[M],json:{name:"layerDefinition.drawingInfo.labelingInfo",read:{reader:V},write:!0}})],Y.prototype,"labelingInfo",void 0),e([u(U)],Y.prototype,"legendEnabled",void 0),e([u({type:["show","hide"],json:{origins:{"portal-item":{read:!1,write:!1}}}})],Y.prototype,"listMode",void 0),e([u({type:y})],Y.prototype,"maxReconnectionAttempts",void 0),e([u({type:y})],Y.prototype,"maxReconnectionInterval",void 0),e([u(k)],Y.prototype,"maxScale",void 0),e([u(D)],Y.prototype,"minScale",void 0),e([u({type:String})],Y.prototype,"objectIdField",void 0),e([u({value:"ArcGISStreamLayer",type:["ArcGISStreamLayer"]})],Y.prototype,"operationalLayerType",void 0),e([u(E)],Y.prototype,"popupEnabled",void 0),e([u({type:t,json:{name:"popupInfo",write:!0}})],Y.prototype,"popupTemplate",void 0),e([u({type:q})],Y.prototype,"purgeOptions",void 0),e([u({json:{read:!1,write:!1}})],Y.prototype,"refreshInterval",void 0),e([u({types:i,json:{origins:{service:{write:{target:"drawingInfo.renderer",enabled:!1}},"web-scene":{name:"layerDefinition.drawingInfo.renderer",types:o,write:!0}},write:{target:"layerDefinition.drawingInfo.renderer"}}})],Y.prototype,"renderer",null),e([f("service","renderer",["drawingInfo.renderer","defaultSymbol"]),f("renderer",["layerDefinition.drawingInfo.renderer","layerDefinition.defaultSymbol"])],Y.prototype,"readRenderer",null),e([u((()=>{const e=l(C);return e.json.origins["portal-item"]={read:!1,write:!1},e})())],Y.prototype,"screenSizePerspectiveEnabled",void 0),e([u()],Y.prototype,"sourceJSON",void 0),e([u({type:Q,json:{origins:{service:{read:{source:"spatialReference"}}}}})],Y.prototype,"spatialReference",void 0),e([u({json:{read:!1}})],Y.prototype,"type",void 0),e([u(O)],Y.prototype,"url",void 0),e([u({type:Number})],Y.prototype,"updateInterval",void 0),e([u({json:{read:!1,write:!1}})],Y.prototype,"useViewTime",void 0),e([u({type:String})],Y.prototype,"webSocketUrl",void 0),Y=e([h("esri.layers.StreamLayer")],Y);const Z=Y;export{Z as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import"../geometry.js";import t from"../PopupTemplate.js";import"../renderers/ClassBreaksRenderer.js";import"../renderers/DictionaryRenderer.js";import"../renderers/DotDensityRenderer.js";import"../renderers/HeatmapRenderer.js";import"../renderers/PieChartRenderer.js";import"../renderers/Renderer.js";import"../renderers/SimpleRenderer.js";import"../renderers/UniqueValueRenderer.js";import{read as r}from"../renderers/support/jsonUtils.js";import{rendererTypes as i,webSceneRendererTypes as o}from"../renderers/support/types.js";import s from"../request.js";import{ClonableMixin as n}from"../core/Clonable.js";import a from"../core/Error.js";import{handlesGroup as p}from"../core/handleUtils.js";import{clone as l}from"../core/lang.js";import m from"../core/Logger.js";import{MultiOriginJSONMixin as d}from"../core/MultiOriginJSONSupport.js";import{debounce as c,throwIfAbortError as u}from"../core/promiseUtils.js";import{property as y}from"../core/accessorSupport/decorators/property.js";import{Integer as f}from"../core/accessorSupport/ensureType.js";import{reader as h}from"../core/accessorSupport/decorators/reader.js";import{subclass as g}from"../core/accessorSupport/decorators/subclass.js";import{featureGeometryTypeKebabDictionary as j}from"../geometry/support/typeUtils.js";import v from"./Layer.js";import{ArcGISService as w}from"./mixins/ArcGISService.js";import{BlendLayer as b}from"./mixins/BlendLayer.js";import{CustomParametersMixin as S}from"./mixins/CustomParametersMixin.js";import{FeatureEffectLayer as I}from"./mixins/FeatureEffectLayer.js";import{FeatureReductionLayer as x}from"./mixins/FeatureReductionLayer.js";import{OperationalLayer as R}from"./mixins/OperationalLayer.js";import{PortalLayer as T}from"./mixins/PortalLayer.js";import{RefreshableLayer as P}from"./mixins/RefreshableLayer.js";import{ScaleRangeLayer as F}from"./mixins/ScaleRangeLayer.js";import{TemporalLayer as L}from"./mixins/TemporalLayer.js";import{labelsVisible as U,legendEnabled as E,maxScale as k,minScale as A,popupEnabled as D,screenSizePerspectiveEnabled as _,url as O}from"./support/commonProperties.js";import{createDefaultRenderer as C}from"./support/featureLayerUtils.js";import V from"./support/Field.js";import{defineFieldProperties as N}from"./support/fieldProperties.js";import{fixRendererFields as G,fixTimeInfoFields as J}from"./support/fieldUtils.js";import M from"./support/LabelClass.js";import{reader as q}from"./support/labelingInfo.js";import z from"./support/PurgeOptions.js";import{loadStyleRenderer as $}from"../renderers/support/styleUtils.js";import W from"../rest/support/Query.js";import{createPopupTemplate as B}from"../support/popupUtils.js";import Q from"../symbols/support/ElevationInfo.js";import{SaveOperationType as H}from"../webdoc/interfaces.js";import K from"../geometry/SpatialReference.js";import X from"../geometry/Extent.js";const Y=N();function Z(e,t){return new a("layer:unsupported",`Layer (${e.title}, ${e.id}) of type '${e.declaredClass}' ${t}`,{layer:e})}let ee=class extends(x(I(b(L(F(P(w(R(T(d(S(n(v))))))))))))){constructor(...e){super(...e),this.copyright=null,this.definitionExpression=null,this.displayField=null,this.elevationInfo=null,this.fields=null,this.fieldsIndex=null,this.geometryDefinition=null,this.geometryType=null,this.labelsVisible=!0,this.labelingInfo=null,this.legendEnabled=!0,this.maxReconnectionAttempts=0,this.maxReconnectionInterval=20,this.maxScale=0,this.minScale=0,this.objectIdField=null,this.operationalLayerType="ArcGISStreamLayer",this.popupEnabled=!0,this.popupTemplate=null,this.purgeOptions=new z,this.refreshInterval=0,this.screenSizePerspectiveEnabled=!0,this.sourceJSON=null,this.spatialReference=K.WGS84,this.type="stream",this.url=null,this.updateInterval=300,this.useViewTime=!0,this.webSocketUrl=null,this._debouncedSaveOperations=c((async(e,t,r)=>{const{save:i,saveAs:o}=await import("./save/streamLayerUtils.js");switch(e){case H.SAVE:return i(this,t);case H.SAVE_AS:return o(this,r,t)}}))}normalizeCtorArgs(e,t){return"string"==typeof e?{url:e,...t}:e}load(e){if(!("WebSocket"in globalThis))return this.addResolvingPromise(Promise.reject(new a("stream-layer:websocket-unsupported","WebSocket is not supported in this browser. StreamLayer will not have real-time connection with the stream service."))),Promise.resolve(this);const t=null!=e?e.signal:null;return this.addResolvingPromise(this.loadFromPortal({supportedTypes:["Stream Service","Feed"]},e).catch(u).then((()=>this._fetchService(t)))),Promise.resolve(this)}get defaultPopupTemplate(){return this.createPopupTemplate()}set featureReduction(e){const t=this._normalizeFeatureReduction(e);this._set("featureReduction",t)}set renderer(e){G(e,this.fieldsIndex),this._set("renderer",e)}readRenderer(e,t,i){t=t.layerDefinition||t;const o=t.drawingInfo?.renderer;if(o){const e=r(o,t,i)||void 0;return e||m.getLogger(this).error("Failed to create renderer",{rendererDefinition:t.drawingInfo.renderer,layer:this,context:i}),e}return C(t,i)}async connect(e){const[{createConnection:t}]=await Promise.all([import("./graphics/sources/connections/createConnection.js"),this.load()]),r=this.geometryType?j.toJSON(this.geometryType):null,{customParameters:i=null,definitionExpression:o=null,geometryDefinition:s=null,maxReconnectionAttempts:n=0,maxReconnectionInterval:a=20,spatialReference:l=this.spatialReference}=e||this.createConnectionParameters(),m=t(this.parsedUrl,this.spatialReference,l,r,{geometry:s,where:o},n,a,i??void 0),d=p([this.on("send-message-to-socket",(e=>m.sendMessageToSocket(e))),this.on("send-message-to-client",(e=>m.sendMessageToClient(e)))]);return m.once("destroy",d.remove),m}createConnectionParameters(){return{spatialReference:this.spatialReference,customParameters:this.customParameters,definitionExpression:this.definitionExpression,geometryDefinition:this.geometryDefinition,maxReconnectionAttempts:this.maxReconnectionAttempts,maxReconnectionInterval:this.maxReconnectionInterval}}createPopupTemplate(e){return B(this,e)}createQuery(){const e=new W;return e.returnGeometry=!0,e.outFields=["*"],e.where=this.definitionExpression||"1=1",e}getFieldDomain(e,t){if(!this.fields)return null;let r=null;return this.fields.some((t=>(t.name===e&&(r=t.domain),!!r))),r}getField(e){return this.fieldsIndex.get(e)}serviceSupportsSpatialReference(e){return!0}sendMessageToSocket(e){this.emit("send-message-to-socket",e)}sendMessageToClient(e){this.emit("send-message-to-client",e)}async save(e){return this._debouncedSaveOperations(H.SAVE,e)}async saveAs(e,t){return this._debouncedSaveOperations(H.SAVE_AS,t,e)}write(e,t){const r=t?.messages;return this.webSocketUrl?(r?.push(Z(this,"using a custom websocket connection cannot be written to web scenes and web maps")),null):this.parsedUrl?super.write(e,t):(r?.push(Z(this,"using a client-side only connection without a url cannot be written to web scenes and web maps")),null)}async _fetchService(e){if(!!!this.webSocketUrl&&this.parsedUrl){if(!this.sourceJSON){const{data:t}=await s(this.parsedUrl.path,{query:{f:"json",...this.customParameters,...this.parsedUrl.query},responseType:"json",signal:e});this.sourceJSON=t}}else{if(!this.timeInfo?.trackIdField)throw new a("stream-layer:missing-metadata","The stream layer trackIdField must be specified.");if(!this.objectIdField){const e=this.fields.find((e=>"oid"===e.type))?.name;if(!e)throw new a("stream-layer:missing-metadata","The stream layer objectIdField must be specified.");this.objectIdField=e}if(!this.fields)throw new a("stream-layer:missing-metadata","The stream layer fields must be specified.");if(this.fields.some((e=>e.name===this.objectIdField))||this.fields.push(new V({name:this.objectIdField,alias:this.objectIdField,type:"oid"})),!this.geometryType)throw new a("stream-layer:missing-metadata","The stream layer geometryType must be specified.");this.webSocketUrl&&(this.url=this.webSocketUrl)}return this.read(this.sourceJSON,{origin:"service",portalItem:this.portalItem,portal:this.portalItem?.portal,url:this.parsedUrl}),G(this.renderer,this.fieldsIndex),J(this.timeInfo,this.fieldsIndex),this.objectIdField||(this.objectIdField="__esri_stream_id__"),$(this,{origin:"service"})}};e([y({type:String})],ee.prototype,"copyright",void 0),e([y({readOnly:!0})],ee.prototype,"defaultPopupTemplate",null),e([y({type:String,json:{name:"layerDefinition.definitionExpression",write:{enabled:!0,allowNull:!0}}})],ee.prototype,"definitionExpression",void 0),e([y({type:String})],ee.prototype,"displayField",void 0),e([y({type:Q})],ee.prototype,"elevationInfo",void 0),e([y({json:{origins:{"web-map":{read:!1,write:!1},"portal-item":{read:!1,write:!1},"web-scene":{read:!1,write:!1}}}})],ee.prototype,"featureReduction",null),e([y(Y.fields)],ee.prototype,"fields",void 0),e([y(Y.fieldsIndex)],ee.prototype,"fieldsIndex",void 0),e([y({type:X,json:{name:"layerDefinition.definitionGeometry",write:!0}})],ee.prototype,"geometryDefinition",void 0),e([y({type:j.apiValues,json:{read:{reader:j.read}}})],ee.prototype,"geometryType",void 0),e([y(U)],ee.prototype,"labelsVisible",void 0),e([y({type:[M],json:{name:"layerDefinition.drawingInfo.labelingInfo",read:{reader:q},write:!0}})],ee.prototype,"labelingInfo",void 0),e([y(E)],ee.prototype,"legendEnabled",void 0),e([y({type:["show","hide"],json:{origins:{"portal-item":{read:!1,write:!1}}}})],ee.prototype,"listMode",void 0),e([y({type:f})],ee.prototype,"maxReconnectionAttempts",void 0),e([y({type:f})],ee.prototype,"maxReconnectionInterval",void 0),e([y(k)],ee.prototype,"maxScale",void 0),e([y(A)],ee.prototype,"minScale",void 0),e([y({type:String})],ee.prototype,"objectIdField",void 0),e([y({value:"ArcGISStreamLayer",type:["ArcGISStreamLayer"]})],ee.prototype,"operationalLayerType",void 0),e([y(D)],ee.prototype,"popupEnabled",void 0),e([y({type:t,json:{name:"popupInfo",write:!0}})],ee.prototype,"popupTemplate",void 0),e([y({type:z})],ee.prototype,"purgeOptions",void 0),e([y({json:{read:!1,write:!1}})],ee.prototype,"refreshInterval",void 0),e([y({types:i,json:{origins:{service:{write:{target:"drawingInfo.renderer",enabled:!1}},"web-scene":{name:"layerDefinition.drawingInfo.renderer",types:o,write:!0}},write:{target:"layerDefinition.drawingInfo.renderer"}}})],ee.prototype,"renderer",null),e([h("service","renderer",["drawingInfo.renderer","defaultSymbol"]),h("renderer",["layerDefinition.drawingInfo.renderer","layerDefinition.defaultSymbol"])],ee.prototype,"readRenderer",null),e([y((()=>{const e=l(_);return e.json.origins["portal-item"]={read:!1,write:!1},e})())],ee.prototype,"screenSizePerspectiveEnabled",void 0),e([y()],ee.prototype,"sourceJSON",void 0),e([y({type:K,json:{origins:{service:{read:{source:"spatialReference"}}}}})],ee.prototype,"spatialReference",void 0),e([y({json:{read:!1}})],ee.prototype,"type",void 0),e([y(O)],ee.prototype,"url",void 0),e([y({type:Number})],ee.prototype,"updateInterval",void 0),e([y({json:{read:!1,write:!1}})],ee.prototype,"useViewTime",void 0),e([y({type:String})],ee.prototype,"webSocketUrl",void 0),ee=e([g("esri.layers.StreamLayer")],ee);const te=ee;export{te 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.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import{ClonableMixin as r}from"../core/Clonable.js";import t from"../core/Collection.js";import s from"../core/Error.js";import{loadAll as i}from"../core/loadAll.js";import{MultiOriginJSONMixin as o}from"../core/MultiOriginJSONSupport.js";import{throwIfAbortError as a,whenOrAbort as n}from"../core/promiseUtils.js";import{watch as l,sync as u}from"../core/reactiveUtils.js";import{sqlAnd as p}from"../core/sql.js";import{urlToObject as y,join as d}from"../core/urlUtils.js";import{property as c}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{reader as h}from"../core/accessorSupport/decorators/reader.js";import{subclass as m}from"../core/accessorSupport/decorators/subclass.js";import{OriginId as f,nameToId as b}from"../core/accessorSupport/PropertyOrigin.js";import g from"./Layer.js";import{APIKeyMixin as j}from"./mixins/APIKeyMixin.js";import{ArcGISService as v}from"./mixins/ArcGISService.js";import{BlendLayer as w}from"./mixins/BlendLayer.js";import{CustomParametersMixin as S}from"./mixins/CustomParametersMixin.js";import{EditBusLayer as L}from"./mixins/EditBusLayer.js";import{FeatureLayerBase as F}from"./mixins/FeatureLayerBase.js";import{OperationalLayer as x}from"./mixins/OperationalLayer.js";import{PortalLayer as C}from"./mixins/PortalLayer.js";import{RefreshableLayer as _}from"./mixins/RefreshableLayer.js";import{ScaleRangeLayer as I}from"./mixins/ScaleRangeLayer.js";import{TemporalLayer as P}from"./mixins/TemporalLayer.js";import{titleFromUrlAndName as E}from"./support/arcgisLayerUrl.js";import{id as O}from"./support/commonProperties.js";import{ensureLayerCredential as T,computeEffectiveEditingEnabled as U,addAttachment as G,updateAttachment as A,applyEdits as q,createQuery as $,deleteAttachments as M,fetchRecomputedExtents as R,queryAttachments as k,queryObjectIds as N,queryFeatureCount as Q,queryExtent as D,queryRelatedFeatures as H,queryRelatedFeaturesCount as V,hasDataChanged as B}from"./support/featureLayerUtils.js";import{defineFieldProperties as J}from"./support/fieldProperties.js";import{fixTimeInfoFields as z}from"./support/fieldUtils.js";import K from"./support/Subtype.js";import Z from"./support/SubtypeSublayer.js";import W from"./support/TimeInfo.js";import{serviceSupportsSpatialReference as X}from"./support/versionUtils.js";import Y from"../rest/support/Query.js";const ee="SubtypeGroupLayer",re="esri.layers.SubtypeGroupLayer";function te(e,r){return new s("layer:unsupported",`Layer (${e.title}, ${e.id}) of type '${e.declaredClass}' ${r}`,{layer:e})}const se=J();let ie=class extends(F(L(w(P(I(_(v(x(C(o(S(j(r(g)))))))))))))){constructor(...e){super(...e),this._sublayersCollectionChanged=!1,this._sublayerLookup=new Map,this.fields=null,this.fieldsIndex=null,this.outFields=null,this.subtypes=null,this.sublayers=new(t.ofType(Z)),this.timeInfo=null,this.title="Layer",this.type="subtype-group",this.addHandles(l((()=>this.sublayers),((e,r)=>this._handleSublayersChange(e,r)),u))}destroy(){this.source?.destroy()}normalizeCtorArgs(e,r){return"string"==typeof e?{url:e,...r}:e}load(e){const r=null!=e?e.signal:null,t=this.loadFromPortal({supportedTypes:["Feature Service"]},e).catch(a).then((async()=>{if(!this.url)throw new s("subtype-grouplayer:missing-url-or-source","SubtypeGroupLayer must be created with either a url or a portal item");if(null==this.layerId)throw new s("subtype-grouplayer:missing-layerid","layerId is required for a SubtypeGroupLayer created with url");return this._initLayerProperties(await this.createGraphicsSource(r))})).then((()=>T(this,"load",e)));return this.addResolvingPromise(t),Promise.resolve(this)}get createQueryVersion(){return this.commitProperty("definitionExpression"),this.commitProperty("timeExtent"),this.commitProperty("timeOffset"),this.commitProperty("geometryType"),this.commitProperty("gdbVersion"),this.commitProperty("historicMoment"),this.commitProperty("returnZ"),this.commitProperty("capabilities"),this.commitProperty("returnM"),(this._get("createQueryVersion")??0)+1}get editingEnabled(){return this.loaded&&null!=this.capabilities&&this.capabilities.operations.supportsEditing&&this.userHasEditingPrivileges}get effectiveEditingEnabled(){return U(this)}get parsedUrl(){const e=y(this.url);return null!=e&&null!=this.layerId&&(e.path=d(e.path,this.layerId.toString())),e}set source(e){this._get("source")!==e&&this._set("source",e)}readTitleFromService(e,{name:r}){return this.url?E(this.url,r):r}async addAttachment(e,r){return G(this,e,r,ee)}async updateAttachment(e,r,t){return A(this,e,r,t,ee)}async applyEdits(e,r){return q(this,e,r)}on(e,r){return super.on(e,r)}async createGraphicsSource(e){const{default:r}=await n(import("./graphics/sources/FeatureLayerSource.js"),e);return new r({layer:this}).load({signal:e})}createQuery(){const e=$(this),r=this.sublayers.map((e=>e.subtypeCode));return e.where=p(`${this.subtypeField} IN (${r.join(",")})`,this.definitionExpression),e}async deleteAttachments(e,r){return M(this,e,r,ee)}async fetchRecomputedExtents(e){return R(this,e,ee)}findSublayerForFeature(e){const r=this.fieldsIndex.get(this.subtypeField),t=e.attributes[r.name];return this.findSublayerForSubtypeCode(t)}findSublayerForSubtypeCode(e){return this._sublayerLookup.get(e)}getFieldDomain(e,r){return this._getLayerDomain(e)}getField(e){return this.fieldsIndex.get(e)}loadAll(){return i(this,(e=>{e(this.sublayers)}))}async queryAttachments(e,r){return k(this,e,r,ee)}async queryFeatures(e,r){const t=await this.load(),s=Y.from(e)??t.createQuery(),i=s.outFields??[];i.includes(this.subtypeField)||(i.push(this.subtypeField),s.outFields=i);const o=await t.source.queryFeatures(s,r);if(o?.features)for(const a of o.features)a.layer=a.sourceLayer=this.findSublayerForFeature(a);return o}async queryObjectIds(e,r){return N(this,e,r,ee)}async queryFeatureCount(e,r){return Q(this,e,r,ee)}async queryExtent(e,r){return D(this,e,r,ee)}async queryRelatedFeatures(e,r){return H(this,e,r,ee)}async queryRelatedFeaturesCount(e,r){return V(this,e,r,ee)}async save(e){const{save:r}=await import("./save/featureLayerUtils.js");return r(this,e)}async saveAs(e,r){const{saveAs:t}=await import("./save/featureLayerUtils.js");return t(this,e,r)}write(e,r){const{origin:t,layerContainerType:i,messages:o}=r;if(this.isTable){if("web-scene"===t||"web-map"===t&&"tables"!==i)return o?.push(te(this,"using a table source cannot be written to web scenes and web maps")),null}else if(this.loaded&&"web-map"===t&&"tables"===i)return o?.push(te(this,"using a non-table source cannot be written to tables in web maps")),null;return this.sublayers?.length?super.write(e,r):(o?.push(new s("web-document-write:invalid-property",`Layer (${this.title}, ${this.id}) of type '${this.declaredClass}' has invalid value for 'sublayers' property. 'sublayers' collection should contain at least one sublayer`,{layer:this})),null)}serviceSupportsSpatialReference(e){return!!this.loaded&&X(this,e)}_getLayerDomain(e){const r=this.fieldsIndex.get(e);return r?r.domain:null}async _initLayerProperties(e){this._set("source",e);const{sourceJSON:r}=e;if(r&&(this.sourceJSON=r,this.read(r,{origin:"service",url:this.parsedUrl})),this.isTable)throw new s("subtype-grouplayer:unsupported-source","SubtypeGroupLayer cannot be created using a layer with table source");if(!this.subtypes?.length)throw new s("subtype-grouplayer:missing-subtypes","SubtypeGroupLayer must be created using a layer with subtypes");this._verifyFields(),z(this.timeInfo,this.fieldsIndex)}async hasDataChanged(){return B(this)}_verifyFields(){const e=this.parsedUrl?.path??"undefined";this.objectIdField||console.log("SubtypeGroupLayer: 'objectIdField' property is not defined (url: "+e+")"),this.isTable||-1!==e.search(/\/FeatureServer\//i)||this.fields?.some((e=>"geometry"===e.type))||console.log("SubtypeGroupLayer: unable to find field of type 'geometry' in the layer 'fields' list. If you are using a map service layer, features will not have geometry (url: "+e+")")}_handleSublayersChange(e,r){r&&(r.forEach((e=>{e.parent=null})),this.removeHandles("sublayers-owner"),this._sublayerLookup.clear()),e&&(e.forEach((e=>{e.parent=this,this._sublayerLookup.set(e.subtypeCode,e)})),this._sublayersCollectionChanged=!1,this.addHandles([e.on("after-add",(({item:e})=>{e.parent=this,this._sublayerLookup.set(e.subtypeCode,e)})),e.on("after-remove",(({item:e})=>{e.parent=null,this._sublayerLookup.delete(e.subtypeCode)})),e.on("after-changes",(()=>{this._sublayersCollectionChanged=!0}))],"sublayers-owner"))}};e([c({readOnly:!0})],ie.prototype,"createQueryVersion",null),e([c({readOnly:!0})],ie.prototype,"editingEnabled",null),e([c({readOnly:!0})],ie.prototype,"effectiveEditingEnabled",null),e([c({...se.fields,readOnly:!0,json:{origins:{service:{read:!0}},read:!1}})],ie.prototype,"fields",void 0),e([c(se.fieldsIndex)],ie.prototype,"fieldsIndex",void 0),e([c(O)],ie.prototype,"id",void 0),e([c({type:["show","hide","hide-children"],json:{origins:{"portal-item":{read:!1,write:!1}}}})],ie.prototype,"listMode",void 0),e([c({value:"SubtypeGroupLayer",type:["SubtypeGroupLayer"],json:{origins:{"portal-item":{name:"layerType",write:{enabled:!0,ignoreOrigin:!0}}}}})],ie.prototype,"operationalLayerType",void 0),e([c(se.outFields)],ie.prototype,"outFields",void 0),e([c({readOnly:!0})],ie.prototype,"parsedUrl",null),e([c({clonable:!1})],ie.prototype,"source",null),e([c({type:[K],readOnly:!0,json:{read:!1,origins:{service:{read:!0}}}})],ie.prototype,"subtypes",void 0),e([c({type:t.ofType(Z),json:{origins:{service:{read:{source:"subtypes",reader:(e,r,s)=>{const i=e.map((({code:e})=>{const t=new Z({subtypeCode:e});return t.read(r,s),t}));return new(t.ofType(Z))(i)}}}},name:"layers",write:{overridePolicy(e,r,t){const s=this.originOf("sublayers"),i=f.PORTAL_ITEM;let o=!0;if(b(s)===i&&b(t.origin)>i){const r=e.some((e=>e.hasUserOverrides()));o=this._sublayersCollectionChanged||r}return{enabled:o,ignoreOrigin:!0}}}}})],ie.prototype,"sublayers",void 0),e([c({type:W})],ie.prototype,"timeInfo",void 0),e([c({json:{origins:{"portal-item":{write:{enabled:!0,ignoreOrigin:!0,writerEnsuresNonNull:!0}}}}})],ie.prototype,"title",void 0),e([h("service","title",["name"])],ie.prototype,"readTitleFromService",null),e([c({json:{read:!1}})],ie.prototype,"type",void 0),ie=e([m(re)],ie);const oe=ie;export{oe as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import{ClonableMixin as r}from"../core/Clonable.js";import t from"../core/Collection.js";import s from"../core/Error.js";import{loadAll as i}from"../core/loadAll.js";import{MultiOriginJSONMixin as o}from"../core/MultiOriginJSONSupport.js";import{debounce as a,throwIfAbortError as n,whenOrAbort as u}from"../core/promiseUtils.js";import{watch as l,sync as p}from"../core/reactiveUtils.js";import{sqlAnd as y}from"../core/sql.js";import{urlToObject as d,join as c}from"../core/urlUtils.js";import{property as h}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{reader as m}from"../core/accessorSupport/decorators/reader.js";import{subclass as f}from"../core/accessorSupport/decorators/subclass.js";import{OriginId as b,nameToId as g}from"../core/accessorSupport/PropertyOrigin.js";import j from"./Layer.js";import{APIKeyMixin as S}from"./mixins/APIKeyMixin.js";import{ArcGISService as v}from"./mixins/ArcGISService.js";import{BlendLayer as w}from"./mixins/BlendLayer.js";import{CustomParametersMixin as L}from"./mixins/CustomParametersMixin.js";import{EditBusLayer as F}from"./mixins/EditBusLayer.js";import{FeatureLayerBase as _}from"./mixins/FeatureLayerBase.js";import{OperationalLayer as x}from"./mixins/OperationalLayer.js";import{PortalLayer as C}from"./mixins/PortalLayer.js";import{RefreshableLayer as E}from"./mixins/RefreshableLayer.js";import{ScaleRangeLayer as I}from"./mixins/ScaleRangeLayer.js";import{TemporalLayer as O}from"./mixins/TemporalLayer.js";import{titleFromUrlAndName as P}from"./support/arcgisLayerUrl.js";import{id as A}from"./support/commonProperties.js";import{ensureLayerCredential as T,computeEffectiveEditingEnabled as U,addAttachment as G,updateAttachment as q,applyEdits as $,createQuery as M,deleteAttachments as R,fetchRecomputedExtents as V,queryAttachments as k,queryObjectIds as N,queryFeatureCount as Q,queryExtent as D,queryRelatedFeatures as H,queryRelatedFeaturesCount as B,hasDataChanged as J}from"./support/featureLayerUtils.js";import{defineFieldProperties as z}from"./support/fieldProperties.js";import{fixTimeInfoFields as K}from"./support/fieldUtils.js";import Z from"./support/Subtype.js";import W from"./support/SubtypeSublayer.js";import X from"./support/TimeInfo.js";import{serviceSupportsSpatialReference as Y}from"./support/versionUtils.js";import ee from"../rest/support/Query.js";import{SaveOperationType as re}from"../webdoc/interfaces.js";const te="SubtypeGroupLayer",se="esri.layers.SubtypeGroupLayer";function ie(e,r){return new s("layer:unsupported",`Layer (${e.title}, ${e.id}) of type '${e.declaredClass}' ${r}`,{layer:e})}const oe=z();let ae=class extends(_(F(w(O(I(E(v(x(C(o(L(S(r(j)))))))))))))){constructor(...e){super(...e),this._sublayersCollectionChanged=!1,this._sublayerLookup=new Map,this.fields=null,this.fieldsIndex=null,this.outFields=null,this.subtypes=null,this.sublayers=new(t.ofType(W)),this.timeInfo=null,this.title="Layer",this.type="subtype-group",this._debouncedSaveOperations=a((async(e,r,t)=>{const{save:s,saveAs:i}=await import("./save/featureLayerUtils.js");switch(e){case re.SAVE:return s(this,r);case re.SAVE_AS:return i(this,t,r)}})),this.addHandles(l((()=>this.sublayers),((e,r)=>this._handleSublayersChange(e,r)),p))}destroy(){this.source?.destroy()}normalizeCtorArgs(e,r){return"string"==typeof e?{url:e,...r}:e}load(e){const r=null!=e?e.signal:null,t=this.loadFromPortal({supportedTypes:["Feature Service"]},e).catch(n).then((async()=>{if(!this.url)throw new s("subtype-grouplayer:missing-url-or-source","SubtypeGroupLayer must be created with either a url or a portal item");if(null==this.layerId)throw new s("subtype-grouplayer:missing-layerid","layerId is required for a SubtypeGroupLayer created with url");return this._initLayerProperties(await this.createGraphicsSource(r))})).then((()=>T(this,"load",e)));return this.addResolvingPromise(t),Promise.resolve(this)}get createQueryVersion(){return this.commitProperty("definitionExpression"),this.commitProperty("timeExtent"),this.commitProperty("timeOffset"),this.commitProperty("geometryType"),this.commitProperty("gdbVersion"),this.commitProperty("historicMoment"),this.commitProperty("returnZ"),this.commitProperty("capabilities"),this.commitProperty("returnM"),(this._get("createQueryVersion")??0)+1}get editingEnabled(){return this.loaded&&null!=this.capabilities&&this.capabilities.operations.supportsEditing&&this.userHasEditingPrivileges}get effectiveEditingEnabled(){return U(this)}get parsedUrl(){const e=d(this.url);return null!=e&&null!=this.layerId&&(e.path=c(e.path,this.layerId.toString())),e}set source(e){this._get("source")!==e&&this._set("source",e)}readTitleFromService(e,{name:r}){return this.url?P(this.url,r):r}async addAttachment(e,r){return G(this,e,r,te)}async updateAttachment(e,r,t){return q(this,e,r,t,te)}async applyEdits(e,r){return $(this,e,r)}on(e,r){return super.on(e,r)}async createGraphicsSource(e){const{default:r}=await u(import("./graphics/sources/FeatureLayerSource.js"),e);return new r({layer:this}).load({signal:e})}createQuery(){const e=M(this),r=this.sublayers.map((e=>e.subtypeCode));return e.where=y(`${this.subtypeField} IN (${r.join(",")})`,this.definitionExpression),e}async deleteAttachments(e,r){return R(this,e,r,te)}async fetchRecomputedExtents(e){return V(this,e,te)}findSublayerForFeature(e){const r=this.fieldsIndex.get(this.subtypeField),t=e.attributes[r.name];return this.findSublayerForSubtypeCode(t)}findSublayerForSubtypeCode(e){return this._sublayerLookup.get(e)}getFieldDomain(e,r){return this._getLayerDomain(e)}getField(e){return this.fieldsIndex.get(e)}loadAll(){return i(this,(e=>{e(this.sublayers)}))}async queryAttachments(e,r){return k(this,e,r,te)}async queryFeatures(e,r){const t=await this.load(),s=ee.from(e)??t.createQuery(),i=s.outFields??[];i.includes(this.subtypeField)||(i.push(this.subtypeField),s.outFields=i);const o=await t.source.queryFeatures(s,r);if(o?.features)for(const a of o.features)a.layer=a.sourceLayer=this.findSublayerForFeature(a);return o}async queryObjectIds(e,r){return N(this,e,r,te)}async queryFeatureCount(e,r){return Q(this,e,r,te)}async queryExtent(e,r){return D(this,e,r,te)}async queryRelatedFeatures(e,r){return H(this,e,r,te)}async queryRelatedFeaturesCount(e,r){return B(this,e,r,te)}async save(e){return this._debouncedSaveOperations(re.SAVE,e)}async saveAs(e,r){return this._debouncedSaveOperations(re.SAVE_AS,r,e)}write(e,r){const{origin:t,layerContainerType:i,messages:o}=r;if(this.isTable){if("web-scene"===t||"web-map"===t&&"tables"!==i)return o?.push(ie(this,"using a table source cannot be written to web scenes and web maps")),null}else if(this.loaded&&"web-map"===t&&"tables"===i)return o?.push(ie(this,"using a non-table source cannot be written to tables in web maps")),null;return this.sublayers?.length?super.write(e,r):(o?.push(new s("web-document-write:invalid-property",`Layer (${this.title}, ${this.id}) of type '${this.declaredClass}' has invalid value for 'sublayers' property. 'sublayers' collection should contain at least one sublayer`,{layer:this})),null)}serviceSupportsSpatialReference(e){return!!this.loaded&&Y(this,e)}_getLayerDomain(e){const r=this.fieldsIndex.get(e);return r?r.domain:null}async _initLayerProperties(e){this._set("source",e);const{sourceJSON:r}=e;if(r&&(this.sourceJSON=r,this.read(r,{origin:"service",url:this.parsedUrl})),this.isTable)throw new s("subtype-grouplayer:unsupported-source","SubtypeGroupLayer cannot be created using a layer with table source");if(!this.subtypes?.length)throw new s("subtype-grouplayer:missing-subtypes","SubtypeGroupLayer must be created using a layer with subtypes");this._verifyFields(),K(this.timeInfo,this.fieldsIndex)}async hasDataChanged(){return J(this)}_verifyFields(){const e=this.parsedUrl?.path??"undefined";this.objectIdField||console.log("SubtypeGroupLayer: 'objectIdField' property is not defined (url: "+e+")"),this.isTable||-1!==e.search(/\/FeatureServer\//i)||this.fields?.some((e=>"geometry"===e.type))||console.log("SubtypeGroupLayer: unable to find field of type 'geometry' in the layer 'fields' list. If you are using a map service layer, features will not have geometry (url: "+e+")")}_handleSublayersChange(e,r){r&&(r.forEach((e=>{e.parent=null})),this.removeHandles("sublayers-owner"),this._sublayerLookup.clear()),e&&(e.forEach((e=>{e.parent=this,this._sublayerLookup.set(e.subtypeCode,e)})),this._sublayersCollectionChanged=!1,this.addHandles([e.on("after-add",(({item:e})=>{e.parent=this,this._sublayerLookup.set(e.subtypeCode,e)})),e.on("after-remove",(({item:e})=>{e.parent=null,this._sublayerLookup.delete(e.subtypeCode)})),e.on("after-changes",(()=>{this._sublayersCollectionChanged=!0}))],"sublayers-owner"))}};e([h({readOnly:!0})],ae.prototype,"createQueryVersion",null),e([h({readOnly:!0})],ae.prototype,"editingEnabled",null),e([h({readOnly:!0})],ae.prototype,"effectiveEditingEnabled",null),e([h({...oe.fields,readOnly:!0,json:{origins:{service:{read:!0}},read:!1}})],ae.prototype,"fields",void 0),e([h(oe.fieldsIndex)],ae.prototype,"fieldsIndex",void 0),e([h(A)],ae.prototype,"id",void 0),e([h({type:["show","hide","hide-children"],json:{origins:{"portal-item":{read:!1,write:!1}}}})],ae.prototype,"listMode",void 0),e([h({value:"SubtypeGroupLayer",type:["SubtypeGroupLayer"],json:{origins:{"portal-item":{name:"layerType",write:{enabled:!0,ignoreOrigin:!0}}}}})],ae.prototype,"operationalLayerType",void 0),e([h(oe.outFields)],ae.prototype,"outFields",void 0),e([h({readOnly:!0})],ae.prototype,"parsedUrl",null),e([h({clonable:!1})],ae.prototype,"source",null),e([h({type:[Z],readOnly:!0,json:{read:!1,origins:{service:{read:!0}}}})],ae.prototype,"subtypes",void 0),e([h({type:t.ofType(W),json:{origins:{service:{read:{source:"subtypes",reader:(e,r,s)=>{const i=e.map((({code:e})=>{const t=new W({subtypeCode:e});return t.read(r,s),t}));return new(t.ofType(W))(i)}}}},name:"layers",write:{overridePolicy(e,r,t){const s=this.originOf("sublayers"),i=b.PORTAL_ITEM;let o=!0;if(g(s)===i&&g(t.origin)>i){const r=e.some((e=>e.hasUserOverrides()));o=this._sublayersCollectionChanged||r}return{enabled:o,ignoreOrigin:!0}}}}})],ae.prototype,"sublayers",void 0),e([h({type:X})],ae.prototype,"timeInfo",void 0),e([h({json:{origins:{"portal-item":{write:{enabled:!0,ignoreOrigin:!0,writerEnsuresNonNull:!0}}}}})],ae.prototype,"title",void 0),e([m("service","title",["name"])],ae.prototype,"readTitleFromService",null),e([h({json:{read:!1}})],ae.prototype,"type",void 0),ae=e([f(se)],ae);const ne=ae;export{ne 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.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import t from"../Graphic.js";import r from"../request.js";import has from"../core/has.js";import s from"../core/Logger.js";import{isAbortError as i}from"../core/promiseUtils.js";import{watch as a,initial as n}from"../core/reactiveUtils.js";import{property as o}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import{subclass as l}from"../core/accessorSupport/decorators/subclass.js";import{h}from"../chunks/vec3.js";import{c as d}from"../chunks/vec3f64.js";import{renderSRFromViewSR as u}from"../geometry/support/coordinateSystem.js";import{PointIndex as _,PlaneIndex as c}from"../geometry/support/frustum.js";import{WasmCullMode as m,VoxelRequestType as p,UpdateFlags as g,ContainerType as f}from"../libs/vxl/enums.js";import{loadVoxelWASM as x}from"../libs/vxl/VxlModule.js";import{ViewingMode as y}from"../views/ViewingMode.js";import{VoxelTarget as v}from"../views/3d/layers/i3s/Intersector.js";import{Frustum as b}from"../views/3d/state/Frustum.js";import{RenderCoordsHelper as w}from"../views/3d/support/RenderCoordsHelper.js";import{ShaderOutput as T}from"../views/3d/webgl-engine/core/shaderLibrary/ShaderOutput.js";import{SyncRenderPlugin as R}from"../views/3d/webgl-engine/effects/RenderPlugin.js";import{newIntersectorResult as L}from"../views/3d/webgl-engine/lib/Intersector.js";import{IntersectorType as E,StoreResults as V}from"../views/3d/webgl-engine/lib/IntersectorInterfaces.js";import{RenderFeature as C}from"../views/3d/webgl-engine/lib/RenderFeature.js";import{RenderSlot as F}from"../views/3d/webgl-engine/lib/RenderSlot.js";import{ContextType as S}from"../views/webgl/contextUtils.js";import{CompareFunction as P,Face as U,StencilOperation as k}from"../views/webgl/enums.js";const I=s.getLogger("esri.layers.VoxelWasmPerSceneView");var B;!function(e){e[e.Lifetime=1]="Lifetime",e[e.RequestResponse=2]="RequestResponse",e[e.Rendering=3]="Rendering",e[e.Error=4]="Error"}(B||(B={}));let A=class extends R{constructor(e){super(e),this._halfIntTexturesAvailable=!1,this._textureFloatLinearAvailable=!1,this._havePreparedWithAllLayers=!1,this._renderPluginContext=null,this._vxlPromise=null,this._vxl=null,this._pluginIsActive=!1,this._moreToLoad=!1,this._viewportWidth=-1,this._viewportHeight=-1,this._newLayers=[],this._layers=new Map,this.renderSlots=[F.VOXEL],this._rctx=null,this._renderTargetToRestore=null,this._lastFrameWasStationary=!1,this._wasmMemBlockSizes=[512,1024,2048,4096,8192,16384,32768,65536],this._wasmMemBlocks=new Map,this._dbgFlags=new Set,this._captureFrustum=!1,this._frustum=null,this._frustumRenderableId=-1,this._renderCoordsHelper=null,this.type=E.VOXEL,this.slicePlaneEnabled=!0,this.isGround=!1,this.layerUid=[]}canRender(){return!!this._vxl&&"local"===this.view.viewingMode}_dbg(e,t){this._dbgFlags.has(e)&&(e===B.Error?I.error(t):I.warn(t))}_removeRenderPlugin(){this._pluginIsActive&&this.view._stage&&(this._dbg(B.Lifetime,"--removeRenderPlugin--"),this.view._stage.removeRenderPlugin(this)),this._pluginIsActive=!1}initialize(){this._dbg(B.Lifetime,"--initialize--");for(const e of this._wasmMemBlockSizes)this._wasmMemBlocks.set(e,0);this.addHandles([a((()=>this.view.ready),(e=>{e&&"local"===this.view.viewingMode?(this._dbg(B.Lifetime,"view ready status changed to ready on a local view, calling addRenderPlugin"),this.view._stage.addRenderPlugin(this),this._pluginIsActive=!0):(this._dbg(B.Lifetime,"view ready status changed, not ready or not a local view!"),this._removeRenderPlugin())}),n),a((()=>this.view?.qualityProfile),(e=>{this._dbg(B.Rendering,"qualityProfile changed to "+e),this._vxl&&this._vxl.set_quality(this._toWasmQuality(e))}),n),a((()=>this.view?.timeExtent),(()=>{if(this._vxl){const e=this._getTimeArgs(this.view?.timeExtent);this._dbg(B.Rendering,"sceneView timeExtent changed to useTime="+e.useTime+" st="+e.startTime+" et="+e.endTime),this._vxl.set_scene_time_extent(e.startTime,e.endTime,e.useTime),this._renderPluginContext.requestRender()}}),n),a((()=>this.view?.stationary),(e=>{this._vxl&&e&&!this._lastFrameWasStationary&&this._renderPluginContext.requestRender()}))])}initializeRenderContext(e){this._dbg(B.Lifetime,"--initializeRenderContext--");const t=e.renderContext.rctx;t.type===S.WEBGL2?(this._renderPluginContext=e,this._rctx=e.renderContext.rctx,this._halfIntTexturesAvailable=!!this._rctx.capabilities.textureNorm16,this._textureFloatLinearAvailable=this._rctx.capabilities.textureFloatLinear,this._initializeWasm(t.gl)):this._dbg(B.Error,"WebGL 1 context only!")}uninitializeRenderContext(){this._renderPluginContext=null,this._rctx=null,this._dbg(B.Lifetime,"--uninitializeRenderContext--")}_restoreFramebuffer(){if(!this._renderTargetToRestore)return;const e=this._renderTargetToRestore.fbo;if(!!!this._rctx)return void this._dbg(B.Error,"no context in restoreFramebuffer!");this._rctx.bindFramebuffer(e,!0);const t=this._renderTargetToRestore.viewport;this._rctx.setViewport(t.x,t.y,t.width,t.height)}_bindPreviousDepthToSlot(e,t){const r=!!this._rctx,s=!!this._renderTargetToRestore;if(!r||!s)return 0;const i=this._renderTargetToRestore.fbo.depthStencilTexture;return i?(0===t?this._rctx.bindTexture(null,e,!0):this._rctx.bindTexture(i,e,!0),1):(this._dbg(B.Error,"no depth/stencil texture exists!"),0)}_modifyResourceCount(e,t,r){if(!this._rctx)return void this._dbg(B.Error,"modifyAllocation callback has no rendering context!");const s=e;1===r?this._rctx.instanceCounter.increment(s,t):this._rctx.instanceCounter.decrement(s,t)}_setBlendState(e,t,r,s){this._rctx?(this._rctx.setBlendingEnabled(1===e),this._rctx.setBlendFunction(t,r),this._rctx.setBlendEquation(s)):this._dbg(B.Error,"setBlendState callback has no rendering context!")}_setFrontFace(e){this._rctx?this._rctx.setFrontFace(e):this._dbg(B.Error,"setFrontFace callback has no rendering context!")}_setDepthStencilStateFunction(e,t,r){this._rctx?(this._rctx.setDepthFunction(r),this._rctx.setDepthTestEnabled(1===e),this._rctx.setDepthWriteEnabled(1===t),this._rctx.setStencilTestEnabled(!1),this._rctx.setStencilFunction(P.ALWAYS,0,255),this._rctx.setStencilOpSeparate(U.FRONT,k.KEEP,k.INCR,k.KEEP),this._rctx.setStencilOpSeparate(U.BACK,k.KEEP,k.DECR,k.KEEP)):this._dbg(B.Error,"setDepthStencilStateFunction callback has no rendering context!")}_setRasterizerState(e){if(this._rctx)switch(e){case m.None:this._rctx.setFaceCullingEnabled(!1);break;case m.Back:this._rctx.setCullFace(U.BACK),this._rctx.setFaceCullingEnabled(!0);break;case m.Front:this._rctx.setCullFace(U.FRONT),this._rctx.setFaceCullingEnabled(!0)}else this._dbg(B.Error,"setRasterizerState callback has no rendering context!")}_setViewport(e,t,r,s){this._rctx?this._rctx.setViewport(e,t,r,s):this._dbg(B.Error,"setViewport callback has no rendering context!")}_updateMemoryUsage(){this._layers.forEach(((e,t)=>{if(e.needMemoryUsageUpdate){const r=this._vxl.estimate_memory_usage(t);r>=0&&(e.needMemoryUsageUpdate=!1,e.layerView.setUsedMemory(r))}}))}_syncRequestsResponses(){this._layers.forEach(((e,t)=>{const s=[];e.responses.forEach(((r,i)=>{s.push(i),this._dbg(B.RequestResponse,"responding for requestID:"+i+" size:"+r.size),this._vxl.respond(t,i,r),r.requestType!==p.TreeIndex&&r.requestType!==p.Section||(e.needMemoryUsageUpdate=!0)}));const a=e.responses;for(const r of s)a.delete(r);const n=this._vxl.get_new_requests(t),o=e.abortController.signal;for(const l in n){e.outstandingRequestCount+=1,1===e.outstandingRequestCount&&e.layerView.updatingFlagChanged();const t=n[l],s={responseType:"array-buffer",signal:o};this._dbg(B.RequestResponse,"making requestID:"+l+" url:"+t.url),r(t.url,s).then((r=>{e.outstandingRequestCount-=1,0===e.outstandingRequestCount&&e.layerView.updatingFlagChanged(),this._dbg(B.RequestResponse,"have response for requestID:"+l);let s=0;if(r.data.byteLength>0){s=this._vxl._malloc(r.data.byteLength);const e=new Uint8Array(this._vxl.HEAPU8.buffer,s,r.data.byteLength),t=new Uint8Array(r.data);for(let s=0;s<r.data.byteLength;++s)e[s]=t[s]}a.set(+l,{responseType:t.responseType,ptr:s,size:r.data.byteLength,success:!0,requestType:t.requestType})})).catch((r=>{e.outstandingRequestCount-=1,0===e.outstandingRequestCount&&e.layerView.updatingFlagChanged(),i(r)||(this._dbg(B.Error,`requestID:${l} failed, error=${r.toString()}`),a.set(+l,{responseType:t.responseType,ptr:0,size:0,success:!1,requestType:t.requestType}))}))}}))}updateWasmCamera(e){this._vxl.set_projection_matrix.apply(this._vxl,e.projectionMatrix),this._vxl.set_view_matrix.apply(this._vxl,e.viewMatrix),this._vxl.set_near_far(e.near,e.far)}isUpdating(e){if(!this._vxl&&this._vxlPromise)return!0;const t=this._layers.get(e);return!!t&&t.outstandingRequestCount>0}getLayerTimes(e){const t=[];return this._layers.forEach(((r,s)=>{if(r.layerView.wasmLayerId===e.wasmLayerId){const r=this._vxl.get_layer_epoch_times(s,e.layer.currentVariableId);for(let e=0;e<r.length;++e)t.push(r[e])}})),t}getCurrentLayerTimeIndex(e){let t=0;return this._layers.forEach(((r,s)=>{r.layerView.wasmLayerId===e.wasmLayerId&&(t=this._vxl.get_layer_current_time_id(s))})),t}setEnabled(e,t){this._layers.forEach(((r,s)=>{r.layerView.wasmLayerId===e.wasmLayerId&&(this._vxl.set_enabled(s,t),r.needMemoryUsageUpdate=!0,this._renderPluginContext.requestRender())}))}setStaticSections(e,t){const r={mask:g.StaticSections,staticSections:t};return this._doMaskedUIUpdate(e,r,!0)}setCurrentVariable(e,t){const r={mask:g.CurrentVariable,currentVariable:t};return this._doMaskedUIUpdate(e,r,!0)}setRenderMode(e,t){const r={mask:g.RenderMode,renderMode:t};return this._doMaskedUIUpdate(e,r,!0)}setVerticalExaggerationAndOffset(e,t,r,s){const i={mask:g.ExaggerationAndOffset,volStyleDesc:{volumeId:t,verticalExaggeration:r,verticalOffset:s}};return this._doMaskedUIUpdate(e,i,!0)}setVariableStyles(e,t){const r={mask:g.VariableStyles,variableStyles:t};return this._doMaskedUIUpdate(e,r,!0)}setVolumeStyles(e,t){const r={mask:g.VolumeStyles,volumeStyles:t};return this._doMaskedUIUpdate(e,r,!0)}setEnableDynamicSections(e,t){const r={mask:g.ContainerVisibility,containerIsVisible:t,container:f.DynamicSections};return this._doMaskedUIUpdate(e,r,!0)}setEnableIsosurfaces(e,t){const r={mask:g.ContainerVisibility,containerIsVisible:t,container:f.Isosurfaces};return this._doMaskedUIUpdate(e,r,!0)}setEnableSections(e,t){const r={mask:g.ContainerVisibility,containerIsVisible:t,container:f.StaticSections};return this._doMaskedUIUpdate(e,r,!0)}setAnalysisSlice(e,t,r,s){const i={mask:g.AnalysisSlice,analysisSlice:{point:r,normal:s,enabled:t}};return this._doMaskedUIUpdate(e,i,!0)}_doMaskedUIUpdate(e,t,r){if(!this._vxl)return!1;let s=!1;return this._layers.forEach(((r,i)=>{if(r.layerView.wasmLayerId===e.wasmLayerId){const e={str:JSON.stringify(t),byteCount:0,ptr:0,isReusable:!1};this._allocateBlock(e)&&(s=1===this._vxl.handle_masked_ui_update(i,e.ptr,e.byteCount),e.isReusable||this._vxl._free(e.ptr))}})),s&&r&&this._renderPluginContext.requestRender(),s}_addTriangleToWasmBuffer(e,t,r,s,i){return e[3*t]=r[0],e[3*t+1]=r[1],e[3*t+2]=r[2],e[3*(t+=1)]=s[0],e[3*t+1]=s[1],e[3*t+2]=s[2],e[3*(t+=1)]=i[0],e[3*t+1]=i[1],e[3*t+2]=i[2],t+=1}_addNormalToWasmBuffer(e,t,r){return e[3*t]=r[0],e[3*t+1]=r[1],e[3*t+2]=r[2],t+=1}_doCaptureFrustum(){if(!this._vxl)return;const e=36,t=e/3,r=this._vxl._malloc(3*e*Float32Array.BYTES_PER_ELEMENT),s=new Float32Array(this._vxl.HEAPF32.buffer,r,3*e),i=this._vxl._malloc(3*t*Float32Array.BYTES_PER_ELEMENT),a=new Float32Array(this._vxl.HEAPF32.buffer,i,e),n=this._frustum.points[_.NEAR_BOTTOM_LEFT],o=this._frustum.points[_.NEAR_BOTTOM_RIGHT],l=this._frustum.points[_.NEAR_TOP_RIGHT],h=this._frustum.points[_.NEAR_TOP_LEFT],d=this._frustum.points[_.FAR_BOTTOM_LEFT],u=this._frustum.points[_.FAR_BOTTOM_RIGHT],m=this._frustum.points[_.FAR_TOP_RIGHT],p=this._frustum.points[_.FAR_TOP_LEFT];let g=0,f=0;const x=this._frustum.planes[c.NEAR];g=this._addTriangleToWasmBuffer(s,g,l,o,n),f=this._addNormalToWasmBuffer(a,f,x),g=this._addTriangleToWasmBuffer(s,g,n,h,l),f=this._addNormalToWasmBuffer(a,f,x);const y=this._frustum.planes[c.FAR];g=this._addTriangleToWasmBuffer(s,g,d,u,m),f=this._addNormalToWasmBuffer(a,f,y),g=this._addTriangleToWasmBuffer(s,g,m,p,d),f=this._addNormalToWasmBuffer(a,f,y);const v=this._frustum.planes[c.TOP];g=this._addTriangleToWasmBuffer(s,g,m,l,h),f=this._addNormalToWasmBuffer(a,f,v),g=this._addTriangleToWasmBuffer(s,g,h,p,m),f=this._addNormalToWasmBuffer(a,f,v);const b=this._frustum.planes[c.BOTTOM];g=this._addTriangleToWasmBuffer(s,g,n,o,u),f=this._addNormalToWasmBuffer(a,f,b),g=this._addTriangleToWasmBuffer(s,g,u,d,n),f=this._addNormalToWasmBuffer(a,f,b);const w=this._frustum.planes[c.LEFT];g=this._addTriangleToWasmBuffer(s,g,h,n,d),f=this._addNormalToWasmBuffer(a,f,w),g=this._addTriangleToWasmBuffer(s,g,d,p,h),f=this._addNormalToWasmBuffer(a,f,w);const T=this._frustum.planes[c.RIGHT];g=this._addTriangleToWasmBuffer(s,g,l,m,u),f=this._addNormalToWasmBuffer(a,f,T),g=this._addTriangleToWasmBuffer(s,g,u,o,l),f=this._addNormalToWasmBuffer(a,f,T),-1!==this._frustumRenderableId&&this._vxl.remove_generic_mesh(this._frustumRenderableId),this._frustumRenderableId=this._vxl.add_generic_mesh(r,3*e,i,e,255,0,0,64),this._vxl._free(r),this._vxl._free(i),this._captureFrustum=!1,this._renderPluginContext.requestRender()}captureFrustum(){null===this._renderCoordsHelper&&(this._renderCoordsHelper=w.create(y.Local,u(!1,this.view.spatialReference))),null===this._frustum&&(this._frustum=new b(this._renderCoordsHelper)),this._captureFrustum=!0,null!==this._renderPluginContext&&this._renderPluginContext.requestRender()}toggleFullVolumeExtentDraw(e){this._vxl&&this._layers.forEach(((t,r)=>{t.layerView.wasmLayerId===e.wasmLayerId&&(this._vxl.toggle_full_volume_extent_draw(r),this._renderPluginContext.requestRender())}))}addVoxelLayer(e){if(!this._vxl){const t={layerView:e,resolveCallback:null,rejectCallback:null},r=new Promise(((e,r)=>{t.resolveCallback=e,t.rejectCallback=r}));return this._newLayers.push(t),r}const t=this._addVoxelLayer(e);return t<0?Promise.reject(-1):Promise.resolve(t)}removeVoxelLayer(e){if(!this._vxl){const t=this._newLayers.findIndex((t=>e.uid===t.layerView.uid));t>=0&&(this._newLayers[t].resolveCallback(-1),this._newLayers.splice(t,1));const r=this._newLayers.length;return 0===r&&(this._dbg(B.Lifetime," no voxel layers left after removing a layer, removing RenderPlugin and destroying"),this.destroy()),r}let t=-1;this._layers.forEach(((r,s)=>{if(r.layerView.wasmLayerId===e.wasmLayerId){t=s,r.abortController.abort(),this._vxl.remove_layer(t);const i=this.layerUid.indexOf(e.layer.uid);-1!==i&&this.layerUid.splice(i,1)}})),t>=0&&this._layers.delete(t);const r=this._layers.size;return 0===r&&(this._dbg(B.Lifetime," no voxel layers left after removing a layer, removing RenderPlugin and destroying"),this.destroy()),r}_getBlockSize(e){for(const t of this._wasmMemBlockSizes)if(e<t)return t;return-1}_allocateBlock(e){e.byteCount=this._vxl.lengthBytesUTF8(e.str)+1;const t=this._getBlockSize(e.byteCount);return t<0?(e.isReusable=!1,e.ptr=this._vxl._malloc(e.byteCount)):(e.isReusable=!0,e.ptr=this._wasmMemBlocks.get(t),0===e.ptr&&(e.ptr=this._vxl._malloc(t),this._wasmMemBlocks.set(t,e.ptr))),0!==e.ptr&&(this._vxl.stringToUTF8(e.str,e.ptr,e.byteCount),!0)}_getTimeArgs(e){let t=-Number.MAX_VALUE,r=Number.MAX_VALUE,s=!1;return null!=e&&(e.isAllTime?s=!0:(null!=e.start&&(s=!0,t=e.start.getTime()/1e3),null!=e.end&&(s=!0,r=e.end.getTime()/1e3))),{startTime:t,endTime:r,useTime:s}}_addVoxelLayer(e){const t=e.layer;let r=-1;const s=t.getConfiguration();if(s.length<1)return-1;const i={str:s,byteCount:0,ptr:0,isReusable:!1};if(!this._allocateBlock(i))return-1;const a=this._getTimeArgs(this.view?.timeExtent),n=this.view.spatialReference.isWGS84&&t.spatialReference.isWGS84?111319.49079327357:1;if(r=this._vxl.add_layer(t.serviceRoot,i.ptr,i.byteCount,n,n,a.startTime,a.endTime,a.useTime,this._toWasmQuality(this.view.qualityProfile)),i.isReusable||this._vxl._free(i.ptr),r>=0){t.test?.constantUpscaling&&(this._setUpscalingLimits(0,.25,.25),this._setUpscalingLimits(1,.5,.5),this._setUpscalingLimits(2,.75,.75));const s=new AbortController;if(this._layers.set(r,{layerView:e,responses:new Map,outstandingRequestCount:0,abortController:s,needMemoryUsageUpdate:!1}),this.layerUid.push(e.layer.uid),!this._halfIntTexturesAvailable||has("mac")){const t=[];let r="";for(const s of e.layer.variables)"Int16"!==s.renderingFormat.type&&"UInt16"!==s.renderingFormat.type||(t.push(s.name),s.id===e.layer.currentVariableId&&(r=s.name));""!==r&&I.error("#addVoxelLayer_error()",e.layer,`The voxel layer '${e.layer.title}' cannot render the current variable '${r}' in this browser`),t.length>0&&I.warn("#addVoxelLayer_warning()",e.layer,`The voxel layer '${e.layer.title}' cannot render the variables '${t.toString()}' in this browser`)}if(!this._textureFloatLinearAvailable){const t=[];let r="";for(const s of e.layer.variables)"Float32"===s.renderingFormat.type&&(t.push(s.name),s.id===e.layer.currentVariableId&&(r=s.name));""!==r&&I.error("#addVoxelLayer_error()",e.layer,`The voxel layer '${e.layer.title}' cannot render the current variable '${r}' in this browser`),t.length>0&&I.warn("#addVoxelLayer_warning()",e.layer,`The voxel layer '${e.layer.title}' cannot render the variables '${t.toString()}' in this browser`)}return has("esri-mobile")&&I.warnOnce("Mobile support differs across devices. Voxel layer might not display as expected."),r}return-1}prepareRender(e){if(!this._vxl)return;const t=e.bindParameters.camera.viewForward,r=e.bindParameters.camera.eye;this._vxl.update_camera_pos_and_direction(r[0],r[1],r[2],t[0],t[1],t[2]);const s=this._vxl.cull();this._dbg(B.RequestResponse,"missingResourceCount="+s),this._moreToLoad=s>0,this._havePreparedWithAllLayers=0===this._newLayers.length,this._updateMemoryUsage()}render(e){if(!this._vxl||e.output!==T.Color)return;for(const r of this._newLayers){const e=this._addVoxelLayer(r.layerView);-1===e?r.rejectCallback(-1):r.resolveCallback(e)}if(this._newLayers=[],0===this._layers.size)return void this._dbg(B.Error,"No voxel layers but RenderPlugin instance is being asked to render!");this._lastFrameWasStationary=this.view.stationary,this._syncRequestsResponses(),this._beforeDraw(),this._vxl.begin_color_frame(!this.view._stage.renderer.isFeatureEnabled(C.HighResolutionVoxel),e.bindParameters.lighting.mainLight.direction[0],e.bindParameters.lighting.mainLight.direction[1],e.bindParameters.lighting.mainLight.direction[2]);const t=this._renderTargetToRestore.viewport;t.width===this._viewportWidth&&t.height===this._viewportHeight||(this._viewportWidth=t.width,this._viewportHeight=t.height,this._vxl.set_viewport(t.width,t.height),this._layers.forEach((e=>{e.needMemoryUsageUpdate=!0}))),0===t.x&&0===t.y||this._dbg(B.Error,"Unsupported viewport parameters detected!"),this.updateWasmCamera(e.bindParameters.camera),this._captureFrustum&&(this._frustum.update(e.bindParameters.camera),this._doCaptureFrustum()),this._vxl.draw(),this._afterDraw(),(this._moreToLoad||!this._havePreparedWithAllLayers&&this._layers.size>0)&&this._renderPluginContext.requestRender()}destroy(){this._dbg(B.Lifetime,"--destroy--"),this._removeRenderPlugin(),this._vxl&&(this._layers.forEach((e=>{e.abortController.abort()})),this._wasmMemBlocks.forEach((e=>{0!==e&&this._vxl._free(e)})),this._vxl.uninitialize_voxel_wasm(),this._vxl=null)}_initializeWasm(e){return this._vxl?Promise.resolve():(this._vxlPromise||(this._vxlPromise=x(e).then((e=>{if(this._vxl=e,this._vxlPromise=null,this._newLayers.length<=0)return this._dbg(B.Lifetime," no voxel layers left after WASM downloaded, removing RenderPlugin and destroying"),void this.destroy();const t=this._getTimeArgs(this.view?.timeExtent),r=this._vxl.addFunction(this._restoreFramebuffer.bind(this),"v"),s=this._vxl.addFunction(this._setBlendState.bind(this),"viiii"),i=this._vxl.addFunction(this._setFrontFace.bind(this),"vi"),a=this._vxl.addFunction(this._setRasterizerState.bind(this),"vi"),n=this._vxl.addFunction(this._setDepthStencilStateFunction.bind(this),"viii"),o=this._vxl.addFunction(this._setViewport.bind(this),"viiii"),l=this._vxl.addFunction(this._bindPreviousDepthToSlot.bind(this),"iii"),h=this._vxl.addFunction(this._modifyResourceCount.bind(this),"viii"),d=this._halfIntTexturesAvailable&&!has("mac"),u=this._textureFloatLinearAvailable;this._vxl.initialize_voxel_wasm(r,s,i,a,n,o,l,h,t.startTime,t.endTime,t.useTime,d,u),this._renderPluginContext&&this._renderPluginContext.requestRender()})).catch((()=>{for(const e of this._newLayers)e.rejectCallback(-2);this._dbg(B.Error," WASM failed to download, removing RenderPlugin and destroying"),this.destroy()}))),this._vxlPromise)}pickDepth(e,t,r){if(!this._vxl||!this._rctx||0===this._layers.size)return null;const s=r.viewport[3]-t;if(e<0||e>r.viewport[2]||t<0||t>r.viewport[3])return this._dbg(B.Error,`[js] pickDepth: outOfRange, screenXY=[${e.toFixed(0)}, ${s.toFixed(0)}]]`),null;this._beforeDraw();const i=r.viewForward,a=r.eye;this._vxl.update_camera_pos_and_direction(a[0],a[1],a[2],i[0],i[1],i[2]),this.updateWasmCamera(r),this._vxl.begin_frame();const n=this._vxl.pick_depth(e,s);if(this._afterDraw(),n.success){return n.distanceToCamera}return null}pickObject(e,t,r,s){if(!this._vxl||!this._rctx||0===this._layers.size)return null;const i=Math.round(e),a=Math.round(t);if(i<0||i>r.viewport[2]||a<0||a>r.viewport[3])return this._dbg(B.Error,`[js] pickObject: outOfRange, screenXY=[${i}, ${a}], vp=[${r.viewport.toString()}]`),null;this._beforeDraw();const n=r.viewForward,o=r.eye;this._vxl.update_camera_pos_and_direction(o[0],o[1],o[2],n[0],n[1],n[2]),this.updateWasmCamera(r),this._vxl.begin_frame();let l=null;if(0===s.length)l=this._vxl.pick_object(i,a,0,0);else{const e={str:JSON.stringify({layerIds:s}),byteCount:0,ptr:0,isReusable:!1};this._allocateBlock(e)&&(l=this._vxl.pick_object(i,a,e.ptr,e.byteCount),e.isReusable||this._vxl._free(e.ptr))}return this._afterDraw(),l}_beforeDraw(){this._renderTargetToRestore={fbo:this._rctx.getBoundFramebufferObject(),viewport:this._rctx.getViewport()},this._rctx.setPolygonOffsetFillEnabled(!1),this._rctx.setScissorTestEnabled(!1),this._rctx.setColorMask(!0,!0,!0,!0)}_afterDraw(){this._renderTargetToRestore.fbo=null,this._rctx.externalTextureUnitUpdate(this._vxl.get_texture_units_bound_in_frame(),this._vxl.get_active_texture_unit()),this._rctx.externalVertexArrayObjectUpdate(),this._rctx.externalVertexBufferUpdate(),this._rctx.externalProgramUpdate()}intersect(e,t,r,s,i){if(!this._vxl||!this._rctx||0===this._layers.size||!e.options.selectionMode||e.options.isFiltered)return;if(i[0]<0||i[0]>e.camera.viewport[2]||i[1]<0||i[1]>e.camera.viewport[3])return this._dbg(B.Error,`[js] VoxelWasmPerScene.intersect: outOfRange, screenXY=[${i[0].toFixed(0)}, ${i[1].toFixed(0)}]`),null;const a=[];this._layers.forEach((t=>{e.options.filteredLayerUids.includes(t.layerView.layer.uid)&&a.push(t.layerView.wasmLayerId)}));const n=this.pickObject(i[0],i[1],e.camera,a);if(null==n||-1===n.layerId)return;const o=this._layers.get(n.layerId);if(o){const t=o.layerView.layer.uid,i=n.distanceToCamera/h(r,s),a=d();a[0]=n.worldX,a[1]=n.worldY,a[2]=n.worldZ;const l={};if(null!=n.continuousValue&&null!=n.continuousValueUnits?l["Voxel.ServiceValue"]=`${n.continuousValue.toLocaleString()} ${n.continuousValueUnits}`:null!=n.uniqueValueLabel&&null!=n.uniqueValue?l["Voxel.ServiceValue"]=`${n.uniqueValueLabel} (${n.uniqueValue})`:null!=n.uniqueValue&&(l["Voxel.ServiceValue"]=`${n.uniqueValue}`),l["Voxel.ServiceVariableLabel"]=n.variableLabel,l["Voxel.Position"]=n.voxelSpacePosition,null!=n.epochTime&&null!=n.nativeTime&&null!=n.nativeTimeUnits){const e=new Date(n.epochTime);l["Voxel.ServiceLocalTime"]=e.toString(),l["Voxel.ServiceNativeTime"]=`${n.nativeTime.toLocaleString()} ${n.nativeTimeUnits}`}null!=n.depth&&null!=n.depthUnits&&(l["Voxel.ServiceDepth"]=`${n.depth.toLocaleString()} ${n.depthUnits}`);const u=n.faceNormal;l["Voxel.WorldPosition"]=`[${a[0]}, ${a[1]}, ${a[2]}]`;const _=e=>{const r=new v(a,t,(()=>this._createVoxelGraphic(o.layerView.layer,l)));e.set(this.type,r,i,u)},c=e.results,m=e.options.store===V.ALL;if((null==c.min.dist||i<c.min.dist)&&_(c.min),(null==c.max.dist||i>c.max.dist)&&_(c.max),m){const t=L(e.ray);_(t),e.results.all.push(t)}}}_createVoxelGraphic(e,r){return new t({layer:e,sourceLayer:e,attributes:r})}_toWasmQuality(e){switch(e){case"low":return 0;case"medium":return 1;case"high":return 2}}_setUpscalingLimits(e,t,r){this._vxl&&this._vxl.set_upscaling_limits(e,t,r)}};e([o({constructOnly:!0})],A.prototype,"view",void 0),A=e([l("esri.layers.VoxelWasmPerSceneView")],A);const M=A;export{M as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import t from"../Graphic.js";import r from"../request.js";import has from"../core/has.js";import s from"../core/Logger.js";import{isAbortError as i}from"../core/promiseUtils.js";import{watch as a,initial as n}from"../core/reactiveUtils.js";import{property as o}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import{subclass as l}from"../core/accessorSupport/decorators/subclass.js";import{h}from"../chunks/vec3.js";import{c as d}from"../chunks/vec3f64.js";import{renderSRFromViewSR as u}from"../geometry/support/coordinateSystem.js";import{PointIndex as _,PlaneIndex as c}from"../geometry/support/frustum.js";import{WasmCullMode as m,VoxelRequestType as p,UpdateFlags as g,ContainerType as f}from"../libs/vxl/enums.js";import{loadVoxelWASM as x}from"../libs/vxl/VxlModule.js";import{ViewingMode as y}from"../views/ViewingMode.js";import{VoxelTarget as v}from"../views/3d/layers/i3s/Intersector.js";import{Frustum as b}from"../views/3d/state/Frustum.js";import{RenderCoordsHelper as w}from"../views/3d/support/RenderCoordsHelper.js";import{ShaderOutput as T}from"../views/3d/webgl-engine/core/shaderLibrary/ShaderOutput.js";import{SyncRenderPlugin as R}from"../views/3d/webgl-engine/effects/RenderPlugin.js";import{newIntersectorResult as L}from"../views/3d/webgl-engine/lib/Intersector.js";import{IntersectorType as E,StoreResults as V}from"../views/3d/webgl-engine/lib/IntersectorInterfaces.js";import{RenderFeature as C}from"../views/3d/webgl-engine/lib/RenderFeature.js";import{RenderSlot as F}from"../views/3d/webgl-engine/lib/RenderSlot.js";import{ContextType as S}from"../views/webgl/contextUtils.js";import{CompareFunction as P,Face as U,StencilOperation as k}from"../views/webgl/enums.js";const I=s.getLogger("esri.layers.VoxelWasmPerSceneView");var B;!function(e){e[e.Lifetime=1]="Lifetime",e[e.RequestResponse=2]="RequestResponse",e[e.Rendering=3]="Rendering",e[e.Error=4]="Error"}(B||(B={}));let A=class extends R{constructor(e){super(e),this._halfIntTexturesAvailable=!1,this._textureFloatLinearAvailable=!1,this._havePreparedWithAllLayers=!1,this._renderPluginContext=null,this._vxlPromise=null,this._vxl=null,this._pluginIsActive=!1,this._moreToLoad=!1,this._viewportWidth=-1,this._viewportHeight=-1,this._newLayers=[],this._layers=new Map,this.renderSlots=[F.VOXEL],this._rctx=null,this._renderTargetToRestore=null,this._lastFrameWasStationary=!1,this._wasmMemBlockSizes=[512,1024,2048,4096,8192,16384,32768,65536],this._wasmMemBlocks=new Map,this._dbgFlags=new Set,this._captureFrustum=!1,this._frustum=null,this._frustumRenderableId=-1,this._renderCoordsHelper=null,this.type=E.VOXEL,this.slicePlaneEnabled=!0,this.isGround=!1,this.layerUid=[]}produces(){return!!this._vxl&&"local"===this.view.viewingMode}_dbg(e,t){this._dbgFlags.has(e)&&(e===B.Error?I.error(t):I.warn(t))}_removeRenderPlugin(){this._pluginIsActive&&this.view._stage&&(this._dbg(B.Lifetime,"--removeRenderPlugin--"),this.view._stage.removeRenderPlugin(this)),this._pluginIsActive=!1}initialize(){this._dbg(B.Lifetime,"--initialize--");for(const e of this._wasmMemBlockSizes)this._wasmMemBlocks.set(e,0);this.addHandles([a((()=>this.view.ready),(e=>{e&&"local"===this.view.viewingMode?(this._dbg(B.Lifetime,"view ready status changed to ready on a local view, calling addRenderPlugin"),this.view._stage.addRenderPlugin(this),this._pluginIsActive=!0):(this._dbg(B.Lifetime,"view ready status changed, not ready or not a local view!"),this._removeRenderPlugin())}),n),a((()=>this.view?.qualityProfile),(e=>{this._dbg(B.Rendering,"qualityProfile changed to "+e),this._vxl&&this._vxl.set_quality(this._toWasmQuality(e))}),n),a((()=>this.view?.timeExtent),(()=>{if(this._vxl){const e=this._getTimeArgs(this.view?.timeExtent);this._dbg(B.Rendering,"sceneView timeExtent changed to useTime="+e.useTime+" st="+e.startTime+" et="+e.endTime),this._vxl.set_scene_time_extent(e.startTime,e.endTime,e.useTime),this._renderPluginContext.requestRender()}}),n),a((()=>this.view?.stationary),(e=>{this._vxl&&e&&!this._lastFrameWasStationary&&this._renderPluginContext.requestRender()}))])}initializeRenderContext(e){this._dbg(B.Lifetime,"--initializeRenderContext--");const t=e.renderContext.rctx;t.type===S.WEBGL2?(this._renderPluginContext=e,this._rctx=e.renderContext.rctx,this._halfIntTexturesAvailable=!!this._rctx.capabilities.textureNorm16,this._textureFloatLinearAvailable=this._rctx.capabilities.textureFloatLinear,this._initializeWasm(t.gl)):this._dbg(B.Error,"WebGL 1 context only!")}uninitializeRenderContext(){this._renderPluginContext=null,this._rctx=null,this._dbg(B.Lifetime,"--uninitializeRenderContext--")}_restoreFramebuffer(){if(!this._renderTargetToRestore)return;const e=this._renderTargetToRestore.fbo;if(!!!this._rctx)return void this._dbg(B.Error,"no context in restoreFramebuffer!");this._rctx.bindFramebuffer(e,!0);const t=this._renderTargetToRestore.viewport;this._rctx.setViewport(t.x,t.y,t.width,t.height)}_bindPreviousDepthToSlot(e,t){const r=!!this._rctx,s=!!this._renderTargetToRestore;if(!r||!s)return 0;const i=this._renderTargetToRestore.fbo.depthStencilTexture;return i?(0===t?this._rctx.bindTexture(null,e,!0):this._rctx.bindTexture(i,e,!0),1):(this._dbg(B.Error,"no depth/stencil texture exists!"),0)}_modifyResourceCount(e,t,r){if(!this._rctx)return void this._dbg(B.Error,"modifyAllocation callback has no rendering context!");const s=e;1===r?this._rctx.instanceCounter.increment(s,t):this._rctx.instanceCounter.decrement(s,t)}_setBlendState(e,t,r,s){this._rctx?(this._rctx.setBlendingEnabled(1===e),this._rctx.setBlendFunction(t,r),this._rctx.setBlendEquation(s)):this._dbg(B.Error,"setBlendState callback has no rendering context!")}_setFrontFace(e){this._rctx?this._rctx.setFrontFace(e):this._dbg(B.Error,"setFrontFace callback has no rendering context!")}_setDepthStencilStateFunction(e,t,r){this._rctx?(this._rctx.setDepthFunction(r),this._rctx.setDepthTestEnabled(1===e),this._rctx.setDepthWriteEnabled(1===t),this._rctx.setStencilTestEnabled(!1),this._rctx.setStencilFunction(P.ALWAYS,0,255),this._rctx.setStencilOpSeparate(U.FRONT,k.KEEP,k.INCR,k.KEEP),this._rctx.setStencilOpSeparate(U.BACK,k.KEEP,k.DECR,k.KEEP)):this._dbg(B.Error,"setDepthStencilStateFunction callback has no rendering context!")}_setRasterizerState(e){if(this._rctx)switch(e){case m.None:this._rctx.setFaceCullingEnabled(!1);break;case m.Back:this._rctx.setCullFace(U.BACK),this._rctx.setFaceCullingEnabled(!0);break;case m.Front:this._rctx.setCullFace(U.FRONT),this._rctx.setFaceCullingEnabled(!0)}else this._dbg(B.Error,"setRasterizerState callback has no rendering context!")}_setViewport(e,t,r,s){this._rctx?this._rctx.setViewport(e,t,r,s):this._dbg(B.Error,"setViewport callback has no rendering context!")}_updateMemoryUsage(){this._layers.forEach(((e,t)=>{if(e.needMemoryUsageUpdate){const r=this._vxl.estimate_memory_usage(t);r>=0&&(e.needMemoryUsageUpdate=!1,e.layerView.setUsedMemory(r))}}))}_syncRequestsResponses(){this._layers.forEach(((e,t)=>{const s=[];e.responses.forEach(((r,i)=>{s.push(i),this._dbg(B.RequestResponse,"responding for requestID:"+i+" size:"+r.size),this._vxl.respond(t,i,r),r.requestType!==p.TreeIndex&&r.requestType!==p.Section||(e.needMemoryUsageUpdate=!0)}));const a=e.responses;for(const r of s)a.delete(r);const n=this._vxl.get_new_requests(t),o=e.abortController.signal;for(const l in n){e.outstandingRequestCount+=1,1===e.outstandingRequestCount&&e.layerView.updatingFlagChanged();const t=n[l],s={responseType:"array-buffer",signal:o};this._dbg(B.RequestResponse,"making requestID:"+l+" url:"+t.url),r(t.url,s).then((r=>{e.outstandingRequestCount-=1,0===e.outstandingRequestCount&&e.layerView.updatingFlagChanged(),this._dbg(B.RequestResponse,"have response for requestID:"+l);let s=0;if(r.data.byteLength>0){s=this._vxl._malloc(r.data.byteLength);const e=new Uint8Array(this._vxl.HEAPU8.buffer,s,r.data.byteLength),t=new Uint8Array(r.data);for(let s=0;s<r.data.byteLength;++s)e[s]=t[s]}a.set(+l,{responseType:t.responseType,ptr:s,size:r.data.byteLength,success:!0,requestType:t.requestType})})).catch((r=>{e.outstandingRequestCount-=1,0===e.outstandingRequestCount&&e.layerView.updatingFlagChanged(),i(r)||(this._dbg(B.Error,`requestID:${l} failed, error=${r.toString()}`),a.set(+l,{responseType:t.responseType,ptr:0,size:0,success:!1,requestType:t.requestType}))}))}}))}updateWasmCamera(e){this._vxl.set_projection_matrix.apply(this._vxl,e.projectionMatrix),this._vxl.set_view_matrix.apply(this._vxl,e.viewMatrix),this._vxl.set_near_far(e.near,e.far)}isUpdating(e){if(!this._vxl&&this._vxlPromise)return!0;const t=this._layers.get(e);return!!t&&t.outstandingRequestCount>0}getLayerTimes(e){const t=[];return this._layers.forEach(((r,s)=>{if(r.layerView.wasmLayerId===e.wasmLayerId){const r=this._vxl.get_layer_epoch_times(s,e.layer.currentVariableId);for(let e=0;e<r.length;++e)t.push(r[e])}})),t}getCurrentLayerTimeIndex(e){let t=0;return this._layers.forEach(((r,s)=>{r.layerView.wasmLayerId===e.wasmLayerId&&(t=this._vxl.get_layer_current_time_id(s))})),t}setEnabled(e,t){this._layers.forEach(((r,s)=>{r.layerView.wasmLayerId===e.wasmLayerId&&(this._vxl.set_enabled(s,t),r.needMemoryUsageUpdate=!0,this._renderPluginContext.requestRender())}))}setStaticSections(e,t){const r={mask:g.StaticSections,staticSections:t};return this._doMaskedUIUpdate(e,r,!0)}setCurrentVariable(e,t){const r={mask:g.CurrentVariable,currentVariable:t};return this._doMaskedUIUpdate(e,r,!0)}setRenderMode(e,t){const r={mask:g.RenderMode,renderMode:t};return this._doMaskedUIUpdate(e,r,!0)}setVerticalExaggerationAndOffset(e,t,r,s){const i={mask:g.ExaggerationAndOffset,volStyleDesc:{volumeId:t,verticalExaggeration:r,verticalOffset:s}};return this._doMaskedUIUpdate(e,i,!0)}setVariableStyles(e,t){const r={mask:g.VariableStyles,variableStyles:t};return this._doMaskedUIUpdate(e,r,!0)}setVolumeStyles(e,t){const r={mask:g.VolumeStyles,volumeStyles:t};return this._doMaskedUIUpdate(e,r,!0)}setEnableDynamicSections(e,t){const r={mask:g.ContainerVisibility,containerIsVisible:t,container:f.DynamicSections};return this._doMaskedUIUpdate(e,r,!0)}setEnableIsosurfaces(e,t){const r={mask:g.ContainerVisibility,containerIsVisible:t,container:f.Isosurfaces};return this._doMaskedUIUpdate(e,r,!0)}setEnableSections(e,t){const r={mask:g.ContainerVisibility,containerIsVisible:t,container:f.StaticSections};return this._doMaskedUIUpdate(e,r,!0)}setAnalysisSlice(e,t,r,s){const i={mask:g.AnalysisSlice,analysisSlice:{point:r,normal:s,enabled:t}};return this._doMaskedUIUpdate(e,i,!0)}_doMaskedUIUpdate(e,t,r){if(!this._vxl)return!1;let s=!1;return this._layers.forEach(((r,i)=>{if(r.layerView.wasmLayerId===e.wasmLayerId){const e={str:JSON.stringify(t),byteCount:0,ptr:0,isReusable:!1};this._allocateBlock(e)&&(s=1===this._vxl.handle_masked_ui_update(i,e.ptr,e.byteCount),e.isReusable||this._vxl._free(e.ptr))}})),s&&r&&this._renderPluginContext.requestRender(),s}_addTriangleToWasmBuffer(e,t,r,s,i){return e[3*t]=r[0],e[3*t+1]=r[1],e[3*t+2]=r[2],e[3*(t+=1)]=s[0],e[3*t+1]=s[1],e[3*t+2]=s[2],e[3*(t+=1)]=i[0],e[3*t+1]=i[1],e[3*t+2]=i[2],t+=1}_addNormalToWasmBuffer(e,t,r){return e[3*t]=r[0],e[3*t+1]=r[1],e[3*t+2]=r[2],t+=1}_doCaptureFrustum(){if(!this._vxl)return;const e=36,t=e/3,r=this._vxl._malloc(3*e*Float32Array.BYTES_PER_ELEMENT),s=new Float32Array(this._vxl.HEAPF32.buffer,r,3*e),i=this._vxl._malloc(3*t*Float32Array.BYTES_PER_ELEMENT),a=new Float32Array(this._vxl.HEAPF32.buffer,i,e),n=this._frustum.points[_.NEAR_BOTTOM_LEFT],o=this._frustum.points[_.NEAR_BOTTOM_RIGHT],l=this._frustum.points[_.NEAR_TOP_RIGHT],h=this._frustum.points[_.NEAR_TOP_LEFT],d=this._frustum.points[_.FAR_BOTTOM_LEFT],u=this._frustum.points[_.FAR_BOTTOM_RIGHT],m=this._frustum.points[_.FAR_TOP_RIGHT],p=this._frustum.points[_.FAR_TOP_LEFT];let g=0,f=0;const x=this._frustum.planes[c.NEAR];g=this._addTriangleToWasmBuffer(s,g,l,o,n),f=this._addNormalToWasmBuffer(a,f,x),g=this._addTriangleToWasmBuffer(s,g,n,h,l),f=this._addNormalToWasmBuffer(a,f,x);const y=this._frustum.planes[c.FAR];g=this._addTriangleToWasmBuffer(s,g,d,u,m),f=this._addNormalToWasmBuffer(a,f,y),g=this._addTriangleToWasmBuffer(s,g,m,p,d),f=this._addNormalToWasmBuffer(a,f,y);const v=this._frustum.planes[c.TOP];g=this._addTriangleToWasmBuffer(s,g,m,l,h),f=this._addNormalToWasmBuffer(a,f,v),g=this._addTriangleToWasmBuffer(s,g,h,p,m),f=this._addNormalToWasmBuffer(a,f,v);const b=this._frustum.planes[c.BOTTOM];g=this._addTriangleToWasmBuffer(s,g,n,o,u),f=this._addNormalToWasmBuffer(a,f,b),g=this._addTriangleToWasmBuffer(s,g,u,d,n),f=this._addNormalToWasmBuffer(a,f,b);const w=this._frustum.planes[c.LEFT];g=this._addTriangleToWasmBuffer(s,g,h,n,d),f=this._addNormalToWasmBuffer(a,f,w),g=this._addTriangleToWasmBuffer(s,g,d,p,h),f=this._addNormalToWasmBuffer(a,f,w);const T=this._frustum.planes[c.RIGHT];g=this._addTriangleToWasmBuffer(s,g,l,m,u),f=this._addNormalToWasmBuffer(a,f,T),g=this._addTriangleToWasmBuffer(s,g,u,o,l),f=this._addNormalToWasmBuffer(a,f,T),-1!==this._frustumRenderableId&&this._vxl.remove_generic_mesh(this._frustumRenderableId),this._frustumRenderableId=this._vxl.add_generic_mesh(r,3*e,i,e,255,0,0,64),this._vxl._free(r),this._vxl._free(i),this._captureFrustum=!1,this._renderPluginContext.requestRender()}captureFrustum(){null===this._renderCoordsHelper&&(this._renderCoordsHelper=w.create(y.Local,u(!1,this.view.spatialReference))),null===this._frustum&&(this._frustum=new b(this._renderCoordsHelper)),this._captureFrustum=!0,null!==this._renderPluginContext&&this._renderPluginContext.requestRender()}toggleFullVolumeExtentDraw(e){this._vxl&&this._layers.forEach(((t,r)=>{t.layerView.wasmLayerId===e.wasmLayerId&&(this._vxl.toggle_full_volume_extent_draw(r),this._renderPluginContext.requestRender())}))}addVoxelLayer(e){if(!this._vxl){const t={layerView:e,resolveCallback:null,rejectCallback:null},r=new Promise(((e,r)=>{t.resolveCallback=e,t.rejectCallback=r}));return this._newLayers.push(t),r}const t=this._addVoxelLayer(e);return t<0?Promise.reject(-1):Promise.resolve(t)}removeVoxelLayer(e){if(!this._vxl){const t=this._newLayers.findIndex((t=>e.uid===t.layerView.uid));t>=0&&(this._newLayers[t].resolveCallback(-1),this._newLayers.splice(t,1));const r=this._newLayers.length;return 0===r&&(this._dbg(B.Lifetime," no voxel layers left after removing a layer, removing RenderPlugin and destroying"),this.destroy()),r}let t=-1;this._layers.forEach(((r,s)=>{if(r.layerView.wasmLayerId===e.wasmLayerId){t=s,r.abortController.abort(),this._vxl.remove_layer(t);const i=this.layerUid.indexOf(e.layer.uid);-1!==i&&this.layerUid.splice(i,1)}})),t>=0&&this._layers.delete(t);const r=this._layers.size;return 0===r&&(this._dbg(B.Lifetime," no voxel layers left after removing a layer, removing RenderPlugin and destroying"),this.destroy()),r}_getBlockSize(e){for(const t of this._wasmMemBlockSizes)if(e<t)return t;return-1}_allocateBlock(e){e.byteCount=this._vxl.lengthBytesUTF8(e.str)+1;const t=this._getBlockSize(e.byteCount);return t<0?(e.isReusable=!1,e.ptr=this._vxl._malloc(e.byteCount)):(e.isReusable=!0,e.ptr=this._wasmMemBlocks.get(t),0===e.ptr&&(e.ptr=this._vxl._malloc(t),this._wasmMemBlocks.set(t,e.ptr))),0!==e.ptr&&(this._vxl.stringToUTF8(e.str,e.ptr,e.byteCount),!0)}_getTimeArgs(e){let t=-Number.MAX_VALUE,r=Number.MAX_VALUE,s=!1;return null!=e&&(e.isAllTime?s=!0:(null!=e.start&&(s=!0,t=e.start.getTime()/1e3),null!=e.end&&(s=!0,r=e.end.getTime()/1e3))),{startTime:t,endTime:r,useTime:s}}_addVoxelLayer(e){const t=e.layer;let r=-1;const s=t.getConfiguration();if(s.length<1)return-1;const i={str:s,byteCount:0,ptr:0,isReusable:!1};if(!this._allocateBlock(i))return-1;const a=this._getTimeArgs(this.view?.timeExtent),n=this.view.spatialReference.isWGS84&&t.spatialReference.isWGS84?111319.49079327357:1;if(r=this._vxl.add_layer(t.serviceRoot,i.ptr,i.byteCount,n,n,a.startTime,a.endTime,a.useTime,this._toWasmQuality(this.view.qualityProfile)),i.isReusable||this._vxl._free(i.ptr),r>=0){t.test?.constantUpscaling&&(this._setUpscalingLimits(0,.25,.25),this._setUpscalingLimits(1,.5,.5),this._setUpscalingLimits(2,.75,.75));const s=new AbortController;if(this._layers.set(r,{layerView:e,responses:new Map,outstandingRequestCount:0,abortController:s,needMemoryUsageUpdate:!1}),this.layerUid.push(e.layer.uid),!this._halfIntTexturesAvailable||has("mac")){const t=[];let r="";for(const s of e.layer.variables)"Int16"!==s.renderingFormat.type&&"UInt16"!==s.renderingFormat.type||(t.push(s.name),s.id===e.layer.currentVariableId&&(r=s.name));""!==r&&I.error("#addVoxelLayer_error()",e.layer,`The voxel layer '${e.layer.title}' cannot render the current variable '${r}' in this browser`),t.length>0&&I.warn("#addVoxelLayer_warning()",e.layer,`The voxel layer '${e.layer.title}' cannot render the variables '${t.toString()}' in this browser`)}if(!this._textureFloatLinearAvailable){const t=[];let r="";for(const s of e.layer.variables)"Float32"===s.renderingFormat.type&&(t.push(s.name),s.id===e.layer.currentVariableId&&(r=s.name));""!==r&&I.error("#addVoxelLayer_error()",e.layer,`The voxel layer '${e.layer.title}' cannot render the current variable '${r}' in this browser`),t.length>0&&I.warn("#addVoxelLayer_warning()",e.layer,`The voxel layer '${e.layer.title}' cannot render the variables '${t.toString()}' in this browser`)}return has("esri-mobile")&&I.warnOnce("Mobile support differs across devices. Voxel layer might not display as expected."),r}return-1}prepareRender(e){if(!this._vxl)return;const t=e.bindParameters.camera.viewForward,r=e.bindParameters.camera.eye;this._vxl.update_camera_pos_and_direction(r[0],r[1],r[2],t[0],t[1],t[2]);const s=this._vxl.cull();this._dbg(B.RequestResponse,"missingResourceCount="+s),this._moreToLoad=s>0,this._havePreparedWithAllLayers=0===this._newLayers.length,this._updateMemoryUsage()}render(e){if(!this._vxl||e.output!==T.Color)return;for(const r of this._newLayers){const e=this._addVoxelLayer(r.layerView);-1===e?r.rejectCallback(-1):r.resolveCallback(e)}if(this._newLayers=[],0===this._layers.size)return void this._dbg(B.Error,"No voxel layers but RenderPlugin instance is being asked to render!");this._lastFrameWasStationary=this.view.stationary,this._syncRequestsResponses(),this._beforeDraw(),this._vxl.begin_color_frame(!this.view._stage.renderer.isFeatureEnabled(C.HighResolutionVoxel),e.bindParameters.lighting.mainLight.direction[0],e.bindParameters.lighting.mainLight.direction[1],e.bindParameters.lighting.mainLight.direction[2]);const t=this._renderTargetToRestore.viewport;t.width===this._viewportWidth&&t.height===this._viewportHeight||(this._viewportWidth=t.width,this._viewportHeight=t.height,this._vxl.set_viewport(t.width,t.height),this._layers.forEach((e=>{e.needMemoryUsageUpdate=!0}))),0===t.x&&0===t.y||this._dbg(B.Error,"Unsupported viewport parameters detected!"),this.updateWasmCamera(e.bindParameters.camera),this._captureFrustum&&(this._frustum.update(e.bindParameters.camera),this._doCaptureFrustum()),this._vxl.draw(),this._afterDraw(),(this._moreToLoad||!this._havePreparedWithAllLayers&&this._layers.size>0)&&this._renderPluginContext.requestRender()}destroy(){this._dbg(B.Lifetime,"--destroy--"),this._removeRenderPlugin(),this._vxl&&(this._layers.forEach((e=>{e.abortController.abort()})),this._wasmMemBlocks.forEach((e=>{0!==e&&this._vxl._free(e)})),this._vxl.uninitialize_voxel_wasm(),this._vxl=null)}_initializeWasm(e){return this._vxl?Promise.resolve():(this._vxlPromise||(this._vxlPromise=x(e).then((e=>{if(this._vxl=e,this._vxlPromise=null,this._newLayers.length<=0)return this._dbg(B.Lifetime," no voxel layers left after WASM downloaded, removing RenderPlugin and destroying"),void this.destroy();const t=this._getTimeArgs(this.view?.timeExtent),r=this._vxl.addFunction(this._restoreFramebuffer.bind(this),"v"),s=this._vxl.addFunction(this._setBlendState.bind(this),"viiii"),i=this._vxl.addFunction(this._setFrontFace.bind(this),"vi"),a=this._vxl.addFunction(this._setRasterizerState.bind(this),"vi"),n=this._vxl.addFunction(this._setDepthStencilStateFunction.bind(this),"viii"),o=this._vxl.addFunction(this._setViewport.bind(this),"viiii"),l=this._vxl.addFunction(this._bindPreviousDepthToSlot.bind(this),"iii"),h=this._vxl.addFunction(this._modifyResourceCount.bind(this),"viii"),d=this._halfIntTexturesAvailable&&!has("mac"),u=this._textureFloatLinearAvailable;this._vxl.initialize_voxel_wasm(r,s,i,a,n,o,l,h,t.startTime,t.endTime,t.useTime,d,u),this._renderPluginContext&&this._renderPluginContext.requestRender()})).catch((()=>{for(const e of this._newLayers)e.rejectCallback(-2);this._dbg(B.Error," WASM failed to download, removing RenderPlugin and destroying"),this.destroy()}))),this._vxlPromise)}pickDepth(e,t,r){if(!this._vxl||!this._rctx||0===this._layers.size)return null;const s=r.viewport[3]-t;if(e<0||e>r.viewport[2]||t<0||t>r.viewport[3])return this._dbg(B.Error,`[js] pickDepth: outOfRange, screenXY=[${e.toFixed(0)}, ${s.toFixed(0)}]]`),null;this._beforeDraw();const i=r.viewForward,a=r.eye;this._vxl.update_camera_pos_and_direction(a[0],a[1],a[2],i[0],i[1],i[2]),this.updateWasmCamera(r),this._vxl.begin_frame();const n=this._vxl.pick_depth(e,s);if(this._afterDraw(),n.success){return n.distanceToCamera}return null}pickObject(e,t,r,s){if(!this._vxl||!this._rctx||0===this._layers.size)return null;const i=Math.round(e),a=Math.round(t);if(i<0||i>r.viewport[2]||a<0||a>r.viewport[3])return this._dbg(B.Error,`[js] pickObject: outOfRange, screenXY=[${i}, ${a}], vp=[${r.viewport.toString()}]`),null;this._beforeDraw();const n=r.viewForward,o=r.eye;this._vxl.update_camera_pos_and_direction(o[0],o[1],o[2],n[0],n[1],n[2]),this.updateWasmCamera(r),this._vxl.begin_frame();let l=null;if(0===s.length)l=this._vxl.pick_object(i,a,0,0);else{const e={str:JSON.stringify({layerIds:s}),byteCount:0,ptr:0,isReusable:!1};this._allocateBlock(e)&&(l=this._vxl.pick_object(i,a,e.ptr,e.byteCount),e.isReusable||this._vxl._free(e.ptr))}return this._afterDraw(),l}_beforeDraw(){this._renderTargetToRestore={fbo:this._rctx.getBoundFramebufferObject(),viewport:this._rctx.getViewport()},this._rctx.setPolygonOffsetFillEnabled(!1),this._rctx.setScissorTestEnabled(!1),this._rctx.setColorMask(!0,!0,!0,!0)}_afterDraw(){this._renderTargetToRestore.fbo=null,this._rctx.externalTextureUnitUpdate(this._vxl.get_texture_units_bound_in_frame(),this._vxl.get_active_texture_unit()),this._rctx.externalVertexArrayObjectUpdate(),this._rctx.externalVertexBufferUpdate(),this._rctx.externalProgramUpdate()}intersect(e,t,r,s,i){if(!this._vxl||!this._rctx||0===this._layers.size||!e.options.selectionMode||e.options.isFiltered)return;if(i[0]<0||i[0]>e.camera.viewport[2]||i[1]<0||i[1]>e.camera.viewport[3])return this._dbg(B.Error,`[js] VoxelWasmPerScene.intersect: outOfRange, screenXY=[${i[0].toFixed(0)}, ${i[1].toFixed(0)}]`),null;const a=[];this._layers.forEach((t=>{e.options.filteredLayerUids.includes(t.layerView.layer.uid)&&a.push(t.layerView.wasmLayerId)}));const n=this.pickObject(i[0],i[1],e.camera,a);if(null==n||-1===n.layerId)return;const o=this._layers.get(n.layerId);if(o){const t=o.layerView.layer.uid,i=n.distanceToCamera/h(r,s),a=d();a[0]=n.worldX,a[1]=n.worldY,a[2]=n.worldZ;const l={};if(null!=n.continuousValue&&null!=n.continuousValueUnits?l["Voxel.ServiceValue"]=`${n.continuousValue.toLocaleString()} ${n.continuousValueUnits}`:null!=n.uniqueValueLabel&&null!=n.uniqueValue?l["Voxel.ServiceValue"]=`${n.uniqueValueLabel} (${n.uniqueValue})`:null!=n.uniqueValue&&(l["Voxel.ServiceValue"]=`${n.uniqueValue}`),l["Voxel.ServiceVariableLabel"]=n.variableLabel,l["Voxel.Position"]=n.voxelSpacePosition,null!=n.epochTime&&null!=n.nativeTime&&null!=n.nativeTimeUnits){const e=new Date(n.epochTime);l["Voxel.ServiceLocalTime"]=e.toString(),l["Voxel.ServiceNativeTime"]=`${n.nativeTime.toLocaleString()} ${n.nativeTimeUnits}`}null!=n.depth&&null!=n.depthUnits&&(l["Voxel.ServiceDepth"]=`${n.depth.toLocaleString()} ${n.depthUnits}`);const u=n.faceNormal;l["Voxel.WorldPosition"]=`[${a[0]}, ${a[1]}, ${a[2]}]`;const _=e=>{const r=new v(a,t,(()=>this._createVoxelGraphic(o.layerView.layer,l)));e.set(this.type,r,i,u)},c=e.results,m=e.options.store===V.ALL;if((null==c.min.dist||i<c.min.dist)&&_(c.min),(null==c.max.dist||i>c.max.dist)&&_(c.max),m){const t=L(e.ray);_(t),e.results.all.push(t)}}}_createVoxelGraphic(e,r){return new t({layer:e,sourceLayer:e,attributes:r})}_toWasmQuality(e){switch(e){case"low":return 0;case"medium":return 1;case"high":return 2}}_setUpscalingLimits(e,t,r){this._vxl&&this._vxl.set_upscaling_limits(e,t,r)}};e([o({constructOnly:!0})],A.prototype,"view",void 0),A=e([l("esri.layers.VoxelWasmPerSceneView")],A);const M=A;export{M 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.28/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../request.js";import"../../../../core/has.js";import{throwIfAborted as o}from"../../../../core/promiseUtils.js";import{join as t}from"../../../../core/urlUtils.js";import{isHostedAgolService as s}from"../../../support/arcgisLayerUrl.js";import{arrayBufferToBase64 as r}from"../../../../support/base64Utils.js";const a=1e6,n=20*a,i=2e9,p=3;async function m({data:r,name:m,description:c},l,d){let f=null;try{const u=t(l,"uploads"),h=t(u,"info"),{data:w}=await e(h,{query:{f:"json"},responseType:"json"});o(d);const j=s(l),y=w.maxUploadFileSize*a,g=j?i:y,q=j?Math.min(n,y):n;if(r.size>g)throw new Error("Data too large");const T=t(u,"register"),{data:U}=await e(T,{query:{f:"json",itemName:m,description:c},responseType:"json",method:"post"});if(o(d),!U.success)throw new Error("Registration failed");const{itemID:z}=U.item;f=t(u,z);const E=t(f,"uploadPart"),D=Math.ceil(r.size/q),M=new Array;for(let e=0;e<D;++e)M.push(r.slice(e*q,Math.min((e+1)*q,r.size)));const P=M.slice().reverse(),b=new Array,x=async()=>{for(;0!==P.length;){const t=M.length-P.length,s=P.pop(),r=new FormData,a=s;r.append("f","json"),r.append("file",a),r.append("partId",`${t}`);const{data:n}=await e(E,{timeout:0,body:r,responseType:"json",method:"post"});if(o(d),!n.success)throw new Error("Part upload failed")}};for(let e=0;e<p&&0!==P.length;++e)b.push(x());await Promise.all(b);const A=t(f,"commit"),{data:F}=await e(A,{query:{f:"json",parts:M.map(((e,o)=>o)).join(",")},responseType:"json",method:"post"});if(o(d),!F.success)throw new Error("Commit failed");return F.item}catch(u){if(null!=f){const o=t(f,"delete");await e(o,{query:{f:"json"},responseType:"json",method:"post"})}throw u}}export{m as uploadItem};
5
+ import e from"../../../../request.js";import"../../../../core/has.js";import{throwIfAborted as t}from"../../../../core/promiseUtils.js";import{join as o}from"../../../../core/urlUtils.js";import{isHostedAgolService as r}from"../../../support/arcgisLayerUrl.js";import{arrayBufferToBase64 as s}from"../../../../support/base64Utils.js";const a=1e6,n=20*a,i=2e9,p=3;async function l({data:s,name:l,description:m},f,d){let u=null;try{const h=o(f,"uploads"),w=o(h,"info"),{data:j}=await e(w,{query:{f:"json"},responseType:"json"});t(d);const y=r(f),g=j.maxUploadFileSize*a,q=y?i:g,T=y?Math.min(n,g):n;if(s.size>q)throw new Error("Data too large");const U=o(h,"register"),{data:z}=await e(U,{query:{f:"json",itemName:c(l),description:m},responseType:"json",method:"post"});if(t(d),!z.success)throw new Error("Registration failed");const{itemID:A}=z.item;u=o(h,A);const E=o(u,"uploadPart"),D=Math.ceil(s.size/T),M=new Array;for(let e=0;e<D;++e)M.push(s.slice(e*T,Math.min((e+1)*T,s.size)));const P=M.slice().reverse(),b=new Array,x=async()=>{for(;0!==P.length;){const o=M.length-P.length,r=P.pop(),s=new FormData,a=r;s.append("f","json"),s.append("file",a),s.append("partId",`${o}`);const{data:n}=await e(E,{timeout:0,body:s,responseType:"json",method:"post"});if(t(d),!n.success)throw new Error("Part upload failed")}};for(let e=0;e<p&&0!==P.length;++e)b.push(x());await Promise.all(b);const F=o(u,"commit"),{data:I}=await e(F,{query:{f:"json",parts:M.map(((e,t)=>t)).join(",")},responseType:"json",method:"post"});if(t(d),!I.success)throw new Error("Commit failed");return I.item}catch(h){if(null!=u){const t=o(u,"delete");await e(t,{query:{f:"json"},responseType:"json",method:"post"})}throw h}}function c(e){return e.replaceAll("/","_").replaceAll("\\","_")}export{l as uploadItem};