@arcgis/core 4.27.0-next.20230516 → 4.27.0-next.20230518

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 (194) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/03dba2a2bbc363369a0f.js +1 -0
  3. package/assets/esri/core/workers/chunks/12714d64a0154688072e.js +1 -0
  4. package/assets/esri/core/workers/chunks/{a507135977d83aea4421.js → 1827a3da6b5b9272ffe1.js} +1 -1
  5. package/assets/esri/core/workers/chunks/1edc5c06874cb12c5478.js +1 -0
  6. package/assets/esri/core/workers/chunks/{395ef46b635f9e9a5643.js → 20e8e18e4bd2fd5da47c.js} +1 -1
  7. package/assets/esri/core/workers/chunks/23f73f81aea461c0c6e6.js +1 -0
  8. package/assets/esri/core/workers/chunks/{15dda462b979e90b58fe.js → 3cebdd77a8401495097f.js} +1 -1
  9. package/assets/esri/core/workers/chunks/3eb75b6c3c4b3aea2325.js +1 -0
  10. package/assets/esri/core/workers/chunks/48cb634255e39711a720.js +1 -0
  11. package/assets/esri/core/workers/chunks/4d5f71d84c85f45c97ea.js +1 -0
  12. package/assets/esri/core/workers/chunks/55ca6ba8b40921025181.js +2 -0
  13. package/assets/esri/core/workers/chunks/{ef141014ed21a7fd1ff3.js.LICENSE.txt → 55ca6ba8b40921025181.js.LICENSE.txt} +1 -1
  14. package/assets/esri/core/workers/chunks/6312783626bacf52df7a.js +1 -0
  15. package/assets/esri/core/workers/chunks/{a3822a97701890c12d63.js → 6b3b277a21de7c434717.js} +1 -1
  16. package/assets/esri/core/workers/chunks/6d80f81bf6ad97a7e69e.js +1 -0
  17. package/assets/esri/core/workers/chunks/887a630c5c980c5028e1.js +1 -0
  18. package/assets/esri/core/workers/chunks/{522660da4589739a70c3.js → c7fb48ea5d907883bcce.js} +1 -1
  19. package/assets/esri/core/workers/chunks/d0ff968e42116f592065.js +1 -0
  20. package/assets/esri/core/workers/chunks/{fdf64f23529a22c79fbd.js → d52c920acf08c95277c3.js} +19 -19
  21. package/assets/esri/core/workers/chunks/d64c271c173797d98286.js +1 -0
  22. package/assets/esri/core/workers/chunks/e1b2076d0040fcb7d864.js +1 -0
  23. package/assets/esri/core/workers/chunks/e3397036e060dac3b4d5.js +1 -0
  24. package/assets/esri/core/workers/chunks/e6836c84470fb6bd25bf.js +1 -0
  25. package/assets/esri/core/workers/chunks/f3f6035a17f7dcd19675.js +1 -0
  26. package/assets/esri/core/workers/chunks/{bff317b08e91414f6edc.js → f720967ba8c5486a26a2.js} +1 -1
  27. package/assets/esri/themes/base/widgets/_BasemapGallery.scss +20 -11
  28. package/assets/esri/themes/base/widgets/_Editor.scss +0 -9
  29. package/assets/esri/themes/base/widgets/_FeatureForm.scss +4 -2
  30. package/assets/esri/themes/base/widgets/_ItemList.scss +0 -49
  31. package/assets/esri/themes/base/widgets/_ValuePicker.scss +27 -10
  32. package/assets/esri/themes/dark/main.css +1 -1
  33. package/assets/esri/themes/light/main.css +1 -1
  34. package/assets/esri/themes/light/view.css +1 -1
  35. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_ar.json +1 -1
  36. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_bg.json +1 -1
  37. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_bs.json +1 -1
  38. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_ca.json +1 -1
  39. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_cs.json +1 -1
  40. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_da.json +1 -1
  41. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_de.json +1 -1
  42. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_el.json +1 -1
  43. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_es.json +1 -1
  44. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_et.json +1 -1
  45. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_fi.json +1 -1
  46. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_fr.json +1 -1
  47. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_he.json +1 -1
  48. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_hr.json +1 -1
  49. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_hu.json +1 -1
  50. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_id.json +1 -1
  51. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_it.json +1 -1
  52. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_ja.json +1 -1
  53. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_ko.json +1 -1
  54. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_lt.json +1 -1
  55. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_lv.json +1 -1
  56. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_nb.json +1 -1
  57. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_nl.json +1 -1
  58. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_pl.json +1 -1
  59. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_pt-BR.json +1 -1
  60. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_pt-PT.json +1 -1
  61. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_ro.json +1 -1
  62. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_ru.json +1 -1
  63. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_sk.json +1 -1
  64. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_sl.json +1 -1
  65. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_sr.json +1 -1
  66. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_sv.json +1 -1
  67. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_th.json +1 -1
  68. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_tr.json +1 -1
  69. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_uk.json +1 -1
  70. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_vi.json +1 -1
  71. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_zh-CN.json +1 -1
  72. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_zh-HK.json +1 -1
  73. package/assets/esri/widgets/BasemapGallery/t9n/BasemapGallery_zh-TW.json +1 -1
  74. package/chunks/DefaultMaterial.glsl.js +4 -4
  75. package/chunks/HUDMaterial.glsl.js +22 -22
  76. package/chunks/HeatmapDensity.glsl.js +5 -5
  77. package/chunks/LineMarker.glsl.js +35 -35
  78. package/chunks/RibbonLine.glsl.js +47 -47
  79. package/chunks/ShadowCastVisualize.glsl.js +2 -2
  80. package/core/Queue.js +1 -1
  81. package/core/a11yUtils.js +5 -0
  82. package/interfaces.d.ts +769 -25
  83. package/intl/date.js +1 -1
  84. package/layers/ImageryTileLayer.js +1 -1
  85. package/layers/WMSLayer.js +1 -1
  86. package/layers/graphics/data/QueryEngine.js +1 -1
  87. package/layers/graphics/data/attributeSupport.js +1 -1
  88. package/layers/mixins/ArcGISImageService.js +1 -1
  89. package/layers/support/RasterBandInfo.d.ts +4 -0
  90. package/layers/support/RasterSensorInfo.d.ts +4 -0
  91. package/layers/support/infoFor3D.js +1 -1
  92. package/layers/support/rasterDatasets/TIFFRaster.js +1 -1
  93. package/layers/support/rasterFormats/TiffDecoder.js +1 -1
  94. package/layers/support/rasterFunctions/rasterFunctionHelper.js +1 -1
  95. package/package.json +2 -2
  96. package/popup/FieldInfo.js +1 -1
  97. package/popup/support/FieldInfoFormat.js +1 -1
  98. package/portal/schemas/definitions.js +1 -1
  99. package/rest/support/BaseImageMeasureParameters.d.ts +4 -0
  100. package/rest/support/BaseImageMeasureParameters.js +1 -1
  101. package/rest/support/ImageHistogramParameters.js +1 -1
  102. package/rest/support/ImageIdentifyParameters.js +1 -1
  103. package/smartMapping/raster/support/adapters/ImageryLayerAdapter.js +1 -1
  104. package/smartMapping/raster/support/adapters/ImageryTileLayerAdapter.js +1 -1
  105. package/support/revision.js +1 -1
  106. package/views/2d/engine/vectorTiles/GlyphMosaic.js +1 -1
  107. package/views/2d/engine/vectorTiles/GlyphSource.js +1 -1
  108. package/views/2d/engine/vectorTiles/TextShaping.js +1 -1
  109. package/views/2d/engine/vectorTiles/buckets/SymbolBucket.js +1 -1
  110. package/views/2d/engine/webgl/GlyphSource.js +1 -1
  111. package/views/2d/layers/MediaLayerView2D.js +1 -1
  112. package/views/2d/layers/TileLayerView2D.js +1 -1
  113. package/views/2d/layers/support/cimSymbolUtils.js +1 -1
  114. package/views/3d/interactive/editingTools/draw/DrawGraphicTool3D.js +1 -1
  115. package/views/3d/support/DisplayQualityProfile.js +1 -1
  116. package/views/3d/support/QualitySettings.js +1 -1
  117. package/views/3d/support/pointsOfInterest/PointsOfInterest.js +1 -1
  118. package/views/3d/terrain/Overlay.js +1 -1
  119. package/views/3d/terrain/OverlayManager.js +1 -1
  120. package/views/3d/terrain/OverlayRenderer.js +1 -1
  121. package/views/3d/webgl-engine/core/shaderLibrary/hud/HUD.glsl.js +13 -13
  122. package/views/3d/webgl-engine/core/shaderLibrary/shading/LineStipple.glsl.js +18 -18
  123. package/views/3d/webgl-engine/core/shaderLibrary/shading/MarkerSizing.glsl.js +8 -8
  124. package/views/3d/webgl-engine/core/shaderLibrary/util/View.glsl.js +1 -1
  125. package/views/3d/webgl-engine/lib/OffscreenRendering.js +1 -1
  126. package/views/3d/webgl-engine/lib/RenderFeature.js +1 -1
  127. package/views/3d/webgl-engine/lib/RenderTargetHelper.js +1 -1
  128. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  129. package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
  130. package/views/3d/webgl-engine/lib/ShadowCastRenderer.js +1 -1
  131. package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
  132. package/views/3d/webgl-engine/lib/lodRendering/LodComponentData.js +1 -1
  133. package/views/3d/webgl-engine/materials/DefaultBufferWriter.js +1 -1
  134. package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
  135. package/views/3d/webgl-engine/materials/HeatmapDensityMaterial.js +1 -1
  136. package/views/3d/webgl-engine/materials/LineCalloutMaterial.js +1 -1
  137. package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
  138. package/views/3d/webgl-engine/materials/MeasurementArrowMaterial.js +1 -1
  139. package/views/3d/webgl-engine/materials/NativeLineMaterial.js +1 -1
  140. package/views/3d/webgl-engine/materials/ShadedColorMaterial.js +1 -1
  141. package/views/3d/webgl-engine/materials/lineStippleUtils.js +1 -1
  142. package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
  143. package/views/3d/webgl-engine/shaders/HUDMaterial.glsl.js +1 -1
  144. package/views/3d/webgl-engine/shaders/HUDMaterialTechniqueConfiguration.js +1 -1
  145. package/views/3d/webgl-engine/shaders/HeatmapDensity.glsl.js +1 -1
  146. package/views/3d/webgl-engine/shaders/LineCalloutTechniqueConfiguration.js +1 -1
  147. package/views/3d/webgl-engine/shaders/LineMarkerTechniqueConfiguration.js +1 -1
  148. package/views/DOMContainer.js +1 -1
  149. package/views/PopupView.js +1 -1
  150. package/views/draw/DrawOperation.js +1 -1
  151. package/views/webgl/ValidatedTextureDescriptor.js +1 -1
  152. package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
  153. package/widgets/Editor/CreateWorkflow.js +1 -1
  154. package/widgets/Editor/EditorViewModel.js +1 -1
  155. package/widgets/Editor/UpdateWorkflow.js +1 -1
  156. package/widgets/Editor/Upload.js +1 -1
  157. package/widgets/Editor/Workflow.js +1 -1
  158. package/widgets/Editor/modelUploadUtils.js +1 -1
  159. package/widgets/Editor/workflowUtils.js +1 -1
  160. package/widgets/Editor.js +1 -1
  161. package/widgets/Feature/FeatureMedia.js +1 -1
  162. package/widgets/FeatureForm/InputField.js +5 -0
  163. package/widgets/FeatureForm/InputFieldGroup.js +5 -0
  164. package/widgets/FeatureForm/css.js +1 -1
  165. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  166. package/widgets/FeatureTable.js +1 -1
  167. package/widgets/FeatureTemplates/ItemList.js +1 -1
  168. package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
  169. package/widgets/Print/PrintViewModel.js +1 -1
  170. package/widgets/Search/SearchViewModel.js +1 -1
  171. package/widgets/ValuePicker/ValuePickerBaseComponent.js +1 -1
  172. package/widgets/ValuePicker/ValuePickerCollection.js +1 -1
  173. package/widgets/ValuePicker/ValuePickerCombobox.js +1 -1
  174. package/widgets/ValuePicker/ValuePickerLabel.js +1 -1
  175. package/widgets/ValuePicker/ValuePickerSlider.js +1 -1
  176. package/widgets/ValuePicker/ValuePickerViewModel.js +1 -1
  177. package/widgets/ValuePicker.js +1 -1
  178. package/assets/esri/core/workers/chunks/009026614cae60e9505c.js +0 -1
  179. package/assets/esri/core/workers/chunks/415c326d268b1a8fd03f.js +0 -1
  180. package/assets/esri/core/workers/chunks/504e929b686570ee858d.js +0 -1
  181. package/assets/esri/core/workers/chunks/5c811527898eb1c04e67.js +0 -1
  182. package/assets/esri/core/workers/chunks/6164a9c654c38f9cb64e.js +0 -1
  183. package/assets/esri/core/workers/chunks/6dd99db0adce09ac9794.js +0 -1
  184. package/assets/esri/core/workers/chunks/7cec069db0598431829e.js +0 -1
  185. package/assets/esri/core/workers/chunks/8bb3b10a777ae19f57f9.js +0 -1
  186. package/assets/esri/core/workers/chunks/91971a76a4ae0474a878.js +0 -1
  187. package/assets/esri/core/workers/chunks/9ed9e2ad50816a4f937a.js +0 -1
  188. package/assets/esri/core/workers/chunks/b3013a5a39d038b2d748.js +0 -1
  189. package/assets/esri/core/workers/chunks/b81bb096ccfcea182cc1.js +0 -1
  190. package/assets/esri/core/workers/chunks/cf3dd5aad1d60ff1b0b6.js +0 -1
  191. package/assets/esri/core/workers/chunks/d05d9ddf244bb3dcbcaa.js +0 -1
  192. package/assets/esri/core/workers/chunks/d3a6504fbaf555707c58.js +0 -1
  193. package/assets/esri/core/workers/chunks/ef141014ed21a7fd1ff3.js +0 -2
  194. package/assets/esri/core/workers/chunks/f4933025edecdc1aae76.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{removeUnordered as e,filterInPlace as t}from"../../../../../core/arrayUtils.js";import{someMap as r}from"../../../../../core/MapUtils.js";import{NestedMap as s}from"../../../../../core/NestedMap.js";import i from"../../../../../core/PooledArray.js";import{m as a,a as o,t as n}from"../../../../../chunks/mat4.js";import{c as l}from"../../../../../chunks/mat4f64.js";import{glLayout as h}from"../../../support/buffer/glUtil.js";import{ShaderOutput as u}from"../../core/shaderLibrary/ShaderOutput.js";import{AppleAmdDriverHelper as c}from"../../lib/AppleAmdDriverHelper.js";import{GLMaterials as f}from"../../lib/GLMaterials.js";import{RenderOccludedFlag as d}from"../../lib/Material.js";import{DirtyState as m}from"../../lib/ModelDirtyTypes.js";import{assert as g,setMatrixTranslation3 as p}from"../../lib/Util.js";import{DrawParameters as y}from"../DrawParameters.js";import{WaterMaterial as _}from"../WaterMaterial.js";import{BufferRange as v,mergeAdjacentRanges as w}from"./BufferRange.js";import{Instance as b}from"./Instance.js";import{PerBufferData as O,hasVao as A}from"./PerBufferData.js";import{PerOriginData as C}from"./PerOriginData.js";import{VaoCache as H}from"./VaoCache.js";class B{constructor(e,t,r){this._rctx=e,this._materialRepository=t,this.material=r,this._dataByOrigin=new Map,this._appleAmdDriverHelper=null,this._hasHighlights=!1,this._hasOccludees=!1,this._glMaterials=new f(this.material,this._materialRepository),this._bufferWriter=r.createBufferWriter(),this._vaoCache=new H(e,r.vertexAttributeLocations,h(this._bufferWriter.vertexBufferLayout)),this._rctx.driverTest.drawArraysRequiresIndicesTypeReset.result&&(this._appleAmdDriverHelper=new c(this._rctx))}dispose(){this._glMaterials.destroy(),this._dataByOrigin.forEach((e=>e.dispose())),this._dataByOrigin.clear(),this._vaoCache.dispose(),this._appleAmdDriverHelper?.dispose()}get isEmpty(){return 0===this._dataByOrigin.size}get hasHighlights(){return this._hasHighlights}get hasOccludees(){return this._hasOccludees}get hasWater(){return!this.isEmpty&&this.material instanceof _}get rendersOccluded(){return!this.isEmpty&&this.material.renderOccluded!==d.Occlude}get numGeometries(){let e=0;return this._dataByOrigin.forEach((t=>e+=t.buffers.reduce(((e,t)=>e+t.instances.size),0))),e}forEachGeometry(e){this._dataByOrigin.forEach((t=>t.buffers.forEach((t=>t.instances.forEach((t=>e(t.geometry)))))))}modify(e){this._updateGeometries(e.updates),this._addAndRemoveGeometries(e.adds,e.removes),this._updateDrawCommands()}_updateGeometries(e){const t=this._bufferWriter,r=t.vertexBufferLayout.stride/4;for(const s of e){const e=s.renderGeometry,i=this._dataByOrigin.get(e.localOrigin.id),a=i?.findBuffer(e.id);if(null==a)return;const o=a.instances.get(e.id);if(s.updateType&(m.GEOMETRY|m.TRANSFORMATION)){const s=W(t.elementCount(o.geometry.geometry)*r),i=t.vertexBufferLayout.createView(s.buffer);this._writeGeometry(e,i,0),a.vao.vertexBuffers.geometry.setSubData(s,o.from*r,0,o.numElements*r),P()}s.updateType&(m.HIGHLIGHT|m.OCCLUDEE|m.VISIBILITY)&&(a.drawCommandsDirty=!0)}}_computeDeltas(e,t){const r=new s;for(const s of e){const e=s.localOrigin;if(null==e)continue;let t=r.get(e.id,null);null==t&&(t=new D(e.vec3),r.set(e.id,null,t)),t.changes.push(s)}for(const s of t){const e=s.localOrigin;if(null==e)continue;const t=this._dataByOrigin.get(e.id),i=t?.findBuffer(s.id);if(null==i)continue;let a=r.get(e.id,i);null==a&&(a=new D(e.vec3),r.set(e.id,i,a)),a.changes.push(s)}return r}_addAndRemoveGeometries(t,r){const{_bufferWriter:s,_dataByOrigin:i}=this,a=s.vertexBufferLayout.stride/4,o=this._computeDeltas(t,r);o.forEach(((t,r)=>{const n=t.get(null),l=null!=n?n.changes:[];o.delete(r,null);let h=i.get(r);if(t.forEach(((t,n)=>{if(o.delete(r,n),null==n)return void g(!1,"No VAO for removed geometries");if(n.instances.size===t.changes.length)return this._vaoCache.deleteVao(n.vao),e(h.buffers,n),void(0===h.buffers.length&&0===l.length&&i.delete(r));const u=n.numElements,c=n.vao.byteSize/4,f=l.reduce(((e,t)=>e+s.elementCount(t.geometry)),0),d=t.changes.reduce(((e,t)=>e+s.elementCount(t.geometry)),0),m=Math.min((u+f-d)*a,T),p=m>c;m>I&&m<c/2?(t.changes.forEach((({id:e})=>n.deleteInstance(e))),n.instances.forEach((({geometry:e})=>l.push(e))),this._vaoCache.deleteVao(n.vao),e(h.buffers,n)):p?this._applyAndRebuild(n,l,t):this._applyRemoves(n,t)})),l.length>0)for(null==h&&(h=new C(n.origin),i.set(r,h)),h.buffers.forEach((e=>this._applyAdds(e,l)));l.length>0;)h.buffers.push(this._applyAndRebuild(new O,l,null))}))}_updateDrawCommands(){this._hasHighlights=!1,this._hasOccludees=!1,this._dataByOrigin.forEach((e=>{e.buffers.forEach((e=>{e.drawCommandsDirty&&(e.hasHiddenInstances=!1,e.hasHighlights=!1,e.hasOccludees=!1,r(e.instances,(t=>(e.updateDrawState(t),e.hasHiddenInstances&&e.hasHighlights&&e.hasOccludees))),e.updateDrawCommands(this._bufferWriter.vertexBufferLayout.stride)),this._hasHighlights=this._hasHighlights||e.hasHighlights,this._hasOccludees=this._hasOccludees||e.hasOccludees}))}))}_applyAndRebuild(e,t,r){if(null!=r)for(const d of r.changes)e.deleteInstance(d.id);const s=this._bufferWriter,i=s.vertexBufferLayout.stride,a=i/4,o=Math.floor(T/a);let n=e.numElements;for(;t.length>0;){const r=t.pop(),i=s.elementCount(r.geometry);if(n+i>o&&n>0){t.push(r);break}n+=i;const a=new b(r,0,0);g(null==e.instances.get(r.id)),e.addInstance(r.id,a)}const l=n*a,h=W(l),u=s.vertexBufferLayout.createView(h.buffer);let c=0;e.hasHiddenInstances=!1,e.hasHighlights=!1,e.hasOccludees=!1,e.instances.forEach(((t,r)=>{this._writeGeometry(t.geometry,u,c);const i=c;c+=s.elementCount(t.geometry.geometry),e.updateInstance(r,i,c),e.updateDrawState(t)})),this._vaoCache.deleteVao(e.vao),e.vao=this._vaoCache.newVao(V(l)),e.vao.vertexBuffers.geometry.setSubData(h,0,0,c*a),P(),e.holes.clear();const f=e.holes.pushNew();return f.from=c,f.to=Math.floor(e.vao.byteSize/i),e.updateDrawCommands(i),e}_applyRemoves(e,t){if(0===t.changes.length)return;for(const o of t.changes){const t=o.id,r=e.instances.get(t);if(!r)continue;e.deleteInstance(t);const s=j.back();if(s){if(s.to===r.from){s.to=r.to;continue}if(s.from===r.to){s.from=r.from;continue}}const i=j.pushNew();i.from=r.from,i.to=r.to}w(j);const r=this._bufferWriter.vertexBufferLayout.stride/4,s=j.reduce(((e,t)=>Math.max(e,t.numElements)),0)*r,i=W(s);i.fill(0,0,s);const a=e.vao.vertexBuffers.geometry;j.forAll((e=>a.setSubData(i,e.from*r,0,e.numElements*r))),P(),e.holes.pushArray(j.data,j.length),j.forAll(((e,t)=>j.data[t]=null)),j.clear(),e.drawCommandsDirty=!0}_applyAdds(e,r){if(0===r.length)return;if(!A(e))return void this._applyAndRebuild(e,r,null);const s=this._bufferWriter,i=s.vertexBufferLayout.stride/4,a=e.numElements,o=r.reduce(((e,t)=>e+s.elementCount(t.geometry)),0),n=Math.min((a+o)*i,T),l=4*n;if(e.vao.byteSize<V(T-I)&&l>e.vao.byteSize)return void this._applyAndRebuild(e,r,null);w(e.holes);const h=new Array;for(const t of r){const r=s.elementCount(t.geometry),i=E(e.holes,r);h.push(i)}const u=e.vao.vertexBuffers.geometry;let c=0,f=0,d=0;const m=W(n),p=s.vertexBufferLayout.createView(m.buffer);r.forEach(((t,r)=>{const a=h[r];if(null==a)return;if(!(d===a)){const e=d-f;e>0&&u.setSubData(m,f*i,0,e*i),f=a,c=0}const o=s.elementCount(t.geometry);this._writeGeometry(t,p,c),c+=o,d=a+o;const n=new b(t,a,a+o);g(null==e.instances.get(t.id)),e.addInstance(t.id,n),e.drawCommandsDirty=!0}));const y=d-f;y>0&&u.setSubData(m,f*i,0,y*i),t(r,((e,t)=>null==h[t])),P()}_writeGeometry(e,t,r){const s=e.localOrigin.vec3;p(S,-s[0],-s[1],-s[2]);const i=a(x,S,e.transformation);o(M,i),n(M,M),this._bufferWriter.write(i,M,e.geometry,t,r)}updateAnimation(e){return this.material.update(e)}requiresSlot(e,t){return this.material.requiresSlot(e,t)}prepareTechnique(e){const{output:t,bindParameters:r}=e;if(!this.requiresSlot(r.slot,t))return null;const s=t===u.Highlight||t===u.ShadowHighlight;if(s&&!this._hasHighlights)return null;const i=t===u.ShadowExcludeHighlight,a=!(s||i);this._appleAmdDriverHelper?.resetIndicesType();for(const o of this._dataByOrigin.values())for(const n of o.buffers){if(s&&!n.hasHighlights)continue;const o=(s?n.drawCommandsHighlight:i&&n.needsMultipleCommands()?n.drawCommandsShadowHighlightRest:n.drawCommandsDefault)||null,l=a&&n.drawCommandsOccludees||null;if(o?.length||l?.length){const s=this._glMaterials.load(e.rctx,r.slot,t),i=null!=s?s.beginSlot(r):null;if(null!=i)return i}}return null}render(e,t){const{output:r,bindParameters:s}=e,i=r===u.Highlight||r===u.ShadowHighlight,a=r===u.ShadowExcludeHighlight,o=!(i||a),n=this._rctx;this._appleAmdDriverHelper?.resetIndicesType(),n.bindTechnique(t,this.material.parameters,s);for(const l of this._dataByOrigin.values())for(const e of l.buffers){if(i&&!e.hasHighlights)continue;const r=(i?e.drawCommandsHighlight:a&&e.needsMultipleCommands()?e.drawCommandsShadowHighlightRest:e.drawCommandsDefault)||null,h=o&&e.drawCommandsOccludees||null;if(r?.length||h?.length){t.program.bindDraw(new y(l.origin),s,this.material.parameters),t.ensureAttributeLocations(e.vao),n.bindVAO(e.vao),r?.length&&(t.bindPipelineState(n,s.slot,!1),r.forAll((e=>n.drawArrays(t.primitiveType,e.first,e.count)))),h?.length&&(t.bindPipelineState(n,s.slot,!0),h.forAll((e=>n.drawArrays(t.primitiveType,e.first,e.count))))}}}get test(){return{material:this.material,glMaterials:this._glMaterials,dataByOrigin:this._dataByOrigin}}}class D{constructor(e){this.origin=e,this.changes=new Array}}function E(e,t){let r;if(!e.some((e=>!(e.numElements<t)&&(r=e,!0))))return null;const s=r.from;return r.from+=t,r.from>=r.to&&e.removeUnordered(r),s}const S=l(),x=l(),M=l(),j=new i({allocator:e=>e||new v,deallocator:null}),I=65536,R=4*I,L=16777216,T=L/4;let G=new Float32Array(I);function W(e){return G.length<e&&(G=new Float32Array(e)),G}function V(e){const t=4*e;return t<R?R:Math.max(Math.min(Math.ceil(1.5*t/R)*R,L),t)}function P(){G=new Float32Array(2)}export{B as MergedRenderer};
5
+ import{removeUnordered as e,filterInPlace as t}from"../../../../../core/arrayUtils.js";import{someMap as r}from"../../../../../core/MapUtils.js";import{NestedMap as s}from"../../../../../core/NestedMap.js";import i from"../../../../../core/PooledArray.js";import{m as a,a as o,t as n}from"../../../../../chunks/mat4.js";import{c as l}from"../../../../../chunks/mat4f64.js";import{glLayout as h}from"../../../support/buffer/glUtil.js";import{ShaderOutput as u}from"../../core/shaderLibrary/ShaderOutput.js";import{AppleAmdDriverHelper as c}from"../../lib/AppleAmdDriverHelper.js";import{GLMaterials as f}from"../../lib/GLMaterials.js";import{RenderOccludedFlag as d}from"../../lib/Material.js";import{DirtyState as m}from"../../lib/ModelDirtyTypes.js";import{assert as g,setMatrixTranslation3 as p}from"../../lib/Util.js";import{DrawParameters as y}from"../DrawParameters.js";import{WaterMaterial as _}from"../WaterMaterial.js";import{BufferRange as v,mergeAdjacentRanges as w}from"./BufferRange.js";import{Instance as b}from"./Instance.js";import{PerBufferData as O,hasVao as A}from"./PerBufferData.js";import{PerOriginData as C}from"./PerOriginData.js";import{VaoCache as H}from"./VaoCache.js";class B{constructor(e,t,r){this._rctx=e,this._materialRepository=t,this.material=r,this._dataByOrigin=new Map,this._appleAmdDriverHelper=null,this._hasHighlights=!1,this._hasOccludees=!1,this._glMaterials=new f(this.material,this._materialRepository),this._bufferWriter=r.createBufferWriter(),this._vaoCache=new H(e,r.vertexAttributeLocations,h(this._bufferWriter.vertexBufferLayout)),this._rctx.driverTest.drawArraysRequiresIndicesTypeReset.result&&(this._appleAmdDriverHelper=new c(this._rctx))}dispose(){this._glMaterials.destroy(),this._dataByOrigin.forEach((e=>e.dispose())),this._dataByOrigin.clear(),this._vaoCache.dispose(),this._appleAmdDriverHelper?.dispose()}get isEmpty(){return 0===this._dataByOrigin.size}get hasHighlights(){return this._hasHighlights}get hasOccludees(){return this._hasOccludees}get hasWater(){return!this.isEmpty&&this.material instanceof _}get rendersOccluded(){return!this.isEmpty&&this.material.renderOccluded!==d.Occlude}get numGeometries(){let e=0;return this._dataByOrigin.forEach((t=>e+=t.buffers.reduce(((e,t)=>e+t.instances.size),0))),e}forEachGeometry(e){this._dataByOrigin.forEach((t=>t.buffers.forEach((t=>t.instances.forEach((t=>e(t.geometry)))))))}modify(e){this._updateGeometries(e.updates),this._addAndRemoveGeometries(e.adds,e.removes),this._updateDrawCommands()}_updateGeometries(e){const t=this._bufferWriter,r=t.vertexBufferLayout.stride/4;for(const s of e){const e=s.renderGeometry,i=this._dataByOrigin.get(e.localOrigin.id),a=i?.findBuffer(e.id);if(null==a)return;const o=a.instances.get(e.id);if(s.updateType&(m.GEOMETRY|m.TRANSFORMATION)){const s=V(t.elementCount(o.geometry.geometry)*r),i=t.vertexBufferLayout.createView(s.buffer);this._writeGeometry(e,i,0),a.vao.vertexBuffers.geometry.setSubData(s,o.from*r,0,o.numElements*r),z()}s.updateType&(m.HIGHLIGHT|m.OCCLUDEE|m.VISIBILITY)&&(a.drawCommandsDirty=!0)}}_computeDeltas(e,t){const r=new s;for(const s of e){const e=s.localOrigin;if(null==e)continue;let t=r.get(e.id,null);null==t&&(t=new D(e.vec3),r.set(e.id,null,t)),t.changes.push(s)}for(const s of t){const e=s.localOrigin;if(null==e)continue;const t=this._dataByOrigin.get(e.id),i=t?.findBuffer(s.id);if(null==i)continue;let a=r.get(e.id,i);null==a&&(a=new D(e.vec3),r.set(e.id,i,a)),a.changes.push(s)}return r}_addAndRemoveGeometries(t,r){const{_bufferWriter:s,_dataByOrigin:i}=this,a=s.vertexBufferLayout.stride/4,o=this._computeDeltas(t,r);o.forEach(((t,r)=>{const n=t.get(null),l=null!=n?n.changes:[];o.delete(r,null);let h=i.get(r);if(t.forEach(((t,n)=>{if(o.delete(r,n),null==n)return void g(!1,"No VAO for removed geometries");if(n.instances.size===t.changes.length)return this._vaoCache.deleteVao(n.vao),e(h.buffers,n),void(0===h.buffers.length&&0===l.length&&i.delete(r));const u=n.numElements,c=n.vao.byteSize/4,f=l.reduce(((e,t)=>e+s.elementCount(t.geometry)),0),d=t.changes.reduce(((e,t)=>e+s.elementCount(t.geometry)),0),m=Math.min((u+f-d)*a,G),p=m>c;m>I&&m<c/2?(t.changes.forEach((({id:e})=>n.deleteInstance(e))),n.instances.forEach((({geometry:e})=>l.push(e))),this._vaoCache.deleteVao(n.vao),e(h.buffers,n)):p?this._applyAndRebuild(n,l,t):this._applyRemoves(n,t)})),l.length>0)for(null==h&&(h=new C(n.origin),i.set(r,h)),h.buffers.forEach((e=>this._applyAdds(e,l)));l.length>0;)h.buffers.push(this._applyAndRebuild(new O,l,null))}))}_updateDrawCommands(){this._hasHighlights=!1,this._hasOccludees=!1,this._dataByOrigin.forEach((e=>{e.buffers.forEach((e=>{e.drawCommandsDirty&&(e.hasHiddenInstances=!1,e.hasHighlights=!1,e.hasOccludees=!1,r(e.instances,(t=>(e.updateDrawState(t),e.hasHiddenInstances&&e.hasHighlights&&e.hasOccludees))),e.updateDrawCommands(this._bufferWriter.vertexBufferLayout.stride)),this._hasHighlights=this._hasHighlights||e.hasHighlights,this._hasOccludees=this._hasOccludees||e.hasOccludees}))}))}_applyAndRebuild(e,t,r){if(null!=r)for(const d of r.changes)e.deleteInstance(d.id);const s=this._bufferWriter,i=s.vertexBufferLayout.stride,a=i/4,o=Math.floor(G/a);let n=e.numElements;for(;t.length>0;){const r=t.pop(),i=s.elementCount(r.geometry);if(n+i>o&&n>0){t.push(r);break}n+=i;const a=new b(r,0,0);g(null==e.instances.get(r.id)),e.addInstance(r.id,a)}const l=n*a,h=V(l),u=s.vertexBufferLayout.createView(h.buffer);let c=0;e.hasHiddenInstances=!1,e.hasHighlights=!1,e.hasOccludees=!1,e.instances.forEach(((t,r)=>{this._writeGeometry(t.geometry,u,c);const i=c;c+=s.elementCount(t.geometry.geometry),e.updateInstance(r,i,c),e.updateDrawState(t)})),this._vaoCache.deleteVao(e.vao),e.vao=this._vaoCache.newVao(P(l)),e.vao.vertexBuffers.geometry.setSubData(h,0,0,c*a),z(),e.holes.clear();const f=e.holes.pushNew();return f.from=c,f.to=Math.floor(e.vao.byteSize/i),e.updateDrawCommands(i),e}_applyRemoves(e,t){if(0===t.changes.length)return;for(const o of t.changes){const t=o.id,r=e.instances.get(t);if(!r)continue;e.deleteInstance(t);const s=j.back();if(s){if(s.to===r.from){s.to=r.to;continue}if(s.from===r.to){s.from=r.from;continue}}const i=j.pushNew();i.from=r.from,i.to=r.to}w(j);const r=this._bufferWriter.vertexBufferLayout.stride/4,s=j.reduce(((e,t)=>Math.max(e,t.numElements)),0)*r,i=V(s);i.fill(0,0,s);const a=e.vao.vertexBuffers.geometry;j.forAll((e=>a.setSubData(i,e.from*r,0,e.numElements*r))),z(),e.holes.pushArray(j.data,j.length),j.forAll(((e,t)=>j.data[t]=null)),j.clear(),e.drawCommandsDirty=!0}_applyAdds(e,r){if(0===r.length)return;if(!A(e))return void this._applyAndRebuild(e,r,null);const s=this._bufferWriter,i=s.vertexBufferLayout.stride/4,a=e.numElements,o=r.reduce(((e,t)=>e+s.elementCount(t.geometry)),0),n=Math.min((a+o)*i,G),l=4*n;if(e.vao.byteSize<P(G-I)&&l>e.vao.byteSize)return void this._applyAndRebuild(e,r,null);w(e.holes);const h=new Array;for(const t of r){const r=s.elementCount(t.geometry),i=E(e.holes,r);h.push(i)}const u=e.vao.vertexBuffers.geometry;let c=0,f=0,d=0;const m=V(n),p=s.vertexBufferLayout.createView(m.buffer);r.forEach(((t,r)=>{const a=h[r];if(null==a)return;if(!(d===a)){const e=d-f;e>0&&u.setSubData(m,f*i,0,e*i),f=a,c=0}const o=s.elementCount(t.geometry);this._writeGeometry(t,p,c),c+=o,d=a+o;const n=new b(t,a,a+o);g(null==e.instances.get(t.id)),e.addInstance(t.id,n),e.drawCommandsDirty=!0}));const y=d-f;y>0&&u.setSubData(m,f*i,0,y*i),t(r,((e,t)=>null==h[t])),z()}_writeGeometry(e,t,r){const s=e.localOrigin.vec3;p(S,-s[0],-s[1],-s[2]);const i=a(x,S,e.transformation);o(M,i),n(M,M),this._bufferWriter.write(i,M,e.geometry,t,r)}updateAnimation(e){return this.material.update(e)}requiresSlot(e,t){return this.material.requiresSlot(e,t)}prepareTechnique(e){const{output:t,bindParameters:r}=e;if(!this.requiresSlot(r.slot,t))return null;const s=t===u.Highlight||t===u.ShadowHighlight;if(s&&!this._hasHighlights)return null;const i=t===u.ShadowExcludeHighlight,a=!(s||i);this._appleAmdDriverHelper?.resetIndicesType();for(const o of this._dataByOrigin.values())for(const n of o.buffers){if(s&&!n.hasHighlights)continue;const o=(s?n.drawCommandsHighlight:i&&n.needsMultipleCommands()?n.drawCommandsShadowHighlightRest:n.drawCommandsDefault)||null,l=a&&n.drawCommandsOccludees||null;if(o?.length||l?.length){const s=this._glMaterials.load(e.rctx,r.slot,t),i=null!=s?s.beginSlot(r):null;if(null!=i)return i}}return null}render(e,t){const{output:r,bindParameters:s}=e,i=r===u.Highlight||r===u.ShadowHighlight,a=r===u.ShadowExcludeHighlight,o=!(i||a),n=this._rctx;this._appleAmdDriverHelper?.resetIndicesType(),n.bindTechnique(t,this.material.parameters,s);for(const l of this._dataByOrigin.values())for(const e of l.buffers){if(i&&!e.hasHighlights)continue;const r=(i?e.drawCommandsHighlight:a&&e.needsMultipleCommands()?e.drawCommandsShadowHighlightRest:e.drawCommandsDefault)||null,h=o&&e.drawCommandsOccludees||null;if(r?.length||h?.length){t.program.bindDraw(new y(l.origin),s,this.material.parameters),t.ensureAttributeLocations(e.vao),n.bindVAO(e.vao),r?.length&&(t.bindPipelineState(n,s.slot,!1),r.forAll((e=>n.drawArrays(t.primitiveType,e.first,e.count)))),h?.length&&(t.bindPipelineState(n,s.slot,!0),h.forAll((e=>n.drawArrays(t.primitiveType,e.first,e.count))))}}}get test(){return{material:this.material,glMaterials:this._glMaterials,dataByOrigin:this._dataByOrigin}}}class D{constructor(e){this.origin=e,this.changes=new Array}}function E(e,t){let r;if(!e.some((e=>!(e.numElements<t)&&(r=e,!0))))return null;const s=r.from;return r.from+=t,r.from>=r.to&&e.removeUnordered(r),s}const S=l(),x=l(),M=l(),j=new i({allocator:e=>e||new v,deallocator:null}),I=65536,R=4*I,L=1024,T=16777216,G=T/4;let W=new Float32Array(I);function V(e){return W.length<e&&(W=new Float32Array(e)),W}function P(e){const t=4*e;return t<=L?L:t<R?R:Math.max(Math.min(Math.ceil(1.5*t/R)*R,T),t)}function z(){W=new Float32Array(2)}export{B as MergedRenderer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import"../../../../chunks/vec2.js";import"../../../../chunks/vec2f64.js";import"../../../../chunks/vec4f64.js";import"../../support/engineContent/sdfPrimitives.js";import"../core/shaderLibrary/ShaderOutput.js";import"../core/shaderLibrary/Slice.glsl.js";import"../core/shaderLibrary/attributes/ObjectAndLayerIdColor.glsl.js";import"../core/shaderLibrary/hud/AlignPixel.glsl.js";import"../core/shaderLibrary/hud/HUD.glsl.js";import"../core/shaderLibrary/hud/HUDOcclusionPass.glsl.js";import"../core/shaderLibrary/output/OutputHighlight.glsl.js";import"../core/shaderLibrary/shading/VisualVariables.glsl.js";import"../core/shaderLibrary/util/AlphaCutoff.js";import"../core/shaderLibrary/util/ColorConversion.glsl.js";import"../core/shaderLibrary/util/RgbaFloatEncoding.glsl.js";import"../core/shaderLibrary/util/ScreenSizePerspective.glsl.js";import"../core/shaderModules/Float2PassUniform.js";import"../core/shaderModules/Float4PassUniform.js";import"../core/shaderModules/FloatPassUniform.js";import"../core/shaderModules/interfaces.js";import"../core/shaderModules/ShaderBuilder.js";import"../core/shaderModules/Texture2DPassUniform.js";import"../lib/TransparencyPassType.js";import"../lib/VertexAttribute.js";export{b as build,c as calculateAnchorPosForRendering}from"../../../../chunks/HUDMaterial.glsl.js";
5
+ import"../../../../chunks/vec2.js";import"../../../../chunks/vec2f64.js";import"../../../../chunks/vec4f64.js";import"../../support/engineContent/sdfPrimitives.js";import"../core/shaderLibrary/ShaderOutput.js";import"../core/shaderLibrary/Slice.glsl.js";import"../core/shaderLibrary/attributes/ObjectAndLayerIdColor.glsl.js";import"../core/shaderLibrary/hud/AlignPixel.glsl.js";import"../core/shaderLibrary/hud/HUD.glsl.js";import"../core/shaderLibrary/hud/HUDOcclusionPass.glsl.js";import"../core/shaderLibrary/output/OutputHighlight.glsl.js";import"../core/shaderLibrary/shading/VisualVariables.glsl.js";import"../core/shaderLibrary/util/AlphaCutoff.js";import"../core/shaderLibrary/util/ColorConversion.glsl.js";import"../core/shaderLibrary/util/RgbaFloatEncoding.glsl.js";import"../core/shaderLibrary/util/ScreenSizePerspective.glsl.js";import"../core/shaderLibrary/util/View.glsl.js";import"../core/shaderModules/Float2PassUniform.js";import"../core/shaderModules/Float4PassUniform.js";import"../core/shaderModules/FloatPassUniform.js";import"../core/shaderModules/interfaces.js";import"../core/shaderModules/ShaderBuilder.js";import"../core/shaderModules/Texture2DPassUniform.js";import"../lib/TransparencyPassType.js";import"../lib/VertexAttribute.js";export{b as build,c as calculateAnchorPosForRendering}from"../../../../chunks/HUDMaterial.glsl.js";
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import{ShaderOutput as o}from"../core/shaderLibrary/ShaderOutput.js";import{HUDSpace as t}from"../core/shaderLibrary/hud/HUD.glsl.js";import{parameter as i}from"../core/shaderTechnique/ShaderTechniqueConfiguration.js";import{TransparencyPassType as s}from"../lib/TransparencyPassType.js";import{DefaultTechniqueConfiguration as r}from"../materials/DefaultTechniqueConfiguration.js";class a extends r{constructor(){super(...arguments),this.output=o.Color,this.screenCenterOffsetUnitsEnabled=t.World,this.transparencyPassType=s.NONE,this.spherical=!1,this.occlusionTestEnabled=!0,this.signedDistanceFieldEnabled=!1,this.vvSize=!1,this.vvColor=!1,this.hasVerticalOffset=!1,this.hasScreenSizePerspective=!1,this.debugDrawLabelBorder=!1,this.binaryHighlightOcclusionEnabled=!0,this.hasSlicePlane=!1,this.hasPolygonOffset=!1,this.depthEnabled=!0,this.pixelSnappingEnabled=!0,this.isDraped=!1,this.hasMultipassGeometry=!1,this.hasMultipassTerrain=!1,this.cullAboveGround=!1,this.occlusionPass=!1,this.objectAndLayerIdColorInstanced=!1}}e([i({count:o.COUNT})],a.prototype,"output",void 0),e([i({count:t.COUNT})],a.prototype,"screenCenterOffsetUnitsEnabled",void 0),e([i({count:s.COUNT})],a.prototype,"transparencyPassType",void 0),e([i()],a.prototype,"spherical",void 0),e([i()],a.prototype,"occlusionTestEnabled",void 0),e([i()],a.prototype,"signedDistanceFieldEnabled",void 0),e([i()],a.prototype,"vvSize",void 0),e([i()],a.prototype,"vvColor",void 0),e([i()],a.prototype,"hasVerticalOffset",void 0),e([i()],a.prototype,"hasScreenSizePerspective",void 0),e([i()],a.prototype,"debugDrawLabelBorder",void 0),e([i()],a.prototype,"binaryHighlightOcclusionEnabled",void 0),e([i()],a.prototype,"hasSlicePlane",void 0),e([i()],a.prototype,"hasPolygonOffset",void 0),e([i()],a.prototype,"depthEnabled",void 0),e([i()],a.prototype,"pixelSnappingEnabled",void 0),e([i()],a.prototype,"isDraped",void 0),e([i()],a.prototype,"hasMultipassGeometry",void 0),e([i()],a.prototype,"hasMultipassTerrain",void 0),e([i()],a.prototype,"cullAboveGround",void 0),e([i()],a.prototype,"occlusionPass",void 0),e([i()],a.prototype,"objectAndLayerIdColorInstanced",void 0),e([i({constValue:!0})],a.prototype,"hasSliceInVertexProgram",void 0),e([i({constValue:!1})],a.prototype,"hasVvInstancing",void 0);export{a as HUDMaterialTechniqueConfiguration};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import{ShaderOutput as o}from"../core/shaderLibrary/ShaderOutput.js";import{HUDSpace as t}from"../core/shaderLibrary/hud/HUD.glsl.js";import{parameter as i}from"../core/shaderTechnique/ShaderTechniqueConfiguration.js";import{TransparencyPassType as s}from"../lib/TransparencyPassType.js";import{DefaultTechniqueConfiguration as r}from"../materials/DefaultTechniqueConfiguration.js";class a extends r{constructor(){super(...arguments),this.output=o.Color,this.screenCenterOffsetUnitsEnabled=t.World,this.transparencyPassType=s.NONE,this.spherical=!1,this.occlusionTestEnabled=!0,this.signedDistanceFieldEnabled=!1,this.vvSize=!1,this.vvColor=!1,this.hasVerticalOffset=!1,this.hasScreenSizePerspective=!1,this.debugDrawLabelBorder=!1,this.binaryHighlightOcclusionEnabled=!0,this.hasSlicePlane=!1,this.hasPolygonOffset=!1,this.depthEnabled=!0,this.pixelSnappingEnabled=!0,this.draped=!1,this.hasMultipassGeometry=!1,this.hasMultipassTerrain=!1,this.cullAboveGround=!1,this.occlusionPass=!1,this.objectAndLayerIdColorInstanced=!1}}e([i({count:o.COUNT})],a.prototype,"output",void 0),e([i({count:t.COUNT})],a.prototype,"screenCenterOffsetUnitsEnabled",void 0),e([i({count:s.COUNT})],a.prototype,"transparencyPassType",void 0),e([i()],a.prototype,"spherical",void 0),e([i()],a.prototype,"occlusionTestEnabled",void 0),e([i()],a.prototype,"signedDistanceFieldEnabled",void 0),e([i()],a.prototype,"vvSize",void 0),e([i()],a.prototype,"vvColor",void 0),e([i()],a.prototype,"hasVerticalOffset",void 0),e([i()],a.prototype,"hasScreenSizePerspective",void 0),e([i()],a.prototype,"debugDrawLabelBorder",void 0),e([i()],a.prototype,"binaryHighlightOcclusionEnabled",void 0),e([i()],a.prototype,"hasSlicePlane",void 0),e([i()],a.prototype,"hasPolygonOffset",void 0),e([i()],a.prototype,"depthEnabled",void 0),e([i()],a.prototype,"pixelSnappingEnabled",void 0),e([i()],a.prototype,"draped",void 0),e([i()],a.prototype,"hasMultipassGeometry",void 0),e([i()],a.prototype,"hasMultipassTerrain",void 0),e([i()],a.prototype,"cullAboveGround",void 0),e([i()],a.prototype,"occlusionPass",void 0),e([i()],a.prototype,"objectAndLayerIdColorInstanced",void 0),e([i({constValue:!0})],a.prototype,"hasSliceInVertexProgram",void 0),e([i({constValue:!1})],a.prototype,"hasVvInstancing",void 0);export{a as HUDMaterialTechniqueConfiguration};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import"../core/shaderLibrary/util/View.glsl.js";import"../core/shaderModules/FloatPassUniform.js";import"../core/shaderModules/interfaces.js";import"../core/shaderModules/ShaderBuilder.js";import"../lib/VertexAttribute.js";export{b as build}from"../../../../chunks/HeatmapDensity.glsl.js";
5
+ import"../../terrain/Overlay.js";import"../core/shaderLibrary/util/View.glsl.js";import"../core/shaderModules/FloatPassUniform.js";import"../core/shaderModules/interfaces.js";import"../core/shaderModules/ShaderBuilder.js";import"../lib/VertexAttribute.js";export{b as build}from"../../../../chunks/HeatmapDensity.glsl.js";
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import{HUDSpace as t}from"../core/shaderLibrary/hud/HUD.glsl.js";import{parameter as o}from"../core/shaderTechnique/ShaderTechniqueConfiguration.js";import{DefaultTechniqueConfiguration as s}from"../materials/DefaultTechniqueConfiguration.js";class i extends s{constructor(){super(...arguments),this.screenCenterOffsetUnitsEnabled=t.World,this.spherical=!1,this.occlusionTestEnabled=!0,this.hasVerticalOffset=!1,this.hasScreenSizePerspective=!1,this.depthHudEnabled=!1,this.depthHudAlignStartEnabled=!1,this.hasSlicePlane=!1,this.hasMultipassGeometry=!1}}e([o({count:t.COUNT})],i.prototype,"screenCenterOffsetUnitsEnabled",void 0),e([o()],i.prototype,"spherical",void 0),e([o()],i.prototype,"occlusionTestEnabled",void 0),e([o()],i.prototype,"hasVerticalOffset",void 0),e([o()],i.prototype,"hasScreenSizePerspective",void 0),e([o()],i.prototype,"depthHudEnabled",void 0),e([o()],i.prototype,"depthHudAlignStartEnabled",void 0),e([o()],i.prototype,"hasSlicePlane",void 0),e([o()],i.prototype,"hasMultipassGeometry",void 0),e([o({constValue:!0})],i.prototype,"hasSliceInVertexProgram",void 0),e([o({constValue:!1})],i.prototype,"isDraped",void 0);export{i as LineCalloutTechniqueConfiguration};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import{HUDSpace as t}from"../core/shaderLibrary/hud/HUD.glsl.js";import{parameter as o}from"../core/shaderTechnique/ShaderTechniqueConfiguration.js";import{DefaultTechniqueConfiguration as s}from"../materials/DefaultTechniqueConfiguration.js";class r extends s{constructor(){super(...arguments),this.screenCenterOffsetUnitsEnabled=t.World,this.spherical=!1,this.occlusionTestEnabled=!0,this.hasVerticalOffset=!1,this.hasScreenSizePerspective=!1,this.depthHudEnabled=!1,this.depthHudAlignStartEnabled=!1,this.hasSlicePlane=!1,this.hasMultipassGeometry=!1}}e([o({count:t.COUNT})],r.prototype,"screenCenterOffsetUnitsEnabled",void 0),e([o()],r.prototype,"spherical",void 0),e([o()],r.prototype,"occlusionTestEnabled",void 0),e([o()],r.prototype,"hasVerticalOffset",void 0),e([o()],r.prototype,"hasScreenSizePerspective",void 0),e([o()],r.prototype,"depthHudEnabled",void 0),e([o()],r.prototype,"depthHudAlignStartEnabled",void 0),e([o()],r.prototype,"hasSlicePlane",void 0),e([o()],r.prototype,"hasMultipassGeometry",void 0),e([o({constValue:!0})],r.prototype,"hasSliceInVertexProgram",void 0),e([o({constValue:!1})],r.prototype,"draped",void 0);export{r as LineCalloutTechniqueConfiguration};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as o}from"../../../../chunks/tslib.es6.js";import{ShaderOutput as t}from"../core/shaderLibrary/ShaderOutput.js";import{parameter as e}from"../core/shaderTechnique/ShaderTechniqueConfiguration.js";import{TransparencyPassType as r}from"../lib/TransparencyPassType.js";import{DefaultTechniqueConfiguration as i}from"../materials/DefaultTechniqueConfiguration.js";var p,s;!function(o){o[o.Draped=0]="Draped",o[o.Screen=1]="Screen",o[o.World=2]="World",o[o.COUNT=3]="COUNT"}(p||(p={})),function(o){o[o.Center=0]="Center",o[o.Tip=1]="Tip",o[o.COUNT=2]="COUNT"}(s||(s={}));class a extends i{constructor(){super(...arguments),this.output=t.Color,this.transparencyPassType=r.NONE,this.occluder=!1,this.hasSlicePlane=!1,this.writeDepth=!1,this.space=p.Screen,this.hideOnShortSegments=!1,this.hasCap=!1,this.anchor=s.Center,this.hasTip=!1,this.vvSize=!1,this.vvColor=!1,this.vvOpacity=!1,this.hasOccludees=!1,this.hasMultipassTerrain=!1,this.cullAboveGround=!1}}o([e({count:t.COUNT})],a.prototype,"output",void 0),o([e({count:r.COUNT})],a.prototype,"transparencyPassType",void 0),o([e()],a.prototype,"occluder",void 0),o([e()],a.prototype,"hasSlicePlane",void 0),o([e()],a.prototype,"writeDepth",void 0),o([e({count:p.COUNT})],a.prototype,"space",void 0),o([e()],a.prototype,"hideOnShortSegments",void 0),o([e()],a.prototype,"hasCap",void 0),o([e({count:s.COUNT})],a.prototype,"anchor",void 0),o([e()],a.prototype,"hasTip",void 0),o([e()],a.prototype,"vvSize",void 0),o([e()],a.prototype,"vvColor",void 0),o([e()],a.prototype,"vvOpacity",void 0),o([e()],a.prototype,"hasOccludees",void 0),o([e()],a.prototype,"hasMultipassTerrain",void 0),o([e()],a.prototype,"cullAboveGround",void 0),o([e({constValue:!0})],a.prototype,"hasVvInstancing",void 0),o([e({constValue:!0})],a.prototype,"hasSliceTranslatedView",void 0);export{s as LineMarkerAnchor,p as LineMarkerSpace,a as LineMarkerTechniqueConfiguration};
5
+ import{_ as t}from"../../../../chunks/tslib.es6.js";import{ShaderOutput as o}from"../core/shaderLibrary/ShaderOutput.js";import{parameter as e}from"../core/shaderTechnique/ShaderTechniqueConfiguration.js";import{TransparencyPassType as r}from"../lib/TransparencyPassType.js";import{DefaultTechniqueConfiguration as i}from"../materials/DefaultTechniqueConfiguration.js";var p,s;!function(t){t[t.Draped=0]="Draped",t[t.Screen=1]="Screen",t[t.World=2]="World",t[t.COUNT=3]="COUNT"}(p||(p={})),function(t){t[t.Center=0]="Center",t[t.Tip=1]="Tip",t[t.COUNT=2]="COUNT"}(s||(s={}));class a extends i{constructor(){super(...arguments),this.output=o.Color,this.transparencyPassType=r.NONE,this.occluder=!1,this.hasSlicePlane=!1,this.writeDepth=!1,this.space=p.Screen,this.hideOnShortSegments=!1,this.hasCap=!1,this.anchor=s.Center,this.hasTip=!1,this.vvSize=!1,this.vvColor=!1,this.vvOpacity=!1,this.hasOccludees=!1,this.hasMultipassTerrain=!1,this.cullAboveGround=!1}get draped(){return this.space===p.Draped}}t([e({count:o.COUNT})],a.prototype,"output",void 0),t([e({count:r.COUNT})],a.prototype,"transparencyPassType",void 0),t([e()],a.prototype,"occluder",void 0),t([e()],a.prototype,"hasSlicePlane",void 0),t([e()],a.prototype,"writeDepth",void 0),t([e({count:p.COUNT})],a.prototype,"space",void 0),t([e()],a.prototype,"hideOnShortSegments",void 0),t([e()],a.prototype,"hasCap",void 0),t([e({count:s.COUNT})],a.prototype,"anchor",void 0),t([e()],a.prototype,"hasTip",void 0),t([e()],a.prototype,"vvSize",void 0),t([e()],a.prototype,"vvColor",void 0),t([e()],a.prototype,"vvOpacity",void 0),t([e()],a.prototype,"hasOccludees",void 0),t([e()],a.prototype,"hasMultipassTerrain",void 0),t([e()],a.prototype,"cullAboveGround",void 0),t([e({constValue:!0})],a.prototype,"hasVvInstancing",void 0),t([e({constValue:!0})],a.prototype,"hasSliceTranslatedView",void 0);export{s as LineMarkerAnchor,p as LineMarkerSpace,a as LineMarkerTechniqueConfiguration};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import{byId as t,reparent as s,empty as i}from"../core/domUtils.js";import r from"../core/Logger.js";import{destroyMaybe as o,removeMaybe as n}from"../core/maybe.js";import{watch as a,initial as d}from"../core/reactiveUtils.js";import{addFrameTask as h}from"../core/scheduling.js";import{property as l}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as u}from"../core/accessorSupport/decorators/subclass.js";import c from"./overlay/ViewOverlay.js";const p=[0,0];function m(e){const t=(e.ownerDocument||window.document).defaultView,s=e.getBoundingClientRect();return p[0]=s.left+(t?.pageXOffset??0),p[1]=s.top+(t?.pageYOffset??0),p}function f(e){e&&(i(e),e.parentNode&&e.parentNode.removeChild(e))}function y(e){const t=document.createElement("div");return e.appendChild(t),t}const v=16,g=750,_=512,w=2,C=i=>{let p=class extends i{constructor(...e){super(...e),this._freqInfo={freq:v,time:g},this._overlayRenderTaskHandle=null,this.height=0,this.overlay=null,this.position=null,this.resizing=!1,this.root=null,this.surface=null,this.suspended=!0,this.ui=null,this.userContent=null,this.width=0,this.widthBreakpoint=null,this.addHandles([a((()=>this.cursor),(e=>{const{surface:t}=this;t&&t.setAttribute("data-cursor",e)})),a((()=>this.navigating),(e=>{const{surface:t}=this;t&&t.setAttribute("data-navigating",e.toString())}))])}initialize(){this.addHandles([a((()=>this.ui),((e,t)=>this._handleUIChange(e,t)),d),this.on("focus",(()=>this.notifyChange("focused"))),this.on("blur",(()=>this.notifyChange("focused")))])}destroy(){this.destroyed||(this.ui=o(this.ui),this.container=null)}get container(){return this._get("container")??null}set container(e){const i=this._get("container"),o=t(e);if(o||"string"!=typeof e||r.getLogger(this).error("#container",`element with id '${e}' not found`),i===o)return;const l="dom-size";if(this.removeHandles(l),this._stopMeasuring(),i&&(i.classList.remove("esri-view"),this._overlayRenderTaskHandle&&(this._overlayRenderTaskHandle.remove(),this._overlayRenderTaskHandle=null),this.overlay&&(this.overlay.destroy(),this._set("overlay",null)),this.root&&(f(this.root),this._set("root",null)),this.userContent&&(s(this.userContent,i),f(this.userContent),this._set("userContent",null))),!o)return this._set("width",0),this._set("height",0),this._set("position",null),this._set("suspended",!0),this._set("surface",null),void this._set("container",null);o.classList.add("esri-view");const u=document.createElement("div");u.className="esri-view-user-storage",s(o,u),o.appendChild(u),this._set("userContent",u);const p=document.createElement("div");p.className="esri-view-root",o.insertBefore(p,o.firstChild),this._set("root",p);const m=document.createElement("div");m.className="esri-view-surface",m.setAttribute("role","application"),m.tabIndex=0,p.appendChild(m),this._set("surface",m);const y=new c;p.appendChild(y.surface),this._set("overlay",y),this.addHandles(a((()=>y.needsRender),(e=>{e&&!this._overlayRenderTaskHandle?this._overlayRenderTaskHandle=h({render:()=>this.overlay?.render()}):this._overlayRenderTaskHandle=n(this._overlayRenderTaskHandle)}))),this.forceDOMReadyCycle(),this.addHandles(a((()=>this.size),(e=>{const[t,s]=e,i="esri-view-surface--inset-outline";t>=document.body.clientWidth||s>=document.body.clientHeight?m.classList.add(i):m.classList.remove(i)}),d),l),this._set("container",o),this._startMeasuring()}get focused(){const e=document.activeElement===this.surface;return document.hasFocus()&&e}get size(){return[this.width,this.height]}blur(){this.surface&&this.surface.blur()}focus(){this.surface&&this.surface.focus()}pageToContainer(e,t,s){const i=this.position;return e-=i?i[0]:0,t-=i?i[1]:0,s?(s[0]=e,s[1]=t):s=[e,t],s}containerToPage(e,t,s){const i=this.position;return e+=i?i[0]:0,t+=i?i[1]:0,s?(s[0]=e,s[1]=t):s=[e,t],s}_handleUIChange(e,t){this.removeHandles("ui"),t&&t!==e&&t.destroy(),e&&(e.view=this,this.addHandles(a((()=>this.root),(t=>{e.container=t?y(t):null}),d),"ui")),this._set("ui",e)}_stopMeasuring(){this.removeHandles("measuring"),this._get("resizing")&&this._set("resizing",!1)}_startMeasuring(){const e=this._freqInfo;e.freq=v,e.time=g,this.addHandles([(()=>{const t=()=>{e.freq=v,e.time=g};return window.addEventListener("resize",t),{remove(){window.removeEventListener("resize",t)}}})(),h({prepare:e=>{const t=this._measure(),s=this._freqInfo;if(s.time+=e.deltaTime,t&&(s.freq=v,this._get("resizing")||this._set("resizing",!0)),s.time<s.freq)return;s.time=0;const i=this._position();s.freq=i||t?v:Math.min(g,s.freq*w),!t&&s.freq>=_&&this._get("resizing")&&this._set("resizing",!1)}})],"measuring"),this._measure(),this._position()}_measure(){const e=this.container,t=e?e.clientWidth:0,s=e?e.clientHeight:0;if(0===t||0===s)return this.suspended||this._set("suspended",!0),!1;const i=this.width,r=this.height;return t===i&&s===r?(this.suspended&&this._set("suspended",!1),!1):(this._set("width",t),this._set("height",s),this.suspended&&this._set("suspended",!1),this.emit("resize",{oldWidth:i,oldHeight:r,width:t,height:s}),!0)}_position(){const e=this.container,t=this.position,s=e&&m(e);return!!s&&((!t||s[0]!==t[0]||s[1]!==t[1])&&(this._set("position",[s[0],s[1]]),!0))}forceDOMReadyCycle(){}};return e([l()],p.prototype,"container",null),e([l({readOnly:!0})],p.prototype,"focused",null),e([l({readOnly:!0})],p.prototype,"height",void 0),e([l({type:c})],p.prototype,"overlay",void 0),e([l({readOnly:!0})],p.prototype,"position",void 0),e([l({readOnly:!0})],p.prototype,"resizing",void 0),e([l({readOnly:!0})],p.prototype,"root",void 0),e([l({value:null,readOnly:!0})],p.prototype,"size",null),e([l({readOnly:!0})],p.prototype,"surface",void 0),e([l({readOnly:!0})],p.prototype,"suspended",void 0),e([l()],p.prototype,"ui",void 0),e([l({readOnly:!0})],p.prototype,"userContent",void 0),e([l({readOnly:!0})],p.prototype,"width",void 0),e([l()],p.prototype,"widthBreakpoint",void 0),p=e([u("esri.views.DOMContainer")],p),p};export{C as DOMContainer};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import{byId as t,reparent as s,empty as i}from"../core/domUtils.js";import r from"../core/Logger.js";import{destroyMaybe as o,removeMaybe as n}from"../core/maybe.js";import{watch as a,initial as d}from"../core/reactiveUtils.js";import{addFrameTask as h}from"../core/scheduling.js";import{property as l}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as u}from"../core/accessorSupport/decorators/subclass.js";import c from"./overlay/ViewOverlay.js";const p=[0,0];function m(e){const t=(e.ownerDocument||window.document).defaultView,s=e.getBoundingClientRect();return p[0]=s.left+(t?.pageXOffset??0),p[1]=s.top+(t?.pageYOffset??0),p}function f(e){e&&(i(e),e.parentNode&&e.parentNode.removeChild(e))}function y(e){const t=document.createElement("div");return e.appendChild(t),t}const v=16,g=750,_=512,w=2,C=i=>{let p=class extends i{constructor(...e){super(...e),this._freqInfo={freq:v,time:g},this._overlayRenderTaskHandle=null,this.height=0,this.overlay=null,this.position=null,this.resizing=!1,this.root=null,this.surface=null,this.suspended=!0,this.ui=null,this.userContent=null,this.width=0,this.widthBreakpoint=null,this.addHandles([a((()=>this.cursor),(e=>{const{surface:t}=this;t&&t.setAttribute("data-cursor",e)})),a((()=>this.navigating),(e=>{const{surface:t}=this;t&&t.setAttribute("data-navigating",e.toString())}))])}initialize(){this.addHandles([a((()=>this.ui),((e,t)=>this._handleUIChange(e,t)),d),this.on("focus",(()=>this.notifyChange("focused"))),this.on("blur",(()=>this.notifyChange("focused")))])}destroy(){this.destroyed||(this.ui=o(this.ui),this.container=null)}get container(){return this._get("container")??null}set container(e){const i=this._get("container"),o=t(e);if(o||"string"!=typeof e||r.getLogger(this).error("#container",`element with id '${e}' not found`),i===o)return;const l="dom-size";if(this.removeHandles(l),this._stopMeasuring(),i&&(i.classList.remove("esri-view"),this._overlayRenderTaskHandle&&(this._overlayRenderTaskHandle.remove(),this._overlayRenderTaskHandle=null),this.overlay&&(this.overlay.destroy(),this._set("overlay",null)),this.root&&(f(this.root),this._set("root",null)),this.userContent&&(s(this.userContent,i),f(this.userContent),this._set("userContent",null))),!o)return this._set("width",0),this._set("height",0),this._set("position",null),this._set("suspended",!0),this._set("surface",null),void this._set("container",null);o.classList.add("esri-view");const u=document.createElement("div");u.className="esri-view-user-storage",s(o,u),o.appendChild(u),this._set("userContent",u);const p=document.createElement("div");p.className="esri-view-root",o.insertBefore(p,o.firstChild),this._set("root",p);const m=document.createElement("div");m.className="esri-view-surface",m.setAttribute("role","application"),m.tabIndex=0,p.appendChild(m),this._set("surface",m);const y=new c;p.appendChild(y.surface),this._set("overlay",y),this.addHandles(a((()=>y.needsRender),(e=>{e&&!this._overlayRenderTaskHandle?this._overlayRenderTaskHandle=h({render:()=>this.overlay?.render()}):this._overlayRenderTaskHandle=n(this._overlayRenderTaskHandle)}))),this.forceDOMReadyCycle(),this.addHandles(a((()=>this.size),(e=>{const[t,s]=e,i="esri-view-surface--inset-outline";t>=document.body.clientWidth||s>=document.body.clientHeight?m.classList.add(i):m.classList.remove(i)}),d),l),this._set("container",o),this._startMeasuring()}get focused(){const e=document.activeElement===this.surface;return document.hasFocus()&&e}get size(){return[this.width,this.height]}blur(){this.surface?.blur()}focus(){this.surface?.focus()}pageToContainer(e,t,s){const i=this.position;return e-=i?i[0]:0,t-=i?i[1]:0,s?(s[0]=e,s[1]=t):s=[e,t],s}containerToPage(e,t,s){const i=this.position;return e+=i?i[0]:0,t+=i?i[1]:0,s?(s[0]=e,s[1]=t):s=[e,t],s}_handleUIChange(e,t){this.removeHandles("ui"),t&&t!==e&&t.destroy(),e&&(e.view=this,this.addHandles(a((()=>this.root),(t=>{e.container=t?y(t):null}),d),"ui")),this._set("ui",e)}_stopMeasuring(){this.removeHandles("measuring"),this._get("resizing")&&this._set("resizing",!1)}_startMeasuring(){const e=this._freqInfo;e.freq=v,e.time=g,this.addHandles([(()=>{const t=()=>{e.freq=v,e.time=g};return window.addEventListener("resize",t),{remove(){window.removeEventListener("resize",t)}}})(),h({prepare:e=>{const t=this._measure(),s=this._freqInfo;if(s.time+=e.deltaTime,t&&(s.freq=v,this._get("resizing")||this._set("resizing",!0)),s.time<s.freq)return;s.time=0;const i=this._position();s.freq=i||t?v:Math.min(g,s.freq*w),!t&&s.freq>=_&&this._get("resizing")&&this._set("resizing",!1)}})],"measuring"),this._measure(),this._position()}_measure(){const e=this.container,t=e?e.clientWidth:0,s=e?e.clientHeight:0;if(0===t||0===s)return this.suspended||this._set("suspended",!0),!1;const i=this.width,r=this.height;return t===i&&s===r?(this.suspended&&this._set("suspended",!1),!1):(this._set("width",t),this._set("height",s),this.suspended&&this._set("suspended",!1),this.emit("resize",{oldWidth:i,oldHeight:r,width:t,height:s}),!0)}_position(){const e=this.container,t=this.position,s=e&&m(e);return!!s&&((!t||s[0]!==t[0]||s[1]!==t[1])&&(this._set("position",[s[0],s[1]]),!0))}forceDOMReadyCycle(){}};return e([l()],p.prototype,"container",null),e([l({readOnly:!0})],p.prototype,"focused",null),e([l({readOnly:!0})],p.prototype,"height",void 0),e([l({type:c})],p.prototype,"overlay",void 0),e([l({readOnly:!0})],p.prototype,"position",void 0),e([l({readOnly:!0})],p.prototype,"resizing",void 0),e([l({readOnly:!0})],p.prototype,"root",void 0),e([l({value:null,readOnly:!0})],p.prototype,"size",null),e([l({readOnly:!0})],p.prototype,"surface",void 0),e([l({readOnly:!0})],p.prototype,"suspended",void 0),e([l()],p.prototype,"ui",void 0),e([l({readOnly:!0})],p.prototype,"userContent",void 0),e([l({readOnly:!0})],p.prototype,"width",void 0),e([l()],p.prototype,"widthBreakpoint",void 0),p=e([u("esri.views.DOMContainer")],p),p};export{C as DOMContainer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import{createTask as p}from"../core/asyncUtils.js";import{deprecated as t}from"../core/deprecate.js";import i from"../core/Error.js";import s from"../core/Logger.js";import{eachAlwaysValues as o,throwIfAborted as r}from"../core/promiseUtils.js";import{watch as a,initial as n,whenOnce as u}from"../core/reactiveUtils.js";import{property as l}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as c}from"../core/accessorSupport/decorators/subclass.js";import{ViewEventPriorities as h}from"./input/InputManager.js";function d(e){return null!=e&&"open"in e&&"declaredClass"in e}function y(e){return null!=e&&"declaredClass"in e&&"dockOptions"in e}const w=w=>{let m=class extends w{constructor(){super(...arguments),this._popupSetupTask=null,this.popup={},this.popupEnabled=!0}initialize(){this.addHandles([a((()=>[this.ui,this.popup]),(([e,p],t)=>{const i="popup",s="manual";if(t){const[e,p]=t;e&&d(p)&&(p.view=null,y(p)&&e.remove(p,i))}e&&d(p)&&(p.view=this,y(p)&&e.add(p,{key:i,position:s}))}),n),this.on("click",(e=>{if(!this.popup||!this.popupEnabled||"mouse"===e.pointerType&&0!==e.button)return;const p="autoOpenEnabled"in this.popup&&!1===this.popup.autoOpenEnabled;!d(this.popup)&&p||(d(this.popup)?this.popup.viewModel.handleViewClick(e):e.async((async()=>{await this.setupPopup(),d(this.popup)&&!this.destroyed&&this.ready&&this.popupEnabled&&this.popup.viewModel.handleViewClick(e)})))}),h.WIDGET)]),u((()=>this.ready&&this.popupEnabled&&!this.updating)).then((()=>{import("../widgets/Popup.js")}))}destroy(){this.destroyed||this.closePopup()}async openPopup(e){d(this.popup)&&this.popup.open(e);try{if(await this.setupPopup(),!this.popup)return void s.getLogger(this).error(new i("view:null-popup","Popup is null and can't be opened"));this.popup.open(e)}catch{}}closePopup(){this._popupSetupTask?.abort(),d(this.popup)&&this.popup.close()}async fetchPopupFeatures(e,p){await this.when();const{location:t,queryArea:i,layerViewsAndGraphics:s,clientOnlyGraphics:r}=await this._prepareFetchPopupFeatures(e,p),a=Promise.resolve(r),n=this._queryLayerPopupFeatures(i,s,p),u=n.map((e=>e.promise));return{location:t,clientOnlyGraphics:r,allGraphicsPromise:o([a,...u]).then((e=>Array.from(new Set(e.flat())))),promisesPerLayerView:n}}async setupPopup(){if(this._popupSetupTask?.abort(),this.popup&&!d(this.popup))return this._popupSetupTask=p((async e=>{const{default:p}=await import("../widgets/Popup.js");if(r(e),!this.popup||d(this.popup))return;const t=this.popup;delete t.open,delete t.close,this.popup=new p(t)})),this._popupSetupTask.promise}_queryLayerPopupFeatures(e,p,t){return p.map((({layerView:p,graphics:i})=>{const s={clientGraphics:i,event:null!=t?t.event:void 0,signal:null!=t?t.signal:void 0,defaultPopupTemplateEnabled:null!=t&&!!t.defaultPopupTemplateEnabled},o=p.fetchPopupFeatures(e,s);return{layerView:p,promise:o}}))}_isValidPopupGraphic(e,p){return e&&!!e.getEffectivePopupTemplate(null!=p&&p.defaultPopupTemplateEnabled)}async _prepareFetchPopupFeatures(e,p){const{clientGraphics:t,queryArea:i,location:s}=await this._popupHitTestGraphics(e,p),o=this._getFetchPopupLayerViews(),{layerViewsAndGraphics:r,clientOnlyGraphics:a}=this._graphicsPerFetchPopupLayerView(t,o);return{clientOnlyGraphics:a,layerViewsAndGraphics:r,queryArea:i,location:s}}async _popupHitTestGraphics(e,p){const t=await this.popupHitTest(e),i=t.results,s=t.mapPoint,o=i.filter((e=>"graphic"===e.type&&this._isValidPopupGraphic(e.graphic,p))),r=o.length?o[0].mapPoint:null;return{clientGraphics:o.map((e=>e.graphic)),queryArea:s,location:s||r}}_getFetchPopupLayerViews(){const e=[];return this.allLayerViews.forEach((p=>{this._isValidPopupLayerView(p)&&e.push(p)})),null!=this.graphicsView&&this._isValidPopupLayerView(this.graphicsView)&&e.push(this.graphicsView),e.reverse()}_isValidPopupLayerView(e){return null!=e&&(!("layer"in e)||!e.suspended)&&"fetchPopupFeatures"in e}_graphicsPerFetchPopupLayerView(e,p){const t=[],i=new Map,s=p.map((e=>{const p=[];return"layer"in e?i.set(e.layer,p):i.set(e.graphics,p),{layerView:e,graphics:p}}));for(const o of e){const e=i.get(o.layer)||i.get(o.sourceLayer)||null;e?e.push(o):t.push(o)}return{layerViewsAndGraphics:s,clientOnlyGraphics:t}}};return e([l({cast(e){return!e||d(e)||"object"==typeof e&&(e.open=e=>(t(s.getLogger(this),"view.popup is no longer created by default. view.popup.open() will stop working when the popup isn't created",{replacement:"Use view.openPopup() instead.",version:"4.27"}),this.openPopup(e)),e.close=()=>(t(s.getLogger(this),"view.popup is no longer created by default. view.popup.close() will stop working when the popup isn't created",{replacement:"Use view.closePopup() instead.",version:"4.27"}),this.closePopup())),e}})],m.prototype,"popup",void 0),e([l()],m.prototype,"popupEnabled",void 0),m=e([c("esri.views.PopupView")],m),m};export{w as PopupView};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import{createTask as p}from"../core/asyncUtils.js";import{deprecated as t}from"../core/deprecate.js";import i from"../core/Error.js";import s from"../core/Logger.js";import{eachAlwaysValues as o,throwIfAborted as r}from"../core/promiseUtils.js";import{watch as a,initial as u,whenOnce as n}from"../core/reactiveUtils.js";import{property as l}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as c}from"../core/accessorSupport/decorators/subclass.js";import{ViewEventPriorities as h}from"./input/InputManager.js";function d(e){return null!=e&&"open"in e&&"declaredClass"in e}function y(e){return null!=e&&"declaredClass"in e&&"dockOptions"in e}const w=w=>{let m=class extends w{constructor(){super(...arguments),this._popupSetupTask=null,this.popup={},this.popupEnabled=!0}initialize(){this.addHandles([a((()=>[this.ui,this.popup]),(([e,p],t)=>{const i="popup",s="manual";if(t){const[e,p]=t;e&&d(p)&&(p.view=null,y(p)&&e.remove(p,i))}e&&d(p)&&(p.view=this,y(p)&&e.add(p,{key:i,position:s}))}),u),this.on("click",(e=>{this.popup&&this.popupEnabled&&("mouse"!==e.pointerType||0===e.button)&&(!d(this.popup)&&"autoOpenEnabled"in this.popup&&!1===this.popup.autoOpenEnabled||(d(this.popup)?this.popup.viewModel.handleViewClick(e):e.async((async()=>{await this.setupPopup(),d(this.popup)&&!this.destroyed&&this.ready&&this.popupEnabled&&this.popup.viewModel.handleViewClick(e)}))))}),h.WIDGET)]),n((()=>this.ready&&this.popupEnabled&&!this.updating)).then((()=>{import("../widgets/Popup.js")}))}destroy(){this.destroyed||this.closePopup()}async openPopup(e){d(this.popup)&&this.popup.open(e);try{if(await this.setupPopup(),!this.popup)return void s.getLogger(this).error(new i("view:null-popup","Popup is null and can't be opened"));this.popup.open(e)}catch{}}closePopup(){this._popupSetupTask?.abort(),d(this.popup)&&this.popup.close()}async fetchPopupFeatures(e,p){await this.when();const{location:t,queryArea:i,layerViewsAndGraphics:s,clientOnlyGraphics:r}=await this._prepareFetchPopupFeatures(e,p),a=Promise.resolve(r),u=this._queryLayerPopupFeatures(i,s,p),n=u.map((e=>e.promise));return{location:t,clientOnlyGraphics:r,allGraphicsPromise:o([a,...n]).then((e=>Array.from(new Set(e.flat())))),promisesPerLayerView:u}}async setupPopup(){if(this._popupSetupTask?.abort(),this.popup&&!d(this.popup))return this._popupSetupTask=p((async e=>{const{default:p}=await import("../widgets/Popup.js");if(r(e),!this.popup||d(this.popup))return;const t=this.popup;delete t.open,delete t.close,this.popup=new p(t)})),this._popupSetupTask.promise}_queryLayerPopupFeatures(e,p,t){return p.map((({layerView:p,graphics:i})=>{const s={clientGraphics:i,event:null!=t?t.event:void 0,signal:null!=t?t.signal:void 0,defaultPopupTemplateEnabled:null!=t&&!!t.defaultPopupTemplateEnabled},o=p.fetchPopupFeatures(e,s);return{layerView:p,promise:o}}))}_isValidPopupGraphic(e,p){return e&&!!e.getEffectivePopupTemplate(null!=p&&p.defaultPopupTemplateEnabled)}async _prepareFetchPopupFeatures(e,p){const{clientGraphics:t,queryArea:i,location:s}=await this._popupHitTestGraphics(e,p),o=this._getFetchPopupLayerViews(),{layerViewsAndGraphics:r,clientOnlyGraphics:a}=this._graphicsPerFetchPopupLayerView(t,o);return{clientOnlyGraphics:a,layerViewsAndGraphics:r,queryArea:i,location:s}}async _popupHitTestGraphics(e,p){const t=await this.popupHitTest(e),i=t.results,s=t.mapPoint,o=i.filter((e=>"graphic"===e.type&&this._isValidPopupGraphic(e.graphic,p))),r=o.length?o[0].mapPoint:null;return{clientGraphics:o.map((e=>e.graphic)),queryArea:s,location:s||r}}_getFetchPopupLayerViews(){const e=[];return this.allLayerViews.forEach((p=>{this._isValidPopupLayerView(p)&&e.push(p)})),null!=this.graphicsView&&this._isValidPopupLayerView(this.graphicsView)&&e.push(this.graphicsView),e.reverse()}_isValidPopupLayerView(e){return null!=e&&(!("layer"in e)||!e.suspended)&&"fetchPopupFeatures"in e}_graphicsPerFetchPopupLayerView(e,p){const t=[],i=new Map,s=p.map((e=>{const p=[];return"layer"in e?i.set(e.layer,p):i.set(e.graphics,p),{layerView:e,graphics:p}}));for(const o of e){const e=i.get(o.layer)||i.get(o.sourceLayer)||null;e?e.push(o):t.push(o)}return{layerViewsAndGraphics:s,clientOnlyGraphics:t}}};return e([l({cast(e){return!e||d(e)||"object"==typeof e&&(e.open=e=>(t(s.getLogger(this),"view.popup is no longer created by default. view.popup.open() will stop working when the popup isn't created",{replacement:"Use view.openPopup() instead.",version:"4.27"}),this.openPopup(e)),e.close=()=>(t(s.getLogger(this),"view.popup is no longer created by default. view.popup.close() will stop working when the popup isn't created",{replacement:"Use view.closePopup() instead.",version:"4.27"}),this.closePopup())),e}})],m.prototype,"popup",void 0),e([l()],m.prototype,"popupEnabled",void 0),m=e([c("esri.views.PopupView")],m),m};export{w as PopupView};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Evented.js";import{HandleOwner as i}from"../../core/HandleOwner.js";import{clone as n}from"../../core/lang.js";import{destroyMaybe as r,applySome as o,equalsMaybe as s}from"../../core/maybe.js";import{ignoreAbortErrors as a}from"../../core/promiseUtils.js";import{watch as p,syncAndInitial as l}from"../../core/reactiveUtils.js";import{createScreenPoint as c}from"../../core/screenUtils.js";import{property as h}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import{diff as g}from"../../core/accessorSupport/diffUtils.js";import{pointEquals as m}from"../../layers/graphics/dehydratedFeatureComparison.js";import{getEffectiveElevationInfo as u}from"../../support/elevationInfoUtils.js";import{ViewingMode as v}from"../ViewingMode.js";import{defaultDrawingMode as y}from"./DrawingMode.js";import{DrawManipulator as _}from"./DrawManipulator.js";import{createCoordinateHelper as x}from"../interactive/coordinateHelper.js";import{createManipulatorDragEventPipeline as f,sceneSnappingAtLocation as S}from"../interactive/dragEventPipeline.js";import{EditGeometry as V,Component as w}from"../interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as O}from"../interactive/editGeometry/EditGeometryOperations.js";import T from"../interactive/sketch/SketchLabelOptions.js";import b from"../interactive/sketch/SketchTooltipOptions.js";import{SnappingContext as M}from"../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as P}from"../interactive/snapping/SnappingDragPipelineStep.js";import{SnappingOperation as D}from"../interactive/snapping/SnappingOperation.js";import{setupSnappingToggleHandles as C}from"../interactive/snapping/snappingUtils.js";let I=class extends(t.EventedMixin(i)){constructor(e){super(e),this._createOperationCompleted=!1,this._pointerDownStates=new Set,this._stagedScreenPoint=null,this._stagedPointerType=null,this.isDraped=!0,this.labelOptions=new T,this.tooltipOptions=new b,this.snapToSceneEnabled=null,this.lastVertex=null,null==e.elevationInfo&&(this.elevationInfo=u(!!e.hasZ))}initialize(){const{geometryType:e,view:t}=this,i=t.spatialReference,n="viewingMode"in t.state?t.state.viewingMode:v.Local,r="segment"===e||"multipoint"===e?"polyline":e;this.coordinateHelper=x(this.hasZ,this.hasM,i),this._editGeometryOperations=new O(new V(r,this.coordinateHelper)),this._snappingOperation=new D({view:t,constrainResult:e=>null==e?e:this._getEffectiveDrawSurface()?.constrainZ(e)}),this.handles.add(p((()=>this.stagedVertex),(e=>{null!=e&&this.emit("cursor-update",{updated:null,vertices:[{componentIndex:0,vertexIndex:this._activeComponent.vertices.length,coordinates:this.coordinateHelper.pointToArray(e)}],operation:"apply",type:"vertex-update"})}),{sync:!0,equals:(e,t)=>s(e,t,m)}),p((()=>this.view.viewpoint),((e,t)=>{e&&t&&g(e,t)&&this._onViewpointChange()}))),this._activeComponent=new w(i,n),this._editGeometryOperations.data.components.push(this._activeComponent);const o=this.segmentLabels;null!=o&&(o.context={view:t,editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,labelOptions:this.labelOptions},this.handles.add([p((()=>this.labelOptions.enabled),(e=>{o.visible=e}),l),this.on("cursor-update",(()=>{const e=this.stagedVertex;o.stagedVertex=null!=e?this.coordinateHelper.pointToVector(e):null}))])),this.handles.add(this._editGeometryOperations.on(["vertex-add","vertex-update","vertex-remove"],(e=>{const t=e.vertices.map((e=>({componentIndex:0,vertexIndex:e.index,coordinates:this.coordinateHelper.vectorToArray(e.pos)}))),i=t.map((e=>e.coordinates));switch(e.type){case"vertex-add":this.emit(e.type,{...e,added:i,vertices:t});break;case"vertex-update":this.emit(e.type,{...e,updated:i,vertices:t});break;case"vertex-remove":this.emit(e.type,{...e,removed:i,vertices:t})}const n=this._activeComponent.getLastVertex(),r=null!=n?this.coordinateHelper.vectorToDehydratedPoint(n.pos):null;null!=r&&null!=this.lastVertex&&m(this.lastVertex,r)||(this.lastVertex=r)}))),this._manipulator=new _({grabbableForEvent:e=>"click"!==this.drawingMode||"touch"===e.pointerType&&this._snappingEnabled&&1===this._pointerDownStates.size}),this.manipulators.add(this._manipulator),this._manipulator.grabbable="point"!==e,this.handles.add([this._createManipulatorDragPipeline(this._manipulator),this._manipulator.events.on("immediate-click",(e=>this._onImmediateClick(e))),this._manipulator.events.on("immediate-double-click",(e=>this._onImmediateDoubleClick(e)))]),C(this,(()=>{const e=this.view.inputManager.latestPointerType??"mouse",t=this._getSnappingContext(e);null!=this.snappingManager&&this.updatingHandles.addPromise(a(this._snappingOperation.resnap(this.snappingManager,t)))}))}destroy(){r(this.segmentLabels),r(this._snappingOperation),this._editGeometryOperations=r(this._editGeometryOperations)}get _snappingEnabled(){return null!=this.snappingManager&&this.snappingManager.options.effectiveEnabled}get _requiresScenePoint(){const e=this._getEffectiveDrawSurface();return"3d"===this.view.type&&this.drawSurface!==e}get canRedo(){return this._editGeometryOperations.canRedo}get canUndo(){return this._editGeometryOperations.canUndo}get committedVertices(){return this._activeComponent.vertices.map((e=>this.coordinateHelper.vectorToArray(e.pos)))}set drawingMode(e){this._set("drawingMode",e??y)}get interactive(){return this._manipulator.interactive}set interactive(e){this._manipulator.interactive=e}get isCompleted(){return this._createOperationCompleted}get numCommittedVertices(){return this._activeComponent.vertices.length}get numVertices(){return null!=this.stagedVertex?this._activeComponent.vertices.length+1:this._activeComponent.vertices.length}get snappingOptions(){return null!=this.snappingManager?this.snappingManager.options:null}get stagedVertex(){return this._snappingOperation.stagedPoint}set stagedVertex(e){this._snappingOperation.stagedPoint=n(e)}get updating(){return this.updatingHandles.updating}get vertices(){const e=this.committedVertices;return null!=this.stagedVertex&&e.push(this.coordinateHelper.pointToArray(this.stagedVertex)),e}cancel(){this.complete({aborted:!0})}commitStagedVertex(){if(this._snappingOperation.abort(),null!=this.stagedVertex){const{stagedVertex:e}=this;this.stagedVertex=null,this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(e))}}complete(e){const t=e&&e.aborted||!1;this._snappingOperation.abort(),null!=this.snappingManager&&this.snappingManager.doneSnapping(),"segment"===this.geometryType||"point"===this.geometryType?this.commitStagedVertex():this.stagedVertex=null;const i="multipoint"===this.geometryType&&0===this.numVertices||"polyline"===this.geometryType&&this.numVertices<2||"polygon"===this.geometryType&&this.numVertices<3;this._createOperationCompleted=!i,(this.isCompleted||t)&&this.emit("complete",{vertices:this.vertices.map(((e,t)=>({componentIndex:0,vertexIndex:t,coordinates:e}))),aborted:t,type:"complete"})}onInputEvent(e){switch(e.type){case"pointer-down":this._pointerDownStates.add(e.pointerId);break;case"pointer-up":this._pointerDownStates.delete(e.pointerId)}switch(e.type){case"pointer-move":return this._onPointerMove(e);case"hold":return this._onHold(e)}}redo(){this._editGeometryOperations.redo()}undo(){null!=this.snappingManager&&this.snappingManager.doneSnapping(),this._editGeometryOperations.undo()}_closeOnClickVertexIndex(e){const t=this._activeComponent;if("polygon"===this.geometryType&&t.vertices.length>2){if(this._vertexWithinPointerDistance(t.vertices[0].pos,e))return 0;if(this._vertexWithinPointerDistance(t.vertices[t.vertices.length-1].pos,e))return t.vertices.length-1}return null}_createManipulatorDragPipeline(e){switch(this.drawingMode){case"click":return this._createManipulatorDragPipelineClick(e);case"freehand":return this._createManipulatorDragPipelineFreehand(e);case"hybrid":return this._createManipulatorDragPipelineHybrid(e)}}_createManipulatorDragPipelineClick(e){return f(e,((e,t,i,n)=>{const r="touch"===n&&this._snappingEnabled;if(this.isCompleted||!r)return;const{snappingStep:o,cancelSnapping:s}=P({predicate:()=>r,snappingManager:this.snappingManager,snappingContext:new M({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,pointer:n,visualizer:this.snappingVisualizer}),updatingHandles:this.updatingHandles,useZ:!this._requiresScenePoint});i=i.next((e=>(r&&null!=this.snappingManager&&this.snappingManager.doneSnapping(),e))).next(s),t.next(this._screenToMapDragEventStep()).next((e=>("start"===e.action&&(this.stagedVertex=e.mapStart,("segment"===this.geometryType||r&&0===this.numVertices)&&this.commitStagedVertex()),e))).next(S(this.view,this.elevationInfo)).next(...o).next((e=>(r&&(this.stagedVertex=e.mapEnd,"end"===e.action&&this.commitStagedVertex()),e))).next((e=>("end"===e.action&&("segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()),e)))}))}_createManipulatorDragPipelineFreehand(e){return f(e,((e,t)=>{this.isCompleted||t.next(this._screenToMapDragEventStep()).next((e=>("start"===e.action&&(null==this.stagedVertex&&(this.stagedVertex=e.mapStart),"segment"===this.geometryType&&this.commitStagedVertex()),e))).next((e=>{switch(e.action){case"start":case"update":this.stagedVertex=e.mapEnd,"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":this.complete()}return e}))}))}_createManipulatorDragPipelineHybrid(e){return f(e,((e,t)=>{this.isCompleted||t.next(this._screenToMapDragEventStep()).next((e=>("start"===e.action&&(null==this.stagedVertex&&(this.stagedVertex=e.mapStart),this.commitStagedVertex()),e))).next((e=>{switch(e.action){case"start":case"update":this.stagedVertex=e.mapEnd,"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":"segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()}return e}))}))}get _drawAtFixedElevation(){return("segment"===this.geometryType||"polygon"===this.geometryType)&&this.numCommittedVertices>0}_getEffectiveDrawSurface(){if(null==this.elevationDrawSurface)return this.drawSurface;if(!this.coordinateHelper.hasZ())return this.elevationDrawSurface.defaultZ=null,this.elevationDrawSurface;let e=this.defaultZ,t=!1;return null!=this.elevationInfo&&"absolute-height"===this.elevationInfo.mode&&(t=!0),null!=this.snapToSceneEnabled&&(t=this.snapToSceneEnabled),null!=this.elevationInfo&&"on-the-ground"===this.elevationInfo.mode&&(t=!1),this._drawAtFixedElevation&&(e=this.coordinateHelper.getZ(this._activeComponent.vertices[0].pos),t=!1),t?this.drawSurface:(this.elevationDrawSurface.defaultZ=e,this.elevationDrawSurface)}_mapToScreen(e){return this._getEffectiveDrawSurface()?.mapToScreen(e)}_onHold(e){this._snappingOperation.abort(),"click"===this.drawingMode&&"touch"===e.pointerType&&this._snappingEnabled&&(this.stagedVertex=e.mapPoint),e.stopPropagation()}_onImmediateClick(e){if("mouse"===e.pointerType&&2===e.button||this._manipulator.dragging)return;const t=this._activeComponent;if(null!=this._closeOnClickVertexIndex(e.screenPoint))return e.stopPropagation(),void this.complete();const i=this._screenToMap(e.screenPoint);if(null!=i)switch(this.drawingMode){case"freehand":"point"===this.geometryType&&(null!=this.stagedVertex?this.commitStagedVertex():this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(i)),this.complete());break;case"click":case"hybrid":this._snappingOperation.abort(),null!=this.stagedVertex?this.commitStagedVertex():this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(i)),("point"===this.geometryType||"segment"===this.geometryType&&2===t.vertices.length||"segment"===this.geometryType&&"hybrid"===this.drawingMode&&1===t.vertices.length)&&this.complete()}e.stopPropagation()}_onImmediateDoubleClick(e){this._manipulator.dragging||"point"===this.geometryType||(this.complete(),e.stopPropagation())}_onPointerMove(e){const t=c(e.x,e.y);this._stagedScreenPoint=t,this._stagedPointerType=e.pointerType;const i=this._snappingOperation;this._manipulator.dragging||this._pointerDownStates.has(e.pointerId)||this._manipulator.grabbing||!this._manipulator.interactive?i.abort():(e.stopPropagation(),this._updateStagedVertexOnPointerMove(t,e.pointerType))}_onViewpointChange(){this._stagedScreenPoint&&!this._manipulator.dragging&&!this._manipulator.grabbing&&this._manipulator.interactive?this._updateStagedVertexOnPointerMove(this._stagedScreenPoint,this._stagedPointerType??"mouse"):this._snappingOperation.abort()}_updateStagedVertexOnPointerMove(e,t){const i=this._snappingOperation,n=this._closeOnClickVertexIndex(e);if(null!=n)return this._closeOnVertex(n),void i.abort();const r=this._screenToMap(e),o=this._requiresScenePoint?this.drawSurface?.screenToMap(e):null;if(this._manipulator.cursor=null!=r?"crosshair":null,null==r)return void i.abort();const s=this.snappingManager;if(null==s)return this.stagedVertex=r,void i.abort();const p=this._getSnappingContext(t);this.updatingHandles.addPromise(a(i.snap({point:r,scenePoint:o},s,p)))}_closeOnVertex(e){this.stagedVertex=null;const t={componentIndex:0,vertexIndex:e,coordinates:this.coordinateHelper.vectorToArray(this._activeComponent.vertices[e].pos)};this.emit("cursor-update",{updated:null,vertices:[t],operation:"apply",type:"vertex-update"})}_screenToMap(e){return this._getEffectiveDrawSurface()?.screenToMap(e)}_screenToMapDragEventStep(){let e=null;return t=>{if("start"===t.action&&(e=this._screenToMap(t.screenStart)),null==e)return null;const i=this._screenToMap(t.screenEnd);return null!=i?{...t,mapStart:e,mapEnd:i}:null}}_vertexWithinPointerDistance(e,t){const i=25,n=this._mapToScreen(this.coordinateHelper.vectorToDehydratedPoint(e));return null!=n&&E(n,t,i)}_getSnappingContext(e){const t=this._drawAtFixedElevation?o(this.elevationDrawSurface,(({defaultZ:e})=>e)):null;return new M({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,pointer:e,visualizer:this.snappingVisualizer,selfSnappingZ:null!=t?{value:t,elevationInfo:this.elevationInfo}:null})}};function E(e,t,i){const n=e.x-t.x,r=e.y-t.y;return n*n+r*r<=i}e([h()],I.prototype,"_snappingEnabled",null),e([h()],I.prototype,"defaultZ",void 0),e([h()],I.prototype,"isDraped",void 0),e([h({value:y})],I.prototype,"drawingMode",null),e([h({constructOnly:!0})],I.prototype,"elevationDrawSurface",void 0),e([h({constructOnly:!0})],I.prototype,"elevationInfo",void 0),e([h({constructOnly:!0,type:T})],I.prototype,"labelOptions",void 0),e([h({constructOnly:!0,type:b})],I.prototype,"tooltipOptions",void 0),e([h({constructOnly:!0})],I.prototype,"geometryType",void 0),e([h({constructOnly:!0})],I.prototype,"hasM",void 0),e([h({constructOnly:!0})],I.prototype,"hasZ",void 0),e([h({constructOnly:!0})],I.prototype,"manipulators",void 0),e([h({constructOnly:!0})],I.prototype,"drawSurface",void 0),e([h({constructOnly:!0})],I.prototype,"segmentLabels",void 0),e([h({constructOnly:!0})],I.prototype,"snappingManager",void 0),e([h({constructOnly:!0})],I.prototype,"snappingVisualizer",void 0),e([h()],I.prototype,"snapToSceneEnabled",void 0),e([h()],I.prototype,"_snappingOperation",void 0),e([h()],I.prototype,"stagedVertex",null),e([h()],I.prototype,"lastVertex",void 0),e([h()],I.prototype,"updating",null),e([h({constructOnly:!0})],I.prototype,"view",void 0),I=e([d("esri.views.draw.DrawOperation")],I);export{I as DrawOperation};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Evented.js";import{HandleOwner as i}from"../../core/HandleOwner.js";import{clone as n}from"../../core/lang.js";import{destroyMaybe as r,applySome as o,equalsMaybe as s}from"../../core/maybe.js";import{ignoreAbortErrors as a}from"../../core/promiseUtils.js";import{watch as p,syncAndInitial as l}from"../../core/reactiveUtils.js";import{createScreenPoint as c}from"../../core/screenUtils.js";import{property as h}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import{diff as g}from"../../core/accessorSupport/diffUtils.js";import{pointEquals as m}from"../../layers/graphics/dehydratedFeatureComparison.js";import{getEffectiveElevationInfo as u}from"../../support/elevationInfoUtils.js";import{ViewingMode as v}from"../ViewingMode.js";import{defaultDrawingMode as y}from"./DrawingMode.js";import{DrawManipulator as _}from"./DrawManipulator.js";import{createCoordinateHelper as x}from"../interactive/coordinateHelper.js";import{createManipulatorDragEventPipeline as f,sceneSnappingAtLocation as S}from"../interactive/dragEventPipeline.js";import{EditGeometry as V,Component as w}from"../interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as O}from"../interactive/editGeometry/EditGeometryOperations.js";import T from"../interactive/sketch/SketchLabelOptions.js";import b from"../interactive/sketch/SketchTooltipOptions.js";import{SnappingContext as M}from"../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as P}from"../interactive/snapping/SnappingDragPipelineStep.js";import{SnappingOperation as D}from"../interactive/snapping/SnappingOperation.js";import{setupSnappingToggleHandles as C}from"../interactive/snapping/snappingUtils.js";let I=class extends(t.EventedMixin(i)){constructor(e){super(e),this._createOperationCompleted=!1,this._pointerDownStates=new Set,this._stagedScreenPoint=null,this._stagedPointerType=null,this.isDraped=!0,this.labelOptions=new T,this.tooltipOptions=new b,this.snapToSceneEnabled=null,this.lastVertex=null,null==e.elevationInfo&&(this.elevationInfo=u(!!e.hasZ))}initialize(){const{geometryType:e,view:t}=this,i=t.spatialReference,n="viewingMode"in t.state?t.state.viewingMode:v.Local,r="segment"===e||"multipoint"===e?"polyline":e;this.coordinateHelper=x(this.hasZ,this.hasM,i),this._editGeometryOperations=new O(new V(r,this.coordinateHelper)),this._snappingOperation=new D({view:t,constrainResult:e=>null==e?e:this._getEffectiveDrawSurface()?.constrainZ(e)}),this.handles.add(p((()=>this.stagedVertex),(e=>{null!=e&&this.emit("cursor-update",{updated:null,vertices:[{componentIndex:0,vertexIndex:this._activeComponent.vertices.length,coordinates:this.coordinateHelper.pointToArray(e)}],operation:"apply",type:"vertex-update"})}),{sync:!0,equals:(e,t)=>s(e,t,m)}),p((()=>this.view.viewpoint),((e,t)=>{e&&t&&g(e,t)&&this._onViewpointChange()}))),this._activeComponent=new w(i,n),this._editGeometryOperations.data.components.push(this._activeComponent);const o=this.segmentLabels;null!=o&&(o.context={view:t,editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,labelOptions:this.labelOptions},this.handles.add([p((()=>this.labelOptions.enabled),(e=>{o.visible=e}),l),this.on("cursor-update",(()=>{const e=this.stagedVertex;o.stagedVertex=null!=e?this.coordinateHelper.pointToVector(e):null}))])),this.handles.add(this._editGeometryOperations.on(["vertex-add","vertex-update","vertex-remove"],(e=>{const t=e.vertices.map((e=>({componentIndex:0,vertexIndex:e.index,coordinates:this.coordinateHelper.vectorToArray(e.pos)}))),i=t.map((e=>e.coordinates));switch(e.type){case"vertex-add":this.emit(e.type,{...e,added:i,vertices:t});break;case"vertex-update":this.emit(e.type,{...e,updated:i,vertices:t});break;case"vertex-remove":this.emit(e.type,{...e,removed:i,vertices:t})}const n=this._activeComponent.getLastVertex(),r=null!=n?this.coordinateHelper.vectorToDehydratedPoint(n.pos):null;null!=r&&null!=this.lastVertex&&m(this.lastVertex,r)||(this.lastVertex=r)}))),this._manipulator=new _({grabbableForEvent:e=>"click"!==this.drawingMode||"touch"===e.pointerType&&this._snappingEnabled&&1===this._pointerDownStates.size}),this.manipulators.add(this._manipulator),this._manipulator.grabbable="point"!==e,this.handles.add([this._createManipulatorDragPipeline(this._manipulator),this._manipulator.events.on("immediate-click",(e=>this._onImmediateClick(e))),this._manipulator.events.on("immediate-double-click",(e=>this._onImmediateDoubleClick(e)))]),C(this,(()=>{const e=this.view.inputManager.latestPointerType??"mouse",t=this._getSnappingContext(e);null!=this.snappingManager&&this.updatingHandles.addPromise(a(this._snappingOperation.resnap(this.snappingManager,t)))}))}destroy(){r(this.segmentLabels),r(this._snappingOperation),this._editGeometryOperations=r(this._editGeometryOperations)}get _snappingEnabled(){return null!=this.snappingManager&&this.snappingManager.options.effectiveEnabled}get _requiresScenePoint(){const e=this._getEffectiveDrawSurface();return"3d"===this.view.type&&this.drawSurface!==e}get canRedo(){return this._editGeometryOperations.canRedo}get canUndo(){return this._editGeometryOperations.canUndo}get committedVertices(){return this._activeComponent.vertices.map((e=>this.coordinateHelper.vectorToArray(e.pos)))}set drawingMode(e){this._set("drawingMode",e??y)}set cursor(e){const t=this._manipulator;t&&(t.cursor=e),this._set("cursor",e)}get interactive(){return this._manipulator.interactive}set interactive(e){this._manipulator.interactive=e}get isCompleted(){return this._createOperationCompleted}get numCommittedVertices(){return this._activeComponent.vertices.length}get numVertices(){return null!=this.stagedVertex?this._activeComponent.vertices.length+1:this._activeComponent.vertices.length}get snappingOptions(){return null!=this.snappingManager?this.snappingManager.options:null}get stagedVertex(){return this._snappingOperation.stagedPoint}set stagedVertex(e){this._snappingOperation.stagedPoint=n(e)}get updating(){return this.updatingHandles.updating}get vertices(){const e=this.committedVertices;return null!=this.stagedVertex&&e.push(this.coordinateHelper.pointToArray(this.stagedVertex)),e}cancel(){this.complete({aborted:!0})}commitStagedVertex(){if(this._snappingOperation.abort(),null!=this.stagedVertex){const{stagedVertex:e}=this;this.stagedVertex=null,this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(e))}}complete(e){const t=e&&e.aborted||!1;this._snappingOperation.abort(),null!=this.snappingManager&&this.snappingManager.doneSnapping(),"segment"===this.geometryType||"point"===this.geometryType?this.commitStagedVertex():this.stagedVertex=null;const i="multipoint"===this.geometryType&&0===this.numVertices||"polyline"===this.geometryType&&this.numVertices<2||"polygon"===this.geometryType&&this.numVertices<3;this._createOperationCompleted=!i,(this.isCompleted||t)&&this.emit("complete",{vertices:this.vertices.map(((e,t)=>({componentIndex:0,vertexIndex:t,coordinates:e}))),aborted:t,type:"complete"})}onInputEvent(e){switch(e.type){case"pointer-down":this._pointerDownStates.add(e.pointerId);break;case"pointer-up":this._pointerDownStates.delete(e.pointerId)}switch(e.type){case"pointer-move":return this._onPointerMove(e);case"hold":return this._onHold(e)}}redo(){this._editGeometryOperations.redo()}undo(){null!=this.snappingManager&&this.snappingManager.doneSnapping(),this._editGeometryOperations.undo()}_closeOnClickVertexIndex(e){const t=this._activeComponent;if("polygon"===this.geometryType&&t.vertices.length>2){if(this._vertexWithinPointerDistance(t.vertices[0].pos,e))return 0;if(this._vertexWithinPointerDistance(t.vertices[t.vertices.length-1].pos,e))return t.vertices.length-1}return null}_createManipulatorDragPipeline(e){switch(this.drawingMode){case"click":return this._createManipulatorDragPipelineClick(e);case"freehand":return this._createManipulatorDragPipelineFreehand(e);case"hybrid":return this._createManipulatorDragPipelineHybrid(e)}}_createManipulatorDragPipelineClick(e){return f(e,((e,t,i,n)=>{const r="touch"===n&&this._snappingEnabled;if(this.isCompleted||!r)return;const{snappingStep:o,cancelSnapping:s}=P({predicate:()=>r,snappingManager:this.snappingManager,snappingContext:new M({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,pointer:n,visualizer:this.snappingVisualizer}),updatingHandles:this.updatingHandles,useZ:!this._requiresScenePoint});i=i.next((e=>(r&&null!=this.snappingManager&&this.snappingManager.doneSnapping(),e))).next(s),t.next(this._screenToMapDragEventStep()).next((e=>("start"===e.action&&(this.stagedVertex=e.mapStart,("segment"===this.geometryType||r&&0===this.numVertices)&&this.commitStagedVertex()),e))).next(S(this.view,this.elevationInfo)).next(...o).next((e=>(r&&(this.stagedVertex=e.mapEnd,"end"===e.action&&this.commitStagedVertex()),e))).next((e=>("end"===e.action&&("segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()),e)))}))}_createManipulatorDragPipelineFreehand(e){return f(e,((e,t)=>{this.isCompleted||t.next(this._screenToMapDragEventStep()).next((e=>("start"===e.action&&(null==this.stagedVertex&&(this.stagedVertex=e.mapStart),"segment"===this.geometryType&&this.commitStagedVertex()),e))).next((e=>{switch(e.action){case"start":case"update":this.stagedVertex=e.mapEnd,"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":this.complete()}return e}))}))}_createManipulatorDragPipelineHybrid(e){return f(e,((e,t)=>{this.isCompleted||t.next(this._screenToMapDragEventStep()).next((e=>("start"===e.action&&(null==this.stagedVertex&&(this.stagedVertex=e.mapStart),this.commitStagedVertex()),e))).next((e=>{switch(e.action){case"start":case"update":this.stagedVertex=e.mapEnd,"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":"segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()}return e}))}))}get _drawAtFixedElevation(){return("segment"===this.geometryType||"polygon"===this.geometryType)&&this.numCommittedVertices>0}_getEffectiveDrawSurface(){if(null==this.elevationDrawSurface)return this.drawSurface;if(!this.coordinateHelper.hasZ())return this.elevationDrawSurface.defaultZ=null,this.elevationDrawSurface;let e=this.defaultZ,t=!1;return null!=this.elevationInfo&&"absolute-height"===this.elevationInfo.mode&&(t=!0),null!=this.snapToSceneEnabled&&(t=this.snapToSceneEnabled),null!=this.elevationInfo&&"on-the-ground"===this.elevationInfo.mode&&(t=!1),this._drawAtFixedElevation&&(e=this.coordinateHelper.getZ(this._activeComponent.vertices[0].pos),t=!1),t?this.drawSurface:(this.elevationDrawSurface.defaultZ=e,this.elevationDrawSurface)}_mapToScreen(e){return this._getEffectiveDrawSurface()?.mapToScreen(e)}_onHold(e){this._snappingOperation.abort(),"click"===this.drawingMode&&"touch"===e.pointerType&&this._snappingEnabled&&(this.stagedVertex=e.mapPoint),e.stopPropagation()}_onImmediateClick(e){if("mouse"===e.pointerType&&2===e.button||this._manipulator.dragging)return;const t=this._activeComponent;if(null!=this._closeOnClickVertexIndex(e.screenPoint))return e.stopPropagation(),void this.complete();const i=this._screenToMap(e.screenPoint);if(null!=i)switch(this.drawingMode){case"freehand":"point"===this.geometryType&&(null!=this.stagedVertex?this.commitStagedVertex():this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(i)),this.complete());break;case"click":case"hybrid":this._snappingOperation.abort(),null!=this.stagedVertex?this.commitStagedVertex():this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(i)),("point"===this.geometryType||"segment"===this.geometryType&&2===t.vertices.length||"segment"===this.geometryType&&"hybrid"===this.drawingMode&&1===t.vertices.length)&&this.complete()}e.stopPropagation()}_onImmediateDoubleClick(e){this._manipulator.dragging||"point"===this.geometryType||(this.complete(),e.stopPropagation())}_onPointerMove(e){const t=c(e.x,e.y);this._stagedScreenPoint=t,this._stagedPointerType=e.pointerType;const i=this._snappingOperation;this._manipulator.dragging||this._pointerDownStates.has(e.pointerId)||this._manipulator.grabbing||!this._manipulator.interactive?i.abort():(e.stopPropagation(),this._updateStagedVertexOnPointerMove(t,e.pointerType))}_onViewpointChange(){this._stagedScreenPoint&&!this._manipulator.dragging&&!this._manipulator.grabbing&&this._manipulator.interactive?this._updateStagedVertexOnPointerMove(this._stagedScreenPoint,this._stagedPointerType??"mouse"):this._snappingOperation.abort()}_updateStagedVertexOnPointerMove(e,t){const i=this._snappingOperation,n=this._closeOnClickVertexIndex(e);if(null!=n)return this._closeOnVertex(n),void i.abort();const r=this._screenToMap(e),o=this._requiresScenePoint?this.drawSurface?.screenToMap(e):null;if(this.cursor??=null!=r?"crosshair":null,null==r)return void i.abort();const s=this.snappingManager;if(null==s)return this.stagedVertex=r,void i.abort();const p=this._getSnappingContext(t);this.updatingHandles.addPromise(a(i.snap({point:r,scenePoint:o},s,p)))}_closeOnVertex(e){this.stagedVertex=null;const t={componentIndex:0,vertexIndex:e,coordinates:this.coordinateHelper.vectorToArray(this._activeComponent.vertices[e].pos)};this.emit("cursor-update",{updated:null,vertices:[t],operation:"apply",type:"vertex-update"})}_screenToMap(e){return this._getEffectiveDrawSurface()?.screenToMap(e)}_screenToMapDragEventStep(){let e=null;return t=>{if("start"===t.action&&(e=this._screenToMap(t.screenStart)),null==e)return null;const i=this._screenToMap(t.screenEnd);return null!=i?{...t,mapStart:e,mapEnd:i}:null}}_vertexWithinPointerDistance(e,t){const i=25,n=this._mapToScreen(this.coordinateHelper.vectorToDehydratedPoint(e));return null!=n&&E(n,t,i)}_getSnappingContext(e){const t=this._drawAtFixedElevation?o(this.elevationDrawSurface,(({defaultZ:e})=>e)):null;return new M({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,pointer:e,visualizer:this.snappingVisualizer,selfSnappingZ:null!=t?{value:t,elevationInfo:this.elevationInfo}:null})}};function E(e,t,i){const n=e.x-t.x,r=e.y-t.y;return n*n+r*r<=i}e([h()],I.prototype,"_snappingEnabled",null),e([h()],I.prototype,"defaultZ",void 0),e([h()],I.prototype,"isDraped",void 0),e([h({value:y})],I.prototype,"drawingMode",null),e([h({constructOnly:!0})],I.prototype,"elevationDrawSurface",void 0),e([h({constructOnly:!0})],I.prototype,"elevationInfo",void 0),e([h({constructOnly:!0,type:T})],I.prototype,"labelOptions",void 0),e([h({constructOnly:!0,type:b})],I.prototype,"tooltipOptions",void 0),e([h({constructOnly:!0})],I.prototype,"geometryType",void 0),e([h({constructOnly:!0})],I.prototype,"hasM",void 0),e([h({constructOnly:!0})],I.prototype,"hasZ",void 0),e([h()],I.prototype,"cursor",null),e([h({constructOnly:!0})],I.prototype,"manipulators",void 0),e([h({constructOnly:!0})],I.prototype,"drawSurface",void 0),e([h({constructOnly:!0})],I.prototype,"segmentLabels",void 0),e([h({constructOnly:!0})],I.prototype,"snappingManager",void 0),e([h({constructOnly:!0})],I.prototype,"snappingVisualizer",void 0),e([h()],I.prototype,"snapToSceneEnabled",void 0),e([h()],I.prototype,"_snappingOperation",void 0),e([h()],I.prototype,"stagedVertex",null),e([h()],I.prototype,"lastVertex",void 0),e([h()],I.prototype,"updating",null),e([h({constructOnly:!0})],I.prototype,"view",void 0),I=e([d("esri.views.draw.DrawOperation")],I);export{I as DrawOperation};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{TextureDescriptor as t}from"./TextureDescriptor.js";class e extends t{constructor(t,e){super(),this.context=t,Object.assign(this,e)}static validate(t,s){return new e(t,s)}}export{e as ValidatedTextureDescriptor};
5
+ import{SizedPixelFormat as s,PixelFormat as e}from"./enums.js";import{TextureDescriptor as t}from"./TextureDescriptor.js";class a extends t{constructor(t,a){switch(super(),this.context=t,Object.assign(this,a),this.internalFormat){case s.R16F:case s.R16I:case s.R16UI:case s.R32F:case s.R32I:case s.R32UI:case s.R8_SNORM:case s.R8:case s.R8I:case s.R8UI:this.pixelFormat=e.RED}}static validate(s,e){return new a(s,e)}}export{a as ValidatedTextureDescriptor};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import{remove as t}from"../../core/arrayUtils.js";import{makeHandle as a,handlesGroup as i}from"../../core/handleUtils.js";import{removeMaybe as r,destroyMaybe as o}from"../../core/maybe.js";import{throwIfAborted as n}from"../../core/promiseUtils.js";import{whenOnce as s,watch as l,syncAndInitial as c}from"../../core/reactiveUtils.js";import{generateBracedUUID as d}from"../../core/uuid.js";import{property as u}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/has.js";import{subclass as h}from"../../core/accessorSupport/decorators/subclass.js";import{getEffectiveLayerCapabilities as p,getEffectiveEditingEnabled as f}from"../../layers/support/layerUtils.js";import{getDrawHelpMessage as m}from"../../views/draw/support/helpMessageUtils.js";import g from"../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{CreateFeaturesWorkflowData as w}from"./CreateFeaturesWorkflowData.js";import{isModelUpload as v,waitForModelUpload as y}from"./modelUploadUtils.js";import _ from"./Workflow.js";import{shouldShowAttachmentsForCreateWorkflow as M,startCreatingNewFeature as F,findLayerInfo as I,updateGraphicSymbolWhenRequired as A,isTerminalUpdateEventType as b,getVisualVariableAttributes as V,startUpdatingFeature as k,createWorkflowSteps as j,avoidFeatureTemplateSelectionWithOnlyOneItem as S,prepareAttachmentsForCreateWorkflow as U,visualVariableInteractiveUpdate as C}from"./workflowUtils.js";var E;const O=Symbol();let G=E=class extends _{constructor(e){super(e),this.type="create-features",this.createFeatureState="create-new",this._featureFormHandle=null,this._visualVariableAttributes={rotation:null,size:null},this._attachmentFileInfos=new Map,this._highlightHandles=new Map,this._preventDefaultActionOnCancel=!1,this._lastActiveGraphics=[]}get hasPendingEdits(){if(this.numPendingFeatures)return!0;const{data:e}=this,{upload:t}=e;return!(!t||t.error)||!!e.creationInfo?.geometryToPlace}get helpMessage(){const{creationInfo:e,viewModel:t}=this.data;if("creating-features"!==this.stepId||!e)return;const a=e.layer.geometryType,i=t.sketchViewModel.createGraphic?.geometry;return m(a,i,t.view)}get numPendingFeatures(){return this.data.viewModel.sketchViewModel.layer.graphics.length}get pendingFeatures(){return this.data.viewModel.sketchViewModel.layer.graphics}get reliesOnOwnerAdminPrivileges(){const{creationInfo:e}=this.data;if(!e)return!1;const{layer:t}=e,a=t.capabilities?.operations.supportsAdd,i=p(t)?.operations.supportsAdd;return f(t)&&!t.editingEnabled||!!i&&!a}get shouldShowAttachments(){return!!(this.data&&this.data.creationInfo&&this.data.viewModel)&&M(this.data)}get shouldAllowAttachmentEditing(){return this.shouldShowAttachments}get test(){return{addAttachment:(e,t)=>{this._attachmentFileInfos.set(e,t)}}}async updatePendingFeature(e,a){return this._preventDefaultActionOnCancel=!0,this.data.viewModel.sketchViewModel.cancel(),t(this._lastActiveGraphics,e),this._startUpdating(e,a)}static create(e,t,a,i,r){const o=new E({data:new w({creationInfo:t,viewModel:e}),onCommit:async e=>{const{creationInfo:t,viewModel:a}=e;if(!t)return;t.geometryToPlace&&(e.creationInfo=null);const n=a.sketchViewModel.layer.graphics.toArray(),{layer:s}=t,l=s.capabilities?.editing.supportsGlobalId&&"globalIdField"in s,c=o._attachmentFileInfos;if(l){const e=D(n,s,c);return void await i(s,e,{globalIdUsed:!0})}const d=await i(s,{addFeatures:n});if(c.size>0){const e=d?.addFeatureResults??[];await r(s,H(n,e,s,c))}}});return o._set("steps",this._createWorkflowSteps(o,a)),o}_fadeExistingFeatures(e){if("effect"in e){const t=e.effect;return e.effect="saturate(0.6) opacity(0.8)",a((()=>e.effect=t))}const t=e.opacity;return e.opacity=.7,a((()=>e.opacity=t))}_highlight(e){const t=this.data.viewModel.view;"3d"===t?.type&&this._highlightHandles.set(e,t.highlight(e))}_removeHighlight(e){r(this._highlightHandles.get(e)),this._highlightHandles.delete(e)}async _startCreating(e){const{creationInfo:t}=this.data;if(t)return this.createFeatureState="create-new",F(this.data.viewModel.sketchViewModel,t,e)}async _startUpdating(e,t){const{creationInfo:a,viewModel:o}=this.data,{featureFormViewModel:n,layerInfos:s,sketchViewModel:l,view:c}=o;if(!c||!a)return;const d=a.layer,u=I(s,d),h=u?.formTemplate,p=c.spatialReference;return n.set({arcadeEditType:"INSERT",feature:e,formTemplate:h,spatialReference:p,view:c}),r(this._featureFormHandle),this._featureFormHandle=i([n.on("value-change",(async()=>{e.attributes=n.getValues(),await A(e,t)})),l.on(["update","undo","redo"],(e=>{("undo"===e.type||"redo"===e.type||"update"===e.type&&null!=e.toolEventInfo&&b(e.toolEventInfo.type))&&n.notifyFeatureGeometryChanged()}))]),this._removeHighlight(e),this.createFeatureState="update-pending",this._visualVariableAttributes=V(e),k(l,e,d,this._visualVariableAttributes,t)}static _createWorkflowSteps(e,i="awaiting-feature-creation-info"){const{data:d,handles:u}=e;let h=null,p=!0;const f=new Map,m=j(["awaiting-feature-creation-info","creating-features","adding-attachment","editing-attachment"],i,{"awaiting-feature-creation-info":()=>({id:"awaiting-feature-creation-info",async setUp(t){const{creationInfo:a,viewModel:i}=d,{view:r}=i;if(r)if(v(a)){const a=await y({view:r,data:d,signal:t,next:()=>e.next(),cancel:()=>i.cancelWorkflow()});n(t),u.add(a,this.id)}else d.creationInfo=null,u.add(i.featureTemplatesViewModel.on("select",(({item:e})=>{e&&(d.creationInfo=e,i.activeWorkflow?.next())})),this.id)},async tearDown(){u.remove(this.id)}}),"creating-features":()=>({id:"creating-features",async setUp(){if(u.has(this.id))return;const i=d.viewModel.view;if(!i)return;const n=d.viewModel.sketchViewModel;p=n.updateOnGraphicClick,n.updateOnGraphicClick=!1,e._lastActiveGraphics=[],e._featureFormHandle=r(e._featureFormHandle),e._visualVariableAttributes={rotation:null,size:null},U(d.viewModel.attachmentsViewModel);const m="2d"===i.type&&d.creationInfo?e._fadeExistingFeatures(d.creationInfo.layer):null,w=n.on("create",(async t=>{if("cancel"===t.state){if(e._preventDefaultActionOnCancel)return void(e._preventDefaultActionOnCancel=!1);if(e._lastActiveGraphics.length<1)return e._startCreating(f);const t=e._lastActiveGraphics.pop();return e._startUpdating(t,f)}if("complete"===t.state&&t.graphic)return e._startUpdating(t.graphic,f)})),v=n.on("update",(async t=>{const{viewModel:r}=d,{attachmentsViewModel:o,featureFormViewModel:n}=r,l=t.graphics[0];if("complete"===t.state){if(l!==h&&(e._lastActiveGraphics.push(l),e._highlight(l)),h=null,"add"!==o.mode&&"edit"!==o.mode||r.activeWorkflow?.previous(),t.aborted&&e._preventDefaultActionOnCancel)return void(e._preventDefaultActionOnCancel=!1);const c=i.cursor;return i.cursor="progress",u.add([a((()=>i.cursor=c)),i.on("click",(e=>e.preventDefault()))],O),s((()=>!n.updating)).then((()=>{u.remove(O),e._startCreating(f)}))}if("start"===t.state){e._removeHighlight(l),"add"!==o.mode&&"edit"!==o.mode||d.viewModel.activeWorkflow?.previous(),o.fileInfos.removeAll(),o.graphic=l,o.mode="view";(e._attachmentFileInfos.get(l)||[]).forEach((({file:e,form:t})=>o.addFile(e,t)))}const c=e._visualVariableAttributes;await C(i,l,t,c,f);const p=l.attributes,{rotation:m,size:g}=c;if(null!=m){const{field:e}=m;n.setValue(e,p[e])}if(null!=g){const{field:e}=g;n.setValue(e,p[e])}})),y=n.on("delete",(async a=>{const i=a.graphics[0];t(e._lastActiveGraphics,i),h=i}));let _=null;const M=l((()=>{const e=n.snappingOptions.featureSources.find((e=>e.layer===d.creationInfo?.layer));return{hasFeatureLayerSource:!!e,enabled:e?.enabled??!1}}),(({hasFeatureLayerSource:e,enabled:t})=>{const a=n.snappingOptions.featureSources;e?(null==_&&(_=new g({layer:n.layer,enabled:t}),a.add(_)),_.enabled=t):(null!=_&&a.remove(_),_=o(_))}),c),F=i.on("immediate-click",(async t=>{const{results:a}=await i.hitTest(t,{include:n.layer}),r=a.find((e=>"graphic"===e.type));if(r){const t=r.graphic;if("transform"===n.activeTool||"reshape"===n.activeTool){if(n.updateGraphics.getItemAt(0)===t)return;await e.updatePendingFeature(t,f)}}})),I=l((()=>d.viewModel.attachmentsViewModel.mode),(e=>{"add"===e&&d.viewModel.activeWorkflow.go("adding-attachment"),"edit"===e&&d.viewModel.activeWorkflow.go("editing-attachment")}));await e._startCreating(f);const A={remove:()=>{r(e._featureFormHandle),w.remove(),v.remove(),y.remove(),M.remove(),null!=_&&n.snappingOptions.featureSources.remove(_),_=o(_),n.cancel(),F.remove(),I.remove(),r(m)}};u.add(A,this.id)},async tearDown(t){t.canceled&&(d.viewModel.sketchViewModel.layer.removeAll(),u.remove([this.id,O]),d.viewModel.attachmentsViewModel.fileInfos.removeAll(),e._attachmentFileInfos.clear(),d.viewModel.sketchViewModel.updateOnGraphicClick=p)}}),"adding-attachment":()=>({id:"adding-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{graphic:t,fileInfos:a}=d.viewModel.attachmentsViewModel;e._attachmentFileInfos.set(t,a.toArray()),d.viewModel.attachmentsViewModel.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{graphic:t,fileInfos:a}=d.viewModel.attachmentsViewModel;e._attachmentFileInfos.set(t,a.toArray()),d.viewModel.attachmentsViewModel.mode="view"}})});return S(d,m)}};function H(e,t,a,i){const r=[];return t.forEach(((t,o)=>{if(!t.error){const n=e[o],s=i.get(n)||[];n.attributes[a.objectIdField]=t.objectId,s.forEach((({form:e})=>r.push({feature:n,attachment:e})))}})),r}function D(e,t,a){const i=[],r=t.globalIdField;return e.forEach(((t,o)=>{e[o].attributes[r]??=d(),(a?.get(t)||[]).forEach((({file:e})=>i.push({feature:t,attachment:{globalId:d(),data:e}})))})),i.length?{addFeatures:e,addAttachments:i}:{addFeatures:e}}e([u()],G.prototype,"hasPendingEdits",null),e([u()],G.prototype,"helpMessage",null),e([u()],G.prototype,"reliesOnOwnerAdminPrivileges",null),e([u()],G.prototype,"shouldShowAttachments",null),e([u()],G.prototype,"shouldAllowAttachmentEditing",null),G=E=e([h("esri.widgets.Editor.CreateFeaturesWorkflow")],G);const T=G;export{T as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import{remove as t}from"../../core/arrayUtils.js";import{makeHandle as a,handlesGroup as i}from"../../core/handleUtils.js";import{removeMaybe as r,destroyMaybe as n}from"../../core/maybe.js";import{throwIfAborted as o}from"../../core/promiseUtils.js";import{whenOnce as s,watch as l,syncAndInitial as c}from"../../core/reactiveUtils.js";import{generateBracedUUID as d}from"../../core/uuid.js";import{property as u}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/has.js";import{subclass as h}from"../../core/accessorSupport/decorators/subclass.js";import{getEffectiveLayerCapabilities as p,getEffectiveEditingEnabled as f}from"../../layers/support/layerUtils.js";import{getDrawHelpMessage as m}from"../../views/draw/support/helpMessageUtils.js";import g from"../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{CreateFeaturesWorkflowData as w}from"./CreateFeaturesWorkflowData.js";import{isModelUpload as v,waitForModelUpload as y}from"./modelUploadUtils.js";import _ from"./Workflow.js";import{shouldShowAttachmentsForCreateWorkflow as M,startCreatingNewFeature as F,findLayerInfo as I,updateGraphicSymbolWhenRequired as b,isTerminalUpdateEventType as A,getVisualVariableAttributes as k,startUpdatingFeature as V,createWorkflowSteps as j,avoidFeatureTemplateSelectionWithOnlyOneItem as S,prepareAttachmentsForCreateWorkflow as C,showProgressCursor as E,visualVariableInteractiveUpdate as U}from"./workflowUtils.js";var O;const G=Symbol();let H=O=class extends _{constructor(e){super(e),this.type="create-features",this.createFeatureState="create-new",this._featureFormHandle=null,this._visualVariableAttributes={rotation:null,size:null},this._attachmentFileInfos=new Map,this._highlightHandles=new Map,this._preventDefaultActionOnCancel=!1,this._lastActiveGraphics=[]}get hasPendingEdits(){if(this.numPendingFeatures)return!0;const{data:e}=this,{upload:t}=e;return!(!t||t.error)||!!e.creationInfo?.geometryToPlace}get helpMessage(){const{creationInfo:e,viewModel:t}=this.data;if("creating-features"!==this.stepId||!e)return;const a=e.layer.geometryType,i=t.sketchViewModel.createGraphic?.geometry;return m(a,i,t.view)}get numPendingFeatures(){return this.pendingFeatures.length}get pendingFeatures(){return this.data.viewModel.sketchViewModel.layer.graphics}get keyboardCancellationEnabled(){return 0===this.numPendingFeatures}get reliesOnOwnerAdminPrivileges(){const{creationInfo:e}=this.data;if(!e)return!1;const{layer:t}=e,a=t.capabilities?.operations.supportsAdd,i=p(t)?.operations.supportsAdd;return f(t)&&!t.editingEnabled||!!i&&!a}get shouldShowAttachments(){return!!(this.data&&this.data.creationInfo&&this.data.viewModel)&&M(this.data)}get shouldAllowAttachmentEditing(){return this.shouldShowAttachments}get test(){return{addAttachment:(e,t)=>{this._attachmentFileInfos.set(e,t)}}}async updatePendingFeature(e,a){return this._preventDefaultActionOnCancel=!0,this.data.viewModel.sketchViewModel.cancel(),t(this._lastActiveGraphics,e),this._startUpdating(e,a)}static create(e,t,a,i,r){const n=new O({data:new w({creationInfo:t,viewModel:e}),onCommit:async e=>{const{creationInfo:t,viewModel:a}=e;if(!t)return;t.geometryToPlace&&(e.creationInfo=null);const o=a.sketchViewModel.layer.graphics.toArray(),{layer:s}=t,l=s.capabilities?.editing.supportsGlobalId&&"globalIdField"in s,c=n._attachmentFileInfos;if(l){const e=T(o,s,c);return void await i(s,e,{globalIdUsed:!0})}const d=await i(s,{addFeatures:o});if(c.size>0){const e=d?.addFeatureResults??[];await r(s,D(o,e,s,c))}}});return n._set("steps",this._createWorkflowSteps(n,a)),n}_fadeExistingFeatures(e){if("effect"in e){const t=e.effect;return e.effect="saturate(0.6) opacity(0.8)",a((()=>e.effect=t))}const t=e.opacity;return e.opacity=.7,a((()=>e.opacity=t))}_highlight(e){const t=this.data.viewModel.view;"3d"===t?.type&&this._highlightHandles.set(e,t.highlight(e))}_removeHighlight(e){r(this._highlightHandles.get(e)),this._highlightHandles.delete(e)}async _startCreating(e){const{data:t}=this,{creationInfo:a}=t;if(a)return this.createFeatureState="create-new",F(t.viewModel.sketchViewModel,a,e)}async _startUpdating(e,t){const{creationInfo:a,viewModel:n}=this.data,{featureFormViewModel:o,layerInfos:s,sketchViewModel:l,view:c}=n;if(!c||!a)return;const d=a.layer,u=I(s,d),h=u?.formTemplate,p=c.spatialReference;return o.set({arcadeEditType:"INSERT",feature:e,formTemplate:h,spatialReference:p,view:c}),r(this._featureFormHandle),this._featureFormHandle=i([o.on("value-change",(async()=>{e.attributes=o.getValues(),await b(e,t)})),l.on(["update","undo","redo"],(e=>{("undo"===e.type||"redo"===e.type||"update"===e.type&&null!=e.toolEventInfo&&A(e.toolEventInfo.type))&&o.notifyFeatureGeometryChanged()}))]),this._removeHighlight(e),this.createFeatureState="update-pending",this._visualVariableAttributes=k(e),V(l,e,d,this._visualVariableAttributes,t)}static _createWorkflowSteps(e,d="awaiting-feature-creation-info"){const{data:u,handles:h}=e;let p=null,f=!0;const m=new Map,w=j(["awaiting-feature-creation-info","creating-features","adding-attachment","editing-attachment"],d,{"awaiting-feature-creation-info":()=>({id:"awaiting-feature-creation-info",async setUp(t){const{creationInfo:a,viewModel:i}=u,{view:r}=i;if(r)if(v(a)){const a=await y({view:r,data:u,signal:t,next:()=>e.next(),cancel:()=>i.cancelWorkflow()});o(t),h.add(a,this.id)}else u.creationInfo=null,h.add(i.featureTemplatesViewModel.on("select",(({item:e})=>{e&&(u.creationInfo=e,i.activeWorkflow?.next())})),this.id)},async tearDown(){h.remove(this.id)}}),"creating-features":()=>({id:"creating-features",async setUp(){if(h.has(this.id))return;const o=u.viewModel.view;if(!o)return;const d=u.viewModel.sketchViewModel;f=d.updateOnGraphicClick,d.updateOnGraphicClick=!1,e._lastActiveGraphics=[],e._featureFormHandle=r(e._featureFormHandle),e._visualVariableAttributes={rotation:null,size:null},C(u.viewModel.attachmentsViewModel);const w="2d"===o.type&&u.creationInfo?e._fadeExistingFeatures(u.creationInfo.layer):null,v=d.on("create",(async t=>{if("cancel"===t.state){if(e._preventDefaultActionOnCancel)return void(e._preventDefaultActionOnCancel=!1);if(e._lastActiveGraphics.length<1)return e._startCreating(m);const t=e._lastActiveGraphics.pop();return e._startUpdating(t,m)}if("complete"===t.state&&t.graphic)return e._startUpdating(t.graphic,m)})),y=d.on("update",(async t=>{const{viewModel:a}=u,{attachmentsViewModel:i,featureFormViewModel:r}=a,n=t.graphics[0];if("complete"===t.state)return n!==p&&(e._lastActiveGraphics.push(n),e._highlight(n)),p=null,"add"!==i.mode&&"edit"!==i.mode||a.activeWorkflow?.previous(),t.aborted&&e._preventDefaultActionOnCancel?void(e._preventDefaultActionOnCancel=!1):(h.add([E(o),o.on("click",(e=>e.preventDefault()))],G),s((()=>!r.updating)).then((()=>{h.remove(G),e._startCreating(m)})));if("start"===t.state){e._removeHighlight(n),"add"!==i.mode&&"edit"!==i.mode||u.viewModel.activeWorkflow?.previous(),i.fileInfos.removeAll(),i.graphic=n,i.mode="view";(e._attachmentFileInfos.get(n)||[]).forEach((({file:e,form:t})=>i.addFile(e,t)))}const l=e._visualVariableAttributes;await U(o,n,t,l,m);const c=n.attributes,{rotation:d,size:f}=l;if(null!=d){const{field:e}=d;r.setValue(e,c[e])}if(null!=f){const{field:e}=f;r.setValue(e,c[e])}})),_=d.on("delete",(async a=>{const i=a.graphics[0];t(e._lastActiveGraphics,i),p=i}));let M=null;const F=i([l((()=>{const e=d.snappingOptions.featureSources.find((e=>e.layer===u.creationInfo?.layer));return{hasFeatureLayerSource:!!e,enabled:e?.enabled??!1}}),(({hasFeatureLayerSource:e,enabled:t})=>{const a=d.snappingOptions.featureSources;e?(null==M&&(M=new g({layer:d.layer,enabled:t}),a.add(M)),M.enabled=t):(null!=M&&a.remove(M),M=n(M))}),c),a((()=>{null!=M&&(d.snappingOptions.featureSources.remove(M),M=n(M))}))]),I=o.on("immediate-click",(async t=>{const{results:a}=await o.hitTest(t,{include:d.layer}),i=a.find((e=>"graphic"===e.type));if(i){const t=i.graphic;if("transform"===d.activeTool||"reshape"===d.activeTool){if(d.updateGraphics.getItemAt(0)===t)return;await e.updatePendingFeature(t,m)}}})),b=l((()=>u.viewModel.attachmentsViewModel.mode),(e=>{"add"===e&&u.viewModel.activeWorkflow.go("adding-attachment"),"edit"===e&&u.viewModel.activeWorkflow.go("editing-attachment")})),A=E(o);try{await e._startCreating(m)}finally{A.remove()}h.add([A,e._featureFormHandle,v,y,_,F,a((()=>d.cancel())),I,b,w],this.id)},async tearDown(t){t.canceled&&(u.viewModel.sketchViewModel.layer.removeAll(),h.remove([this.id,G]),u.viewModel.attachmentsViewModel.fileInfos.removeAll(),e._attachmentFileInfos.clear(),u.viewModel.sketchViewModel.updateOnGraphicClick=f)}}),"adding-attachment":()=>({id:"adding-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{graphic:t,fileInfos:a}=u.viewModel.attachmentsViewModel;e._attachmentFileInfos.set(t,a.toArray()),u.viewModel.attachmentsViewModel.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{graphic:t,fileInfos:a}=u.viewModel.attachmentsViewModel;e._attachmentFileInfos.set(t,a.toArray()),u.viewModel.attachmentsViewModel.mode="view"}})});return S(u,w)}};function D(e,t,a,i){const r=[];return t.forEach(((t,n)=>{if(!t.error){const o=e[n],s=i.get(o)||[];o.attributes[a.objectIdField]=t.objectId,s.forEach((({form:e})=>r.push({feature:o,attachment:e})))}})),r}function T(e,t,a){const i=[],r=t.globalIdField;return e.forEach(((t,n)=>{e[n].attributes[r]??=d(),(a?.get(t)||[]).forEach((({file:e})=>i.push({feature:t,attachment:{globalId:d(),data:e}})))})),i.length?{addFeatures:e,addAttachments:i}:{addFeatures:e}}e([u()],H.prototype,"hasPendingEdits",null),e([u()],H.prototype,"helpMessage",null),e([u()],H.prototype,"keyboardCancellationEnabled",null),e([u()],H.prototype,"reliesOnOwnerAdminPrivileges",null),e([u()],H.prototype,"shouldShowAttachments",null),e([u()],H.prototype,"shouldAllowAttachmentEditing",null),H=O=e([h("esri.widgets.Editor.CreateFeaturesWorkflow")],H);const P=H;export{P as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import{watch as t}from"../../core/reactiveUtils.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import{getEffectiveLayerCapabilities as o,getEffectiveEditingEnabled as r}from"../../layers/support/layerUtils.js";import{getDrawHelpMessage as s}from"../../views/draw/support/helpMessageUtils.js";import n from"./CreateWorkflowData.js";import{Edits as d}from"./Edits.js";import l from"./Workflow.js";import{shouldShowAttachmentsForCreateWorkflow as c,createWorkflowSteps as w,avoidFeatureTemplateSelectionWithOnlyOneItem as p,setUpFeatureAdd as u,findLayerInfo as f,prepareAttachmentsForCreateWorkflow as m,getVisualVariableAttributes as h,startUpdatingFeature as g,visualVariableInteractiveUpdate as v,updateGraphicSymbolWhenRequired as M}from"./workflowUtils.js";var y;let V=y=class extends l{constructor(e){super(e),this.type="create"}get shouldShowAttachments(){return!!(this.data&&this.data.creationInfo&&this.data.viewModel)&&c(this.data)}get shouldAllowAttachmentEditing(){return this.shouldShowAttachments}get helpMessage(){if("editing-new-feature"!==this.stepId)return;const{creationInfo:e,viewModel:t}=this.data,a=t.sketchViewModel.createGraphic?.geometry,i=e.layer.geometryType;return s(i,a,t.view)}get reliesOnOwnerAdminPrivileges(){const{layer:e}=this.data.creationInfo,t=e.capabilities?.operations.supportsAdd,a=o(e)?.operations.supportsAdd;return r(e)&&!e.editingEnabled||!!a&&!t}static create(e,t,a){const i=new y({data:new n({edits:new d,viewModel:e}),onCommit:async e=>{await a(e.creationInfo.layer,{addFeatures:[e.edits.feature]})}});return i._set("steps",this._createWorkflowSteps(i,t)),i}static _createWorkflowSteps(e,a="awaiting-feature-creation-info"){const{data:i,handles:o}=e,r=new Map,s=w(["awaiting-feature-creation-info","awaiting-feature-to-create","editing-new-feature","adding-attachment","editing-attachment"],a,{"awaiting-feature-creation-info":()=>({id:"awaiting-feature-creation-info",async setUp(){i.creationInfo=null,i.edits.feature=null,i.viewModel.featureTemplatesViewModel.select(null),o.add(i.viewModel.featureTemplatesViewModel.on("select",(({item:e})=>{e&&(i.creationInfo=e,i.viewModel.activeWorkflow?.next())})),this.id)},async tearDown(){o.remove(this.id)}}),"awaiting-feature-to-create":()=>({id:"awaiting-feature-to-create",async setUp(){o.add(await u(i.viewModel.sketchViewModel,i.creationInfo,(e=>{i.edits.feature=e,i.viewModel.activeWorkflow?.next()}),r),this.id)},async tearDown(){o.remove(this.id)}}),"editing-new-feature":()=>({id:"editing-new-feature",async setUp(){const e=i.edits.feature,a=e.sourceLayer,s=i.viewModel,n=s.sketchViewModel,d=f(s.layerInfos,a),l=d?.formTemplate,{spatialReference:c}=s.view;s.featureFormViewModel.set({arcadeEditType:"INSERT",feature:e,formTemplate:l,spatialReference:c}),n.allowDeleteKey=!1,m(s.attachmentsViewModel);const w=h(e);await g(n,e,a,w,r);const p=n.on("update",(async e=>{const t=e.graphics[0];if("complete"===e.state)return g(n,t,a,w,r);await v(n.view,t,e,w,r);const i=t.attributes;if(null!=w.rotation){const{field:e}=w.rotation;s.featureFormViewModel.setValue(e,i[e])}if(null!=w.size){const{field:e}=w.size;s.featureFormViewModel.setValue(e,i[e])}}));o.add([i.viewModel.featureFormViewModel.on("value-change",(async()=>{i.edits.updateAttributes(i.viewModel.featureFormViewModel.getValues()),e.attributes=i.edits.feature.attributes,"3d"===n.view.type&&await M(e,r)})),p,t((()=>i.viewModel.attachmentsViewModel.mode),(e=>{"add"===e&&i.viewModel.activeWorkflow.go("adding-attachment"),"edit"===e&&i.viewModel.activeWorkflow.go("editing-attachment")}))],this.id)},async tearDown(e){e.canceled&&i.viewModel.sketchViewModel.layer.removeAll(),o.remove(this.id)}}),"adding-attachment":()=>({id:"adding-attachment",parent:"editing-new-feature",async setUp(){},async tearDown(){i.viewModel.attachmentsViewModel.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"editing-new-feature",async setUp(){},async tearDown(){i.viewModel.attachmentsViewModel.mode="view"}})});return p(i,s)}};e([a()],V.prototype,"shouldShowAttachments",null),e([a()],V.prototype,"shouldAllowAttachmentEditing",null),e([a()],V.prototype,"helpMessage",null),e([a()],V.prototype,"reliesOnOwnerAdminPrivileges",null),V=y=e([i("esri.widgets.Editor.CreateWorkflow")],V);const k=V;export{k as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import{watch as t}from"../../core/reactiveUtils.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import{getEffectiveLayerCapabilities as o,getEffectiveEditingEnabled as r}from"../../layers/support/layerUtils.js";import{getDrawHelpMessage as s}from"../../views/draw/support/helpMessageUtils.js";import n from"./CreateWorkflowData.js";import{Edits as d}from"./Edits.js";import l from"./Workflow.js";import{shouldShowAttachmentsForCreateWorkflow as c,createWorkflowSteps as w,avoidFeatureTemplateSelectionWithOnlyOneItem as p,setUpFeatureAdd as u,findLayerInfo as f,prepareAttachmentsForCreateWorkflow as m,getVisualVariableAttributes as h,startUpdatingFeature as g,visualVariableInteractiveUpdate as v,updateGraphicSymbolWhenRequired as y}from"./workflowUtils.js";var M;let V=M=class extends l{constructor(e){super(e),this.type="create"}get shouldShowAttachments(){return!!(this.data&&this.data.creationInfo&&this.data.viewModel)&&c(this.data)}get shouldAllowAttachmentEditing(){return this.shouldShowAttachments}get hasPendingEdits(){return!0}get helpMessage(){if("editing-new-feature"!==this.stepId)return;const{creationInfo:e,viewModel:t}=this.data,a=t.sketchViewModel.createGraphic?.geometry,i=e.layer.geometryType;return s(i,a,t.view)}get reliesOnOwnerAdminPrivileges(){const{layer:e}=this.data.creationInfo,t=e.capabilities?.operations.supportsAdd,a=o(e)?.operations.supportsAdd;return r(e)&&!e.editingEnabled||!!a&&!t}static create(e,t,a){const i=new M({data:new n({edits:new d,viewModel:e}),onCommit:async e=>{await a(e.creationInfo.layer,{addFeatures:[e.edits.feature]})}});return i._set("steps",this._createWorkflowSteps(i,t)),i}static _createWorkflowSteps(e,a="awaiting-feature-creation-info"){const{data:i,handles:o}=e,r=new Map,s=w(["awaiting-feature-creation-info","awaiting-feature-to-create","editing-new-feature","adding-attachment","editing-attachment"],a,{"awaiting-feature-creation-info":()=>({id:"awaiting-feature-creation-info",async setUp(){i.creationInfo=null,i.edits.feature=null,i.viewModel.featureTemplatesViewModel.select(null),o.add(i.viewModel.featureTemplatesViewModel.on("select",(({item:e})=>{e&&(i.creationInfo=e,i.viewModel.activeWorkflow?.next())})),this.id)},async tearDown(){o.remove(this.id)}}),"awaiting-feature-to-create":()=>({id:"awaiting-feature-to-create",async setUp(){o.add(await u(i.viewModel.sketchViewModel,i.creationInfo,(e=>{i.edits.feature=e,i.viewModel.activeWorkflow?.next()}),r),this.id)},async tearDown(){o.remove(this.id)}}),"editing-new-feature":()=>({id:"editing-new-feature",async setUp(){const e=i.edits.feature,a=e.sourceLayer,s=i.viewModel,n=s.sketchViewModel,d=f(s.layerInfos,a),l=d?.formTemplate,{spatialReference:c}=s.view;s.featureFormViewModel.set({arcadeEditType:"INSERT",feature:e,formTemplate:l,spatialReference:c}),n.allowDeleteKey=!1,m(s.attachmentsViewModel);const w=h(e);await g(n,e,a,w,r);const p=n.on("update",(async e=>{const t=e.graphics[0];if("complete"===e.state)return g(n,t,a,w,r);await v(n.view,t,e,w,r);const i=t.attributes;if(null!=w.rotation){const{field:e}=w.rotation;s.featureFormViewModel.setValue(e,i[e])}if(null!=w.size){const{field:e}=w.size;s.featureFormViewModel.setValue(e,i[e])}}));o.add([i.viewModel.featureFormViewModel.on("value-change",(async()=>{i.edits.updateAttributes(i.viewModel.featureFormViewModel.getValues()),e.attributes=i.edits.feature.attributes,"3d"===n.view.type&&await y(e,r)})),p,t((()=>i.viewModel.attachmentsViewModel.mode),(e=>{"add"===e&&i.viewModel.activeWorkflow.go("adding-attachment"),"edit"===e&&i.viewModel.activeWorkflow.go("editing-attachment")}))],this.id)},async tearDown(e){e.canceled&&i.viewModel.sketchViewModel.layer.removeAll(),o.remove(this.id)}}),"adding-attachment":()=>({id:"adding-attachment",parent:"editing-new-feature",async setUp(){},async tearDown(){i.viewModel.attachmentsViewModel.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"editing-new-feature",async setUp(){},async tearDown(){i.viewModel.attachmentsViewModel.mode="view"}})});return p(i,s)}};e([a()],V.prototype,"shouldShowAttachments",null),e([a()],V.prototype,"shouldAllowAttachmentEditing",null),e([a()],V.prototype,"hasPendingEdits",null),e([a()],V.prototype,"helpMessage",null),e([a()],V.prototype,"reliesOnOwnerAdminPrivileges",null),V=M=e([i("esri.widgets.Editor.CreateWorkflow")],V);const k=V;export{k as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../chunks/tslib.es6.js";import{createTask as e}from"../../core/asyncUtils.js";import a from"../../core/Collection.js";import{deprecated as r}from"../../core/deprecate.js";import i from"../../core/Error.js";import s from"../../core/Evented.js";import{HandleOwnerMixin as o}from"../../core/HandleOwner.js";import n from"../../core/Logger.js";import{abortMaybe as l}from"../../core/maybe.js";import{throwIfAborted as d}from"../../core/promiseUtils.js";import{watch as p,on as c,when as u,whenOnce as h,initial as w}from"../../core/reactiveUtils.js";import{property as f}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as m}from"../../core/accessorSupport/decorators/subclass.js";import y from"../../layers/GraphicsLayer.js";import{getOwningPortalUrl as k,getEffectiveLayerCapabilities as g}from"../../layers/support/layerUtils.js";import{parseKnownArcGISOnlineDomain as v}from"../../portal/support/urlUtils.js";import b from"../Attachments/AttachmentsViewModel.js";import _ from"./CreateFeaturesWorkflow.js";import W from"./CreateWorkflow.js";import{workflowDeprecation as C}from"./deprecationUtils.js";import F from"./UpdateWorkflow.js";import{whenEditorLayerView as E}from"./workflowUtils.js";import I from"../FeatureForm/FeatureFormViewModel.js";import U from"../FeatureTemplates/FeatureTemplatesViewModel.js";import A from"../Sketch/SketchViewModel.js";import O from"../Spinner/SpinnerViewModel.js";const V="esri.widgets.Editor.EditorViewModel",M=n.getLogger(V),j=["create","create-features","update"];function T(t,e,a){M.error(new i(t,e,a))}function S(t,e){return t?t.find((t=>t.layer===e)):void 0}let L=class extends(o(s.EventedAccessor)){constructor(t){super(t),this._editableItems=new a,this._sketchGraphicsLayer=new y({listMode:"hide",internal:!0}),this._updateEditableItemsTask=null,this.activeWorkflow=null,this._activityQueue=[],this.failures=[],this.attachmentsViewModel=new b({capabilities:{editing:!0}}),this.featureFormViewModel=new I,this.featureTemplatesViewModel=new U,this.sketchViewModel=new A({layer:this._sketchGraphicsLayer}),this.spinnerViewModel=new O,this.pageStack=[],this.showDiscardEditsPrompt=()=>Promise.resolve(),this._candidateCommitted=!1,this.useDeprecatedCreateWorkflow=!1,this.back=async()=>{const t=this.activeWorkflow;if(t&&this.canGoBack){if(this.hasPendingEdits)try{await this.showDiscardEditsPrompt()}catch(e){return}t.hasPreviousStep?await t.previous({cancelCurrentStep:!0}):await this.cancelWorkflow({force:!0})}},this.saveAndResetWorkflow=async()=>{const{featureFormViewModel:t}=this;if(t.submit(),!t.submittable)return;const e=t.getValues();if(t.validateContingencyConstraints(e,{includeIncompleteViolations:!0}).length>0)return;const{activeWorkflow:a}=this;await(a?.commit()),a?.reset()},this.selectFeature=(t,e=!1)=>{const a=this.activeWorkflow;this._candidateCommitted||"update"!==a?.type||(a.data.edits.feature=t,e&&(a.next(),this._candidateCommitted=!0))}}initialize(){this.addHandles([p((()=>{const t=this.view?.map?.editableLayers.filter((({parent:t,visible:e})=>t&&"visible"in t?e&&t.visible:e)),e=this.view?.allLayerViews,a=e?.filter((e=>!!t?.includes(e.layer)&&!e.suspended));return[t,a,this.layerInfos,this.allowedWorkflows]}),(()=>this._updateEditableItems()),w),c((()=>this.activeWorkflow),"cancel",(()=>this.emit("workflow-cancel"))),c((()=>this.activeWorkflow),"commit",(()=>this.emit("workflow-commit"))),u((()=>this.view?.map),(t=>t.add(this._sketchGraphicsLayer)),w),p((()=>this._editableItems.toArray()),(()=>{const{activeWorkflow:t}=this;if(this.refreshCreationTemplates(),!t)return;const{stepId:e}=t;"create"!==t.type?"update"===t.type&&("awaiting-feature-to-update"===e&&!this.canUpdate||"awaiting-update-feature-candidate"===e&&!t.data.candidates.some((t=>{const e=this._editableItems.find((e=>e.layer===t.layer));return e&&e.supports.includes("update")})))&&this._cancelWorkflow():"awaiting-feature-creation-info"!==e||this.canCreate||this._cancelWorkflow()})),p((()=>this.page),((t,e)=>{const a=this.pageStack.slice(),r=a.indexOf(t);-1===r&&e?a.push(e):a.splice(r),this.pageStack=a})),u((()=>"awaiting-update-feature-candidate"===this.state),(()=>this._candidateCommitted=!1)),c((()=>this.featureTemplatesViewModel),"select",(async({item:t,oldItem:e})=>{const{activeWorkflow:a}=this,r=!!t&&t.id===e?.id,i="create-features"===a?.type&&a.data.upload?.error;if(a)try{await this.cancelWorkflow({force:!this.hasPendingEdits})}catch{return this.featureTemplatesViewModel.select(e,{emit:!1})}if(!t||r&&!i)return;const s={layer:t.layer,template:t.template};if(t.supportsUpload)return this.startCreateFeaturesWorkflow(s);this.useDeprecatedCreateWorkflow?this.startCreateWorkflowAtFeatureCreation(s):this.startCreateFeaturesWorkflowAtFeatureCreation(s)}))])}destroy(){this._cancelWorkflow().then((()=>{this.view?.map&&this.view.map.remove(this._sketchGraphicsLayer),this.view=null})),this._updateEditableItemsTask=l(this._updateEditableItemsTask)}get allowedWorkflows(){return this._get("allowedWorkflows")}set allowedWorkflows(t){t&&0!==t.length||(t=[...j]),this._set("allowedWorkflows",t)}get canCreate(){return this._editableItems.some((t=>t.supports.includes("create")))}get canUpdate(){return this._editableItems.some((({attachmentsOnUpdateEnabled:t,layer:e,supports:a})=>{const r=a.includes("update")||a.includes("delete")||t,i=e.parent,s=!(i&&"visible"in i)||!!i.visible;return e.visible&&s&&r}))}get editableItems(){return this._editableItems}get labelOptions(){return this.sketchViewModel.labelOptions}set labelOptions(t){this.sketchViewModel.labelOptions=t}set layerInfos(t){t?.some((t=>("allowAttachments"in t&&r(M,"Property: layerInfo.allowAttachments",{replacement:"layerInfo.attachmentsOnCreateEnabled or layerInfo.attachmentsOnUpdateEnabled",version:"4.26"}),!0))),this._set("layerInfos",t)}get snappingOptions(){return this.sketchViewModel.snappingOptions}set snappingOptions(t){this.sketchViewModel.snappingOptions=t}get state(){if(!this.get("view.ready")||0===this._editableItems.length)return"disabled";const t=this.attachmentsViewModel.mode;if("add"===t)return"adding-attachment";if("edit"===t)return"editing-attachment";const{activeWorkflow:e}=this;return e?e.stepId:"ready"}get syncing(){return this._activityQueue.length>0}get updating(){return this.updatingHandles.updating}get tooltipOptions(){return this.sketchViewModel.tooltipOptions}set tooltipOptions(t){this.sketchViewModel.tooltipOptions=t}set view(t){this.sketchViewModel.view=t,this.spinnerViewModel.view=t,this._set("view",t)}get page(){const{activeWorkflow:t,state:e}=this;return"awaiting-feature-to-update"===e||"awaiting-feature-to-create"===e||"create-features"===t?.type&&0===t.numPendingFeatures?"ready":e??"disabled"}get selectedTemplateItem(){const{activeWorkflow:t}=this;if("create-features"===t?.type&&0===t.numPendingFeatures){const e=t.data.creationInfo?.template;if(!e)return;for(const t of this.featureTemplatesViewModel.items)if("findByTemplate"in t){const a=t.findByTemplate(e);if(a)return a}else if(t.template===e)return t}}get featureFormDisabled(){const{activeWorkflow:t}=this;return"update"===t?.type&&!1===t?.data.editableItem?.attributeUpdatesEnabled}get canGoBack(){return null!=this.activeWorkflow&&!this.syncing}get shouldShowDeleteButton(){const{activeWorkflow:t}=this;return!!t&&"update"===t.type&&t.data.editableItem.supports.includes("delete")}get hasPendingEdits(){const{activeWorkflow:t}=this;return!!t&&("create"===t.type||"create-features"===t.type&&t.hasPendingEdits||"editing-existing-feature"===t.stepId&&t.data.edits.modified)}async startCreateWorkflowAtFeatureTypeSelection(){if(C(M,"startCreateWorkflowAtFeatureTypeSelection","startCreateFeaturesWorkflowAtFeatureTypeSelection"),await h((()=>!this.updating)),!this.canCreate)return void T("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createCreateWorkflow();await t.start(),this._set("activeWorkflow",t)}async startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.startCreateFeaturesWorkflow()}async startCreateWorkflowAtFeatureCreation(t){if(C(M,"startCreateWorkflowAtFeatureCreation","startCreateFeaturesWorkflowAtFeatureCreation"),await h((()=>!this.updating)),!this.canCreate)return void T("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createCreateWorkflow("awaiting-feature-to-create");e.data.creationInfo=t,await e.start(),this._set("activeWorkflow",e)}async startCreateFeaturesWorkflowAtFeatureCreation(t){return this.startCreateFeaturesWorkflow(t,"creating-features")}async startCreateFeaturesWorkflow(t,e="awaiting-feature-creation-info"){if(await h((()=>!this.updating)),!this.canCreate)throw new i("editing:unsupported-workflow","Creating features is unsupported or disabled.");await this._cancelWorkflow();const a=this._createCreateFeaturesWorkflow(t,e);await a.start(),this._set("activeWorkflow",a)}async startCreateWorkflowAtFeatureEdit(t){if(C(M,"startCreateWorkflowAtFeatureEdit"),await h((()=>!this.updating)),!this.canCreate)return void T("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createCreateWorkflow("editing-new-feature");e.data.edits.feature=t,await e.start(),this._set("activeWorkflow",e)}async startUpdateWorkflowAtFeatureSelection(){if(await h((()=>!this.updating)),!this.canUpdate)return void T("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createUpdateWorkflow();await t.start(),this._set("activeWorkflow",t)}async startUpdateWorkflowAtMultipleFeatureSelection(t){if(await h((()=>!this.updating)),!this.canUpdate)return void T("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createUpdateWorkflow("awaiting-update-feature-candidate");e.data.candidates=t,await e.start(),this._set("activeWorkflow",e)}async startUpdateWorkflowAtFeatureEdit(t){if(await h((()=>!this.updating)),!this.canUpdate)return void T("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createUpdateWorkflow("editing-existing-feature");e.data.edits.feature=t,await e.start(),this._set("activeWorkflow",e)}async deleteFeatureFromWorkflow(){const{activeWorkflow:t}=this;t&&"update"===t.type?await t.deleteFeature((async(t,e)=>this._applyEdits(t,e))):T("editing:unsupported-workflow","Deleting requires an active update workflow.")}async cancelWorkflow(t){return this._cancelWorkflow({warn:!0,...t})}findEditableItemForLayer(t){const e="subtype-sublayer"===t.type?t.parent:t;return this._editableItems.find((t=>t.layer===e))}refreshCreationTemplates(){const t=[];for(const{layer:e,supports:a}of this._editableItems)e.loaded&&a.includes("create")&&t.push(e);this.featureTemplatesViewModel.layers=t}async _updateEditableItems(){l(this._updateEditableItemsTask);const t=e((async t=>{const e=this.view?.allLayerViews,r=this.view?.map?.editableLayers;if(!e||!r)return;const i=new Set(r),s=r?.filter((t=>{const e=g(t)?.operations;return!(!t.visible||!e?.supportsAdd||e?.supportsQuery)})),o=e.filter((t=>i.has(t.layer))),n=[];for(const{layer:a,suspended:p}of o.reverse())if("subtype-group"===a.type){await a.loadAll(),d(t);for(let t=a.sublayers.length-1;t>=0;--t)n.push(this._makeEditableItemForLayer(a.sublayers.at(t),p))}else n.push(this._makeEditableItemForLayer(a,p));for(const a of s.reverse())if("subtype-group"===a.type){await a.loadAll(),d(t);for(const t of a.sublayers)n.push(this._makeEditableItemForLayer(t,!1))}else n.push(this._makeEditableItemForLayer(a,!1));if(t.aborted)return;const l=this._editableItems;this._editableItems=new a(n),l.destroy()}));this.updatingHandles.addPromise(t.promise),this._updateEditableItemsTask=t}async _cancelWorkflow(t){const e=this.activeWorkflow;if(!e)return void(t&&t.warn&&T("editing:no-active-workflow","There is no active workflow to cancel."));if(!t||!1!==t.force)return this.emit("workflow-cancel"),this._set("activeWorkflow",null),void await e.cancel(t);await e.cancel(t),this._set("activeWorkflow",null)}_createCreateFeaturesWorkflow(t,e){return _.create(this,t,e,((t,e,a)=>this._applyEdits(t,e,a)),((t,e)=>this._addAttachments(t,e)))}_createCreateWorkflow(t){return W.create(this,t,((t,e,a)=>this._applyEdits(t,e,a)))}_createUpdateWorkflow(t){return F.create(this,t,((t,e)=>this._applyEdits(t,e)))}_addAttachments(t,e){const a=e.map((e=>this._addAttachment(t,e.feature,e.attachment)))??[];return Promise.all(a)}async _addAttachment(t,e,a){let r=null;if("geojson"===t.type||"scene"===t.type||"oriented-imagery"===t.type)throw new i("editor:attachments-not-supported","Adding attachments is not supported for this layer type");return await this._queueOperation((async()=>(r=await(t.addAttachment?.(e,a).catch((t=>{throw t?.error||t})))??null,r))),r}async _applyEdits(t,e,a){let r=null;const i=t.url?await k(t.url):null,s={returnServiceEditsOption:(!i||!v(i))&&!RegExp("/hosted/","i").test(t.url)?"original-and-current-features":void 0,...a};return await this._queueOperation((async()=>{if(g(t)?.operations.supportsQuery){const a=await E(this.view,t);return r=await t.applyEdits(e,s),await h((()=>!a.updating)),r}return r=await t.applyEdits(e,s),r})),r}_queueOperation(t){this._activityQueue.push(t),this.notifyChange("syncing");const e=(t,e)=>{const a=e.indexOf(t);a>-1&&e.splice(a,1)};return t().then((t=>{if("error"in t&&t.error)throw t.error;if("addFeatureResults"in t){const{addFeatureResults:e,deleteFeatureResults:a,updateFeatureResults:r}=t,i=e.find((t=>!!t.error))||r.find((t=>!!t.error))||a.find((t=>!!t.error));if(i)throw i.error}return t})).catch((a=>{T("editing:operation-error","An error occurred.",{error:a});const r={error:a,retry:()=>(e(r,this.failures),this._queueOperation(t)),cancel:()=>{e(r,this.failures)}};this._set("failures",[...this.failures,r])})).then((()=>{e(t,this._activityQueue),this.notifyChange("syncing")}))}_makeEditableItemForLayer(t,e=!0){const a=g(t),r=a?.operations,i=S(this.layerInfos,t),s=this.allowedWorkflows,o=s.includes("create")||s.includes("create-features"),n=s.includes("update"),l=t=>!i||!1!==i.enabled&&!1!==i[t],d=o&&!!r?.supportsAdd&&l("addEnabled"),p=n&&!!r?.supportsUpdate&&l("updateEnabled"),c=n&&!!r?.supportsDelete&&l("deleteEnabled"),u=[];e||(d&&u.push("create"),p&&u.push("update"),c&&u.push("delete"));const h=p&&(!i||!1!==i.attributeUpdatesEnabled),w=p&&!!a?.editing?.supportsGeometryUpdate&&(!i||!1!==i.geometryUpdatesEnabled),f=!(!a?.data?.supportsAttachment||i&&!1===i.allowAttachments);return{layer:t,supports:u,attributeUpdatesEnabled:h,geometryUpdatesEnabled:w,hasAttachments:f,attachmentsOnCreateEnabled:f&&o&&(!i||!1!==i.attachmentsOnCreateEnabled),attachmentsOnUpdateEnabled:f&&(!i||!1!==i.attachmentsOnUpdateEnabled)}}};t([f()],L.prototype,"_editableItems",void 0),t([f({readOnly:!0})],L.prototype,"activeWorkflow",void 0),t([f({readOnly:!0})],L.prototype,"_activityQueue",void 0),t([f({value:[...j]})],L.prototype,"allowedWorkflows",null),t([f({readOnly:!0})],L.prototype,"canCreate",null),t([f({readOnly:!0})],L.prototype,"canUpdate",null),t([f()],L.prototype,"editableItems",null),t([f({readOnly:!0})],L.prototype,"failures",void 0),t([f()],L.prototype,"attachmentsViewModel",void 0),t([f()],L.prototype,"featureFormViewModel",void 0),t([f()],L.prototype,"featureTemplatesViewModel",void 0),t([f()],L.prototype,"labelOptions",null),t([f()],L.prototype,"layerInfos",null),t([f()],L.prototype,"sketchViewModel",void 0),t([f()],L.prototype,"snappingOptions",null),t([f()],L.prototype,"spinnerViewModel",void 0),t([f()],L.prototype,"state",null),t([f({readOnly:!0})],L.prototype,"syncing",null),t([f()],L.prototype,"updating",null),t([f()],L.prototype,"tooltipOptions",null),t([f()],L.prototype,"view",null),t([f()],L.prototype,"pageStack",void 0),t([f()],L.prototype,"showDiscardEditsPrompt",void 0),t([f()],L.prototype,"_candidateCommitted",void 0),t([f()],L.prototype,"page",null),t([f()],L.prototype,"selectedTemplateItem",null),t([f()],L.prototype,"featureFormDisabled",null),t([f()],L.prototype,"canGoBack",null),t([f()],L.prototype,"shouldShowDeleteButton",null),t([f()],L.prototype,"hasPendingEdits",null),t([f()],L.prototype,"useDeprecatedCreateWorkflow",void 0),L=t([m(V)],L);const P=L;export{P as default};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import{createTask as e}from"../../core/asyncUtils.js";import a from"../../core/Collection.js";import{deprecated as r}from"../../core/deprecate.js";import i from"../../core/Error.js";import s from"../../core/Evented.js";import{HandleOwnerMixin as o}from"../../core/HandleOwner.js";import n from"../../core/Logger.js";import{abortMaybe as l}from"../../core/maybe.js";import{throwIfAborted as d}from"../../core/promiseUtils.js";import{watch as p,on as c,when as u,whenOnce as h,initial as w}from"../../core/reactiveUtils.js";import{property as f}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as m}from"../../core/accessorSupport/decorators/subclass.js";import y from"../../layers/GraphicsLayer.js";import{getOwningPortalUrl as k,getEffectiveLayerCapabilities as g}from"../../layers/support/layerUtils.js";import{parseKnownArcGISOnlineDomain as v}from"../../portal/support/urlUtils.js";import b from"../Attachments/AttachmentsViewModel.js";import W from"./CreateFeaturesWorkflow.js";import _ from"./CreateWorkflow.js";import{workflowDeprecation as C}from"./deprecationUtils.js";import E from"./UpdateWorkflow.js";import{whenEditorLayerView as F}from"./workflowUtils.js";import I from"../FeatureForm/FeatureFormViewModel.js";import U from"../FeatureTemplates/FeatureTemplatesViewModel.js";import A from"../Sketch/SketchViewModel.js";import O from"../Spinner/SpinnerViewModel.js";const V="esri.widgets.Editor.EditorViewModel",M=n.getLogger(V),j=["create","create-features","update"];function T(t,e,a){M.error(new i(t,e,a))}function S(t,e){return t?t.find((t=>t.layer===e)):void 0}let L=class extends(o(s.EventedAccessor)){constructor(t){super(t),this._editableItems=new a,this._sketchGraphicsLayer=new y({listMode:"hide",internal:!0}),this._updateEditableItemsTask=null,this.activeWorkflow=null,this._activityQueue=[],this.failures=[],this.attachmentsViewModel=new b({capabilities:{editing:!0}}),this.featureFormViewModel=new I,this.featureTemplatesViewModel=new U,this.sketchViewModel=new A({layer:this._sketchGraphicsLayer}),this.spinnerViewModel=new O,this.pageStack=[],this.showDiscardEditsPrompt=()=>Promise.resolve(!0),this._candidateCommitted=!1,this.useDeprecatedCreateWorkflow=!1,this.back=async()=>{const t=this.activeWorkflow;t&&this.canGoBack&&(this.hasPendingEdits&&!await this.showDiscardEditsPrompt()||(t.hasPreviousStep?await t.previous({cancelCurrentStep:!0}):await this.cancelWorkflow({force:!0})))},this.saveAndResetWorkflow=async()=>{const{featureFormViewModel:t}=this;if(t.submit(),!t.submittable)return;const e=t.getValues();if(t.validateContingencyConstraints(e,{includeIncompleteViolations:!0}).length>0)return;const{activeWorkflow:a}=this;await(a?.commit()),a?.reset()},this.selectFeature=(t,e=!1)=>{const a=this.activeWorkflow;this._candidateCommitted||"update"!==a?.type||(a.data.edits.feature=t,e&&(a.next(),this._candidateCommitted=!0))}}initialize(){this.addHandles([p((()=>{const t=this.view?.map?.editableLayers.filter((({parent:t,visible:e})=>t&&"visible"in t?e&&t.visible:e)),e=this.view?.allLayerViews,a=e?.filter((e=>!!t?.includes(e.layer)&&!e.suspended));return[t,a,this.layerInfos,this.allowedWorkflows]}),(()=>this._updateEditableItems()),w),c((()=>this.activeWorkflow),"cancel",(()=>this.emit("workflow-cancel"))),c((()=>this.activeWorkflow),"commit",(()=>this.emit("workflow-commit"))),u((()=>this.view?.map),(t=>t.add(this._sketchGraphicsLayer)),w),p((()=>this._editableItems.toArray()),(()=>{const{activeWorkflow:t}=this;if(this.refreshCreationTemplates(),!t)return;const{stepId:e}=t;"create"!==t.type?"update"===t.type&&("awaiting-feature-to-update"===e&&!this.canUpdate||"awaiting-update-feature-candidate"===e&&!t.data.candidates.some((t=>{const e=this._editableItems.find((e=>e.layer===t.layer));return e&&e.supports.includes("update")})))&&this._cancelWorkflow():"awaiting-feature-creation-info"!==e||this.canCreate||this._cancelWorkflow()})),p((()=>this.page),((t,e)=>{const a=this.pageStack.slice(),r=a.indexOf(t);-1===r&&e?a.push(e):a.splice(r),this.pageStack=a})),u((()=>"awaiting-update-feature-candidate"===this.state),(()=>this._candidateCommitted=!1)),c((()=>this.featureTemplatesViewModel),"select",(async({item:t,oldItem:e})=>{const{activeWorkflow:a}=this,r=!!t&&t.id===e?.id,i="create-features"===a?.type&&a.data.upload?.error;if(a)try{await this.cancelWorkflow({force:!this.hasPendingEdits})}catch{return this.featureTemplatesViewModel.select(e,{emit:!1})}if(!t||r&&!i)return;const s={layer:t.layer,template:t.template};if(t.supportsUpload)return this.startCreateFeaturesWorkflow(s);this.useDeprecatedCreateWorkflow?this.startCreateWorkflowAtFeatureCreation(s):this.startCreateFeaturesWorkflowAtFeatureCreation(s)})),c((()=>this.view),"key-down",(t=>{"Escape"===t.key&&this.activeWorkflow?.keyboardCancellationEnabled&&this.back()}))])}destroy(){this._cancelWorkflow().then((()=>{this.view?.map&&this.view.map.remove(this._sketchGraphicsLayer),this.view=null})),this._updateEditableItemsTask=l(this._updateEditableItemsTask)}get allowedWorkflows(){return this._get("allowedWorkflows")}set allowedWorkflows(t){t&&0!==t.length||(t=[...j]),this._set("allowedWorkflows",t)}get canCreate(){return this._editableItems.some((t=>t.supports.includes("create")))}get canUpdate(){return this._editableItems.some((({attachmentsOnUpdateEnabled:t,layer:e,supports:a})=>{const r=a.includes("update")||a.includes("delete")||t,i=e.parent,s=!(i&&"visible"in i)||!!i.visible;return e.visible&&s&&r}))}get editableItems(){return this._editableItems}get labelOptions(){return this.sketchViewModel.labelOptions}set labelOptions(t){this.sketchViewModel.labelOptions=t}set layerInfos(t){t?.some((t=>("allowAttachments"in t&&r(M,"Property: layerInfo.allowAttachments",{replacement:"layerInfo.attachmentsOnCreateEnabled or layerInfo.attachmentsOnUpdateEnabled",version:"4.26"}),!0))),this._set("layerInfos",t)}get snappingOptions(){return this.sketchViewModel.snappingOptions}set snappingOptions(t){this.sketchViewModel.snappingOptions=t}get state(){if(!this.get("view.ready")||0===this._editableItems.length)return"disabled";const t=this.attachmentsViewModel.mode;if("add"===t)return"adding-attachment";if("edit"===t)return"editing-attachment";const{activeWorkflow:e}=this;return e?e.stepId:"ready"}get syncing(){return this._activityQueue.length>0}get updating(){return this.updatingHandles.updating}get tooltipOptions(){return this.sketchViewModel.tooltipOptions}set tooltipOptions(t){this.sketchViewModel.tooltipOptions=t}set view(t){this.sketchViewModel.view=t,this.spinnerViewModel.view=t,this._set("view",t)}get page(){const{activeWorkflow:t,state:e}=this;return"awaiting-feature-to-update"===e||"awaiting-feature-to-create"===e||"create-features"===t?.type&&0===t.numPendingFeatures?"ready":e??"disabled"}get selectedTemplateItem(){const{activeWorkflow:t}=this;if("create-features"===t?.type&&0===t.numPendingFeatures){const e=t.data.creationInfo?.template;if(!e)return;for(const t of this.featureTemplatesViewModel.items)if("findByTemplate"in t){const a=t.findByTemplate(e);if(a)return a}else if(t.template===e)return t}}get featureFormDisabled(){const{activeWorkflow:t}=this;return"update"===t?.type&&!1===t?.data.editableItem?.attributeUpdatesEnabled}get canGoBack(){return null!=this.activeWorkflow&&!this.syncing}get shouldShowDeleteButton(){const{activeWorkflow:t}=this;return!!t&&"update"===t.type&&t.data.editableItem.supports.includes("delete")}get hasPendingEdits(){return this.activeWorkflow?.hasPendingEdits??!1}async startCreateWorkflowAtFeatureTypeSelection(){if(C(M,"startCreateWorkflowAtFeatureTypeSelection","startCreateFeaturesWorkflowAtFeatureTypeSelection"),await h((()=>!this.updating)),!this.canCreate)return void T("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createCreateWorkflow();await t.start(),this._set("activeWorkflow",t)}async startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.startCreateFeaturesWorkflow()}async startCreateWorkflowAtFeatureCreation(t){if(C(M,"startCreateWorkflowAtFeatureCreation","startCreateFeaturesWorkflowAtFeatureCreation"),await h((()=>!this.updating)),!this.canCreate)return void T("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createCreateWorkflow("awaiting-feature-to-create");e.data.creationInfo=t,await e.start(),this._set("activeWorkflow",e)}async startCreateFeaturesWorkflowAtFeatureCreation(t){return this.startCreateFeaturesWorkflow(t,"creating-features")}async startCreateFeaturesWorkflow(t,e="awaiting-feature-creation-info"){if(await h((()=>!this.updating)),!this.canCreate)throw new i("editing:unsupported-workflow","Creating features is unsupported or disabled.");await this._cancelWorkflow();const a=this._createCreateFeaturesWorkflow(t,e);await a.start(),this._set("activeWorkflow",a)}async startCreateWorkflowAtFeatureEdit(t){if(C(M,"startCreateWorkflowAtFeatureEdit"),await h((()=>!this.updating)),!this.canCreate)return void T("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createCreateWorkflow("editing-new-feature");e.data.edits.feature=t,await e.start(),this._set("activeWorkflow",e)}async startUpdateWorkflowAtFeatureSelection(){if(await h((()=>!this.updating)),!this.canUpdate)return void T("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createUpdateWorkflow();await t.start(),this._set("activeWorkflow",t)}async startUpdateWorkflowAtMultipleFeatureSelection(t){if(await h((()=>!this.updating)),!this.canUpdate)return void T("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createUpdateWorkflow("awaiting-update-feature-candidate");e.data.candidates=t,await e.start(),this._set("activeWorkflow",e)}async startUpdateWorkflowAtFeatureEdit(t){if(await h((()=>!this.updating)),!this.canUpdate)return void T("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createUpdateWorkflow("editing-existing-feature");e.data.edits.feature=t,await e.start(),this._set("activeWorkflow",e)}async deleteFeatureFromWorkflow(){const{activeWorkflow:t}=this;t&&"update"===t.type?await t.deleteFeature((async(t,e)=>this._applyEdits(t,e))):T("editing:unsupported-workflow","Deleting requires an active update workflow.")}async cancelWorkflow(t){return this._cancelWorkflow({warn:!0,...t})}findEditableItemForLayer(t){const e="subtype-sublayer"===t.type?t.parent:t;return this._editableItems.find((t=>t.layer===e))}refreshCreationTemplates(){const t=[];for(const{layer:e,supports:a}of this._editableItems)e.loaded&&a.includes("create")&&t.push(e);this.featureTemplatesViewModel.layers=t}async toggleUpdateWorkflow(){this.canUpdate&&(this.hasPendingEdits&&!await this.showDiscardEditsPrompt()||(this.activeWorkflow&&"awaiting-feature-to-update"===this.state?await this.cancelWorkflow({force:!1}):await this.startUpdateWorkflowAtFeatureSelection()))}async _updateEditableItems(){l(this._updateEditableItemsTask);const t=e((async t=>{const e=this.view?.allLayerViews,r=this.view?.map?.editableLayers;if(!e||!r)return;const i=new Set(r),s=r?.filter((t=>{const e=g(t)?.operations;return!(!t.visible||!e?.supportsAdd||e?.supportsQuery)})),o=e.filter((t=>i.has(t.layer))),n=[];for(const{layer:a,suspended:p}of o.reverse())if("subtype-group"===a.type){await a.loadAll(),d(t);for(let t=a.sublayers.length-1;t>=0;--t)n.push(this._makeEditableItemForLayer(a.sublayers.at(t),p))}else n.push(this._makeEditableItemForLayer(a,p));for(const a of s.reverse())if("subtype-group"===a.type){await a.loadAll(),d(t);for(const t of a.sublayers)n.push(this._makeEditableItemForLayer(t,!1))}else n.push(this._makeEditableItemForLayer(a,!1));if(t.aborted)return;const l=this._editableItems;this._editableItems=new a(n),l.destroy()}));this.updatingHandles.addPromise(t.promise),this._updateEditableItemsTask=t}async _cancelWorkflow(t){const e=this.activeWorkflow;if(!e)return void(t&&t.warn&&T("editing:no-active-workflow","There is no active workflow to cancel."));if(!t||!1!==t.force)return this.emit("workflow-cancel"),this._set("activeWorkflow",null),void await e.cancel(t);await e.cancel(t),this._set("activeWorkflow",null)}_createCreateFeaturesWorkflow(t,e){return W.create(this,t,e,((t,e,a)=>this._applyEdits(t,e,a)),((t,e)=>this._addAttachments(t,e)))}_createCreateWorkflow(t){return _.create(this,t,((t,e,a)=>this._applyEdits(t,e,a)))}_createUpdateWorkflow(t){return E.create(this,t,((t,e)=>this._applyEdits(t,e)))}_addAttachments(t,e){const a=e.map((e=>this._addAttachment(t,e.feature,e.attachment)))??[];return Promise.all(a)}async _addAttachment(t,e,a){let r=null;if("geojson"===t.type||"scene"===t.type||"oriented-imagery"===t.type)throw new i("editor:attachments-not-supported","Adding attachments is not supported for this layer type");return await this._queueOperation((async()=>(r=await(t.addAttachment?.(e,a).catch((t=>{throw t?.error||t})))??null,r))),r}async _applyEdits(t,e,a){let r=null;const i=t.url?await k(t.url):null,s={returnServiceEditsOption:(!i||!v(i))&&!RegExp("/hosted/","i").test(t.url)?"original-and-current-features":void 0,...a};return await this._queueOperation((async()=>{if(g(t)?.operations.supportsQuery){const a=await F(this.view,t);return r=await t.applyEdits(e,s),await h((()=>!a.updating)),r}return r=await t.applyEdits(e,s),r})),r}_queueOperation(t){this._activityQueue.push(t),this.notifyChange("syncing");const e=(t,e)=>{const a=e.indexOf(t);a>-1&&e.splice(a,1)};return t().then((t=>{if("error"in t&&t.error)throw t.error;if("addFeatureResults"in t){const{addFeatureResults:e,deleteFeatureResults:a,updateFeatureResults:r}=t,i=e.find((t=>!!t.error))||r.find((t=>!!t.error))||a.find((t=>!!t.error));if(i)throw i.error}return t})).catch((a=>{T("editing:operation-error","An error occurred.",{error:a});const r={error:a,retry:()=>(e(r,this.failures),this._queueOperation(t)),cancel:()=>{e(r,this.failures)}};this._set("failures",[...this.failures,r])})).then((()=>{e(t,this._activityQueue),this.notifyChange("syncing")}))}_makeEditableItemForLayer(t,e=!0){const a=g(t),r=a?.operations,i=S(this.layerInfos,t),s=this.allowedWorkflows,o=s.includes("create")||s.includes("create-features"),n=s.includes("update"),l=t=>!i||!1!==i.enabled&&!1!==i[t],d=o&&!!r?.supportsAdd&&l("addEnabled"),p=n&&!!r?.supportsUpdate&&l("updateEnabled"),c=n&&!!r?.supportsDelete&&l("deleteEnabled"),u=[];e||(d&&u.push("create"),p&&u.push("update"),c&&u.push("delete"));const h=p&&(!i||!1!==i.attributeUpdatesEnabled),w=p&&!!a?.editing?.supportsGeometryUpdate&&(!i||!1!==i.geometryUpdatesEnabled),f=!(!a?.data?.supportsAttachment||i&&!1===i.allowAttachments);return{layer:t,supports:u,attributeUpdatesEnabled:h,geometryUpdatesEnabled:w,hasAttachments:f,attachmentsOnCreateEnabled:f&&o&&(!i||!1!==i.attachmentsOnCreateEnabled),attachmentsOnUpdateEnabled:f&&(!i||!1!==i.attachmentsOnUpdateEnabled)}}};t([f()],L.prototype,"_editableItems",void 0),t([f({readOnly:!0})],L.prototype,"activeWorkflow",void 0),t([f({readOnly:!0})],L.prototype,"_activityQueue",void 0),t([f({value:[...j]})],L.prototype,"allowedWorkflows",null),t([f({readOnly:!0})],L.prototype,"canCreate",null),t([f({readOnly:!0})],L.prototype,"canUpdate",null),t([f()],L.prototype,"editableItems",null),t([f({readOnly:!0})],L.prototype,"failures",void 0),t([f()],L.prototype,"attachmentsViewModel",void 0),t([f()],L.prototype,"featureFormViewModel",void 0),t([f()],L.prototype,"featureTemplatesViewModel",void 0),t([f()],L.prototype,"labelOptions",null),t([f()],L.prototype,"layerInfos",null),t([f()],L.prototype,"sketchViewModel",void 0),t([f()],L.prototype,"snappingOptions",null),t([f()],L.prototype,"spinnerViewModel",void 0),t([f()],L.prototype,"state",null),t([f({readOnly:!0})],L.prototype,"syncing",null),t([f()],L.prototype,"updating",null),t([f()],L.prototype,"tooltipOptions",null),t([f()],L.prototype,"view",null),t([f()],L.prototype,"pageStack",void 0),t([f()],L.prototype,"showDiscardEditsPrompt",void 0),t([f()],L.prototype,"_candidateCommitted",void 0),t([f()],L.prototype,"page",null),t([f()],L.prototype,"selectedTemplateItem",null),t([f()],L.prototype,"featureFormDisabled",null),t([f()],L.prototype,"canGoBack",null),t([f()],L.prototype,"shouldShowDeleteButton",null),t([f()],L.prototype,"hasPendingEdits",null),t([f()],L.prototype,"useDeprecatedCreateWorkflow",void 0),L=t([m(V)],L);const P=L;export{P as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import{makeHandle as t}from"../../core/handleUtils.js";import{onAbort as i,createAbortError as a,throwIfAborted as s,isAborted as r}from"../../core/promiseUtils.js";import{watch as o}from"../../core/reactiveUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import{getEffectiveLayerCapabilities as l,getEffectiveEditingEnabled as u}from"../../layers/support/layerUtils.js";import{sceneLayerEditingEnabled as c,i3sPatchingEnabled as p}from"../../support/featureFlags.js";import{highlightsSupported as m}from"../../views/support/layerViewUtils.js";import{Edits as h}from"./Edits.js";import f from"./UpdateWorkflowData.js";import g from"./Workflow.js";import{cloneGraphicExceptMesh as w,createWorkflowSteps as y,fetchCandidates as v,whenEditorLayerView as b,fetchFullFeature as M,findLayerInfo as U,canCreateInteractiveEditSession as j,getVisualVariableAttributes as A,setUpGeometryUpdate as I,isTerminalUpdateEventType as k}from"./workflowUtils.js";var E;const V="candidate-highlight";let x=E=class extends g{constructor(e){super(e),this.type="update"}get shouldShowAttachments(){return!!this.data?.editableItem.attachmentsOnUpdateEnabled}get shouldAllowAttachmentEditing(){return!!this.data?.editableItem.supports.includes("update")}get helpMessage(){return"awaiting-feature-to-update"===this.stepId?"select":void 0}get reliesOnOwnerAdminPrivileges(){const{layer:e}=this.data.editableItem,t=e.capabilities?.operations.supportsUpdate,i=l(e)?.operations.supportsUpdate;return u(e)&&!e.editingEnabled||!!i&&!t}static create(e,t,i){const a=new E({data:new f({edits:new h,viewModel:e}),onCommit:async e=>{const t=e.edits.feature;if(!t)return;const a=t.sourceLayer,s=w(t);if(!e.edits.attributesModified){const e=a.objectIdField;if(s.attributes={[e]:t.getAttribute(e)},c()&&p()&&"scene"===a.type&&null!=a.infoFor3D){const e=a.associatedLayer?.globalIdField;null!=e&&(s.attributes[e]=t.getAttribute(e))}}e.edits.geometryModified||(s.geometry=null),await i(a,{updateFeatures:[s]})}});return a._set("steps",this._createWorkflowSteps(a,t)),a}async deleteFeature(e){const t=this.data.edits.feature;await this.reset();const i=t?.sourceLayer;i&&"applyEdits"in i&&await e(i,{deleteFeatures:[t]})}highlight(e){const t=this.data.viewModel.view;if(!t||!e)return;const i=e&&t.allLayerViews.items.find((({layer:t})=>t===e.layer||"subtype-sublayer"===e.layer?.type&&e.layer?.parent===t));m(i)&&this.handles.add(i.highlight(e),V)}unhighlight(){this.handles.remove(V)}static _createWorkflowSteps(e,n="awaiting-feature-to-update"){const{data:d,handles:l}=e,u=new Map;return y(["awaiting-feature-to-update","awaiting-update-feature-candidate","editing-existing-feature","adding-attachment","editing-attachment"],n,{"awaiting-feature-to-update":()=>({id:"awaiting-feature-to-update",async setUp(){const{spinnerViewModel:e}=d.viewModel,t=d.viewModel.view;let r=null;l.add({remove(){r&&(r.abort(),r=null)}},this.id),d.edits.feature=null,d.candidates=[];const o=t.on("immediate-click",(o=>{e.location=o.mapPoint,e.visible=!0,r?.abort();const{editableItems:n}=d.viewModel;r=new AbortController,new Promise(((e,s)=>{i(r?.signal,(()=>s(a()))),e(v(n,t,o,r?.signal))})).then((e=>{if(s(r),d.candidates=e.reduce(((e,t)=>t.error?e:[...e,...t.value]),[]),d.viewModel.spinnerViewModel.visible=1===d.candidates.length,0===d.candidates.length)return;const t=d.viewModel.activeWorkflow;if(1===d.candidates.length){const e=d.candidates[0];d.edits.feature=e,t.go("editing-existing-feature").catch((()=>{})).then((()=>d.viewModel.spinnerViewModel.visible=!1))}else t.next()}))}));t.focus(),l.add(o,this.id)},async tearDown(){l.remove(this.id)}}),"awaiting-update-feature-candidate":()=>({id:"awaiting-update-feature-candidate",async setUp(){const{edits:t}=d;t.feature=null,l.add(o((()=>t.feature),(t=>{e.unhighlight(),e.highlight(t)})),this.id)},async tearDown(){e.unhighlight(),l.remove(this.id)}}),"editing-existing-feature":()=>({id:"editing-existing-feature",async setUp(){if(l.has("editing-existing-feature"))return;const i=d.edits.feature,a=d.viewModel.view,{attachmentsViewModel:s,editableItems:n,featureFormViewModel:m,layerInfos:h,sketchViewModel:f}=d.viewModel;d.editableItem=n.find((e=>e.layer===i.layer));const g=new AbortController;l.add(t((()=>g.abort())),this.id);const w=b(a,i.layer),y=M(i,a.spatialReference,g.signal),v=await w,E=await y;if(r(g))return;d.edits.updateGeometry(E.geometry),d.edits.updateAttributes(E.attributes),d.edits.trackChanges();const V=d.editableItem.supports,x=V.includes("create"),D=V.includes("update");s.set({capabilities:{editing:!0,operations:{add:x||D,update:D,delete:D}},graphic:E,filesEnabled:!1,mode:"view"});const F=E.sourceLayer,C=null!=F&&"feature"===F.type?U(h,F):void 0,S=C?.formTemplate,W=a.spatialReference;m.set({arcadeEditType:"UPDATE",feature:E,formTemplate:S,spatialReference:W,view:a});const _=j(v)?v.createInteractiveEditSession(i):null,L=[m.on("value-change",(e=>{d.edits.updateAttributes(m.getValues()),E.attributes=d.edits.feature.attributes,_&&_.setAttribute(e.fieldName,e.value)})),o((()=>s.mode),(e=>{"add"===e&&d.viewModel.activeWorkflow.go("adding-attachment"),"edit"===e&&d.viewModel.activeWorkflow.go("editing-attachment")}))];_&&(L.push(t((()=>_.rollback()))),l.add(t((()=>_.commit())),e._handleKeys.afterCommit));if(d.editableItem.geometryUpdatesEnabled){f.allowDeleteKey=!1;const t=A(E),{interactive:i,visual:s}=await I(E,t,f,a,(({geometry:e,attributes:i},a)=>{if(null!=t.rotation){const{field:e}=t.rotation;m.setValue(e,i[e])}if(null!=t.size){const{field:e}=t.size;m.setValue(e,i[e])}d.edits.updateAttributes(i),d.edits.updateGeometry(e),m.feature.geometry=e,"scene"===F?.type&&null!=F?.infoFor3D&&c()&&p()&&_&&"mesh"===e?.type&&_.setGeometry(e),("undo"===a.type||"redo"===a.type||"update"===a.type&&null!=a.toolEventInfo&&k(a.toolEventInfo.type))&&m.notifyFeatureGeometryChanged()}),u);L.push(i,s),l.add(i,e._handleKeys.beforeCommit),l.add(s,e._handleKeys.afterCommit)}else e.highlight(E);l.add(L,this.id)},async tearDown({canceled:t}){t&&(e.unhighlight(),l.remove(this.id))}}),"adding-attachment":()=>({id:"adding-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){d.viewModel.attachmentsViewModel.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){d.viewModel.attachmentsViewModel.mode="view"}})})}};e([n()],x.prototype,"shouldShowAttachments",null),e([n()],x.prototype,"shouldAllowAttachmentEditing",null),e([n()],x.prototype,"helpMessage",null),e([n()],x.prototype,"reliesOnOwnerAdminPrivileges",null),x=E=e([d("esri.widgets.Editor.UpdateWorkflow")],x);const D=x;export{D as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import{makeHandle as t,abortHandle as i}from"../../core/handleUtils.js";import{abortMaybe as a}from"../../core/maybe.js";import{onAbort as s,createAbortError as r,throwIfAborted as o,isAborted as d}from"../../core/promiseUtils.js";import{watch as n}from"../../core/reactiveUtils.js";import{property as l}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as u}from"../../core/accessorSupport/decorators/subclass.js";import{getEffectiveLayerCapabilities as c,getEffectiveEditingEnabled as p}from"../../layers/support/layerUtils.js";import{sceneLayerEditingEnabled as m,i3sPatchingEnabled as h}from"../../support/featureFlags.js";import{highlightsSupported as g}from"../../views/support/layerViewUtils.js";import{Edits as f}from"./Edits.js";import w from"./UpdateWorkflowData.js";import y from"./Workflow.js";import{cloneGraphicExceptMesh as b,createWorkflowSteps as v,fetchCandidates as M,whenEditorLayerView as U,fetchFullFeature as j,findLayerInfo as A,getVisualVariableAttributes as E,setUpGeometryUpdate as I,isTerminalUpdateEventType as k,canCreateInteractiveEditSession as V}from"./workflowUtils.js";var x;const D="candidate-highlight";let F=x=class extends y{constructor(e){super(e),this.type="update"}get shouldShowAttachments(){return!!this.data?.editableItem.attachmentsOnUpdateEnabled}get shouldAllowAttachmentEditing(){return!!this.data?.editableItem.supports.includes("update")}get hasPendingEdits(){return this.data.edits.modified}get helpMessage(){return"awaiting-feature-to-update"===this.stepId?"select":void 0}get reliesOnOwnerAdminPrivileges(){const{layer:e}=this.data.editableItem,t=e.capabilities?.operations.supportsUpdate,i=c(e)?.operations.supportsUpdate;return p(e)&&!e.editingEnabled||!!i&&!t}static create(e,t,i){const a=new x({data:new w({edits:new f,viewModel:e}),onCommit:async e=>{const t=e.edits.feature;if(!t)return;const a=t.sourceLayer,s=b(t);if(!e.edits.attributesModified){const e=a.objectIdField;if(s.attributes={[e]:t.getAttribute(e)},m()&&h()&&"scene"===a.type&&null!=a.infoFor3D){const e=a.associatedLayer?.globalIdField;null!=e&&(s.attributes[e]=t.getAttribute(e))}}e.edits.geometryModified||(s.geometry=null),await i(a,{updateFeatures:[s]})}});return a._set("steps",this._createWorkflowSteps(a,t)),a}async deleteFeature(e){const t=this.data.edits.feature;await this.reset();const i=t?.sourceLayer;i&&"applyEdits"in i&&await e(i,{deleteFeatures:[t]})}highlight(e){const t=this.data.viewModel.view;if(!t||!e)return;const i=e&&t.allLayerViews.items.find((({layer:t})=>t===e.layer||"subtype-sublayer"===e.layer?.type&&e.layer?.parent===t));g(i)&&this.handles.add(i.highlight(e),D)}unhighlight(){this.handles.remove(D)}static _createWorkflowSteps(e,l="awaiting-feature-to-update"){const{data:u,handles:c}=e,p=new Map;return v(["awaiting-feature-to-update","awaiting-update-feature-candidate","editing-existing-feature","adding-attachment","editing-attachment"],l,{"awaiting-feature-to-update":()=>({id:"awaiting-feature-to-update",async setUp(){const{spinnerViewModel:i}=u.viewModel,d=u.viewModel.view;let n=null;c.add(t((()=>{n=a(n)})),this.id),u.edits.feature=null,u.candidates=[];const l=d.on("immediate-click",(async t=>{i.location=t.mapPoint,i.visible=!0,n?.abort();const{editableItems:a}=u.viewModel;n=new AbortController;const l=await new Promise(((e,i)=>{s(n?.signal,(()=>i(r()))),e(M(a,d,t,n?.signal))}));o(n),u.candidates=l.reduce(((e,t)=>t.error?e:[...e,...t.value]),[]),i.visible=1===u.candidates.length,0!==u.candidates.length&&(1===u.candidates.length?(u.edits.feature=u.candidates[0],e.go("editing-existing-feature").catch((()=>{})).then((()=>i.visible=!1))):e.next())}));d.focus(),c.add(l,this.id)},async tearDown(){c.remove(this.id)}}),"awaiting-update-feature-candidate":()=>({id:"awaiting-update-feature-candidate",async setUp(){const{edits:t}=u;t.feature=null,c.add(n((()=>t.feature),(t=>{e.unhighlight(),e.highlight(t)})),this.id)},async tearDown(){e.unhighlight(),c.remove(this.id)}}),"editing-existing-feature":()=>({id:"editing-existing-feature",async setUp(){if(c.has("editing-existing-feature"))return;const a=u.edits.feature,s=u.viewModel.view,{attachmentsViewModel:r,editableItems:o,featureFormViewModel:l,layerInfos:g,sketchViewModel:f,spinnerViewModel:w}=u.viewModel;u.editableItem=o.find((e=>e.layer===a.layer));const y=new AbortController;c.add(i(y),this.id);const b=U(s,a.layer),v=j(a,s.spatialReference,y.signal),M=await b,x=await v;if(d(y))return;u.edits.updateGeometry(x.geometry),u.edits.updateAttributes(x.attributes),u.edits.trackChanges();const D=u.editableItem.supports,F=D.includes("create"),C=D.includes("update");r.set({capabilities:{editing:!0,operations:{add:F||C,update:C,delete:C}},graphic:x,filesEnabled:!1,mode:"view"});const S=x.sourceLayer,P=null!=S&&"feature"===S.type?A(g,S):void 0,W=P?.formTemplate,_=s.spatialReference;l.set({arcadeEditType:"UPDATE",feature:x,formTemplate:W,spatialReference:_,view:s}),c.add([l.on("value-change",(e=>{u.edits.updateAttributes(l.getValues()),x.attributes=u.edits.feature.attributes,L&&L.setAttribute(e.fieldName,e.value)})),n((()=>r.mode),(e=>{"add"===e&&u.viewModel.activeWorkflow.go("adding-attachment"),"edit"===e&&u.viewModel.activeWorkflow.go("editing-attachment")}))],this.id);if(u.editableItem.geometryUpdatesEnabled){f.allowDeleteKey=!1;const t=E(x),{interactive:i,visual:a}=await I(x,t,f,s,(({geometry:e,attributes:i},a)=>{if(null!=t.rotation){const{field:e}=t.rotation;l.setValue(e,i[e])}if(null!=t.size){const{field:e}=t.size;l.setValue(e,i[e])}u.edits.updateAttributes(i),u.edits.updateGeometry(e),l.feature.geometry=e,"scene"===S?.type&&null!=S?.infoFor3D&&m()&&h()&&L&&"mesh"===e?.type&&L.setGeometry(e),("undo"===a.type||"redo"===a.type||"update"===a.type&&null!=a.toolEventInfo&&k(a.toolEventInfo.type))&&l.notifyFeatureGeometryChanged()}),p);c.add([i,a],this.id),c.add(i,e._handleKeys.beforeCommit),c.add(a,e._handleKeys.afterCommit)}else e.highlight(x);const L=V(M)?M.createInteractiveEditSession(a):null;L&&(c.add(t((()=>L.rollback())),this.id),c.add(t((()=>L.commit())),e._handleKeys.afterCommit)),w.visible=!1},async tearDown({canceled:t}){t&&(e.unhighlight(),c.remove(this.id))}}),"adding-attachment":()=>({id:"adding-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){u.viewModel.attachmentsViewModel.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){u.viewModel.attachmentsViewModel.mode="view"}})})}};e([l()],F.prototype,"shouldShowAttachments",null),e([l()],F.prototype,"shouldAllowAttachmentEditing",null),e([l()],F.prototype,"hasPendingEdits",null),e([l()],F.prototype,"helpMessage",null),e([l()],F.prototype,"reliesOnOwnerAdminPrivileges",null),F=x=e([u("esri.widgets.Editor.UpdateWorkflow")],F);const C=F;export{C as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import o from"../../core/Accessor.js";import{createTask as r}from"../../core/asyncUtils.js";import t from"../../core/Error.js";import{abortMaybe as s}from"../../core/maybe.js";import{isAbortError as n,throwIfAborted as i,createAbortError as a,createResolver as c}from"../../core/promiseUtils.js";import{property as l}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as p}from"../../core/accessorSupport/decorators/subclass.js";import u from"../../geometry/Point.js";import{getSupportedExtensions as m}from"../../layers/support/infoFor3D.js";let f=class extends o{constructor(){super({}),this._uploadTask=null}destroy(){this.cancel()}get state(){const e=this._uploadTask;return e?e.finished?e.error?n(e.error)?"canceled":"error":"success":"pending":"default"}get result(){return this._uploadTask?.value??null}get error(){return this._uploadTask?.error??null}uploadTo(e){this.cancel(),this._uploadTask=r((async o=>{const r=await h({acceptedExtensions:m(e.infoFor3D)});if(i(o),0===r.length)throw a();const s=(await import("../../geometry/Mesh.js")).default;i(o);const n=new u({x:0,y:0,z:0,spatialReference:e.spatialReference}),c=await s.createFromFiles(n,r,{layer:e,signal:o});if(i(o),!c)throw new t("editor:upload","could not upload or convert model");if(!c.transform){const e=await(await import("../../geometry/support/MeshTransform.js")).default;i(o),c.transform=new e({geographic:!0})}return c.load()}))}cancel(){this._uploadTask=s(this._uploadTask)}};e([l()],f.prototype,"state",null),e([l()],f.prototype,"result",null),e([l()],f.prototype,"error",null),e([l()],f.prototype,"_uploadTask",void 0),f=e([p("esri.widgets.Editor.Upload")],f);let d=null;async function h({acceptedExtensions:e}){const o=c();let r;const t=document.createElement("input");function s(){return t.files?Array.from(t.files):[]}function n(e){a(),o.resolve(e)}function i(){n(s())}function a(){clearTimeout(r),t.removeEventListener("change",i),window.removeEventListener("focus",l)}function l(){window.removeEventListener("focus",l),r=setTimeout((()=>{if(0===s().length)return n([])}),g)}return t.type="file",t.multiple=!0,t.accept=e.join(","),t.addEventListener("change",i),window.addEventListener("focus",l),d?d(t):t.click(),o.promise.finally(a)}function y(e){d=o=>{const r=new DataTransfer;e.forEach((e=>r.items.add(e))),o.files=r.files,setTimeout((()=>{o.dispatchEvent(new Event("change"))}))}}function w(){d=null}const g=1e3;export{f as Upload,w as clearPromptForFilesStub,y as simulateSelectingFiles};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import o from"../../core/Accessor.js";import{createTask as r}from"../../core/asyncUtils.js";import t from"../../core/Error.js";import{abortMaybe as s}from"../../core/maybe.js";import{isAbortError as n,throwIfAborted as i,createAbortError as a,throwIfNotAbortError as c,createResolver as l}from"../../core/promiseUtils.js";import{property as p}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as u}from"../../core/accessorSupport/decorators/subclass.js";import m from"../../geometry/Point.js";import{getFilePickerAcceptTypes as f,getSupportedExtensions as d}from"../../layers/support/infoFor3D.js";let h=class extends o{constructor(){super({}),this._uploadTask=null}destroy(){this.cancel()}get state(){const e=this._uploadTask;return e?e.finished?e.error?n(e.error)?"canceled":"error":"success":"pending":"default"}get result(){return this._uploadTask?.value??null}get error(){return this._uploadTask?.error??null}uploadTo(e){this.cancel(),this._uploadTask=r((async o=>{const r=await w(e);if(i(o),0===r.length)throw a();const s=(await import("../../geometry/Mesh.js")).default;i(o);const n=new m({x:0,y:0,z:0,spatialReference:e.spatialReference}),c=await s.createFromFiles(n,r,{layer:e,signal:o});if(i(o),!c)throw new t("editor:upload","could not upload or convert model");if(!c.transform){const e=await(await import("../../geometry/support/MeshTransform.js")).default;i(o),c.transform=new e({geographic:!0})}return c.load()}))}cancel(){this._uploadTask=s(this._uploadTask)}};e([p()],h.prototype,"state",null),e([p()],h.prototype,"result",null),e([p()],h.prototype,"error",null),e([p()],h.prototype,"_uploadTask",void 0),h=e([u("esri.widgets.Editor.Upload")],h);let y=null;async function w(e){return"showOpenFilePicker"in window&&!y?g(e):j(e)}async function g(e){try{const o=await window.showOpenFilePicker({multiple:!0,excludeAcceptAllOption:!0,types:f(e.infoFor3D)});return Promise.all(o.map((e=>e.getFile())))}catch(o){return c(o),[]}}async function j(e){const o=l();let r;const t=document.createElement("input");function s(){return t.files?Array.from(t.files):[]}function n(){i(),o.resolve(s())}function i(){clearTimeout(r),t.removeEventListener("change",n),window.removeEventListener("focus",a)}function a(){r=setTimeout((()=>{const e=s();0===e.length&&(i(),o.resolve(e))}),k)}return t.type="file",t.multiple=!0,t.accept=d(e.infoFor3D).join(","),t.addEventListener("change",n),window.addEventListener("focus",a,{once:!0}),y?y(t):t.click(),o.promise.finally(i)}function T(e){y=o=>{setTimeout((()=>{const r=new DataTransfer;e.forEach((e=>r.items.add(e))),o.files=r.files,o.dispatchEvent(new Event("change"))}))}}function v(){y=null}const k=5e3;export{h as Upload,v as clearPromptForFilesStub,T as simulateSelectingFiles};