@arcgis/core 5.1.0-next.44 → 5.1.0-next.46

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 (178) hide show
  1. package/applications/Components/featureUtils.d.ts +11 -7
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/{9aa1ad8b436b5b0dd5f5.js → 08d76c600926d7642a8b.js} +1 -1
  4. package/assets/esri/core/workers/chunks/{54db91c0a3bd1946e026.js → 0d59f5cd3fdd7d6fd693.js} +1 -1
  5. package/assets/esri/core/workers/chunks/128799741dd3c6fc69b9.js +1 -0
  6. package/assets/esri/core/workers/chunks/13eb0162d95b4d27389c.js +1 -0
  7. package/assets/esri/core/workers/chunks/1a481f3ae3146682eb00.js +1 -0
  8. package/assets/esri/core/workers/chunks/1cce2f8837ad765acf44.js +1 -0
  9. package/assets/esri/core/workers/chunks/{288082ae7b19837a3d38.js → 20e715e3aeb1c3265901.js} +1 -1
  10. package/assets/esri/core/workers/chunks/2379c64b0ca30814a815.js +1 -0
  11. package/assets/esri/core/workers/chunks/23a9070e9362b8439770.js +1 -0
  12. package/assets/esri/core/workers/chunks/2b3a8a53cd68f666676b.js +1 -0
  13. package/assets/esri/core/workers/chunks/{4d16b6ac52e25bd7e6aa.js → 32a51ce8e1a362115c89.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{392941013107bbd96503.js → 365ad1ffd496ed86637b.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{45cf181c1945e6c77a4b.js → 3a7c02616d942c81257d.js} +1 -1
  16. package/assets/esri/core/workers/chunks/3e9700445518b8f9ae1b.js +1 -0
  17. package/assets/esri/core/workers/chunks/{eab74d830c2eaa9d133b.js → 4869e2f35aaf6b058281.js} +1 -1
  18. package/assets/esri/core/workers/chunks/4b3545965b11a54184d4.js +2 -0
  19. package/assets/esri/core/workers/chunks/{10941b50f5933d168df6.js → 521a671182b0f79e3624.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{c2f3fc1b34a6782b431f.js → 5351e71ce7839636d06d.js} +1 -1
  21. package/assets/esri/core/workers/chunks/569e4479707bc6881d97.js +1 -0
  22. package/assets/esri/core/workers/chunks/5b515b5741733bcb4645.js +1 -0
  23. package/assets/esri/core/workers/chunks/{1669f1bf959c4e3083da.js → 5c0b3c76a7bc971c61dc.js} +1 -1
  24. package/assets/esri/core/workers/chunks/{5f81f9e586b3ba0c34d4.js → 5c830cce32710d70dfa6.js} +1 -1
  25. package/assets/esri/core/workers/chunks/5e9bd5ed6ecee5b15127.js +1 -0
  26. package/assets/esri/core/workers/chunks/617328964d480d4a3a45.js +1 -0
  27. package/assets/esri/core/workers/chunks/650614a9e4871714c42e.js +1 -0
  28. package/assets/esri/core/workers/chunks/66baacbef23291eab853.js +1 -0
  29. package/assets/esri/core/workers/chunks/{c9f5d72b86ecb2a30587.js → 6c49ac7888679b9f7823.js} +1 -1
  30. package/assets/esri/core/workers/chunks/7278cc37e85f0242f19b.js +1 -0
  31. package/assets/esri/core/workers/chunks/{3c597d8ef898627b8f93.js → 768bbc910be6c65ac107.js} +1 -1
  32. package/assets/esri/core/workers/chunks/{a1f36240a31057f998da.js → 79dc7045d9a2d43ba8df.js} +1 -1
  33. package/assets/esri/core/workers/chunks/{4140d4c8b6b122fc2cd4.js → 7b48c102a44606291f82.js} +1 -1
  34. package/assets/esri/core/workers/chunks/{f9da5c81535eaffc8b9c.js → 7f07f490c6fcc794c8d9.js} +1 -1
  35. package/assets/esri/core/workers/chunks/{2b386374330d96387aec.js → 851fc5290497991ba001.js} +1 -1
  36. package/assets/esri/core/workers/chunks/{30cdb2d1d9f018f1642d.js → 9032c040b214b5af775b.js} +1 -1
  37. package/assets/esri/core/workers/chunks/{ff8ec6369c8a1bee9bb4.js → 908f171b9c512d738dea.js} +1 -1
  38. package/assets/esri/core/workers/chunks/{c7799ba861ac5af08e6a.js → 92d4e962284e13ba2fc5.js} +1 -1
  39. package/assets/esri/core/workers/chunks/970d971551e42f7ae08d.js +1 -0
  40. package/assets/esri/core/workers/chunks/9802770413ad814dab29.js +1 -0
  41. package/assets/esri/core/workers/chunks/{6cc5c37d6bdaf5483bd4.js → a422cfe1e2afe0722acd.js} +1 -1
  42. package/assets/esri/core/workers/chunks/{6e8cfe69617876ee0dac.js → a69f1879735a031f62e9.js} +1 -1
  43. package/assets/esri/core/workers/chunks/{af804beb43d4d10c54d9.js → a9f35127c3f5bf42036b.js} +1 -1
  44. package/assets/esri/core/workers/chunks/{fb69a0bb025b7a5ec588.js → b45fdc04d399d2849d63.js} +1 -1
  45. package/assets/esri/core/workers/chunks/{c0cc4ca138db47052845.js → b49b608c0d58a9b55fa2.js} +1 -1
  46. package/assets/esri/core/workers/chunks/b744b950999b92393e37.js +1 -0
  47. package/assets/esri/core/workers/chunks/beb53b372d356800f333.js +1 -0
  48. package/assets/esri/core/workers/chunks/c2aa3b1344b42a904234.js +1 -0
  49. package/assets/esri/core/workers/chunks/cdeb6aec578a1c07d663.js +1 -0
  50. package/assets/esri/core/workers/chunks/{1a3f874700f86b750390.js → ce0a6bc9df30af778ac9.js} +2 -2
  51. package/assets/esri/core/workers/chunks/cf5e4cf9b1aa37eeb6b0.js +1 -0
  52. package/assets/esri/core/workers/chunks/d0adf059085ddf7151dd.js +1 -0
  53. package/assets/esri/core/workers/chunks/d2af5342fbe80e2d8c60.js +1 -0
  54. package/assets/esri/core/workers/chunks/e4e0c5a45cf32973d5d5.js +1 -0
  55. package/assets/esri/core/workers/chunks/{465cc0e00f03cdb640b2.js → e7402dfd683f82878360.js} +1 -1
  56. package/assets/esri/core/workers/chunks/{8838ff9668b472af16a1.js → ef0eae13408cbf83a64f.js} +1 -1
  57. package/assets/esri/core/workers/chunks/f1767b8ba82fdd9bd947.js +1 -0
  58. package/assets/esri/core/workers/chunks/{b86cb84c03b76e824213.js → f9fe89ced41b49608667.js} +1 -1
  59. package/assets/esri/core/workers/chunks/{3c7ee71f0d8582e6d78f.js → ff75fb0fce51ac12e656.js} +1 -1
  60. package/assets/esri/libs/lyr3d/lyr3DMain.wasm +0 -0
  61. package/assets/esri/libs/lyr3d/lyr3DWorker.wasm +0 -0
  62. package/assets/esri/libs/vxl/vxlLayer.wasm +0 -0
  63. package/assets/esri/themes/base/widgets/_Grid.scss +5 -0
  64. package/assets/esri/themes/dark/main.css +1 -1
  65. package/assets/esri/themes/light/main.css +1 -1
  66. package/assets/esri/themes/light/view.css +1 -1
  67. package/chunks/GaussianSplat.glsl.js +2 -2
  68. package/chunks/HUDMaterial.glsl.js +1 -1
  69. package/chunks/Jpg.js +1 -1
  70. package/chunks/LineCallout.glsl.js +1 -1
  71. package/chunks/PointRenderer.glsl.js +1 -1
  72. package/chunks/Terrain.glsl.js +4 -4
  73. package/chunks/Zlib.js +1 -1
  74. package/chunks/lyr3DMain.js +1 -1
  75. package/chunks/lyr3DWorker.js +1 -1
  76. package/chunks/vxlLayer.js +1 -1
  77. package/config.js +1 -1
  78. package/geometry/support/zscale.js +1 -1
  79. package/kernel.js +1 -1
  80. package/layers/IntegratedMesh3DTilesLayer.d.ts +2 -1
  81. package/layers/IntegratedMesh3DTilesLayer.js +1 -1
  82. package/layers/Lyr3DWasmPerSceneView.js +1 -1
  83. package/layers/graphics/featureConversionUtils.js +1 -1
  84. package/layers/knowledgeGraph/dataModelVisualizationUtils.js +1 -1
  85. package/layers/ogc/ogcFeatureUtils.js +1 -1
  86. package/layers/raster/formats/ImageCanvasDecoder.js +1 -1
  87. package/layers/raster/formats/JpgPlus.js +1 -1
  88. package/layers/raster/formats/RasterCodec.js +1 -1
  89. package/layers/raster/formats/TiffDecoder.js +1 -1
  90. package/layers/save/featureLayerUtils.js +1 -1
  91. package/layers/save/groupLayerUtils.js +1 -1
  92. package/layers/save/mapImageLayerUtils.js +1 -1
  93. package/layers/support/SubtypeSublayer.js +1 -1
  94. package/layers/support/layerUtils.js +1 -1
  95. package/layers/support/schemaValidator.js +1 -1
  96. package/libs/ajv/ajv.bundle-wrapper.js +2 -0
  97. package/package.json +3 -3
  98. package/renderers/visualVariables/SizeVariable.js +1 -1
  99. package/rest/locator/locationToAddress.js +1 -1
  100. package/rest/query/operations/pbfFeatureSetUtils.js +1 -1
  101. package/rest/query/operations/pbfFlatFeatureSet.js +1 -1
  102. package/rest/query/operations/pbfOptimizedFeatureSet.js +1 -1
  103. package/rest/support/LocationToAddressParameters.d.ts +62 -2
  104. package/rest/support/types.d.ts +6 -0
  105. package/support/revision.js +1 -1
  106. package/third-party-notices.txt +2 -2
  107. package/views/2d/analysis/AreaMeasurement/AreaMeasurementTool.js +1 -1
  108. package/views/2d/engine/ManagedCanvas.js +1 -1
  109. package/views/2d/engine/vectorTiles/Placement.js +1 -1
  110. package/views/2d/engine/vectorTiles/VTLPainter3D.js +1 -1
  111. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  112. package/views/2d/layers/FeatureLikeLayerView2D.js +1 -1
  113. package/views/2d/layers/TileLayerView2D.js +1 -1
  114. package/views/2d/layers/features/FeaturePipelineWorker.js +1 -1
  115. package/views/2d/layers/features/Processor.js +1 -1
  116. package/views/2d/layers/features/processor/AProcessorStrategy.js +1 -1
  117. package/views/2d/layers/features/processor/ClusterStrategy.js +1 -1
  118. package/views/2d/layers/imagery/BaseImageryTileSubView2D.js +1 -1
  119. package/views/3d/layers/GaussianSplatLayerView3D.js +1 -1
  120. package/views/3d/layers/i3s/I3SClientMaterialUtil.js +1 -1
  121. package/views/3d/terrain/OverlayRenderer.js +1 -1
  122. package/views/3d/terrain/TerrainRenderer.js +1 -1
  123. package/views/3d/terrain/TileCompositor.js +1 -1
  124. package/views/3d/webgl-engine/collections/Component/ComponentDrawParameters.js +1 -1
  125. package/views/3d/webgl-engine/core/renderPasses/RenderPassManager.js +1 -1
  126. package/views/3d/webgl-engine/core/shaderLibrary/Slice.glsl.js +3 -3
  127. package/views/3d/webgl-engine/effects/WeatherFader.js +1 -1
  128. package/views/3d/webgl-engine/effects/debug/RenderNodeVisualizerNode.js +1 -1
  129. package/views/3d/webgl-engine/effects/highlight/ShadowHighlight.js +1 -1
  130. package/views/3d/webgl-engine/lib/BindParameters.js +1 -1
  131. package/views/3d/webgl-engine/lib/GaussianSplatRenderNode.js +1 -1
  132. package/views/3d/webgl-engine/lib/RenderContext.js +1 -1
  133. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  134. package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
  135. package/views/3d/webgl-engine/shaders/GaussianSplat.glsl.js +1 -1
  136. package/views/3d/webgl-engine/shaders/GaussianSplatTechniqueConfiguration.js +1 -1
  137. package/views/3d/webgl-engine/shaders/OutputColorHighlightOLID.glsl.js +1 -1
  138. package/views/interactive/GraphicManipulator.js +1 -1
  139. package/views/webgl/InstanceCounter.js +1 -1
  140. package/webscene/support/schemaValidator.js +1 -1
  141. package/widgets/AreaMeasurement2D/AreaMeasurement2DTool.js +1 -1
  142. package/widgets/DistanceMeasurement2D/DistanceMeasurement2DTool.js +1 -1
  143. package/widgets/Editor/EditorViewModel.d.ts +1 -1
  144. package/widgets/Editor/workflowUtils.js +1 -1
  145. package/widgets/Editor.d.ts +2 -1
  146. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  147. package/widgets/FeatureTable.js +1 -1
  148. package/widgets/Sketch/SketchViewModel.js +1 -1
  149. package/widgets/Sketch/support/PluginManager.js +1 -1
  150. package/assets/esri/core/workers/chunks/02a0a58ca5916db1db19.js +0 -1
  151. package/assets/esri/core/workers/chunks/03c8453ae72a4e190252.js +0 -1
  152. package/assets/esri/core/workers/chunks/0e669a04999feb9f98c9.js +0 -1
  153. package/assets/esri/core/workers/chunks/244dd7a948ca8a7dc6ef.js +0 -1
  154. package/assets/esri/core/workers/chunks/26cafd20c8d03c274389.js +0 -1
  155. package/assets/esri/core/workers/chunks/2cd0934163cb627ce251.js +0 -1
  156. package/assets/esri/core/workers/chunks/2fa86dacc8a12a6a6c43.js +0 -1
  157. package/assets/esri/core/workers/chunks/385f1bb9164b2d488b2d.js +0 -1
  158. package/assets/esri/core/workers/chunks/3e26f9af6b8c75bad97a.js +0 -1
  159. package/assets/esri/core/workers/chunks/5a6a6e7151085a3cd3dd.js +0 -1
  160. package/assets/esri/core/workers/chunks/5eb9fdb076488de9cd83.js +0 -1
  161. package/assets/esri/core/workers/chunks/65865c25487d23dd2e31.js +0 -1
  162. package/assets/esri/core/workers/chunks/65ea5028eb12457a3aeb.js +0 -1
  163. package/assets/esri/core/workers/chunks/73d7337ac9efdbad14a4.js +0 -1
  164. package/assets/esri/core/workers/chunks/8333561a938bcdf6c2e6.js +0 -1
  165. package/assets/esri/core/workers/chunks/848c6989a6a222c7a1d8.js +0 -2
  166. package/assets/esri/core/workers/chunks/91718795fc4ca6516ac7.js +0 -1
  167. package/assets/esri/core/workers/chunks/9b80569819cd1c72a9ff.js +0 -1
  168. package/assets/esri/core/workers/chunks/a4a2e7bc3369434c5cfa.js +0 -1
  169. package/assets/esri/core/workers/chunks/b056b4c79bcd542dd1d2.js +0 -1
  170. package/assets/esri/core/workers/chunks/b553264db0f10bb8c5f7.js +0 -1
  171. package/assets/esri/core/workers/chunks/c4f64195e44986644993.js +0 -1
  172. package/assets/esri/core/workers/chunks/ca6012135929b028ea1b.js +0 -1
  173. package/assets/esri/core/workers/chunks/de79645e559a2d1ffa67.js +0 -1
  174. package/assets/esri/core/workers/chunks/df5788d42787ee8bf523.js +0 -1
  175. package/assets/esri/core/workers/chunks/f0e6a26a3625068b08ab.js +0 -1
  176. package/assets/esri/core/workers/chunks/f36a234ef35faf8ca04d.js +0 -1
  177. package/chunks/ajv.bundle.js +0 -2
  178. /package/assets/esri/core/workers/chunks/{848c6989a6a222c7a1d8.js.LICENSE.txt → 4b3545965b11a54184d4.js.LICENSE.txt} +0 -0
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{sliceEquals as i}from"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{smoothstep as r}from"../../../../core/mathUtils.js";import{disposeMaybe as s}from"../../../../core/maybe.js";import{watch as a,sync as o}from"../../../../core/reactiveUtils.js";import{signal as n}from"../../../../core/signal.js";import{property as h,subclass as c}from"../../../../core/accessorSupport/decorators.js";import{copy as u,equals as l}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as _}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ReadShadowMapPassParameters as m}from"../core/shaderLibrary/shading/ReadShadowMap.glsl.js";import{BindParameters as d}from"./BindParameters.js";import{DepthRange as p}from"./DepthRange.js";import{createQuadVAO as f}from"./glUtil3D.js";import{ShadowCastRenderer as g,shadowCastDisabledElevationThreshold as b,shadowCastDisableElevationMax as v,shadowCastDisableElevationMin as S}from"./ShadowCastRenderer.js";import{ShadowMap as y}from"./ShadowMap.js";import{S as w}from"../../../../chunks/ShadowCastAccumulate.glsl.js";import{ShadowCastAccumulateTechnique as A}from"../shaders/ShadowCastAccumulateTechnique.js";import{ShadowCastAccumulateTechniqueConfiguration as F}from"../shaders/ShadowCastAccumulateTechniqueConfiguration.js";import{ShadowCastClearTechnique as R}from"../shaders/ShadowCastClearTechnique.js";import{TaskPriority as x}from"../../../support/Scheduler.js";import{PixelType as C}from"../../../webgl/enums.js";let H=class extends t{constructor(e,t,i,r,s,n){super({}),this._fbos=e,this._techniques=t,this._stage=i,this._prepareForShadowMapPass=r,this._renderToShadowMap=s,this._requestRender=n,this._primarySet=new j(new F(0),()=>this._requestRenderIfEnabled()),this._contextSet=new j(new F(1),()=>this._requestRenderIfEnabled()),this._passParameters=new m,this._depthRange=p.Zero,this._enabled=!1,this._previewing=!1,this._shadowAccumulatorKey=Symbol("shadowAccumulator"),this._bindParameters=new d(e.rctx,new y(e,i.viewingMode)),this._bindParameters.shadowMap.enabled=!0,this._vao=f(e.rctx),this._accumulationRenderer=new g(t,e.rctx,this,n);const h=this._stage.view.resourceController.scheduler;this.addHandles([h.registerTask(x.SHADOW_ACCUMULATOR,this),a(()=>this._previewing,e=>{e?this._invalidateAccumulationSets():this._requestRenderIfEnabled()},o),a(()=>this._numActive,()=>this._numActiveChanged(),o),a(()=>this._depthRange,()=>this._invalidateAccumulationSets(),o),a(()=>this.accumulating&&this.canAccumulate,()=>this._precompile(),{sync:!0,once:!0})],this._shadowAccumulatorKey)}destroy(){this._disable(),this.removeHandles(this._shadowAccumulatorKey),this._accumulationRenderer=s(this._accumulationRenderer),this._bindParameters.shadowMap.dispose(),this._fboHandle=s(this._fboHandle),this._vao=s(this._vao);for(const e of this._accumulationSets())e.destroy();this._contextSet=null,this._primarySet=null,this._bindParameters.destroy()}*_accumulationSets(){yield this._primarySet,yield this._contextSet}get computedSamples(){return[this._primarySet.progress,this._contextSet.progress]}get shadowCastTexture(){return this._fboHandle?.getTexture()}get accumulating(){return this.active&&this._previewing||this._refining}get _refining(){return this.active&&!this._doneAccumulating&&!this._previewing}get active(){return this._enabled&&[...this._accumulationSets()].some(e=>e.active)}get canAccumulate(){return null!=this._bindParameters.depth&&this._depthRange!==p.Zero&&this._opacityFromElevation>b}get _doneAccumulating(){return[...this._accumulationSets()].every(e=>e.doneAccumulating)}get _opacityFromElevation(){return this._accumulationRenderer.opacityFromElevation}set _opacityFromElevation(e){this._accumulationRenderer.opacityFromElevation=e}get _numActive(){return[...this._accumulationSets()].reduce((e,t)=>e+(t.active?1:0),0)}get _colorFormat(){return 2===this._numActive?2:0}get readyToRun(){return this._refining&&this.canAccumulate&&[...this._accumulationSets()].some(e=>e.running)}_precompile(){for(const e of this._accumulationSets())this._techniques.precompile(A,e.configuration),this._techniques.precompile(R,e.configuration)}runTask(e){this._clearBuffersOnAccumulationStart(),this._prepareForShadowMapPass(this._bindParameters);let t=!1;for(const i of this._accumulationSets())this._runTaskForSet(i,e)&&(t=!0);t&&this._requestRender()}_runTaskForSet(e,t){let i=!1;for(;!t.done&&!e.doneAccumulating;)this._accumulateShadow(e),t.madeProgress(),i=!0;return i}renderAccumulation(e,t,i,r){return this._updateCamera(t),this._bindParameters.contentCamera=i,this._bindParameters.depth=e,this._passParameters.origin=this._bindParameters.camera.center,this.notifyChange("canAccumulate"),!(!this.accumulating||!this.canAccumulate)&&(this._previewing||r?(this._clearFramebuffer(),this._reset()):this._clearBuffersOnAccumulationStart(),this._accumulateSetsForRenderFrame(r))}_clearBuffersOnAccumulationStart(){if([...this._accumulationSets()].every(e=>0===e.progress))this._clearFramebuffer();else for(const e of this._accumulationSets())0===e.progress&&this._clearFramebufferForSet(this._fboHandle,e)}_accumulateSetsForRenderFrame(e){let t=!1;for(const i of this._accumulationSets())this._accumulateSetForRenderFrame(i,e)&&(t=!0);return t&&this._requestRender(),t}_accumulateSetForRenderFrame(e,t){let i=t?e.sampleCount:Math.min(q,e.sampleCount);i-=e.progress;for(let r=0;r<i;++r)this._accumulateShadow(e);return i>0}precompile(){this._accumulationRenderer.precompile()}render(e){this._accumulationRenderer.render(e)}setParameters(e){void 0!==e.previewing&&(this._previewing=e.previewing),void 0!==e.lightDirections&&(this._primarySet.lightDirections=e.lightDirections),void 0!==e.lightDirectionsContext&&(this._contextSet.lightDirections=e.lightDirectionsContext),!0===e.enabled?this._enable():!1===e.enabled&&this._disable(),this._accumulationRenderer.setOptions(e)}readAccumulatedShadow(e,t){const i=this._primarySet.progress;return!this.active||!this._fboHandle||i<1||e<0||e>=this._fboHandle.fbo.width||t<0||t>=this._fboHandle.fbo.height?0:(this._fboHandle.fbo.readPixels(e,t,1,1,6408,C.UNSIGNED_BYTE,P),P[0]/i)}_numActiveChanged(){if(!this._enabled||!this._fboHandle)return;const e=2===this._numActive,{width:t,height:i}=this._fboHandle.fbo,r=this._createFBO(t,i);e&&(this._clearFramebuffer(r),this._contextSet.reset()),this._rctx.blitFramebuffer(this._fboHandle.fbo,r.fbo),this._fboHandle.dispose(),this._fboHandle=r,this._requestRender()}_enable(){this._enabled||(this._enabled=!0,this._invalidateAccumulationSets())}_disable(){this._enabled&&(this._fboHandle=s(this._fboHandle),this._enabled=!1,this._requestRender())}_createFBO(e,t){return this._fbos.acquire(e,t,"shadow accumulation",this._colorFormat)}_invalidateAccumulationSets(){for(const e of this._accumulationSets())e.reset();this._requestRenderIfEnabled()}_reset(){for(const e of this._accumulationSets())e.reset()}_clearFramebuffer(e=this._fboHandle){e&&(this._rctx.bindFramebuffer(e.fbo),this._rctx.setClearColor(0,0,0,0),this._rctx.clear(16384))}_clearFramebufferForSet(e,t){if(!e)return;const i=this._techniques.get(R,t.configuration);this._rctx.bindFramebuffer(e.fbo),this._rctx.bindTechnique(i,this._bindParameters,this._passParameters),this._rctx.bindVAO(this._vao),this._rctx.drawArrays(i.primitiveType,0,this._vao.vertexCount("geometry"))}_accumulateShadow(e){this._renderToShadowMap(this._bindParameters,e.lightDirections[e.progress++],this._depthRange);const t=this._techniques.get(A,e.configuration);this._rctx.bindFramebuffer(this._fboHandle?.fbo),this._rctx.bindTechnique(t,this._bindParameters,this._passParameters),this._rctx.bindVAO(this._vao),this._rctx.drawArrays(t.primitiveType,0,this._vao.vertexCount("geometry"))}_updateCamera(e){if(!this._enabled)return;const t=this._bindParameters.camera;e.equals(t)||t.copyFrom(e),this._fboHandle?.fbo.width===e.fullWidth&&this._fboHandle?.fbo.height===e.fullHeight||(this._fboHandle?.release(),this._fboHandle=this._createFBO(e.fullWidth,e.fullHeight)),this._opacityFromElevation=1-r(S,v,e.relativeElevation)}_requestRenderIfEnabled(){this._enabled&&this._requestRender()}get _rctx(){return this._fbos.rctx}updateDepthRange(e){this._depthRange.equals(e)||(this._depthRange=e)}get test(){}};e([h()],H.prototype,"_refining",null),e([h()],H.prototype,"active",null),e([h()],H.prototype,"canAccumulate",null),e([h()],H.prototype,"_doneAccumulating",null),e([h()],H.prototype,"_opacityFromElevation",null),e([h()],H.prototype,"_numActive",null),e([h()],H.prototype,"_colorFormat",null),e([h()],H.prototype,"readyToRun",null),e([h()],H.prototype,"_depthRange",void 0),e([h()],H.prototype,"_enabled",void 0),e([h()],H.prototype,"_previewing",void 0),e([h()],H.prototype,"_accumulationRenderer",void 0),H=e([c("esri.views.3d.webgl-engine.lib.ShadowAccumulator")],H);const q=6,P=new Uint8Array(4);class j{constructor(e,t){this.configuration=e,this._notifyChange=t,this._cachedLightDirections=[],this._progress=n(0),this._sampleCount=n(0)}get progress(){return this._progress.value}set progress(e){this._progress.value=e}get sampleCount(){return this._sampleCount.value}get doneAccumulating(){return this.progress>=this.sampleCount}get running(){return this.progress>0}get active(){return this.sampleCount>0}get lightDirections(){return this._cachedLightDirections}set lightDirections(e){const t=this._cachedLightDirections,r=Math.min(w,e.length);if(!i(t,0,t.length,e,0,r,l)){t.length=r,this._sampleCount.value=r;for(let i=0;i<r;++i)t[i]=u(t[i]??_(),e[i]);this.reset(),this._notifyChange()}}destroy(){this._cachedLightDirections.length=0,this._sampleCount.value=0}reset(){this.progress=0}precompile(e){e.precompile(A,this.configuration),e.precompile(R,this.configuration)}}export{H as ShadowAccumulator};
2
+ import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{sliceEquals as i}from"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{smoothstep as r}from"../../../../core/mathUtils.js";import{releaseMaybe as s,disposeMaybe as a}from"../../../../core/maybe.js";import{watch as o,sync as n}from"../../../../core/reactiveUtils.js";import{signal as h}from"../../../../core/signal.js";import{property as c,subclass as u}from"../../../../core/accessorSupport/decorators.js";import{copy as l,equals as _}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as m}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ReadShadowMapPassParameters as d}from"../core/shaderLibrary/shading/ReadShadowMap.glsl.js";import{BindParameters as p}from"./BindParameters.js";import{DepthRange as f}from"./DepthRange.js";import{createQuadVAO as g}from"./glUtil3D.js";import{ShadowCastRenderer as b,shadowCastDisabledElevationThreshold as v,shadowCastDisableElevationMax as S,shadowCastDisableElevationMin as y}from"./ShadowCastRenderer.js";import{ShadowMap as w}from"./ShadowMap.js";import{S as A}from"../../../../chunks/ShadowCastAccumulate.glsl.js";import{ShadowCastAccumulateTechnique as R}from"../shaders/ShadowCastAccumulateTechnique.js";import{ShadowCastAccumulateTechniqueConfiguration as F}from"../shaders/ShadowCastAccumulateTechniqueConfiguration.js";import{ShadowCastClearTechnique as C}from"../shaders/ShadowCastClearTechnique.js";import{TaskPriority as x}from"../../../support/Scheduler.js";import{PixelType as H}from"../../../webgl/enums.js";let P=class extends t{constructor(e,t,i,r,a,h){super({}),this._fbos=e,this._techniques=t,this._stage=i,this._prepareForShadowMapPass=r,this._renderToShadowMap=a,this._requestRender=h,this._primarySet=new T(new F(0),()=>this._requestRenderIfEnabled()),this._contextSet=new T(new F(1),()=>this._requestRenderIfEnabled()),this._passParameters=new d,this._depthRange=f.Zero,this._enabled=!1,this._previewing=!1,this._shadowAccumulatorKey=Symbol("shadowAccumulator"),this._bindParameters=new p(e.rctx,new w(e,i.viewingMode)),this._bindParameters.shadowMap.enabled=!0,this._vao=g(e.rctx),this._accumulationRenderer=new b(t,e.rctx,this,h);const c=this._stage.view.resourceController.scheduler;this.addHandles([c.registerTask(x.SHADOW_ACCUMULATOR,this),o(()=>this._previewing,e=>{e?this._invalidateAccumulationSets():this._requestRenderIfEnabled()},n),o(()=>this._numActive,()=>this._numActiveChanged(),n),o(()=>this._depthRange,()=>this._invalidateAccumulationSets(),n),o(()=>this.readyToRun,e=>{e||(this._bindParameters.depth=s(this._bindParameters.depth),this.notifyChange("canAccumulate"))}),o(()=>this.accumulating&&this.canAccumulate,()=>this._precompile(),{sync:!0,once:!0})],this._shadowAccumulatorKey)}destroy(){this._disable(),this.removeHandles(this._shadowAccumulatorKey),this._accumulationRenderer=a(this._accumulationRenderer),this._fboHandle=a(this._fboHandle),this._vao=a(this._vao),this._bindParameters.destroy();for(const e of this._accumulationSets())e.destroy();this._contextSet=null,this._primarySet=null}*_accumulationSets(){yield this._primarySet,yield this._contextSet}get computedSamples(){return[this._primarySet.progress,this._contextSet.progress]}get shadowCastTexture(){return this._fboHandle?.getTexture()}get accumulating(){return this.active&&this._previewing||this._refining}get _refining(){return this.active&&!this._doneAccumulating&&!this._previewing}get active(){return this._enabled&&[...this._accumulationSets()].some(e=>e.active)}get canAccumulate(){return null!=this._bindParameters.depth&&this._depthRange!==f.Zero&&this._opacityFromElevation>v}get _doneAccumulating(){return[...this._accumulationSets()].every(e=>e.doneAccumulating)}get _opacityFromElevation(){return this._accumulationRenderer.opacityFromElevation}set _opacityFromElevation(e){this._accumulationRenderer.opacityFromElevation=e}get _numActive(){return[...this._accumulationSets()].reduce((e,t)=>e+(t.active?1:0),0)}get _colorFormat(){return 2===this._numActive?2:0}get readyToRun(){return this._refining&&this.canAccumulate&&[...this._accumulationSets()].some(e=>e.running)}runTask(e){this._clearBuffersOnAccumulationStart(),this._prepareForShadowMapPass(this._bindParameters);let t=!1;for(const i of this._accumulationSets())this._runTaskForSet(i,e)&&(t=!0);t&&this._requestRender()}_runTaskForSet(e,t){let i=!1;for(;!t.done&&!e.doneAccumulating;)this._accumulateShadow(e),t.madeProgress(),i=!0;return i}_precompile(){for(const e of this._accumulationSets())this._techniques.precompile(R,e.configuration),this._techniques.precompile(C,e.configuration)}renderAccumulation(e,t){return this._updateCamera(e.camera),this._bindParameters.contentCamera=e.contentCamera,this._bindParameters.depth?.release(),e.depth?.retain(),this._bindParameters.depth=e.depth,this._passParameters.origin=this._bindParameters.camera.center,this.notifyChange("canAccumulate"),!(!this.accumulating||!this.canAccumulate)&&(this._previewing||t?(this._clearFramebuffer(),this._reset()):this._clearBuffersOnAccumulationStart(),this._accumulateSetsForRenderFrame(t))}_clearBuffersOnAccumulationStart(){if([...this._accumulationSets()].every(e=>0===e.progress))this._clearFramebuffer();else for(const e of this._accumulationSets())0===e.progress&&this._clearFramebufferForSet(this._fboHandle,e)}_accumulateSetsForRenderFrame(e){let t=!1;for(const i of this._accumulationSets())this._accumulateSetForRenderFrame(i,e)&&(t=!0);return t&&this._requestRender(),t}_accumulateSetForRenderFrame(e,t){let i=t?e.sampleCount:Math.min(q,e.sampleCount);i-=e.progress;for(let r=0;r<i;++r)this._accumulateShadow(e);return i>0}precompile(){this._accumulationRenderer.precompile()}render(e){this._accumulationRenderer.render(e)}setParameters(e){void 0!==e.previewing&&(this._previewing=e.previewing),void 0!==e.lightDirections&&(this._primarySet.lightDirections=e.lightDirections),void 0!==e.lightDirectionsContext&&(this._contextSet.lightDirections=e.lightDirectionsContext),!0===e.enabled?this._enable():!1===e.enabled&&this._disable(),this._accumulationRenderer.setOptions(e)}readAccumulatedShadow(e,t){const i=this._primarySet.progress;return!this.active||!this._fboHandle||i<1||e<0||e>=this._fboHandle.fbo.width||t<0||t>=this._fboHandle.fbo.height?0:(this._fboHandle.fbo.readPixels(e,t,1,1,6408,H.UNSIGNED_BYTE,j),j[0]/i)}_numActiveChanged(){if(!this._enabled||!this._fboHandle)return;const e=2===this._numActive,{width:t,height:i}=this._fboHandle.fbo,r=this._createFBO(t,i);e&&(this._clearFramebuffer(r),this._contextSet.reset()),this._rctx.blitFramebuffer(this._fboHandle.fbo,r.fbo),this._fboHandle.dispose(),this._fboHandle=r,this._requestRender()}_enable(){this._enabled||(this._enabled=!0,this._invalidateAccumulationSets())}_disable(){this._enabled&&(this._fboHandle=a(this._fboHandle),this._enabled=!1,this._requestRender())}_createFBO(e,t){return this._fbos.acquire(e,t,"shadow accumulation",this._colorFormat)}_invalidateAccumulationSets(){for(const e of this._accumulationSets())e.reset();this._requestRenderIfEnabled()}_reset(){for(const e of this._accumulationSets())e.reset()}_clearFramebuffer(e=this._fboHandle){e&&(this._rctx.bindFramebuffer(e.fbo),this._rctx.setClearColor(0,0,0,0),this._rctx.clear(16384))}_clearFramebufferForSet(e,t){if(!e)return;const i=this._techniques.get(C,t.configuration);this._rctx.bindFramebuffer(e.fbo),this._rctx.bindTechnique(i,this._bindParameters,this._passParameters),this._rctx.bindVAO(this._vao),this._rctx.drawArrays(i.primitiveType,0,this._vao.vertexCount("geometry"))}_accumulateShadow(e){this._renderToShadowMap(this._bindParameters,e.lightDirections[e.progress++],this._depthRange);const t=this._techniques.get(R,e.configuration);this._rctx.bindFramebuffer(this._fboHandle?.fbo),this._rctx.bindTechnique(t,this._bindParameters,this._passParameters),this._rctx.bindVAO(this._vao),this._rctx.drawArrays(t.primitiveType,0,this._vao.vertexCount("geometry"))}_updateCamera(e){if(!this._enabled)return;const t=this._bindParameters.camera;e.equals(t)||t.copyFrom(e),this._fboHandle?.fbo.width===e.fullWidth&&this._fboHandle?.fbo.height===e.fullHeight||(this._fboHandle?.release(),this._fboHandle=this._createFBO(e.fullWidth,e.fullHeight)),this._opacityFromElevation=1-r(y,S,e.relativeElevation)}_requestRenderIfEnabled(){this._enabled&&this._requestRender()}get _rctx(){return this._fbos.rctx}updateDepthRange(e){this._depthRange.equals(e)||(this._depthRange=e)}get test(){}};e([c()],P.prototype,"_refining",null),e([c()],P.prototype,"active",null),e([c()],P.prototype,"canAccumulate",null),e([c()],P.prototype,"_doneAccumulating",null),e([c()],P.prototype,"_opacityFromElevation",null),e([c()],P.prototype,"_numActive",null),e([c()],P.prototype,"_colorFormat",null),e([c()],P.prototype,"readyToRun",null),e([c()],P.prototype,"_depthRange",void 0),e([c()],P.prototype,"_enabled",void 0),e([c()],P.prototype,"_previewing",void 0),e([c()],P.prototype,"_accumulationRenderer",void 0),P=e([u("esri.views.3d.webgl-engine.lib.ShadowAccumulator")],P);const q=6,j=new Uint8Array(4);class T{constructor(e,t){this.configuration=e,this._notifyChange=t,this._cachedLightDirections=[],this._progress=h(0),this._sampleCount=h(0)}get progress(){return this._progress.value}set progress(e){this._progress.value=e}get sampleCount(){return this._sampleCount.value}get doneAccumulating(){return this.progress>=this.sampleCount}get running(){return this.progress>0}get active(){return this.sampleCount>0}get lightDirections(){return this._cachedLightDirections}set lightDirections(e){const t=this._cachedLightDirections,r=Math.min(A,e.length);if(!i(t,0,t.length,e,0,r,_)){t.length=r,this._sampleCount.value=r;for(let i=0;i<r;++i)t[i]=l(t[i]??m(),e[i]);this.reset(),this._notifyChange()}}destroy(){this._cachedLightDirections.length=0,this._sampleCount.value=0}reset(){this.progress=0}precompile(e){e.precompile(R,this.configuration),e.precompile(C,this.configuration)}}export{P as ShadowAccumulator};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import"../../../../core/libs/gl-matrix-2/math/vec2.js";import"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import"../core/shaderLibrary/shading/EvaluateSceneLighting.glsl.js";import"../core/shaderLibrary/shading/NormalUtils.glsl.js";import"../core/shaderLibrary/shading/PositionOutsideClipSpace.js";import"../core/shaderLibrary/shading/TerrainDepthTest.glsl.js";import"../core/shaderLibrary/util/ComputeCovariance.glsl.js";import"../core/shaderLibrary/util/GaussianSplatUnpacking.glsl.js";import"../core/shaderLibrary/util/QuaternionToRotationMatrix.glsl.js";import"../core/shaderLibrary/util/RgbNormalizedDepthEncoding.glsl.js";import"../core/shaderModules/Float2BindUniform.js";import"../core/shaderModules/Float2PassUniform.js";import"../core/shaderModules/Float3BindUniform.js";import"../core/shaderModules/Float3PassUniform.js";import"../core/shaderModules/FloatPassUniform.js";import"../core/shaderModules/glsl.js";import"../core/shaderModules/Matrix4BindUniform.js";import"../core/shaderModules/Texture2DUintPassUniform.js";import"./GaussianSplatTechniqueConfiguration.js";import"../../../webgl/ShaderBuilder.js";export{G as GaussianSplatPassParameters,b as build}from"../../../../chunks/GaussianSplat.glsl.js";
2
+ import"../../../../core/libs/gl-matrix-2/math/vec2.js";import"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import"../core/shaderLibrary/Slice.glsl.js";import"../core/shaderLibrary/shading/EvaluateSceneLighting.glsl.js";import"../core/shaderLibrary/shading/NormalUtils.glsl.js";import"../core/shaderLibrary/shading/PositionOutsideClipSpace.js";import"../core/shaderLibrary/shading/TerrainDepthTest.glsl.js";import"../core/shaderLibrary/util/ComputeCovariance.glsl.js";import"../core/shaderLibrary/util/GaussianSplatUnpacking.glsl.js";import"../core/shaderLibrary/util/QuaternionToRotationMatrix.glsl.js";import"../core/shaderLibrary/util/RgbNormalizedDepthEncoding.glsl.js";import"../core/shaderModules/Float2BindUniform.js";import"../core/shaderModules/Float2PassUniform.js";import"../core/shaderModules/Float3BindUniform.js";import"../core/shaderModules/Float3PassUniform.js";import"../core/shaderModules/FloatPassUniform.js";import"../core/shaderModules/glsl.js";import"../core/shaderModules/Matrix4BindUniform.js";import"../core/shaderModules/Texture2DUintPassUniform.js";import"./GaussianSplatTechniqueConfiguration.js";import"../../../webgl/ShaderBuilder.js";export{G as GaussianSplatPassParameters,b as build}from"../../../../chunks/GaussianSplat.glsl.js";
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{ShaderTechniqueConfiguration as t,parameter as i}from"../core/shaderTechnique/ShaderTechniqueConfiguration.js";class o extends t{constructor(e){super(),this.spherical=e,this.alphaCutoff=1,this.fadingEnabled=!1,this.clippingEnabled=!1,this.terrainDepthTest=!1,this.cullAboveTerrain=!1,this.receiveAmbientOcclusion=!1,this.pbrMode=0,this.useCustomDTRExponentForWater=!1,this.useFillLights=!1,this.hasColorTexture=!0}}function r(e){switch(e){case 2:return.005;case 0:return.05;default:return.01}}e([i({count:3})],o.prototype,"alphaCutoff",void 0),e([i()],o.prototype,"fadingEnabled",void 0),e([i()],o.prototype,"clippingEnabled",void 0),e([i()],o.prototype,"terrainDepthTest",void 0),e([i()],o.prototype,"cullAboveTerrain",void 0),e([i()],o.prototype,"receiveAmbientOcclusion",void 0);export{o as GaussianSplatTechniqueConfiguration,r as getGaussianSplatAlphaCutoffValue};
2
+ import{__decorate as e}from"tslib";import{SliceConfiguration as t}from"../core/shaderLibrary/Slice.glsl.js";import{parameter as i}from"../core/shaderTechnique/ShaderTechniqueConfiguration.js";class r extends t{constructor(e){super(),this.spherical=e,this.alphaCutoff=1,this.fadingEnabled=!1,this.clippingEnabled=!1,this.terrainDepthTest=!1,this.cullAboveTerrain=!1,this.receiveAmbientOcclusion=!1,this.pbrMode=0,this.useCustomDTRExponentForWater=!1,this.useFillLights=!1,this.hasColorTexture=!0}}function o(e){switch(e){case 2:return.005;case 0:return.05;default:return.01}}e([i({count:3})],r.prototype,"alphaCutoff",void 0),e([i()],r.prototype,"fadingEnabled",void 0),e([i()],r.prototype,"clippingEnabled",void 0),e([i()],r.prototype,"terrainDepthTest",void 0),e([i()],r.prototype,"cullAboveTerrain",void 0),e([i()],r.prototype,"receiveAmbientOcclusion",void 0);export{r as GaussianSplatTechniqueConfiguration,o as getGaussianSplatAlphaCutoffValue};
@@ -1,5 +1,5 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{isColor as o,isOITColor as r,isOITFrontFace as i}from"../core/shaderLibrary/ShaderOutput.js";import{Emissions as l}from"../core/shaderLibrary/output/Emissions.glsl.js";import{OutputHighlight as a}from"../core/shaderLibrary/output/OutputHighlight.glsl.js";import{ColorConversion as t}from"../core/shaderLibrary/util/ColorConversion.glsl.js";import{If as s,glsl as e}from"../core/shaderModules/glsl.js";import{alphaCutoff as n}from"./alphaCutoff.glsl.js";import{oitResolution as f}from"./oitResolution.glsl.js";function u(u,d){u.include(a,d),u.include(l,d);const{fragment:g,outputs:c}=u;g.include(t);const{output:m,hasEmission:C,discardInvisibleFragments:p,oitPremultipliedAlpha:h,snowCover:v,hasFloatOit:b}=d,y=11===m,O=r(m),$=i(m),E=o(m)&&!O;let j=0;(E||O)&&c.add("fragColor","vec4",j++),C&&c.add("fragEmission","vec4",j++),O&&c.add("fragAlpha","float",j++),g.include(n),g.include(f,d),g.code.add(b?"float ditherNoise() { return 0.0; }":"\n float ditherNoise() {\n return (1.0 / 255.0) *\n (fract(52.9829189 * fract(dot(gl_FragCoord.xy + gl_FragCoord.z, vec2(0.06711056, 0.00583715)))) - 0.5);\n }\n "),g.code.add(e`
2
+ import{isColor as o,isOITColor as r,isOITFrontFace as i}from"../core/shaderLibrary/ShaderOutput.js";import{Emissions as l}from"../core/shaderLibrary/output/Emissions.glsl.js";import{OutputHighlight as a}from"../core/shaderLibrary/output/OutputHighlight.glsl.js";import{ColorConversion as t}from"../core/shaderLibrary/util/ColorConversion.glsl.js";import{If as s,glsl as e}from"../core/shaderModules/glsl.js";import{alphaCutoff as n}from"./alphaCutoff.glsl.js";import{oitResolution as f}from"./oitResolution.glsl.js";function u(u,d){u.include(a,d),u.include(l,d);const{fragment:g,outputs:c}=u;g.include(t);const{output:m,hasEmission:C,discardInvisibleFragments:p,oitPremultipliedAlpha:h,snowCover:v,hasFloatOit:b}=d,y=11===m,O=r(m),$=i(m),E=o(m)&&!O;let j=0;(E||O)&&c.add("fragColor","vec4",j++),C&&c.add("fragEmission","vec4",j++),O&&c.add("fragAlpha","float",j++),g.include(n),g.include(f,d),g.code.add(b?"float ditherNoise() { return 0.0; }":"float ditherNoise() {\n return (1.0 / 255.0) *\n (fract(52.9829189 * fract(dot(gl_FragCoord.xy + gl_FragCoord.z, vec2(0.06711056, 0.00583715)))) - 0.5);\n }\n "),g.code.add(e`
3
3
  void outputColorHighlightOLID(vec4 finalColor, vec3 emissiveSymbolColor ${s(v,", float snow")}) {
4
4
  ${s(y,"finalColor.a = 1.0;")}
5
5
  ${s(p,"if (finalColor.a < alphaCutoff) { discard; }")}
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as t}from"tslib";import e from"../../core/Accessor.js";import{EventEmitter as i}from"../../core/Evented.js";import{watch as o,sync as s}from"../../core/reactiveUtils.js";import{property as l,subclass as r}from"../../core/accessorSupport/decorators.js";import{distance as n}from"../../core/libs/gl-matrix-2/math/vec3.js";import{create as a}from"../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectPointToVector as h}from"../../geometry/projection/projectPointToVector.js";import{getGraphicEffectiveElevationMode as c}from"../../support/elevationInfoUtils.js";import p from"../../symbols/support/ElevationInfo.js";import{intersectionDistance2D as m}from"./support/utils.js";let u=class extends e{set graphic(t){this._circleCollisionCache=null,this._originalSymbol=t.symbol,this._set("graphic",t),this.attachSymbolChanged()}get elevationInfo(){const{layer:t}=this.graphic,e=t&&"elevationInfo"in t?t.elevationInfo:null,i=c(this.graphic),o=e?e.offset:0;return new p({mode:i,offset:o})}set focusedSymbol(t){t!==this._get("focusedSymbol")&&(this._set("focusedSymbol",t),this._updateGraphicSymbol(),this._circleCollisionCache=null)}grabbableForEvent(){return!0}set grabbing(t){t!==this._get("grabbing")&&(this._set("grabbing",t),this._updateGraphicSymbol())}set hovering(t){t!==this._get("hovering")&&(this._set("hovering",t),this._updateGraphicSymbol())}set selected(t){t!==this._get("selected")&&(this._set("selected",t),this._updateGraphicSymbol(),this.events.emit("select-changed",{action:t?"select":"deselect"}))}get _focused(){return this._get("hovering")||this._get("grabbing")}constructor(t){super(t),this.layer=null,this.interactive=!0,this.selectable=!1,this.grabbable=!0,this.dragging=!1,this.cursor=null,this.consumesClicks=!0,this.events=new i,this._circleCollisionCache=null,this._graphicSymbolChangedHandle=null,this._originalSymbol=null}destroy(){this.detachSymbolChanged(),this._resetGraphicSymbol(),this._set("view",null)}intersectionDistance(t){const e=this.graphic;if(!1===e.visible)return null;const i=e.geometry;if(null==i)return null;const o=this._get("focusedSymbol"),s=null!=o?o:e.symbol;return"2d"===this.view.type?this._intersectDistance2D(this.view,t,i,s):this._intersectDistance3D(this.view,t,e)}attach(){this.attachSymbolChanged(),null!=this.layer&&this.layer.add(this.graphic)}detach(){this.detachSymbolChanged(),this._resetGraphicSymbol(),null!=this.layer&&this.layer.remove(this.graphic)}attachSymbolChanged(){this.detachSymbolChanged(),this._graphicSymbolChangedHandle=o(()=>this.graphic?.symbol,t=>{null!=t&&t!==this.focusedSymbol&&t!==this._originalSymbol&&(this._originalSymbol=t,this._focused&&null!=this.focusedSymbol&&(this.graphic.symbol=this.focusedSymbol))},s)}detachSymbolChanged(){null!=this._graphicSymbolChangedHandle&&(this._graphicSymbolChangedHandle.remove(),this._graphicSymbolChangedHandle=null)}onElevationChange(){}onViewChange(){}_updateGraphicSymbol(){this.graphic.symbol=this._focused&&null!=this.focusedSymbol?this.focusedSymbol:this._originalSymbol}_resetGraphicSymbol(){this.graphic.symbol=this._originalSymbol}_intersectDistance2D(t,e,i,o){const{cache:s,result:l}=m(t,e,i,o,this._circleCollisionCache)??{};return this._circleCollisionCache=s,l??null}_intersectDistance3D(t,e,i){const o=t.toMap(e,{include:[i]});return o&&h(o,g,t.renderSpatialReference)?n(g,t.state.camera.eye):null}};t([l({constructOnly:!0,nonNullable:!0})],u.prototype,"graphic",null),t([l()],u.prototype,"elevationInfo",null),t([l({constructOnly:!0,nonNullable:!0})],u.prototype,"view",void 0),t([l({value:null})],u.prototype,"focusedSymbol",null),t([l({constructOnly:!0})],u.prototype,"layer",void 0),t([l()],u.prototype,"interactive",void 0),t([l()],u.prototype,"selectable",void 0),t([l()],u.prototype,"grabbable",void 0),t([l({value:!1})],u.prototype,"grabbing",null),t([l()],u.prototype,"dragging",void 0),t([l()],u.prototype,"hovering",null),t([l({value:!1})],u.prototype,"selected",null),t([l()],u.prototype,"cursor",void 0),u=t([r("esri.views.interactive.GraphicManipulator")],u);const g=a();export{u as GraphicManipulator};
2
+ import{__decorate as t}from"tslib";import e from"../../core/Accessor.js";import{EventEmitter as i}from"../../core/Evented.js";import{watch as o,sync as s}from"../../core/reactiveUtils.js";import{property as l,subclass as r}from"../../core/accessorSupport/decorators.js";import{distance as n}from"../../core/libs/gl-matrix-2/math/vec3.js";import{create as a}from"../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectPointToVector as h}from"../../geometry/projection/projectPointToVector.js";import{getGraphicEffectiveElevationMode as c}from"../../support/elevationInfoUtils.js";import p from"../../symbols/support/ElevationInfo.js";import{intersectionDistance2D as u}from"./support/utils.js";let m=class extends e{set graphic(t){this._circleCollisionCache=null,this._originalSymbol=t.symbol,this._set("graphic",t),this.attachSymbolChanged()}get elevationInfo(){const{layer:t}=this.graphic,e=t&&"elevationInfo"in t?t.elevationInfo:null,i=c(this.graphic),o=e?e.offset:0;return new p({mode:i,offset:o})}set focusedSymbol(t){t!==this._get("focusedSymbol")&&(this._set("focusedSymbol",t),this._updateGraphicSymbol(),this._circleCollisionCache=null)}grabbableForEvent(){return!0}set grabbing(t){t!==this._get("grabbing")&&(this._set("grabbing",t),this._updateGraphicSymbol())}set hovering(t){t!==this._get("hovering")&&(this._set("hovering",t),this._updateGraphicSymbol())}set selected(t){t!==this._get("selected")&&(this._set("selected",t),this._updateGraphicSymbol(),this.events.emit("select-changed",{action:t?"select":"deselect"}))}get _focused(){return this._get("hovering")||this._get("grabbing")}constructor(t){super(t),this.layer=null,this.interactive=!0,this.selectable=!1,this.grabbable=!0,this.dragging=!1,this.cursor=null,this.consumesClicks=!0,this.events=new i,this._circleCollisionCache=null,this._graphicSymbolChangedHandle=null,this._originalSymbol=null}destroy(){this.detachSymbolChanged(),this._resetGraphicSymbol(),this._set("view",null)}intersectionDistance(t){const e=this.graphic;if(!1===e.visible)return null;const i=e.geometry;if(null==i)return null;const o=this._get("focusedSymbol"),s=null!=o?o:e.symbol;return"2d"===this.view.type?this._intersectDistance2D(this.view,t,i,s):this._intersectDistance3D(this.view,t,e)}attach(){this.attachSymbolChanged(),null!=this.layer&&this.layer.add(this.graphic)}detach(){this.detachSymbolChanged(),this._resetGraphicSymbol(),null!=this.layer&&this.layer.remove(this.graphic)}attachSymbolChanged(){this.detachSymbolChanged(),this._graphicSymbolChangedHandle=o(()=>this.graphic?.symbol,t=>{null!=t&&t!==this.focusedSymbol&&t!==this._originalSymbol&&(this._originalSymbol=t,this._focused&&null!=this.focusedSymbol&&(this.graphic.symbol=this.focusedSymbol))},s)}detachSymbolChanged(){null!=this._graphicSymbolChangedHandle&&(this._graphicSymbolChangedHandle.remove(),this._graphicSymbolChangedHandle=null)}onElevationChange(){}onViewChange(){}_updateGraphicSymbol(){this.graphic.symbol=this._focused&&null!=this.focusedSymbol?this.focusedSymbol:this._originalSymbol}_resetGraphicSymbol(){this.graphic.symbol=this._originalSymbol}_intersectDistance2D(t,e,i,o){const{cache:s,result:l}=u(t,e,i,o,this._circleCollisionCache)??{};return this._circleCollisionCache=s,l??null}_intersectDistance3D(t,e,i){const o=t.toMap(e,{include:[i]});return o&&h(o,g,t.renderSpatialReference)?n(g,t.state.camera.eye):null}};t([l({constructOnly:!0,nonNullable:!0})],m.prototype,"graphic",null),t([l()],m.prototype,"elevationInfo",null),t([l({constructOnly:!0,nonNullable:!0})],m.prototype,"view",void 0),t([l({value:null})],m.prototype,"focusedSymbol",null),t([l({constructOnly:!0})],m.prototype,"layer",void 0),t([l()],m.prototype,"interactive",void 0),t([l()],m.prototype,"selectable",void 0),t([l()],m.prototype,"grabbable",void 0),t([l({value:!1})],m.prototype,"grabbing",null),t([l()],m.prototype,"dragging",void 0),t([l()],m.prototype,"hovering",null),t([l({value:!1})],m.prototype,"selected",null),t([l()],m.prototype,"cursor",void 0),t([l({constructOnly:!0})],m.prototype,"consumesClicks",void 0),m=t([r("esri.views.interactive.GraphicManipulator")],m);const g=a();export{m as GraphicManipulator};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{getKey as t}from"../../core/object.js";import{AllocationTracer as r}from"./AllocationTracer.js";import{ResourceType as e}from"./enums.js";const o={RECORD_ALLOCATIONS:!1};class n{constructor(){for(this._current=new Array,this._allocations=o.RECORD_ALLOCATIONS?new r("WebGLObject"):null;this._current.length<e.COUNT;)this._current.push(0)}increment(t,r,e=1){this._current[t]+=e,this._allocations?.add(r)}decrement(t,r,e=1){this._current[t]-=e,this._allocations?.remove(r)}get current(){return this._current}get total(){return this.current.reduce((t,r,o)=>t+(o<e.UNCOUNTED?r:0),0)}get resourceInformation(){let r="";if(this.total>0){r+="Live objects:\n";for(let o=0;o<e.COUNT;++o){const n=this._current[o];n>0&&(r+=`${t(e,o)}: ${n}\n`)}}return r+=this._allocations?.resetLog(),r}}export{n as InstanceCounter,o as test};
2
+ import{getKey as t}from"../../core/object.js";import{AllocationTracer as r}from"./AllocationTracer.js";import{ResourceType as e}from"./enums.js";const o={RECORD_ALLOCATIONS:!0};class n{constructor(){for(this._current=new Array,this._allocations=o.RECORD_ALLOCATIONS?new r("WebGLObject"):null;this._current.length<e.COUNT;)this._current.push(0)}increment(t,r,e=1){this._current[t]+=e,this._allocations?.add(r)}decrement(t,r,e=1){this._current[t]-=e,this._allocations?.remove(r)}get current(){return this._current}get total(){return this.current.reduce((t,r,o)=>t+(o<e.UNCOUNTED?r:0),0)}get resourceInformation(){let r="";if(this.total>0){r+="Live objects:\n";for(let o=0;o<e.COUNT;++o){const n=this._current[o];n>0&&(r+=`${t(e,o)}: ${n}\n`)}}return r+=this._allocations?.resetLog(),r}}export{n as InstanceCounter,o as test};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import e from"../../WebScene.js";import n from"../../core/Error.js";import r from"../../core/Version.js";import{A as o}from"../../chunks/ajv.bundle.js";import{json as t}from"../../portal/schemas/webScene.js";import{convertAjvErrors as s}from"../../support/validationUtilsAjv.js";let i=null;function c(e,n){d(n);const r=h();return r.validate(j(n),e)?[]:s(r.errors??[])}async function a(n){let o=r.parse(n.version||"","webscene");const t=r.parse(e.version,"webscene");if(o.major===t.major&&o.minor===t.minor)return c(n);o.lessThan(1,38)&&(o=new r(1,38,"webscene"));const i=h(),a=m(o);if(null==i.getSchema(a)){const e=await fetch(l(o));if(e.ok){const n=await e.json();i.addSchema(n,a)}}return i.validate(a,n)?[]:s(i.errors??[])}async function f(e){const n=await a(e);if(n.length)throw new p(n)}function m(e){return`webscene-schema-v${e.major}.${e.minor}.json`}function l(e){return`https://js.arcgis.com/webscene-spec/${m(e)}`}function u(e){const n=e?t.definitions[j(e)]:void 0;if(!n)throw new Error(`invalid schema name to validate against '${e}'`);const r={};for(const o in n)r[o]=n[o];return r.definitions=t.definitions,r}function d(e){const n=j(e),r=h();if(!r.getSchema(n)){const o=u(e);r.addSchema(o,n)}}function h(){return i||(i=new o({allErrors:!0,extendRefs:!0}),i.addSchema(t,j()),i)}function w(){i=null}function j(e){return e?`${e}_schema.json`:"webScene_schema.json"}class p extends n{constructor(e){super("webscene:validation-failed",`WebScene validation failed with ${e.length} ${1===e.length?"error":"errors"}.`,{errors:e})}}export{p as WebSceneValidationError,f as assertValidWebScene,w as clearValidator,l as getVersionedWebSceneSchemaCDNUrl,c as validate,a as validateWebScene};
2
+ import e from"../../WebScene.js";import n from"../../core/Error.js";import r from"../../core/Version.js";import o from"../../libs/ajv/ajv.bundle-wrapper.js";import{json as t}from"../../portal/schemas/webScene.js";import{convertAjvErrors as s}from"../../support/validationUtilsAjv.js";let i=null;function a(e,n){d(n);const r=h();return r.validate(j(n),e)?[]:s(r.errors??[])}async function c(n){let o=r.parse(n.version||"","webscene");const t=r.parse(e.version,"webscene");if(o.major===t.major&&o.minor===t.minor)return a(n);o.lessThan(1,38)&&(o=new r(1,38,"webscene"));const i=h(),c=m(o);if(null==i.getSchema(c)){const e=await fetch(l(o));if(e.ok){const n=await e.json();i.addSchema(n,c)}}return i.validate(c,n)?[]:s(i.errors??[])}async function f(e){const n=await c(e);if(n.length)throw new p(n)}function m(e){return`webscene-schema-v${e.major}.${e.minor}.json`}function l(e){return`https://js.arcgis.com/webscene-spec/${m(e)}`}function u(e){const n=e?t.definitions[j(e)]:void 0;if(!n)throw new Error(`invalid schema name to validate against '${e}'`);const r={};for(const o in n)r[o]=n[o];return r.definitions=t.definitions,r}function d(e){const n=j(e),r=h();if(!r.getSchema(n)){const o=u(e);r.addSchema(o,n)}}function h(){return i||(i=new o({allErrors:!0,extendRefs:!0}),i.addSchema(t,j()),i)}function w(){i=null}function j(e){return e?`${e}_schema.json`:"webScene_schema.json"}class p extends n{constructor(e){super("webscene:validation-failed",`WebScene validation failed with ${e.length} ${1===e.length?"error":"errors"}.`,{errors:e})}}export{p as WebSceneValidationError,f as assertValidWebScene,w as clearValidator,l as getVersionedWebSceneSchemaCDNUrl,a as validate,c as validateWebScene};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{fetchMessageBundle as r,onLocaleChange as i}from"../../intl.js";import{multiplyOpacity as s,getContrast as a}from"../../core/colorUtils.js";import{destroyMaybe as n}from"../../core/maybe.js";import{watch as o,initial as m}from"../../core/reactiveUtils.js";import{formatDecimal as l,formatImperialArea as p,formatMetricArea as c,formatImperialLength as h,formatMetricLength as u}from"../../core/unitFormatUtils.js";import{convertUnit as d,deriveLengthUnitFromAreaUnit as v}from"../../core/units.js";import{property as y,subclass as g}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as f}from"../../core/support/UpdatingHandles.js";import{isSupported as _,geodesicDensify as w,geodesicLengths as b,geodesicAreas as L}from"../../geometry/geodesicUtils.js";import j from"../../geometry/Point.js";import S from"../../geometry/Polygon.js";import A from"../../geometry/Polyline.js";import{e as G}from"../../chunks/areaOperator.js";import{e as k,l as x}from"../../chunks/geodeticAreaOperator.js";import{e as M,l as O}from"../../chunks/geodeticDensifyOperator.js";import{e as C,l as H}from"../../chunks/geodeticLengthOperator.js";import{e as R}from"../../chunks/lengthOperator.js";import{e as T}from"../../chunks/simplifyOperator.js";import{polygonCentroidPoint as U}from"../../geometry/support/centroid.js";import q from"../../layers/GraphicsLayer.js";import z from"../../symbols/Font.js";import D from"../../symbols/SimpleFillSymbol.js";import P from"../../symbols/SimpleLineSymbol.js";import E from"../../symbols/SimpleMarkerSymbol.js";import V from"../../symbols/TextSymbol.js";import{SnappingVisualizer2D as F}from"../../views/2d/interactive/SnappingVisualizer2D.js";import W from"../../views/draw/Draw.js";import{createCoordinateHelper as I}from"../../views/interactive/coordinateHelper.js";import{createManipulatorDragEventPipeline as B,screenToMap as J,dragManipulatedObject as N}from"../../views/interactive/dragEventPipeline.js";import{GraphicManipulator as K}from"../../views/interactive/GraphicManipulator.js";import{InteractiveToolBase as Q}from"../../views/interactive/InteractiveToolBase.js";import{EditGeometry as X}from"../../views/interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as Y}from"../../views/interactive/editGeometry/EditGeometryOperations.js";import{SnappingContext as Z}from"../../views/interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as $}from"../../views/interactive/snapping/SnappingDragPipelineStep.js";import{setupSnappingToggleHandles as ee}from"../../views/interactive/snapping/snappingUtils.js";const te=1e5;let re=class extends Q{constructor(e){super(e),this._measurementLayer=new q({internal:!0,listMode:"hide",visible:!1,title:"Area measurement layer"}),this._manipulatorLayer=new q({internal:!0,listMode:"hide",visible:!1,title:"Area measurement manipulator layer"}),this._snappingLayer=new q({internal:!0,listMode:"hide",visible:!1,title:"Area measurement snapping layer"}),this._updatingHandles=new f,this._vertices=[],this._drawActive=!1,this.measurement=null,this.measurementLabel=null}initialize(){r("esri/core/t9n/Units").then(e=>{this.messages=e});const e=this.view;this._draw=new W({view:e}),e.map.addMany([this._measurementLayer,this._manipulatorLayer,this._snappingLayer]),e.focus(),this.addHandles([i(async()=>{this.messages=await r("esri/core/t9n/Units")}),o(()=>[this.unit,this.messages],()=>{this._updateGraphics()},m),o(()=>[this.view.effectiveTheme.accentColor,this.view.effectiveTheme.textColor],()=>{if(!this._vertices.length)return;const e=this._vertices.map(({coord:e})=>e);for(const{handle:t}of this._vertices)t.remove();this._vertices=[],this._measurementLayer.removeAll(),this._manipulatorLayer.removeAll(),this._snappingLayer.removeAll(),this.manipulators.removeAll(),this._updateSketch(e)})]),ee(this)}destroy(){const{map:e}=this.view;this._draw.view=null,this._draw=n(this._draw),e.removeMany([this._measurementLayer,this._manipulatorLayer,this._snappingLayer]),this._measurementLayer.removeAll(),this._manipulatorLayer.removeAll(),this._snappingLayer.removeAll(),this._set("measurement",null),this._set("measurementLabel",null),this._measurementLayer=n(this._measurementLayer),this._manipulatorLayer=n(this._manipulatorLayer),this._snappingLayer=n(this._snappingLayer),this._updatingHandles=n(this._updatingHandles),this._resetVertices()}get cursor(){return this._drawActive?"crosshair":null}set editable(e){this._set("editable",e),e||this._draw.reset()}get snappingOptions(){return this.snappingManager.options}get updating(){return this._updatingHandles.updating||this.snappingManager.updating}onActivate(){this._drawActive||0!==this._vertices.length||this._startSketch()}onShow(){this._measurementLayer.visible=!0,this._manipulatorLayer.visible=!0,this._snappingLayer.visible=!0}onHide(){this._measurementLayer.visible=!1,this._manipulatorLayer.visible=!1,this._snappingLayer.visible=!1}reset(){this.manipulators.removeAll(),this._resetVertices(),this._measurementLayer.removeAll(),this._manipulatorLayer.removeAll(),this._set("measurement",null),this._set("measurementLabel",null),this._draw.reset(),this._drawActive=!1}_getSnappingContext(e){return new Z({elevationInfo:{mode:"on-the-ground",offset:0},pointer:e,editGeometryOperations:new Y(new X("point",I(!1,!1,this.view.spatialReference)),2),visualizer:new F(this._snappingLayer)})}_resetVertices(){for(const{handle:e}of this._vertices)e.remove();this._vertices=[]}_startSketch(){this._drawActive=!0;const{snappingManager:e}=this;this._draw.create("polyline",{mode:"click",snappingManager:e}).on(["draw-complete","vertex-add","vertex-update","vertex-remove","cursor-update","undo","redo"],e=>{this._updateSketch(e.vertices),"draw-complete"===e.type&&this._stopSketch()})}_stopSketch(){if(this._vertices.length<3)return this.reset(),void this._startSketch();this.manipulators.forEach(({manipulator:e})=>{e.interactive=!0}),this._drawActive=!1,this.finishToolCreation()}_updateSketch(e){const{spatialReference:t}=this.view;for(;this._vertices.length>e.length;){const{handle:e,manipulator:t}=this._vertices.pop();e.remove(),this.manipulators.remove(t)}for(let r=this._vertices.length;r<e.length;r++){const[i,s]=e[r],a=new j({x:i,y:s,spatialReference:t}),n=ie(a,this.view,this._manipulatorLayer);this.manipulators.add(n);const o=Y.fromGeometry(a,2);o.on("vertex-update",e=>{const t=e.vertices.at(0);t&&(this._vertices[r].coord=[t.pos[0],t.pos[1]],this._updateGraphics())});const m=B(n,(e,t,r,i)=>{const s=this._getSnappingContext(i),{snappingManager:a}=this,n=this._updatingHandles,{snappingStep:m}=$({snappingContext:s,snappingManager:a,updatingHandles:n});t.next(J(this.view)).next(t=>{if("start"===t.action){const r=new j(t.mapStart);e.graphic.geometry=r,o.trySetGeometry(r)}return t}).next(...m).next(N({operations:o})).next(()=>{e.graphic.geometry=o.data.geometry})});this._vertices.push({manipulator:n,coord:[i,s],handle:m})}if(this._vertices.length){const r=this._vertices.length-1,i=this._vertices[r],[s,a]=e[r];i.coord[0]===s&&i.coord[1]===a||(i.coord=[s,a],i.manipulator.graphic.geometry=new j({x:s,y:a,spatialReference:t}));const n=this._drawActive?this._vertices[r].manipulator:null;this.manipulators.forEach(({manipulator:e})=>{e.interactive=null==n||e!==n})}this._updateGraphics()}_updateGraphics(){if(this._vertices.length<2)return void this._measurementLayer.removeAll();const e=se(this._vertices.map(({coord:e})=>e),this.view.spatialReference);if(!e)return;const{measurement:r,fillGeometry:i,outlineGeometry:n}=e;this._set("measurement",r);const o=r?oe(this.messages,r,this.unit):null;if(this._set("measurementLabel",o),!i&&!n)return;let m,l,p;const{graphics:c}=this._measurementLayer,h=3===c.length,{effectiveTheme:u}=this.view;h?(m=c.at(0),l=c.at(1),p=c.at(2)):(m=new t({symbol:new D({color:s(u.accentColor,.3),outline:null})}),l=new t({symbol:new P({color:u.accentColor,width:2})}),p=new t({symbol:new V({color:u.textColor,font:new z({size:14,family:"sans-serif"}),haloColor:s(a(u.textColor,160),.5),haloSize:2})}),c.removeAll(),c.addMany([m,l,p])),m.geometry=i,l.geometry=n;const d=i?U(i):null,v=d?j.fromJSON(d):null;p.geometry=v,p.symbol.text=o?.area??""}};function ie(e,r,i){const a=8,n={style:"circle",color:s(r.effectiveTheme.accentColor,.5),outline:{type:"simple-line",width:0}},o=new E({...n,size:a}),m=new E({...n,size:1.5*a}),l=new t({geometry:e,symbol:o});return new K({view:r,layer:i,graphic:l,focusedSymbol:m})}function se(e,t){if(2===e.length){const r=new A({paths:[e],spatialReference:t});let i;return i=t.isGeographic?_(t)?w(r,te):M(r,te,{unit:"meters"}):t.isWebMercator?M(r,te,{unit:"meters"}):r,{measurement:null,fillGeometry:null,outlineGeometry:i}}e.push(e[0]);const r=new A({paths:[e],spatialReference:t}),i=new S({rings:[e],spatialReference:t});let s,a,n=null,o=null;if(t.isGeographic)if(_(t)){if(n=w(r,te),o=w(i,te),o=T(o),!o)return null;s=b([r],"meters")[0],a=L([o],"square-meters")[0]}else{if(n=M(r,te,{unit:"meters"}),o=M(i,te,{unit:"meters"}),o=T(o),!o)return null;s=C(r,{unit:"meters"}),a=k(o,{unit:"square-meters"})}else if(t.isWebMercator){if(n=M(r,te,{unit:"meters"}),o=M(i,te,{unit:"meters"}),o=T(o),!o)return null;s=C(r,{unit:"meters"}),a=k(o,{unit:"square-meters"})}else{if(n=r,o=T(i),!o)return null;s=R(r,{unit:"meters"}),a=G(o,{unit:"square-meters"})}return{measurement:{geometry:o,area:a,perimeter:s},fillGeometry:o,outlineGeometry:n}}function ae(e){return null!=e}async function ne(e){(e?.isGeographic&&!_(e)||e?.isWebMercator)&&await Promise.all([x(),O(),H()])}function oe(e,t,r){if(!t||!e)return null;const i={area:null,perimeter:null},{area:s,perimeter:a}=t;switch(r){case"metric":i.area=c(e,s,"square-meters");break;case"imperial":i.area=p(e,s,"square-meters");break;default:{const t=d(s,"square-meters",r);i.area=l(e,t,r);break}}const n=v(r);if(n)switch(n){case"metric":i.perimeter=u(e,a,"meters");break;case"imperial":i.perimeter=h(e,a,"meters");break;default:{const t=d(a,"meters",n);i.perimeter=l(e,t,n);break}}else i.perimeter="";return i}e([y()],re.prototype,"_drawActive",void 0),e([y({readOnly:!0})],re.prototype,"cursor",null),e([y({value:!0})],re.prototype,"editable",null),e([y({readOnly:!0})],re.prototype,"measurement",void 0),e([y({readOnly:!0})],re.prototype,"measurementLabel",void 0),e([y()],re.prototype,"messages",void 0),e([y({constructOnly:!0})],re.prototype,"snappingManager",void 0),e([y()],re.prototype,"unit",void 0),e([y()],re.prototype,"updating",null),e([y({constructOnly:!0})],re.prototype,"view",void 0),re=e([g("esri.widgets.AreaMeasurement2D.AreaMeasurement2DTool")],re);export{re as AreaMeasurement2DTool,se as createAreaMeasurementInfo2D,oe as createAreaMeasurementLabel,ae as isSupported,ne as loadGeometryOperators};
2
+ import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{fetchMessageBundle as r,onLocaleChange as i}from"../../intl.js";import{multiplyOpacity as s,getContrast as a}from"../../core/colorUtils.js";import{destroyMaybe as n}from"../../core/maybe.js";import{watch as o,initial as m}from"../../core/reactiveUtils.js";import{formatDecimal as l,formatImperialArea as p,formatMetricArea as c,formatImperialLength as h,formatMetricLength as u}from"../../core/unitFormatUtils.js";import{convertUnit as d,deriveLengthUnitFromAreaUnit as v}from"../../core/units.js";import{property as y,subclass as g}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as f}from"../../core/support/UpdatingHandles.js";import{isSupported as _,geodesicDensify as w,geodesicLengths as b,geodesicAreas as L}from"../../geometry/geodesicUtils.js";import j from"../../geometry/Point.js";import S from"../../geometry/Polygon.js";import A from"../../geometry/Polyline.js";import{e as k}from"../../chunks/areaOperator.js";import{e as G,l as x}from"../../chunks/geodeticAreaOperator.js";import{e as M,l as O}from"../../chunks/geodeticDensifyOperator.js";import{e as C,l as H}from"../../chunks/geodeticLengthOperator.js";import{e as R}from"../../chunks/lengthOperator.js";import{e as T}from"../../chunks/simplifyOperator.js";import{polygonCentroidPoint as U}from"../../geometry/support/centroid.js";import q from"../../layers/GraphicsLayer.js";import z from"../../symbols/Font.js";import D from"../../symbols/SimpleFillSymbol.js";import P from"../../symbols/SimpleLineSymbol.js";import E from"../../symbols/SimpleMarkerSymbol.js";import V from"../../symbols/TextSymbol.js";import{SnappingVisualizer2D as F}from"../../views/2d/interactive/SnappingVisualizer2D.js";import W from"../../views/draw/Draw.js";import{createCoordinateHelper as I}from"../../views/interactive/coordinateHelper.js";import{createManipulatorDragEventPipeline as B,screenToMap as J,dragManipulatedObject as N}from"../../views/interactive/dragEventPipeline.js";import{GraphicManipulator as K}from"../../views/interactive/GraphicManipulator.js";import{InteractiveToolBase as Q}from"../../views/interactive/InteractiveToolBase.js";import{EditGeometry as X}from"../../views/interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as Y}from"../../views/interactive/editGeometry/EditGeometryOperations.js";import{SnappingContext as Z}from"../../views/interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as $}from"../../views/interactive/snapping/SnappingDragPipelineStep.js";import{setupSnappingToggleHandles as ee}from"../../views/interactive/snapping/snappingUtils.js";const te=1e5;let re=class extends Q{constructor(e){super(e),this._measurementLayer=new q({internal:!0,listMode:"hide",visible:!1,title:"Area measurement layer"}),this._manipulatorLayer=new q({internal:!0,listMode:"hide",visible:!1,title:"Area measurement manipulator layer"}),this._snappingLayer=new q({internal:!0,listMode:"hide",visible:!1,title:"Area measurement snapping layer"}),this._updatingHandles=new f,this._vertices=[],this._drawActive=!1,this.measurement=null,this.measurementLabel=null}initialize(){r("esri/core/t9n/Units").then(e=>{this.messages=e});const e=this.view;this._draw=new W({view:e}),e.map.addMany([this._measurementLayer,this._manipulatorLayer,this._snappingLayer]),e.focus(),this.addHandles([i(async()=>{this.messages=await r("esri/core/t9n/Units")}),o(()=>[this.unit,this.messages],()=>{this._updateGraphics()},m),o(()=>[this.view.effectiveTheme.accentColor,this.view.effectiveTheme.textColor],()=>{if(!this._vertices.length)return;const e=this._vertices.map(({coord:e})=>e);for(const{handle:t}of this._vertices)t.remove();this._vertices=[],this._measurementLayer.removeAll(),this._manipulatorLayer.removeAll(),this._snappingLayer.removeAll(),this.manipulators.removeAll(),this._updateSketch(e)})]),ee(this)}destroy(){const{map:e}=this.view;this._draw.view=null,this._draw=n(this._draw),e.removeMany([this._measurementLayer,this._manipulatorLayer,this._snappingLayer]),this._measurementLayer.removeAll(),this._manipulatorLayer.removeAll(),this._snappingLayer.removeAll(),this._set("measurement",null),this._set("measurementLabel",null),this._measurementLayer=n(this._measurementLayer),this._manipulatorLayer=n(this._manipulatorLayer),this._snappingLayer=n(this._snappingLayer),this._updatingHandles=n(this._updatingHandles),this._resetVertices()}get cursor(){return this._drawActive?"crosshair":null}set editable(e){this._set("editable",e),e||this._draw.reset()}get snappingOptions(){return this.snappingManager.options}get updating(){return this._updatingHandles.updating||this.snappingManager.updating}onActivate(){this._drawActive||0!==this._vertices.length||this._startSketch()}onShow(){this._measurementLayer.visible=!0,this._manipulatorLayer.visible=!0,this._snappingLayer.visible=!0}onHide(){this._measurementLayer.visible=!1,this._manipulatorLayer.visible=!1,this._snappingLayer.visible=!1}reset(){this.manipulators.removeAll(),this._resetVertices(),this._measurementLayer.removeAll(),this._manipulatorLayer.removeAll(),this._set("measurement",null),this._set("measurementLabel",null),this._draw.reset(),this._drawActive=!1}_getSnappingContext(e){return new Z({elevationInfo:{mode:"on-the-ground",offset:0},pointer:e,editGeometryOperations:new Y(new X("point",I(!1,!1,this.view.spatialReference)),2),visualizer:new F(this._snappingLayer)})}_resetVertices(){for(const{handle:e}of this._vertices)e.remove();this._vertices=[]}_startSketch(){this._drawActive=!0;const{snappingManager:e}=this;this._draw.create("polyline",{mode:"click",snappingManager:e}).on(["draw-complete","vertex-add","vertex-update","vertex-remove","cursor-update","undo","redo"],e=>{this._updateSketch(e.vertices),"draw-complete"===e.type&&this._stopSketch()})}_stopSketch(){if(this._vertices.length<3)return this.reset(),void this._startSketch();this.manipulators.forEach(({manipulator:e})=>{e.interactive=!0}),this._drawActive=!1,this.finishToolCreation()}_updateSketch(e){const{spatialReference:t}=this.view;for(;this._vertices.length>e.length;){const{handle:e,manipulator:t}=this._vertices.pop();e.remove(),this.manipulators.remove(t)}for(let r=this._vertices.length;r<e.length;r++){const[i,s]=e[r],a=new j({x:i,y:s,spatialReference:t}),n=ie(a,this.view,this._manipulatorLayer);this.manipulators.add(n);const o=Y.fromGeometry(a,2);o.on("vertex-update",e=>{const t=e.vertices.at(0);t&&(this._vertices[r].coord=[t.pos[0],t.pos[1]],this._updateGraphics())});const m=B(n,(e,t,r,i)=>{const s=this._getSnappingContext(i),{snappingManager:a}=this,n=this._updatingHandles,{snappingStep:m}=$({snappingContext:s,snappingManager:a,updatingHandles:n});t.next(J(this.view)).next(t=>{if("start"===t.action){const r=new j(t.mapStart);e.graphic.geometry=r,o.trySetGeometry(r)}return t}).next(...m).next(N({operations:o})).next(()=>{e.graphic.geometry=o.data.geometry})});this._vertices.push({manipulator:n,coord:[i,s],handle:m})}if(this._vertices.length){const r=this._vertices.length-1,i=this._vertices[r],[s,a]=e[r];i.coord[0]===s&&i.coord[1]===a||(i.coord=[s,a],i.manipulator.graphic.geometry=new j({x:s,y:a,spatialReference:t}));const n=this._drawActive?this._vertices[r].manipulator:null;this.manipulators.forEach(({manipulator:e})=>{e.interactive=null==n||e!==n})}this._updateGraphics()}_updateGraphics(){if(this._vertices.length<2)return void this._measurementLayer.removeAll();const e=se(this._vertices.map(({coord:e})=>e),this.view.spatialReference);if(!e)return;const{measurement:r,fillGeometry:i,outlineGeometry:n}=e;this._set("measurement",r);const o=r?oe(this.messages,r,this.unit):null;if(this._set("measurementLabel",o),!i&&!n)return;let m,l,p;const{graphics:c}=this._measurementLayer,h=3===c.length,{effectiveTheme:u}=this.view;h?(m=c.at(0),l=c.at(1),p=c.at(2)):(m=new t({symbol:new D({color:s(u.accentColor,.3),outline:null})}),l=new t({symbol:new P({color:u.accentColor,width:2})}),p=new t({symbol:new V({color:u.textColor,font:new z({size:14,family:"sans-serif"}),haloColor:s(a(u.textColor,160),.5),haloSize:2})}),c.removeAll(),c.addMany([m,l,p])),m.geometry=i,l.geometry=n;const d=i?U(i):null,v=d?j.fromJSON(d):null;p.geometry=v,p.symbol.text=o?.area??""}};function ie(e,r,i){const a=8,n={style:"circle",color:s(r.effectiveTheme.accentColor,.5),outline:{type:"simple-line",width:0}},o=new E({...n,size:a}),m=new E({...n,size:1.5*a}),l=new t({geometry:e,symbol:o});return new K({view:r,layer:i,graphic:l,focusedSymbol:m,consumesClicks:!1})}function se(e,t){if(2===e.length){const r=new A({paths:[e],spatialReference:t});let i;return i=t.isGeographic?_(t)?w(r,te):M(r,te,{unit:"meters"}):t.isWebMercator?M(r,te,{unit:"meters"}):r,{measurement:null,fillGeometry:null,outlineGeometry:i}}e.push(e[0]);const r=new A({paths:[e],spatialReference:t}),i=new S({rings:[e],spatialReference:t});let s,a,n=null,o=null;if(t.isGeographic)if(_(t)){if(n=w(r,te),o=w(i,te),o=T(o),!o)return null;s=b([r],"meters")[0],a=L([o],"square-meters")[0]}else{if(n=M(r,te,{unit:"meters"}),o=M(i,te,{unit:"meters"}),o=T(o),!o)return null;s=C(r,{unit:"meters"}),a=G(o,{unit:"square-meters"})}else if(t.isWebMercator){if(n=M(r,te,{unit:"meters"}),o=M(i,te,{unit:"meters"}),o=T(o),!o)return null;s=C(r,{unit:"meters"}),a=G(o,{unit:"square-meters"})}else{if(n=r,o=T(i),!o)return null;s=R(r,{unit:"meters"}),a=k(o,{unit:"square-meters"})}return{measurement:{geometry:o,area:a,perimeter:s},fillGeometry:o,outlineGeometry:n}}function ae(e){return null!=e}async function ne(e){(e?.isGeographic&&!_(e)||e?.isWebMercator)&&await Promise.all([x(),O(),H()])}function oe(e,t,r){if(!t||!e)return null;const i={area:null,perimeter:null},{area:s,perimeter:a}=t;switch(r){case"metric":i.area=c(e,s,"square-meters");break;case"imperial":i.area=p(e,s,"square-meters");break;default:{const t=d(s,"square-meters",r);i.area=l(e,t,r);break}}const n=v(r);if(n)switch(n){case"metric":i.perimeter=u(e,a,"meters");break;case"imperial":i.perimeter=h(e,a,"meters");break;default:{const t=d(a,"meters",n);i.perimeter=l(e,t,n);break}}else i.perimeter="";return i}e([y()],re.prototype,"_drawActive",void 0),e([y({readOnly:!0})],re.prototype,"cursor",null),e([y({value:!0})],re.prototype,"editable",null),e([y({readOnly:!0})],re.prototype,"measurement",void 0),e([y({readOnly:!0})],re.prototype,"measurementLabel",void 0),e([y()],re.prototype,"messages",void 0),e([y({constructOnly:!0})],re.prototype,"snappingManager",void 0),e([y()],re.prototype,"unit",void 0),e([y()],re.prototype,"updating",null),e([y({constructOnly:!0})],re.prototype,"view",void 0),re=e([g("esri.widgets.AreaMeasurement2D.AreaMeasurement2DTool")],re);export{re as AreaMeasurement2DTool,se as createAreaMeasurementInfo2D,oe as createAreaMeasurementLabel,ae as isSupported,ne as loadGeometryOperators};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{fetchMessageBundle as i,onLocaleChange as r}from"../../intl.js";import{getContrast as s,multiplyOpacity as n}from"../../core/colorUtils.js";import{handlesGroup as o}from"../../core/handleUtils.js";import{destroyMaybe as a}from"../../core/maybe.js";import{watch as l,initial as p}from"../../core/reactiveUtils.js";import{formatDecimal as m,formatImperialLength as c,formatMetricLength as h}from"../../core/unitFormatUtils.js";import{convertUnit as u}from"../../core/units.js";import{property as d,subclass as y}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as v}from"../../core/support/UpdatingHandles.js";import{isSupported as g,geodesicLengths as _,geodesicDensify as f}from"../../geometry/geodesicUtils.js";import w from"../../geometry/Point.js";import L from"../../geometry/Polyline.js";import{e as b,l as S}from"../../chunks/geodeticDensifyOperator.js";import{e as j,l as M}from"../../chunks/geodeticLengthOperator.js";import{e as x}from"../../chunks/lengthOperator.js";import C from"../../layers/GraphicsLayer.js";import A from"../../symbols/CIMSymbol.js";import D from"../../symbols/Font.js";import k from"../../symbols/SimpleMarkerSymbol.js";import G from"../../symbols/TextSymbol.js";import{SnappingVisualizer2D as T}from"../../views/2d/interactive/SnappingVisualizer2D.js";import O from"../../views/draw/Draw.js";import{createCoordinateHelper as H}from"../../views/interactive/coordinateHelper.js";import{createManipulatorDragEventPipeline as P,screenToMap as R,dragManipulatedObject as U}from"../../views/interactive/dragEventPipeline.js";import{GraphicManipulator as E}from"../../views/interactive/GraphicManipulator.js";import{InteractiveToolBase as I}from"../../views/interactive/InteractiveToolBase.js";import{EditGeometry as z}from"../../views/interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as B}from"../../views/interactive/editGeometry/EditGeometryOperations.js";import{SnappingContext as F}from"../../views/interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as V}from"../../views/interactive/snapping/SnappingDragPipelineStep.js";import{setupSnappingToggleHandles as W}from"../../views/interactive/snapping/snappingUtils.js";const N=1e5;let q=class extends I{constructor(e){super(e),this._measurementLayer=new C({internal:!0,listMode:"hide",visible:!1,title:"DistanceMeasurement2DTool measurement layer"}),this._manipulatorLayer=new C({internal:!0,listMode:"hide",visible:!1,title:"DistanceMeasurement2DTool manipulator layer"}),this._snappingLayer=new C({internal:!0,listMode:"hide",visible:!1,title:"DistanceMeasurement2DTool snapping layer"}),this._updatingHandles=new v,this._vertices=[],this._drawActive=!1,this.measurement=null,this.measurementLabel=null}initialize(){i("esri/core/t9n/Units").then(e=>{this.messages=e});const e=this.view;this._draw=new O({view:e}),e.map.addMany([this._measurementLayer,this._manipulatorLayer,this._snappingLayer]),e.focus(),this.addHandles([r(async()=>{this.messages=await i("esri/core/t9n/Units")}),l(()=>[this.unit,this.messages],()=>{this._updatePolylines()},p),l(()=>[this.view.effectiveTheme.accentColor,this.view.effectiveTheme.textColor],()=>{if(!this._vertices.length)return;const e=this._vertices.map(({coord:e})=>e);for(const{handle:t}of this._vertices)t.remove();this._vertices=[],this._measurementLayer.removeAll(),this._manipulatorLayer.removeAll(),this._snappingLayer.removeAll(),this.manipulators.removeAll(),this._updateSketch(e)})]),W(this)}destroy(){const{map:e}=this.view;this._draw.view=null,this._draw=a(this._draw),e.removeMany([this._measurementLayer,this._manipulatorLayer,this._snappingLayer]),this._measurementLayer.removeAll(),this._manipulatorLayer.removeAll(),this._snappingLayer.removeAll(),this._set("measurement",null),this._set("measurementLabel",null),this._measurementLayer=a(this._measurementLayer),this._manipulatorLayer=a(this._manipulatorLayer),this._snappingLayer=a(this._snappingLayer),this._updatingHandles=a(this._updatingHandles),this._resetVertices()}get cursor(){return this._drawActive?"crosshair":null}set editable(e){this._set("editable",e),e||this._draw.reset()}get snappingOptions(){return this.snappingManager.options}get updating(){return this._updatingHandles.updating||this.snappingManager.updating}onActivate(){this._drawActive||0!==this._vertices.length||this._startSketch()}onShow(){this._measurementLayer.visible=!0,this._manipulatorLayer.visible=!0,this._snappingLayer.visible=!0}onHide(){this._measurementLayer.visible=!1,this._manipulatorLayer.visible=!1,this._snappingLayer.visible=!1}_getSnappingContext(e){return new F({elevationInfo:{mode:"on-the-ground",offset:0},pointer:e,editGeometryOperations:new B(new z("point",H(!1,!1,this.view.spatialReference)),2),visualizer:new T(this._snappingLayer)})}_resetVertices(){for(const{handle:e}of this._vertices)e.remove();this._vertices=[]}_startSketch(){this._drawActive=!0;const{snappingManager:e}=this;this._draw.create("polyline",{mode:"click",snappingManager:e}).on(["draw-complete","vertex-add","vertex-update","vertex-remove","cursor-update","undo","redo"],e=>{this._updateSketch(e.vertices),"draw-complete"===e.type&&this._stopSketch()})}_stopSketch(){this.manipulators.forEach(({manipulator:e})=>{e.interactive=!0}),this._drawActive=!1,this.finishToolCreation()}_updateSketch(e){const{spatialReference:t}=this.view;for(;this._vertices.length>e.length;){const{handle:e,manipulator:t}=this._vertices.pop();e.remove(),this.manipulators.remove(t)}for(let l=this._vertices.length;l<e.length;l++){const[i,r]=e[l],s=new w({x:i,y:r,spatialReference:t}),n=J(s,this.view,this._manipulatorLayer);this.manipulators.add(n);const a=B.fromGeometry(s,2),p=[a.on("vertex-update",e=>{const t=e.vertices.at(0);t&&(this._vertices[l].coord=[t.pos[0],t.pos[1]],this._updatePolylines())}),P(n,(e,t,i,r)=>{const s=this._getSnappingContext(r),{snappingManager:n}=this,o=this._updatingHandles,{snappingStep:l}=V({snappingContext:s,snappingManager:n,updatingHandles:o});t.next(R(this.view)).next(t=>{if("start"===t.action){const i=new w(t.mapStart);e.graphic.geometry=i,a.trySetGeometry(i)}return t}).next(...l).next(U({operations:a})).next(()=>{e.graphic.geometry=a.data.geometry})})];this._vertices.push({manipulator:n,coord:[i,r],handle:o(p)})}const i=this._vertices.length-1,r=this._vertices[i],[s,n]=e[i];r.coord[0]===s&&r.coord[1]===n||(r.coord=[s,n],r.manipulator.graphic.geometry=new w({x:s,y:n,spatialReference:t}));const a=this._drawActive?this._vertices[i].manipulator:null;this.manipulators.forEach(({manipulator:e})=>{e.interactive=null==a||e!==a}),this._updatePolylines()}_updatePolylines(){if(this._vertices.length<2)return void this._measurementLayer.removeAll();const e=K(this._vertices.map(({coord:e})=>e),this.view.spatialReference);if(!e)return;const{measurement:i,drawing:r,original:o}=e;this._set("measurement",i);const a=Y(this.messages,i,this.unit);let l,p;this._set("measurementLabel",a);const{graphics:m}=this._measurementLayer,c=2===m.length,{effectiveTheme:h}=this.view;c?(l=m.at(0),p=m.at(1)):(l=new t({symbol:new A({data:{type:"CIMSymbolReference",symbol:{type:"CIMLineSymbol",symbolLayers:[{type:"CIMSolidStroke",effects:[{type:"CIMGeometricEffectDashes",dashTemplate:[14,12],lineDashEnding:"FullGap",controlPointEnding:"NoConstraint"}],enable:!0,capStyle:"Butt",joinStyle:"Round",width:3.5,color:s(h.accentColor).toArray()},{type:"CIMSolidStroke",enable:!0,capStyle:"Butt",joinStyle:"Round",width:5,color:h.accentColor.toArray()}]}}})}),p=new t({symbol:new G({color:h.textColor,haloColor:n(s(h.textColor,160),.5),haloSize:2,font:new D({size:14,family:"sans-serif"})})}),m.removeAll(),m.addMany([l,p])),l.geometry=r,p.geometry=o.extent?.center,p.symbol.text=a}};function J(e,i,r){const s=n(i.effectiveTheme.accentColor,.5),o={type:"simple-line",width:0},a=8,l=new k({style:"circle",color:s,size:a,outline:o}),p=new k({style:"circle",color:s,size:1.5*a,outline:o}),m=new t({geometry:e,symbol:l});return new E({view:i,layer:r,graphic:m,focusedSymbol:p})}function K(e,t){const i=new L({paths:[e],spatialReference:t});let r,s;return t.isGeographic?g(t)?(r=_([i],"meters")[0],s=f(i,N)):(r=j(i,{unit:"meters"}),s=b(i,N,{unit:"meters"})):t.isWebMercator?(r=j(i,{unit:"meters"}),s=b(i,N,{unit:"meters"})):(r=x(i,{unit:"meters"}),s=i),{measurement:{geometry:s,length:r},original:i,drawing:s}}function Q(e){return null!=e}async function X(e){(e?.isGeographic&&!g(e)||e?.isWebMercator)&&await Promise.all([S(),M()])}function Y(e,t,i){if(!t||!e)return"";switch(i){case"metric":return h(e,t.length,"meters");case"imperial":return c(e,t.length,"meters");default:return m(e,u(t.length,"meters",i),i)}}e([d()],q.prototype,"_drawActive",void 0),e([d({readOnly:!0})],q.prototype,"cursor",null),e([d({value:!0})],q.prototype,"editable",null),e([d({readOnly:!0})],q.prototype,"measurement",void 0),e([d({readOnly:!0})],q.prototype,"measurementLabel",void 0),e([d()],q.prototype,"messages",void 0),e([d({constructOnly:!0})],q.prototype,"snappingManager",void 0),e([d()],q.prototype,"unit",void 0),e([d()],q.prototype,"updating",null),e([d({constructOnly:!0})],q.prototype,"view",void 0),q=e([y("esri.widgets.DistanceMeasurement2D.DistanceMeasurement2DTool")],q);export{q as DistanceMeasurement2DTool,K as createDistanceMeasurementInfo2D,Y as createDistanceMeasurementLabel,Q as isSupported,X as loadGeometryOperators};
2
+ import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{fetchMessageBundle as i,onLocaleChange as r}from"../../intl.js";import{getContrast as s,multiplyOpacity as n}from"../../core/colorUtils.js";import{handlesGroup as o}from"../../core/handleUtils.js";import{destroyMaybe as a}from"../../core/maybe.js";import{watch as l,initial as p}from"../../core/reactiveUtils.js";import{formatDecimal as m,formatImperialLength as c,formatMetricLength as h}from"../../core/unitFormatUtils.js";import{convertUnit as u}from"../../core/units.js";import{property as d,subclass as y}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as v}from"../../core/support/UpdatingHandles.js";import{isSupported as g,geodesicLengths as _,geodesicDensify as f}from"../../geometry/geodesicUtils.js";import w from"../../geometry/Point.js";import L from"../../geometry/Polyline.js";import{e as b,l as S}from"../../chunks/geodeticDensifyOperator.js";import{e as j,l as M}from"../../chunks/geodeticLengthOperator.js";import{e as x}from"../../chunks/lengthOperator.js";import C from"../../layers/GraphicsLayer.js";import A from"../../symbols/CIMSymbol.js";import D from"../../symbols/Font.js";import k from"../../symbols/SimpleMarkerSymbol.js";import G from"../../symbols/TextSymbol.js";import{SnappingVisualizer2D as T}from"../../views/2d/interactive/SnappingVisualizer2D.js";import O from"../../views/draw/Draw.js";import{createCoordinateHelper as H}from"../../views/interactive/coordinateHelper.js";import{createManipulatorDragEventPipeline as P,screenToMap as R,dragManipulatedObject as U}from"../../views/interactive/dragEventPipeline.js";import{GraphicManipulator as E}from"../../views/interactive/GraphicManipulator.js";import{InteractiveToolBase as I}from"../../views/interactive/InteractiveToolBase.js";import{EditGeometry as z}from"../../views/interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as B}from"../../views/interactive/editGeometry/EditGeometryOperations.js";import{SnappingContext as F}from"../../views/interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as V}from"../../views/interactive/snapping/SnappingDragPipelineStep.js";import{setupSnappingToggleHandles as W}from"../../views/interactive/snapping/snappingUtils.js";const N=1e5;let q=class extends I{constructor(e){super(e),this._measurementLayer=new C({internal:!0,listMode:"hide",visible:!1,title:"DistanceMeasurement2DTool measurement layer"}),this._manipulatorLayer=new C({internal:!0,listMode:"hide",visible:!1,title:"DistanceMeasurement2DTool manipulator layer"}),this._snappingLayer=new C({internal:!0,listMode:"hide",visible:!1,title:"DistanceMeasurement2DTool snapping layer"}),this._updatingHandles=new v,this._vertices=[],this._drawActive=!1,this.measurement=null,this.measurementLabel=null}initialize(){i("esri/core/t9n/Units").then(e=>{this.messages=e});const e=this.view;this._draw=new O({view:e}),e.map.addMany([this._measurementLayer,this._manipulatorLayer,this._snappingLayer]),e.focus(),this.addHandles([r(async()=>{this.messages=await i("esri/core/t9n/Units")}),l(()=>[this.unit,this.messages],()=>{this._updatePolylines()},p),l(()=>[this.view.effectiveTheme.accentColor,this.view.effectiveTheme.textColor],()=>{if(!this._vertices.length)return;const e=this._vertices.map(({coord:e})=>e);for(const{handle:t}of this._vertices)t.remove();this._vertices=[],this._measurementLayer.removeAll(),this._manipulatorLayer.removeAll(),this._snappingLayer.removeAll(),this.manipulators.removeAll(),this._updateSketch(e)})]),W(this)}destroy(){const{map:e}=this.view;this._draw.view=null,this._draw=a(this._draw),e.removeMany([this._measurementLayer,this._manipulatorLayer,this._snappingLayer]),this._measurementLayer.removeAll(),this._manipulatorLayer.removeAll(),this._snappingLayer.removeAll(),this._set("measurement",null),this._set("measurementLabel",null),this._measurementLayer=a(this._measurementLayer),this._manipulatorLayer=a(this._manipulatorLayer),this._snappingLayer=a(this._snappingLayer),this._updatingHandles=a(this._updatingHandles),this._resetVertices()}get cursor(){return this._drawActive?"crosshair":null}set editable(e){this._set("editable",e),e||this._draw.reset()}get snappingOptions(){return this.snappingManager.options}get updating(){return this._updatingHandles.updating||this.snappingManager.updating}onActivate(){this._drawActive||0!==this._vertices.length||this._startSketch()}onShow(){this._measurementLayer.visible=!0,this._manipulatorLayer.visible=!0,this._snappingLayer.visible=!0}onHide(){this._measurementLayer.visible=!1,this._manipulatorLayer.visible=!1,this._snappingLayer.visible=!1}_getSnappingContext(e){return new F({elevationInfo:{mode:"on-the-ground",offset:0},pointer:e,editGeometryOperations:new B(new z("point",H(!1,!1,this.view.spatialReference)),2),visualizer:new T(this._snappingLayer)})}_resetVertices(){for(const{handle:e}of this._vertices)e.remove();this._vertices=[]}_startSketch(){this._drawActive=!0;const{snappingManager:e}=this;this._draw.create("polyline",{mode:"click",snappingManager:e}).on(["draw-complete","vertex-add","vertex-update","vertex-remove","cursor-update","undo","redo"],e=>{this._updateSketch(e.vertices),"draw-complete"===e.type&&this._stopSketch()})}_stopSketch(){this.manipulators.forEach(({manipulator:e})=>{e.interactive=!0}),this._drawActive=!1,this.finishToolCreation()}_updateSketch(e){const{spatialReference:t}=this.view;for(;this._vertices.length>e.length;){const{handle:e,manipulator:t}=this._vertices.pop();e.remove(),this.manipulators.remove(t)}for(let l=this._vertices.length;l<e.length;l++){const[i,r]=e[l],s=new w({x:i,y:r,spatialReference:t}),n=J(s,this.view,this._manipulatorLayer);this.manipulators.add(n);const a=B.fromGeometry(s,2),p=[a.on("vertex-update",e=>{const t=e.vertices.at(0);t&&(this._vertices[l].coord=[t.pos[0],t.pos[1]],this._updatePolylines())}),P(n,(e,t,i,r)=>{const s=this._getSnappingContext(r),{snappingManager:n}=this,o=this._updatingHandles,{snappingStep:l}=V({snappingContext:s,snappingManager:n,updatingHandles:o});t.next(R(this.view)).next(t=>{if("start"===t.action){const i=new w(t.mapStart);e.graphic.geometry=i,a.trySetGeometry(i)}return t}).next(...l).next(U({operations:a})).next(()=>{e.graphic.geometry=a.data.geometry})})];this._vertices.push({manipulator:n,coord:[i,r],handle:o(p)})}const i=this._vertices.length-1,r=this._vertices[i],[s,n]=e[i];r.coord[0]===s&&r.coord[1]===n||(r.coord=[s,n],r.manipulator.graphic.geometry=new w({x:s,y:n,spatialReference:t}));const a=this._drawActive?this._vertices[i].manipulator:null;this.manipulators.forEach(({manipulator:e})=>{e.interactive=null==a||e!==a}),this._updatePolylines()}_updatePolylines(){if(this._vertices.length<2)return void this._measurementLayer.removeAll();const e=K(this._vertices.map(({coord:e})=>e),this.view.spatialReference);if(!e)return;const{measurement:i,drawing:r,original:o}=e;this._set("measurement",i);const a=Y(this.messages,i,this.unit);let l,p;this._set("measurementLabel",a);const{graphics:m}=this._measurementLayer,c=2===m.length,{effectiveTheme:h}=this.view;c?(l=m.at(0),p=m.at(1)):(l=new t({symbol:new A({data:{type:"CIMSymbolReference",symbol:{type:"CIMLineSymbol",symbolLayers:[{type:"CIMSolidStroke",effects:[{type:"CIMGeometricEffectDashes",dashTemplate:[14,12],lineDashEnding:"FullGap",controlPointEnding:"NoConstraint"}],enable:!0,capStyle:"Butt",joinStyle:"Round",width:3.5,color:s(h.accentColor).toArray()},{type:"CIMSolidStroke",enable:!0,capStyle:"Butt",joinStyle:"Round",width:5,color:h.accentColor.toArray()}]}}})}),p=new t({symbol:new G({color:h.textColor,haloColor:n(s(h.textColor,160),.5),haloSize:2,font:new D({size:14,family:"sans-serif"})})}),m.removeAll(),m.addMany([l,p])),l.geometry=r,p.geometry=o.extent?.center,p.symbol.text=a}};function J(e,i,r){const s=n(i.effectiveTheme.accentColor,.5),o={type:"simple-line",width:0},a=8,l=new k({style:"circle",color:s,size:a,outline:o}),p=new k({style:"circle",color:s,size:1.5*a,outline:o}),m=new t({geometry:e,symbol:l});return new E({view:i,layer:r,graphic:m,focusedSymbol:p,consumesClicks:!1})}function K(e,t){const i=new L({paths:[e],spatialReference:t});let r,s;return t.isGeographic?g(t)?(r=_([i],"meters")[0],s=f(i,N)):(r=j(i,{unit:"meters"}),s=b(i,N,{unit:"meters"})):t.isWebMercator?(r=j(i,{unit:"meters"}),s=b(i,N,{unit:"meters"})):(r=x(i,{unit:"meters"}),s=i),{measurement:{geometry:s,length:r},original:i,drawing:s}}function Q(e){return null!=e}async function X(e){(e?.isGeographic&&!g(e)||e?.isWebMercator)&&await Promise.all([S(),M()])}function Y(e,t,i){if(!t||!e)return"";switch(i){case"metric":return h(e,t.length,"meters");case"imperial":return c(e,t.length,"meters");default:return m(e,u(t.length,"meters",i),i)}}e([d()],q.prototype,"_drawActive",void 0),e([d({readOnly:!0})],q.prototype,"cursor",null),e([d({value:!0})],q.prototype,"editable",null),e([d({readOnly:!0})],q.prototype,"measurement",void 0),e([d({readOnly:!0})],q.prototype,"measurementLabel",void 0),e([d()],q.prototype,"messages",void 0),e([d({constructOnly:!0})],q.prototype,"snappingManager",void 0),e([d()],q.prototype,"unit",void 0),e([d()],q.prototype,"updating",null),e([d({constructOnly:!0})],q.prototype,"view",void 0),q=e([y("esri.widgets.DistanceMeasurement2D.DistanceMeasurement2DTool")],q);export{q as DistanceMeasurement2DTool,K as createDistanceMeasurementInfo2D,Y as createDistanceMeasurementLabel,Q as isSupported,X as loadGeometryOperators};
@@ -396,7 +396,7 @@ export default class EditorViewModel extends EventedAccessor {
396
396
  * and displays the panel where feature creation begins.
397
397
  * @since 4.23
398
398
  */
399
- startCreateFeaturesWorkflowAtFeatureCreation(creationInfo: Required<Pick<CreationInfo, "layer" | "template">>): Promise<void>;
399
+ startCreateFeaturesWorkflowAtFeatureCreation(creationInfo: Required<Pick<CreationInfo, "layer" | "template">> & Partial<Pick<CreationInfo, "maxFeatures">>): Promise<void>;
400
400
  /**
401
401
  * This method starts the [CreateFeaturesWorkflow](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/CreateFeaturesWorkflow/) at the "creating-features" step with the provided feature.
402
402
  *
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import e from"../../Color.js";import t from"../../Graphic.js";import{isSome as r,equals as n,addMany as o}from"../../core/arrayUtils.js";import{createTask as i}from"../../core/asyncUtils.js";import a from"../../core/Error.js";import{handlesGroup as s,makeHandle as l,abortHandle as c}from"../../core/handleUtils.js";import{clone as u}from"../../core/lang.js";import p from"../../core/Logger.js";import{getOrCreateMapValue as d}from"../../core/MapUtils.js";import{debounce as f,isPromiseLike as y,throwIfAborted as m,whenOrAbort as h}from"../../core/promiseUtils.js";import{watch as g,on as b,whenOnce as w}from"../../core/reactiveUtils.js";import{px2pt as I}from"../../core/screenUtils.js";import{addMany as v}from"../../core/SetUtils.js";import{diff as T}from"../../core/accessorSupport/diffUtils.js";import{isSharedTemplateOrMetadata as F,isSharedGroupTemplate as j,getCreationAttributes as S,isSharedPresetTemplate as k}from"../../editing/templateUtils.js";import{isCurvedGeometry as A,hasUnsupportedCurve as L}from"../../geometry/support/curves/curveUtils.js";import U from"../../layers/GraphicsLayer.js";import{featureHasFields as V,fixFields as M,getDisplayFieldName as O}from"../../layers/support/fieldUtils.js";import{isSubtypeSublayer as x,isGraphicsLayer as q,isSceneLayer as z}from"../../layers/support/layerUtils.js";import{calculateTolerance as C}from"../../renderers/support/clickToleranceUtils.js";import{meterIn as P}from"../../renderers/support/lengthUtils.js";import{isRenderer as E}from"../../renderers/support/typeUtils.js";import{getTransformationType as R}from"../../renderers/visualVariables/support/sizeVariableUtils.js";import{isGraphic as D}from"../../support/graphicInstanceUtils.js";import G from"../../symbols/SimpleFillSymbol.js";import B from"../../symbols/SimpleLineSymbol.js";import Z from"../../symbols/SimpleMarkerSymbol.js";import{to3D as N}from"../../symbols/support/symbolConversion.js";import{getDisplayedSymbol as Q}from"../../symbols/support/symbolUtils.js";import{getServices as W}from"../../undoredo/support/Services.js";import{GraphicState as $}from"../../views/3d/layers/graphics/GraphicState.js";import{defaultDrawingMode as H}from"../../views/draw/drawingModes.js";import{createQueryGeometry as J}from"../../views/support/drapedUtils.js";import{filterGraphicHits as K,hitTestSelectSimilarDistance as X}from"../../views/support/hitTestSelectUtils.js";import{dependencySort as Y}from"./support/dependencySort.js";import{isDrawGraphicTool as _,isDrawTool as ee}from"../Sketch/support/sketchUtils.js";const te=()=>p.getLogger("esri.widgets.Editor.workflowUtils");function re(e){return le(e)||ae(e)}function ne(e){return!!e&&"features"in e}function oe(e){return null!=e&&"create-features"===e.type}function ie(e){return!!e&&"feature"in e}function ae(e){return null!=e&&"update-features"===e.type}function se(e){return null!=e&&"update-feature"===e.type}function le(e){return null!=e&&e.type.includes("update-")&&"fullFeature"in e}function ce(e){return null!=e&&"update"===e.type}function ue(e){return null!=e&&"merge-features"===e.type}function pe(e){return null!=e&&"split-feature"===e.type}function de(e){const t=e?.type;return"update-feature"===t||"update-table-record"===t||"update-features"===t||"split-feature"===t}function fe(e){return"merge"===e?.type}function ye(e){return"split"===e?.type}function me(e){return ue(e)||pe(e)}function he(e){return"update-multiple"===e?.type}function ge(e){const t=e&&"renderer"in e?e.renderer:null;if(!je(t))return{rotation:null,size:null};const r=t.getVisualVariablesForType("rotation").filter(e=>(!e.axis||"heading"===e.axis)&&e.field&&!e.valueExpression),n=t.getVisualVariablesForType("size").filter(e=>e.field&&!e.useSymbolValue&&!e.valueExpression&&"real-world-size"===R(e));return{rotation:1===r.length?r[0]:null,size:1===n.length?n[0]:null}}function be(e){const t=e.sourceLayer;if(!(t&&"renderer"in t&&je(t.renderer)))return{rotation:null,size:null};const{rotation:r,size:n}=ge(t);let o=null,i=null;if(r){const e=t.fields?.filter(e=>e.name===r.field),n=1===e?.length?e[0]:null;o=we(r,n)}if(n){const e=t.fields?.filter(e=>e.name===n.field),r=1===e?.length?e[0]:null;i=Te(n,r)}return{rotation:o,size:i}}function we(e,t){const r="heading"===(e.axis||"heading")&&"arithmetic"===e.rotationType?-1:1,n=t?.type??"double",o={initial:0,current:0};return{field:e.field,fieldType:n,getDefaultValue:()=>Promise.resolve(0),getValue:e=>(o.current=o.initial-r*e,Fe((o.current+360)%360,n)),setInitialValue:e=>{o.initial=e,o.current=0},isUpdatingInteractively:!1,rotationType:e.rotationType??"geographic"}}function Ie(e,t){switch(t){case"width":return e[0];case"depth":return e[1];case"height":return e[2];default:return e[2]||e[1]||e[0]}}async function ve(e,t,r){if(null==t)return 0;const{symbol:n}=N(t);if(null==n||"web-style"===n.type||"cim"===n.type)return 0;const o=n.symbolLayers.at(0);if(!o)return 0;switch(o.type){case"icon":{const{computeIconLayerResourceSize:e}=await import("../../symbols/support/symbolLayerUtils.js");return Math.min(ut.icon,(await e(o,ut.icon))[0])||ut.icon}case"text":return ut.text;case"line":return ut.line;case"object":{const{computeObjectLayerResourceSize:t}=await import("../../symbols/support/symbolLayerUtils.js");return Ie(await t(o,e.scale/ut.viewScaleSizeFactor),r)}case"path":case"extrude":return e.scale/ut.viewScaleSizeFactor;default:return 0}}function Te(e,t){const r=e.axis,n=t?.type??"double",o={initial:0,current:0},i=P[e.valueUnit]??1;let a;return a="area"===e.valueRepresentation?e=>(e*i/2)**2*Math.PI:"radius"===e.valueRepresentation||"distance"===e.valueRepresentation?e=>e*i/2:e=>e*i,{field:e.field,fieldType:n,getDefaultValue:async(e,t)=>Fe(a(await ve(t,e,r)),n),getValue:(e,t)=>(o.initial||(o.initial=t.pixelSizeAt(t.center)),o.current=o.initial*e,Fe(o.current,n)),setInitialValue:e=>{o.initial=e,o.current=0},isUpdatingInteractively:!1,displayUnit:ft(e.valueUnit),axis:e.axis}}function Fe(e,t){switch(t){case"small-integer":case"integer":case"long":return Math.round(e);case"double":case"single":return e;default:return 0}}function je(e){if(!E(e))return!1;switch(e?.type){case"class-breaks":case"simple":case"unique-value":case"dot-density":case"dictionary":case"pie-chart":return!0;default:return!1}}async function Se(e,t,r){const n=await Q(e,{useSourceLayer:!0,ignoreGraphicSymbol:!0,webStyleCache:t,scale:r});null!=T(e.symbol,n)&&(e.symbol=n)}function ke(e,t){if(!e||!t)throw new Error("no geometry type");if("multipatch"===e)return{tool:"mesh",createOptions:{mode:"hybrid"}};const r=new Map;r.set("circle",{mode:"freehand"}),r.set("rectangle",{mode:"freehand"});const n={mode:H,optionsPerTool:r};if(F(t)){const o=t.defaultTool,i=j(t)?t.definition?.inputGeometryType??e:e;switch(o){case"freehand":case"stream-line":return{tool:"polyline"===i?"freehandPolyline":"freehandPolygon",createOptions:n};case"autocomplete-freehand-polygons":case"stream-polygon":return{tool:"freehandPolygon",createOptions:n};case"autocomplete-polygons":case"difference-polygon":case"create-structures":case"polygon":case"trace":return{tool:"polygon"===i?"polygon":"polyline",createOptions:n};case"circle":return r.get("circle").preserveAspectRatio=!0,{tool:"circle",createOptions:n};case"ellipse":return r.get("circle").preserveAspectRatio=!1,{tool:"circle",createOptions:n};case"create-points-along-line":case"multipoint":return{tool:"multipoint",createOptions:n};case"line":case"radial-line":case"right-angle-line":case"split":case"two-point-line":return{tool:"polyline",createOptions:n};case"rectangle":case"regular-polygon":case"right-angle-polygon":return{tool:"rectangle",createOptions:n};case"elevation-point-from-contour":case"elevation-point-from-dem":case"parcel-seed":case"point":case"point-and-rotation":case"point-at-end-of-line":return{tool:"point",createOptions:n}}}else{const o=t.drawingTool;if("circle"===o||"ellipse"===o)return r.get("circle").preserveAspectRatio="circle"===o,{tool:"circle",createOptions:n};if("rectangle"===o)return{tool:"rectangle",createOptions:n};if("freehand"===o)return{tool:"polygon"===e?"freehandPolygon":"freehandPolyline",createOptions:n}}return{tool:e,createOptions:n}}async function Ae(e,t,r,n){const{creationInfo:o,fullTemplate:i}=r;if(!o)throw new a("featureworkflow","No creation info provided.");const s=o.layer,l=S(i,o.attributeOverrides,o.layer),{view:c}=e,u="2d"===c?.type;j(i)||k(i)||await Qe(e,s,l,n,u?c.scale:null);const{capabilities:p}=s;t.elevationInfo=s.elevationInfo;const d=ke(s.geometryType,i);e.defaultCreateOptions={graphicProperties:{attributes:l,sourceLayer:s},mode:d.createOptions.mode,optionsPerTool:d.createOptions.optionsPerTool,preserveAspectRatio:d.createOptions.preserveAspectRatio,hasZ:p.data.supportsZ,defaultZ:(u?p.editing.zDefault:null)??e.defaultCreateOptions.defaultZ},null==o.geometryToPlace?await e.create(d.tool):await e.place(o.geometryToPlace,{graphicProperties:{attributes:l,sourceLayer:s}})}async function Le(e){return s([Ue(e),Ve(e)])}function Ue({creationAttributes:e,data:t,sketchViewModel:r,view:n,webStyleCache:o}){const{creationInfo:i}=t,{fullTemplate:a}=t;if(!i||"2d"!==n?.type||j(a)||k(a))return null;const s=f(t=>Qe(r,i.layer,e,o,t));return g(()=>n.scale,e=>s(e))}function Ve({data:t,sketchViewModel:r,view:n}){const{templateExecutorInfo:o}=t;if(!o)return null;const i=r.activeComponent;if(!n||!_(i)&&!ee(i))return te().error(new a("featureworkflow","Failed to set up template feedback.")),null;const c=new U({effect:"saturate(0.6) opacity(0.8)",listMode:"hide",title:"Shared Template Feedback Graphics"});n.map?.add(c);const{executor:u,serviceLayersById:p}=o,d=n.theme?.accentColor??new e([255,165,0,1]);return s([b(()=>i,["cursor-update","vertex-add"],()=>{c.removeAll();const e=_(i)?i.graphic?.geometry:i.unprocessedGeometry;if(!e||!Me(e))return;const t=u(e,"digitizing");if(!y(t))for(const r of t.edits){const e=p.get(r.id);if(e&&r.addFeatures&&0!==r.addFeatures.length)for(const t of e)if(!t.isTable)for(const e of r.addFeatures){const t=Oe(e,d);t&&c.add(t)}}}),l(()=>{n.map.remove(c),c.destroy()})])}function Me(e){switch(e.type){case"point":case"multipoint":return!0;case"polyline":{if(A(e))return e.curvePaths[0].length>1;const t=e.paths[0];return!!t&&t.length>1}case"polygon":{if(A(e))return e.curveRings[0].length>2;const t=e.rings[0];return!!t&&(n(t.at(0),t.at(-1))?t.length>2:t.length>1)}default:return!1}}function Oe(e,r){let n=null;switch(e.geometry?.type){case"point":case"multipoint":n=new Z({angle:0,color:r,outline:new B({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:1}),path:"undefined",size:8,style:"circle",xoffset:0,yoffset:0});break;case"polygon":n=new G({color:r,outline:new B({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:3}),style:"none"});break;case"polyline":n=new B({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:2});break;default:return null}return new t({geometry:e.geometry,symbol:n,attributes:{...e.attributes}})}function xe(e,t){const r=W(t),n=x(e)?e.parent:e;return r.tablesAndLayersLookup.get(n)}function qe(e,t){const r=xe(e,t);if(!r)return new Map;const n=new Map;for(const o of r.layersAndTables)d(n,o.layerId,()=>[]).push(o);return n}function ze(e){const t=e.objectIdField,r=e.globalIdField??"";return{id:e.layerId,identifierFields:{objectIdField:t,globalIdField:r},addFeatures:[],deleteAttachments:[],addAttachments:[],deleteFeatures:[],updateFeatures:[]}}function Ce(e){const{edits:t,serviceInfo:n,view:o,findOriginalFeature:i}=e,a=Pe(n.layersAndTables),s=n.layersAndTables.toArray(),{allEditData:l,editDataByLayerIdMap:c,editDataByIdMap:u}=Re(t,a,i),p=De(l,Ee(s,c),c);if(o&&Ze(l,p,o),0===p.length)return t;const d=Y(p,{continueOnCircularDependency:!0}).map(e=>u.get(e)).filter(r),f=new Map;for(const r of d)f.set(r.uniqueId,r);const y=[];for(const r of l)f.has(r.uniqueId)||y.push(r);const m=[];let h=null;for(const r of d){const{layer:e}=r;switch(null==h?h=ze(e):h.id!==e.layerId&&(m.push(h),h=ze(e)),r.operationType){case"add":case"modify":h.addFeatures.push(r.after);break;case"delete":h.deleteFeatures.push(r.before)}}null!==h&&m.push(h);for(const r of y){const e=r.layer.layerId,t=m.find(t=>t.id===e)??ze(r.layer);switch(m.includes(t)||m.push(t),r.operationType){case"add":t.addFeatures.push(r.after);break;case"modify":t.updateFeatures.push(r.after);break;case"delete":t.deleteFeatures.push(r.before);break;case"deleteAttachment":t.deleteAttachments.push(r.attachmentId);break;case"addAttachment":t.addAttachments.push(r.attachment)}}for(const r of m)void 0!==r.deleteAttachments&&0===r.deleteAttachments.length&&delete r.deleteAttachments,void 0!==r.addAttachments&&0===r.addAttachments.length&&delete r.addAttachments;return m}function Pe(e){const t=new Map;for(const r of e)t.set(r.layerId,r);return t}function Ee(e,t){const r=new Map;for(const n of e)for(const e of n.relationships??[])if(r.set(Ge(n,e),""),t.has(e.relatedTableId)){const o=t.get(e.relatedTableId);if(o.length>0)for(const t of o[0].layer.relationships??[])if(t.id===e.id){r.set(Ge(n,e),t.keyField);break}}return r}function Re(e,t,r){const n=new Map,o=[],i=new Map;let s=1;for(const l of e){const e=[],c=t.get(l.id);if(!c)throw new a("featureworkflow",`Failed to prepare applyEdits payload. Layer with id ${l.id} not found.`);for(const t of l.addFeatures??[])e.push({uniqueId:"T"+s++,operationType:"add",layer:c,after:t});for(const t of l.deleteFeatures??[])e.push({uniqueId:"T"+s++,operationType:"delete",before:t,layer:c});for(const t of l.deleteAttachments??[])e.push({uniqueId:"T"+s++,operationType:"deleteAttachment",attachmentId:t,layer:c});for(const t of l.addAttachments??[])e.push({uniqueId:"T"+s++,operationType:"addAttachment",attachment:t,layer:c});for(const t of l.updateFeatures??[])e.push({uniqueId:"T"+s++,operationType:"modify",before:r(t),after:t,layer:c});n.set(c.layerId,e);for(const t of e)o.push(t),i.set(t.uniqueId,t)}return{allEditData:o,editDataByIdMap:i,editDataByLayerIdMap:n}}function De(e,t,r){const n=[];for(const o of e){const e=o.layer.relationships??[],{uniqueId:i}=o;for(const a of e){const e=a.keyField;if("origin"===a.role){const s=r.get(a.relatedTableId);if(!s||0===s.length)continue;const l=Ge(o.layer,a),c=t.get(l);if(void 0===c||""===c)continue;switch(o.operationType){case"add":for(const t of s)t!==o&&("add"!==t.operationType&&"modify"!==t.operationType||t.after.attributes[c]===o.after.attributes[e]&&n.push([i,t.uniqueId]));break;case"modify":if(o.before.attributes[e]!==o.after.attributes[e])for(const t of s){const r=t.uniqueId;t!==o&&("delete"===t.operationType?t.before.attributes[c]===o.before.attributes[e]?n.push([r,i]):t.before.attributes[c]===o.after.attributes[e]&&n.push([i,r]):"add"===t.operationType?t.after.attributes[c]===o.after.attributes[e]?n.push([i,r]):t.after.attributes[c]===o.before.attributes[e]&&n.push([r,i]):"modify"===t.operationType&&(t.before.attributes[c]!==t.after.attributes[c]?t.after.attributes[c]===o.after.attributes[e]?n.push([i,r]):n.push([r,i]):n.push([i,r])))}break;case"delete":for(const t of s)t!==o&&("delete"!==t.operationType&&"modify"!==t.operationType||t.before.attributes[c]===o.before.attributes[e]&&n.push([t.uniqueId,i]))}}}}return n}function Ge(e,t){return`${e.layerId}:${t.id}`}function Be(e,t){return!!(t?.map&&"utilityNetworks"in t.map&&t.map.utilityNetworks?.length&&t.map.utilityNetworks.some(t=>!(!t.loaded||!e.url?.startsWith(t.featureServiceUrl)||e.layerId!==t.networkSystemLayers.associationsTableId)))}function Ze(e,t,r){const n=[];for(const i of e)Be(i.layer,r)&&n.push(i);if(0===n.length)return;let o=[];for(const i of n){const r=i.layer;switch(i.operationType){case"delete":o=[...Ne(i.before.attributes[r.fieldsIndex.get("fromglobalid").name],e),...Ne(i.before.attributes[r.fieldsIndex.get("toglobalid").name],e)];for(const e of o)t.push([i.uniqueId,e.uniqueId]);break;case"add":o=[...Ne(i.after.attributes[r.fieldsIndex.get("fromglobalid").name],e),...Ne(i.after.attributes[r.fieldsIndex.get("toglobalid").name],e)];for(const e of o)t.push([e.uniqueId,i.uniqueId])}}}function Ne(e,t){const r=[],n=t.filter(({layer:e})=>""!==e.globalIdField&&null!=e.globalIdField);for(const o of n){const t=o.layer.globalIdField;("before"in o&&o.before?.attributes[t]===e||"after"in o&&o.after?.attributes[t]===e)&&r.push(o)}return r}async function Qe(e,r,n,o,i){const a=new t({sourceLayer:r,attributes:n}),{rotation:s,size:l}=be(a);let c=await Q(a,{useSourceLayer:!0,webStyleCache:o,scale:i}),u=!1;for(const t of[l,s]){if(null==t)continue;null==n[t.field]&&(n[t.field]=await t.getDefaultValue(c,e.view),u=!0)}switch(u&&(c=await Q(a,{useSourceLayer:!0,webStyleCache:o,scale:i})),c?.type){case"simple-fill":case"polygon-3d":e.polygonSymbol=c;break;case"simple-line":case"line-3d":e.polylineSymbol=c;break;case"simple-marker":case"picture-marker":case"point-3d":case"cim":e.pointSymbol=c;break;case"mesh-3d":e.meshSymbol=c}We(e.tooltipOptions,l,s)}function We(e,t,r){e.visualVariables=null!=t||null!=r?{size:null!=t?{unit:t.displayUnit,axis:t.axis,valueType:t.fieldType}:null,rotation:null!=r?{valueType:r.fieldType,rotationType:r.rotationType??"geographic"}:null}:null}function $e(e,t){return e.find(e=>e.layer===t)}function He(e,t){const r=$e(e,t);if(null==r)throw new a("no-editorItem-found","The EditorViewModel provided did not have an EditorItem associated with the specified layer");return r}function Je(e,t){return e?.find(e=>e.layer===t)}async function Ke(e,t,r,n){switch(t.type){case"3d":return Xe(e,t,r,n);case"2d":return Ye(e,t,r,n)}}async function Xe(e,t,r,n){if(0===e.length)return[];const{updatable:i,graphicsByLayer:a}=await r.defer(async()=>{const{results:o}=await h(X(t,r),n),i=new Map,a=e=>{const t=e.layer,r=i.get(t);if(!r){const e=new Array;return i.set(t,e),e}return r};K(o).forEach(({graphic:e})=>a(e).push(e));const s=e.filter(({capabilities:e,layer:t})=>e.update.enabled&&i.has(t));return 0!==s.length&&r.stopPropagation(),{updatable:s,graphicsByLayer:i}});return h(Promise.allSettled(i.map(async({layer:e})=>{const t=a.get(e),r=_e(e);if(t.every(e=>V(e,r)))return t;const i=[];for(const n of t){i.push(n.getObjectId());const e=Object.keys(n.attributes);o(r,e)}const s=e.createQuery();return s.returnGeometry=!1,s.objectIds=i,s.outFields=M(e.fieldsIndex,r),e.queryFeatures(s,{signal:n}).then(({features:e})=>e)})),n)}async function Ye(e,t,r,n){if(0===e.length)return[];const{mapPoint:o}=r;if(null==o)return[];let i=null;const a=await r.defer(async()=>{const{results:o}=await h(t.hitTest(r),n);if(0===o.length)return[];const a=new Set;i=K(o),i.forEach(({graphic:e})=>e&&a.add(e.layer));const s=e.filter(e=>a.has(e.layer)&&e.supportsUpdateWorkflow);return s.length>0&&r.stopPropagation(),s});return h(Promise.allSettled(a.map(async({layer:e})=>{const a=e.createQuery();a.returnGeometry=!0,a.outFields=_e(e);const s="renderer"in e?C({renderer:e.renderer,pointerType:r.pointerType}):0;a.geometry=J(o,s,t),a.outSpatialReference=t.spatialReference;const{features:l}=await e.queryFeatures(a,{signal:n});return i?.forEach(({graphic:t})=>{t.layer!==e||l.some(e=>e.getObjectId()===t.getObjectId())||l.push(t)}),l})),n)}function _e(e){return M(e.fieldsIndex,[e.objectIdField,O({displayField:"displayField"in e?e.displayField:null,fields:e.fields})])}async function et(e,t,n,o){return tt(e.map(e=>e.getObjectId()??e.attributes[t.objectIdField]).filter(r),t,n,o)}async function tt(e,t,r,n){const o=t.createQuery();o.objectIds=e,o.outFields=["*"],o.returnM=t.capabilities.data.supportsM,o.returnZ=t.capabilities.data.supportsZ,o.returnGeometry=!0,z(t)&&null!=t.infoFor3D||(o.outSpatialReference=r),!z(t)&&t.capabilities?.data.supportsTrueCurve&&(o.returnTrueCurves=!0);const i=await t.queryFeatures(o,{signal:n});return m(n),i.features}async function rt(e){const{graphic:t,sketchViewModel:r,sourceLayer:n,updateOptions:o,visualVariables:i}=e;await nt(e);const a={multipleSelectionEnabled:!1,...o};return"point"===n.geometryType&&(a.enableRotation=null!=i.rotation,a.enableScaling=null!=i.size),r.update(t,a)}async function nt(e){const{graphic:t,sketchLayer:r,sketchViewModel:n,sourceLayer:o,visualVariables:i,webStyleCache:a}=e;let s=!1;const{rotation:l,size:c}=i;for(const u of[l,c]){if(null==u)continue;const e=t.getAttribute(u.field);if(null!=e)u.setInitialValue(e);else{const e=await u.getDefaultValue(t.symbol,n.view);u.setInitialValue(e),t.setAttribute(u.field,e),s=!0}}if(s){const e="2d"===n.view?.type?n.view.scale:null;await Se(t,a,e)}We(n.tooltipOptions,c,l),r.elevationInfo=o.elevationInfo}function ot(e){return null==e||"rotate-start"!==e.type&&"rotate"!==e.type&&"rotate-stop"!==e.type?null:e}function it(e){return null==e||"scale-start"!==e.type&&"scale"!==e.type&&"scale-stop"!==e.type?null:e}function at(e,t,r,n){if(null==t.geometry||"point"!==t.geometry?.type)return!1;const o=t.attributes;let i=!1;const a=n.rotation,s=ot(r.toolEventInfo);if(null!=a&&null!=s){const{field:r,getValue:n}=a;if("rotate-stop"===s.type)a.isUpdatingInteractively=!1,a.setInitialValue(t.getAttribute(r));else{a.isUpdatingInteractively=!0;const l=n(s.angle,e);l!==o[r]&&t.setAttribute(r,l),i=!0}}const l=n.size,c=it(r.toolEventInfo);if(null!=l&&null!=c){const{field:r,getValue:n}=l;if("scale-stop"===c.type)l.isUpdatingInteractively=!1,l.setInitialValue(t.getAttribute(r));else{l.isUpdatingInteractively=!0;const a=n(c.xScale,e);a!==o[r]&&t.setAttribute(r,a),i=!0}}return i}async function st({feature:e,featureClone:t,sketchLayer:r,sketchViewModel:n,updateOptions:o,view:i,visualVariableAttributes:a,webStyleCache:u,addHandle:p,addUpdatingPromise:d,onUpdate:y}){await Se(t,u,"2d"===i.type?i.scale:null);let m=null;if("2d"===n?.view?.type){const e=f(e=>Se(t,u,e));m=g(()=>n?.view?.scale,t=>e(t))}const h=t.sourceLayer,b=ht(i,h);await rt({graphic:t,sketchLayer:r,sketchViewModel:n,sourceLayer:h,updateOptions:o,visualVariables:a,webStyleCache:u});let I=null;b.then(e=>I=e).catch(()=>{});const v=a.size,T=a.rotation,F=g(()=>e.attributes,async e=>{let r=!1;for(const n in e){const o=e[n];o!==t.getAttribute(n)&&(t.setAttribute(n,o),null==v||v.isUpdatingInteractively||v.field!==n||v.setInitialValue(o),null==T||T.isUpdatingInteractively||T.field!==n||T.setInitialValue(o),(null==I||I.requiredFields.includes(n))&&(r=!0))}r&&await Se(t,u,"2d"===i.type?i.scale:null)}),j=n.on("update",async e=>{const t=e.graphics[0],s={graphic:t,sketchLayer:r,sketchViewModel:n,sourceLayer:h,updateOptions:o,visualVariables:a,webStyleCache:u};if("complete"===e.state){if(null===i.activeTool)return rt(s);const e=new AbortController,t=c(e);return p(t),d(w(()=>null===i.activeTool,e.signal).then(async()=>{if(!e.signal.aborted)return e.abort(),rt(s)}))}at(i,t,e,a)&&await Se(t,u,"2d"===i.type?i.scale:null),y(bt(t),e)}),S=n.on(["undo","redo"],e=>{y(bt(e.graphics[0]),e)});return s([S,j,l(()=>n.cancel()),F,m])}async function lt(e,t,r,n){e.add(n);const o=r.sourceLayer,a=r.layer??o,c=r.getAttribute(o.objectIdField);let u=null;function p(e){u?.abort(),q(a)?r.visible=e:u=i(async r=>{const n=await ht(t,a);m(r),n.setVisibility?.(c,e)})}return await ct(t,n),p(!1),s([l(async()=>{p(!0);try{if(!t.destroyed){const e=await ht(t,a).catch(()=>{});e&&!e.destroyed&&await w(()=>!e.updating)}}finally{e.remove(n)}})])}async function ct(e,t){if("3d"===e.type){const r=new $({graphic:t}),n=e.trackGraphicState(r);await w(()=>r.displaying||r.error),n.remove()}else await w(()=>t.visible)}const ut={icon:I(24),text:I(12),line:I(1),viewScaleSizeFactor:100};function pt(e,t,r){let n=!1;return e.filter(e=>!!n||(n=e===t,n)).map(e=>r[e]())}function dt(e,t){e.viewModel.syncFeatureTemplates();const r=e.creationInfo;if("awaiting-feature-creation-info"===t[0].id&&r){const n=r.layer,o=e.viewModel.getTemplatesForLayer(n);1===o.length&&"scene"!==n.type&&(r.template=o[0],t.shift())}return t}function ft(e){return"unknown"===e?null:e}function yt(e){e.filesEnabled=!0,e.mode="view",e.capabilities={editing:!0,operations:{add:!0,update:!0,delete:!0}}}const mt=e=>e.includes("-stop")||e.includes("vertex-"),ht=(e,t)=>{const r="subtype-sublayer"===t.type?t.parent:t;return e.whenLayerView(r)};function gt(e){return"createInteractiveEditSession"in e}function bt(e){const t=e.geometry;if("mesh"===t?.type){const r=e.cloneShallow();return r.attributes=u(e.attributes),r.geometry=t.cloneShallow(),r.geometry.transform=t.transform?.clone()??null,r}return e.clone()}function wt(e){return e.acquireCursor("progress")}function It(e){for(const t of e){const{destinationGraphic:e,destinationField:r,sourceGraphic:n,sourceField:o}=t;e.setAttribute(r,n.getAttribute(o))}}function vt(e){const t=e.templateExecutorInfo?.completionResults;return t?.length?(t.forEach(e=>It(e.relationships)),t.flatMap(e=>e.edits)):null}function Tt(e){const t=ce(e)?e.activeWorkflow:e;if(null==t)return[];if(ae(t))return t.data.layers;const r=t.layer;return r?[r]:[]}function Ft({attributes:e},t){const r=new Set;r.add(t.objectIdField),"uniqueIdFields"in t&&t.uniqueIdFields&&t.uniqueIdFields.length>0&&v(r,t.uniqueIdFields);const n={};for(const o of r)null!=e[o]&&(n[o]=e[o]);if("scene"===t.type&&null!=t.infoFor3D){const r=t.associatedLayer?.globalIdField;null!=r&&(e[r]=e[r])}return n}function jt(e){if(!St(e))return e;const t=new Map;for(const r of e){const e=r.getObjectId();if(null!=e){const n=r.sourceLayer??r.layer;d(t,n,()=>[]).push(e)}}return Array.from(t.entries()).map(([e,t])=>({layer:e,objectIds:t}))}function St(e){return 0===e.length||D(e[0])}function kt({drawTool:e},t){const r=e?.mostDownstreamPlugin?.configuration?.curveTypes;if(!t||!r||0===r.length)return!1;const n=new Set(t.capabilities.supportedCurveTypes);return r.some(e=>!n.has(e))}function At(e,t){const r=new Set(t.capabilities.supportedCurveTypes);return e.some(({geometry:e})=>e&&A(e)&&L(e,r))}export{kt as activeSketchToolDrawsUnsupportedCurve,Ze as appendAllUtilityNetworkAssociationRelationships,dt as avoidFeatureTemplateSelectionWithOnlyOneItem,gt as canCreateInteractiveEditSession,bt as cloneGraphicExceptMesh,At as containsUnsupportedCurve,Pe as createLayerIdMap,Ee as createRelationshipKeyMap,ke as createToolFromGeometryType,pt as createWorkflowSteps,Ke as fetchCandidates,et as fetchFullFeatures,tt as fetchFullFeaturesByObjectId,De as findAllDependencies,Ne as findChangesByGlobalId,$e as findEditorItemForLayer,He as findEditorItemForLayerOrThrow,Je as findLayerInfo,Ge as generateHashForRelationship,Tt as getLayersFromWorkflow,we as getRotationVariableAttribute,vt as getServiceEditsFromWorkflowData,xe as getServiceInfoForLayer,qe as getServiceLayersById,Te as getSizeVariableAttribute,be as getVisualVariableAttributes,ge as getVisualVariablesForLayer,re as isAnyUpdateLeafWorkflow,ne as isBatchAttributeFormViewModel,oe as isCreateFeaturesWorkflow,ie as isFeatureFormViewModel,St as isGraphicsArray,ue as isMergeFeaturesWorkflow,fe as isMergeWorkflowOptions,de as isParentWorkflow,pe as isSplitFeatureWorkflow,ye as isSplitWorkflowOptions,mt as isTerminalUpdateEventType,se as isUpdateFeatureWorkflow,ae as isUpdateFeaturesWorkflow,he as isUpdateFeaturesWorkflowOptions,le as isUpdateRecordWorkflow,ce as isUpdateWorkflow,Be as isUtilityNetworkAssociationsTable,Ft as makeMinimalAttributes,Ce as orderEditsByRelationshipDependencies,yt as prepareAttachmentsForCreateFeaturesWorkflow,It as setRelationshipFields,st as setUpGeometryUpdate,Le as setUpSketchCreateWatchers,nt as setVisualVariablesAndElevationInfoForUpdate,wt as showProgressCursor,ut as sizeDefaults,ft as sizeVariableUnitToLengthUnit,Ae as startCreatingNewFeature,rt as startUpdatingFeatureGeometry,lt as swapForEditingSession,jt as toFeatureInfos,Se as updateGraphicSymbolWhenRequired,at as visualVariableInteractiveUpdate,ht as whenEditorLayerView,ct as whenGraphicDisplayed,me as workflowInfluencesOutcomeOfParent};
2
+ import e from"../../Color.js";import t from"../../Graphic.js";import{isSome as r,equals as n,addMany as o}from"../../core/arrayUtils.js";import{createTask as i}from"../../core/asyncUtils.js";import a from"../../core/Error.js";import{handlesGroup as s,makeHandle as l,abortHandle as c}from"../../core/handleUtils.js";import{clone as u}from"../../core/lang.js";import p from"../../core/Logger.js";import{getOrCreateMapValue as d}from"../../core/MapUtils.js";import{debounce as f,isPromiseLike as y,throwIfAborted as m,whenOrAbort as h}from"../../core/promiseUtils.js";import{watch as g,on as b,whenOnce as w}from"../../core/reactiveUtils.js";import{px2pt as I}from"../../core/screenUtils.js";import{addMany as v}from"../../core/SetUtils.js";import{diff as T}from"../../core/accessorSupport/diffUtils.js";import{isSharedTemplateOrMetadata as F,isSharedGroupTemplate as j,getCreationAttributes as S,isSharedPresetTemplate as k}from"../../editing/templateUtils.js";import{isCurvedGeometry as A,hasUnsupportedCurve as L}from"../../geometry/support/curves/curveUtils.js";import U from"../../layers/GraphicsLayer.js";import{featureHasFields as V,fixFields as M,getDisplayFieldName as O}from"../../layers/support/fieldUtils.js";import{isSubtypeSublayer as x,isGraphicsLayer as q,isSceneLayer as z}from"../../layers/support/layerUtils.js";import{calculateTolerance as C}from"../../renderers/support/clickToleranceUtils.js";import{meterIn as P}from"../../renderers/support/lengthUtils.js";import{isRenderer as E}from"../../renderers/support/typeUtils.js";import{getTransformationType as R}from"../../renderers/visualVariables/support/sizeVariableUtils.js";import{isGraphic as D}from"../../support/graphicInstanceUtils.js";import G from"../../symbols/SimpleFillSymbol.js";import B from"../../symbols/SimpleLineSymbol.js";import Z from"../../symbols/SimpleMarkerSymbol.js";import{to3D as N}from"../../symbols/support/symbolConversion.js";import{getDisplayedSymbol as Q}from"../../symbols/support/symbolUtils.js";import{getServices as W}from"../../undoredo/support/Services.js";import{GraphicState as $}from"../../views/3d/layers/graphics/GraphicState.js";import{defaultDrawingMode as H}from"../../views/draw/drawingModes.js";import{createQueryGeometry as J}from"../../views/support/drapedUtils.js";import{filterGraphicHits as K,hitTestSelectSimilarDistance as X}from"../../views/support/hitTestSelectUtils.js";import{dependencySort as Y}from"./support/dependencySort.js";import{isDrawGraphicTool as _,isDrawTool as ee}from"../Sketch/support/sketchUtils.js";const te=()=>p.getLogger("esri.widgets.Editor.workflowUtils");function re(e){return le(e)||ae(e)}function ne(e){return!!e&&"features"in e}function oe(e){return null!=e&&"create-features"===e.type}function ie(e){return!!e&&"feature"in e}function ae(e){return null!=e&&"update-features"===e.type}function se(e){return null!=e&&"update-feature"===e.type}function le(e){return null!=e&&e.type.includes("update-")&&"fullFeature"in e}function ce(e){return null!=e&&"update"===e.type}function ue(e){return null!=e&&"merge-features"===e.type}function pe(e){return null!=e&&"split-feature"===e.type}function de(e){const t=e?.type;return"update-feature"===t||"update-table-record"===t||"update-features"===t||"split-feature"===t}function fe(e){return"merge"===e?.type}function ye(e){return"split"===e?.type}function me(e){return ue(e)||pe(e)}function he(e){return"update-multiple"===e?.type}function ge(e){const t=e&&"renderer"in e?e.renderer:null;if(!je(t))return{rotation:null,size:null};const r=t.getVisualVariablesForType("rotation").filter(e=>(!e.axis||"heading"===e.axis)&&e.field&&!e.valueExpression),n=t.getVisualVariablesForType("size").filter(e=>e.field&&!e.useSymbolValue&&!e.valueExpression&&"real-world-size"===R(e));return{rotation:1===r.length?r[0]:null,size:1===n.length?n[0]:null}}function be(e){const t=e.sourceLayer;if(!(t&&"renderer"in t&&je(t.renderer)))return{rotation:null,size:null};const{rotation:r,size:n}=ge(t);let o=null,i=null;if(r){const e=t.fields?.filter(e=>e.name===r.field),n=1===e?.length?e[0]:null;o=we(r,n)}if(n){const e=t.fields?.filter(e=>e.name===n.field),r=1===e?.length?e[0]:null;i=Te(n,r)}return{rotation:o,size:i}}function we(e,t){const r="heading"===(e.axis||"heading")&&"arithmetic"===e.rotationType?-1:1,n=t?.type??"double",o={initial:0,current:0};return{field:e.field,fieldType:n,getDefaultValue:()=>Promise.resolve(0),getValue:e=>(o.current=o.initial-r*e,Fe((o.current+360)%360,n)),setInitialValue:e=>{o.initial=e,o.current=0},isUpdatingInteractively:!1,rotationType:e.rotationType??"geographic"}}function Ie(e,t){switch(t){case"width":return e[0];case"depth":return e[1];case"height":return e[2];default:return e[2]||e[1]||e[0]}}async function ve(e,t,r){if(null==t)return 0;const{symbol:n}=N(t);if(null==n||"web-style"===n.type||"cim"===n.type)return 0;const o=n.symbolLayers.at(0);if(!o)return 0;switch(o.type){case"icon":{const{computeIconLayerResourceSize:e}=await import("../../symbols/support/symbolLayerUtils.js");return Math.min(ut.icon,(await e(o,ut.icon))[0])||ut.icon}case"text":return ut.text;case"line":return ut.line;case"object":{const{computeObjectLayerResourceSize:t}=await import("../../symbols/support/symbolLayerUtils.js");return Ie(await t(o,e.scale/ut.viewScaleSizeFactor),r)}case"path":case"extrude":return e.scale/ut.viewScaleSizeFactor;default:return 0}}function Te(e,t){const r=e.axis,n=t?.type??"double",o={initial:0,current:0},i=P[e.valueUnit]??1;let a;return a="area"===e.valueRepresentation?e=>(e*i/2)**2*Math.PI:"radius"===e.valueRepresentation||"distance"===e.valueRepresentation?e=>e*i/2:e=>e*i,{field:e.field,fieldType:n,getDefaultValue:async(e,t)=>Fe(a(await ve(t,e,r)),n),getValue:(e,t)=>(o.initial||(o.initial=t.pixelSizeAt(t.center)),o.current=o.initial*e,Fe(o.current,n)),setInitialValue:e=>{o.initial=e,o.current=0},isUpdatingInteractively:!1,displayUnit:ft(e.valueUnit),axis:e.axis}}function Fe(e,t){switch(t){case"small-integer":case"integer":case"long":return Math.round(e);case"double":case"single":return e;default:return 0}}function je(e){if(!E(e))return!1;switch(e?.type){case"class-breaks":case"simple":case"unique-value":case"dot-density":case"dictionary":case"pie-chart":return!0;default:return!1}}async function Se(e,t,r){const n=await Q(e,{useSourceLayer:!0,ignoreGraphicSymbol:!0,webStyleCache:t,scale:r});null!=T(e.symbol,n)&&(e.symbol=n)}function ke(e,t){if(!e||!t)throw new Error("no geometry type");if("multipatch"===e)return{tool:"mesh",createOptions:{mode:"hybrid"}};const r=new Map;r.set("circle",{mode:"freehand"}),r.set("rectangle",{mode:"freehand"});const n={mode:H,optionsPerTool:r};if(F(t)){const o=t.defaultTool,i=j(t)?t.definition?.inputGeometryType??e:e;switch(o){case"freehand":case"stream-line":return{tool:"polyline"===i?"freehandPolyline":"freehandPolygon",createOptions:n};case"autocomplete-freehand-polygons":case"stream-polygon":return{tool:"freehandPolygon",createOptions:n};case"autocomplete-polygons":case"difference-polygon":case"create-structures":case"polygon":case"trace":return{tool:"polygon"===i?"polygon":"polyline",createOptions:n};case"circle":return r.get("circle").preserveAspectRatio=!0,{tool:"circle",createOptions:n};case"ellipse":return r.get("circle").preserveAspectRatio=!1,{tool:"circle",createOptions:n};case"create-points-along-line":case"multipoint":return{tool:"multipoint",createOptions:n};case"line":case"radial-line":case"right-angle-line":case"split":case"two-point-line":return{tool:"polyline",createOptions:n};case"rectangle":case"regular-polygon":case"right-angle-polygon":return{tool:"rectangle",createOptions:n};case"elevation-point-from-contour":case"elevation-point-from-dem":case"parcel-seed":case"point":case"point-and-rotation":case"point-at-end-of-line":return{tool:"point",createOptions:n}}}else{const o=t.drawingTool;if("circle"===o||"ellipse"===o)return r.get("circle").preserveAspectRatio="circle"===o,{tool:"circle",createOptions:n};if("rectangle"===o)return{tool:"rectangle",createOptions:n};if("freehand"===o)return{tool:"polygon"===e?"freehandPolygon":"freehandPolyline",createOptions:n}}return{tool:e,createOptions:n}}async function Ae(e,t,r,n){const{creationInfo:o,fullTemplate:i}=r;if(!o)throw new a("featureworkflow","No creation info provided.");const s=o.layer,l=S(i,o.attributeOverrides,o.layer),{view:c}=e,u="2d"===c?.type;j(i)||k(i)||await Qe(e,s,l,n,u?c.scale:null);const{capabilities:p}=s;t.elevationInfo=s.elevationInfo;const d=ke(s.geometryType,i);e.defaultCreateOptions={graphicProperties:{attributes:l,sourceLayer:s},mode:d.createOptions.mode,optionsPerTool:d.createOptions.optionsPerTool,preserveAspectRatio:d.createOptions.preserveAspectRatio,hasZ:p.data.supportsZ,defaultZ:(u?p.editing.zDefault:null)??e.defaultCreateOptions.defaultZ},null==o.geometryToPlace?await e.create(d.tool):await e.place(o.geometryToPlace,{graphicProperties:{attributes:l,sourceLayer:s}})}async function Le(e){return s([Ue(e),Ve(e)])}function Ue({creationAttributes:e,data:t,sketchViewModel:r,view:n,webStyleCache:o}){const{creationInfo:i}=t,{fullTemplate:a}=t;if(!i||"2d"!==n?.type||j(a)||k(a))return null;const s=f(t=>Qe(r,i.layer,e,o,t));return g(()=>n.scale,e=>s(e))}function Ve({data:t,sketchViewModel:r,view:n}){const{templateExecutorInfo:o}=t;if(!o)return null;const i=r.activeComponent;if(!n||!_(i)&&!ee(i))return te().error(new a("featureworkflow","Failed to set up template feedback.")),null;const c=new U({effect:"saturate(0.6) opacity(0.8)",listMode:"hide",title:"Shared Template Feedback Graphics"});n.map?.add(c);const{executor:u,serviceLayersById:p}=o,d=n.theme?.accentColor??new e([255,165,0,1]);return s([b(()=>i,["cursor-update","vertex-add"],()=>{c.removeAll();const e=_(i)?i.graphic?.geometry:i.unprocessedGeometry;if(!e||!Me(e))return;const t=u(e,"digitizing");if(!y(t))for(const r of t.edits){const e=p.get(r.id);if(e&&r.addFeatures&&0!==r.addFeatures.length)for(const t of e)if(!t.isTable)for(const e of r.addFeatures){const t=Oe(e,d);t&&c.add(t)}}}),l(()=>{n.map.remove(c),c.destroy()})])}function Me(e){switch(e.type){case"point":case"multipoint":return!0;case"polyline":{if(A(e))return e.curvePaths[0].length>1;const t=e.paths[0];return!!t&&t.length>1}case"polygon":{if(A(e))return e.curveRings[0].length>2;const t=e.rings[0];return!!t&&(n(t.at(0),t.at(-1))?t.length>2:t.length>1)}default:return!1}}function Oe(e,r){let n=null;switch(e.geometry?.type){case"point":case"multipoint":n=new Z({angle:0,color:r,outline:new B({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:1}),path:"undefined",size:8,style:"circle",xoffset:0,yoffset:0});break;case"polygon":n=new G({color:r,outline:new B({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:3}),style:"none"});break;case"polyline":n=new B({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:2});break;default:return null}return new t({geometry:e.geometry,symbol:n,attributes:{...e.attributes}})}function xe(e,t){const r=W(t),n=x(e)?e.parent:e;return r.tablesAndLayersLookup.get(n)}function qe(e,t){const r=xe(e,t);if(!r)return new Map;const n=new Map;for(const o of r.layersAndTables)d(n,o.layerId,()=>[]).push(o);return n}function ze(e){const t=e.objectIdField,r=e.globalIdField??"";return{id:e.layerId,identifierFields:{objectIdField:t,globalIdField:r},addFeatures:[],deleteAttachments:[],addAttachments:[],deleteFeatures:[],updateFeatures:[]}}function Ce(e){const{edits:t,serviceInfo:n,view:o,findOriginalFeature:i}=e,a=Pe(n.layersAndTables),s=n.layersAndTables.toArray(),{allEditData:l,editDataByLayerIdMap:c,editDataByIdMap:u}=Re(t,a,i),p=De(l,Ee(s,c),c);if(o&&Ze(l,p,o),0===p.length)return t;const d=Y(p,{continueOnCircularDependency:!0}).map(e=>u.get(e)).filter(r),f=new Map;for(const r of d)f.set(r.uniqueId,r);const y=[];for(const r of l)f.has(r.uniqueId)||y.push(r);const m=[];let h=null;for(const r of d){const{layer:e}=r;switch(null==h?h=ze(e):h.id!==e.layerId&&(m.push(h),h=ze(e)),r.operationType){case"add":case"modify":h.addFeatures.push(r.after);break;case"delete":h.deleteFeatures.push(r.before)}}null!==h&&m.push(h);for(const r of y){const e=r.layer.layerId,t=m.find(t=>t.id===e)??ze(r.layer);switch(m.includes(t)||m.push(t),r.operationType){case"add":t.addFeatures.push(r.after);break;case"modify":t.updateFeatures.push(r.after);break;case"delete":t.deleteFeatures.push(r.before);break;case"deleteAttachment":t.deleteAttachments.push(r.attachmentId);break;case"addAttachment":t.addAttachments.push(r.attachment)}}for(const r of m)void 0!==r.deleteAttachments&&0===r.deleteAttachments.length&&delete r.deleteAttachments,void 0!==r.addAttachments&&0===r.addAttachments.length&&delete r.addAttachments;return m}function Pe(e){const t=new Map;for(const r of e)t.set(r.layerId,r);return t}function Ee(e,t){const r=new Map;for(const n of e)for(const e of n.relationships??[])if(r.set(Ge(n,e),""),t.has(e.relatedTableId)){const o=t.get(e.relatedTableId);if(o.length>0)for(const t of o[0].layer.relationships??[])if(t.id===e.id){r.set(Ge(n,e),t.keyField);break}}return r}function Re(e,t,r){const n=new Map,o=[],i=new Map;let s=1;for(const l of e){const e=[],c=t.get(l.id);if(!c)throw new a("featureworkflow",`Failed to prepare applyEdits payload. Layer with id ${l.id} not found.`);for(const t of l.addFeatures??[])e.push({uniqueId:"T"+s++,operationType:"add",layer:c,after:t});for(const t of l.deleteFeatures??[])e.push({uniqueId:"T"+s++,operationType:"delete",before:t,layer:c});for(const t of l.deleteAttachments??[])e.push({uniqueId:"T"+s++,operationType:"deleteAttachment",attachmentId:t,layer:c});for(const t of l.addAttachments??[])e.push({uniqueId:"T"+s++,operationType:"addAttachment",attachment:t,layer:c});for(const t of l.updateFeatures??[])e.push({uniqueId:"T"+s++,operationType:"modify",before:r(t),after:t,layer:c});n.set(c.layerId,e);for(const t of e)o.push(t),i.set(t.uniqueId,t)}return{allEditData:o,editDataByIdMap:i,editDataByLayerIdMap:n}}function De(e,t,r){const n=[];for(const o of e){const e=o.layer.relationships??[],{uniqueId:i}=o;for(const a of e){const e=a.keyField;if("origin"===a.role){const s=r.get(a.relatedTableId);if(!s||0===s.length)continue;const l=Ge(o.layer,a),c=t.get(l);if(void 0===c||""===c)continue;switch(o.operationType){case"add":for(const t of s)t!==o&&("add"!==t.operationType&&"modify"!==t.operationType||t.after.attributes[c]===o.after.attributes[e]&&n.push([i,t.uniqueId]));break;case"modify":if(o.before.attributes[e]!==o.after.attributes[e])for(const t of s){const r=t.uniqueId;t!==o&&("delete"===t.operationType?t.before.attributes[c]===o.before.attributes[e]?n.push([r,i]):t.before.attributes[c]===o.after.attributes[e]&&n.push([i,r]):"add"===t.operationType?t.after.attributes[c]===o.after.attributes[e]?n.push([i,r]):t.after.attributes[c]===o.before.attributes[e]&&n.push([r,i]):"modify"===t.operationType&&(t.before.attributes[c]!==t.after.attributes[c]?t.after.attributes[c]===o.after.attributes[e]?n.push([i,r]):n.push([r,i]):n.push([i,r])))}break;case"delete":for(const t of s)t!==o&&("delete"!==t.operationType&&"modify"!==t.operationType||t.before.attributes[c]===o.before.attributes[e]&&n.push([t.uniqueId,i]))}}}}return n}function Ge(e,t){return`${e.layerId}:${t.id}`}function Be(e,t){return!!(t?.map&&"utilityNetworks"in t.map&&t.map.utilityNetworks?.length&&t.map.utilityNetworks.some(t=>!(!t.loaded||!e.url?.startsWith(t.featureServiceUrl)||e.layerId!==t.networkSystemLayers.associationsTableId)))}function Ze(e,t,r){const n=[];for(const i of e)Be(i.layer,r)&&n.push(i);if(0===n.length)return;let o=[];for(const i of n){const r=i.layer;switch(i.operationType){case"delete":o=[...Ne(i.before.attributes[r.fieldsIndex.get("fromglobalid").name],e),...Ne(i.before.attributes[r.fieldsIndex.get("toglobalid").name],e)];for(const e of o)t.push([i.uniqueId,e.uniqueId]);break;case"add":o=[...Ne(i.after.attributes[r.fieldsIndex.get("fromglobalid").name],e),...Ne(i.after.attributes[r.fieldsIndex.get("toglobalid").name],e)];for(const e of o)t.push([e.uniqueId,i.uniqueId])}}}function Ne(e,t){const r=[],n=t.filter(({layer:e})=>""!==e.globalIdField&&null!=e.globalIdField);for(const o of n){const t=o.layer.globalIdField;("before"in o&&o.before?.attributes[t]===e||"after"in o&&o.after?.attributes[t]===e)&&r.push(o)}return r}async function Qe(e,r,n,o,i){const a=new t({sourceLayer:r,attributes:n}),{rotation:s,size:l}=be(a);let c=await Q(a,{useSourceLayer:!0,webStyleCache:o,scale:i}),u=!1;for(const t of[l,s]){if(null==t)continue;null==n[t.field]&&(n[t.field]=await t.getDefaultValue(c,e.view),u=!0)}switch(u&&(c=await Q(a,{useSourceLayer:!0,webStyleCache:o,scale:i})),c?.type){case"simple-fill":case"polygon-3d":e.polygonSymbol=c;break;case"simple-line":case"line-3d":e.polylineSymbol=c;break;case"simple-marker":case"picture-marker":case"point-3d":case"cim":e.pointSymbol=c;break;case"mesh-3d":e.meshSymbol=c}We(e.tooltipOptions,l,s)}function We(e,t,r){e.visualVariables=null!=t||null!=r?{size:null!=t?{unit:t.displayUnit,axis:t.axis,valueType:t.fieldType}:null,rotation:null!=r?{valueType:r.fieldType,rotationType:r.rotationType??"geographic"}:null}:null}function $e(e,t){return e.find(e=>e.layer===t)}function He(e,t){const r=$e(e,t);if(null==r)throw new a("no-editorItem-found","The EditorViewModel provided did not have an EditorItem associated with the specified layer");return r}function Je(e,t){return e?.find(e=>e.layer===t)}async function Ke(e,t,r,n){switch(t.type){case"3d":return Xe(e,t,r,n);case"2d":return Ye(e,t,r,n)}}async function Xe(e,t,r,n){if(0===e.length)return[];const{updatable:i,graphicsByLayer:a}=await r.defer(async()=>{const{results:o}=await h(X(t,r),n),i=new Map,a=e=>{const t=e.layer,r=i.get(t);if(!r){const e=new Array;return i.set(t,e),e}return r};K(o).forEach(({graphic:e})=>a(e).push(e));const s=e.filter(({capabilities:e,layer:t})=>e.update.enabled&&i.has(t));return 0!==s.length&&r.stopPropagation(),{updatable:s,graphicsByLayer:i}});return h(Promise.allSettled(i.map(async({layer:e})=>{const t=a.get(e),r=_e(e);if(t.every(e=>V(e,r)))return t;const i=[];for(const n of t){i.push(n.getObjectId());const e=Object.keys(n.attributes);o(r,e)}const s=e.createQuery();return s.returnGeometry=!1,s.objectIds=i,s.outFields=M(e.fieldsIndex,r),e.queryFeatures(s,{signal:n}).then(({features:e})=>e)})),n)}async function Ye(e,t,r,n){if(0===e.length)return[];const{mapPoint:o}=r;if(null==o)return[];let i=null;const a=await r.defer(async()=>{const{results:o}=await h(t.hitTest(r),n);if(0===o.length)return[];const a=new Set;i=K(o),i.forEach(({graphic:e})=>e&&a.add(e.layer));const s=e.filter(e=>a.has(e.layer)&&e.supportsUpdateWorkflow);return s.length>0&&r.stopPropagation(),s});return h(Promise.allSettled(a.map(async({layer:e})=>{const a=e.createQuery();a.returnGeometry=!0,a.outFields=_e(e);const s="renderer"in e?C({renderer:e.renderer,pointerType:r.pointerType}):0;a.geometry=J(o,s,t),a.outSpatialReference=t.spatialReference;const{features:l}=await e.queryFeatures(a,{signal:n});return i?.forEach(({graphic:t})=>{t.layer!==e||l.some(e=>e.getObjectId()===t.getObjectId())||l.push(t)}),l})),n)}function _e(e){return M(e.fieldsIndex,[e.objectIdField,O({displayField:"displayField"in e?e.displayField:null,fields:e.fields})])}async function et(e,t,n,o){return tt(e.map(e=>e.getObjectId()??e.attributes[t.objectIdField]).filter(r),t,n,o)}async function tt(e,t,r,n){const o=t.createQuery();o.objectIds=e,o.outFields=["*"],o.returnM=t.capabilities.data.supportsM,o.returnZ=t.capabilities.data.supportsZ,o.returnGeometry=!0,z(t)&&null!=t.infoFor3D||(o.outSpatialReference=r),!z(t)&&t.capabilities?.data.supportsTrueCurve&&(o.returnTrueCurves=!0);const i=await t.queryFeatures(o,{signal:n});return m(n),i.features}async function rt(e){const{graphic:t,sketchViewModel:r,sourceLayer:n,updateOptions:o,visualVariables:i}=e;await nt(e);const a={multipleSelectionEnabled:!1,...o};return"point"===n.geometryType&&(a.enableRotation=null!=i.rotation,a.enableScaling=null!=i.size),r.update(t,a)}async function nt(e){const{graphic:t,sketchLayer:r,sketchViewModel:n,sourceLayer:o,visualVariables:i,webStyleCache:a}=e;let s=!1;const{rotation:l,size:c}=i;for(const u of[l,c]){if(null==u)continue;const e=t.getAttribute(u.field);if(null!=e)u.setInitialValue(e);else{const e=await u.getDefaultValue(t.symbol,n.view);u.setInitialValue(e),t.setAttribute(u.field,e),s=!0}}if(s){const e="2d"===n.view?.type?n.view.scale:null;await Se(t,a,e)}We(n.tooltipOptions,c,l),r.elevationInfo=o.elevationInfo}function ot(e){return null==e||"rotate-start"!==e.type&&"rotate"!==e.type&&"rotate-stop"!==e.type?null:e}function it(e){return null==e||"scale-start"!==e.type&&"scale"!==e.type&&"scale-stop"!==e.type?null:e}function at(e,t,r,n){if(null==t.geometry||"point"!==t.geometry?.type)return!1;const o=t.attributes;let i=!1;const a=n.rotation,s=ot(r.toolEventInfo);if(null!=a&&null!=s){const{field:r,getValue:n}=a;if("rotate-stop"===s.type)a.isUpdatingInteractively=!1,a.setInitialValue(t.getAttribute(r));else{a.isUpdatingInteractively=!0;const l=n(s.angle,e);l!==o[r]&&t.setAttribute(r,l),i=!0}}const l=n.size,c=it(r.toolEventInfo);if(null!=l&&null!=c){const{field:r,getValue:n}=l;if("scale-stop"===c.type)l.isUpdatingInteractively=!1,l.setInitialValue(t.getAttribute(r));else{l.isUpdatingInteractively=!0;const a=n(c.xScale,e);a!==o[r]&&t.setAttribute(r,a),i=!0}}return i}async function st({feature:e,featureClone:t,sketchLayer:r,sketchViewModel:n,updateOptions:o,view:i,visualVariableAttributes:a,webStyleCache:u,addHandle:p,addUpdatingPromise:d,onUpdate:y}){await Se(t,u,"2d"===i.type?i.scale:null);let m=null;if("2d"===n?.view?.type){const e=f(e=>Se(t,u,e));m=g(()=>n?.view?.scale,t=>e(t))}const h=t.sourceLayer,b=ht(i,h);await rt({graphic:t,sketchLayer:r,sketchViewModel:n,sourceLayer:h,updateOptions:o,visualVariables:a,webStyleCache:u});let I=null;b.then(e=>I=e).catch(()=>{});const v=a.size,T=a.rotation,F=g(()=>e.attributes,async e=>{let r=!1;for(const n in e){const o=e[n];o!==t.getAttribute(n)&&(t.setAttribute(n,o),null==v||v.isUpdatingInteractively||v.field!==n||v.setInitialValue(o),null==T||T.isUpdatingInteractively||T.field!==n||T.setInitialValue(o),(null==I||I.requiredFields.includes(n))&&(r=!0))}r&&await Se(t,u,"2d"===i.type?i.scale:null)}),j=n.on("update",async e=>{const t=e.graphics[0],s={graphic:t,sketchLayer:r,sketchViewModel:n,sourceLayer:h,updateOptions:o,visualVariables:a,webStyleCache:u};if("complete"===e.state){if(null===i.activeTool)return rt(s);const e=new AbortController,t=c(e);return p(t),d(w(()=>null===i.activeTool,e.signal).then(async()=>{if(!e.signal.aborted)return e.abort(),rt(s)}))}at(i,t,e,a)&&await Se(t,u,"2d"===i.type?i.scale:null),y(bt(t),e)}),S=n.on(["undo","redo"],e=>{y(bt(e.graphics[0]),e)});return s([S,j,l(()=>n.cancel()),F,m])}async function lt(e,t,r,n){e.add(n);const o=r.sourceLayer,a=r.layer??o,c=r.getAttribute(o.objectIdField);let u=null;function p(e){u?.abort(),q(a)?r.visible=e:u=i(async r=>{const n=await ht(t,a);if(m(r),!t.destroyed&&!n.destroyed)try{n.setVisibility?.(c,e)}catch(o){if(r.aborted||t.destroyed||n.destroyed)return;throw o}})}return await ct(t,n),p(!1),s([l(async()=>{p(!0);try{if(!t.destroyed){const e=await ht(t,a).catch(()=>{});e&&!e.destroyed&&await w(()=>!e.updating)}}finally{e.remove(n)}})])}async function ct(e,t){if("3d"===e.type){const r=new $({graphic:t}),n=e.trackGraphicState(r);await w(()=>r.displaying||r.error),n.remove()}else await w(()=>t.visible)}const ut={icon:I(24),text:I(12),line:I(1),viewScaleSizeFactor:100};function pt(e,t,r){let n=!1;return e.filter(e=>!!n||(n=e===t,n)).map(e=>r[e]())}function dt(e,t){e.viewModel.syncFeatureTemplates();const r=e.creationInfo;if("awaiting-feature-creation-info"===t[0].id&&r){const n=r.layer,o=e.viewModel.getTemplatesForLayer(n);1===o.length&&"scene"!==n.type&&(r.template=o[0],t.shift())}return t}function ft(e){return"unknown"===e?null:e}function yt(e){e.filesEnabled=!0,e.mode="view",e.capabilities={editing:!0,operations:{add:!0,update:!0,delete:!0}}}const mt=e=>e.includes("-stop")||e.includes("vertex-"),ht=(e,t)=>{const r="subtype-sublayer"===t.type?t.parent:t;return e.whenLayerView(r)};function gt(e){return"createInteractiveEditSession"in e}function bt(e){const t=e.geometry;if("mesh"===t?.type){const r=e.cloneShallow();return r.attributes=u(e.attributes),r.geometry=t.cloneShallow(),r.geometry.transform=t.transform?.clone()??null,r}return e.clone()}function wt(e){return e.acquireCursor("progress")}function It(e){for(const t of e){const{destinationGraphic:e,destinationField:r,sourceGraphic:n,sourceField:o}=t;e.setAttribute(r,n.getAttribute(o))}}function vt(e){const t=e.templateExecutorInfo?.completionResults;return t?.length?(t.forEach(e=>It(e.relationships)),t.flatMap(e=>e.edits)):null}function Tt(e){const t=ce(e)?e.activeWorkflow:e;if(null==t)return[];if(ae(t))return t.data.layers;const r=t.layer;return r?[r]:[]}function Ft({attributes:e},t){const r=new Set;r.add(t.objectIdField),"uniqueIdFields"in t&&t.uniqueIdFields&&t.uniqueIdFields.length>0&&v(r,t.uniqueIdFields);const n={};for(const o of r)null!=e[o]&&(n[o]=e[o]);if("scene"===t.type&&null!=t.infoFor3D){const r=t.associatedLayer?.globalIdField;null!=r&&(e[r]=e[r])}return n}function jt(e){if(!St(e))return e;const t=new Map;for(const r of e){const e=r.getObjectId();if(null!=e){const n=r.sourceLayer??r.layer;d(t,n,()=>[]).push(e)}}return Array.from(t.entries()).map(([e,t])=>({layer:e,objectIds:t}))}function St(e){return 0===e.length||D(e[0])}function kt({drawTool:e},t){const r=e?.mostDownstreamPlugin?.configuration?.curveTypes;if(!t||!r||0===r.length)return!1;const n=new Set(t.capabilities.supportedCurveTypes);return r.some(e=>!n.has(e))}function At(e,t){const r=new Set(t.capabilities.supportedCurveTypes);return e.some(({geometry:e})=>e&&A(e)&&L(e,r))}export{kt as activeSketchToolDrawsUnsupportedCurve,Ze as appendAllUtilityNetworkAssociationRelationships,dt as avoidFeatureTemplateSelectionWithOnlyOneItem,gt as canCreateInteractiveEditSession,bt as cloneGraphicExceptMesh,At as containsUnsupportedCurve,Pe as createLayerIdMap,Ee as createRelationshipKeyMap,ke as createToolFromGeometryType,pt as createWorkflowSteps,Ke as fetchCandidates,et as fetchFullFeatures,tt as fetchFullFeaturesByObjectId,De as findAllDependencies,Ne as findChangesByGlobalId,$e as findEditorItemForLayer,He as findEditorItemForLayerOrThrow,Je as findLayerInfo,Ge as generateHashForRelationship,Tt as getLayersFromWorkflow,we as getRotationVariableAttribute,vt as getServiceEditsFromWorkflowData,xe as getServiceInfoForLayer,qe as getServiceLayersById,Te as getSizeVariableAttribute,be as getVisualVariableAttributes,ge as getVisualVariablesForLayer,re as isAnyUpdateLeafWorkflow,ne as isBatchAttributeFormViewModel,oe as isCreateFeaturesWorkflow,ie as isFeatureFormViewModel,St as isGraphicsArray,ue as isMergeFeaturesWorkflow,fe as isMergeWorkflowOptions,de as isParentWorkflow,pe as isSplitFeatureWorkflow,ye as isSplitWorkflowOptions,mt as isTerminalUpdateEventType,se as isUpdateFeatureWorkflow,ae as isUpdateFeaturesWorkflow,he as isUpdateFeaturesWorkflowOptions,le as isUpdateRecordWorkflow,ce as isUpdateWorkflow,Be as isUtilityNetworkAssociationsTable,Ft as makeMinimalAttributes,Ce as orderEditsByRelationshipDependencies,yt as prepareAttachmentsForCreateFeaturesWorkflow,It as setRelationshipFields,st as setUpGeometryUpdate,Le as setUpSketchCreateWatchers,nt as setVisualVariablesAndElevationInfoForUpdate,wt as showProgressCursor,ut as sizeDefaults,ft as sizeVariableUnitToLengthUnit,Ae as startCreatingNewFeature,rt as startUpdatingFeatureGeometry,lt as swapForEditingSession,jt as toFeatureInfos,Se as updateGraphicSymbolWhenRequired,at as visualVariableInteractiveUpdate,ht as whenEditorLayerView,ct as whenGraphicDisplayed,me as workflowInfluencesOutcomeOfParent};
@@ -763,4 +763,5 @@ export interface EditorStartSplitFeatureWorkflowOptions {
763
763
  }
764
764
 
765
765
  /** This object provides required properties needed when creating a new feature. */
766
- export type CreateFeaturesCreationInfo = Required<Pick<CreationInfo, "layer" | "template">>;
766
+ export type CreateFeaturesCreationInfo = Required<Pick<CreationInfo, "layer" | "template">>
767
+ & Partial<Pick<CreationInfo, "maxFeatures">>;