@arcgis/core 4.33.0-next.20250206 → 4.33.0-next.20250208

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 (195) hide show
  1. package/applications/Components/styleUtils.js +1 -1
  2. package/applications/Components/webStyleSymbolUtils.js +1 -1
  3. package/arcade/treeAnalysis.js +1 -1
  4. package/arcade.js +1 -1
  5. package/assets/esri/core/workers/RemoteClient.js +1 -1
  6. package/assets/esri/core/workers/chunks/{5b20ee64248f2d5c937f.js → 08980b1ad3d5d67c6390.js} +1 -1
  7. package/assets/esri/core/workers/chunks/0a8e388e96af44deeabb.js +1 -0
  8. package/assets/esri/core/workers/chunks/{38cd7745b8ef1b8b6196.js → 12d6baeffd55a98a7c75.js} +1 -1
  9. package/assets/esri/core/workers/chunks/{b1f5344e57ee679a7e81.js → 140d0c4285c6978103ea.js} +7 -7
  10. package/assets/esri/core/workers/chunks/143a193fa3a6e645c8ac.js +1 -0
  11. package/assets/esri/core/workers/chunks/{2a7f5d09cdc0333fa4bd.js → 2611adb4f328f95ee508.js} +1 -1
  12. package/assets/esri/core/workers/chunks/2def7db73a776e759dae.js +1 -0
  13. package/assets/esri/core/workers/chunks/308ec51ff4a66f7fcb0d.js.LICENSE.txt +1 -1
  14. package/assets/esri/core/workers/chunks/{72cf9192292e5c85c6df.js → 32d3657dcae89b740f8b.js} +2 -2
  15. package/assets/esri/core/workers/chunks/{72cf9192292e5c85c6df.js.LICENSE.txt → 32d3657dcae89b740f8b.js.LICENSE.txt} +1 -1
  16. package/assets/esri/core/workers/chunks/354531dc2f0dea2ad96f.js.LICENSE.txt +1 -1
  17. package/assets/esri/core/workers/chunks/35e4af82a08b4eadbfab.js +1 -0
  18. package/assets/esri/core/workers/chunks/369a2b8484a8807bde38.js +1 -0
  19. package/assets/esri/core/workers/chunks/4040158835f9036967cd.js +2 -0
  20. package/assets/esri/core/workers/chunks/{1a2e1a414e651e988435.js.LICENSE.txt → 4040158835f9036967cd.js.LICENSE.txt} +1 -6
  21. package/assets/esri/core/workers/chunks/53810519ff5922b42cd2.js +1 -0
  22. package/assets/esri/core/workers/chunks/{15f850c9a1154fc57e5a.js → 5721557a1d8eab23a55b.js} +1 -1
  23. package/assets/esri/core/workers/chunks/594d923400fd74881833.js +1 -0
  24. package/assets/esri/core/workers/chunks/{32f5f00aab55ef16dcf1.js → 5b85f9da022742f602e2.js} +1 -1
  25. package/assets/esri/core/workers/chunks/62a1d60ad4bf6469c4dd.js +1 -0
  26. package/assets/esri/core/workers/chunks/{bab541feca7ab4d3f993.js → 6ea02ff25f051c08e6c3.js} +1 -1
  27. package/assets/esri/core/workers/chunks/{81aa8cc289fd02ca4da6.js → 7058001bf66f9f3d5d45.js} +1 -1
  28. package/assets/esri/core/workers/chunks/{e8ae8a11d8439e2a66ad.js → 706f867a9034d62a8ef7.js} +1 -1
  29. package/assets/esri/core/workers/chunks/77764ca90bdd13ee2167.js.LICENSE.txt +1 -1
  30. package/assets/esri/core/workers/chunks/{1ab83753d9eec0463461.js → 7b367bb0ed9c218ca595.js} +1 -1
  31. package/assets/esri/core/workers/chunks/{8e334fa440ae542e2e34.js → 7e49ddb5a2182f2c9ca6.js} +1 -1
  32. package/assets/esri/core/workers/chunks/8191dd3d7451b2e7b95e.js +1 -0
  33. package/assets/esri/core/workers/chunks/8c32cee395da0a7b9a8e.js +1 -0
  34. package/assets/esri/core/workers/chunks/{48ecc5a74fecbb2b9c6f.js → 8d8f5f08d730270e1165.js} +1 -1
  35. package/assets/esri/core/workers/chunks/94225d92afbdb10dfedb.js +1 -0
  36. package/assets/esri/core/workers/chunks/94490937dca566fe2640.js +1 -0
  37. package/assets/esri/core/workers/chunks/{b9ce0049e27a3e1ed9f9.js → 9b2fab133786e5d47631.js} +1 -1
  38. package/assets/esri/core/workers/chunks/{28374a64790342e1b5ae.js → 9d61590c4d21c7421925.js} +1 -1
  39. package/assets/esri/core/workers/chunks/b21b152fa15896577242.js.LICENSE.txt +1 -1
  40. package/assets/esri/core/workers/chunks/{5a25cef6355fd20e44e7.js → b765670b47d209d7655a.js} +2 -2
  41. package/assets/esri/core/workers/chunks/{5a25cef6355fd20e44e7.js.LICENSE.txt → b765670b47d209d7655a.js.LICENSE.txt} +1 -1
  42. package/assets/esri/core/workers/chunks/b97673755cd2cc5164e8.js +1 -0
  43. package/assets/esri/core/workers/chunks/bb9ab85a135d211637f6.js +1 -0
  44. package/assets/esri/core/workers/chunks/c26ffbff1115e76bcb0f.js +1 -0
  45. package/assets/esri/core/workers/chunks/c38c154062cd838dd144.js +1 -0
  46. package/assets/esri/core/workers/chunks/d29c3bf29fcd7fa31f1a.js +1 -0
  47. package/assets/esri/core/workers/chunks/d339dee99c4820b63f39.js +1 -0
  48. package/assets/esri/core/workers/chunks/de1f3c4b8000c2d73013.js +1 -0
  49. package/assets/esri/core/workers/chunks/{4decfae8bc5e80878bdd.js → de4384b5833a60e88e31.js} +1 -1
  50. package/assets/esri/core/workers/chunks/e37e5d2e233d7f6ccd52.js +314 -0
  51. package/assets/esri/core/workers/chunks/e4b3f2d5c43518b0cde7.js +1 -0
  52. package/assets/esri/core/workers/chunks/e5e3b6d00d27b5bb354f.js +1 -0
  53. package/assets/esri/core/workers/chunks/e93dea6b112ce8e2779b.js +1 -0
  54. package/assets/esri/core/workers/chunks/edb580ce96da6fd66503.js +1 -0
  55. package/assets/esri/core/workers/chunks/f14b318bab5efcf43419.js +1 -0
  56. package/assets/esri/core/workers/chunks/{24e47f748f0e4f815c6e.js → f32ca4381e804cc3481e.js} +1 -1
  57. package/assets/esri/core/workers/chunks/f9070edd8e0b2a57af79.js +1 -0
  58. package/assets/esri/themes/base/widgets/_ItemList.scss +6 -0
  59. package/assets/esri/themes/dark/main.css +1 -1
  60. package/assets/esri/themes/light/main.css +1 -1
  61. package/assets/esri/themes/light/view.css +1 -1
  62. package/chunks/ImageMaterial.glsl.js +4 -4
  63. package/geometry/Mesh.js +1 -1
  64. package/geometry/support/Indices.js +1 -1
  65. package/geometry/support/meshUtils/deduplicate.js +1 -1
  66. package/geometry/support/meshVertexSpaceUtils.js +1 -1
  67. package/geometry/support/triangulationUtils.js +1 -1
  68. package/interfaces.d.ts +61 -84
  69. package/layers/FeatureLayer.js +1 -1
  70. package/layers/SubtypeGroupLayer.js +1 -1
  71. package/layers/WCSLayer.js +1 -1
  72. package/layers/graphics/data/QueryEngineCapabilities.js +1 -1
  73. package/layers/graphics/sources/FeatureLayerSource.js +1 -1
  74. package/layers/graphics/sources/geojson/GeoJSONSourceWorker.js +1 -1
  75. package/layers/graphics/sources/support/MemorySourceWorker.js +1 -1
  76. package/layers/graphics/sources/support/clientSideDefaults.js +1 -1
  77. package/layers/graphics/sources/support/sourceUtils.js +1 -1
  78. package/layers/mixins/BlendLayer.js +1 -1
  79. package/layers/mixins/FeatureLayerBase.js +1 -1
  80. package/layers/mixins/OperationalLayer.js +1 -1
  81. package/layers/mixins/operationalLayerModuleMap.js +1 -1
  82. package/layers/support/SubtypeSublayer.js +1 -1
  83. package/layers/support/arcadeUtils.js +1 -1
  84. package/layers/support/commonProperties.js +1 -1
  85. package/layers/support/layersCreator.js +1 -1
  86. package/package.json +2 -2
  87. package/portal/support/layersLoader.js +1 -1
  88. package/portal/support/loadUtils.js +1 -1
  89. package/rest/imageService.js +1 -1
  90. package/rest/support/ImageSampleParameters.js +1 -1
  91. package/rest/support/ImageSampleResult.js +1 -1
  92. package/rest/support/ImageVolumeResult.js +1 -1
  93. package/support/TablesMixin.js +1 -1
  94. package/support/arcadeUtils.js +1 -1
  95. package/support/revision.js +1 -1
  96. package/symbols/WebStyleSymbol.js +1 -1
  97. package/symbols/cim/cimAnalyzer.js +1 -1
  98. package/symbols/cim/fitVectorMarker.js +5 -0
  99. package/symbols/support/previewCIMSymbol.js +1 -1
  100. package/symbols/support/previewSymbol3D.js +1 -1
  101. package/symbols/support/previewWebStyleSymbol.js +1 -1
  102. package/symbols/support/styleUtils.js +1 -1
  103. package/symbols/support/symbolUtils.js +1 -1
  104. package/symbols/support/utils.js +1 -1
  105. package/symbols/support/webStyleAcceptedFormats.js +5 -0
  106. package/symbols/support/webStyleSymbolUtils.js +1 -1
  107. package/views/2d/engine/webgl/TextureManager.js +1 -1
  108. package/views/2d/layers/features/schema/SourceSchema.js +1 -1
  109. package/views/2d/layers/features/sources/FeatureSource.js +1 -1
  110. package/views/2d/layers/features/sources/FeatureSourceQueryInfo.js +1 -1
  111. package/views/2d/layers/features/sources/strategies/DrillDownTileLoadStrategy.js +1 -1
  112. package/views/2d/layers/features/sources/strategies/PagedTileLoadStrategy.js +1 -1
  113. package/views/2d/layers/features/sources/strategies/ParquetLoadStrategy.js +1 -1
  114. package/views/2d/layers/features/sources/strategies/SnapshotLoadStrategy.js +1 -1
  115. package/views/2d/layers/features/sources/strategies/StreamLoadStrategy.js +1 -1
  116. package/views/3d/glTF/internal/resourceUtils.js +1 -1
  117. package/views/3d/layers/MediaLayerView3D.js +1 -1
  118. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  119. package/views/3d/layers/graphics/Graphics3DWebStyleSymbol.js +1 -1
  120. package/views/3d/layers/graphics/Labeler.js +1 -1
  121. package/views/3d/layers/graphics/pipeline/Feature3DPipeline.js +1 -1
  122. package/views/3d/layers/graphics/pipeline/Feature3DPipelineWorker.js +1 -1
  123. package/views/3d/layers/graphics/pipeline/Feature3DPipelineWorkerHandle.js +1 -1
  124. package/views/3d/layers/graphics/pipeline/PipelineCommand.js +1 -1
  125. package/views/3d/layers/graphics/pipeline/featureData/FeatureData.js +1 -1
  126. package/views/3d/layers/graphics/pipeline/featureData/processingUtils.js +1 -1
  127. package/views/3d/layers/graphics/pipeline/rendering/DirectRenderer.js +1 -1
  128. package/views/3d/layers/graphics/pipeline/rendering/FeaturePipelineRenderManager.js +1 -1
  129. package/views/3d/layers/graphics/pipeline/rendering/LodRenderer.js +1 -1
  130. package/views/3d/layers/graphics/pipeline/rendering/RenderCommandContext.js +1 -1
  131. package/views/3d/layers/graphics/pipeline/rendering/RenderCommandEncoder.js +1 -1
  132. package/views/3d/layers/graphics/pipeline/rendering/RenderGeometryBufferWriter.js +1 -1
  133. package/views/3d/layers/graphics/pipeline/symbolization/TestObjectSymbol.js +1 -1
  134. package/views/3d/layers/graphics/pipeline/symbolization/TestSymbol.js +1 -1
  135. package/views/3d/layers/graphics/pipeline/symbolization/UniqueValueFeatureRenderer.js +1 -1
  136. package/views/3d/layers/graphics/pipeline/symbolization/primitiveObjectUtils.js +1 -1
  137. package/views/3d/layers/graphics/pipeline/utils.js +5 -0
  138. package/views/3d/layers/graphics/webStyleUtils.js +1 -1
  139. package/views/3d/layers/graphics/wosrLoader.js +1 -1
  140. package/views/3d/webgl-engine/lib/GLTextureMaterial.js +1 -1
  141. package/views/3d/webgl-engine/lib/Texture.js +1 -1
  142. package/views/3d/webgl-engine/lib/TextureRepository.js +1 -1
  143. package/views/3d/webgl-engine/materials/DefaultBufferWriter.js +1 -1
  144. package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
  145. package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
  146. package/views/3d/webgl-engine/materials/HeatmapDensityMaterial.js +1 -1
  147. package/views/3d/webgl-engine/materials/ImageMaterial.js +1 -1
  148. package/views/3d/webgl-engine/materials/LineCalloutMaterial.js +1 -1
  149. package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
  150. package/views/3d/webgl-engine/materials/MeasurementArrowMaterial.js +1 -1
  151. package/views/3d/webgl-engine/materials/PatternMaterial.js +1 -1
  152. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  153. package/views/3d/webgl-engine/materials/ShadedColorMaterial.js +1 -1
  154. package/views/3d/webgl-engine/materials/internal/bufferWriterUtils.js +1 -1
  155. package/views/3d/webgl-engine/parts/RenderView.js +1 -1
  156. package/views/3d/webgl-engine/shaders/ImageMaterial.glsl.js +1 -1
  157. package/views/3d/webgl-engine/shaders/ImageMaterialTechnique.js +1 -1
  158. package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
  159. package/widgets/Editor/EditorViewModel.js +1 -1
  160. package/widgets/Editor/UpdateWorkflow.js +1 -1
  161. package/widgets/Editor/VisibleElements.js +1 -1
  162. package/widgets/Editor/components/FeatureList.js +1 -1
  163. package/widgets/Editor/components/UpdateFeaturePanelContent.js +1 -1
  164. package/widgets/Editor/workflowUtils.js +1 -1
  165. package/widgets/Editor.js +1 -1
  166. package/widgets/Feature/support/arcadeFeatureUtils.js +1 -1
  167. package/widgets/Sketch.js +1 -1
  168. package/widgets/support/UtilityNetworkAssociations/UtilityNetworkAssociationsViewModel.js +1 -1
  169. package/assets/esri/core/workers/chunks/07bff9e742f3e5877f3f.js +0 -1
  170. package/assets/esri/core/workers/chunks/1100d9d114287b6443e2.js +0 -1
  171. package/assets/esri/core/workers/chunks/1a2e1a414e651e988435.js +0 -2
  172. package/assets/esri/core/workers/chunks/287362f9af132fafe4de.js +0 -1
  173. package/assets/esri/core/workers/chunks/2adc533dadcb018a9755.js +0 -1
  174. package/assets/esri/core/workers/chunks/2ea5e5e6c4660a06b516.js +0 -1
  175. package/assets/esri/core/workers/chunks/3984bf01f055fc42bfbf.js +0 -1
  176. package/assets/esri/core/workers/chunks/41cd1a5c99ab3bbd1fb4.js +0 -1
  177. package/assets/esri/core/workers/chunks/5e7f16b312077ca8c18d.js +0 -1
  178. package/assets/esri/core/workers/chunks/6ec108bd955e064256b5.js +0 -1
  179. package/assets/esri/core/workers/chunks/6ef2514a6b7bbfb8e37d.js +0 -1
  180. package/assets/esri/core/workers/chunks/7b11bf5799ecb3640b48.js +0 -314
  181. package/assets/esri/core/workers/chunks/81efe1f47fd41b7a5cc1.js +0 -1
  182. package/assets/esri/core/workers/chunks/82d26884127ed772cc4b.js +0 -1
  183. package/assets/esri/core/workers/chunks/918bdba41fa470cf77fd.js +0 -1
  184. package/assets/esri/core/workers/chunks/91d2bdfa6e34c10b7f50.js +0 -1
  185. package/assets/esri/core/workers/chunks/92871ebb339a7b6ff29c.js +0 -1
  186. package/assets/esri/core/workers/chunks/991e0f619f1f81f94d56.js +0 -1
  187. package/assets/esri/core/workers/chunks/9a27824d94df702e6e28.js +0 -1
  188. package/assets/esri/core/workers/chunks/b3f9d7a676076a7557f5.js +0 -1
  189. package/assets/esri/core/workers/chunks/c1fd87af3129873369fd.js +0 -1
  190. package/assets/esri/core/workers/chunks/c4c2b94e5cee7b824093.js +0 -1
  191. package/assets/esri/core/workers/chunks/c85374360ac5e169af16.js +0 -1
  192. package/assets/esri/core/workers/chunks/c94ec324ecad77c53a87.js +0 -1
  193. package/assets/esri/core/workers/chunks/d175953337fa655dc6b0.js +0 -1
  194. package/assets/esri/core/workers/chunks/e26dc0c1654316bb1558.js +0 -1
  195. package/assets/esri/core/workers/chunks/fe817283bbcbca8fb296.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.33/esri/copyright.txt for details.
4
4
  */
5
- import{fromValues as e}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{BufferViewMat3f as t,BufferViewVec4f as r}from"../../../../geometry/support/buffer/BufferView.js";import{newLayout as s}from"../../support/buffer/InterleavedLayout.js";import{isHighlightOrOID as i,isColorOrColorEmission as o,isDepth as a,isColorEmissionHighlightOrOID as n}from"../core/shaderLibrary/ShaderOutput.js";import{olidEnabled as f}from"../effects/geometry/olidUtils.js";import{CullFaceOptions as c}from"../lib/basicInterfaces.js";import l from"../lib/GLMaterial.js";import{OITPolygonOffsetLimit as u}from"../lib/OrderIndependentTransparency.js";import{RenderSlot as p}from"../lib/RenderSlot.js";import{assert as h}from"../lib/Util.js";import{VertexAttribute as m}from"../lib/VertexAttribute.js";import{DefaultBufferWriter as d}from"./DefaultBufferWriter.js";import{Style as g}from"./PatternStyle.js";import{TriangleMaterial as A}from"./TriangleMaterial.js";import{VisualVariablePassParameters as T}from"./VisualVariablePassParameters.js";import{writeDefaultAttributes as b,writeBufferVec4 as v}from"./internal/bufferWriterUtils.js";import{vertexAttributeLocationsOID as O,vertexAttributeLocations as _,PatternTechnique as j}from"../shaders/PatternTechnique.js";import{PatternTechniqueConfiguration as C}from"../shaders/PatternTechniqueConfiguration.js";import{alphaCutoff as E}from"../../../../webscene/support/AlphaCutoff.js";class P extends A{constructor(e){super(e,I),this._configuration=new C,this.vertexAttributeLocations=f()?O:_,this.supportsEdges=!0,this.produces=new Map([[p.OPAQUE_MATERIAL,e=>i(e)],[p.TRANSPARENT_MATERIAL,e=>o(e)],[p.TRANSPARENT_MATERIAL_WITHOUT_NORMALS,e=>a(e)],[p.DRAPED_MATERIAL,e=>this.parameters.draped&&n(e)]])}getConfiguration(e,t){return this._configuration.output=e,this._configuration.cullFace=this.parameters.cullFace,this._configuration.hasVertexColors=this.parameters.hasVertexColors&&!this.parameters.vvColor,this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.polygonOffset=this.parameters.polygonOffset,this._configuration.style=this.parameters.style,this._configuration.draped=this.parameters.draped,this._configuration.oitPass=t.oitPass,this._configuration.enableOffset=t.camera.relativeElevation<u,this._configuration.terrainDepthTest=t.terrainDepthTest&&o(e),this._configuration.cullAboveTerrain=t.cullAboveTerrain,this._configuration.vvColor=!!this.parameters.vvColor,this._configuration}get visible(){return this.parameters.color[3]>=E}createGLMaterial(e){return new R(e)}createBufferWriter(){const e=s().vec3f(m.POSITION).vec4f(m.UVMAPSPACE);return this.parameters.draped||e.mat3f(m.BOUNDINGRECT),this.parameters.vvColor?e.f32(m.COLORFEATUREATTRIBUTE):e.vec4u8(m.COLOR),f()&&e.vec4u8(m.OBJECTANDLAYERIDCOLOR),new y(e)}}class R extends l{beginSlot(e){return this.getTechnique(j,e)}}class y extends d{write(e,s,i,o,a,n){b(i,o,this.vertexBufferLayout,e,s,a,n);for(const f of this.vertexBufferLayout.fields.keys()){const s=i.get(f),o=s?.indices;if(s&&o)switch(f){case m.UVMAPSPACE:{h(4===s.size);const e=a.getField(f,r);e&&v(s,e,n);break}case m.BOUNDINGRECT:{h(9===s.size);const r=a.getField(f,t);r&&L(s,e,r,n);break}}}}}function L(e,t,r,s){const{data:i,indices:o}=e,a=t,n=r.typedBuffer,f=r.typedBufferStride,c=o.length;s*=f;for(let l=0;l<c;++l){const e=9*o[l],t=i[e],r=i[e+1],c=i[e+2];n[s]=a[0]*t+a[4]*r+a[8]*c+a[12],n[s+1]=a[1]*t+a[5]*r+a[9]*c+a[13],n[s+2]=a[2]*t+a[6]*r+a[10]*c+a[14];for(let o=3;o<9;++o)n[s+o]=i[e+o];s+=f}}class I extends T{constructor(){super(...arguments),this.color=e(1,1,1,1),this.hasVertexColors=!1,this.polygonOffset=!1,this.hasSlicePlane=!1,this.cullFace=c.None,this.hasOccludees=!1,this.style=g.Cross,this.draped=!0}}export{I as Parameters,P as PatternMaterial};
5
+ import{fromValues as t}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{BufferViewMat3f as e,BufferViewVec4f as r}from"../../../../geometry/support/buffer/BufferView.js";import{newLayout as s}from"../../support/buffer/InterleavedLayout.js";import{isHighlightOrOID as i,isColorOrColorEmission as o,isDepth as a,isColorEmissionHighlightOrOID as n}from"../core/shaderLibrary/ShaderOutput.js";import{olidEnabled as f}from"../effects/geometry/olidUtils.js";import{CullFaceOptions as c}from"../lib/basicInterfaces.js";import l from"../lib/GLMaterial.js";import{OITPolygonOffsetLimit as u}from"../lib/OrderIndependentTransparency.js";import{RenderSlot as p}from"../lib/RenderSlot.js";import{assert as h}from"../lib/Util.js";import{VertexAttribute as m}from"../lib/VertexAttribute.js";import{DefaultBufferWriter as d}from"./DefaultBufferWriter.js";import{Style as g}from"./PatternStyle.js";import{TriangleMaterial as A}from"./TriangleMaterial.js";import{VisualVariablePassParameters as T}from"./VisualVariablePassParameters.js";import{writeDefaultAttributes as b,writeBufferVec4 as v}from"./internal/bufferWriterUtils.js";import{vertexAttributeLocationsOID as O,vertexAttributeLocations as _,PatternTechnique as j}from"../shaders/PatternTechnique.js";import{PatternTechniqueConfiguration as C}from"../shaders/PatternTechniqueConfiguration.js";import{alphaCutoff as E}from"../../../../webscene/support/AlphaCutoff.js";class P extends A{constructor(t){super(t,I),this._configuration=new C,this.vertexAttributeLocations=f()?O:_,this.supportsEdges=!0,this.produces=new Map([[p.OPAQUE_MATERIAL,t=>i(t)],[p.TRANSPARENT_MATERIAL,t=>o(t)],[p.TRANSPARENT_MATERIAL_WITHOUT_NORMALS,t=>a(t)],[p.DRAPED_MATERIAL,t=>this.parameters.draped&&n(t)]])}getConfiguration(t,e){return this._configuration.output=t,this._configuration.cullFace=this.parameters.cullFace,this._configuration.hasVertexColors=this.parameters.hasVertexColors&&!this.parameters.vvColor,this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.polygonOffset=this.parameters.polygonOffset,this._configuration.style=this.parameters.style,this._configuration.draped=this.parameters.draped,this._configuration.oitPass=e.oitPass,this._configuration.enableOffset=e.camera.relativeElevation<u,this._configuration.terrainDepthTest=e.terrainDepthTest&&o(t),this._configuration.cullAboveTerrain=e.cullAboveTerrain,this._configuration.vvColor=!!this.parameters.vvColor,this._configuration}get visible(){return this.parameters.color[3]>=E}createGLMaterial(t){return new R(t)}createBufferWriter(){const t=s().vec3f(m.POSITION).vec4f(m.UVMAPSPACE);return this.parameters.draped||t.mat3f(m.BOUNDINGRECT),this.parameters.vvColor?t.f32(m.COLORFEATUREATTRIBUTE):t.vec4u8(m.COLOR),f()&&t.vec4u8(m.OBJECTANDLAYERIDCOLOR),new y(t)}}class R extends l{beginSlot(t){return this.getTechnique(j,t)}}class y extends d{write(t,s,i,o,a,n){const f=b(i,o,this.vertexBufferLayout,t,s,a,n);for(const c of this.vertexBufferLayout.fields.keys()){const s=i.get(c),o=s?.indices;if(s&&o)switch(c){case m.UVMAPSPACE:{h(4===s.size);const t=a.getField(c,r);t&&v(s,t,n);break}case m.BOUNDINGRECT:{h(9===s.size);const r=a.getField(c,e);r&&L(s,t,r,n);break}}}return f}}function L(t,e,r,s){const{data:i,indices:o}=t,a=e,n=r.typedBuffer,f=r.typedBufferStride,c=o.length;s*=f;for(let l=0;l<c;++l){const t=9*o[l],e=i[t],r=i[t+1],c=i[t+2];n[s]=a[0]*e+a[4]*r+a[8]*c+a[12],n[s+1]=a[1]*e+a[5]*r+a[9]*c+a[13],n[s+2]=a[2]*e+a[6]*r+a[10]*c+a[14];for(let o=3;o<9;++o)n[s+o]=i[t+o];s+=f}}class I extends T{constructor(){super(...arguments),this.color=t(1,1,1,1),this.hasVertexColors=!1,this.polygonOffset=!1,this.hasSlicePlane=!1,this.cullFace=c.None,this.hasOccludees=!1,this.style=g.Cross,this.draped=!0}}export{I as Parameters,P as PatternMaterial};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../core/Logger.js";import{clamp as t}from"../../../../core/mathUtils.js";import{createRenderScreenPointArray3 as r}from"../../../../core/screenUtils.js";import{copy as i}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{i as s,d as a,f as n,h as o,g as l,c,l as p,j as h,t as f}from"../../../../chunks/vec32.js";import{create as m}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as u}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{PlaneIndex as T}from"../../../../geometry/support/frustum.js";import{create as d,distance2 as _,fromPoints as E,closestLineSegmentPoint as A}from"../../../../geometry/support/lineSegment.js";import{create as R,fromPoints as O,signedDistance as g,getNormal as I}from"../../../../geometry/support/plane.js";import{newLayout as S}from"../../support/buffer/InterleavedLayout.js";import{isHighlightOrOID as v,isColorOrColorEmission as P,isDepth as N,isColorEmissionHighlightOIDOrDepth as L,is2DGeometryOutput as b,ShaderOutput as C}from"../core/shaderLibrary/ShaderOutput.js";import{olidEnabled as U}from"../effects/geometry/olidUtils.js";import y from"../lib/GLMaterial.js";import{Material as D,RenderOccludedFlag as j}from"../lib/Material.js";import{RenderSlot as F}from"../lib/RenderSlot.js";import{isTranslationMatrix as w}from"../lib/Util.js";import{VertexAttribute as M}from"../lib/VertexAttribute.js";import{VisualVariablePassParameters as x}from"./VisualVariablePassParameters.js";import{LineMarkerAnchor as B}from"../shaders/LineMarkerTechniqueConfiguration.js";import{r as J}from"../../../../chunks/RibbonLine.glsl.js";import{vertexAttributeLocations as H,RibbonLineTechnique as z}from"../shaders/RibbonLineTechnique.js";import{RibbonLineTechniqueConfiguration as G,CapType as k}from"../shaders/RibbonLineTechniqueConfiguration.js";import{alphaCutoff as V}from"../../../../webscene/support/AlphaCutoff.js";var Z;!function(e){e[e.LEFT_JOIN_START=-2]="LEFT_JOIN_START",e[e.LEFT_JOIN_END=-1]="LEFT_JOIN_END",e[e.LEFT_CAP_START=-4]="LEFT_CAP_START",e[e.LEFT_CAP_END=-5]="LEFT_CAP_END",e[e.RIGHT_JOIN_START=2]="RIGHT_JOIN_START",e[e.RIGHT_JOIN_END=1]="RIGHT_JOIN_END",e[e.RIGHT_CAP_START=4]="RIGHT_CAP_START",e[e.RIGHT_CAP_END=5]="RIGHT_CAP_END"}(Z||(Z={}));class W extends D{constructor(e){super(e,q),this._configuration=new G,this.vertexAttributeLocations=H,this.produces=new Map([[F.OPAQUE_MATERIAL,e=>v(e)||P(e)&&this.parameters.renderOccluded===j.OccludeAndTransparentStencil],[F.OPAQUE_MATERIAL_WITHOUT_NORMALS,e=>N(e)],[F.OCCLUDER_MATERIAL,e=>L(e)&&this.parameters.renderOccluded===j.OccludeAndTransparentStencil],[F.TRANSPARENT_OCCLUDER_MATERIAL,e=>L(e)&&this.parameters.renderOccluded===j.OccludeAndTransparentStencil],[F.TRANSPARENT_MATERIAL,e=>P(e)&&this.parameters.writeDepth&&this.parameters.renderOccluded!==j.OccludeAndTransparentStencil],[F.TRANSPARENT_MATERIAL_WITHOUT_DEPTH,e=>P(e)&&!this.parameters.writeDepth&&this.parameters.renderOccluded!==j.OccludeAndTransparentStencil],[F.DRAPED_MATERIAL,e=>b(e)]])}getConfiguration(e,t){this._configuration.output=e,this._configuration.oitPass=t.oitPass,this._configuration.draped=t.slot===F.DRAPED_MATERIAL;const r=null!=this.parameters.stipplePattern&&e!==C.Highlight;return this._configuration.stippleEnabled=r,this._configuration.stippleOffColorEnabled=r&&null!=this.parameters.stippleOffColor,this._configuration.stipplePreferContinuous=r&&this.parameters.stipplePreferContinuous,this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.roundJoins="round"===this.parameters.join,this._configuration.capType=this.parameters.cap,this._configuration.applyMarkerOffset=null!=this.parameters.markerParameters&&$(this.parameters.markerParameters),this._configuration.hasPolygonOffset=this.parameters.hasPolygonOffset,this._configuration.writeDepth=this.parameters.writeDepth,this._configuration.vvSize=!!this.parameters.vvSize,this._configuration.vvColor=!!this.parameters.vvColor,this._configuration.vvOpacity=!!this.parameters.vvOpacity,this._configuration.innerColorEnabled=this.parameters.innerWidth>0&&null!=this.parameters.innerColor,this._configuration.falloffEnabled=this.parameters.falloff>0,this._configuration.hasOccludees=t.hasOccludees,this._configuration.occluder=this.parameters.renderOccluded===j.OccludeAndTransparentStencil,this._configuration.terrainDepthTest=t.terrainDepthTest&&P(e),this._configuration.cullAboveTerrain=t.cullAboveTerrain,this._configuration.wireframe=this.parameters.wireframe,this._configuration}get visible(){return this.parameters.color[3]>=V||null!=this.parameters.stipplePattern&&(this.parameters.stippleOffColor?.[3]??0)>V}intersectDraped({attributes:e,screenToWorldRatio:r},i,s,a,n,o){if(!s.options.selectionMode)return;const l=e.get(M.SIZE);let c=this.parameters.width;if(this.parameters.vvSize){const r=e.get(M.SIZEFEATUREATTRIBUTE).data[0];c*=t(this.parameters.vvSize.offset[0]+r*this.parameters.vvSize.factor[0],this.parameters.vvSize.minSize[0],this.parameters.vvSize.maxSize[0])}else l&&(c*=l.data[0]);const p=a[0],h=a[1],f=(c/2+4)*r;let m=Number.MAX_VALUE,u=0;const T=e.get(M.POSITION).data,d=K(this.parameters,e)?T.length-2:T.length-5;for(let _=0;_<d;_+=3){const e=T[_],r=T[_+1],i=(_+3)%T.length,s=p-e,a=h-r,n=T[i]-e,o=T[i+1]-r,l=t((n*s+o*a)/(n*n+o*o),0,1),c=n*l-s,f=o*l-a,d=c*c+f*f;d<m&&(m=d,u=_/3)}m<f*f&&n(o.dist,o.normal,u,!1)}intersect(r,f,m,u,d,R){if(!m.options.selectionMode||!r.visible)return;if(!w(f))return void e.getLogger("esri.views.3d.webgl-engine.materials.RibbonLineMaterial").error("intersection assumes a translation-only matrix");const S=r.attributes,v=S.get(M.POSITION).data;let P=this.parameters.width;if(this.parameters.vvSize){const e=S.get(M.SIZEFEATUREATTRIBUTE).data[0];P*=t(this.parameters.vvSize.offset[0]+e*this.parameters.vvSize.factor[0],this.parameters.vvSize.minSize[0],this.parameters.vvSize.maxSize[0])}else S.has(M.SIZE)&&(P*=S.get(M.SIZE).data[0]);const N=m.camera,L=se;i(L,m.point);const b=P*N.pixelRatio/2+4*N.pixelRatio;s(ue[0],L[0]-b,L[1]+b,0),s(ue[1],L[0]+b,L[1]+b,0),s(ue[2],L[0]+b,L[1]-b,0),s(ue[3],L[0]-b,L[1]-b,0);for(let e=0;e<4;e++)if(!N.unprojectFromRenderScreen(ue[e],Te[e]))return;O(N.eye,Te[0],Te[1],de),O(N.eye,Te[1],Te[2],_e),O(N.eye,Te[2],Te[3],Ee),O(N.eye,Te[3],Te[0],Ae);let C=Number.MAX_VALUE,U=0;const y=K(this.parameters,S)?v.length-2:v.length-5;for(let e=0;e<y;e+=3){ee[0]=v[e]+f[12],ee[1]=v[e+1]+f[13],ee[2]=v[e+2]+f[14];const t=(e+3)%v.length;if(te[0]=v[t]+f[12],te[1]=v[t+1]+f[13],te[2]=v[t+2]+f[14],g(de,ee)<0&&g(de,te)<0||g(_e,ee)<0&&g(_e,te)<0||g(Ee,ee)<0&&g(Ee,te)<0||g(Ae,ee)<0&&g(Ae,te)<0)continue;if(N.projectToRenderScreen(ee,ae),N.projectToRenderScreen(te,ne),ae[2]<0&&ne[2]>0){a(re,ee,te);const e=N.frustum,t=-g(e[T.NEAR],ee)/n(re,I(e[T.NEAR]));o(re,re,t),l(ee,ee,re),N.projectToRenderScreen(ee,ae)}else if(ae[2]>0&&ne[2]<0){a(re,te,ee);const e=N.frustum,t=-g(e[T.NEAR],te)/n(re,I(e[T.NEAR]));o(re,re,t),l(te,te,re),N.projectToRenderScreen(te,ne)}else if(ae[2]<0&&ne[2]<0)continue;ae[2]=0,ne[2]=0;const r=_(E(ae,ne,ce),L);r<C&&(C=r,c(oe,ee),c(le,te),U=e/3)}const D=m.rayBegin,j=m.rayEnd;if(C<b*b){let e=Number.MAX_VALUE;if(A(E(oe,le,ce),E(D,j,pe),ie)){a(ie,ie,D);const t=p(ie);o(ie,ie,1/t),e=t/h(D,j)}R(e,ie,U,!1)}}get _layout(){const e=S().vec3f(M.POSITION).vec3f(M.PREVPOSITION).vec3f(M.NEXTPOSITION).f32(M.SUBDIVISIONFACTOR).vec2f(M.UV0);return this.parameters.vvSize?e.f32(M.SIZEFEATUREATTRIBUTE):e.f32(M.SIZE),this.parameters.vvColor?e.f32(M.COLORFEATUREATTRIBUTE):e.vec4f(M.COLOR),this.parameters.vvOpacity&&e.f32(M.OPACITYFEATUREATTRIBUTE),U()&&e.vec4u8(M.OBJECTANDLAYERIDCOLOR),e}createBufferWriter(){return new X(this._layout,this.parameters)}createGLMaterial(e){return new Y(e)}validateParameters(e){"miter"!==e.join&&(e.miterLimit=0),null!=e.markerParameters&&(e.markerScale=e.markerParameters.width/e.width)}}class Y extends y{constructor(){super(...arguments),this._stipplePattern=null}dispose(){super.dispose(),this._stippleTextures.release(this._stipplePattern),this._stipplePattern=null}beginSlot(e){const t=this._material.parameters.stipplePattern;return this._stipplePattern!==t&&(this._material.setParameters({stippleTexture:this._stippleTextures.swap(t,this._stipplePattern)}),this._stipplePattern=t),this.getTechnique(z,e)}}class q extends x{constructor(){super(...arguments),this.width=0,this.color=u,this.join="miter",this.cap=k.BUTT,this.miterLimit=5,this.writeDepth=!0,this.hasPolygonOffset=!1,this.stippleTexture=null,this.stipplePreferContinuous=!0,this.markerParameters=null,this.markerScale=1,this.hasSlicePlane=!1,this.vvFastUpdate=!1,this.isClosed=!1,this.falloff=0,this.innerWidth=0,this.wireframe=!1}get transparent(){return this.color[3]<1||null!=this.stipplePattern&&(this.stippleOffColor?.[3]??0)<1}}class X{constructor(e,t){this.vertexBufferLayout=e,this._parameters=t,this.numJoinSubdivisions=0;const r=t.stipplePattern?1:0;switch(this._parameters.join){case"miter":case"bevel":this.numJoinSubdivisions=r;break;case"round":this.numJoinSubdivisions=J+r}}_isClosed(e){return K(this._parameters,e)}allocate(e){return this.vertexBufferLayout.createBuffer(e)}elementCount(e){const t=2,r=e.get(M.POSITION).indices.length/2+1,i=this._isClosed(e);let s=i?2:2*t;return s+=((i?r:r-1)-(i?0:1))*(2*this.numJoinSubdivisions+4),s+=2,this._parameters.wireframe&&(s=2+4*(s-2)),s}write(e,t,r,i,a,n){const o=he,l=fe,p=me,m=r.get(M.POSITION),u=m.indices,T=m.data.length/3,d=r.get(M.DISTANCETOSTART)?.data;u&&u.length!==2*(T-1)&&console.warn("RibbonLineMaterial does not support indices");const _=r.get(M.SIZEFEATUREATTRIBUTE)?.data[0]??r.get(M.SIZE)?.data[0]??1;let E=[1,1,1,1],A=0;const R=this.vertexBufferLayout.fields.has(M.COLORFEATUREATTRIBUTE);R?A=r.get(M.COLORFEATUREATTRIBUTE).data[0]:r.has(M.COLOR)&&(E=r.get(M.COLOR).data);const O=this.vertexBufferLayout.fields.has(M.OPACITYFEATUREATTRIBUTE),g=O?r.get(M.OPACITYFEATUREATTRIBUTE).data[0]:0,I=new Float32Array(a.buffer),S=U()?new Uint8Array(a.buffer):null,v=this.vertexBufferLayout.stride/4;let P=n*v;const N=P;let L=0;const b=d?(e,t,r)=>L=d[r]:(e,t,r)=>L+=h(e,t),C=(e,t,r,s,a,n,o)=>{if(I[P++]=t[0],I[P++]=t[1],I[P++]=t[2],I[P++]=e[0],I[P++]=e[1],I[P++]=e[2],I[P++]=r[0],I[P++]=r[1],I[P++]=r[2],I[P++]=s,I[P++]=o,I[P++]=a,I[P++]=_,R)I[P++]=A;else{const e=Math.min(4*n,E.length-4);I[P++]=E[e],I[P++]=E[e+1],I[P++]=E[e+2],I[P++]=E[e+3]}O&&(I[P++]=g),U()&&(i&&(S[4*P]=i[0],S[4*P+1]=i[1],S[4*P+2]=i[2],S[4*P+3]=i[3]),P++)};P+=v,s(l,m.data[0],m.data[1],m.data[2]),e&&f(l,l,e);const y=this._isClosed(r);if(y){const t=m.data.length-3;s(o,m.data[t],m.data[t+1],m.data[t+2]),e&&f(o,o,e)}else s(p,m.data[3],m.data[4],m.data[5]),e&&f(p,p,e),C(l,l,p,1,Z.LEFT_CAP_START,0,0),C(l,l,p,1,Z.RIGHT_CAP_START,0,0),c(o,l),c(l,p);const D=y?0:1,j=y?T:T-1;for(let h=D;h<j;h++){const t=(h+1)%T*3;s(p,m.data[t],m.data[t+1],m.data[t+2]),e&&f(p,p,e),b(o,l,h),C(o,l,p,0,Z.LEFT_JOIN_END,h,L),C(o,l,p,0,Z.RIGHT_JOIN_END,h,L);const r=this.numJoinSubdivisions;for(let e=0;e<r;++e){const t=(e+1)/(r+1);C(o,l,p,t,Z.LEFT_JOIN_END,h,L),C(o,l,p,t,Z.RIGHT_JOIN_END,h,L)}C(o,l,p,1,Z.LEFT_JOIN_START,h,L),C(o,l,p,1,Z.RIGHT_JOIN_START,h,L),c(o,l),c(l,p)}y?(s(p,m.data[3],m.data[4],m.data[5]),e&&f(p,p,e),L=b(o,l,j),C(o,l,p,0,Z.LEFT_JOIN_END,D,L),C(o,l,p,0,Z.RIGHT_JOIN_END,D,L)):(L=b(o,l,j),C(o,l,l,0,Z.LEFT_CAP_END,j,L),C(o,l,l,0,Z.RIGHT_CAP_END,j,L)),Q(I,N+v,I,N,v);P=Q(I,P-v,I,P,v),this._parameters.wireframe&&this._addWireframeVertices(a,N,P,v)}_addWireframeVertices(e,t,r,i){const s=new Float32Array(e.buffer,r*Float32Array.BYTES_PER_ELEMENT),a=new Float32Array(e.buffer,t*Float32Array.BYTES_PER_ELEMENT,r-t);let n=0;const o=e=>n=Q(a,e,s,n,i);for(let l=0;l<a.length-1;l+=2*i)o(l),o(l+2*i),o(l+1*i),o(l+2*i),o(l+1*i),o(l+3*i)}}function Q(e,t,r,i,s){for(let a=0;a<s;a++)r[i++]=e[t++];return i}function K(e,t){if(!e.isClosed)return!1;return t.get(M.POSITION).indices.length>2}function $(e){return e.anchor===B.Tip&&e.hideOnShortSegments&&"begin-end"===e.placement&&e.worldSpace}const ee=m(),te=m(),re=m(),ie=m(),se=m(),ae=r(),ne=r(),oe=m(),le=m(),ce=d(),pe=d(),he=m(),fe=m(),me=m(),ue=[r(),r(),r(),r()],Te=[m(),m(),m(),m()],de=R(),_e=R(),Ee=R(),Ae=R();export{q as Parameters,W as RibbonLineMaterial};
5
+ import e from"../../../../core/Logger.js";import{clamp as t}from"../../../../core/mathUtils.js";import{createRenderScreenPointArray3 as r}from"../../../../core/screenUtils.js";import{copy as i}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{i as s,d as a,f as n,h as o,g as l,c,l as p,j as h,t as u}from"../../../../chunks/vec32.js";import{create as f}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as m}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{PlaneIndex as T}from"../../../../geometry/support/frustum.js";import{create as d,distance2 as _,fromPoints as E,closestLineSegmentPoint as A}from"../../../../geometry/support/lineSegment.js";import{create as R,fromPoints as O,signedDistance as g,getNormal as I}from"../../../../geometry/support/plane.js";import{newLayout as S}from"../../support/buffer/InterleavedLayout.js";import{isHighlightOrOID as v,isColorOrColorEmission as P,isDepth as N,isColorEmissionHighlightOIDOrDepth as L,is2DGeometryOutput as b,ShaderOutput as C}from"../core/shaderLibrary/ShaderOutput.js";import{olidEnabled as U}from"../effects/geometry/olidUtils.js";import y from"../lib/GLMaterial.js";import{Material as D,RenderOccludedFlag as j}from"../lib/Material.js";import{RenderSlot as F}from"../lib/RenderSlot.js";import{isTranslationMatrix as w}from"../lib/Util.js";import{VertexAttribute as M}from"../lib/VertexAttribute.js";import{VisualVariablePassParameters as x}from"./VisualVariablePassParameters.js";import{LineMarkerAnchor as B}from"../shaders/LineMarkerTechniqueConfiguration.js";import{r as J}from"../../../../chunks/RibbonLine.glsl.js";import{vertexAttributeLocations as H,RibbonLineTechnique as z}from"../shaders/RibbonLineTechnique.js";import{RibbonLineTechniqueConfiguration as G,CapType as k}from"../shaders/RibbonLineTechniqueConfiguration.js";import{alphaCutoff as V}from"../../../../webscene/support/AlphaCutoff.js";var Z;!function(e){e[e.LEFT_JOIN_START=-2]="LEFT_JOIN_START",e[e.LEFT_JOIN_END=-1]="LEFT_JOIN_END",e[e.LEFT_CAP_START=-4]="LEFT_CAP_START",e[e.LEFT_CAP_END=-5]="LEFT_CAP_END",e[e.RIGHT_JOIN_START=2]="RIGHT_JOIN_START",e[e.RIGHT_JOIN_END=1]="RIGHT_JOIN_END",e[e.RIGHT_CAP_START=4]="RIGHT_CAP_START",e[e.RIGHT_CAP_END=5]="RIGHT_CAP_END"}(Z||(Z={}));class W extends D{constructor(e){super(e,q),this._configuration=new G,this.vertexAttributeLocations=H,this.produces=new Map([[F.OPAQUE_MATERIAL,e=>v(e)||P(e)&&this.parameters.renderOccluded===j.OccludeAndTransparentStencil],[F.OPAQUE_MATERIAL_WITHOUT_NORMALS,e=>N(e)],[F.OCCLUDER_MATERIAL,e=>L(e)&&this.parameters.renderOccluded===j.OccludeAndTransparentStencil],[F.TRANSPARENT_OCCLUDER_MATERIAL,e=>L(e)&&this.parameters.renderOccluded===j.OccludeAndTransparentStencil],[F.TRANSPARENT_MATERIAL,e=>P(e)&&this.parameters.writeDepth&&this.parameters.renderOccluded!==j.OccludeAndTransparentStencil],[F.TRANSPARENT_MATERIAL_WITHOUT_DEPTH,e=>P(e)&&!this.parameters.writeDepth&&this.parameters.renderOccluded!==j.OccludeAndTransparentStencil],[F.DRAPED_MATERIAL,e=>b(e)]])}getConfiguration(e,t){this._configuration.output=e,this._configuration.oitPass=t.oitPass,this._configuration.draped=t.slot===F.DRAPED_MATERIAL;const r=null!=this.parameters.stipplePattern&&e!==C.Highlight;return this._configuration.stippleEnabled=r,this._configuration.stippleOffColorEnabled=r&&null!=this.parameters.stippleOffColor,this._configuration.stipplePreferContinuous=r&&this.parameters.stipplePreferContinuous,this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.roundJoins="round"===this.parameters.join,this._configuration.capType=this.parameters.cap,this._configuration.applyMarkerOffset=null!=this.parameters.markerParameters&&$(this.parameters.markerParameters),this._configuration.hasPolygonOffset=this.parameters.hasPolygonOffset,this._configuration.writeDepth=this.parameters.writeDepth,this._configuration.vvSize=!!this.parameters.vvSize,this._configuration.vvColor=!!this.parameters.vvColor,this._configuration.vvOpacity=!!this.parameters.vvOpacity,this._configuration.innerColorEnabled=this.parameters.innerWidth>0&&null!=this.parameters.innerColor,this._configuration.falloffEnabled=this.parameters.falloff>0,this._configuration.hasOccludees=t.hasOccludees,this._configuration.occluder=this.parameters.renderOccluded===j.OccludeAndTransparentStencil,this._configuration.terrainDepthTest=t.terrainDepthTest&&P(e),this._configuration.cullAboveTerrain=t.cullAboveTerrain,this._configuration.wireframe=this.parameters.wireframe,this._configuration}get visible(){return this.parameters.color[3]>=V||null!=this.parameters.stipplePattern&&(this.parameters.stippleOffColor?.[3]??0)>V}intersectDraped({attributes:e,screenToWorldRatio:r},i,s,a,n,o){if(!s.options.selectionMode)return;const l=e.get(M.SIZE);let c=this.parameters.width;if(this.parameters.vvSize){const r=e.get(M.SIZEFEATUREATTRIBUTE).data[0];c*=t(this.parameters.vvSize.offset[0]+r*this.parameters.vvSize.factor[0],this.parameters.vvSize.minSize[0],this.parameters.vvSize.maxSize[0])}else l&&(c*=l.data[0]);const p=a[0],h=a[1],u=(c/2+4)*r;let f=Number.MAX_VALUE,m=0;const T=e.get(M.POSITION).data,d=K(this.parameters,e)?T.length-2:T.length-5;for(let _=0;_<d;_+=3){const e=T[_],r=T[_+1],i=(_+3)%T.length,s=p-e,a=h-r,n=T[i]-e,o=T[i+1]-r,l=t((n*s+o*a)/(n*n+o*o),0,1),c=n*l-s,u=o*l-a,d=c*c+u*u;d<f&&(f=d,m=_/3)}f<u*u&&n(o.dist,o.normal,m,!1)}intersect(r,u,f,m,d,R){if(!f.options.selectionMode||!r.visible)return;if(!w(u))return void e.getLogger("esri.views.3d.webgl-engine.materials.RibbonLineMaterial").error("intersection assumes a translation-only matrix");const S=r.attributes,v=S.get(M.POSITION).data;let P=this.parameters.width;if(this.parameters.vvSize){const e=S.get(M.SIZEFEATUREATTRIBUTE).data[0];P*=t(this.parameters.vvSize.offset[0]+e*this.parameters.vvSize.factor[0],this.parameters.vvSize.minSize[0],this.parameters.vvSize.maxSize[0])}else S.has(M.SIZE)&&(P*=S.get(M.SIZE).data[0]);const N=f.camera,L=se;i(L,f.point);const b=P*N.pixelRatio/2+4*N.pixelRatio;s(me[0],L[0]-b,L[1]+b,0),s(me[1],L[0]+b,L[1]+b,0),s(me[2],L[0]+b,L[1]-b,0),s(me[3],L[0]-b,L[1]-b,0);for(let e=0;e<4;e++)if(!N.unprojectFromRenderScreen(me[e],Te[e]))return;O(N.eye,Te[0],Te[1],de),O(N.eye,Te[1],Te[2],_e),O(N.eye,Te[2],Te[3],Ee),O(N.eye,Te[3],Te[0],Ae);let C=Number.MAX_VALUE,U=0;const y=K(this.parameters,S)?v.length-2:v.length-5;for(let e=0;e<y;e+=3){ee[0]=v[e]+u[12],ee[1]=v[e+1]+u[13],ee[2]=v[e+2]+u[14];const t=(e+3)%v.length;if(te[0]=v[t]+u[12],te[1]=v[t+1]+u[13],te[2]=v[t+2]+u[14],g(de,ee)<0&&g(de,te)<0||g(_e,ee)<0&&g(_e,te)<0||g(Ee,ee)<0&&g(Ee,te)<0||g(Ae,ee)<0&&g(Ae,te)<0)continue;if(N.projectToRenderScreen(ee,ae),N.projectToRenderScreen(te,ne),ae[2]<0&&ne[2]>0){a(re,ee,te);const e=N.frustum,t=-g(e[T.NEAR],ee)/n(re,I(e[T.NEAR]));o(re,re,t),l(ee,ee,re),N.projectToRenderScreen(ee,ae)}else if(ae[2]>0&&ne[2]<0){a(re,te,ee);const e=N.frustum,t=-g(e[T.NEAR],te)/n(re,I(e[T.NEAR]));o(re,re,t),l(te,te,re),N.projectToRenderScreen(te,ne)}else if(ae[2]<0&&ne[2]<0)continue;ae[2]=0,ne[2]=0;const r=_(E(ae,ne,ce),L);r<C&&(C=r,c(oe,ee),c(le,te),U=e/3)}const D=f.rayBegin,j=f.rayEnd;if(C<b*b){let e=Number.MAX_VALUE;if(A(E(oe,le,ce),E(D,j,pe),ie)){a(ie,ie,D);const t=p(ie);o(ie,ie,1/t),e=t/h(D,j)}R(e,ie,U,!1)}}get _layout(){const e=S().vec3f(M.POSITION).vec3f(M.PREVPOSITION).vec3f(M.NEXTPOSITION).f32(M.SUBDIVISIONFACTOR).vec2f(M.UV0);return this.parameters.vvSize?e.f32(M.SIZEFEATUREATTRIBUTE):e.f32(M.SIZE),this.parameters.vvColor?e.f32(M.COLORFEATUREATTRIBUTE):e.vec4f(M.COLOR),this.parameters.vvOpacity&&e.f32(M.OPACITYFEATUREATTRIBUTE),U()&&e.vec4u8(M.OBJECTANDLAYERIDCOLOR),e}createBufferWriter(){return new X(this._layout,this.parameters)}createGLMaterial(e){return new Y(e)}validateParameters(e){"miter"!==e.join&&(e.miterLimit=0),null!=e.markerParameters&&(e.markerScale=e.markerParameters.width/e.width)}}class Y extends y{constructor(){super(...arguments),this._stipplePattern=null}dispose(){super.dispose(),this._stippleTextures.release(this._stipplePattern),this._stipplePattern=null}beginSlot(e){const t=this._material.parameters.stipplePattern;return this._stipplePattern!==t&&(this._material.setParameters({stippleTexture:this._stippleTextures.swap(t,this._stipplePattern)}),this._stipplePattern=t),this.getTechnique(z,e)}}class q extends x{constructor(){super(...arguments),this.width=0,this.color=m,this.join="miter",this.cap=k.BUTT,this.miterLimit=5,this.writeDepth=!0,this.hasPolygonOffset=!1,this.stippleTexture=null,this.stipplePreferContinuous=!0,this.markerParameters=null,this.markerScale=1,this.hasSlicePlane=!1,this.vvFastUpdate=!1,this.isClosed=!1,this.falloff=0,this.innerWidth=0,this.wireframe=!1}get transparent(){return this.color[3]<1||null!=this.stipplePattern&&(this.stippleOffColor?.[3]??0)<1}}class X{constructor(e,t){this.vertexBufferLayout=e,this._parameters=t,this.numJoinSubdivisions=0;const r=t.stipplePattern?1:0;switch(this._parameters.join){case"miter":case"bevel":this.numJoinSubdivisions=r;break;case"round":this.numJoinSubdivisions=J+r}}_isClosed(e){return K(this._parameters,e)}allocate(e){return this.vertexBufferLayout.createBuffer(e)}elementCount(e){const t=2,r=e.get(M.POSITION).indices.length/2+1,i=this._isClosed(e);let s=i?2:2*t;return s+=((i?r:r-1)-(i?0:1))*(2*this.numJoinSubdivisions+4),s+=2,this._parameters.wireframe&&(s=2+4*(s-2)),s}write(e,t,r,i,a,n){const o=he,l=ue,p=fe,f=r.get(M.POSITION),m=f.indices,T=f.data.length/3,d=r.get(M.DISTANCETOSTART)?.data;m&&m.length!==2*(T-1)&&console.warn("RibbonLineMaterial does not support indices");const _=r.get(M.SIZEFEATUREATTRIBUTE)?.data[0]??r.get(M.SIZE)?.data[0]??1;let E=[1,1,1,1],A=0;const R=this.vertexBufferLayout.fields.has(M.COLORFEATUREATTRIBUTE);R?A=r.get(M.COLORFEATUREATTRIBUTE).data[0]:r.has(M.COLOR)&&(E=r.get(M.COLOR).data);const O=this.vertexBufferLayout.fields.has(M.OPACITYFEATUREATTRIBUTE),g=O?r.get(M.OPACITYFEATUREATTRIBUTE).data[0]:0,I=new Float32Array(a.buffer),S=U()?new Uint8Array(a.buffer):null,v=this.vertexBufferLayout.stride/4;let P=n*v;const N=P;let L=0;const b=d?(e,t,r)=>L=d[r]:(e,t,r)=>L+=h(e,t),C=(e,t,r,s,a,n,o)=>{if(I[P++]=t[0],I[P++]=t[1],I[P++]=t[2],I[P++]=e[0],I[P++]=e[1],I[P++]=e[2],I[P++]=r[0],I[P++]=r[1],I[P++]=r[2],I[P++]=s,I[P++]=o,I[P++]=a,I[P++]=_,R)I[P++]=A;else{const e=Math.min(4*n,E.length-4);I[P++]=E[e],I[P++]=E[e+1],I[P++]=E[e+2],I[P++]=E[e+3]}O&&(I[P++]=g),U()&&(i&&(S[4*P]=i[0],S[4*P+1]=i[1],S[4*P+2]=i[2],S[4*P+3]=i[3]),P++)};P+=v,s(l,f.data[0],f.data[1],f.data[2]),e&&u(l,l,e);const y=this._isClosed(r);if(y){const t=f.data.length-3;s(o,f.data[t],f.data[t+1],f.data[t+2]),e&&u(o,o,e)}else s(p,f.data[3],f.data[4],f.data[5]),e&&u(p,p,e),C(l,l,p,1,Z.LEFT_CAP_START,0,0),C(l,l,p,1,Z.RIGHT_CAP_START,0,0),c(o,l),c(l,p);const D=y?0:1,j=y?T:T-1;for(let h=D;h<j;h++){const t=(h+1)%T*3;s(p,f.data[t],f.data[t+1],f.data[t+2]),e&&u(p,p,e),b(o,l,h),C(o,l,p,0,Z.LEFT_JOIN_END,h,L),C(o,l,p,0,Z.RIGHT_JOIN_END,h,L);const r=this.numJoinSubdivisions;for(let e=0;e<r;++e){const t=(e+1)/(r+1);C(o,l,p,t,Z.LEFT_JOIN_END,h,L),C(o,l,p,t,Z.RIGHT_JOIN_END,h,L)}C(o,l,p,1,Z.LEFT_JOIN_START,h,L),C(o,l,p,1,Z.RIGHT_JOIN_START,h,L),c(o,l),c(l,p)}y?(s(p,f.data[3],f.data[4],f.data[5]),e&&u(p,p,e),L=b(o,l,j),C(o,l,p,0,Z.LEFT_JOIN_END,D,L),C(o,l,p,0,Z.RIGHT_JOIN_END,D,L)):(L=b(o,l,j),C(o,l,l,0,Z.LEFT_CAP_END,j,L),C(o,l,l,0,Z.RIGHT_CAP_END,j,L)),Q(I,N+v,I,N,v);return P=Q(I,P-v,I,P,v),this._parameters.wireframe&&this._addWireframeVertices(a,N,P,v),null}_addWireframeVertices(e,t,r,i){const s=new Float32Array(e.buffer,r*Float32Array.BYTES_PER_ELEMENT),a=new Float32Array(e.buffer,t*Float32Array.BYTES_PER_ELEMENT,r-t);let n=0;const o=e=>n=Q(a,e,s,n,i);for(let l=0;l<a.length-1;l+=2*i)o(l),o(l+2*i),o(l+1*i),o(l+2*i),o(l+1*i),o(l+3*i)}}function Q(e,t,r,i,s){for(let a=0;a<s;a++)r[i++]=e[t++];return i}function K(e,t){if(!e.isClosed)return!1;return t.get(M.POSITION).indices.length>2}function $(e){return e.anchor===B.Tip&&e.hideOnShortSegments&&"begin-end"===e.placement&&e.worldSpace}const ee=f(),te=f(),re=f(),ie=f(),se=f(),ae=r(),ne=r(),oe=f(),le=f(),ce=d(),pe=d(),he=f(),ue=f(),fe=f(),me=[r(),r(),r(),r()],Te=[f(),f(),f(),f()],de=R(),_e=R(),Ee=R(),Ae=R();export{q as Parameters,W as RibbonLineMaterial};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{n as e,i as t,h as r,g as i}from"../../../../chunks/vec32.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as a}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{center as o,scale as n}from"../../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as c}from"../../../../geometry/support/buffer/BufferView.js";import{newLayout as h}from"../../support/buffer/InterleavedLayout.js";import{ShaderOutput as l,isColorOrOID as p,isColorOrColorEmission as u}from"../core/shaderLibrary/ShaderOutput.js";import{CullFaceOptions as f}from"../lib/basicInterfaces.js";import m from"../lib/GLMaterial.js";import{Material as d,MaterialParameters as S}from"../lib/Material.js";import{intersectTriangleGeometry as b}from"../lib/RayIntersections.js";import{RenderSlot as g}from"../lib/RenderSlot.js";import{assert as T}from"../lib/Util.js";import{VertexAttribute as E}from"../lib/VertexAttribute.js";import{writeDefaultAttributes as A,writePosition as j}from"./internal/bufferWriterUtils.js";import{vertexAttributeLocations as F,ShadedColorMaterialTechnique as w}from"../shaders/ShadedColorMaterialTechnique.js";import{ShadedColorMaterialTechniqueConfiguration as _}from"../shaders/ShadedColorMaterialTechniqueConfiguration.js";import{alphaCutoff as v}from"../../../../webscene/support/AlphaCutoff.js";class x extends d{constructor(e){super(e,O),this._configuration=new _,this.vertexAttributeLocations=F,this.supportsEdges=!0,this.produces=new Map([[g.OPAQUE_MATERIAL,e=>e===l.Highlight||p(e)&&!this.parameters.transparent],[g.TRANSPARENT_MATERIAL,e=>p(e)&&this.parameters.transparent&&this.parameters.writeDepth],[g.TRANSPARENT_MATERIAL_WITHOUT_DEPTH,e=>p(e)&&this.parameters.transparent&&!this.parameters.writeDepth]])}getConfiguration(e,t){return this._configuration.output=e,this._configuration.cullFace=this.parameters.cullFace,this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.transparent=this.parameters.transparent,this._configuration.writeDepth=this.parameters.writeDepth,this._configuration.screenSizeEnabled=this.parameters.screenSizeEnabled,this._configuration.shadingEnabled=this.parameters.shadingEnabled,this._configuration.oitPass=t.oitPass,this._configuration.terrainDepthTest=t.terrainDepthTest&&u(e),this._configuration.cullAboveTerrain=t.cullAboveTerrain,this._configuration}get visible(){return this.parameters.color[3]>=v}intersect(e,s,a,c,h,l){if(this.parameters.screenSizeEnabled){const s=e.attributes.get(E.OFFSET),p={applyToVertex:(e,o,n,c)=>{const h=t(P,s.data[3*c],s.data[3*c+1],s.data[3*c+2]),l=t(I,e,o,n);return r(h,h,this.parameters.screenSizeScale*a.camera.computeScreenPixelSizeAt(h)),i(l,l,h),[l[0],l[1],l[2]]},applyToAabb:e=>{const t=o(e,P);return n(e,this.parameters.screenSizeScale*a.camera.computeScreenPixelSizeAt(t))}};b(e,a,c,h,p,l)}else b(e,a,c,h,void 0,l)}createGLMaterial(e){return new z(e)}createBufferWriter(){return new M(this.parameters.screenSizeEnabled)}}class z extends m{beginSlot(e){return this.getTechnique(w,e)}}class O extends S{constructor(){super(...arguments),this.color=a(1,1,1,1),this.shadingTint=a(0,0,0,.25),this.shadingDirection=e(s(),[.5,-.5,-.5]),this.screenSizeScale=14,this.forceTransparentMode=!1,this.writeDepth=!0,this.hasSlicePlane=!1,this.cullFace=f.None,this.screenSizeEnabled=!1,this.shadingEnabled=!0}get transparent(){return this.color[3]<1||this.forceTransparentMode}}class M{constructor(e){this.screenSizeEnabled=e;const t=h().vec3f(E.POSITION).vec3f(E.NORMAL);this.screenSizeEnabled&&t.vec3f(E.OFFSET),this.vertexBufferLayout=t}elementCount(e){return e.get(E.POSITION).indices.length}write(e,t,r,i,s,a){if(A(r,i,this.vertexBufferLayout,e,t,s,a),this.screenSizeEnabled){if(!r.has(E.OFFSET))throw new Error(`${E.OFFSET} vertex attribute required for screenSizeEnabled ShadedColorMaterial`);{const e=r.get(E.OFFSET);T(3===e.size);const i=s.getField(E.OFFSET,c);if(!i)throw new Error("unable to acquire view for "+E.OFFSET);j(e,t,i,a)}}}}const P=s(),I=s();export{O as Parameters,x as ShadedColorMaterial};
5
+ import{n as e,i as t,h as r,g as i}from"../../../../chunks/vec32.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as a}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{center as o,scale as n}from"../../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as c}from"../../../../geometry/support/buffer/BufferView.js";import{newLayout as h}from"../../support/buffer/InterleavedLayout.js";import{ShaderOutput as l,isColorOrOID as p,isColorOrColorEmission as u}from"../core/shaderLibrary/ShaderOutput.js";import{CullFaceOptions as f}from"../lib/basicInterfaces.js";import m from"../lib/GLMaterial.js";import{Material as d,MaterialParameters as S}from"../lib/Material.js";import{intersectTriangleGeometry as b}from"../lib/RayIntersections.js";import{RenderSlot as g}from"../lib/RenderSlot.js";import{assert as T}from"../lib/Util.js";import{VertexAttribute as E}from"../lib/VertexAttribute.js";import{writeDefaultAttributes as A,writePosition as j}from"./internal/bufferWriterUtils.js";import{vertexAttributeLocations as F,ShadedColorMaterialTechnique as w}from"../shaders/ShadedColorMaterialTechnique.js";import{ShadedColorMaterialTechniqueConfiguration as _}from"../shaders/ShadedColorMaterialTechniqueConfiguration.js";import{alphaCutoff as v}from"../../../../webscene/support/AlphaCutoff.js";class x extends d{constructor(e){super(e,O),this._configuration=new _,this.vertexAttributeLocations=F,this.supportsEdges=!0,this.produces=new Map([[g.OPAQUE_MATERIAL,e=>e===l.Highlight||p(e)&&!this.parameters.transparent],[g.TRANSPARENT_MATERIAL,e=>p(e)&&this.parameters.transparent&&this.parameters.writeDepth],[g.TRANSPARENT_MATERIAL_WITHOUT_DEPTH,e=>p(e)&&this.parameters.transparent&&!this.parameters.writeDepth]])}getConfiguration(e,t){return this._configuration.output=e,this._configuration.cullFace=this.parameters.cullFace,this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.transparent=this.parameters.transparent,this._configuration.writeDepth=this.parameters.writeDepth,this._configuration.screenSizeEnabled=this.parameters.screenSizeEnabled,this._configuration.shadingEnabled=this.parameters.shadingEnabled,this._configuration.oitPass=t.oitPass,this._configuration.terrainDepthTest=t.terrainDepthTest&&u(e),this._configuration.cullAboveTerrain=t.cullAboveTerrain,this._configuration}get visible(){return this.parameters.color[3]>=v}intersect(e,s,a,c,h,l){if(this.parameters.screenSizeEnabled){const s=e.attributes.get(E.OFFSET),p={applyToVertex:(e,o,n,c)=>{const h=t(P,s.data[3*c],s.data[3*c+1],s.data[3*c+2]),l=t(I,e,o,n);return r(h,h,this.parameters.screenSizeScale*a.camera.computeScreenPixelSizeAt(h)),i(l,l,h),[l[0],l[1],l[2]]},applyToAabb:e=>{const t=o(e,P);return n(e,this.parameters.screenSizeScale*a.camera.computeScreenPixelSizeAt(t))}};b(e,a,c,h,p,l)}else b(e,a,c,h,void 0,l)}createGLMaterial(e){return new z(e)}createBufferWriter(){return new M(this.parameters.screenSizeEnabled)}}class z extends m{beginSlot(e){return this.getTechnique(w,e)}}class O extends S{constructor(){super(...arguments),this.color=a(1,1,1,1),this.shadingTint=a(0,0,0,.25),this.shadingDirection=e(s(),[.5,-.5,-.5]),this.screenSizeScale=14,this.forceTransparentMode=!1,this.writeDepth=!0,this.hasSlicePlane=!1,this.cullFace=f.None,this.screenSizeEnabled=!1,this.shadingEnabled=!0}get transparent(){return this.color[3]<1||this.forceTransparentMode}}class M{constructor(e){this.screenSizeEnabled=e;const t=h().vec3f(E.POSITION).vec3f(E.NORMAL);this.screenSizeEnabled&&t.vec3f(E.OFFSET),this.vertexBufferLayout=t}elementCount(e){return e.get(E.POSITION).indices.length}write(e,t,r,i,s,a){const o=A(r,i,this.vertexBufferLayout,e,t,s,a);if(this.screenSizeEnabled){if(!r.has(E.OFFSET))throw new Error(`${E.OFFSET} vertex attribute required for screenSizeEnabled ShadedColorMaterial`);{const e=r.get(E.OFFSET);T(3===e.size);const i=s.getField(E.OFFSET,c);if(!i)throw new Error("unable to acquire view for "+E.OFFSET);j(e,t,i,a)}}return o}}const P=s(),I=s();export{O as Parameters,x as ShadedColorMaterial};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{hasIdentityRotation as e,isOrthoNormal as t}from"../../../../../core/libs/gl-matrix-2/math/mat4.js";import{BufferViewVec4u8 as f,BufferViewVec4f as o,BufferViewFloat as r,BufferViewVec2f as i,BufferViewVec2i16 as s,BufferViewVec3f as n}from"../../../../../geometry/support/buffer/BufferView.js";import{assert as c}from"../../lib/Util.js";import{VertexAttribute as l}from"../../lib/VertexAttribute.js";function d(e,t,f,o=1){const{data:r,indices:i}=e,s=t.typedBuffer,n=t.typedBufferStride,c=i.length;if(f*=n,1===o)for(let l=0;l<c;++l)s[f]=r[i[l]],f+=n;else for(let l=0;l<c;++l){const e=r[i[l]];for(let t=0;t<o;t++)s[f]=e,f+=n}}function u(e,t,f){const{data:o,indices:r}=e,i=t.typedBuffer,s=t.typedBufferStride,n=r.length;f*=s;for(let c=0;c<n;++c){const e=2*r[c];i[f]=o[e],i[f+1]=o[e+1],f+=s}}function a(e,t,f,o){const{data:r,indices:i}=e,s=t.typedBuffer,n=t.typedBufferStride,c=i.length;if(f*=n,null==o||1===o)for(let l=0;l<c;++l){const e=3*i[l];s[f]=r[e],s[f+1]=r[e+1],s[f+2]=r[e+2],f+=n}else for(let l=0;l<c;++l){const e=3*i[l];for(let t=0;t<o;++t)s[f]=r[e],s[f+1]=r[e+1],s[f+2]=r[e+2],f+=n}}function p(e,t,f,o=1){const{data:r,indices:i}=e,s=t.typedBuffer,n=t.typedBufferStride,c=i.length;if(f*=n,1===o)for(let l=0;l<c;++l){const e=4*i[l];s[f]=r[e],s[f+1]=r[e+1],s[f+2]=r[e+2],s[f+3]=r[e+3],f+=n}else for(let l=0;l<c;++l){const e=4*i[l];for(let t=0;t<o;++t)s[f]=r[e],s[f+1]=r[e+1],s[f+2]=r[e+2],s[f+3]=r[e+3],f+=n}}function B(e,t,f){const o=e.typedBuffer,r=e.typedBufferStride;t*=r;for(let i=0;i<f;++i)o[t]=0,o[t+1]=0,o[t+2]=0,o[t+3]=0,t+=r}function y(e,t,f){const{data:o,indices:r}=e,i=t.typedBuffer,s=t.typedBufferStride,n=r.length;f*=s;for(let c=0;c<n;++c){const e=9*r[c];for(let t=0;t<9;++t)i[f+t]=o[e+t];f+=s}}function g(e,t,f){const{data:o,indices:r}=e,i=t.typedBuffer,s=t.typedBufferStride,n=r.length;f*=s;for(let c=0;c<n;++c){const e=16*r[c];for(let t=0;t<16;++t)i[f+t]=o[e+t];f+=s}}function b(t,f,o,r,i=1){if(!f)return void a(t,o,r,i);const{data:s,indices:n}=t,c=o.typedBuffer,l=o.typedBufferStride,d=n.length,u=f[0],p=f[1],B=f[2],y=f[4],g=f[5],b=f[6],O=f[8],h=f[9],S=f[10],N=f[12],R=f[13],E=f[14];r*=l;let F=0,z=0,A=0;const L=e(f)?e=>{F=s[e]+N,z=s[e+1]+R,A=s[e+2]+E}:e=>{const t=s[e],f=s[e+1],o=s[e+2];F=u*t+y*f+O*o+N,z=p*t+g*f+h*o+R,A=B*t+b*f+S*o+E};if(1===i)for(let e=0;e<d;++e)L(3*n[e]),c[r]=F,c[r+1]=z,c[r+2]=A,r+=l;else for(let e=0;e<d;++e){L(3*n[e]);for(let e=0;e<i;++e)c[r]=F,c[r+1]=z,c[r+2]=A,r+=l}}function O(f,o,r,i,s=1){if(!o)return void a(f,r,i,s);const{data:n,indices:c}=f,l=o,d=r.typedBuffer,u=r.typedBufferStride,p=c.length,B=l[0],y=l[1],g=l[2],b=l[4],O=l[5],h=l[6],S=l[8],N=l[9],R=l[10],E=!t(l),F=1e-6,z=1-F;i*=u;let A=0,L=0,m=0;const T=e(l)?e=>{A=n[e],L=n[e+1],m=n[e+2]}:e=>{const t=n[e],f=n[e+1],o=n[e+2];A=B*t+b*f+S*o,L=y*t+O*f+N*o,m=g*t+h*f+R*o};if(1===s)if(E)for(let e=0;e<p;++e){T(3*c[e]);const t=A*A+L*L+m*m;if(t<z&&t>F){const e=1/Math.sqrt(t);d[i]=A*e,d[i+1]=L*e,d[i+2]=m*e}else d[i]=A,d[i+1]=L,d[i+2]=m;i+=u}else for(let e=0;e<p;++e)T(3*c[e]),d[i]=A,d[i+1]=L,d[i+2]=m,i+=u;else for(let e=0;e<p;++e){if(T(3*c[e]),E){const e=A*A+L*L+m*m;if(e<z&&e>F){const t=1/Math.sqrt(e);A*=t,L*=t,m*=t}}for(let e=0;e<s;++e)d[i]=A,d[i+1]=L,d[i+2]=m,i+=u}}function h(e,f,o,r,i=1){if(!f)return void p(e,o,r,i);const{data:s,indices:n}=e,c=f,l=o.typedBuffer,d=o.typedBufferStride,u=n.length,a=c[0],B=c[1],y=c[2],g=c[4],b=c[5],O=c[6],h=c[8],S=c[9],N=c[10],R=!t(c),E=1e-6,F=1-E;if(r*=d,1===i)for(let t=0;t<u;++t){const e=4*n[t],f=s[e],o=s[e+1],i=s[e+2],c=s[e+3];let u=a*f+g*o+h*i,p=B*f+b*o+S*i,z=y*f+O*o+N*i;if(R){const e=u*u+p*p+z*z;if(e<F&&e>E){const t=1/Math.sqrt(e);u*=t,p*=t,z*=t}}l[r]=u,l[r+1]=p,l[r+2]=z,l[r+3]=c,r+=d}else for(let t=0;t<u;++t){const e=4*n[t],f=s[e],o=s[e+1],c=s[e+2],u=s[e+3];let p=a*f+g*o+h*c,z=B*f+b*o+S*c,A=y*f+O*o+N*c;if(R){const e=p*p+z*z+A*A;if(e<F&&e>E){const t=1/Math.sqrt(e);p*=t,z*=t,A*=t}}for(let t=0;t<i;++t)l[r]=p,l[r+1]=z,l[r+2]=A,l[r+3]=u,r+=d}}function S(e,t,f,o,r=1){const{data:i,indices:s}=e,n=f.typedBuffer,c=f.typedBufferStride,l=s.length;if(o*=c,t!==i.length||4!==t)if(1!==r)if(4!==t)for(let d=0;d<l;++d){const e=3*s[d];for(let t=0;t<r;++t)n[o]=i[e],n[o+1]=i[e+1],n[o+2]=i[e+2],n[o+3]=255,o+=c}else for(let d=0;d<l;++d){const e=4*s[d];for(let t=0;t<r;++t)n[o]=i[e],n[o+1]=i[e+1],n[o+2]=i[e+2],n[o+3]=i[e+3],o+=c}else{if(4===t){for(let e=0;e<l;++e){const t=4*s[e];n[o]=i[t],n[o+1]=i[t+1],n[o+2]=i[t+2],n[o+3]=i[t+3],o+=c}return}for(let e=0;e<l;++e){const t=3*s[e];n[o]=i[t],n[o+1]=i[t+1],n[o+2]=i[t+2],n[o+3]=255,o+=c}}else{n[o]=i[0],n[o+1]=i[1],n[o+2]=i[2],n[o+3]=i[3];const e=new Uint32Array(f.typedBuffer.buffer,f.start),t=c/4,s=e[o/=4];o+=t;const d=l*r;for(let f=1;f<d;++f)e[o]=s,o+=t}}function N(e,t,f){const{data:o,indices:r}=e,i=t.typedBuffer,s=t.typedBufferStride,n=r.length,c=o[0];f*=s;for(let l=0;l<n;++l)i[f]=c,f+=s}function R(e,t,f,o,r=1){const i=t.typedBuffer,s=t.typedBufferStride;if(o*=s,1===r)for(let n=0;n<f;++n)i[o]=e[0],i[o+1]=e[1],i[o+2]=e[2],i[o+3]=e[3],o+=s;else for(let n=0;n<f;++n)for(let t=0;t<r;++t)i[o]=e[0],i[o+1]=e[1],i[o+2]=e[2],i[o+3]=e[3],o+=s}function E(e,t,o,r,i,s,n){for(const c of o.fields.keys()){const o=e.get(c),d=o?.indices;if(o&&d)F(c,o,r,i,s,n);else if(c===l.OBJECTANDLAYERIDCOLOR&&null!=t){const o=e.get(l.POSITION)?.indices;if(o){const e=o.length;R(t,s.getField(c,f),e,n)}}}}function F(e,t,d,a,B,y){switch(e){case l.POSITION:{c(3===t.size);const f=B.getField(e,n);c(!!f,`No buffer view for ${e}`),f&&b(t,d,f,y);break}case l.NORMAL:{c(3===t.size);const f=B.getField(e,n);c(!!f,`No buffer view for ${e}`),f&&O(t,a,f,y);break}case l.NORMALCOMPRESSED:{c(2===t.size);const f=B.getField(e,s);c(!!f,`No buffer view for ${e}`),f&&u(t,f,y);break}case l.UV0:{c(2===t.size);const f=B.getField(e,i);c(!!f,`No buffer view for ${e}`),f&&u(t,f,y);break}case l.COLOR:case l.SYMBOLCOLOR:{const o=B.getField(e,f);c(!!o,`No buffer view for ${e}`),c(3===t.size||4===t.size),!o||3!==t.size&&4!==t.size||S(t,t.size,o,y);break}case l.COLORFEATUREATTRIBUTE:{const f=B.getField(e,r);c(!!f,`No buffer view for ${e}`),c(1===t.size),f&&1===t.size&&N(t,f,y);break}case l.TANGENT:{c(4===t.size);const f=B.getField(e,o);c(!!f,`No buffer view for ${e}`),f&&h(t,d,f,y);break}case l.PROFILERIGHT:case l.PROFILEUP:case l.PROFILEVERTEXANDNORMAL:case l.FEATUREVALUE:{c(4===t.size);const f=B.getField(e,o);c(!!f,`No buffer view for ${e}`),f&&p(t,f,y)}}}export{d as writeBufferFloat,y as writeBufferMat3f,g as writeBufferMat4f,u as writeBufferVec2,a as writeBufferVec3,p as writeBufferVec4,B as writeBufferVec4Zeros,S as writeColor,N as writeColorFeatureAttribute,F as writeDefaultAttribute,E as writeDefaultAttributes,O as writeNormal,R as writeObjectAndLayerIdColor,b as writePosition,h as writeTangent};
5
+ import{hasIdentityRotation as e,isOrthoNormal as t}from"../../../../../core/libs/gl-matrix-2/math/mat4.js";import{BufferViewVec4u8 as f,BufferViewVec4f as r,BufferViewFloat as o,BufferViewVec2f as i,BufferViewVec2i16 as n,BufferViewVec3f as s}from"../../../../../geometry/support/buffer/BufferView.js";import{assert as c}from"../../lib/Util.js";import{VertexAttribute as l}from"../../lib/VertexAttribute.js";function d(e,t,f,r=1){const{data:o,indices:i}=e,n=t.typedBuffer,s=t.typedBufferStride,c=i.length;if(f*=s,1===r)for(let l=0;l<c;++l)n[f]=o[i[l]],f+=s;else for(let l=0;l<c;++l){const e=o[i[l]];for(let t=0;t<r;t++)n[f]=e,f+=s}}function u(e,t,f){const{data:r,indices:o}=e,i=t.typedBuffer,n=t.typedBufferStride,s=o.length;f*=n;for(let c=0;c<s;++c){const e=2*o[c];i[f]=r[e],i[f+1]=r[e+1],f+=n}}function a(e,t,f,r){const{data:o,indices:i}=e,n=t.typedBuffer,s=t.typedBufferStride,c=i.length;if(f*=s,null==r||1===r)for(let l=0;l<c;++l){const e=3*i[l];n[f]=o[e],n[f+1]=o[e+1],n[f+2]=o[e+2],f+=s}else for(let l=0;l<c;++l){const e=3*i[l];for(let t=0;t<r;++t)n[f]=o[e],n[f+1]=o[e+1],n[f+2]=o[e+2],f+=s}}function p(e,t,f,r=1){const{data:o,indices:i}=e,n=t.typedBuffer,s=t.typedBufferStride,c=i.length;if(f*=s,1===r)for(let l=0;l<c;++l){const e=4*i[l];n[f]=o[e],n[f+1]=o[e+1],n[f+2]=o[e+2],n[f+3]=o[e+3],f+=s}else for(let l=0;l<c;++l){const e=4*i[l];for(let t=0;t<r;++t)n[f]=o[e],n[f+1]=o[e+1],n[f+2]=o[e+2],n[f+3]=o[e+3],f+=s}}function B(e,t,f){const r=e.typedBuffer,o=e.typedBufferStride;t*=o;for(let i=0;i<f;++i)r[t]=0,r[t+1]=0,r[t+2]=0,r[t+3]=0,t+=o}function y(e,t,f){const{data:r,indices:o}=e,i=t.typedBuffer,n=t.typedBufferStride,s=o.length;f*=n;for(let c=0;c<s;++c){const e=9*o[c];for(let t=0;t<9;++t)i[f+t]=r[e+t];f+=n}}function g(e,t,f){const{data:r,indices:o}=e,i=t.typedBuffer,n=t.typedBufferStride,s=o.length;f*=n;for(let c=0;c<s;++c){const e=16*o[c];for(let t=0;t<16;++t)i[f+t]=r[e+t];f+=n}}function O(t,f,r,o,i=1){if(!f)return void a(t,r,o,i);const{data:n,indices:s}=t,c=r.typedBuffer,l=r.typedBufferStride,d=s.length,u=f[0],p=f[1],B=f[2],y=f[4],g=f[5],O=f[6],b=f[8],h=f[9],m=f[10],S=f[12],N=f[13],R=f[14];o*=l;let E=0,I=0,F=0;const z=e(f)?e=>{E=n[e]+S,I=n[e+1]+N,F=n[e+2]+R}:e=>{const t=n[e],f=n[e+1],r=n[e+2];E=u*t+y*f+b*r+S,I=p*t+g*f+h*r+N,F=B*t+O*f+m*r+R};if(1===i)for(let e=0;e<d;++e)z(3*s[e]),c[o]=E,c[o+1]=I,c[o+2]=F,o+=l;else for(let e=0;e<d;++e){z(3*s[e]);for(let e=0;e<i;++e)c[o]=E,c[o+1]=I,c[o+2]=F,o+=l}}function b(f,r,o,i,n=1){if(!r)return void a(f,o,i,n);const{data:s,indices:c}=f,l=r,d=o.typedBuffer,u=o.typedBufferStride,p=c.length,B=l[0],y=l[1],g=l[2],O=l[4],b=l[5],h=l[6],m=l[8],S=l[9],N=l[10],R=!t(l),E=1e-6,I=1-E;i*=u;let F=0,z=0,A=0;const L=e(l)?e=>{F=s[e],z=s[e+1],A=s[e+2]}:e=>{const t=s[e],f=s[e+1],r=s[e+2];F=B*t+O*f+m*r,z=y*t+b*f+S*r,A=g*t+h*f+N*r};if(1===n)if(R)for(let e=0;e<p;++e){L(3*c[e]);const t=F*F+z*z+A*A;if(t<I&&t>E){const e=1/Math.sqrt(t);d[i]=F*e,d[i+1]=z*e,d[i+2]=A*e}else d[i]=F,d[i+1]=z,d[i+2]=A;i+=u}else for(let e=0;e<p;++e)L(3*c[e]),d[i]=F,d[i+1]=z,d[i+2]=A,i+=u;else for(let e=0;e<p;++e){if(L(3*c[e]),R){const e=F*F+z*z+A*A;if(e<I&&e>E){const t=1/Math.sqrt(e);F*=t,z*=t,A*=t}}for(let e=0;e<n;++e)d[i]=F,d[i+1]=z,d[i+2]=A,i+=u}}function h(e,f,r,o,i=1){if(!f)return void p(e,r,o,i);const{data:n,indices:s}=e,c=f,l=r.typedBuffer,d=r.typedBufferStride,u=s.length,a=c[0],B=c[1],y=c[2],g=c[4],O=c[5],b=c[6],h=c[8],m=c[9],S=c[10],N=!t(c),R=1e-6,E=1-R;if(o*=d,1===i)for(let t=0;t<u;++t){const e=4*s[t],f=n[e],r=n[e+1],i=n[e+2],c=n[e+3];let u=a*f+g*r+h*i,p=B*f+O*r+m*i,I=y*f+b*r+S*i;if(N){const e=u*u+p*p+I*I;if(e<E&&e>R){const t=1/Math.sqrt(e);u*=t,p*=t,I*=t}}l[o]=u,l[o+1]=p,l[o+2]=I,l[o+3]=c,o+=d}else for(let t=0;t<u;++t){const e=4*s[t],f=n[e],r=n[e+1],c=n[e+2],u=n[e+3];let p=a*f+g*r+h*c,I=B*f+O*r+m*c,F=y*f+b*r+S*c;if(N){const e=p*p+I*I+F*F;if(e<E&&e>R){const t=1/Math.sqrt(e);p*=t,I*=t,F*=t}}for(let t=0;t<i;++t)l[o]=p,l[o+1]=I,l[o+2]=F,l[o+3]=u,o+=d}}function m(e,t,f,r,o=1){const{data:i,indices:n}=e,s=f.typedBuffer,c=f.typedBufferStride,l=n.length;if(r*=c,t!==i.length||4!==t)if(1!==o)if(4!==t)for(let d=0;d<l;++d){const e=3*n[d];for(let t=0;t<o;++t)s[r]=i[e],s[r+1]=i[e+1],s[r+2]=i[e+2],s[r+3]=255,r+=c}else for(let d=0;d<l;++d){const e=4*n[d];for(let t=0;t<o;++t)s[r]=i[e],s[r+1]=i[e+1],s[r+2]=i[e+2],s[r+3]=i[e+3],r+=c}else{if(4===t){for(let e=0;e<l;++e){const t=4*n[e];s[r]=i[t],s[r+1]=i[t+1],s[r+2]=i[t+2],s[r+3]=i[t+3],r+=c}return}for(let e=0;e<l;++e){const t=3*n[e];s[r]=i[t],s[r+1]=i[t+1],s[r+2]=i[t+2],s[r+3]=255,r+=c}}else{s[r]=i[0],s[r+1]=i[1],s[r+2]=i[2],s[r+3]=i[3];const e=new Uint32Array(f.typedBuffer.buffer,f.start),t=c/4,n=e[r/=4];r+=t;const d=l*o;for(let f=1;f<d;++f)e[r]=n,r+=t}}function S(e,t,f){const{data:r,indices:o}=e,i=t.typedBuffer,n=t.typedBufferStride,s=o.length,c=r[0];f*=n;for(let l=0;l<s;++l)i[f]=c,f+=n}function N(e,t,f,r,o=1){const i=t.typedBuffer,n=t.typedBufferStride;if(r*=n,1===o)for(let s=0;s<f;++s)i[r]=e[0],i[r+1]=e[1],i[r+2]=e[2],i[r+3]=e[3],r+=n;else for(let s=0;s<f;++s)for(let t=0;t<o;++t)i[r]=e[0],i[r+1]=e[1],i[r+2]=e[2],i[r+3]=e[3],r+=n}function R(e,t,r,o,i,n,s){let c={numItems:0,numVerticesPerItem:0};for(const d of r.fields.keys()){const r=e.get(d),u=r?.indices;if(r&&u)d===l.POSITION&&(c={numItems:1,numVerticesPerItem:u.length}),E(d,r,o,i,n,s);else if(d===l.OBJECTANDLAYERIDCOLOR&&null!=t){const r=e.get(l.POSITION)?.indices;if(r){const e=r.length;N(t,n.getField(d,f),e,s)}}}return c}function E(e,t,d,a,B,y){switch(e){case l.POSITION:{c(3===t.size);const f=B.getField(e,s);c(!!f,`No buffer view for ${e}`),f&&O(t,d,f,y);break}case l.NORMAL:{c(3===t.size);const f=B.getField(e,s);c(!!f,`No buffer view for ${e}`),f&&b(t,a,f,y);break}case l.NORMALCOMPRESSED:{c(2===t.size);const f=B.getField(e,n);c(!!f,`No buffer view for ${e}`),f&&u(t,f,y);break}case l.UV0:{c(2===t.size);const f=B.getField(e,i);c(!!f,`No buffer view for ${e}`),f&&u(t,f,y);break}case l.COLOR:case l.SYMBOLCOLOR:{const r=B.getField(e,f);c(!!r,`No buffer view for ${e}`),c(3===t.size||4===t.size),!r||3!==t.size&&4!==t.size||m(t,t.size,r,y);break}case l.COLORFEATUREATTRIBUTE:{const f=B.getField(e,o);c(!!f,`No buffer view for ${e}`),c(1===t.size),f&&1===t.size&&S(t,f,y);break}case l.TANGENT:{c(4===t.size);const f=B.getField(e,r);c(!!f,`No buffer view for ${e}`),f&&h(t,d,f,y);break}case l.PROFILERIGHT:case l.PROFILEUP:case l.PROFILEVERTEXANDNORMAL:case l.FEATUREVALUE:{c(4===t.size);const f=B.getField(e,r);c(!!f,`No buffer view for ${e}`),f&&p(t,f,y)}}}export{d as writeBufferFloat,y as writeBufferMat3f,g as writeBufferMat4f,u as writeBufferVec2,a as writeBufferVec3,p as writeBufferVec4,B as writeBufferVec4Zeros,m as writeColor,S as writeColorFeatureAttribute,E as writeDefaultAttribute,R as writeDefaultAttributes,b as writeNormal,N as writeObjectAndLayerIdColor,O as writePosition,h as writeTangent};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import r from"../../../../core/Evented.js";import{unpackFloatRGBA as s}from"../../../../core/floatRGBA.js";import has from"../../../../core/has.js";import i from"../../../../core/Logger.js";import{removeMaybe as n,destroyMaybe as o}from"../../../../core/maybe.js";import{watch as a,initial as h,syncAndInitial as d}from"../../../../core/reactiveUtils.js";import{addFrameTask as p}from"../../../../core/scheduling.js";import{Milliseconds as c}from"../../../../core/time.js";import{property as l}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/RandomLCG.js";import{subclass as m}from"../../../../core/accessorSupport/decorators/subclass.js";import{isMoon as u,isMars as _}from"../../../../geometry/support/spatialReferenceUtils.js";import{ViewingMode as f}from"../../../ViewingMode.js";import{ChapmanAtmosphere as g}from"../../environment/ChapmanAtmosphere.js";import{CloudsComposition as v}from"../../environment/CloudsComposition.js";import{Fog as w}from"../../environment/Fog.js";import{LocalAtmosphere as x}from"../../environment/LocalAtmosphere.js";import y from"../../environment/MarsAtmosphere.js";import{ComponentObjectCollection as j}from"../collections/Component/ComponentObjectCollection.js";import{ShaderTechniqueConstructionContext as R}from"../core/shaderTechnique/ShaderTechniqueConstructionContext.js";import{ShaderTechniqueRepository as b}from"../core/shaderTechnique/ShaderTechniqueRepository.js";import{ObjectAndLayerIDRenderNode as A}from"../effects/geometry/ObjectAndLayerIDRenderNode.js";import{olidEnabled as T}from"../effects/geometry/olidUtils.js";import{RenderOccludedRenderNode as C}from"../effects/geometry/RenderOccludedRenderNode.js";import{Haze as S}from"../effects/haze/Haze.js";import{Highlight as O}from"../effects/highlight/Highlight.js";import{ShadowHighlight as U}from"../effects/highlight/ShadowHighlight.js";import{Magnifier as q}from"../effects/magnifier/Magnifier.js";import{SMAA as D}from"../effects/smaa/SMAA.js";import{SSAO as L}from"../effects/ssao/SSAO.js";import{Stars as M}from"../effects/stars/Stars.js";import{RenderRequestType as k}from"../lib/basicInterfaces.js";import E from"../lib/CompositingHelper.js";import{GLMaterialRepository as F}from"../lib/GLMaterialRepository.js";import{ObjectAndLayerIdRenderHelper as H}from"../lib/ObjectAndLayerIdRenderHelper.js";import{Renderer as W}from"../lib/Renderer.js";import{RenderingContext as B}from"../lib/RenderingContext.js";import{TextureRepository as G}from"../lib/TextureRepository.js";import{createMarkerTextureRepository as N}from"../materials/markerTextureRepository.js";import{createStippleTextureRepository as I}from"../materials/stippleTextureRepository.js";import{WaterTextureRepository as P}from"../materials/internal/WaterTextureRepository.js";import{getContextCache as z}from"./contextCache.js";import{removeLoadedShaderModules as K}from"./renderUtils.js";import{ScreenshotManager as V,ScreenshotContext as Q}from"./ScreenshotManager.js";import{contextCache as X}from"./testUtils.js";import{RenderState as J}from"../../../support/RenderState.js";let Y=class extends t{constructor(e){super(e),this.events=new r,this.waterTextures=new P,this.olidRenderHelper=T()?new H:null,this._needsUpdate=!0,this._needsRender=!0,this._idleSuspend=!0,this._needsWaterReflectionUpdate=!1,this._lastAnimationUpdate=0,this._savedFadeDuration=c(0);const t=e.stage;try{this._initializeContext(t)}catch(n){return void console.error("Failed to initialize context",n)}const{memoryController:s}=t.view.resourceController;this.stippleTextures=I(this._rctx,s),this.markerTextures=N(this._rctx,s),this._techniques=new b(new R(this._rctx,t.viewingMode,this.stippleTextures,this.waterTextures,this.markerTextures)),this._textures=new G(t,this._techniques,this._rctx),this.addHandles(this._textures.events.on("changed",(e=>this.requestRender(e)))),this._materials=new F(this._textures,this._techniques,(()=>this.requestRender()),(()=>this.requestRender())),this._compositingHelper=new E(this._rctx,this._techniques),this.renderer=new W(t,this._materials,this._techniques,this._rctx,this._compositingHelper,(e=>this.requestRender(e))),this.addHandles([a((()=>t.view.ready),(e=>{e&&this._createRenderNodes()}),h),a((()=>this.waterTextures?.updating),(()=>this.requestRender()),h),a((()=>t.view.qualityProfile),(e=>this.renderer?.updateRenderFeatures(e)),d)]);const i={renderScene:(e,t,r,s)=>this.renderer.render(e,t,r,s),requestRenderScene:e=>this.requestRender(e),prepareOverlay:()=>t.options.screenshot.prepareOverlay(),renderOverlay:(e,r,s)=>t.options.screenshot.renderOverlay(e,r,s)};this._screenshotManager=new V(this._rctx,i,(e=>this.events.emit("force-camera-for-screenshot",e))),this._registerFrameTask(t)}destroy(){this._container.contains(this._canvas)&&this._container.removeChild(this._canvas),this._frameTask=n(this._frameTask),this._techniques=o(this._techniques),this._componentObjects=o(this._componentObjects),this._screenshotManager=o(this._screenshotManager),o(this.renderer),this._textures=o(this._textures),o(this.waterTextures),o(this.markerTextures),o(this.stippleTextures),this._canvas=null,this._rctx=o(this._rctx)}_createRenderNodes(){const{view:e,viewingMode:t}=this.stage;new M({view:e}),u(e.spatialReference)||(t===f.Local?new x({view:e}):_(e.spatialReference)?new y({view:e}):(new g({view:e}),new v({view:e}),new S({view:e}),new w({view:e}))),new L({view:e,isEnabled:()=>this.renderer.hasSSAO}),new D({view:e,isEnabled:()=>this.renderer.hasSMAA}),new q({view:e}),new O({view:e}),new U({view:e,viewingMode:t}),new C({view:e}),T()&&new A({view:e})}requestRender(e=k.UPDATE){this._needsRender=!0,e===k.UPDATE&&(this._needsUpdate=!0)}get updating(){return this._needsUpdate||this._needsWaterReflectionUpdate||this.renderer.updating||this._textures.updating||this.waterTextures.updating}get textures(){return this._textures}get techniques(){return this._techniques}get compositingHelper(){return this._compositingHelper}setIdleSuspend(e){this._idleSuspend!==e&&(this._idleSuspend=e,this.requestRender())}get renderingContext(){return this._rctx}get capabilities(){return this._rctx.capabilities}get canvas(){return this._canvas}takeScreenshot(e){return this._screenshotManager.takeScreenshot(e).then((e=>e[0]))}takeScreenshotWithOID(e){return e.objectAndLayerIdColor=!0,this._screenshotManager.takeScreenshot(e)}getAlpha(){return!!this._rctx.contextAttributes.alpha}getMinimalDepthForArea(e,t,r,i,n,o=n){const a=i.constrainWindowSize(t,r,n*i.pixelRatio,o*i.pixelRatio),h=this._ensureLinearDepthArrayBuffer(a);this.renderer.readMainDepth(a,h);const d=(e,t,r)=>s(t,e)*(r[1]-r[0])+r[0];let p=Number.MAX_VALUE;for(let s=0;s<a[2]*a[3];s++){const e=d(4*s,h,i.nearFar);p>e&&e!==i.nearFar[0]&&e!==i.nearFar[1]&&(p=e)}if(e){const s=e.pickDepth(t*i.pixelRatio,r*i.pixelRatio,i);null!=s&&p>s&&s!==i.nearFar[0]&&s!==i.nearFar[1]&&(p=s)}return p===Number.MAX_VALUE?void 0:p}_ensureLinearDepthArrayBuffer(e){const t=4*e[2]*e[3];return(null==this._tmpDepthBuffer||this._tmpDepthBuffer.byteLength<t)&&(this._tmpDepthBuffer=new Uint8Array(t)),this._tmpDepthBuffer}async reloadShaders(){K(),await this._techniques.reloadAll(),this.renderer.overlay?.reloadShaders(),this.requestRender()}_registerFrameTask(e){const t=e.view.state;let r=!1,s=k.BACKGROUND,i=!1;const n={preRender:({time:i})=>{r=this.updating,s=this._needsUpdate?k.UPDATE:k.BACKGROUND,e.commitSyncLayers(),i=this._testTime??i;(c(i-this._lastAnimationUpdate)>this.renderer.animationTimestep||null!=t.forcedAnimationTime||r||this._needsRender)&&(this.renderer.updateAnimation(t,i)&&this.requestRender(k.BACKGROUND),this._lastAnimationUpdate=i)},render:({time:e})=>{if((this._needsRender||!this._idleSuspend||!this.renderer.isCameraFinal||this._needsWaterReflectionUpdate)&&t.camera.fullWidth>0&&t.camera.fullHeight>0){const r=this._needsUpdate&&this._idleSuspend&&this.renderer.isCameraFinal;this._needsRender=!1,this._needsUpdate=!1,this._needsWaterReflectionUpdate=!1,e=this._testTime??e,this.renderer.render(t,e),i=!0,r&&this.renderer.hasReflections&&(this.requestRender(k.BACKGROUND),this._needsWaterReflectionUpdate=!0)}},update:({time:e})=>{this._textures.update();const r=new Q(t,this.renderer.fboCache);e=this._testTime??e,this._screenshotManager.update(r,e)},finish:()=>{i&&(this.renderer.finish(t.mode===J.IDLE?s:k.UPDATE),i=!1)}};this._frameTask=p(n)}_initializeContext(e){const t=e.options;this._canvas=t.canvas??document.createElement("canvas"),this._canvas.setAttribute("style","width: 100%; height:100%; display:block;");const r={alpha:t.alpha||!1,premultipliedAlpha:!0,antialias:!1,depth:!0,stencil:t.stencil??!0,powerPreference:"high-performance",preserveDrawingBuffer:t.preserveDrawingBuffer??!1},s=this._canvas.getContext("webgl2",r);null!=s?(this._rctx=Z(s,e),this._loadShaderOnlyExtensions(),!t.alpha&&this._rctx.contextAttributes.alpha&&i.getLogger(this).error("WebGL context has alpha channel even though no alpha channel was requested"),!this._rctx.contextAttributes.alpha&&has("safari")>=11&&(this._container.style.backgroundColor="black"),e.container.contains(this._canvas)||e.container.appendChild(this._canvas)):i.getLogger(this).error("A WebGL2 context could not be created.")}_loadShaderOnlyExtensions(){this._rctx.capabilities.enable("textureFloatLinear")}get _container(){return this.stage.container}get _viewingMode(){return this.stage.viewingMode}getObjectAndLayerIdColor(e){return this.olidRenderHelper?.getObjectAndLayerIdColor(e)}get componentObjectCollection(){return null==this._componentObjects&&(this._componentObjects=new j(this.renderer.renderPassManager,this._viewingMode)),this._componentObjects}set componentObjectCollection(e){this._componentObjects=e}updateQualitySettings(e){null!=this._testTime&&(this._savedFadeDuration=e.fadeDuration,e.fadeDuration=c(0))}set testTime(e){this._testTime=e,null==e?this.stage.view.qualitySettings.fadeDuration=this._savedFadeDuration:this.updateQualitySettings(this.stage.view.qualitySettings)}get testTime(){return this._testTime}};function Z(e,t){const r=(e,r)=>t.view.resourceController.memoryController.newCache(e,r),s={disabledExtensions:t.options.deactivatedWebGLExtensions||{},debugWebGLExtensions:t.options.debugWebGLExtensions||{},maxAnisotropy:8,newCache:r};if(X.enabled){let t=$.get(e);return t?(t.configure(s),t.ref(),t):(t=new B(e,s),$.set(e,t),t.ref(),t)}return new B(e,s)}e([l({type:Boolean,readOnly:!0})],Y.prototype,"updating",null),e([l({constructOnly:!0})],Y.prototype,"stage",void 0),e([l()],Y.prototype,"_rctx",void 0),e([l()],Y.prototype,"_canvas",void 0),e([l()],Y.prototype,"stippleTextures",void 0),e([l()],Y.prototype,"markerTextures",void 0),e([l()],Y.prototype,"waterTextures",void 0),e([l({readOnly:!0})],Y.prototype,"olidRenderHelper",void 0),e([l()],Y.prototype,"_textures",void 0),e([l({readOnly:!0})],Y.prototype,"renderer",void 0),e([l()],Y.prototype,"_screenshotManager",void 0),e([l()],Y.prototype,"componentObjectCollection",null),e([l()],Y.prototype,"_componentObjects",void 0),e([l()],Y.prototype,"_needsUpdate",void 0),e([l()],Y.prototype,"_needsWaterReflectionUpdate",void 0),Y=e([m("esri.views.3d.webgl-engine.parts.RenderView")],Y);const $=z();export{Y as RenderView};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import r from"../../../../core/Evented.js";import{unpackFloatRGBA as s}from"../../../../core/floatRGBA.js";import has from"../../../../core/has.js";import i from"../../../../core/Logger.js";import{removeMaybe as n,destroyMaybe as o}from"../../../../core/maybe.js";import{watch as a,initial as h,syncAndInitial as d}from"../../../../core/reactiveUtils.js";import{addFrameTask as p}from"../../../../core/scheduling.js";import{Milliseconds as c}from"../../../../core/time.js";import{property as l}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/RandomLCG.js";import{subclass as m}from"../../../../core/accessorSupport/decorators/subclass.js";import{isMoon as u,isMars as f}from"../../../../geometry/support/spatialReferenceUtils.js";import{ViewingMode as _}from"../../../ViewingMode.js";import{ChapmanAtmosphere as g}from"../../environment/ChapmanAtmosphere.js";import{CloudsComposition as w}from"../../environment/CloudsComposition.js";import{Fog as v}from"../../environment/Fog.js";import{LocalAtmosphere as x}from"../../environment/LocalAtmosphere.js";import y from"../../environment/MarsAtmosphere.js";import{ComponentObjectCollection as j}from"../collections/Component/ComponentObjectCollection.js";import{ShaderTechniqueConstructionContext as R}from"../core/shaderTechnique/ShaderTechniqueConstructionContext.js";import{ShaderTechniqueRepository as b}from"../core/shaderTechnique/ShaderTechniqueRepository.js";import{ObjectAndLayerIDRenderNode as A}from"../effects/geometry/ObjectAndLayerIDRenderNode.js";import{olidEnabled as T}from"../effects/geometry/olidUtils.js";import{RenderOccludedRenderNode as C}from"../effects/geometry/RenderOccludedRenderNode.js";import{Haze as S}from"../effects/haze/Haze.js";import{Highlight as O}from"../effects/highlight/Highlight.js";import{ShadowHighlight as U}from"../effects/highlight/ShadowHighlight.js";import{Magnifier as q}from"../effects/magnifier/Magnifier.js";import{SMAA as D}from"../effects/smaa/SMAA.js";import{SSAO as L}from"../effects/ssao/SSAO.js";import{Stars as M}from"../effects/stars/Stars.js";import{RenderRequestType as k}from"../lib/basicInterfaces.js";import E from"../lib/CompositingHelper.js";import{GLMaterialRepository as F}from"../lib/GLMaterialRepository.js";import{ObjectAndLayerIdRenderHelper as H}from"../lib/ObjectAndLayerIdRenderHelper.js";import{Renderer as W}from"../lib/Renderer.js";import{RenderingContext as B}from"../lib/RenderingContext.js";import{TextureRepository as G}from"../lib/TextureRepository.js";import{createMarkerTextureRepository as N}from"../materials/markerTextureRepository.js";import{createStippleTextureRepository as I}from"../materials/stippleTextureRepository.js";import{WaterTextureRepository as P}from"../materials/internal/WaterTextureRepository.js";import{getContextCache as z}from"./contextCache.js";import{removeLoadedShaderModules as K}from"./renderUtils.js";import{ScreenshotManager as V,ScreenshotContext as Q}from"./ScreenshotManager.js";import{contextCache as X}from"./testUtils.js";import{RenderState as J}from"../../../support/RenderState.js";let Y=class extends t{constructor(e){super(e),this.events=new r,this.waterTextures=new P,this.olidRenderHelper=T()?new H:null,this._needsUpdate=!0,this._needsRender=!0,this._idleSuspend=!0,this._needsWaterReflectionUpdate=!1,this._lastAnimationUpdate=0,this._savedFadeDuration=c(0);const t=e.stage;try{this._initializeContext(t)}catch(n){return void console.error("Failed to initialize context",n)}const{memoryController:s}=t.view.resourceController;this.stippleTextures=I(this._rctx,s),this.markerTextures=N(this._rctx,s),this._techniques=new b(new R(this._rctx,t.viewingMode,this.stippleTextures,this.waterTextures,this.markerTextures)),this._textures=new G(t),this.addHandles(this._textures.events.on("changed",(e=>this.requestRender(e)))),this._materials=new F(this._textures,this._techniques,(()=>this.requestRender()),(()=>this.requestRender())),this._compositingHelper=new E(this._rctx,this._techniques),this.renderer=new W(t,this._materials,this._techniques,this._rctx,this._compositingHelper,(e=>this.requestRender(e))),this.addHandles([a((()=>t.view.ready),(e=>{e&&this._createRenderNodes()}),h),a((()=>this.waterTextures?.updating),(()=>this.requestRender()),h),a((()=>t.view.qualityProfile),(e=>this.renderer?.updateRenderFeatures(e)),d)]);const i={renderScene:(e,t,r,s)=>this.renderer.render(e,t,r,s),requestRenderScene:e=>this.requestRender(e),prepareOverlay:()=>t.options.screenshot.prepareOverlay(),renderOverlay:(e,r,s)=>t.options.screenshot.renderOverlay(e,r,s)};this._screenshotManager=new V(this._rctx,i,(e=>this.events.emit("force-camera-for-screenshot",e))),this._registerFrameTask(t)}destroy(){const e=this.stage?.container;e?.contains(this._canvas)&&e.removeChild(this._canvas),this._frameTask=n(this._frameTask),this._techniques=o(this._techniques),this._componentObjects=o(this._componentObjects),this._screenshotManager=o(this._screenshotManager),o(this.renderer),this._textures=o(this._textures),o(this.waterTextures),o(this.markerTextures),o(this.stippleTextures),this._canvas=null,this._rctx=o(this._rctx)}_createRenderNodes(){const{view:e,viewingMode:t}=this.stage;new M({view:e}),u(e.spatialReference)||(t===_.Local?new x({view:e}):f(e.spatialReference)?new y({view:e}):(new g({view:e}),new w({view:e}),new S({view:e}),new v({view:e}))),new L({view:e,isEnabled:()=>this.renderer.hasSSAO}),new D({view:e,isEnabled:()=>this.renderer.hasSMAA}),new q({view:e}),new O({view:e}),new U({view:e,viewingMode:t}),new C({view:e}),T()&&new A({view:e})}requestRender(e=k.UPDATE){this._needsRender=!0,e===k.UPDATE&&(this._needsUpdate=!0)}get updating(){return this._needsUpdate||this._needsWaterReflectionUpdate||this.renderer.updating||this._textures.updating||this.waterTextures.updating}get textures(){return this._textures}get techniques(){return this._techniques}get compositingHelper(){return this._compositingHelper}setIdleSuspend(e){this._idleSuspend!==e&&(this._idleSuspend=e,this.requestRender())}get renderingContext(){return this._rctx}get capabilities(){return this._rctx.capabilities}get canvas(){return this._canvas}takeScreenshot(e){return this._screenshotManager.takeScreenshot(e).then((e=>e[0]))}takeScreenshotWithOID(e){return e.objectAndLayerIdColor=!0,this._screenshotManager.takeScreenshot(e)}getAlpha(){return!!this._rctx.contextAttributes.alpha}getMinimalDepthForArea(e,t,r,i,n,o=n){const a=i.constrainWindowSize(t,r,n*i.pixelRatio,o*i.pixelRatio),h=this._ensureLinearDepthArrayBuffer(a);this.renderer.readMainDepth(a,h);const d=(e,t,r)=>s(t,e)*(r[1]-r[0])+r[0];let p=Number.MAX_VALUE;for(let s=0;s<a[2]*a[3];s++){const e=d(4*s,h,i.nearFar);p>e&&e!==i.nearFar[0]&&e!==i.nearFar[1]&&(p=e)}if(e){const s=e.pickDepth(t*i.pixelRatio,r*i.pixelRatio,i);null!=s&&p>s&&s!==i.nearFar[0]&&s!==i.nearFar[1]&&(p=s)}return p===Number.MAX_VALUE?void 0:p}_ensureLinearDepthArrayBuffer(e){const t=4*e[2]*e[3];return(null==this._tmpDepthBuffer||this._tmpDepthBuffer.byteLength<t)&&(this._tmpDepthBuffer=new Uint8Array(t)),this._tmpDepthBuffer}async reloadShaders(){K(),await this._techniques.reloadAll(),this.renderer.overlay?.reloadShaders(),this.requestRender()}_registerFrameTask(e){const t=e.view.state;let r=!1,s=k.BACKGROUND,i=!1;const n={preRender:({time:i})=>{r=this.updating,s=this._needsUpdate?k.UPDATE:k.BACKGROUND,e.commitSyncLayers(),i=this._testTime??i;(c(i-this._lastAnimationUpdate)>this.renderer.animationTimestep||null!=t.forcedAnimationTime||r||this._needsRender)&&(this.renderer.updateAnimation(t,i)&&this.requestRender(k.BACKGROUND),this._lastAnimationUpdate=i)},render:({time:e})=>{if((this._needsRender||!this._idleSuspend||!this.renderer.isCameraFinal||this._needsWaterReflectionUpdate)&&t.camera.fullWidth>0&&t.camera.fullHeight>0){const r=this._needsUpdate&&this._idleSuspend&&this.renderer.isCameraFinal;this._needsRender=!1,this._needsUpdate=!1,this._needsWaterReflectionUpdate=!1,e=this._testTime??e,this.renderer.render(t,e),i=!0,r&&this.renderer.hasReflections&&(this.requestRender(k.BACKGROUND),this._needsWaterReflectionUpdate=!0)}},update:({time:e})=>{this._textures.update();const r=new Q(t,this.renderer.fboCache);e=this._testTime??e,this._screenshotManager.update(r,e)},finish:()=>{i&&(this.renderer.finish(t.mode===J.IDLE?s:k.UPDATE),i=!1)}};this._frameTask=p(n)}_initializeContext(e){const{options:t}=e,r=t.canvas??document.createElement("canvas");r.setAttribute("style","width: 100%; height:100%; display:block;"),this._canvas=r;const s={alpha:t.alpha||!1,premultipliedAlpha:!0,antialias:!1,depth:!0,stencil:t.stencil??!0,powerPreference:"high-performance",preserveDrawingBuffer:t.preserveDrawingBuffer??!1},n=r.getContext("webgl2",s);if(null==n)return void i.getLogger(this).error("A WebGL2 context could not be created.");this._rctx=Z(n,e),this._loadShaderOnlyExtensions(),!t.alpha&&this._rctx.contextAttributes.alpha&&i.getLogger(this).error("WebGL context has alpha channel even though no alpha channel was requested");const{container:o}=e;!this._rctx.contextAttributes.alpha&&has("safari")>=11&&(o.style.backgroundColor="black"),o.contains(r)||o.appendChild(r)}_loadShaderOnlyExtensions(){this._rctx.capabilities.enable("textureFloatLinear")}get _viewingMode(){return this.stage.viewingMode}getObjectAndLayerIdColor(e){return this.olidRenderHelper?.getObjectAndLayerIdColor(e)}get componentObjectCollection(){return null==this._componentObjects&&(this._componentObjects=new j(this.renderer.renderPassManager,this._viewingMode)),this._componentObjects}set componentObjectCollection(e){this._componentObjects=e}updateQualitySettings(e){null!=this._testTime&&(this._savedFadeDuration=e.fadeDuration,e.fadeDuration=c(0))}set testTime(e){this._testTime=e,null==e?this.stage.view.qualitySettings.fadeDuration=this._savedFadeDuration:this.updateQualitySettings(this.stage.view.qualitySettings)}get testTime(){return this._testTime}};function Z(e,t){const r=(e,r)=>t.view.resourceController.memoryController.newCache(e,r),s={disabledExtensions:t.options.deactivatedWebGLExtensions||{},debugWebGLExtensions:t.options.debugWebGLExtensions||{},maxAnisotropy:8,newCache:r};if(X.enabled){let t=$.get(e);return t?(t.configure(s),t.ref(),t):(t=new B(e,s),$.set(e,t),t.ref(),t)}return new B(e,s)}e([l({type:Boolean,readOnly:!0})],Y.prototype,"updating",null),e([l({constructOnly:!0})],Y.prototype,"stage",void 0),e([l()],Y.prototype,"_rctx",void 0),e([l()],Y.prototype,"_canvas",void 0),e([l()],Y.prototype,"stippleTextures",void 0),e([l()],Y.prototype,"markerTextures",void 0),e([l()],Y.prototype,"waterTextures",void 0),e([l({readOnly:!0})],Y.prototype,"olidRenderHelper",void 0),e([l()],Y.prototype,"_textures",void 0),e([l({readOnly:!0})],Y.prototype,"renderer",void 0),e([l()],Y.prototype,"_screenshotManager",void 0),e([l()],Y.prototype,"componentObjectCollection",null),e([l()],Y.prototype,"_componentObjects",void 0),e([l()],Y.prototype,"_needsUpdate",void 0),e([l()],Y.prototype,"_needsWaterReflectionUpdate",void 0),Y=e([m("esri.views.3d.webgl-engine.parts.RenderView")],Y);const $=z();export{Y as RenderView};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import"../core/shaderLibrary/ShaderOutput.js";import"../core/shaderLibrary/Slice.glsl.js";import"../core/shaderLibrary/Transform.glsl.js";import"../core/shaderLibrary/attributes/ObjectAndLayerIdColor.glsl.js";import"../core/shaderLibrary/shading/TerrainDepthTest.glsl.js";import"../core/shaderLibrary/util/ColorConversion.glsl.js";import"../core/shaderLibrary/util/View.glsl.js";import"../core/shaderModules/FloatPassUniform.js";import"../core/shaderModules/glsl.js";import"../core/shaderModules/Texture2DPassUniform.js";import"../lib/VertexAttribute.js";import"./OutputColorHighlightOID.glsl.js";import"../../../webgl/ShaderBuilder.js";export{b as build}from"../../../../chunks/ImageMaterial.glsl.js";
5
+ import"../core/shaderLibrary/ShaderOutput.js";import"../core/shaderLibrary/Slice.glsl.js";import"../core/shaderLibrary/Transform.glsl.js";import"../core/shaderLibrary/attributes/ObjectAndLayerIdColor.glsl.js";import"../core/shaderLibrary/shading/TerrainDepthTest.glsl.js";import"../core/shaderLibrary/util/ColorConversion.glsl.js";import"../core/shaderLibrary/util/View.glsl.js";import"../core/shaderModules/FloatPassUniform.js";import"../core/shaderModules/glsl.js";import"../core/shaderModules/Texture2DPassUniform.js";import"../lib/VertexAttribute.js";import"./OutputColorHighlightOID.glsl.js";import"../../../webgl/NoParameters.js";import"../../../webgl/ShaderBuilder.js";export{a as ImageMaterialPassParameters,b as build}from"../../../../chunks/ImageMaterial.glsl.js";
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{isColorOrColorEmission as e}from"../core/shaderLibrary/ShaderOutput.js";import{ReloadableShaderModule as t}from"../core/shaderTechnique/ReloadableShaderModule.js";import{ShaderTechnique as r}from"../core/shaderTechnique/ShaderTechnique.js";import{OITPass as i}from"../lib/OITPass.js";import{oitBlending as l,oitDepthTest as s,depthWrite as n,getDrawBuffers as o,getOITPolygonOffset as a}from"../lib/OrderIndependentTransparency.js";import{stencilWriteMaskOn as p,stencilToolMaskBaseParams as c,stencilBaseAllZerosParams as u}from"../lib/StencilUtils.js";import{VertexAttribute as m}from"../lib/VertexAttribute.js";import{I as d}from"../../../../chunks/ImageMaterial.glsl.js";import{NoParameters as f}from"../../../webgl/NoParameters.js";import{makePipelineState as h,blendWithPremultipliedAlpha as g,cullingParams as P,defaultColorWrite as b}from"../../../webgl/renderState.js";class j extends f{}class I extends r{constructor(e,r){super(e,r,new t(d,(()=>import("./ImageMaterial.glsl.js"))),S)}_getPipelineState(t,r){const{oitPass:m,output:d,hasOccludees:f,enableOffset:j,cullFace:I}=t,S=m===i.NONE,O=m===i.FrontFace;return h({blending:e(d)?S?g:l(m):null,culling:P(I),depthTest:{func:s(m)},depthWrite:n(t),drawBuffers:o(m,d),colorWrite:b,stencilWrite:f?p:null,stencilTest:f?r?c:u:null,polygonOffset:S||O?null:a(j)})}initializePipeline(e){return this._occludeePipeline=this._getPipelineState(e,!0),this._getPipelineState(e,!1)}getPipeline(e){return e?this._occludeePipeline:super.getPipeline()}}const S=new Map([[m.POSITION,0],[m.UV0,2],[m.PERSPECTIVEDIVIDE,3]]);export{j as ImageMaterialPassParameters,I as ImageMaterialTechnique,S as vertexAttributeLocations};
5
+ import{isColorOrColorEmission as e}from"../core/shaderLibrary/ShaderOutput.js";import{ReloadableShaderModule as t}from"../core/shaderTechnique/ReloadableShaderModule.js";import{ShaderTechnique as r}from"../core/shaderTechnique/ShaderTechnique.js";import{OITPass as i}from"../lib/OITPass.js";import{oitBlending as l,oitDepthTest as s,depthWrite as n,getDrawBuffers as o,getOITPolygonOffset as a}from"../lib/OrderIndependentTransparency.js";import{stencilWriteMaskOn as p,stencilToolMaskBaseParams as c,stencilBaseAllZerosParams as u}from"../lib/StencilUtils.js";import{VertexAttribute as m}from"../lib/VertexAttribute.js";import{I as d}from"../../../../chunks/ImageMaterial.glsl.js";import{makePipelineState as h,blendWithPremultipliedAlpha as f,cullingParams as g,defaultColorWrite as P}from"../../../webgl/renderState.js";class b extends r{constructor(e,r){super(e,r,new t(d,(()=>import("./ImageMaterial.glsl.js"))),j)}_getPipelineState(t,r){const{oitPass:m,output:d,hasOccludees:b,enableOffset:j,cullFace:I}=t,S=m===i.NONE,O=m===i.FrontFace;return h({blending:e(d)?S?f:l(m):null,culling:g(I),depthTest:{func:s(m)},depthWrite:n(t),drawBuffers:o(m,d),colorWrite:P,stencilWrite:b?p:null,stencilTest:b?r?c:u:null,polygonOffset:S||O?null:a(j)})}initializePipeline(e){return this._occludeePipeline=this._getPipelineState(e,!0),this._getPipelineState(e,!1)}getPipeline(e){return e?this._occludeePipeline:super.getPipeline()}}const j=new Map([[m.POSITION,0],[m.UV0,2],[m.PERSPECTIVEDIVIDE,3]]);export{b as ImageMaterialTechnique,j as vertexAttributeLocations};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import a from"../../core/Error.js";import{makeHandle as i,handlesGroup as r,abortHandle as s}from"../../core/handleUtils.js";import"../../core/has.js";import{removeMaybe as o,destroyMaybe as n}from"../../core/maybe.js";import{debounce as l}from"../../core/promiseUtils.js";import{watch as d,when as c,initial as u,whenOnce as h,syncAndInitial as p}from"../../core/reactiveUtils.js";import{generateBracedUUID as m}from"../../core/uuid.js";import{property as f}from"../../core/accessorSupport/decorators/property.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as w}from"../../core/accessorSupport/decorators/subclass.js";import{isSharedTemplateOrMetadata as g}from"../../editing/templateUtils.js";import y from"../../layers/GraphicsLayer.js";import{isTable as v}from"../../layers/support/layerUtils.js";import{getDrawHelpMessage as F}from"../../views/draw/support/helpMessageUtils.js";import _ from"../../views/draw/support/HighlightHelper.js";import M from"../../views/interactive/sketch/SketchOptions.js";import b from"../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{temporaryHighlightName as V}from"../../views/support/HighlightDefaults.js";import k from"./CreateFeaturesWorkflowData.js";import{isModelUpload as I,handleModelUpload as S}from"./modelUploadUtils.js";import C from"./Workflow.js";import{startCreatingNewFeature as H,findLayerInfo as A,updateGraphicSymbolWhenRequired as P,isTerminalUpdateEventType as j,getVisualVariableAttributes as E,startUpdatingFeatureGeometry as U,createWorkflowSteps as T,avoidFeatureTemplateSelectionWithOnlyOneItem as O,prepareAttachmentsForCreateFeaturesWorkflow as D,showProgressCursor as L,visualVariableInteractiveUpdate as x}from"./workflowUtils.js";import W from"../FeatureForm/FeatureFormViewModel.js";import G from"../Sketch/SketchViewModel.js";var N;const z=Symbol(),R=Symbol(),Z=Symbol(),q=Symbol(),K={point:["point"],multipoint:["multipoint"],polygon:["polygon","freehandPolygon","rectangle","circle"],polyline:["polyline","freehandPolyline"],mesh:[],multipatch:[]};let B=N=class extends C{constructor(e){super(e),this.type="create-features",this.createFeatureState="create-new",this.data=void 0,this.isNested=!1,this._getDrawMeshHelpMessage=void 0,this._webStyleCache=new Map,this._featureFormHandle=null,this._visualVariableAttributes={rotation:null,size:null},this._featureFormViewModel=new W,this._sketchViewModel=null,this._attachmentFileInfos=new Map,this._isActive=!0,this._updateGraphicDebounced=l(((e,t,a)=>P(e,t,a)))}initialize(){this.isNested&&(this._isActive=!1),this._initializeSketchViewModel()}destroy(){this._sketchViewModel.destroy()}get featureFormViewModel(){return this._featureFormViewModel}get hasPendingEdits(){if(this.pendingFeatures.some((e=>!!this.data.getEditsForPendingFeature(e)?.modified)))return!0;const{creationInfo:e,upload:t}=this.data,a=this._sketchViewModel,{activeComponent:i}=a,r=a.createGraphic?.geometry?.type;return!("polyline"!==r&&"polygon"!==r&&"multipoint"!==r||"draw-2d"!==i?.type&&"draw-3d"!==i?.type)&&i.drawOperation.committedVertices.length>0||(!(!t||"pending"!==t.state&&"success"!==t.state)||!!e?.geometryToPlace)}get helpMessage(){const{creationInfo:e,viewModel:t}=this.data;if("creating-features"!==this.stepId||!e)return;const a=e.layer.geometryType,i=this._sketchViewModel.createGraphic;if("mesh"===a){this._getDrawMeshHelpMessage||import("../../views/draw/support/helpMessageUtils3d.js").then((e=>{this._getDrawMeshHelpMessage=e.getDrawMeshHelpMessage}));const{view:e}=t;return"3d"===e?.type?this._getDrawMeshHelpMessage?.(i,e):void 0}const r=this._sketchViewModel.activeCreateToolDrawMode,s=this._sketchViewModel.activeTool;return F("rectangle"===s?"rectangle":"circle"===s?"circle":a,i?.geometry,r)}get layer(){return this.data.creationInfo?.layer}get numPendingFeatures(){return this.pendingFeatures.length}get parent(){return this.data.parent}get parentLayer(){return this.parent?.data.editorItem.layer}get pendingFeatures(){return this.data.pendingFeatures}get keyboardCancellationEnabled(){return 0===this.numPendingFeatures}get reliesOnOwnerAdminPrivileges(){return this.data.editorItem?.capabilities.create.reliesOnOwnerAdminPrivileges??!1}get shouldShowAttachments(){return(this.data.selectedPendingFeature&&this.data.editorItem?.capabilities.create.attachments.enabled)??!1}get shouldAllowAttachmentEditing(){return this.shouldShowAttachments}get sketchViewModel(){return this._sketchViewModel}get test(){}get availableCreateTools(){const e=this.data.creationInfo?.layer.geometryType,t=this.data.viewModel.view;return e?this.data.creationInfo?.maxFeatures&&this.data.creationInfo.maxFeatures<=this.numPendingFeatures||"2d"!==t?.type&&"multipoint"===e?[]:[...K[e]]:[]}async enter(){this._isActive=!0,"awaiting-feature-creation-info"!==this.stepId&&this._setUpCreatingFeaturesStep()}exit(){this._isActive=!1,this.removeHandles([Z])}async updatePendingFeature(e){if(e!==this.data.selectedPendingFeature)return this._sketchViewModel.cancel(),this._startUpdating({feature:e})}async start(){return await super.start(),v(this.data.creationInfo?.layer)?null:{enter:async()=>{},exit:async()=>{},viewModel:this._sketchViewModel}}async save(){const{featureFormViewModel:e}=this;if(e.pendingSubtypeChoice)return;e.submit(),this._stashValidationState();const t=this.data.selectedPendingFeature,a=this._hasValidationErrors(t)?t:this.data.pendingFeatures.find((e=>this._hasValidationErrors(e)));return a?(await this._startUpdating({feature:a}),void e?.submit()):super.save()}cancelFeature(e){this.data.removePendingFeature(e),this.sketchViewModel.layer.graphics.remove(e)}static create(e){const{addAttachmentsCallback:t,applyEditsCallback:a,isNested:i,creationInfo:r,parent:s,snappingManager:o,startAt:n,viewModel:l}=e,d=e.sketchOptions??new M,c=r?.layer,u=c?l.findEditorItemForLayer(c):void 0,h=new N({data:new k({creationInfo:r,editorItem:u,parent:s,sketchOptions:d,snappingManager:o,viewModel:l}),isNested:i,onCommit:async e=>{const{creationInfo:i}=e;if(!i)return;h._sketchViewModel.cancel();const r=e.pendingFeatures.toArray(),{layer:s}=i,o=s.capabilities?.editing.supportsGlobalId&&"globalIdField"in s,n=h._attachmentFileInfos;if(o){const e=Y(r,s,n);return void await a(s,e,{globalIdUsed:!0})}const l=await a(s,{addFeatures:r});if(n.size>0){const e=l?.addFeatureResults??[];await t(s,X(r,e,s,n))}}});return h._set("steps",this._createWorkflowSteps(h,n)),h}_fadeExistingFeatures(e){if("effect"in e){const t=e.effect;return e.effect="saturate(0.6) opacity(0.8)",i((()=>e.effect=t))}const t=e.opacity;return e.opacity=.7,i((()=>e.opacity=t))}async _startCreating(){this.removeHandles(R);const{creationInfo:e}=this.data;if(!e)return;const t=this.data.creationInfo?.maxFeatures;if(t&&this.numPendingFeatures>=t)return this.sketchViewModel.cancel(),void(this.numPendingFeatures&&await this._startUpdating({feature:this.pendingFeatures.at(-1)}));this.createFeatureState="create-new";const a=await H(this._sketchViewModel,this._webStyleCache,e);this.addHandles(a,R)}async _clearSelectedFeature(){const e=this._featureFormViewModel.pendingSubtypeChoice;e&&(e.resolve("undo"),await e.promise),this._stashValidationState(),this.data.selectedPendingFeature=null,this._featureFormViewModel.feature=null;const t=this.data.viewModel.attachmentsViewModel;"add"!==t.mode&&"edit"!==t.mode||this.data.viewModel.activeWorkflow?.previous()}_stashValidationState(){const e=this._featureFormViewModel.feature,t=e&&this.data.getEditsForPendingFeature(e);t&&(t.submittable=this._featureFormViewModel.submittable)}async _selectFeatureForUpdate({feature:e,initialFeature:t=e}){this._stashValidationState();const{data:a,pendingFeatures:i,_webStyleCache:s}=this;i.includes(e)||a.addPendingFeature(e,t),a.selectedPendingFeature=e;const{_featureFormViewModel:n,_sketchViewModel:l}=this,{creationInfo:c,viewModel:u}=a,{attachmentsViewModel:h,layerInfos:p,view:m}=u;if(!m||!c)return;const f=c.layer,w=A(p,f),g=w?.formTemplate,y=m.spatialReference;n.set({arcadeEditType:"INSERT",feature:e,formTemplate:g,spatialReference:y,map:m.map}),"add"!==h.mode&&"edit"!==h.mode||u.activeWorkflow?.previous(),h.graphic=e,h.fileInfos.removeAll(),h.mode="view";if((this._attachmentFileInfos.get(e)||[]).forEach((({file:e,form:t})=>h.addFile(e,t))),await P(e,s,"2d"===m.type?m.scale:null),this.removeHandles(R),o(this._featureFormHandle),"2d"===m.type){const t=d((()=>m.scale),(t=>this._updateGraphicDebounced(e,s,t)));this.addHandles(t,R)}const v=a.getEditsForPendingFeature(e);this._featureFormHandle=r([n.on("value-change",(async()=>{v?.updateAttributes(n.getValues()),await P(e,s,"2d"===m.type?m.scale:null)})),l.on(["update","undo","redo"],(e=>{("undo"===e.type||"redo"===e.type||"update"===e.type&&null!=e.toolEventInfo&&j(e.toolEventInfo.type))&&n.notifyFeatureGeometryChanged()})),d((()=>n.feature?.sourceLayer),(t=>e.sourceLayer=t))]),this.createFeatureState="update-pending",this._visualVariableAttributes=E(e)}async _startUpdating({feature:e,initialFeature:t=e}){await this._selectFeatureForUpdate({feature:e,initialFeature:t});const{_sketchViewModel:a,data:i}=this,{creationInfo:r,viewModel:s}=i,{view:o}=s;if(!o||!r)return;const n=r.layer;return v(n)?void 0:U({graphic:e,sketchViewModel:a,sourceLayer:n,visualVariables:this._visualVariableAttributes,webStyleCache:this._webStyleCache})}static _createWorkflowSteps(e,t="awaiting-feature-creation-info"){const{data:a}=e,i=T(["awaiting-feature-creation-info","creating-features","adding-attachment","editing-attachment"],t,{"awaiting-feature-creation-info":()=>({id:"awaiting-feature-creation-info",async setUp(){const{creationInfo:t,viewModel:i}=a,{view:r}=i;r&&(I(t)?e.addHandles(await S({view:r,data:a,next:()=>e.next(),cancel:()=>i.cancelWorkflow({warnIfNoWorkflow:!1})}),this.id):(a.parent&&t&&(e.addHandles(i.lockFeatureTemplatesViewModel(),this.id),i.featureTemplatesViewModel.layers=[t.layer]),e.addHandles(i.featureTemplatesViewModel.on("select",(({item:t})=>{t&&(a.creationInfo={...a.creationInfo,layer:t.layer,template:t.template},e.next())})),this.id)))},async tearDown(){e.removeHandles([this.id,R])}}),"creating-features":()=>({id:"creating-features",async setUp(){e._isActive&&await e._setUpCreatingFeaturesStep()},async tearDown(t){const{viewModel:i}=a;t.canceled&&(e.removeHandles([Z,z,R,q]),i.attachmentsViewModel.fileInfos.removeAll(),e._attachmentFileInfos.clear())}}),"adding-attachment":()=>({id:"adding-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=a.viewModel,{graphic:i,fileInfos:r}=t;e._attachmentFileInfos.set(i,r.toArray()),t.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=a.viewModel,{graphic:i,fileInfos:r}=t;e._attachmentFileInfos.set(i,r.toArray()),t.mode="view"}})});return O(a,i)}static _configureSketchViewModel(e){const{data:t}=e,{creationInfo:a,viewModel:s}=t,{view:o}=s,n=e._sketchViewModel,l=[];if(!o)return i();"2d"===o.type&&a&&l.push(e._fadeExistingFeatures(a.layer));const u=async t=>{if("cancel"===t.state&&null!==o.activeTool&&o.activeTool!==e.sketchViewModel.activeComponent&&(await e._waitForActiveToolCleared(),await e._startCreating()),"complete"===t.state&&t.graphic){const a=t.graphic,i=t.graphic.clone();return i.geometry=null,await e._waitForActiveToolCleared(),void await e._selectFeatureForUpdate({feature:a,initialFeature:i})}},h=async i=>{const{attachmentsViewModel:r}=s,{_featureFormViewModel:n}=e;if(i.graphics.length>1)return void await e._clearSelectedFeature();const l=i.graphics[0];if("complete"===i.state){const{submittable:t}=n;if(e.numPendingFeatures!==a?.maxFeatures&&t||n.submit(),await e._clearSelectedFeature(),"add"!==r.mode&&"edit"!==r.mode||s.activeWorkflow?.previous(),!i.aborted&&o.activeTool===e.sketchViewModel.activeComponent&&(await e.sketchViewModel.wait(),"ready"===e.sketchViewModel.state&&"mesh"!==e.data.creationInfo?.layer.geometryType))return e._startCreating()}else{if("start"===i.state)return l.sourceLayer=t.creationInfo?.layer,e._selectFeatureForUpdate({feature:l});if("active"===i.state){await e.updatePendingFeature(l);const t=e._visualVariableAttributes;await x(o,l,i,t,e._webStyleCache);const a=l.attributes,{rotation:r,size:s}=t;if(null!=r){const{field:e}=r;n.setValue(e,a[e])}if(null!=s){const{field:e}=s;n.setValue(e,a[e])}}}},p=async a=>{if(a.graphics.forEach((e=>{t.removePendingFeature(e)})),!I(t.creationInfo))return e._startCreating()},m=async()=>(I(t.creationInfo)&&await e.data.viewModel.back(),e._startCreating());l.push(n.on("create",(t=>e._updatingHandles.addPromise(u(t)))),n.on("update",(t=>e._updatingHandles.addPromise(h(t)))),n.on("delete",(t=>e._updatingHandles.addPromise(p(t)))),c((()=>!e.numPendingFeatures),(()=>e._updatingHandles.addPromise(m()))),J(n,t),...Q(t)),l.push(d((()=>[e._featureFormViewModel.feature,e._featureFormViewModel.submittable]),(()=>{e._stashValidationState()})));const f=r(l);return n.addHandles(f),f}_initializeSketchViewModel(){const{data:e}=this,{view:t}=e.viewModel,a=new y({elevationInfo:e.creationInfo?.layer.elevationInfo,internal:!0,listMode:"hide"}),r=new G({layer:a,creationMode:"update",sketchOptions:e.sketchOptions,snappingManager:e.snappingManager,updateOnGraphicClick:!1,defaultUpdateOptions:{multipleSelectionEnabled:!1},view:t});this._sketchViewModel=r,t?.map.add(a),this.addHandles([i((()=>{t?.destroyed||t?.map.remove(a),a.destroy()})),d((()=>this.numPendingFeatures>0),(e=>this._sketchViewModel.updateOnGraphicClick=e),u)])}_hasValidationErrors(e){return!!e&&(!this.data.isSubmittable(e)||!!this._featureFormViewModel.validateContingencyConstraints(e.attributes,{includeIncompleteViolations:!0})?.length)}async _setUpCreatingFeaturesStep(){if(this.hasHandles(Z))return;const{data:e,sketchViewModel:s}=this,{creationInfo:n,viewModel:l}=e,{attachmentsViewModel:c,view:h}=l;if(!h||!n?.layer)throw new a("missing-parameters","CreateFeaturesWorkflow requires a view and creationInfo.");const{initialFeature:p,layer:m}=n,f=[];this._featureFormHandle=o(this._featureFormHandle),this._visualVariableAttributes={rotation:null,size:null},this.data.editorItem=l.findEditorItemForLayer(n.layer),D(c),f.push(d((()=>c.mode),(e=>{switch(e){case"add":this.go("adding-attachment");break;case"edit":this.go("editing-attachment")}})));const w=L(h);f.push(w);const y=v(n.layer);try{if(y){const{template:e}=n;if(e&&g(e))throw new a("Shared templates are not yet supported");const i=p??new t({attributes:{...e?.prototype.attributes,...n.attributeOverrides},sourceLayer:m});await this._startUpdating({feature:i})}else f.push(N._configureSketchViewModel(this)),p?(s.layer.add(p),await this._startUpdating({feature:p})):await this._startCreating()}finally{w.remove()}const F=i((()=>{for(const t of e.pendingFeatures)s.layer.remove(t),e.removePendingFeature(t)})),_=d((()=>h?.timeZone),(e=>this._featureFormViewModel.timeZone=e),u),M=i((()=>{I(n)&&l.cancelWorkflow({warnIfNoWorkflow:!1})}));this._featureFormHandle&&f.push(this._featureFormHandle),this.addHandles(f,this._handleKeys.beforeCommit),this.addHandles([i((()=>c.fileInfos.removeAll())),r(f),M,F,_],Z)}async _waitForActiveToolCleared(){const e=this.data.viewModel.view;if(null==e?.activeTool)return;const t=new AbortController;this.addHandles(s(t),q),await h((()=>null==e?.activeTool),t.signal),t.abort()}};function J(e,t){let a=null;const s=()=>e.snappingOptions.featureSources,o=()=>(a=new b({layer:e.layer}),s().add(a),a),l=()=>{null!=a&&(s().remove(a),a=n(a))};return r([d((()=>{const e=t.creationInfo?.layer,a=s().find((t=>t.layer===e));return{hasFeatureLayerSource:!!a,enabled:a?.enabled??!1}}),(({hasFeatureLayerSource:e,enabled:t})=>{if(!e)return l();a??=o(),a.enabled=t}),p),i(l)])}function Q(e){const t=e.viewModel.view;if(!t)return[];const a=[];if("3d"===t.type){const r=new _({view:t});a.push(d((()=>e.selectedPendingFeature),((e,t)=>{r.remove(e),r.add(t)})),i((()=>r.destroy())))}const r=new _({view:t,highlightName:V});return a.push(d((()=>e.temporaryHighlightFeature),(e=>{r.removeAll(),r.add(e)})),i((()=>r.destroy()))),a}function X(e,t,a,i){const r=[];return t.forEach(((t,s)=>{if(!t.error){const o=e[s],n=i.get(o)||[];o.attributes[a.objectIdField]=t.objectId,n.forEach((({form:e})=>r.push({feature:o,attachment:e})))}})),r}function Y(e,t,a){const i=[],r=t.globalIdField;return e.forEach(((t,s)=>{e[s].attributes[r]??=m(),(a?.get(t)||[]).forEach((({file:e})=>i.push({feature:t,attachment:{globalId:m(),data:e}})))})),i.length?{addFeatures:e,addAttachments:i}:{addFeatures:e}}e([f()],B.prototype,"createFeatureState",void 0),e([f()],B.prototype,"data",void 0),e([f({constructOnly:!0})],B.prototype,"isNested",void 0),e([f()],B.prototype,"featureFormViewModel",null),e([f()],B.prototype,"hasPendingEdits",null),e([f()],B.prototype,"_getDrawMeshHelpMessage",void 0),e([f()],B.prototype,"helpMessage",null),e([f()],B.prototype,"layer",null),e([f()],B.prototype,"parent",null),e([f()],B.prototype,"parentLayer",null),e([f()],B.prototype,"keyboardCancellationEnabled",null),e([f()],B.prototype,"reliesOnOwnerAdminPrivileges",null),e([f()],B.prototype,"shouldShowAttachments",null),e([f()],B.prototype,"shouldAllowAttachmentEditing",null),e([f()],B.prototype,"sketchViewModel",null),e([f()],B.prototype,"availableCreateTools",null),B=N=e([w("esri.widgets.Editor.CreateFeaturesWorkflow")],B);const $=B;export{$ as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import a from"../../core/Error.js";import{makeHandle as i,handlesGroup as r,abortHandle as s}from"../../core/handleUtils.js";import"../../core/has.js";import{removeMaybe as o,destroyMaybe as n}from"../../core/maybe.js";import{debounce as l}from"../../core/promiseUtils.js";import{watch as d,when as c,initial as u,whenOnce as h,syncAndInitial as p}from"../../core/reactiveUtils.js";import{generateBracedUUID as m}from"../../core/uuid.js";import{property as f}from"../../core/accessorSupport/decorators/property.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as w}from"../../core/accessorSupport/decorators/subclass.js";import{isSharedTemplateOrMetadata as g}from"../../editing/templateUtils.js";import y from"../../layers/GraphicsLayer.js";import{isTable as v}from"../../layers/support/layerUtils.js";import{getDrawHelpMessage as F}from"../../views/draw/support/helpMessageUtils.js";import _ from"../../views/draw/support/HighlightHelper.js";import M from"../../views/interactive/sketch/SketchOptions.js";import b from"../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{temporaryHighlightName as V}from"../../views/support/HighlightDefaults.js";import k from"./CreateFeaturesWorkflowData.js";import{isModelUpload as I,handleModelUpload as S}from"./modelUploadUtils.js";import C from"./Workflow.js";import{startCreatingNewFeature as P,findLayerInfo as H,updateGraphicSymbolWhenRequired as A,isTerminalUpdateEventType as j,getVisualVariableAttributes as E,startUpdatingFeatureGeometry as U,createWorkflowSteps as T,avoidFeatureTemplateSelectionWithOnlyOneItem as O,prepareAttachmentsForCreateFeaturesWorkflow as D,showProgressCursor as L,visualVariableInteractiveUpdate as x}from"./workflowUtils.js";import W from"../FeatureForm/FeatureFormViewModel.js";import G from"../Sketch/SketchViewModel.js";var N;const z=Symbol(),R=Symbol(),Z=Symbol(),q=Symbol(),K={point:["point"],multipoint:["multipoint"],polygon:["polygon","freehandPolygon","rectangle","circle"],polyline:["polyline","freehandPolyline"],mesh:[],multipatch:[]};let B=N=class extends C{constructor(e){super(e),this.type="create-features",this.createFeatureState="create-new",this.data=void 0,this.isNested=!1,this._getDrawMeshHelpMessage=void 0,this._webStyleCache=new Map,this._featureFormHandle=null,this._visualVariableAttributes={rotation:null,size:null},this._featureFormViewModel=new W,this._sketchViewModel=null,this._attachmentFileInfos=new Map,this._isActive=!0,this._updateGraphicDebounced=l(((e,t,a)=>A(e,t,a)))}initialize(){this.isNested&&(this._isActive=!1),this._initializeSketchViewModel()}destroy(){this._sketchViewModel.destroy()}get featureFormViewModel(){return this._featureFormViewModel}get hasPendingEdits(){if(this.pendingFeatures.some((e=>!!this.data.getEditsForPendingFeature(e)?.modified)))return!0;const{creationInfo:e,upload:t}=this.data,a=this._sketchViewModel,{activeComponent:i}=a,r=a.createGraphic?.geometry?.type;return!("polyline"!==r&&"polygon"!==r&&"multipoint"!==r||"draw-2d"!==i?.type&&"draw-3d"!==i?.type)&&i.drawOperation.committedVertices.length>0||(!(!t||"pending"!==t.state&&"success"!==t.state)||!!e?.geometryToPlace)}get hasPreviousStep(){return"update-pending"===this.createFeatureState&&!!this.data.selectedPendingFeature}get helpMessage(){const{creationInfo:e,viewModel:t}=this.data;if("creating-features"!==this.stepId||!e)return;const a=e.layer.geometryType,i=this._sketchViewModel.createGraphic;if("mesh"===a){this._getDrawMeshHelpMessage||import("../../views/draw/support/helpMessageUtils3d.js").then((e=>{this._getDrawMeshHelpMessage=e.getDrawMeshHelpMessage}));const{view:e}=t;return"3d"===e?.type?this._getDrawMeshHelpMessage?.(i,e):void 0}const r=this._sketchViewModel.activeCreateToolDrawMode,s=this._sketchViewModel.activeTool;return F("rectangle"===s?"rectangle":"circle"===s?"circle":a,i?.geometry,r)}get layer(){return this.data.creationInfo?.layer}get numPendingFeatures(){return this.pendingFeatures.length}get parent(){return this.data.parent}get parentLayer(){return this.parent?.data.editorItem.layer}get pendingFeatures(){return this.data.pendingFeatures}get keyboardCancellationEnabled(){return 0===this.numPendingFeatures}get reliesOnOwnerAdminPrivileges(){return this.data.editorItem?.capabilities.create.reliesOnOwnerAdminPrivileges??!1}get shouldShowAttachments(){return(this.data.selectedPendingFeature&&this.data.editorItem?.capabilities.create.attachments.enabled)??!1}get shouldAllowAttachmentEditing(){return this.shouldShowAttachments}get sketchViewModel(){return this._sketchViewModel}get test(){}get availableCreateTools(){const e=this.data.creationInfo?.layer.geometryType,t=this.data.viewModel.view;return e?this.data.creationInfo?.maxFeatures&&this.data.creationInfo.maxFeatures<=this.numPendingFeatures||"2d"!==t?.type&&"multipoint"===e?[]:[...K[e]]:[]}async enter(){this._isActive=!0,"awaiting-feature-creation-info"!==this.stepId&&this._setUpCreatingFeaturesStep()}exit(){this._isActive=!1,this.removeHandles([Z])}async updatePendingFeature(e){if(e!==this.data.selectedPendingFeature)return this._sketchViewModel.cancel(),this._startUpdating({feature:e})}async start(){return await super.start(),v(this.data.creationInfo?.layer)?null:{enter:async()=>{},exit:async()=>{},viewModel:this._sketchViewModel}}async save(){const{featureFormViewModel:e}=this;if(e.pendingSubtypeChoice)return;e.submit(),this._stashValidationState();const t=this.data.selectedPendingFeature,a=this._hasValidationErrors(t)?t:this.data.pendingFeatures.find((e=>this._hasValidationErrors(e)));return a?(await this._startUpdating({feature:a}),void e?.submit()):super.save()}back(e){return"update-pending"===this.createFeatureState&&this.data.selectedPendingFeature&&!I(this.data.creationInfo)?this._clearSelectedFeature():super.back(e)}previous(e){return"update-pending"===this.createFeatureState&&this.data.selectedPendingFeature&&!I(this.data.creationInfo)?this._clearSelectedFeature():super.previous(e)}cancelFeature(e){this.data.removePendingFeature(e),this.sketchViewModel.layer.graphics.remove(e)}static create(e){const{addAttachmentsCallback:t,applyEditsCallback:a,isNested:i,creationInfo:r,parent:s,snappingManager:o,startAt:n,viewModel:l}=e,d=e.sketchOptions??new M,c=r?.layer,u=c?l.findEditorItemForLayer(c):void 0,h=new N({data:new k({creationInfo:r,editorItem:u,parent:s,sketchOptions:d,snappingManager:o,viewModel:l}),isNested:i,onCommit:async e=>{const{creationInfo:i}=e;if(!i)return;h._sketchViewModel.cancel();const r=e.pendingFeatures.toArray(),{layer:s}=i,o=s.capabilities?.editing.supportsGlobalId&&"globalIdField"in s,n=h._attachmentFileInfos;if(o){const e=Y(r,s,n);return void await a(s,e,{globalIdUsed:!0})}const l=await a(s,{addFeatures:r});if(n.size>0){const e=l?.addFeatureResults??[];await t(s,X(r,e,s,n))}}});return h._set("steps",this._createWorkflowSteps(h,n)),h}_fadeExistingFeatures(e){if("effect"in e){const t=e.effect;return e.effect="saturate(0.6) opacity(0.8)",i((()=>e.effect=t))}const t=e.opacity;return e.opacity=.7,i((()=>e.opacity=t))}async _startCreating(){this.removeHandles(R);const{creationInfo:e}=this.data;if(!e)return;const t=this.data.creationInfo?.maxFeatures;if(t&&this.numPendingFeatures>=t)return this.sketchViewModel.cancel(),void(this.numPendingFeatures&&await this._startUpdating({feature:this.pendingFeatures.at(-1)}));this.createFeatureState="create-new";const a=await P(this._sketchViewModel,this._webStyleCache,e);this.addHandles(a,R)}async _clearSelectedFeature(){const e=this._featureFormViewModel.pendingSubtypeChoice;e&&(e.resolve("undo"),await e.promise),this._stashValidationState(),this.sketchViewModel.cancel(),this.data.selectedPendingFeature=null,this._featureFormViewModel.feature=null;const t=this.data.viewModel.attachmentsViewModel;"add"!==t.mode&&"edit"!==t.mode||this.data.viewModel.activeWorkflow?.previous()}_stashValidationState(){const e=this._featureFormViewModel.feature,t=e&&this.data.getEditsForPendingFeature(e);t&&(t.submittable=this._featureFormViewModel.submittable)}async _selectFeatureForUpdate({feature:e,initialFeature:t=e}){this._stashValidationState();const{data:a,pendingFeatures:i,_webStyleCache:s}=this;i.includes(e)||a.addPendingFeature(e,t),a.selectedPendingFeature=e;const{_featureFormViewModel:n,_sketchViewModel:l}=this,{creationInfo:c,viewModel:u}=a,{attachmentsViewModel:h,layerInfos:p,view:m}=u;if(!m||!c)return;const f=c.layer,w=H(p,f),g=w?.formTemplate,y=m.spatialReference;n.set({arcadeEditType:"INSERT",feature:e,formTemplate:g,spatialReference:y,map:m.map}),"add"!==h.mode&&"edit"!==h.mode||u.activeWorkflow?.previous(),h.graphic=e,h.fileInfos.removeAll(),h.mode="view";if((this._attachmentFileInfos.get(e)||[]).forEach((({file:e,form:t})=>h.addFile(e,t))),await A(e,s,"2d"===m.type?m.scale:null),this.removeHandles(R),o(this._featureFormHandle),"2d"===m.type){const t=d((()=>m.scale),(t=>this._updateGraphicDebounced(e,s,t)));this.addHandles(t,R)}const v=a.getEditsForPendingFeature(e);this._featureFormHandle=r([n.on("value-change",(async()=>{v?.updateAttributes(n.getValues()),await A(e,s,"2d"===m.type?m.scale:null)})),l.on(["update","undo","redo"],(e=>{("undo"===e.type||"redo"===e.type||"update"===e.type&&null!=e.toolEventInfo&&j(e.toolEventInfo.type))&&n.notifyFeatureGeometryChanged()})),d((()=>n.feature?.sourceLayer),(t=>e.sourceLayer=t))]),this.createFeatureState="update-pending",this._visualVariableAttributes=E(e)}async _startUpdating({feature:e,initialFeature:t=e}){await this._selectFeatureForUpdate({feature:e,initialFeature:t});const{_sketchViewModel:a,data:i}=this,{creationInfo:r,viewModel:s}=i,{view:o}=s;if(!o||!r)return;const n=r.layer;return v(n)?void 0:U({graphic:e,sketchViewModel:a,sourceLayer:n,visualVariables:this._visualVariableAttributes,webStyleCache:this._webStyleCache})}static _createWorkflowSteps(e,t="awaiting-feature-creation-info"){const{data:a}=e,i=T(["awaiting-feature-creation-info","creating-features","adding-attachment","editing-attachment"],t,{"awaiting-feature-creation-info":()=>({id:"awaiting-feature-creation-info",async setUp(){const{creationInfo:t,viewModel:i}=a,{view:r}=i;r&&(I(t)?e.addHandles(await S({view:r,data:a,next:()=>e.next(),cancel:()=>i.cancelWorkflow({warnIfNoWorkflow:!1})}),this.id):(a.parent&&t&&(e.addHandles(i.lockFeatureTemplatesViewModel(),this.id),i.featureTemplatesViewModel.layers=[t.layer]),e.addHandles(i.featureTemplatesViewModel.on("select",(({item:t})=>{t&&(a.creationInfo={...a.creationInfo,layer:t.layer,template:t.template},e.next())})),this.id)))},async tearDown(){e.removeHandles([this.id,R])}}),"creating-features":()=>({id:"creating-features",async setUp(){e._isActive&&await e._setUpCreatingFeaturesStep()},async tearDown(t){const{viewModel:i}=a;t.canceled&&(e.removeHandles([Z,z,R,q]),i.attachmentsViewModel.fileInfos.removeAll(),e._attachmentFileInfos.clear())}}),"adding-attachment":()=>({id:"adding-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=a.viewModel,{graphic:i,fileInfos:r}=t;e._attachmentFileInfos.set(i,r.toArray()),t.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=a.viewModel,{graphic:i,fileInfos:r}=t;e._attachmentFileInfos.set(i,r.toArray()),t.mode="view"}})});return O(a,i)}static _configureSketchViewModel(e){const{data:t}=e,{creationInfo:a,viewModel:s}=t,{view:o}=s,n=e._sketchViewModel,l=[];if(!o)return i();"2d"===o.type&&a&&l.push(e._fadeExistingFeatures(a.layer));const u=async t=>{if("cancel"===t.state&&null!==o.activeTool&&o.activeTool!==e.sketchViewModel.activeComponent&&(await e._waitForActiveToolCleared(),await e._startCreating()),"complete"===t.state&&t.graphic){const a=t.graphic,i=t.graphic.clone();return i.geometry=null,await e._waitForActiveToolCleared(),void await e._selectFeatureForUpdate({feature:a,initialFeature:i})}},h=async i=>{const{attachmentsViewModel:r}=s,{_featureFormViewModel:n}=e;if(i.graphics.length>1)return void await e._clearSelectedFeature();const l=i.graphics[0];if("complete"===i.state){const{submittable:t}=n;if(e.numPendingFeatures!==a?.maxFeatures&&t||n.submit(),await e._clearSelectedFeature(),"add"!==r.mode&&"edit"!==r.mode||s.activeWorkflow?.previous(),!i.aborted&&o.activeTool===e.sketchViewModel.activeComponent&&(await e.sketchViewModel.wait(),"ready"===e.sketchViewModel.state&&"mesh"!==e.data.creationInfo?.layer.geometryType))return e._startCreating()}else{if("start"===i.state)return l.sourceLayer=t.creationInfo?.layer,e._selectFeatureForUpdate({feature:l});if("active"===i.state){await e.updatePendingFeature(l);const t=e._visualVariableAttributes;await x(o,l,i,t,e._webStyleCache);const a=l.attributes,{rotation:r,size:s}=t;if(null!=r){const{field:e}=r;n.setValue(e,a[e])}if(null!=s){const{field:e}=s;n.setValue(e,a[e])}}}},p=async a=>{if(a.graphics.forEach((e=>{t.removePendingFeature(e)})),!I(t.creationInfo))return e._startCreating()},m=async()=>{if(I(t.creationInfo))try{await e.data.viewModel.back()}catch{}return e._startCreating()};l.push(n.on("create",(t=>e._updatingHandles.addPromise(u(t)))),n.on("update",(t=>e._updatingHandles.addPromise(h(t)))),n.on("delete",(t=>e._updatingHandles.addPromise(p(t)))),c((()=>!e.numPendingFeatures),(()=>e._updatingHandles.addPromise(m()))),J(n,t),...Q(t)),l.push(d((()=>[e._featureFormViewModel.feature,e._featureFormViewModel.submittable]),(()=>{e._stashValidationState()})));const f=r(l);return n.addHandles(f),f}_initializeSketchViewModel(){const{data:e}=this,{view:t}=e.viewModel,a=new y({elevationInfo:e.creationInfo?.layer.elevationInfo,internal:!0,listMode:"hide"}),r=new G({layer:a,creationMode:"update",sketchOptions:e.sketchOptions,snappingManager:e.snappingManager,updateOnGraphicClick:!1,defaultUpdateOptions:{multipleSelectionEnabled:!1},view:t});this._sketchViewModel=r,t?.map.add(a),this.addHandles([i((()=>{t?.destroyed||t?.map.remove(a),a.destroy()})),d((()=>this.numPendingFeatures>0),(e=>this._sketchViewModel.updateOnGraphicClick=e),u)])}_hasValidationErrors(e){return!!e&&(!this.data.isSubmittable(e)||!!this._featureFormViewModel.validateContingencyConstraints(e.attributes,{includeIncompleteViolations:!0})?.length)}async _setUpCreatingFeaturesStep(){if(this.hasHandles(Z))return;const{data:e,sketchViewModel:s}=this,{creationInfo:n,viewModel:l}=e,{attachmentsViewModel:c,view:h}=l;if(!h||!n?.layer)throw new a("missing-parameters","CreateFeaturesWorkflow requires a view and creationInfo.");const{initialFeature:p,layer:m}=n,f=[];this._featureFormHandle=o(this._featureFormHandle),this._visualVariableAttributes={rotation:null,size:null},this.data.editorItem=l.findEditorItemForLayer(n.layer),D(c),f.push(d((()=>c.mode),(e=>{switch(e){case"add":this.go("adding-attachment");break;case"edit":this.go("editing-attachment")}})));const w=L(h);f.push(w);const y=v(n.layer);try{if(y){const{template:e}=n;if(e&&g(e))throw new a("Shared templates are not yet supported");const i=p??new t({attributes:{...e?.prototype.attributes,...n.attributeOverrides},sourceLayer:m});await this._startUpdating({feature:i})}else f.push(N._configureSketchViewModel(this)),p?(s.layer.add(p),await this._startUpdating({feature:p})):await this._startCreating()}finally{w.remove()}const F=i((()=>{for(const t of e.pendingFeatures)s.layer.remove(t),e.removePendingFeature(t)})),_=d((()=>h?.timeZone),(e=>this._featureFormViewModel.timeZone=e),u),M=i((()=>{I(n)&&l.cancelWorkflow({warnIfNoWorkflow:!1})}));this._featureFormHandle&&f.push(this._featureFormHandle),this.addHandles(f,this._handleKeys.beforeCommit),this.addHandles([i((()=>c.fileInfos.removeAll())),r(f),M,F,_],Z)}async _waitForActiveToolCleared(){const e=this.data.viewModel.view;if(null==e?.activeTool)return;const t=new AbortController;this.addHandles(s(t),q),await h((()=>null==e?.activeTool),t.signal),t.abort()}};function J(e,t){let a=null;const s=()=>e.snappingOptions.featureSources,o=()=>(a=new b({layer:e.layer}),s().add(a),a),l=()=>{null!=a&&(s().remove(a),a=n(a))};return r([d((()=>{const e=t.creationInfo?.layer,a=s().find((t=>t.layer===e));return{hasFeatureLayerSource:!!a,enabled:a?.enabled??!1}}),(({hasFeatureLayerSource:e,enabled:t})=>{if(!e)return l();a??=o(),a.enabled=t}),p),i(l)])}function Q(e){const t=e.viewModel.view;if(!t)return[];const a=[];if("3d"===t.type){const r=new _({view:t});a.push(d((()=>e.selectedPendingFeature),((e,t)=>{r.remove(e),r.add(t)})),i((()=>r.destroy())))}const r=new _({view:t,highlightName:V});return a.push(d((()=>e.temporaryHighlightFeature),(e=>{r.removeAll(),r.add(e)})),i((()=>r.destroy()))),a}function X(e,t,a,i){const r=[];return t.forEach(((t,s)=>{if(!t.error){const o=e[s],n=i.get(o)||[];o.attributes[a.objectIdField]=t.objectId,n.forEach((({form:e})=>r.push({feature:o,attachment:e})))}})),r}function Y(e,t,a){const i=[],r=t.globalIdField;return e.forEach(((t,s)=>{e[s].attributes[r]??=m(),(a?.get(t)||[]).forEach((({file:e})=>i.push({feature:t,attachment:{globalId:m(),data:e}})))})),i.length?{addFeatures:e,addAttachments:i}:{addFeatures:e}}e([f()],B.prototype,"createFeatureState",void 0),e([f()],B.prototype,"data",void 0),e([f({constructOnly:!0})],B.prototype,"isNested",void 0),e([f()],B.prototype,"featureFormViewModel",null),e([f()],B.prototype,"hasPendingEdits",null),e([f()],B.prototype,"hasPreviousStep",null),e([f()],B.prototype,"_getDrawMeshHelpMessage",void 0),e([f()],B.prototype,"helpMessage",null),e([f()],B.prototype,"layer",null),e([f()],B.prototype,"parent",null),e([f()],B.prototype,"parentLayer",null),e([f()],B.prototype,"keyboardCancellationEnabled",null),e([f()],B.prototype,"reliesOnOwnerAdminPrivileges",null),e([f()],B.prototype,"shouldShowAttachments",null),e([f()],B.prototype,"shouldAllowAttachmentEditing",null),e([f()],B.prototype,"sketchViewModel",null),e([f()],B.prototype,"availableCreateTools",null),B=N=e([w("esri.widgets.Editor.CreateFeaturesWorkflow")],B);const $=B;export{$ 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.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../chunks/tslib.es6.js";import{createTask as e}from"../../core/asyncUtils.js";import a from"../../core/Collection.js";import i from"../../core/Error.js";import r from"../../core/Evented.js";import{makeHandle as s}from"../../core/handleUtils.js";import o from"../../core/Logger.js";import{abortMaybe as n,removeMaybe as l,destroyMaybe as p}from"../../core/maybe.js";import{throwIfAborted as d,createResolver as c}from"../../core/promiseUtils.js";import{watch as u,on as h,when as w,whenOnce as f,syncAndInitial as m,initial as y,sync as k}from"../../core/reactiveUtils.js";import{property as g}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as v}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as _}from"../../core/support/UpdatingHandles.js";import W from"../../layers/GraphicsLayer.js";import{isEditableLayer as F}from"../../layers/support/editableLayers.js";import{isFeatureLayer as E,getOwningPortalUrl as M}from"../../layers/support/layerUtils.js";import{parseKnownArcGISOnlineDomain as I}from"../../portal/support/urlUtils.js";import b from"../../views/interactive/sketch/SketchOptions.js";import{SnappingManager as C}from"../../views/interactive/snapping/SnappingManager.js";import V from"../../views/interactive/snapping/SnappingOptions.js";import A from"../Attachments/AttachmentsViewModel.js";import U from"./CreateFeaturesWorkflow.js";import O from"./UpdateWorkflow.js";import{isUpdateWorkflow as T,whenEditorLayerView as L}from"./workflowUtils.js";import S from"./support/EditorItem.js";import j from"../FeatureTemplates/FeatureTemplatesViewModel.js";import P from"../Sketch/SketchViewModel.js";import R from"../Spinner/SpinnerViewModel.js";const H="esri.widgets.Editor.EditorViewModel",x=()=>o.getLogger(H);function D(t,e,a){x().error(new i(t,e,a))}function G(t,e){return t?.find((t=>t.layer===e))}let q=class extends r.EventedAccessor{constructor(t){super(t),this._sketchEventListenerHandle=null,this._sketchGraphicsLayer=new W({listMode:"hide",internal:!0}),this._snappingManager=null,this._updateItemsTask=null,this._updatingHandles=new _,this._featureTemplatesViewModelLocked=!1,this.activeWorkflow=null,this._activityQueue=new a,this.editorItems=new a,this.failures=[],this.hideTemplatesForInactiveLayers=!1,this.attachmentsViewModel=new A({capabilities:{editing:!0}}),this.featureTemplatesViewModel=new j({disabledItemFunction:({layer:t})=>this._itemIsSuspended(t)}),this.layerInfos=null,this.ownSketchViewModel=new P({layer:this._sketchGraphicsLayer}),this.sketchOptions=new b,this.snappingOptions=new V({attributeRulesEnabled:!0}),this.spinnerViewModel=new R,this.pageStack=[],this.showDiscardEditsPrompt=()=>Promise.resolve(!0),this._candidateCommitted=!1,this.back=async()=>{this.canGoBack&&(this.activeWorkflow?.hasPreviousStep?await this.activeWorkflow.back(this.showDiscardEditsPrompt):await this._cancelWorkflow({force:!this.hasPendingEdits}))},this.saveWorkflow=async()=>{const{featureFormViewModel:t}=this;if(t&&"create-features"!==this.activeWorkflow?.type){if(t.submit(),!t.submittable||t.pendingSubtypeChoice)return;const e=t.getValues();if(t.validateContingencyConstraints(e,{includeIncompleteViolations:!0}).length>0)return}await(this.activeWorkflow?.save())},this.selectFeature=(t,e=!1)=>{const a=this.activeWorkflow;this._candidateCommitted||"update"!==a?.type||(a.data.rootFeature=t,e&&(a.next(),this._candidateCommitted=!0))}}initialize(){this.addHandles([u((()=>{const t=this.view,e=t?.map?.editableLayers,a=t?.allLayerViews,i=a?.filter((t=>!!e?.includes(t.layer)));return[e,i,this.layerInfos]}),(()=>this._updateEditorItems()),m),u((()=>this.hideTemplatesForInactiveLayers),(()=>this.syncFeatureTemplates())),h((()=>this.activeWorkflow),"cancel",(()=>this.emit("workflow-cancel"))),h((()=>this.activeWorkflow),"commit",(()=>this.emit("workflow-commit"))),h((()=>this.activeWorkflow),"complete",(()=>{this.emit("workflow-commit"),this._set("activeWorkflow",null)})),w((()=>this.view?.map),(t=>t.add(this._sketchGraphicsLayer)),y),h((()=>this.editorItems),"change",(()=>this._afterEditorItemsChange())),u((()=>[this.canCreate,this.canUpdateVisible]),(()=>this._afterEditorItemsChange())),u((()=>this.page),((t,e)=>{const a=[...this.pageStack];if(-1===a.indexOf(t))a.push(t);else for(;a.length&&a.at(-1)!==t;)a.pop();this.pageStack=a}),m),w((()=>"awaiting-update-feature-candidate"===this.state),(()=>this._candidateCommitted=!1)),h((()=>this.featureTemplatesViewModel),"select",(async({item:t,oldItem:e})=>{const{activeWorkflow:a}=this;if(a){if("update"===a.type&&"awaiting-feature-creation-info"===a.activeWorkflow?.stepId)return;try{await this.cancelWorkflow({force:!this.hasPendingEdits})}catch{return void this.featureTemplatesViewModel.select(e,{emit:!1})}}if(!t)return;const i={layer:t.layer,template:t.template};if(t.supportsUpload)return this.featureTemplatesViewModel.select(e,{emit:!1}),this.startCreateFeaturesWorkflow(i);this.startCreateFeaturesWorkflowAtFeatureCreation(i)})),h((()=>this.view),"key-down",(t=>{"Escape"===t.key&&this.activeWorkflow?.keyboardCancellationEnabled&&(t.stopPropagation(),this.back())})),h((()=>this.sketchViewModel),["create","delete","update"],(t=>{const{activeWorkflow:e}=this,a="update"===e?.type,i=a?e.activeWorkflow?.layer:e?.layer,r=a?e?.activeWorkflow?.parentLayer:void 0,s=`sketch-${t.type}`;this.emit(s,{type:s,detail:t,layer:i,parentLayer:r})}),k),u((()=>this.view),(t=>{if(this._snappingManager=p(this._snappingManager),!t)return;const e=this.snappingOptions;this._snappingManager=new C({view:t,options:e}),this.ownSketchViewModel.snappingManager=this._snappingManager}),m),u((()=>this.snappingOptions),(t=>{this._snappingManager&&(this._snappingManager.options=t)}),m)])}destroy(){this._cancelWorkflow({warnIfNoWorkflow:!1}).then((()=>{this.view?.map?.remove(this._sketchGraphicsLayer),this.view=null})),this._updateItemsTask=n(this._updateItemsTask),this._updatingHandles.destroy(),this._sketchEventListenerHandle=l(this._sketchEventListenerHandle)}get activeLeafWorkflow(){const t=this.activeWorkflow;return t&&T(t)?t.activeWorkflow??t:t}get canCreate(){return this.editorItems.some((t=>t.supportsCreateFeaturesWorkflow))}get canCreateVisible(){return!!this.featureTemplatesLayers.length}get canUpdate(){return this.editorItems.some((t=>t.supportsUpdateWorkflow))}get canUpdateVisible(){return this.editorItems.some((t=>t.supportsUpdateWorkflow&&t.visible))}get featureTemplatesLayers(){const t=new a;for(const e of this.editorItems){const a=e.supportsCreateFeaturesWorkflow&&!e.isTable,i=this.hideTemplatesForInactiveLayers&&!e.visible;a&&!i&&t.push(e.layer)}return t}get featureFormViewModel(){const{activeWorkflow:t}=this;return"update"===t?.type?t.activeFeatureFormViewModel:"create-features"===t?.type?t.featureFormViewModel:null}get labelOptions(){return this.sketchOptions.labels}set labelOptions(t){this.sketchOptions.labels=t}get sketchViewModel(){const{activeWorkflow:t}=this;return"update"===t?.type?t.activeSketchViewModel:"create-features"===t?.type?t.sketchViewModel:this.ownSketchViewModel}get state(){if(!this.view?.ready)return"disabled";const t=this.attachmentsViewModel.mode;if("add"===t)return"adding-attachment";if("edit"===t)return"editing-attachment";const{activeWorkflow:e}=this;return e?.stepId?"update"===e.type&&e.activeWorkflow?.stepId?e.activeWorkflow.stepId:e.stepId:"ready"}get syncing(){return this._activityQueue.length>0}get updating(){return this._updatingHandles.updating||!0===this.activeWorkflow?.updating}get tooltipOptions(){return this.sketchOptions.tooltips}set tooltipOptions(t){this.sketchOptions.tooltips=t}get valueOptions(){return this.sketchOptions.values}set valueOptions(t){this.sketchOptions.values=t}set view(t){this.ownSketchViewModel.view=t,this.spinnerViewModel.view=t,this._set("view",t)}get page(){const{activeWorkflow:t,state:e}=this;if("update"===t?.type&&null!=t?.activeWorkflow?.featureFormViewModel.associatedLayer)return"viewing-associated-features";if("update"===t?.type&&null!=t?.activeWorkflow?.featureFormViewModel.associationId)return"viewing-associated-layers";if("update"===t?.type&&"awaiting-feature-to-update"===t.stepId)return"ready";if("create-features"===t?.type&&0===t.numPendingFeatures){const e=t.data.upload;if(e)return"default"===e.state?"ready":"creating-features-upload-details"}return e??"disabled"}get featureFormDisabled(){const{activeWorkflow:t}=this;return"update"===t?.type&&!1===t.activeEditorItem?.capabilities.update.attributes}get featureFormHasAssociation(){return!!this.featureFormViewModel?.activeAssociation}get canGoBack(){return null!=this.activeWorkflow&&!this.syncing}get shouldShowDeleteButton(){const{activeWorkflow:t}=this;return!!t&&"update"===t.type&&!!t.activeEditorItem?.capabilities.delete.enabled}get hasPendingEdits(){return this.activeWorkflow?.hasPendingEdits??!1}get snappingManager(){return this._snappingManager}async startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.startCreateFeaturesWorkflow()}async startCreateFeaturesWorkflowAtFeatureCreation(t){return this.startCreateFeaturesWorkflow(t,"creating-features")}async startCreateFeaturesWorkflow(t,e="awaiting-feature-creation-info"){if(await f((()=>!this.updating)),!this.canCreate)throw new i("editing:unsupported-workflow","Creating features is unsupported or disabled.");const a=this._createUpdatingResolver();try{await this._cancelWorkflow();const a=this._createCreateFeaturesWorkflow(t,e);this._set("activeWorkflow",a),await a.start()}catch(r){this._logErrorAndCancelWorkflow(r)}finally{a.resolve()}}async startCreateFeaturesWorkflowAtFeatureEdit(t){await f((()=>!this.updating));const e=this._createUpdatingResolver();try{const{initialFeature:e}=t,a=e.sourceLayer=e.layer,r=a?this.findEditorItemForLayer(a):void 0;if(!r?.supportsCreateFeaturesWorkflow)throw new i("editing:unsupported-workflow","Creating features is unsupported or disabled for this layer.");await this._cancelWorkflow();const s=this._createCreateFeaturesWorkflow({initialFeature:e,layer:r.layer,maxFeatures:1},"creating-features");this._set("activeWorkflow",s),await s.start()}catch(a){this._logErrorAndCancelWorkflow(a)}finally{e.resolve()}}async startUpdateWorkflowAtFeatureSelection(){if(await f((()=>!this.updating)),!this.canUpdate)return void D("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const t=this._createUpdatingResolver();try{await this._cancelWorkflow();const t=this._createUpdateWorkflow();this._set("activeWorkflow",t),await t.start()}catch(e){this._logErrorAndCancelWorkflow(e)}finally{t.resolve()}}async startUpdateWorkflowAtMultipleFeatureSelection(t){if(await f((()=>!this.updating)),!this.canUpdate)return void D("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const e=this._createUpdatingResolver();try{await this._cancelWorkflow();const e=this._createUpdateWorkflow("awaiting-update-feature-candidate");e.data.candidates=t,this._set("activeWorkflow",e),await e.start()}catch(a){this._logErrorAndCancelWorkflow(a)}finally{e.resolve()}}async startUpdateWorkflowAtFeatureEdit(t){if(await f((()=>!this.updating)),!this.canUpdate)return void D("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const e=this._createUpdatingResolver();try{await this._cancelWorkflow();const e=this._createUpdateWorkflow("editing-existing-feature");e.data.rootFeature=t,this._set("activeWorkflow",e),await e.start()}catch(a){this._logErrorAndCancelWorkflow(a)}finally{e.resolve()}}async deleteFeatureFromWorkflow(){const{activeWorkflow:t}=this;t&&"update"===t.type?await t.deleteActiveFeature():D("editing:unsupported-workflow","Deleting a feature requires an active update workflow.")}async deleteAssociationFromWorkflow(){const{activeWorkflow:t}=this;t&&"update"===t.type?await t.deleteActiveAssociation():D("editing:unsupported-workflow","Deleting an association requires an active update workflow.")}async cancelWorkflow(t){return this._cancelWorkflow({warnIfNoWorkflow:!0,...t})}findEditorItemForLayer(t){return this.editorItems.find((e=>e.layer===t))}itemHasInvalidFormTemplate(t){return null!=t&&!0===this.findEditorItemForLayer(t.layer)?.hasInvalidFormTemplate}syncFeatureTemplates(){this._featureTemplatesViewModelLocked||(this.featureTemplatesViewModel.layers=this.featureTemplatesLayers.toArray())}zoomTo(t){const e=t??this.sketchViewModel?.updateGraphics.toArray();e&&this.view?.goTo(e)}async toggleUpdateWorkflow(){this.canUpdate&&(this.hasPendingEdits&&!await this.showDiscardEditsPrompt()||(this.activeWorkflow&&"awaiting-feature-to-update"===this.state?await this.cancelWorkflow({force:!0}):await this.startUpdateWorkflowAtFeatureSelection()))}lockFeatureTemplatesViewModel(){return this._featureTemplatesViewModelLocked=!0,s((()=>{this._featureTemplatesViewModelLocked=!1,this.syncFeatureTemplates()}))}async _getEditorItemCandidates(t){const{view:e}=this;if(!e?.map)return[];const{map:a}=e,i=a.editableLayers.toArray()??[],r=a.allTables.toArray().filter(E)??[];return await Promise.allSettled([...i.map((t=>"subtype-group"===t.type?t.loadAll():Promise.resolve())),...r.map((t=>t.load()))]),d(t),[...i.reverse(),...r.reverse()].filter((t=>F(t)&&("mesh"!==t.geometryType||"3d"===e.type))).flatMap((t=>"subtype-group"===t.type?t.sublayers.toArray():t))}_drainEditorItems(){this.editorItems.drain((t=>t.destroy()))}async _updateEditorItems(){n(this._updateItemsTask);const{view:t}=this,a=e((async e=>{if(!t?.map||!t?.allLayerViews)return;const a=await this._getEditorItemCandidates(e);if(!a.length)return void this._drainEditorItems();const i=[],r=[],s=[],{layerInfos:o}=this;for(const l of a){const e=G(o,l),a=await L(t,l).catch((()=>null));(e?i:a?r:s).push(new S({layer:l,layerInfo:e,layerView:a}))}o?.length&&i.sort(((t,e)=>o.findIndex((({layer:e})=>e===t.layer))-o.findIndex((({layer:t})=>t===e.layer))));const n=[...i,...r,...s];e.aborted||(this._drainEditorItems(),this.editorItems.addMany(n))}));this._updatingHandles.addPromise(a.promise),this._updateItemsTask=a}_afterEditorItemsChange(){const{activeWorkflow:t}=this;if(this.syncFeatureTemplates(),!t)return;const{stepId:e}=t;"create-features"!==t.type?"update"===t.type&&("awaiting-feature-to-update"===e&&!this.canUpdateVisible||"awaiting-update-feature-candidate"===e&&!t.hasUpdatableCandidates)&&this._cancelWorkflow():"awaiting-feature-creation-info"!==e||this.canCreate||this._cancelWorkflow()}async _cancelWorkflow(t){const e=this.activeWorkflow;if(!e)return void(t?.warnIfNoWorkflow&&D("editing:no-active-workflow","There is no active workflow to cancel."));if(!t||!1!==t.force)return this.emit("workflow-cancel"),this._set("activeWorkflow",null),void await e.cancel(t);await e.cancel(t),this._set("activeWorkflow",null)}_createCreateFeaturesWorkflow(t,e){return U.create({viewModel:this,creationInfo:t,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:e,applyEditsCallback:(t,e,a)=>this._applyEdits(t,e,a),addAttachmentsCallback:(t,e)=>this._addAttachments(t,e)})}_createUpdateWorkflow(t){return O.create({viewModel:this,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:t,applyEditsCallback:(t,e,a)=>this._applyEdits(t,e,a),applyEditsAssociationCallback:(t,e,a)=>this._applyEditsAssociation(t,e,a),addAttachmentsCallback:(t,e)=>this._addAttachments(t,e)})}_addAttachments(t,e){const a=e.map((e=>this._addAttachment(t,e.feature,e.attachment)))??[];return Promise.all(a)}async _addAttachment(t,e,a){let r=null;if(!("addAttachment"in t)||null==t.capabilities?.attachment)throw new i("editor:attachments-not-supported","Adding attachments is not supported for this layer type");return await this._queueOperation((async()=>(r=await(t.addAttachment?.(e,a).catch((t=>{throw t?.error||t})))??null,r))),r}async _applyEdits(t,e,a){let i=null;const r=t.url?await M(t.url):null,s={returnServiceEditsOption:(!r||!I(r))&&!RegExp("/hosted/","i").test(t.url)?"original-and-current-features":void 0,...a};return await this._queueOperation((async()=>{const{view:a}=this;if(!a)return null;const r=await L(a,t).catch((()=>null));return i=await t.applyEdits(e,s),r&&await f((()=>!r.updating)),i})),i}async _applyEditsAssociation(t,e,a){let i=null;const r={globalIdUsed:!0,...a};return await this._queueOperation((async()=>i=await t.applyEdits(e,r))),i}_queueOperation(t){this._activityQueue.push(t);const e=(t,e)=>{const a=e.indexOf(t);a>-1&&e.splice(a,1)};return t().then((t=>(Array.isArray(t)?t.forEach((t=>this._handleEditsResultError(t))):this._handleEditsResultError(t),t))).catch((a=>{D("editing:operation-error","An error occurred.",{error:a});const i={error:a,retry:()=>(e(i,this.failures),this._queueOperation(t)),cancel:()=>{e(i,this.failures)}};this._set("failures",[...this.failures,i])})).then((()=>{e(t,this._activityQueue)}))}_handleEditsResultError(t){if(null!=t&&"error"in t&&null!=t.error)throw t.error;if(null!=t&&"addFeatureResults"in t){const{addFeatureResults:e,deleteFeatureResults:a,updateFeatureResults:i}=t,r=e.find((t=>!!t.error))||i.find((t=>!!t.error))||a.find((t=>!!t.error));if(r)throw r.error}}_createUpdatingResolver(){const t=c();return this._updatingHandles.addPromise(t.promise),t}_logErrorAndCancelWorkflow(t){const{name:e,message:a,details:i}=t;D(e??"editing:workflow-start-failed",a??void 0,i??t),this._cancelWorkflow({force:!0})}_itemIsSuspended(t){const e=this.findEditorItemForLayer(t);return null!=e&&(!e.visible||e.disabled)}};t([g()],q.prototype,"_snappingManager",void 0),t([g({readOnly:!0})],q.prototype,"activeWorkflow",void 0),t([g()],q.prototype,"activeLeafWorkflow",null),t([g({readOnly:!0})],q.prototype,"_activityQueue",void 0),t([g({readOnly:!0})],q.prototype,"canCreate",null),t([g()],q.prototype,"canCreateVisible",null),t([g({readOnly:!0})],q.prototype,"canUpdate",null),t([g()],q.prototype,"canUpdateVisible",null),t([g()],q.prototype,"featureTemplatesLayers",null),t([g()],q.prototype,"editorItems",void 0),t([g({readOnly:!0})],q.prototype,"failures",void 0),t([g()],q.prototype,"hideTemplatesForInactiveLayers",void 0),t([g({type:A})],q.prototype,"attachmentsViewModel",void 0),t([g()],q.prototype,"featureFormViewModel",null),t([g({type:j})],q.prototype,"featureTemplatesViewModel",void 0),t([g()],q.prototype,"labelOptions",null),t([g()],q.prototype,"layerInfos",void 0),t([g()],q.prototype,"ownSketchViewModel",void 0),t([g()],q.prototype,"sketchOptions",void 0),t([g()],q.prototype,"sketchViewModel",null),t([g({type:V,nonNullable:!0})],q.prototype,"snappingOptions",void 0),t([g()],q.prototype,"spinnerViewModel",void 0),t([g()],q.prototype,"state",null),t([g({readOnly:!0})],q.prototype,"syncing",null),t([g()],q.prototype,"updating",null),t([g()],q.prototype,"tooltipOptions",null),t([g()],q.prototype,"valueOptions",null),t([g()],q.prototype,"view",null),t([g()],q.prototype,"pageStack",void 0),t([g()],q.prototype,"showDiscardEditsPrompt",void 0),t([g()],q.prototype,"_candidateCommitted",void 0),t([g()],q.prototype,"page",null),t([g()],q.prototype,"featureFormDisabled",null),t([g()],q.prototype,"featureFormHasAssociation",null),t([g()],q.prototype,"canGoBack",null),t([g()],q.prototype,"shouldShowDeleteButton",null),t([g()],q.prototype,"hasPendingEdits",null),t([g()],q.prototype,"snappingManager",null),q=t([v(H)],q);const B=q;export{B as default};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import{createTask as e}from"../../core/asyncUtils.js";import a from"../../core/Collection.js";import i from"../../core/Error.js";import r from"../../core/Evented.js";import{makeHandle as o}from"../../core/handleUtils.js";import s from"../../core/Logger.js";import{abortMaybe as n,removeMaybe as l,destroyMaybe as p}from"../../core/maybe.js";import{throwIfAborted as d,createResolver as c}from"../../core/promiseUtils.js";import{watch as u,on as h,when as w,whenOnce as f,syncAndInitial as m,initial as y,sync as k}from"../../core/reactiveUtils.js";import{property as g}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as v}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as _}from"../../core/support/UpdatingHandles.js";import W from"../../layers/GraphicsLayer.js";import{isEditableLayer as F}from"../../layers/support/editableLayers.js";import{isFeatureLayer as E,getOwningPortalUrl as M}from"../../layers/support/layerUtils.js";import{parseKnownArcGISOnlineDomain as I}from"../../portal/support/urlUtils.js";import b from"../../views/interactive/sketch/SketchOptions.js";import{SnappingManager as C}from"../../views/interactive/snapping/SnappingManager.js";import V from"../../views/interactive/snapping/SnappingOptions.js";import A from"../Attachments/AttachmentsViewModel.js";import U from"./CreateFeaturesWorkflow.js";import O from"./UpdateWorkflow.js";import{isUpdateWorkflow as T,whenEditorLayerView as L}from"./workflowUtils.js";import S from"./support/EditorItem.js";import j from"../FeatureTemplates/FeatureTemplatesViewModel.js";import P from"../Sketch/SketchViewModel.js";import R from"../Spinner/SpinnerViewModel.js";const G="esri.widgets.Editor.EditorViewModel",H=()=>s.getLogger(G);function x(t,e,a){H().error(new i(t,e,a))}function D(t,e){return t?.find((t=>t.layer===e))}let q=class extends r.EventedAccessor{constructor(t){super(t),this._sketchEventListenerHandle=null,this._sketchGraphicsLayer=new W({listMode:"hide",internal:!0}),this._snappingManager=null,this._updateItemsTask=null,this._updatingHandles=new _,this._featureTemplatesViewModelLocked=!1,this.activeWorkflow=null,this._activityQueue=new a,this.editorItems=new a,this.failures=[],this.hideTemplatesForInactiveLayers=!1,this.attachmentsViewModel=new A({capabilities:{editing:!0}}),this.featureTemplatesViewModel=new j({disabledItemFunction:({layer:t})=>this._itemIsSuspended(t)}),this.layerInfos=null,this.ownSketchViewModel=new P({layer:this._sketchGraphicsLayer}),this.sketchOptions=new b,this.snappingOptions=new V({attributeRulesEnabled:!0}),this.spinnerViewModel=new R,this.pageStack=[],this.showDiscardEditsPrompt=()=>Promise.resolve(!0),this._candidateCommitted=!1,this.back=async()=>{this.canGoBack&&(this.activeWorkflow?.hasPreviousStep?await this.activeWorkflow.back(this.showDiscardEditsPrompt):await this._cancelWorkflow({force:!this.hasPendingEdits}))},this.saveWorkflow=async()=>{const{featureFormViewModel:t}=this;if(t&&"create-features"!==this.activeWorkflow?.type){if(t.submit(),!t.submittable||t.pendingSubtypeChoice)return;const e=t.getValues();if(t.validateContingencyConstraints(e,{includeIncompleteViolations:!0}).length>0)return}await(this.activeWorkflow?.save())},this.selectFeature=(t,e=!1)=>{const a=this.activeWorkflow;this._candidateCommitted||"update"!==a?.type||(a.data.rootFeature=t,e&&(a.next(),this._candidateCommitted=!0))}}initialize(){this.addHandles([u((()=>{const t=this.view,e=t?.map?.editableLayers,a=t?.allLayerViews,i=a?.filter((t=>!!e?.includes(t.layer)));return[e,i,this.layerInfos]}),(()=>this._updateEditorItems()),m),u((()=>this.hideTemplatesForInactiveLayers),(()=>this.syncFeatureTemplates())),h((()=>this.activeWorkflow),"cancel",(()=>this.emit("workflow-cancel"))),h((()=>this.activeWorkflow),"commit",(()=>this.emit("workflow-commit"))),h((()=>this.activeWorkflow),"complete",(()=>{this.emit("workflow-commit"),this._set("activeWorkflow",null)})),w((()=>this.view?.map),(t=>t.add(this._sketchGraphicsLayer)),y),h((()=>this.editorItems),"change",(()=>this._afterEditorItemsChange())),u((()=>[this.canCreate,this.canUpdateVisible]),(()=>this._afterEditorItemsChange())),u((()=>this.page),((t,e)=>{const a=[...this.pageStack];if(-1===a.indexOf(t))a.push(t);else for(;a.length&&a.at(-1)!==t;)a.pop();this.pageStack=a}),m),w((()=>"awaiting-update-feature-candidate"===this.state),(()=>this._candidateCommitted=!1)),h((()=>this.featureTemplatesViewModel),"select",(async({item:t,oldItem:e})=>{const{activeWorkflow:a}=this;if(a){if("update"===a.type&&"awaiting-feature-creation-info"===a.activeWorkflow?.stepId)return;try{await this.cancelWorkflow({force:!this.hasPendingEdits})}catch{return void this.featureTemplatesViewModel.select(e,{emit:!1})}}if(!t)return;const i={layer:t.layer,template:t.template};if(t.supportsUpload)return this.featureTemplatesViewModel.select(e,{emit:!1}),this.startCreateFeaturesWorkflow(i);this.startCreateFeaturesWorkflowAtFeatureCreation(i)})),h((()=>this.view),"key-down",(t=>{"Escape"===t.key&&this.activeWorkflow?.keyboardCancellationEnabled&&(t.stopPropagation(),this.back())})),h((()=>this.sketchViewModel),["create","delete","update"],(t=>{const{activeWorkflow:e}=this,a="update"===e?.type,i=a?e.activeWorkflow?.layer:e?.layer,r=a?e?.activeWorkflow?.parentLayer:void 0,o=`sketch-${t.type}`;this.emit(o,{type:o,detail:t,layer:i,parentLayer:r})}),k),u((()=>this.view),(t=>{if(this._snappingManager=p(this._snappingManager),!t)return;const e=this.snappingOptions;this._snappingManager=new C({view:t,options:e}),this.ownSketchViewModel.snappingManager=this._snappingManager}),m),u((()=>this.snappingOptions),(t=>{this._snappingManager&&(this._snappingManager.options=t)}),m)])}destroy(){this._cancelWorkflow({warnIfNoWorkflow:!1}).then((()=>{this.view?.map?.remove(this._sketchGraphicsLayer),this.view=null})),this._updateItemsTask=n(this._updateItemsTask),this._updatingHandles.destroy(),this._sketchEventListenerHandle=l(this._sketchEventListenerHandle)}get activeLeafWorkflow(){const t=this.activeWorkflow;return t&&T(t)?t.activeWorkflow??t:t}get canCreate(){return this.editorItems.some((t=>t.supportsCreateFeaturesWorkflow))}get canCreateVisible(){return!!this.featureTemplatesLayers.length}get canUpdate(){return this.editorItems.some((t=>t.supportsUpdateWorkflow))}get canUpdateVisible(){return this.editorItems.some((t=>t.supportsUpdateWorkflow&&t.visible))}get featureTemplatesLayers(){const t=new a;for(const e of this.editorItems){const a=e.supportsCreateFeaturesWorkflow&&!e.isTable,i=this.hideTemplatesForInactiveLayers&&!e.visible;a&&!i&&t.push(e.layer)}return t}get featureFormViewModel(){const{activeWorkflow:t}=this;return"update"===t?.type?t.activeFeatureFormViewModel:"create-features"===t?.type?t.featureFormViewModel:null}get labelOptions(){return this.sketchOptions.labels}set labelOptions(t){this.sketchOptions.labels=t}get sketchViewModel(){const{activeWorkflow:t}=this;return"update"===t?.type?t.activeSketchViewModel:"create-features"===t?.type?t.sketchViewModel:this.ownSketchViewModel}get state(){if(!this.view?.ready)return"disabled";const t=this.attachmentsViewModel.mode;if("add"===t)return"adding-attachment";if("edit"===t)return"editing-attachment";const{activeWorkflow:e}=this;return e?.stepId?"update"===e.type&&e.activeWorkflow?.stepId?e.activeWorkflow.stepId:e.stepId:"ready"}get syncing(){return this._activityQueue.length>0}get updating(){return this._updatingHandles.updating||!0===this.activeWorkflow?.updating}get tooltipOptions(){return this.sketchOptions.tooltips}set tooltipOptions(t){this.sketchOptions.tooltips=t}get valueOptions(){return this.sketchOptions.values}set valueOptions(t){this.sketchOptions.values=t}set view(t){this.ownSketchViewModel.view=t,this.spinnerViewModel.view=t,this._set("view",t)}get canZoomTo(){const t=this.sketchViewModel,e=t?.createGraphic?.geometry?.type;return!(!t?.updateGraphics?.length&&"multipoint"!==e)}get page(){const{activeWorkflow:t,state:e}=this;if("update"===t?.type&&null!=t?.activeWorkflow?.featureFormViewModel.associatedLayer)return"viewing-associated-features";if("update"===t?.type&&null!=t?.activeWorkflow?.featureFormViewModel.associationId)return"viewing-associated-layers";if("update"===t?.type&&"awaiting-feature-to-update"===t.stepId)return"ready";if("create-features"===t?.type&&0===t.numPendingFeatures){const e=t.data.upload;if(e)return"default"===e.state?"ready":"creating-features-upload-details"}return e??"disabled"}get featureFormDisabled(){const{activeWorkflow:t}=this;return"update"===t?.type&&!1===t.activeEditorItem?.capabilities.update.attributes}get featureFormHasAssociation(){return!!this.featureFormViewModel?.activeAssociation}get canGoBack(){return null!=this.activeWorkflow&&!this.syncing}get shouldShowDeleteButton(){const{activeWorkflow:t}=this;return!!t&&"update"===t.type&&!!t.activeEditorItem?.capabilities.delete.enabled}get hasPendingEdits(){return this.activeWorkflow?.hasPendingEdits??!1}get snappingManager(){return this._snappingManager}async startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.startCreateFeaturesWorkflow()}async startCreateFeaturesWorkflowAtFeatureCreation(t){return this.startCreateFeaturesWorkflow(t,"creating-features")}async startCreateFeaturesWorkflow(t,e="awaiting-feature-creation-info"){if(await f((()=>!this.updating)),!this.canCreate)throw new i("editing:unsupported-workflow","Creating features is unsupported or disabled.");const a=this._createUpdatingResolver();try{await this._cancelWorkflow();const a=this._createCreateFeaturesWorkflow(t,e);this._set("activeWorkflow",a),await a.start()}catch(r){this._logErrorAndCancelWorkflow(r)}finally{a.resolve()}}async startCreateFeaturesWorkflowAtFeatureEdit(t){await f((()=>!this.updating));const e=this._createUpdatingResolver();try{const{initialFeature:e}=t,a=e.sourceLayer=e.layer,r=a?this.findEditorItemForLayer(a):void 0;if(!r?.supportsCreateFeaturesWorkflow)throw new i("editing:unsupported-workflow","Creating features is unsupported or disabled for this layer.");await this._cancelWorkflow();const o=this._createCreateFeaturesWorkflow({initialFeature:e,layer:r.layer,maxFeatures:1},"creating-features");this._set("activeWorkflow",o),await o.start()}catch(a){this._logErrorAndCancelWorkflow(a)}finally{e.resolve()}}async startUpdateWorkflowAtFeatureSelection(){if(await f((()=>!this.updating)),!this.canUpdate)return void x("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const t=this._createUpdatingResolver();try{await this._cancelWorkflow();const t=this._createUpdateWorkflow();this._set("activeWorkflow",t),await t.start()}catch(e){this._logErrorAndCancelWorkflow(e)}finally{t.resolve()}}async startUpdateWorkflowAtMultipleFeatureSelection(t){if(await f((()=>!this.updating)),!this.canUpdate)return void x("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const e=this._createUpdatingResolver();try{await this._cancelWorkflow();const e=this._createUpdateWorkflow("awaiting-update-feature-candidate");e.data.candidates=t,this._set("activeWorkflow",e),await e.start()}catch(a){this._logErrorAndCancelWorkflow(a)}finally{e.resolve()}}async startUpdateWorkflowAtFeatureEdit(t){if(await f((()=>!this.updating)),!this.canUpdate)return void x("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const e=this._createUpdatingResolver();try{await this._cancelWorkflow();const e=this._createUpdateWorkflow("editing-existing-feature");e.data.rootFeature=t,this._set("activeWorkflow",e),await e.start()}catch(a){this._logErrorAndCancelWorkflow(a)}finally{e.resolve()}}async deleteFeatureFromWorkflow(){const{activeWorkflow:t}=this;t&&"update"===t.type?await t.deleteActiveFeature():x("editing:unsupported-workflow","Deleting a feature requires an active update workflow.")}async deleteAssociationFromWorkflow(){const{activeWorkflow:t}=this;t&&"update"===t.type?await t.deleteActiveAssociation():x("editing:unsupported-workflow","Deleting an association requires an active update workflow.")}async cancelWorkflow(t){return this._cancelWorkflow({warnIfNoWorkflow:!0,...t})}findEditorItemForLayer(t){return this.editorItems.find((e=>e.layer===t))}itemHasInvalidFormTemplate(t){return null!=t&&!0===this.findEditorItemForLayer(t.layer)?.hasInvalidFormTemplate}syncFeatureTemplates(){this._featureTemplatesViewModelLocked||(this.featureTemplatesViewModel.layers=this.featureTemplatesLayers.toArray())}zoomTo(t){const e=this.sketchViewModel,a=t??(e?.updateGraphics.length?e?.updateGraphics.toArray():e?.createGraphic);a&&this.view?.goTo(a)}async toggleUpdateWorkflow(){this.canUpdate&&(this.hasPendingEdits&&!await this.showDiscardEditsPrompt()||(this.activeWorkflow&&"awaiting-feature-to-update"===this.state?await this.cancelWorkflow({force:!0}):await this.startUpdateWorkflowAtFeatureSelection()))}lockFeatureTemplatesViewModel(){return this._featureTemplatesViewModelLocked=!0,o((()=>{this._featureTemplatesViewModelLocked=!1,this.syncFeatureTemplates()}))}async _getEditorItemCandidates(t){const{view:e}=this;if(!e?.map)return[];const{map:a}=e,i=a.editableLayers.toArray()??[],r=a.allTables.toArray().filter(E)??[];return await Promise.allSettled([...i.map((t=>"subtype-group"===t.type?t.loadAll():Promise.resolve())),...r.map((t=>t.load()))]),d(t),[...i.reverse(),...r.reverse()].filter((t=>F(t)&&("mesh"!==t.geometryType||"3d"===e.type))).flatMap((t=>"subtype-group"===t.type?t.sublayers.toArray():t))}_drainEditorItems(){this.editorItems.drain((t=>t.destroy()))}async _updateEditorItems(){n(this._updateItemsTask);const{view:t}=this,a=e((async e=>{if(!t?.map||!t?.allLayerViews)return;const a=await this._getEditorItemCandidates(e);if(!a.length)return void this._drainEditorItems();const i=[],r=[],o=[],{layerInfos:s}=this;for(const l of a){const e=D(s,l),a=await L(t,l).catch((()=>null));(e?i:a?r:o).push(new S({layer:l,layerInfo:e,layerView:a}))}s?.length&&i.sort(((t,e)=>s.findIndex((({layer:e})=>e===t.layer))-s.findIndex((({layer:t})=>t===e.layer))));const n=[...i,...r,...o];e.aborted||(this._drainEditorItems(),this.editorItems.addMany(n))}));this._updatingHandles.addPromise(a.promise),this._updateItemsTask=a}_afterEditorItemsChange(){const{activeWorkflow:t}=this;if(this.syncFeatureTemplates(),!t)return;const{stepId:e}=t;"create-features"!==t.type?"update"===t.type&&("awaiting-feature-to-update"===e&&!this.canUpdateVisible||"awaiting-update-feature-candidate"===e&&!t.hasUpdatableCandidates)&&this._cancelWorkflow():"awaiting-feature-creation-info"!==e||this.canCreate||this._cancelWorkflow()}async _cancelWorkflow(t){const e=this.activeWorkflow;if(!e)return void(t?.warnIfNoWorkflow&&x("editing:no-active-workflow","There is no active workflow to cancel."));if(!t||!1!==t.force)return this.emit("workflow-cancel"),this._set("activeWorkflow",null),void await e.cancel(t);await e.cancel(t),this._set("activeWorkflow",null)}_createCreateFeaturesWorkflow(t,e){return U.create({viewModel:this,creationInfo:t,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:e,applyEditsCallback:(t,e,a)=>this._applyEdits(t,e,a),addAttachmentsCallback:(t,e)=>this._addAttachments(t,e)})}_createUpdateWorkflow(t){return O.create({viewModel:this,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:t,applyEditsCallback:(t,e,a)=>this._applyEdits(t,e,a),applyEditsAssociationCallback:(t,e,a)=>this._applyEditsAssociation(t,e,a),addAttachmentsCallback:(t,e)=>this._addAttachments(t,e)})}_addAttachments(t,e){const a=e.map((e=>this._addAttachment(t,e.feature,e.attachment)))??[];return Promise.all(a)}async _addAttachment(t,e,a){let r=null;if(!("addAttachment"in t)||null==t.capabilities?.attachment)throw new i("editor:attachments-not-supported","Adding attachments is not supported for this layer type");return await this._queueOperation((async()=>(r=await(t.addAttachment?.(e,a).catch((t=>{throw t?.error||t})))??null,r))),r}async _applyEdits(t,e,a){let i=null;const r=t.url?await M(t.url):null,o={returnServiceEditsOption:(!r||!I(r))&&!RegExp("/hosted/","i").test(t.url)?"original-and-current-features":void 0,...a};return await this._queueOperation((async()=>{const{view:a}=this;if(!a)return null;const r=await L(a,t).catch((()=>null));return i=await t.applyEdits(e,o),r&&await f((()=>!r.updating)),i})),i}async _applyEditsAssociation(t,e,a){let i=null;const r={globalIdUsed:!0,...a};return await this._queueOperation((async()=>i=await t.applyEdits(e,r))),i}_queueOperation(t){this._activityQueue.push(t);const e=(t,e)=>{const a=e.indexOf(t);a>-1&&e.splice(a,1)};return t().then((t=>(Array.isArray(t)?t.forEach((t=>this._handleEditsResultError(t))):this._handleEditsResultError(t),t))).catch((a=>{x("editing:operation-error","An error occurred.",{error:a});const i={error:a,retry:()=>(e(i,this.failures),this._queueOperation(t)),cancel:()=>{e(i,this.failures)}};this._set("failures",[...this.failures,i])})).then((()=>{e(t,this._activityQueue)}))}_handleEditsResultError(t){if(null!=t&&"error"in t&&null!=t.error)throw t.error;if(null!=t&&"addFeatureResults"in t){const{addFeatureResults:e,deleteFeatureResults:a,updateFeatureResults:i}=t,r=e.find((t=>!!t.error))||i.find((t=>!!t.error))||a.find((t=>!!t.error));if(r)throw r.error}}_createUpdatingResolver(){const t=c();return this._updatingHandles.addPromise(t.promise),t}_logErrorAndCancelWorkflow(t){const{name:e,message:a,details:i}=t;x(e??"editing:workflow-start-failed",a??void 0,i??t),this._cancelWorkflow({force:!0})}_itemIsSuspended(t){const e=this.findEditorItemForLayer(t);return null!=e&&(!e.visible||e.disabled)}};t([g()],q.prototype,"_snappingManager",void 0),t([g({readOnly:!0})],q.prototype,"activeWorkflow",void 0),t([g()],q.prototype,"activeLeafWorkflow",null),t([g({readOnly:!0})],q.prototype,"_activityQueue",void 0),t([g({readOnly:!0})],q.prototype,"canCreate",null),t([g()],q.prototype,"canCreateVisible",null),t([g({readOnly:!0})],q.prototype,"canUpdate",null),t([g()],q.prototype,"canUpdateVisible",null),t([g()],q.prototype,"featureTemplatesLayers",null),t([g()],q.prototype,"editorItems",void 0),t([g({readOnly:!0})],q.prototype,"failures",void 0),t([g()],q.prototype,"hideTemplatesForInactiveLayers",void 0),t([g({type:A})],q.prototype,"attachmentsViewModel",void 0),t([g()],q.prototype,"featureFormViewModel",null),t([g({type:j})],q.prototype,"featureTemplatesViewModel",void 0),t([g()],q.prototype,"labelOptions",null),t([g()],q.prototype,"layerInfos",void 0),t([g()],q.prototype,"ownSketchViewModel",void 0),t([g()],q.prototype,"sketchOptions",void 0),t([g()],q.prototype,"sketchViewModel",null),t([g({type:V,nonNullable:!0})],q.prototype,"snappingOptions",void 0),t([g()],q.prototype,"spinnerViewModel",void 0),t([g()],q.prototype,"state",null),t([g({readOnly:!0})],q.prototype,"syncing",null),t([g()],q.prototype,"updating",null),t([g()],q.prototype,"tooltipOptions",null),t([g()],q.prototype,"valueOptions",null),t([g()],q.prototype,"view",null),t([g()],q.prototype,"canZoomTo",null),t([g()],q.prototype,"pageStack",void 0),t([g()],q.prototype,"showDiscardEditsPrompt",void 0),t([g()],q.prototype,"_candidateCommitted",void 0),t([g()],q.prototype,"page",null),t([g()],q.prototype,"featureFormDisabled",null),t([g()],q.prototype,"featureFormHasAssociation",null),t([g()],q.prototype,"canGoBack",null),t([g()],q.prototype,"shouldShowDeleteButton",null),t([g()],q.prototype,"hasPendingEdits",null),t([g()],q.prototype,"snappingManager",null),q=t([v(G)],q);const B=q;export{B 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.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import a from"../../core/Error.js";import{makeHandle as i}from"../../core/handleUtils.js";import o from"../../core/Logger.js";import{abortMaybe as r}from"../../core/maybe.js";import{createResolver as s,onAbort as n,createAbortError as l,throwIfAborted as d,debounce as c}from"../../core/promiseUtils.js";import p from"../../core/Queue.js";import{whenOnce as u,when as h,watch as w,sync as f}from"../../core/reactiveUtils.js";import{last as g}from"../../core/SetUtils.js";import{property as m}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as k}from"../../core/accessorSupport/decorators/subclass.js";import{getAllStandardFeatureTemplatesForLayer as v}from"../../editing/templateUtils.js";import{isEditableLayer as y}from"../../layers/support/editableLayers.js";import{isFeatureLayer as W,isSubtypeSublayer as b,isSubtypeGroupLayer as C,isTable as _}from"../../layers/support/layerUtils.js";import{createFeatureServices as M}from"../../rest/featureService/utils.js";import A from"../../views/draw/support/HighlightHelper.js";import{ViewEventPriorities as F}from"../../views/input/InputManager.js";import S from"../../views/interactive/sketch/SketchOptions.js";import{temporaryHighlightName as I}from"../../views/support/HighlightDefaults.js";import j from"./CreateFeaturesWorkflow.js";import{UpdateFeatureWorkflow as E}from"./UpdateFeatureWorkflow.js";import{UpdateRecordWorkflow as U}from"./UpdateRecordWorkflow.js";import P from"./UpdateWorkflowData.js";import L from"./Workflow.js";import{createWorkflowSteps as V,fetchCandidates as x}from"./workflowUtils.js";import{isGraphicForRelatableFeatureSupportedLayer as O}from"../Feature/support/featureUtils.js";var R;const T="esri.widgets.Editor.UpdateWorkflow",H=()=>o.getLogger(T);let D=R=class extends L{constructor(e){super(e),this._workflowStack=new p(g),this._sketchStack=new p(g),this.data=void 0,this.type="update"}get activeEditorItem(){return this.activeWorkflow?.data.editorItem??void 0}get activeFeatureFormViewModel(){return this.activeWorkflow?.featureFormViewModel}get activeSketchViewModel(){return this._sketchStack.peek()?.viewModel}get canDeleteAssociation(){const{activeFeatureFormViewModel:e}=this;if(!this.activeWorkflow||!this.data.viewModel.view||!e)return!1;const{activeAssociation:t,feature:a}=e;return!(!t||!a?.sourceLayer||!W(a?.sourceLayer)&&!b(a?.sourceLayer))}get activeWorkflow(){return this._workflowStack.last()}get updating(){return this._updatingHandles.updating||!!this.activeWorkflow?.updating}get hasPreviousStep(){const e=this.activeWorkflow?.featureFormViewModel;return this._stepIndex>0||this.nestedWorkflowCount>1||null!=e?.relationshipId||"view"!==this.data.viewModel.attachmentsViewModel.mode||null!=e?.associationId||null!=e?.associatedLayer}get hasUpdatableCandidates(){const{candidates:e,viewModel:t}=this.data;return e.some((({layer:e})=>t.findEditorItemForLayer(e)?.supportsUpdateWorkflow))}get nestedWorkflowCount(){return this._workflowStack.length}get shouldShowAttachments(){return!!this.activeEditorItem?.capabilities.attachments.enabled}get shouldAllowAttachmentEditing(){return!!this.activeEditorItem?.capabilities.update.attachments.enabled}get hasPendingEdits(){return Array.from(this._workflowStack).some((e=>e.hasPendingEdits))}get helpMessage(){return this.activeWorkflow?.helpMessage?this.activeWorkflow.helpMessage:"awaiting-feature-to-update"===this.stepId?"select":void 0}get reliesOnOwnerAdminPrivileges(){return this.activeWorkflow?.reliesOnOwnerAdminPrivileges??!1}get hasInvalidFormTemplate(){return!!this.activeEditorItem?.hasInvalidFormTemplate}async back(e=()=>Promise.resolve(!0)){const{activeWorkflow:t}=this,a=t?.featureFormViewModel;if(null==a?.relationshipId)if(null==a?.associatedLayer)if(null==a?.associationId)if(t){if(t.hasPendingEdits){if(!await e())return}t.hasPreviousStep?await t.previous({cancelCurrentStep:!0}):await this.cancelActiveWorkflow({force:!0})}else this.hasPreviousStep?await this.previous({cancelCurrentStep:!0}):await this.cancel({force:!0});else a.associationId=null;else a.associatedLayer=null;else a.relationshipId=null}async cancelActiveWorkflow(e){await(this.activeWorkflow?.cancel(e)),await this._popWorkflow()}async commit(){await this._drainWorkflowStack((e=>e.commit())),await super.commit()}static create(e){const{viewModel:t,snappingManager:a,startAt:i,addAttachmentsCallback:o,applyEditsCallback:r,applyEditsAssociationCallback:s}=e,n=e.sketchOptions??new S,l=new R({data:new P({addAttachmentsCallback:o,applyEditsCallback:r,applyEditsAssociationCallback:s,sketchOptions:n,snappingManager:a,viewModel:t}),onCommit:async()=>{}});return l._set("steps",this._createWorkflowSteps(l,i)),l}async save(){this.nestedWorkflowCount>1?(await(this.activeWorkflow?.commit()),await this._popWorkflow()):await this.commit()}async startCreatingRelatedRecord(e){try{const t=await this._createNestedCreateFeaturesWorkflow(e);await this._pushWorkflow(t)}catch(t){throw new a("editor:unable-to-start-creating","Could not begin updating the provided feature or table record.",{error:t})}}async startUpdating(e,t){try{const a=await this._createNestedUpdateWorkflow(e,t);await this._pushWorkflow(a)}catch(i){throw new a("editor:unable-to-start-updating","Could not begin updating the provided feature or table record.",{error:i})}}async deleteActiveFeature(){const{activeWorkflow:e}=this;if(!e)throw new a("editor:nothing-to-delete","There is no feature to delete");G(e)?await e.deleteAndCommit():await e.cancel(),1===this.nestedWorkflowCount?await this.reset():(await this._popWorkflow(),await this._returnToPageWithContent())}async deleteActiveAssociation(){if(!this.canDeleteAssociation)throw new a("editor:nothing-to-delete","There is no association to delete");await this._deleteActiveAssociation(),await this._popWorkflow(),await this._returnToPageWithContent()}async cancelAll(){await this._drainWorkflowStack((e=>e.cancel({force:!0})))}async _deleteActiveAssociation(){const{activeFeatureFormViewModel:e,data:t}=this,{activeAssociation:i,feature:o}=e,{applyEditsAssociationCallback:r}=t,{sourceLayer:s}=o,n=b(s)&&s.parent?s.parent:s,l=M([n]),d=l.values().next().value?.featureService;if(!d)throw new a("editor:failed-to-delete-association","Could not retrieve feature service needed to delete association");await(d?.load());const{utilityNetwork:c}=e.allAssociationInputs[0],p=c?.generateDeleteAssociations([i]);if(!p)throw new a("editor:failed-to-delete-association","Could not create payload needed to delete association");const u=c?.gdbVersion??void 0;await r(d,[p],{gdbVersion:u})}async _returnToPageWithContent(){const{activeFeatureFormViewModel:e}=this;if(!e?.activeAssociationInput)return;const{activeAssociationInput:t,associationId:a}=e;await t.refresh(),t.associatedLayer&&!t.associatedFeatures?.length&&(e.associatedLayer=null),null==a||t.associatedFeatureInfos.size||(e.associationId=null)}async _createNestedCreateFeaturesWorkflow(e){const{relatedLayer:t}=e,{addAttachmentsCallback:i,applyEditsCallback:o,sketchOptions:r,snappingManager:s,viewModel:n}=this.data;if(!y(t))throw new a("editor:unsupported-layer","Editing is not supported on the provided layer");const l=this._getCreationInfoForNestedCreateFeaturesWorkflow(e),d=l.template||l.initialFeature?"creating-features":"awaiting-feature-creation-info",c="create-features"!==this.activeWorkflow?.type?this.activeWorkflow:void 0;return j.create({addAttachmentsCallback:i,applyEditsCallback:o,creationInfo:l,isNested:!0,parent:c,sketchOptions:r,snappingManager:s,startAt:d,viewModel:n})}_getCreationInfoForNestedCreateFeaturesWorkflow(e){const{relatedLayer:i}=e;if(!y(i)||C(i))throw new a("editor:unsupported-layer","Editing is not supported on the provided layer");const o={layer:i,maxFeatures:1},r=this._makeRelatedRecordAttributes(e),s=v(i);return s?.length>0?(o.attributeOverrides=r,1===s.length&&(o.template=s[0])):o.initialFeature=new t({sourceLayer:i,attributes:r}),o}async _createNestedUpdateWorkflow(e,t){const a=_(e.sourceLayer)?U:E,{applyEditsCallback:i,applyEditsAssociationCallback:o,sketchOptions:r,snappingManager:s,viewModel:n}=this.data,l="create-features"!==this.activeWorkflow?.type?this.activeWorkflow:void 0,d=await a.create({association:t,feature:e,parent:l,sketchOptions:r,snappingManager:s,viewModel:n,applyEdits:i,applyEditsAssociation:o,featureFormCallbacks:{addRelatedRecord:async e=>await this.startCreatingRelatedRecord(e),editRelatedRecord:async({relatedFeature:e})=>await this.startUpdating(e),selectAssociatedFeature:async({feature:e,association:t})=>await this.startUpdating(e,t)}});return await u((()=>!d.updating)),d}async _drainWorkflowStack(e){const t=this._workflowStack,a=[];for(;t.length>0;){const i=t.pop();this._sketchStack.pop();const o=e(i).then((()=>i.destroy()));this._updatingHandles.addPromise(o),a.push(o)}await Promise.all(a)}_makeRelatedRecordAttributes(e){const{parentFeature:t,relatedLayer:a,relationshipId:i}=e;if(!O(t))return;const o=a.relationships?.find((e=>e.id===i));if(!o)return void q("relationship-not-found","Could not begin creating a related record because the relationship specified could not be found on the destination layer.");if("origin"===o.role)return void q("unsupported-role","Creating new related records in the 'origin' table of a relationship is not yet supported");const r=t.sourceLayer;o.relatedTableId!==r.layerId&&q("invalid-argument-combination","The given parent feature does not belong to the relationship designated by the given relationship ID.");const s=r.relationships?.find((e=>e.id===i));if(!s)return void q("relationship-not-found","Could not begin creating a related record because the relationship specified could not be found on the origin layer.");const n=N(r,s),l=t.getAttribute(n);l||q("no-key-on-origin-feature","The given parent feature does not have a value for the relationship's origin primary key field.");const d=N(a,o);return{[d]:l}}async _popWorkflow(){this._workflowStack.pop()?.destroy(),this._sketchStack.pop();const e=await this._reconcileWorkflowStack();if(e.failureCount>0)throw new a("editor:next-workflow-failed","Popped the top workflow, but the next workflow in the stack failed to activate",e)}async _pushWorkflow(e){const t=this._workflowRequiresSketchViewModel(e);this.activeWorkflow?.exit({removeSketchHandles:t});const i=this._sketchStack,o=await(e?.start()),r=i.peek();o?(r?.exit(),i.push(o)):i.push(this._cloneSketchController(r)),this._workflowStack.push(e);const s=await this._reconcileWorkflowStack();if(s.failureCount>0)throw new a("editor:failed-to-start-updating-feature","Failed to enter the provided workflow.",s)}async _reconcileWorkflowStack(){const e=this._workflowStack,t=this._sketchStack;try{const a=e.peek();return await(a?.enter()),await(t.peek()?.enter()),{activeWorkflow:a,failureCount:0}}catch(a){e.pop().destroy(),t.pop();const{activeWorkflow:i,failureCount:o}=await this._reconcileWorkflowStack();return{activeWorkflow:i,failureCount:o+1}}}_cloneSketchController(e){return{enter:e?.enter??(async()=>{}),exit:e?.exit??(async()=>{}),viewModel:e?.viewModel}}_workflowRequiresSketchViewModel(e){const{type:t}=e;return"update-feature"===t||"create-features"===t&&!_(e.data.creationInfo?.layer)}static _createWorkflowSteps(e,t="awaiting-feature-to-update"){const{data:o}=e;return V(["awaiting-feature-to-update","awaiting-update-feature-candidate","editing-existing-feature","adding-attachment","editing-attachment"],t,{"awaiting-feature-to-update":()=>({id:"awaiting-feature-to-update",async setUp(){const{spinnerViewModel:t}=o.viewModel,a=o.viewModel.view;a.activeTool=null;let c=null;e.addHandles(i((()=>{c=r(c)})),this.id),o.rootFeature=null,o.candidates=[];const p=a.on("immediate-click",(async i=>{const r=s();e._updatingHandles.addPromise(r.promise);try{t.location=i.mapPoint,t.visible=!0,c?.abort();const{editorItems:r}=o.viewModel;c=new AbortController;const s=await i.async((()=>new Promise(((e,t)=>{n(c?.signal,(()=>t(l()))),e(x(r,a,i,c?.signal))}))));if(d(c),o.candidates=s.filter((e=>"fulfilled"===e.status)).flatMap((e=>e.value)).filter((e=>!e.isAggregate)),t.visible=1===o.candidates.length,0===o.candidates.length)return;i.stopPropagation(),1===o.candidates.length?(o.rootFeature=o.candidates[0],e.go("editing-existing-feature").catch((()=>{})).then((()=>t.visible=!1))):e.next()}finally{r.resolve()}}),F.TOOL),u=h((()=>null!=a.activeTool),(()=>e.cancel({force:!0})),{once:!0});a.focus(),e.addHandles([p,u],this.id)},async tearDown(){0===o.candidates.length&&(o.viewModel.spinnerViewModel.visible=!1),e.removeHandles(this.id)}}),"awaiting-update-feature-candidate":()=>({id:"awaiting-update-feature-candidate",async setUp(){o.rootFeature=null;const{view:t}=o.viewModel;if(!t)return;const a=new A({view:t,highlightName:I});e.addHandles([w((()=>o.rootFeature),((e,t)=>{a.remove(t),a.add(e)}),f),i((()=>a.removeAll()))],this.id)},async tearDown(){e.removeHandles(this.id)}}),"editing-existing-feature":()=>({id:"editing-existing-feature",async setUp(){const{rootFeature:t,viewModel:i}=e.data;if(!t)throw new a("editor:no-feature-specified","Cannot setup the 'updating-existing-feature' step until the root feature is defined");await e.startUpdating(t),i.spinnerViewModel.visible=!1;const o=c((async()=>{await u((()=>!e.updating)),e.previous()}));e.addHandles([w((()=>e.nestedWorkflowCount),((e,t)=>{0===e&&0!==t&&o()}),f)],this.id)},async tearDown(){await e.cancelAll(),e.removeHandles(this.id)}}),"adding-attachment":()=>({id:"adding-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){o.viewModel.attachmentsViewModel.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){o.viewModel.attachmentsViewModel.mode="view"}})})}};function N(e,{keyField:t}){return e.getField(t)?.name??t}e([m()],D.prototype,"activeEditorItem",null),e([m()],D.prototype,"activeFeatureFormViewModel",null),e([m()],D.prototype,"activeSketchViewModel",null),e([m()],D.prototype,"canDeleteAssociation",null),e([m()],D.prototype,"activeWorkflow",null),e([m()],D.prototype,"updating",null),e([m()],D.prototype,"data",void 0),e([m()],D.prototype,"hasPreviousStep",null),e([m()],D.prototype,"hasUpdatableCandidates",null),e([m()],D.prototype,"nestedWorkflowCount",null),e([m()],D.prototype,"shouldShowAttachments",null),e([m()],D.prototype,"shouldAllowAttachmentEditing",null),e([m()],D.prototype,"hasPendingEdits",null),e([m()],D.prototype,"helpMessage",null),e([m()],D.prototype,"reliesOnOwnerAdminPrivileges",null),e([m()],D.prototype,"hasInvalidFormTemplate",null),D=R=e([k(T)],D);const q=(e,t)=>H().warn(`editor:${e}`,t,"The create operation will be allowed to proceed, but the resulting feature may not be related to the given parent feature."),G=e=>!!e&&/update-/.test(e.type),z=D;export{z as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import a from"../../core/Error.js";import{makeHandle as i}from"../../core/handleUtils.js";import o from"../../core/Logger.js";import{abortMaybe as r}from"../../core/maybe.js";import{createResolver as s,onAbort as n,createAbortError as l,throwIfAborted as d,debounce as c}from"../../core/promiseUtils.js";import p from"../../core/Queue.js";import{whenOnce as u,when as w,watch as h,sync as f}from"../../core/reactiveUtils.js";import{last as g}from"../../core/SetUtils.js";import{property as m}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as k}from"../../core/accessorSupport/decorators/subclass.js";import{getAllStandardFeatureTemplatesForLayer as v}from"../../editing/templateUtils.js";import{isEditableLayer as y}from"../../layers/support/editableLayers.js";import{isFeatureLayer as W,isSubtypeSublayer as b,isSubtypeGroupLayer as C,isTable as _}from"../../layers/support/layerUtils.js";import{createFeatureServices as M}from"../../rest/featureService/utils.js";import A from"../../views/draw/support/HighlightHelper.js";import{ViewEventPriorities as S}from"../../views/input/InputManager.js";import F from"../../views/interactive/sketch/SketchOptions.js";import{temporaryHighlightName as I}from"../../views/support/HighlightDefaults.js";import j from"./CreateFeaturesWorkflow.js";import{UpdateFeatureWorkflow as E}from"./UpdateFeatureWorkflow.js";import{UpdateRecordWorkflow as U}from"./UpdateRecordWorkflow.js";import P from"./UpdateWorkflowData.js";import L from"./Workflow.js";import{createWorkflowSteps as V,fetchCandidates as x}from"./workflowUtils.js";import{findUtilityNetwork as O,isGraphicForRelatableFeatureSupportedLayer as R}from"../Feature/support/featureUtils.js";var T;const H="esri.widgets.Editor.UpdateWorkflow",D=()=>o.getLogger(H);let N=T=class extends L{constructor(e){super(e),this._workflowStack=new p(g),this._sketchStack=new p(g),this.data=void 0,this.type="update"}get activeEditorItem(){return this.activeWorkflow?.data.editorItem??void 0}get activeFeatureFormViewModel(){return this.activeWorkflow?.featureFormViewModel}get activeSketchViewModel(){return this._sketchStack.peek()?.viewModel}get canDeleteAssociation(){const{activeFeatureFormViewModel:e}=this;if(!this.activeWorkflow||!this.data.viewModel.view?.map||!e)return!1;const{activeAssociation:t,feature:a}=e;return!(!t||!a?.sourceLayer||!W(a?.sourceLayer)&&!b(a?.sourceLayer))}get activeWorkflow(){return this._workflowStack.last()}get updating(){return this._updatingHandles.updating||!!this.activeWorkflow?.updating}get hasPreviousStep(){const e=this.activeWorkflow?.featureFormViewModel;return this._stepIndex>0||this.nestedWorkflowCount>1||null!=e?.relationshipId||"view"!==this.data.viewModel.attachmentsViewModel.mode||null!=e?.associationId||null!=e?.associatedLayer}get hasUpdatableCandidates(){const{candidates:e,viewModel:t}=this.data;return e.some((({layer:e})=>t.findEditorItemForLayer(e)?.supportsUpdateWorkflow))}get nestedWorkflowCount(){return this._workflowStack.length}get shouldShowAttachments(){return!!this.activeEditorItem?.capabilities.attachments.enabled}get shouldAllowAttachmentEditing(){return!!this.activeEditorItem?.capabilities.update.attachments.enabled}get hasPendingEdits(){return Array.from(this._workflowStack).some((e=>e.hasPendingEdits))}get helpMessage(){return this.activeWorkflow?.helpMessage?this.activeWorkflow.helpMessage:"awaiting-feature-to-update"===this.stepId?"select":void 0}get reliesOnOwnerAdminPrivileges(){return this.activeWorkflow?.reliesOnOwnerAdminPrivileges??!1}get hasInvalidFormTemplate(){return!!this.activeEditorItem?.hasInvalidFormTemplate}async back(e=()=>Promise.resolve(!0)){const{activeWorkflow:t}=this,a=t?.featureFormViewModel;if(null==a?.relationshipId)if(null==a?.associatedLayer)if(null==a?.associationId)if("create-features"===t?.type&&t.hasPreviousStep)await t.previous({cancelCurrentStep:!0});else if(t){if(t.hasPendingEdits){if(!await e())return}t.hasPreviousStep?await t.previous({cancelCurrentStep:!0}):await this.cancelActiveWorkflow({force:!0})}else this.hasPreviousStep?await this.previous({cancelCurrentStep:!0}):await this.cancel({force:!0});else a.associationId=null;else a.associatedLayer=null;else a.relationshipId=null}async cancelActiveWorkflow(e){await(this.activeWorkflow?.cancel(e)),await this._popWorkflow()}async commit(){await this._drainWorkflowStack((e=>e.commit())),await super.commit()}static create(e){const{viewModel:t,snappingManager:a,startAt:i,addAttachmentsCallback:o,applyEditsCallback:r,applyEditsAssociationCallback:s}=e,n=e.sketchOptions??new F,l=new T({data:new P({addAttachmentsCallback:o,applyEditsCallback:r,applyEditsAssociationCallback:s,sketchOptions:n,snappingManager:a,viewModel:t}),onCommit:async()=>{}});return l._set("steps",this._createWorkflowSteps(l,i)),l}async save(){this.nestedWorkflowCount>1?(await(this.activeWorkflow?.commit()),await this._popWorkflow()):await this.commit()}async startCreatingRelatedRecord(e){try{const t=await this._createNestedCreateFeaturesWorkflow(e);await this._pushWorkflow(t)}catch(t){throw new a("editor:unable-to-start-creating","Could not begin updating the provided feature or table record.",{error:t})}}async startUpdating(e,t){try{const a=await this._createNestedUpdateWorkflow(e,t);await this._pushWorkflow(a)}catch(i){throw new a("editor:unable-to-start-updating","Could not begin updating the provided feature or table record.",{error:i})}}async deleteActiveFeature(){const{activeWorkflow:e}=this;if(!e)throw new a("editor:nothing-to-delete","There is no feature to delete");z(e)?await e.deleteAndCommit():await e.cancel(),1===this.nestedWorkflowCount?await this.reset():(await this._popWorkflow(),await this._returnToPageWithContent())}async deleteActiveAssociation(){if(!this.canDeleteAssociation)throw new a("editor:nothing-to-delete","There is no association to delete");await this._deleteActiveAssociation(),await this._popWorkflow(),await this._returnToPageWithContent()}async cancelAll(){await this._drainWorkflowStack((e=>e.cancel({force:!0})))}async _deleteActiveAssociation(){const{activeFeatureFormViewModel:e,data:t}=this,{activeAssociation:i,feature:o}=e,{applyEditsAssociationCallback:r,viewModel:s}=t,{sourceLayer:n}=o,l=b(n)&&n.parent?n.parent:n,d=M([l]),c=d.values().next().value?.featureService;if(!c)throw new a("editor:failed-to-delete-association","Could not retrieve feature service needed to delete association");await(c?.load());const p=s.view.map,u=O(p,l),w=u?.generateDeleteAssociations([i]);if(!w)throw new a("editor:failed-to-delete-association","Could not create payload needed to delete association");const h=u?.gdbVersion??void 0;await r(c,[w],{gdbVersion:h})}async _returnToPageWithContent(){const{activeFeatureFormViewModel:e}=this;if(!e?.activeAssociationInput)return;const{activeAssociationInput:t,associationId:a}=e;await t.refresh(),t.associatedLayer&&!t.associatedFeatures?.length&&(e.associatedLayer=null),null==a||t.associatedFeatureInfos.size||(e.associationId=null)}async _createNestedCreateFeaturesWorkflow(e){const{relatedLayer:t}=e,{addAttachmentsCallback:i,applyEditsCallback:o,sketchOptions:r,snappingManager:s,viewModel:n}=this.data;if(!y(t))throw new a("editor:unsupported-layer","Editing is not supported on the provided layer");const l=this._getCreationInfoForNestedCreateFeaturesWorkflow(e),d=l.template||l.initialFeature?"creating-features":"awaiting-feature-creation-info",c="create-features"!==this.activeWorkflow?.type?this.activeWorkflow:void 0;return j.create({addAttachmentsCallback:i,applyEditsCallback:o,creationInfo:l,isNested:!0,parent:c,sketchOptions:r,snappingManager:s,startAt:d,viewModel:n})}_getCreationInfoForNestedCreateFeaturesWorkflow(e){const{relatedLayer:i}=e;if(!y(i)||C(i))throw new a("editor:unsupported-layer","Editing is not supported on the provided layer");const o={layer:i,maxFeatures:1},r=this._makeRelatedRecordAttributes(e),s=v(i);return s?.length>0?(o.attributeOverrides=r,1===s.length&&(o.template=s[0])):o.initialFeature=new t({sourceLayer:i,attributes:r}),o}async _createNestedUpdateWorkflow(e,t){const a=_(e.sourceLayer)?U:E,{applyEditsCallback:i,applyEditsAssociationCallback:o,sketchOptions:r,snappingManager:s,viewModel:n}=this.data,l="create-features"!==this.activeWorkflow?.type?this.activeWorkflow:void 0,d=await a.create({association:t,feature:e,parent:l,sketchOptions:r,snappingManager:s,viewModel:n,applyEdits:i,applyEditsAssociation:o,featureFormCallbacks:{addRelatedRecord:async e=>await this.startCreatingRelatedRecord(e),editRelatedRecord:async({relatedFeature:e})=>await this.startUpdating(e),selectAssociatedFeature:async({feature:e,association:t})=>await this.startUpdating(e,t)}});return await u((()=>!d.updating)),d}async _drainWorkflowStack(e){const t=this._workflowStack,a=[];for(;t.length>0;){const i=t.pop();this._sketchStack.pop();const o=e(i).then((()=>i.destroy()));this._updatingHandles.addPromise(o),a.push(o)}await Promise.all(a)}_makeRelatedRecordAttributes(e){const{parentFeature:t,relatedLayer:a,relationshipId:i}=e;if(!R(t))return;const o=a.relationships?.find((e=>e.id===i));if(!o)return void G("relationship-not-found","Could not begin creating a related record because the relationship specified could not be found on the destination layer.");if("origin"===o.role)return void G("unsupported-role","Creating new related records in the 'origin' table of a relationship is not yet supported");const r=t.sourceLayer;o.relatedTableId!==r.layerId&&G("invalid-argument-combination","The given parent feature does not belong to the relationship designated by the given relationship ID.");const s=r.relationships?.find((e=>e.id===i));if(!s)return void G("relationship-not-found","Could not begin creating a related record because the relationship specified could not be found on the origin layer.");const n=q(r,s),l=t.getAttribute(n);l||G("no-key-on-origin-feature","The given parent feature does not have a value for the relationship's origin primary key field.");const d=q(a,o);return{[d]:l}}async _popWorkflow(){this._workflowStack.pop()?.destroy(),this._sketchStack.pop();const e=await this._reconcileWorkflowStack();if(e.failureCount>0)throw new a("editor:next-workflow-failed","Popped the top workflow, but the next workflow in the stack failed to activate",e)}async _pushWorkflow(e){const t=this._workflowRequiresSketchViewModel(e);this.activeWorkflow?.exit({removeSketchHandles:t});const i=this._sketchStack,o=await(e?.start()),r=i.peek();o?(r?.exit(),i.push(o)):i.push(this._cloneSketchController(r)),this._workflowStack.push(e);const s=await this._reconcileWorkflowStack();if(s.failureCount>0)throw new a("editor:failed-to-start-updating-feature","Failed to enter the provided workflow.",s)}async _reconcileWorkflowStack(){const e=this._workflowStack,t=this._sketchStack;try{const a=e.peek();return await(a?.enter()),await(t.peek()?.enter()),{activeWorkflow:a,failureCount:0}}catch(a){e.pop().destroy(),t.pop();const{activeWorkflow:i,failureCount:o}=await this._reconcileWorkflowStack();return{activeWorkflow:i,failureCount:o+1}}}_cloneSketchController(e){return{enter:e?.enter??(async()=>{}),exit:e?.exit??(async()=>{}),viewModel:e?.viewModel}}_workflowRequiresSketchViewModel(e){const{type:t}=e;return"update-feature"===t||"create-features"===t&&!_(e.data.creationInfo?.layer)}static _createWorkflowSteps(e,t="awaiting-feature-to-update"){const{data:o}=e;return V(["awaiting-feature-to-update","awaiting-update-feature-candidate","editing-existing-feature","adding-attachment","editing-attachment"],t,{"awaiting-feature-to-update":()=>({id:"awaiting-feature-to-update",async setUp(){const{spinnerViewModel:t}=o.viewModel,a=o.viewModel.view;a.activeTool=null;let c=null;e.addHandles(i((()=>{c=r(c)})),this.id),o.rootFeature=null,o.candidates=[];const p=a.on("immediate-click",(async i=>{const r=s();e._updatingHandles.addPromise(r.promise);try{t.location=i.mapPoint,t.visible=!0,c?.abort();const{editorItems:r}=o.viewModel;c=new AbortController;const s=await i.async((()=>new Promise(((e,t)=>{n(c?.signal,(()=>t(l()))),e(x(r,a,i,c?.signal))}))));if(d(c),o.candidates=s.filter((e=>"fulfilled"===e.status)).flatMap((e=>e.value)).filter((e=>!e.isAggregate)),t.visible=1===o.candidates.length,0===o.candidates.length)return;i.stopPropagation(),1===o.candidates.length?(o.rootFeature=o.candidates[0],e.go("editing-existing-feature").catch((()=>{})).then((()=>t.visible=!1))):e.next()}finally{r.resolve()}}),S.TOOL),u=w((()=>null!=a.activeTool),(()=>e.cancel({force:!0})),{once:!0});a.focus(),e.addHandles([p,u],this.id)},async tearDown(){0===o.candidates.length&&(o.viewModel.spinnerViewModel.visible=!1),e.removeHandles(this.id)}}),"awaiting-update-feature-candidate":()=>({id:"awaiting-update-feature-candidate",async setUp(){o.rootFeature=null;const{view:t}=o.viewModel;if(!t)return;const a=new A({view:t,highlightName:I});e.addHandles([h((()=>o.rootFeature),((e,t)=>{a.remove(t),a.add(e)}),f),i((()=>a.removeAll()))],this.id)},async tearDown(){e.removeHandles(this.id)}}),"editing-existing-feature":()=>({id:"editing-existing-feature",async setUp(){const{rootFeature:t,viewModel:i}=e.data;if(!t)throw new a("editor:no-feature-specified","Cannot setup the 'updating-existing-feature' step until the root feature is defined");await e.startUpdating(t),i.spinnerViewModel.visible=!1;const o=c((async()=>{await u((()=>!e.updating)),e.previous()}));e.addHandles([h((()=>e.nestedWorkflowCount),((e,t)=>{0===e&&0!==t&&o()}),f)],this.id)},async tearDown(){await e.cancelAll(),e.removeHandles(this.id)}}),"adding-attachment":()=>({id:"adding-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){o.viewModel.attachmentsViewModel.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){o.viewModel.attachmentsViewModel.mode="view"}})})}};function q(e,{keyField:t}){return e.getField(t)?.name??t}e([m()],N.prototype,"activeEditorItem",null),e([m()],N.prototype,"activeFeatureFormViewModel",null),e([m()],N.prototype,"activeSketchViewModel",null),e([m()],N.prototype,"canDeleteAssociation",null),e([m()],N.prototype,"activeWorkflow",null),e([m()],N.prototype,"updating",null),e([m()],N.prototype,"data",void 0),e([m()],N.prototype,"hasPreviousStep",null),e([m()],N.prototype,"hasUpdatableCandidates",null),e([m()],N.prototype,"nestedWorkflowCount",null),e([m()],N.prototype,"shouldShowAttachments",null),e([m()],N.prototype,"shouldAllowAttachmentEditing",null),e([m()],N.prototype,"hasPendingEdits",null),e([m()],N.prototype,"helpMessage",null),e([m()],N.prototype,"reliesOnOwnerAdminPrivileges",null),e([m()],N.prototype,"hasInvalidFormTemplate",null),N=T=e([k(H)],N);const G=(e,t)=>D().warn(`editor:${e}`,t,"The create operation will be allowed to proceed, but the resulting feature may not be related to the given parent feature."),z=e=>!!e&&/update-/.test(e.type),Q=N;export{Q 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.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as o}from"../../chunks/tslib.es6.js";import e from"../../core/Accessor.js";import{property as t}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";import l from"../support/SnappingControls/VisibleElements.js";let n=class extends e{constructor(o){super(o),this.createFeaturesSection=!0,this.directionModePicker=!1,this.editFeaturesSection=!0,this.flow=!0,this.labelsToggle=!0,this.settingsMenu=!0,this.snappingControls=!0,this.snappingControlsElements=new l,this.tooltipsToggle=!0,this.undoRedoButtons=!0,this.sketch=!0}};o([t({type:Boolean,nonNullable:!0})],n.prototype,"createFeaturesSection",void 0),o([t({type:Boolean,nonNullable:!0})],n.prototype,"directionModePicker",void 0),o([t({type:Boolean,nonNullable:!0})],n.prototype,"editFeaturesSection",void 0),o([t({type:Boolean,nonNullable:!0})],n.prototype,"flow",void 0),o([t({type:Boolean,nonNullable:!0})],n.prototype,"labelsToggle",void 0),o([t({type:Boolean,nonNullable:!0})],n.prototype,"settingsMenu",void 0),o([t({type:Boolean,nonNullable:!0})],n.prototype,"snappingControls",void 0),o([t({type:l,nonNullable:!0})],n.prototype,"snappingControlsElements",void 0),o([t({type:Boolean,nonNullable:!0})],n.prototype,"tooltipsToggle",void 0),o([t({type:Boolean,nonNullable:!0})],n.prototype,"undoRedoButtons",void 0),o([t({type:Boolean,nonNullable:!0})],n.prototype,"sketch",void 0),n=o([s("esri.widgets.Editor.VisibleElements")],n);const r=n;export{r as default};
5
+ import{_ as o}from"../../chunks/tslib.es6.js";import e from"../../core/Accessor.js";import{property as t}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";import n from"../support/SnappingControls/VisibleElements.js";let l=class extends e{constructor(o){super(o),this.createFeaturesSection=!0,this.directionModePicker=!1,this.editFeaturesSection=!0,this.flow=!0,this.labelsToggle=!0,this.settingsMenu=!0,this.snappingControls=!0,this.snappingControlsElements=new n,this.tooltipsToggle=!0,this.undoRedoButtons=!0,this.sketch=!0,this.zoomToButton=!0}};o([t({type:Boolean,nonNullable:!0})],l.prototype,"createFeaturesSection",void 0),o([t({type:Boolean,nonNullable:!0})],l.prototype,"directionModePicker",void 0),o([t({type:Boolean,nonNullable:!0})],l.prototype,"editFeaturesSection",void 0),o([t({type:Boolean,nonNullable:!0})],l.prototype,"flow",void 0),o([t({type:Boolean,nonNullable:!0})],l.prototype,"labelsToggle",void 0),o([t({type:Boolean,nonNullable:!0})],l.prototype,"settingsMenu",void 0),o([t({type:Boolean,nonNullable:!0})],l.prototype,"snappingControls",void 0),o([t({type:n,nonNullable:!0})],l.prototype,"snappingControlsElements",void 0),o([t({type:Boolean,nonNullable:!0})],l.prototype,"tooltipsToggle",void 0),o([t({type:Boolean,nonNullable:!0})],l.prototype,"undoRedoButtons",void 0),o([t({type:Boolean,nonNullable:!0})],l.prototype,"sketch",void 0),o([t({type:Boolean,nonNullable:!0})],l.prototype,"zoomToButton",void 0),l=o([s("esri.widgets.Editor.VisibleElements")],l);const p=l;export{p as default};