@arcgis/core 4.34.0-next.85 → 4.34.0-next.86

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 (142) hide show
  1. package/Basemap.js +1 -1
  2. package/arcade/functions/measures.js +1 -1
  3. package/assets/esri/core/workers/RemoteClient.js +1 -1
  4. package/assets/esri/core/workers/chunks/06c389283ee5b60573f2.js +1 -0
  5. package/assets/esri/core/workers/chunks/0b679d5a1bfdbd006d6e.js +1 -0
  6. package/assets/esri/core/workers/chunks/1537b02e674f8ef77f4a.js +1 -0
  7. package/assets/esri/core/workers/chunks/{9eb1bfcb9b05f2a36748.js → 1f2d13466c60a6b57717.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{7a23b127f551bf13ef54.js → 268f5b233640a9dbbf89.js} +2 -2
  9. package/assets/esri/core/workers/chunks/2896ada406074f754b00.js +1 -0
  10. package/assets/esri/core/workers/chunks/28d30be414e59eabd963.js +1 -0
  11. package/assets/esri/core/workers/chunks/29471e0b3f7296dee096.js +1 -0
  12. package/assets/esri/core/workers/chunks/{3192b68675ff2afcb1d6.js → 2d3ae187f8aa3495d4ae.js} +1 -1
  13. package/assets/esri/core/workers/chunks/336b54144afec0c7d396.js +2 -0
  14. package/assets/esri/core/workers/chunks/42bc1e981624ce9844a4.js +1 -0
  15. package/assets/esri/core/workers/chunks/436bbe99bedd7b331edb.js +1 -0
  16. package/assets/esri/core/workers/chunks/{d66cdb9bb494da19696b.js → 47e4f66c33bb697fbe6b.js} +2 -2
  17. package/assets/esri/core/workers/chunks/4840bd93d8fe15c7aefd.js +1 -0
  18. package/assets/esri/core/workers/chunks/4a06ab00d095f63598b5.js +1 -0
  19. package/assets/esri/core/workers/chunks/4d4db6854aff7656f6e1.js +1 -0
  20. package/assets/esri/core/workers/chunks/5c585b338a9e9aa0e205.js +1 -0
  21. package/assets/esri/core/workers/chunks/655a878ddea4907d830e.js +1 -0
  22. package/assets/esri/core/workers/chunks/68f5a2d2666636c3f807.js +1 -0
  23. package/assets/esri/core/workers/chunks/6c36cef0b58b87a1f17f.js +316 -0
  24. package/assets/esri/core/workers/chunks/72fe4f1f789abb5b4035.js +1 -0
  25. package/assets/esri/core/workers/chunks/8307f635a5c0c4a95825.js +1 -0
  26. package/assets/esri/core/workers/chunks/{afb76f9d6abedef771df.js → 8380a092ffc8e92ede7a.js} +1 -1
  27. package/assets/esri/core/workers/chunks/{f8f85207b382c1ea038c.js → 97489bf16a1d327992b2.js} +3 -3
  28. package/assets/esri/core/workers/chunks/9d7a22746dae1451deaf.js +1 -0
  29. package/assets/esri/core/workers/chunks/a2652d10bb0bc41c9a8d.js +1 -0
  30. package/assets/esri/core/workers/chunks/a845c68e76382a73da5e.js +1 -0
  31. package/assets/esri/core/workers/chunks/{9c64b78c5c9b35b31d98.js → aa78b69219d9a0ef1c54.js} +2 -2
  32. package/assets/esri/core/workers/chunks/{1859a11df9f579b993d7.js → b2fbb44e219232e61cbd.js} +1 -1
  33. package/assets/esri/core/workers/chunks/b4349db7155673329432.js +1 -0
  34. package/assets/esri/core/workers/chunks/{d153b29c542c37ae1636.js → c50e8d5f554cf151865c.js} +2 -2
  35. package/assets/esri/core/workers/chunks/c5cc0fc652432a9264cc.js +1 -0
  36. package/assets/esri/core/workers/chunks/cab2a1382bdd32bb34d8.js +1 -0
  37. package/assets/esri/core/workers/chunks/ce937ff0dd1147ea297e.js +1 -0
  38. package/assets/esri/core/workers/chunks/d142a42755a78bb157ed.js +1 -0
  39. package/assets/esri/core/workers/chunks/{280af3640f8e93c1024e.js → d6e0528eacee7ea4c1ce.js} +2 -2
  40. package/assets/esri/core/workers/chunks/d9d86cf0500fa29d1d43.js +1 -0
  41. package/assets/esri/core/workers/chunks/{b15ff6c9ef2de8a49853.js → f651c05604eab83aef5f.js} +2 -2
  42. package/assets/esri/core/workers/chunks/{ed773dab5965e42a2879.js → f6e18668f728dfd8ba5e.js} +2 -2
  43. package/assets/esri/core/workers/chunks/ff8e2f998169ca3a7a68.js +1 -0
  44. package/assets/esri/libs/dracoMeshDecoder/draco_mesh_decoder.wasm +0 -0
  45. package/assets/esri/libs/i3s/i3s.wasm +0 -0
  46. package/chunks/CloudsComposition.glsl.js +2 -2
  47. package/chunks/HUDMaterial.glsl.js +49 -50
  48. package/chunks/LineMarker.glsl.js +34 -34
  49. package/chunks/PointRenderer.glsl.js +4 -4
  50. package/chunks/ShadowHighlight.glsl.js +3 -3
  51. package/chunks/draco_mesh_decoder.js +1 -1
  52. package/config.js +1 -1
  53. package/core/NestedMap.js +1 -1
  54. package/core/iteratorUtils.js +1 -1
  55. package/editing/geometry/lineUtils.js +1 -1
  56. package/interfaces.d.ts +55 -7
  57. package/kernel.js +1 -1
  58. package/layers/IntegratedMesh3DTilesLayer.js +1 -1
  59. package/layers/IntegratedMeshLayer.js +1 -1
  60. package/layers/SceneLayer.js +1 -1
  61. package/layers/knowledgeGraph/KnowledgeGraphLayerDataManager.js +1 -1
  62. package/layers/knowledgeGraph/cypherUtils.js +1 -1
  63. package/layers/support/layerUtils.js +1 -1
  64. package/package.json +5 -5
  65. package/support/basemapEnsureType.js +1 -1
  66. package/support/revision.js +1 -1
  67. package/support/userTypeGuards/isBasemap.js +5 -0
  68. package/symbols/support/previewSymbol2D.js +1 -1
  69. package/views/3d/FocusAreasView.js +1 -1
  70. package/views/3d/environment/CloudsComposition.glsl.js +1 -1
  71. package/views/3d/glTF/internal/Resource.js +1 -1
  72. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  73. package/views/3d/layers/i3s/I3SMaterialUtil.js +1 -1
  74. package/views/3d/support/engineContent/marker.js +1 -1
  75. package/views/3d/support/engineContent/sdfPrimitives.js +1 -1
  76. package/views/3d/webgl-engine/core/shaderLibrary/shading/LineStipple.glsl.js +11 -11
  77. package/views/3d/webgl-engine/lib/BasisUtil.js +1 -1
  78. package/views/3d/webgl-engine/lib/Texture.js +1 -1
  79. package/views/3d/webgl-engine/materials/renderers/InstancedCommandVAO.js +5 -0
  80. package/views/3d/webgl-engine/materials/renderers/InstancedCommandVAOs.js +5 -0
  81. package/views/3d/webgl-engine/materials/renderers/PerBufferData.js +1 -1
  82. package/views/3d/webgl-engine/materials/renderers/PerOriginData.js +1 -1
  83. package/views/3d/webgl-engine/materials/renderers/VaoRenderer.js +1 -1
  84. package/views/3d/webgl-engine/materials/renderers/VaoWriter.js +1 -1
  85. package/views/3d/webgl-engine/shaders/AnimatedLine.glsl.js +14 -9
  86. package/views/3d/webgl-engine/shaders/HUDMaterial.glsl.js +1 -1
  87. package/views/3d/webgl-engine/shaders/LineMarker.glsl.js +1 -1
  88. package/views/3d/webgl-engine/shaders/PointRenderer.glsl.js +1 -1
  89. package/views/3d/webgl-engine/shaders/ShadowHighlight.glsl.js +1 -1
  90. package/views/3d/webgl-engine/shaders/sources/edgeRenderer/LineOffset.glsl.js +8 -8
  91. package/views/BasemapView.js +1 -1
  92. package/views/GroundView.js +1 -1
  93. package/views/SceneView.js +1 -1
  94. package/views/View.js +1 -1
  95. package/views/View2D.js +1 -1
  96. package/views/support/LayerViewManager.js +1 -1
  97. package/views/webgl/RenderbufferDescriptor.js +1 -1
  98. package/views/webgl/TextureDescriptor.js +1 -1
  99. package/views/webgl/Util.js +1 -1
  100. package/views/webgl/VertexArrayObject.js +1 -1
  101. package/webscene/Slide.js +1 -1
  102. package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
  103. package/widgets/Editor/SplitFeatureWorkflow.js +1 -1
  104. package/widgets/Editor/UpdateFeatureWorkflow.js +1 -1
  105. package/widgets/Editor/support/SketchController.js +1 -1
  106. package/widgets/Editor/support/splitFeatureUtils.js +1 -1
  107. package/widgets/Editor/workflowUtils.js +1 -1
  108. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  109. package/widgets/Sketch/SketchViewModel.js +1 -1
  110. package/widgets/Sketch/adapters/layer/GraphicsLayerAdapter.js +5 -0
  111. package/widgets/Sketch/adapters/layer/MapNotesLayerAdapter.js +5 -0
  112. package/assets/esri/core/workers/chunks/25ea02dd7d45a90cbb3b.js +0 -1
  113. package/assets/esri/core/workers/chunks/264a9a916e1e972b69d7.js +0 -1
  114. package/assets/esri/core/workers/chunks/30c85a1a4f118cc45a25.js +0 -1
  115. package/assets/esri/core/workers/chunks/3ef8a7468d7e3b2f0b69.js +0 -351
  116. package/assets/esri/core/workers/chunks/5c1cdc2ec06c4c6bd0b3.js +0 -1
  117. package/assets/esri/core/workers/chunks/609abf071c4ea24955c2.js +0 -1
  118. package/assets/esri/core/workers/chunks/71c2a8e5a17803d3e949.js +0 -1
  119. package/assets/esri/core/workers/chunks/7889a909394c61a9d3e0.js +0 -1
  120. package/assets/esri/core/workers/chunks/99ac292a858bbedc6a89.js +0 -1
  121. package/assets/esri/core/workers/chunks/9a6fa91dd204f64d2590.js +0 -1
  122. package/assets/esri/core/workers/chunks/9cdeead9d444e8d95477.js +0 -1
  123. package/assets/esri/core/workers/chunks/aa1eb7b4d9ccda725da5.js +0 -1
  124. package/assets/esri/core/workers/chunks/b4a053063e6022080d31.js +0 -1
  125. package/assets/esri/core/workers/chunks/b4b26cc2ba3ff30e1d03.js +0 -1
  126. package/assets/esri/core/workers/chunks/bbb585f0b484ab5eabb3.js +0 -1
  127. package/assets/esri/core/workers/chunks/c2bc70b65f5c2a2c9671.js +0 -1
  128. package/assets/esri/core/workers/chunks/cd1869e183001266c4c1.js +0 -2
  129. package/assets/esri/core/workers/chunks/d2fe403d6ab237bc89c2.js +0 -1
  130. package/assets/esri/core/workers/chunks/d51e8eeb1e1eb0605cc9.js +0 -1
  131. package/assets/esri/core/workers/chunks/e080628ac6e1cf25dc72.js +0 -1
  132. package/assets/esri/core/workers/chunks/e8e0f73fb94e63e2abc3.js +0 -1
  133. package/assets/esri/core/workers/chunks/f45c343527709f6f91c2.js +0 -1
  134. package/assets/esri/core/workers/chunks/fcac475e4e82911b3126.js +0 -1
  135. /package/assets/esri/core/workers/chunks/{7a23b127f551bf13ef54.js.LICENSE.txt → 268f5b233640a9dbbf89.js.LICENSE.txt} +0 -0
  136. /package/assets/esri/core/workers/chunks/{cd1869e183001266c4c1.js.LICENSE.txt → 336b54144afec0c7d396.js.LICENSE.txt} +0 -0
  137. /package/assets/esri/core/workers/chunks/{280af3640f8e93c1024e.js.LICENSE.txt → 47e4f66c33bb697fbe6b.js.LICENSE.txt} +0 -0
  138. /package/assets/esri/core/workers/chunks/{9c64b78c5c9b35b31d98.js.LICENSE.txt → aa78b69219d9a0ef1c54.js.LICENSE.txt} +0 -0
  139. /package/assets/esri/core/workers/chunks/{d153b29c542c37ae1636.js.LICENSE.txt → c50e8d5f554cf151865c.js.LICENSE.txt} +0 -0
  140. /package/assets/esri/core/workers/chunks/{b15ff6c9ef2de8a49853.js.LICENSE.txt → d6e0528eacee7ea4c1ce.js.LICENSE.txt} +0 -0
  141. /package/assets/esri/core/workers/chunks/{d66cdb9bb494da19696b.js.LICENSE.txt → f651c05604eab83aef5f.js.LICENSE.txt} +0 -0
  142. /package/assets/esri/core/workers/chunks/{ed773dab5965e42a2879.js.LICENSE.txt → f6e18668f728dfd8ba5e.js.LICENSE.txt} +0 -0
package/views/View2D.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../Viewpoint.js";import i from"../core/Collection.js";import r from"../core/CollectionFlattener.js";import s from"../core/Error.js";import has from"../core/has.js";import a from"../core/Logger.js";import{destroyMaybe as n}from"../core/maybe.js";import{watch as o,syncAndInitial as l}from"../core/reactiveUtils.js";import{initialize as p}from"../core/workers/workers.js";import{property as h}from"../core/accessorSupport/decorators/property.js";import{cast as g}from"../core/accessorSupport/decorators/cast.js";import"../core/RandomLCG.js";import{subclass as d}from"../core/accessorSupport/decorators/subclass.js";import{ensureClass as c}from"../core/accessorSupport/ensureType.js";import{owningCollectionProperty as u}from"../core/support/OwningCollection.js";import m from"../geometry/Polygon.js";import{isLoadedOrLoadFor as y}from"../geometry/projectionUtils.js";import f from"../layers/support/TileInfo.js";import{AnalysesCollection as w}from"../support/AnalysesCollection.js";import{BreakpointsOwner as V}from"./BreakpointsOwner.js";import{DOMContainer as v}from"./DOMContainer.js";import{PopupView as M}from"./PopupView.js";import b from"./View.js";import{Viewport2DBaseMixin as _}from"./Viewport2DBaseMixin.js";import{Viewport2DMixin as j}from"./Viewport2DMixin.js";import R from"./2d/AnimationManager.js";import{layerView2DImporter as L}from"./2d/layerViewModuleImportUtils.js";import S from"./2d/tiling/TileInfoView.js";import"./2d/tiling/TileKey.js";import"./2d/tiling/TileQueue.js";import"./2d/tiling/TileStrategy.js";import{extentToScale as O}from"./2d/viewpointUtils.js";import{importAnalysisViewModule as T}from"./2d/analysis/analysisViewModuleImportUtils.js";import{ManagedCanvas as C}from"./2d/engine/ManagedCanvas.js";import k from"./2d/layers/features/support/TileStore.js";import{createOrReuseHighlightGradient as x}from"./2d/layers/support/util.js";import{clipContainsPoint as D}from"./2d/support/clippingUtils.js";import{getDefaultHighlightOptions as A,setDefaultHighlightOptions as P}from"./2d/support/highlightOptionsUtils.js";import{hitTest as E}from"./2d/support/hitTestUtils.js";import{takeRawScreenshot as z,takeScreenshot as G}from"./2d/support/screenshotUtils.js";import{Timeline as U}from"./2d/support/Timeline.js";import q from"./navigation/Navigation.js";import I from"./navigation/NavigationActionMap.js";import N from"./support/AnalysisViewManager.js";import W from"./support/HighlightOptions.js";import{check as $}from"./support/WebGLRequirements.js";import F from"./ui/DefaultUI.js";import H from"./ui/2d/DefaultUI2D.js";import{RenderingContextOptions as B}from"./webgl/RenderingContextOptions.js";import{isWebMap as Z}from"../webmap/utils.js";import J from"../webmap/background/ColorBackground.js";let K,Q,X,Y,ee,te,ie;async function re(){const[,{GraphicsView2D:e,GraphicContainer:t,LabelManager:i,MapViewNavigation:r,MagnifierView2D:s,GridView2D:a,Stage:n}]=await Promise.all([import("./2d/webglDeps.js"),import("./2d/mapViewDeps.js")]);Q=e,X=t,Y=i,ee=r,te=s,ie=a,K=n}let se=class extends(j(_(V(M(v(b)))))){get timeZone(){return super.timeZone}set timeZone(e){super.timeZone=e}constructor(e){super(e),this._magnifierView=null,this._gridView=null,this.stage=null,this._resolveWhenReady=[],this.rootLayerViews=new r({getCollections:()=>[this.basemapView?.baseLayerViews,this.layerViews,this.basemapView?.referenceLayerViews],getChildrenFunction:()=>null}),this.featuresTilingScheme=null,this.graphicsView=null,this.labelManager=null,this.navigation=new q({actionMap:new I({dragTertiary:"none"})}),this.renderingOptions={samplingMode:"dynamic",edgeLabelsVisible:!0,labelsAnimationTime:125,labelCollisionsEnabled:!0},this.supersampleScreenshotsEnabled=!0,this.supportsGround=!1,this.analyses=new w,this.analysisViewManager=new N({importAnalysisViewModule:e=>T(e),view:this}),this.floors=new i,this.grid=null,this.map=null,this.timeline=new U,this.type="2d",this.view2dType=null,this.ui=new H,this.test={takeScreenshot:async e=>z(this._getScreenshotView(e),e)},this.padding={top:0,right:0,bottom:0,left:0},p()}destroy(){this.layerViewManager.clear(),this._set("preconditionsReady",!1),this.frameTask=n(this.frameTask),this.goToManager.destroy(),this.rootLayerViews.destroy(),this.inputManager.destroy(),this._set("inputManager",null)}get graphicsTileStore(){return new k(this.featuresTilingScheme)}get constraintsInfo(){const e=this.defaultsFromMap?.tileInfo,t=this.spatialReference;return{lods:e?.spatialReference?.equals(t)?e.lods:null,spatialReference:t}}get initialExtentRequired(){if(!this.stateManager)return!1;const{scale:e,constraints:t,center:i,viewpoint:r,extent:s}=this;let a=this.zoom;return!(this.map&&"initialViewProperties"in this.map&&this.map.initialViewProperties?.viewpoint)&&(!s&&(t?.effectiveLODs||(a=-1),(!i||0===e&&-1===a)&&(null==r?.targetGeometry||"extent"!==r.targetGeometry.type&&!r.scale)))}get defaultsFromMapSettings(){return{required:{extent:!1,heightModelInfo:!1,tileInfo:!0},requiresExtentInSpatialReference:this.spatialReferenceLocked}}get scheduler(){return this.frameTask.scheduler}get typeSpecificPreconditionsReady(){const e=this._getDefaultViewpoint();if(!e)return!1;const t=e.targetGeometry,i=this.spatialReference;return y(t.spatialReference,i)}get background(){return Z(this.map)?this.map.initialViewProperties.background:null}set background(e){this._override("background",e)}get center(){return this.stateManager?.center??null}set center(e){this.stateManager.center=e}get constraints(){return super.constraints}set constraints(e){super.constraints=e}get highlightOptions(){return A(this)}set highlightOptions(e){P(this,e)}get padding(){return this.stateManager?.padding}set padding(e){this.stateManager&&(this.stateManager.padding=e)}get rendering(){return this.stage?.renderRequested??!1}get resizeAlign(){return super.resizeAlign}set resizeAlign(e){super.resizeAlign=e}get resolution(){return this.stateManager.resolution??0}get rotation(){return super.rotation}set rotation(e){super.rotation=e}get scale(){return this.stateManager?.scale??0}set scale(e){this.stateManager&&(this.stateManager.scale=e)}get spatialReference(){return super.spatialReference}set spatialReference(e){super.spatialReference=e}get spatialReferenceLocked(){return this._get("spatialReferenceLocked")}set spatialReferenceLocked(e){this.stage&&a.getLogger(this).warn("spatialReferenceLocked cannot be changed after the view has become ready"),this._set("spatialReferenceLocked",e)}get tileInfo(){return this.featuresTilingScheme?.tileInfo}get updating(){const e=!(!this.magnifier.visible||null===this.magnifier.position||!this._magnifierView?.updatingHandles.updating),t=!this.destroyed&&(!this.analysisViewManager||!this.layerViewManager||!this.labelManager||!this.graphicsView||!0===this.analysisViewManager.updating||!0===this.layerViewManager.updating||!0===this.labelManager.updating||!0===this.graphicsView.updating||this.allLayerViews.some(e=>!e.destroyed&&!("layerViews"in e)&&!0===e.updating)||e);if(has("esri-2d-log-updating")){const i=this.allLayerViews.reduce((e,t)=>({...e,[`${t.layer.id}(${t.layer.type})`]:!t.destroyed&&!("layerViews"in t)&&t.updating}),{});console.log(`Updating MapView: ${t}\n-> Null LayerViewManager: ${!this.layerViewManager}\n-> Null LabelManager: ${!this.labelManager}\n-> Null GraphicsView: ${!this.graphicsView}\n-> layerViewManager.updating: ${this.layerViewManager?.updating}\n-> labelManager.updating: ${this.labelManager?.updating}\n-> graphicsView.updating: ${this.graphicsView?.updating}\n-> allLayerViews: ${JSON.stringify(i)}\n-> updatingMagnifier: ${e}\n`)}return t}get viewpoint(){return super.viewpoint}set viewpoint(e){super.viewpoint=e}get visibleArea(){const e=this.stateManager.visibleArea;return e?new m({rings:[e.map(e=>[e[0],e[1]])],spatialReference:this.spatialReference}):e}get zoom(){return this.stateManager.zoom??-1}set zoom(e){this.stateManager.zoom=e}get navigating(){return this.mapViewNavigation?.interacting??!1}async hitTest(e,t){return E(this,e,t)}async takeScreenshot(e){return G(this._getScreenshotView(e),e)}toScreen(e,t){return this.stateManager.toScreen(e,t)}async whenAnalysisView(e){if(null==e.parent)throw new s("view:no-analysisview-for-analysis","The analysis does not exist in view.analyses",{analysis:e});return this.analysisViewManager.whenAnalysisView(e)}whenLayerView(e){return super.whenLayerView(e)}graphicChanged(e){if(this.graphicsView){this.graphicsView.graphicUpdateHandler(e)}}whenReady(){return new Promise(e=>{this.ready?e(this):this._resolveWhenReady.push(e)})}forceDOMReadyCycle(){this.forceReadyCycle()}getDefaultSpatialReference(){return this.map&&"initialViewProperties"in this.map&&this.map.initialViewProperties.spatialReference||this.defaultsFromMap?.spatialReference||null}getDefaultTimeZone(){return Z(this.map)?this.map.initialViewProperties.timeZone:null}getDefaultTimeExtent(){return Z(this.map)?this.map.initialViewProperties.timeExtent:null}hasLayerViewModule(e){return L.hasLayerViewModule(e)}importLayerView(e){return L.importLayerView(e)}pixelSizeAt(){return this.ready?this.resolution:(a.getLogger(this).error("#pixelSizeAt()","Map view cannot be used before it is ready"),null)}async popupHitTest(e){const t=this.toMap(e),i=await this.hitTest(e),r=this.allLayerViews.toArray().filter(i=>i.clips.every(i=>D(this,i,e,t))).reverse(),s=new globalThis.Map(r.map(e=>[e.layer.uid,e])),a=[];let n=0,o=0;for(;n<i.results.length||o<r.length;){const e=i.results.at(n);if(e&&"graphic"!==e.type){++n;continue}const l=s.get((e?.layer??e?.graphic.layer)?.uid);if((!e||l)&&o<r.length&&r.at(o)!==l){const e=r.at(o);"fetchPopupFeaturesAtLocation"in e&&a.push({mapPoint:t,layerView:e}),++o}else e&&(a.push({graphic:e.graphic,layerView:l}),++n)}return{hits:a,location:t}}requestUpdate(){this.ready&&this.frameTask.requestUpdate()}async validate(){let e=$(this.type);if(has("safari")&&has("safari")<9&&(e=new s("mapview:browser-not-supported","This browser is not supported by MapView (Safari < 9)",{type:"safari",requiredVersion:9,detectedVersion:has("safari")})),null!=e){a.getLogger(this).warn("#validate()",e.message);const t=document.createElement("div");t.setAttribute("style","display: flex; flex-direction: column; gap: 8px; padding: 20px; height: 100%; justify-content: center; color: black; background: white; font-family: sans-serif;");const i=document.createElement("div");i.innerHTML="Unable to display map. WebGL2 support is required.",i.setAttribute("style","font-size: 24px; font-weight: bold;");const r=document.createElement("div");r.innerHTML="Ensure that your browser and hardware meet the minimum requirements.",r.setAttribute("style","font-size: 18px;");const s=document.createElement("a");throw s.innerHTML="https://esriurl.com/systemRequirements",s.target="_blank",s.setAttribute("style","font-size: 18px;"),s.href="https://esriurl.com/systemRequirements",t.appendChild(i),t.appendChild(r),t.appendChild(s),this.surface.appendChild(t),e}}loadAsyncDependencies(){return re()}_getDefaultViewpoint(){const{constraints:e,initialExtent:i,map:r,padding:s,size:a}=this;if(!e)return null;const n=r&&"initialViewProperties"in r?r.initialViewProperties:void 0,o=this.stateManager.getUserStartupOptions(this.size),l=n?.viewpoint,p=l?.targetGeometry?.extent??i,h=p?.center,g=l?.rotation??0,d=l?.scale||p&&O(p,[a[0]-s.left-s.right,a[1]-s.top-s.bottom]),c=o.center??h,u=o.rotation??g,m=o.scale??d;return c&&m?new t({targetGeometry:c,scale:m,rotation:u}):null}_startup(){this.timeline.begin("MapView Startup");const e=this._getDefaultViewpoint();this.stateManager.startup(e,this.size,this.spatialReference,this.defaultsFromMap.extent?.center),this.graphics.owner=this;const t=new C(this.surface),i=new K(this.surface,{canvas:this.renderCanvas,contextOptions:new B(this.deactivatedWebGLExtensions,this.debugWebGLExtensions),renderingOptions:this.renderingOptions,timeline:this.timeline},t);this.stage=i,this._magnifierView=new te,this._magnifierView.magnifier=this.magnifier,this._gridView=new ie;const r=new Y({view:this});this._set("labelManager",r);const s=new R({view:this});this._set("animationManager",s);const a=new ee({view:this,animationManager:s});this._set("mapViewNavigation",a),this._setupSpatialReferenceDependentProperties(),this.addHandles([this.rootLayerViews.on("change",()=>this._updateStageChildren()),i.on("webgl-error",e=>this.fatalError=e.error),o(()=>this.stationary,e=>i.stationary=e,l),o(()=>this.background,e=>{i.backgroundColor=e?.color,this._magnifierView.backgroundColor=e?.color},l),o(()=>this.magnifier,e=>this._magnifierView.magnifier=e,l),o(()=>this.grid,e=>this._gridView.grid=e,l),o(()=>this.renderingOptions,e=>i.renderingOptions=e,l),o(()=>this.highlights.items.map(e=>({name:e.name,options:{fillColor:e.color,haloColor:e.haloColor,fillOpacity:e.fillOpacity,haloOpacity:e.haloOpacity,haloWidth:e.haloWidth,haloBlur:e.haloBlur}})),()=>{i.highlightGradient=x(i.highlightGradient,this.highlights.items)},l),o(()=>this.state.id,()=>i.state=this.state,l)],"map-view"),this._updateStageChildren();const n=this._resolveWhenReady;this._resolveWhenReady=[],n.forEach(e=>e(this)),this.timeline.end("MapView Startup"),this.frameTask.start(),this._set("ready",!0)}_teardown(){this._destroySpatialReferenceDependentProperties(),this.removeHandles("map-view"),this.mapViewNavigation.destroy(),this._set("mapViewNavigation",null),this.animation=null,this.animationManager.destroy(),this._set("animationManager",null),this.layerViewManager.clear(),this.labelManager.destroy(),this._magnifierView.destroy(),this._gridView.destroy(),this.stage.destroy(),this.stage=null,this._set("graphicsView",null),this._magnifierView=null,this._gridView=null,this._set("labelManager",null),this._set("mapViewNavigation",null),this.graphics.owner=null,this.frameTask.stop(),this.stationaryManager.clear(),this._set("ready",!1),this.stateManager.teardown()}_updateStageChildren(){this.stage.removeAllChildren(),this.rootLayerViews.forEach(e=>{this.stage.addChild(e.container)});const e=this.graphicsView;this.stage.addChild(e.container),this.stage.addChild(this._magnifierView),this.stage.addChild(this._gridView)}_setupSpatialReferenceDependentProperties(){const e=new S(f.create({spatialReference:this.spatialReference,size:512,numLODs:36}));this._set("featuresTilingScheme",e);const t=new Q({view:this,graphics:this.graphics,requestUpdateCallback:()=>this.requestUpdate(),container:new X(e)});this._set("graphicsView",t)}_destroySpatialReferenceDependentProperties(){const e=this.graphicsView;this._set("graphicsView",null),e.destroy(),this._set("featuresTilingScheme",null)}_getScreenshotView(e){const{allLayerViews:t,padding:i,size:r,stage:s}=this;return{allLayerViews:t,backgroundColor:e?.ignoreBackground?null:this.background?.color,padding:i,size:r,stage:s}}_spatialReferenceChanged(e){if(this.ready){this.frameTask.stop();for(const e of this.allLayerViews)e.processDetach();this._destroySpatialReferenceDependentProperties(),this.stateManager.changeSpatialReference(e),this.stage.state=this.state,this._setupSpatialReferenceDependentProperties();for(const e of this.allLayerViews)e.processAttach();this.frameTask.requestFrame(),this.frameTask.start(),this._updateStageChildren()}}static{this.type="2d"}};e([h({constructOnly:!0})],se.prototype,"deactivatedWebGLExtensions",void 0),e([h({constructOnly:!0})],se.prototype,"debugWebGLExtensions",void 0),e([h({readOnly:!0})],se.prototype,"featuresTilingScheme",void 0),e([h({readOnly:!0})],se.prototype,"graphicsTileStore",null),e([h()],se.prototype,"graphicsView",void 0),e([h()],se.prototype,"constraintsInfo",null),e([h()],se.prototype,"initialExtentRequired",null),e([h()],se.prototype,"labelManager",void 0),e([h({type:q,nonNullable:!0})],se.prototype,"navigation",void 0),e([h({constructOnly:!0})],se.prototype,"renderCanvas",void 0),e([h()],se.prototype,"renderingOptions",void 0),e([h({constructOnly:!0})],se.prototype,"supersampleScreenshotsEnabled",void 0),e([h({readOnly:!0})],se.prototype,"supportsGround",void 0),e([h()],se.prototype,"defaultsFromMapSettings",null),e([h({readOnly:!0})],se.prototype,"typeSpecificPreconditionsReady",null),e([h(u(w,"analyses"))],se.prototype,"analyses",void 0),e([h()],se.prototype,"analysisViewManager",void 0),e([h({type:J})],se.prototype,"background",null),e([h()],se.prototype,"center",null),e([h({type:i})],se.prototype,"floors",void 0),e([h()],se.prototype,"grid",void 0),e([h({type:W})],se.prototype,"highlightOptions",null),e([h()],se.prototype,"map",void 0),e([h()],se.prototype,"padding",null),e([h({readOnly:!0})],se.prototype,"rendering",null),e([h({readOnly:!0})],se.prototype,"resolution",null),e([h()],se.prototype,"scale",null),e([h({type:Boolean,value:!1})],se.prototype,"spatialReferenceLocked",null),e([h({readOnly:!0})],se.prototype,"tileInfo",null),e([h({type:U,readOnly:!0})],se.prototype,"timeline",void 0),e([h({readOnly:!0})],se.prototype,"type",void 0),e([h({readOnly:!0})],se.prototype,"updating",null),e([h({readOnly:!0})],se.prototype,"view2dType",void 0),e([h({readOnly:!0})],se.prototype,"visibleArea",null),e([h()],se.prototype,"zoom",null),e([h({readOnly:!0})],se.prototype,"navigating",null),e([h(),g(e=>e instanceof F?e:c(H,e))],se.prototype,"ui",void 0),se=e([d("esri.views.View2D")],se);const ae=se;export{ae as default};
5
+ import{__decorate as e}from"tslib";import t from"../Viewpoint.js";import i from"../core/Collection.js";import r from"../core/CollectionFlattener.js";import s from"../core/Error.js";import has from"../core/has.js";import a from"../core/Logger.js";import{destroyMaybe as n}from"../core/maybe.js";import{watch as o,syncAndInitial as l}from"../core/reactiveUtils.js";import{initialize as p}from"../core/workers/workers.js";import{property as h}from"../core/accessorSupport/decorators/property.js";import{cast as g}from"../core/accessorSupport/decorators/cast.js";import"../core/RandomLCG.js";import{subclass as d}from"../core/accessorSupport/decorators/subclass.js";import{ensureClass as c}from"../core/accessorSupport/ensureType.js";import{owningCollectionProperty as u}from"../core/support/OwningCollection.js";import m from"../geometry/Polygon.js";import{isLoadedOrLoadFor as y}from"../geometry/projectionUtils.js";import f from"../layers/support/TileInfo.js";import{AnalysesCollection as w}from"../support/AnalysesCollection.js";import{BreakpointsOwner as V}from"./BreakpointsOwner.js";import{DOMContainer as M}from"./DOMContainer.js";import{PopupView as v}from"./PopupView.js";import b from"./View.js";import{Viewport2DBaseMixin as _}from"./Viewport2DBaseMixin.js";import{Viewport2DMixin as j}from"./Viewport2DMixin.js";import R from"./2d/AnimationManager.js";import{layerView2DImporter as L}from"./2d/layerViewModuleImportUtils.js";import S from"./2d/tiling/TileInfoView.js";import"./2d/tiling/TileKey.js";import"./2d/tiling/TileQueue.js";import"./2d/tiling/TileStrategy.js";import{extentToScale as O}from"./2d/viewpointUtils.js";import{importAnalysisViewModule as T}from"./2d/analysis/analysisViewModuleImportUtils.js";import{ManagedCanvas as C}from"./2d/engine/ManagedCanvas.js";import k from"./2d/layers/features/support/TileStore.js";import{createOrReuseHighlightGradient as x}from"./2d/layers/support/util.js";import{clipContainsPoint as D}from"./2d/support/clippingUtils.js";import{getDefaultHighlightOptions as A,setDefaultHighlightOptions as P}from"./2d/support/highlightOptionsUtils.js";import{hitTest as E}from"./2d/support/hitTestUtils.js";import{takeRawScreenshot as z,takeScreenshot as U}from"./2d/support/screenshotUtils.js";import{Timeline as G}from"./2d/support/Timeline.js";import q from"./navigation/Navigation.js";import I from"./navigation/NavigationActionMap.js";import N from"./support/AnalysisViewManager.js";import W from"./support/HighlightOptions.js";import{check as $}from"./support/WebGLRequirements.js";import F from"./ui/DefaultUI.js";import H from"./ui/2d/DefaultUI2D.js";import{RenderingContextOptions as B}from"./webgl/RenderingContextOptions.js";import{isWebMap as Z}from"../webmap/utils.js";import J from"../webmap/background/ColorBackground.js";let K,Q,X,Y,ee,te,ie;async function re(){const[,{GraphicsView2D:e,GraphicContainer:t,LabelManager:i,MapViewNavigation:r,MagnifierView2D:s,GridView2D:a,Stage:n}]=await Promise.all([import("./2d/webglDeps.js"),import("./2d/mapViewDeps.js")]);Q=e,X=t,Y=i,ee=r,te=s,ie=a,K=n}let se=class extends(j(_(V(v(M(b)))))){get timeZone(){return super.timeZone}set timeZone(e){super.timeZone=e}constructor(e){super(e),this._magnifierView=null,this._gridView=null,this.stage=null,this._resolveWhenReady=[],this.rootLayerViews=new r({getCollections:()=>[this.basemapView?.baseLayerViews,this.layerViews,this.basemapView?.referenceLayerViews],getChildrenFunction:()=>null}),this.featuresTilingScheme=null,this.graphicsView=null,this.labelManager=null,this.navigation=new q({actionMap:new I({dragTertiary:"none"})}),this.renderingOptions={samplingMode:"dynamic",edgeLabelsVisible:!0,labelsAnimationTime:125,labelCollisionsEnabled:!0},this.supersampleScreenshotsEnabled=!0,this.analyses=new w,this.analysisViewManager=new N({importAnalysisViewModule:e=>T(e),view:this}),this.floors=new i,this.grid=null,this.map=null,this.timeline=new G,this.type="2d",this.view2dType=null,this.ui=new H,this.test={takeScreenshot:async e=>z(this._getScreenshotView(e),e)},this.padding={top:0,right:0,bottom:0,left:0},p()}destroy(){this.layerViewManager.clear(),this._set("preconditionsReady",!1),this.frameTask=n(this.frameTask),this.goToManager.destroy(),this.rootLayerViews.destroy(),this.inputManager.destroy(),this._set("inputManager",null)}get graphicsTileStore(){return new k(this.featuresTilingScheme)}get constraintsInfo(){const e=this.defaultsFromMap?.tileInfo,t=this.spatialReference;return{lods:e?.spatialReference?.equals(t)?e.lods:null,spatialReference:t}}get initialExtentRequired(){if(!this.stateManager)return!1;const{scale:e,constraints:t,center:i,viewpoint:r,extent:s}=this;let a=this.zoom;return!(this.map&&"initialViewProperties"in this.map&&this.map.initialViewProperties?.viewpoint)&&(!s&&(t?.effectiveLODs||(a=-1),(!i||0===e&&-1===a)&&(null==r?.targetGeometry||"extent"!==r.targetGeometry.type&&!r.scale)))}get defaultsFromMapSettings(){return{required:{extent:!1,heightModelInfo:!1,tileInfo:!0},requiresExtentInSpatialReference:this.spatialReferenceLocked}}get scheduler(){return this.frameTask.scheduler}get typeSpecificPreconditionsReady(){const e=this._getDefaultViewpoint();if(!e)return!1;const t=e.targetGeometry,i=this.spatialReference;return y(t.spatialReference,i)}get background(){return Z(this.map)?this.map.initialViewProperties.background:null}set background(e){this._override("background",e)}get center(){return this.stateManager?.center??null}set center(e){this.stateManager.center=e}get constraints(){return super.constraints}set constraints(e){super.constraints=e}get highlightOptions(){return A(this)}set highlightOptions(e){P(this,e)}get padding(){return this.stateManager?.padding}set padding(e){this.stateManager&&(this.stateManager.padding=e)}get rendering(){return this.stage?.renderRequested??!1}get resizeAlign(){return super.resizeAlign}set resizeAlign(e){super.resizeAlign=e}get resolution(){return this.stateManager.resolution??0}get rotation(){return super.rotation}set rotation(e){super.rotation=e}get scale(){return this.stateManager?.scale??0}set scale(e){this.stateManager&&(this.stateManager.scale=e)}get spatialReference(){return super.spatialReference}set spatialReference(e){super.spatialReference=e}get spatialReferenceLocked(){return this._get("spatialReferenceLocked")}set spatialReferenceLocked(e){this.stage&&a.getLogger(this).warn("spatialReferenceLocked cannot be changed after the view has become ready"),this._set("spatialReferenceLocked",e)}get tileInfo(){return this.featuresTilingScheme?.tileInfo}get updating(){const e=!(!this.magnifier.visible||null===this.magnifier.position||!this._magnifierView?.updatingHandles.updating),t=!this.destroyed&&(!this.analysisViewManager||!this.layerViewManager||!this.labelManager||!this.graphicsView||!0===this.analysisViewManager.updating||!0===this.layerViewManager.updating||!0===this.labelManager.updating||!0===this.graphicsView.updating||this.allLayerViews.some(e=>!e.destroyed&&!("layerViews"in e)&&!0===e.updating)||e);if(has("esri-2d-log-updating")){const i=this.allLayerViews.reduce((e,t)=>({...e,[`${t.layer.id}(${t.layer.type})`]:!t.destroyed&&!("layerViews"in t)&&t.updating}),{});console.log(`Updating MapView: ${t}\n-> Null LayerViewManager: ${!this.layerViewManager}\n-> Null LabelManager: ${!this.labelManager}\n-> Null GraphicsView: ${!this.graphicsView}\n-> layerViewManager.updating: ${this.layerViewManager?.updating}\n-> labelManager.updating: ${this.labelManager?.updating}\n-> graphicsView.updating: ${this.graphicsView?.updating}\n-> allLayerViews: ${JSON.stringify(i)}\n-> updatingMagnifier: ${e}\n`)}return t}get viewpoint(){return super.viewpoint}set viewpoint(e){super.viewpoint=e}get visibleArea(){const e=this.stateManager.visibleArea;return e?new m({rings:[e.map(e=>[e[0],e[1]])],spatialReference:this.spatialReference}):e}get zoom(){return this.stateManager.zoom??-1}set zoom(e){this.stateManager.zoom=e}get navigating(){return this.mapViewNavigation?.interacting??!1}async hitTest(e,t){return E(this,e,t)}async takeScreenshot(e){return U(this._getScreenshotView(e),e)}toScreen(e,t){return this.stateManager.toScreen(e,t)}async whenAnalysisView(e){if(null==e.parent)throw new s("view:no-analysisview-for-analysis","The analysis does not exist in view.analyses",{analysis:e});return this.analysisViewManager.whenAnalysisView(e)}whenLayerView(e){return super.whenLayerView(e)}graphicChanged(e){if(this.graphicsView){this.graphicsView.graphicUpdateHandler(e)}}whenReady(){return new Promise(e=>{this.ready?e(this):this._resolveWhenReady.push(e)})}forceDOMReadyCycle(){this.forceReadyCycle()}getDefaultSpatialReference(){return this.map&&"initialViewProperties"in this.map&&this.map.initialViewProperties.spatialReference||this.defaultsFromMap?.spatialReference||null}getDefaultTimeZone(){return Z(this.map)?this.map.initialViewProperties.timeZone:null}getDefaultTimeExtent(){return Z(this.map)?this.map.initialViewProperties.timeExtent:null}hasLayerViewModule(e){return L.hasLayerViewModule(e)}importLayerView(e){return L.importLayerView(e)}pixelSizeAt(){return this.ready?this.resolution:(a.getLogger(this).error("#pixelSizeAt()","Map view cannot be used before it is ready"),null)}async popupHitTest(e){const t=this.toMap(e),i=await this.hitTest(e),r=this.allLayerViews.toArray().filter(i=>i.clips.every(i=>D(this,i,e,t))).reverse(),s=new globalThis.Map(r.map(e=>[e.layer.uid,e])),a=[];let n=0,o=0;for(;n<i.results.length||o<r.length;){const e=i.results.at(n);if(e&&"graphic"!==e.type){++n;continue}const l=s.get((e?.layer??e?.graphic.layer)?.uid);if((!e||l)&&o<r.length&&r.at(o)!==l){const e=r.at(o);"fetchPopupFeaturesAtLocation"in e&&a.push({mapPoint:t,layerView:e}),++o}else e&&(a.push({graphic:e.graphic,layerView:l}),++n)}return{hits:a,location:t}}requestUpdate(){this.ready&&this.frameTask.requestUpdate()}async validate(){let e=$(this.type);if(has("safari")&&has("safari")<9&&(e=new s("mapview:browser-not-supported","This browser is not supported by MapView (Safari < 9)",{type:"safari",requiredVersion:9,detectedVersion:has("safari")})),null!=e){a.getLogger(this).warn("#validate()",e.message);const t=document.createElement("div");t.setAttribute("style","display: flex; flex-direction: column; gap: 8px; padding: 20px; height: 100%; justify-content: center; color: black; background: white; font-family: sans-serif;");const i=document.createElement("div");i.innerHTML="Unable to display map. WebGL2 support is required.",i.setAttribute("style","font-size: 24px; font-weight: bold;");const r=document.createElement("div");r.innerHTML="Ensure that your browser and hardware meet the minimum requirements.",r.setAttribute("style","font-size: 18px;");const s=document.createElement("a");throw s.innerHTML="https://esriurl.com/systemRequirements",s.target="_blank",s.setAttribute("style","font-size: 18px;"),s.href="https://esriurl.com/systemRequirements",t.appendChild(i),t.appendChild(r),t.appendChild(s),this.surface.appendChild(t),e}}loadAsyncDependencies(){return re()}_getDefaultViewpoint(){const{constraints:e,initialExtent:i,map:r,padding:s,size:a}=this;if(!e)return null;const n=r&&"initialViewProperties"in r?r.initialViewProperties:void 0,o=this.stateManager.getUserStartupOptions(this.size),l=n?.viewpoint,p=l?.targetGeometry?.extent??i,h=p?.center,g=l?.rotation??0,d=l?.scale||p&&O(p,[a[0]-s.left-s.right,a[1]-s.top-s.bottom]),c=o.center??h,u=o.rotation??g,m=o.scale??d;return c&&m?new t({targetGeometry:c,scale:m,rotation:u}):null}_startup(){this.timeline.begin("MapView Startup");const e=this._getDefaultViewpoint();this.stateManager.startup(e,this.size,this.spatialReference,this.defaultsFromMap.extent?.center),this.graphics.owner=this;const t=new C(this.surface),i=new K(this.surface,{canvas:this.renderCanvas,contextOptions:new B(this.deactivatedWebGLExtensions,this.debugWebGLExtensions),renderingOptions:this.renderingOptions,timeline:this.timeline},t);this.stage=i,this._magnifierView=new te,this._magnifierView.magnifier=this.magnifier,this._gridView=new ie;const r=new Y({view:this});this._set("labelManager",r);const s=new R({view:this});this._set("animationManager",s);const a=new ee({view:this,animationManager:s});this._set("mapViewNavigation",a),this._setupSpatialReferenceDependentProperties(),this.addHandles([this.rootLayerViews.on("change",()=>this._updateStageChildren()),i.on("webgl-error",e=>this.fatalError=e.error),o(()=>this.stationary,e=>i.stationary=e,l),o(()=>this.background,e=>{i.backgroundColor=e?.color,this._magnifierView.backgroundColor=e?.color},l),o(()=>this.magnifier,e=>this._magnifierView.magnifier=e,l),o(()=>this.grid,e=>this._gridView.grid=e,l),o(()=>this.renderingOptions,e=>i.renderingOptions=e,l),o(()=>this.highlights.items.map(e=>({name:e.name,options:{fillColor:e.color,haloColor:e.haloColor,fillOpacity:e.fillOpacity,haloOpacity:e.haloOpacity,haloWidth:e.haloWidth,haloBlur:e.haloBlur}})),()=>{i.highlightGradient=x(i.highlightGradient,this.highlights.items)},l),o(()=>this.state.id,()=>i.state=this.state,l)],"map-view"),this._updateStageChildren();const n=this._resolveWhenReady;this._resolveWhenReady=[],n.forEach(e=>e(this)),this.timeline.end("MapView Startup"),this.frameTask.start(),this._set("ready",!0)}_teardown(){this._destroySpatialReferenceDependentProperties(),this.removeHandles("map-view"),this.mapViewNavigation.destroy(),this._set("mapViewNavigation",null),this.animation=null,this.animationManager.destroy(),this._set("animationManager",null),this.layerViewManager.clear(),this.labelManager.destroy(),this._magnifierView.destroy(),this._gridView.destroy(),this.stage.destroy(),this.stage=null,this._set("graphicsView",null),this._magnifierView=null,this._gridView=null,this._set("labelManager",null),this._set("mapViewNavigation",null),this.graphics.owner=null,this.frameTask.stop(),this.stationaryManager.clear(),this._set("ready",!1),this.stateManager.teardown()}_updateStageChildren(){this.stage.removeAllChildren(),this.rootLayerViews.forEach(e=>{this.stage.addChild(e.container)});const e=this.graphicsView;this.stage.addChild(e.container),this.stage.addChild(this._magnifierView),this.stage.addChild(this._gridView)}_setupSpatialReferenceDependentProperties(){const e=new S(f.create({spatialReference:this.spatialReference,size:512,numLODs:36}));this._set("featuresTilingScheme",e);const t=new Q({view:this,graphics:this.graphics,requestUpdateCallback:()=>this.requestUpdate(),container:new X(e)});this._set("graphicsView",t)}_destroySpatialReferenceDependentProperties(){const e=this.graphicsView;this._set("graphicsView",null),e.destroy(),this._set("featuresTilingScheme",null)}_getScreenshotView(e){const{allLayerViews:t,padding:i,size:r,stage:s}=this;return{allLayerViews:t,backgroundColor:e?.ignoreBackground?null:this.background?.color,padding:i,size:r,stage:s}}_spatialReferenceChanged(e){if(this.ready){this.frameTask.stop();for(const e of this.allLayerViews)e.processDetach();this._destroySpatialReferenceDependentProperties(),this.stateManager.changeSpatialReference(e),this.stage.state=this.state,this._setupSpatialReferenceDependentProperties();for(const e of this.allLayerViews)e.processAttach();this.frameTask.requestFrame(),this.frameTask.start(),this._updateStageChildren()}}static{this.type="2d"}};e([h({constructOnly:!0})],se.prototype,"deactivatedWebGLExtensions",void 0),e([h({constructOnly:!0})],se.prototype,"debugWebGLExtensions",void 0),e([h({readOnly:!0})],se.prototype,"featuresTilingScheme",void 0),e([h({readOnly:!0})],se.prototype,"graphicsTileStore",null),e([h()],se.prototype,"graphicsView",void 0),e([h()],se.prototype,"constraintsInfo",null),e([h()],se.prototype,"initialExtentRequired",null),e([h()],se.prototype,"labelManager",void 0),e([h({type:q,nonNullable:!0})],se.prototype,"navigation",void 0),e([h({constructOnly:!0})],se.prototype,"renderCanvas",void 0),e([h()],se.prototype,"renderingOptions",void 0),e([h({constructOnly:!0})],se.prototype,"supersampleScreenshotsEnabled",void 0),e([h()],se.prototype,"defaultsFromMapSettings",null),e([h({readOnly:!0})],se.prototype,"typeSpecificPreconditionsReady",null),e([h(u(w,"analyses"))],se.prototype,"analyses",void 0),e([h()],se.prototype,"analysisViewManager",void 0),e([h({type:J})],se.prototype,"background",null),e([h()],se.prototype,"center",null),e([h({type:i})],se.prototype,"floors",void 0),e([h()],se.prototype,"grid",void 0),e([h({type:W})],se.prototype,"highlightOptions",null),e([h()],se.prototype,"map",void 0),e([h()],se.prototype,"padding",null),e([h({readOnly:!0})],se.prototype,"rendering",null),e([h({readOnly:!0})],se.prototype,"resolution",null),e([h()],se.prototype,"scale",null),e([h({type:Boolean,value:!1})],se.prototype,"spatialReferenceLocked",null),e([h({readOnly:!0})],se.prototype,"tileInfo",null),e([h({type:G,readOnly:!0})],se.prototype,"timeline",void 0),e([h({readOnly:!0})],se.prototype,"type",void 0),e([h({readOnly:!0})],se.prototype,"updating",null),e([h({readOnly:!0})],se.prototype,"view2dType",void 0),e([h({readOnly:!0})],se.prototype,"visibleArea",null),e([h()],se.prototype,"zoom",null),e([h({readOnly:!0})],se.prototype,"navigating",null),e([h(),g(e=>e instanceof F?e:c(H,e))],se.prototype,"ui",void 0),se=e([d("esri.views.View2D")],se);const ae=se;export{ae 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.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import r from"../../core/Accessor.js";import i from"../../core/Error.js";import t from"../../core/Logger.js";import{someMap as s}from"../../core/MapUtils.js";import{createResolver as o,createAbortError as a,isAbortError as n}from"../../core/promiseUtils.js";import{on as l,watch as y,syncAndInitial as h}from"../../core/reactiveUtils.js";import{schedule as p}from"../../core/scheduling.js";import{property as c}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import{get as w}from"../../core/accessorSupport/get.js";import{UpdatingHandles as m}from"../../core/support/UpdatingHandles.js";import{destroyMap as u}from"../../support/collectionUtils.js";import{LayerLayerViewInfo as f}from"./LayerLayerViewInfo.js";function g(e){return null!=e&&"object"==typeof e&&"layerViews"in e}let _=class extends r{constructor(e){super(e),this._layerLayerViewInfoMap=new Map,this._recyclingInfoMap=new Map,this._watchUpdatingTracking=new m,this.supportsGround=!0,this._preloadLayerViewModules=()=>{const e=this.view.map?.allLayers;if(e)for(const r of e)!1!==this.layerViewFilter?.(r)&&this.layerViewImporter.hasLayerViewModule(r)&&this.layerViewImporter.importLayerView(r)},this._reschedule=()=>this.destroyed?Promise.reject():(null==this._workPromise&&(this._workPromise=o(),this._workPromise.promise.catch(()=>{})),this.removeHandles("reschedule"),this.addHandles(p(this._doWork),"reschedule"),this._workPromise.promise),this._doWork=()=>{if(this.destroyed)return;const{map:e}=this.view;if(!e)return void this.clear();if(this._map!==e&&(this.clear(),this._map=e),null==this._workPromise)return void this.notifyChange("updating");this.removeHandles("reschedule"),this.removeHandles("collection-change");const r=new Set,i=[],t=this.view.ready,s=e=>{if(null!=e)for(const o of e)if(o){if(!1===this.layerViewFilter?.(o))continue;r.add(o);const e=this._layerLayerViewInfoMap.get(o);e&&t?e.start():e||this._recyclingInfoMap.has(o)||i.push(o),"layers"in o&&o.layers&&s(o.layers)}};for(const n of this._rootCollectionNames)s(w(this,n));const o=new Array,a=e=>{const r=e.tryRecycle(i);r?(this._recyclingInfoMap.set(e.layer,e),this.notifyChange("updating"),r.then(()=>{this._recyclingInfoMap.delete(e.layer),this._layerLayerViewInfoMap.set(e.layer,e),this._reschedule(),this.notifyChange("updating")}).catch(r=>{n(r)||(this._recyclingInfoMap.delete(e.layer),e.destroy(),this._reschedule(),this.notifyChange("updating"))})):o.push(e)};for(const n of this._layerLayerViewInfoMap.values())r.has(n.layer)||(this._layerLayerViewInfoMap.delete(n.layer),a(n));for(const n of this._recyclingInfoMap.values())r.has(n.layer)||(this._recyclingInfoMap.delete(n.layer),a(n));for(const n of i)this._createLayerView(n);this._refreshCollections(),o.forEach(e=>e.destroy());const l=[e?.ground?.layers,e?.basemap?.baseLayers,e?.basemap?.groundLayers,e?.basemap?.referenceLayers,e?.layers].filter(e=>!!e);r.forEach(e=>"layers"in e&&l.push(e.layers)),this.addHandles(l.map(e=>this._watchUpdatingTracking.addOnCollectionChange(()=>e,this._reschedule)),"collection-change"),this._workPromise.resolve(),this._workPromise=null}}initialize(){this.addHandles([l(()=>this.view?.map?.allLayers,"change",this._preloadLayerViewModules,{onListenerAdd:this._preloadLayerViewModules}),y(()=>{const e=this.view,r=e?.map;return[r?.basemap,r?.ground,r?.layers,e?.ready]},()=>this._reschedule(),h)]),this._preloadLayerViewModules(),this._reschedule()}clearHandles(){this._watchUpdatingTracking.removeAll()}destroy(){this.clear(),u(this._recyclingInfoMap),u(this._layerLayerViewInfoMap),this._watchUpdatingTracking.destroy(),this._map=null,null!=this._workPromise&&(this._workPromise.reject(a()),this._workPromise=null)}get _layersToLayerViews(){const e=[["view.map.basemap.baseLayers","view.basemapView.baseLayerViews"],["view.map.basemap.groundLayers","view.basemapView.groundLayerViews"],["view.map.basemap.referenceLayers","view.basemapView.referenceLayerViews"],["view.map.layers","view.layerViews"]];return this.supportsGround&&e.push(["view.map.ground.layers","view.groundView.layerViews"]),new Map(e)}get _rootCollectionNames(){return Array.from(this._layersToLayerViews.keys())}get updating(){return null!=this._workPromise||this._watchUpdatingTracking.updating||s(this._layerLayerViewInfoMap,e=>!e.done)||this._recyclingInfoMap.size>0}get updatingRemaining(){let e=0;for(const r of this._layerLayerViewInfoMap.values())r.done||++e;return e}clear(){this.destroyed||(this._clearCollections(),u(this._layerLayerViewInfoMap))}async whenLayerView(e){await this._reschedule();const r=this._layerLayerViewInfoMap.get(e)?.promise;if(!r){const r=this._recyclingInfoMap.get(e)?.promise;if(!r)throw new i("view:no-layerview-for-layer","No layerview has been found for the layer",{layer:e});return r}return r}isCreatingLayerViewsForLayer(e,r){this.commitProperty("updatingRemaining");const i=this._layerLayerViewInfoMap.get(e);if(!i?.done)return!0;const t=i.layerView;return!(!t||!r||t.parent===r)||!!(i.done&&t&&"layers"in e&&e.layers?.length)&&e.layers.some(e=>this.isCreatingLayerViewsForLayer(e,t))}_refreshCollections(){for(const[e,r]of this._layersToLayerViews)this._populateLayerViewsOwners(w(this,e),w(this,r),this.view);this.notifyChange("updating"),this.notifyChange("updatingRemaining")}_clearCollections(){for(const e of this._layersToLayerViews.values())w(this,e)?.removeAll()}_populateLayerViewsOwners(e,r,i){if(!e||!r)return void r?.removeAll();let t=0;for(const s of e){const e=this._layerLayerViewInfoMap.get(s);if(!e?.layerView)continue;const o=e.layerView;o.layer=s,o.parent=i,r.at(t)!==o&&r.splice(t,0,o),"layers"in s&&g(o)&&this._populateLayerViewsOwners(s.layers,o.layerViews,o),t+=1}t<r.length&&r.splice(t)}_createLayerView(e){e.load().catch(r=>{t.getLogger("LayerViewManager").error(`Error loading layer "${e.title}"`,r)}),this.layerViewImporter.hasLayerViewModule(e)&&this.layerViewImporter.importLayerView(e);const r=new f(e,this.view,this.layerViewImporter);r.promise?.then(()=>this._refreshCollections(),r=>{r&&(n(r)||"cancelled:layerview-create"===r.name)||t.getLogger(this).error(`Failed to create layerview for layer title:'${e.title??"no title"}', id:'${e.id??"no id"}' of type '${e.type}'.`,{layer:e,error:r}),this.destroyed||this._refreshCollections()}),this._layerLayerViewInfoMap.set(e,r),this.view.ready&&r.start(),this.notifyChange("updating"),this.notifyChange("updatingRemaining")}};e([c()],_.prototype,"_workPromise",void 0),e([c({readOnly:!0})],_.prototype,"_watchUpdatingTracking",void 0),e([c({readOnly:!0})],_.prototype,"_layersToLayerViews",null),e([c({readOnly:!0})],_.prototype,"_rootCollectionNames",null),e([c({constructOnly:!0})],_.prototype,"layerViewFilter",void 0),e([c()],_.prototype,"layerViewImporter",void 0),e([c()],_.prototype,"supportsGround",void 0),e([c({readOnly:!0})],_.prototype,"updating",null),e([c({readOnly:!0})],_.prototype,"updatingRemaining",null),e([c({constructOnly:!0})],_.prototype,"view",void 0),_=e([d("esri.views.support.LayerViewManager")],_);const V=_;export{V as default};
5
+ import{__decorate as e}from"tslib";import r from"../../core/Accessor.js";import t from"../../core/Error.js";import i from"../../core/Logger.js";import{someMap as o}from"../../core/MapUtils.js";import{createResolver as s,createAbortError as a,isAbortError as n}from"../../core/promiseUtils.js";import{on as l,watch as y,syncAndInitial as h}from"../../core/reactiveUtils.js";import{schedule as p}from"../../core/scheduling.js";import{property as c}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import{get as w}from"../../core/accessorSupport/get.js";import{UpdatingHandles as f}from"../../core/support/UpdatingHandles.js";import{destroyMap as u}from"../../support/collectionUtils.js";import{LayerLayerViewInfo as m}from"./LayerLayerViewInfo.js";function g(e){return null!=e&&"object"==typeof e&&"layerViews"in e}let _=class extends r{constructor(e){super(e),this._layerLayerViewInfoMap=new Map,this._recyclingInfoMap=new Map,this._watchUpdatingTracking=new f,this.supportsGround=!0,this._preloadLayerViewModules=()=>{const e=this.view.map?.allLayers;if(e)for(const r of e)!1!==this.layerViewFilter?.(r)&&this.layerViewImporter.hasLayerViewModule(r)&&this.layerViewImporter.importLayerView(r)},this._reschedule=()=>this.destroyed?Promise.reject():(null==this._workPromise&&(this._workPromise=s(),this._workPromise.promise.catch(()=>{})),this.removeHandles("reschedule"),this.addHandles(p(this._doWork),"reschedule"),this._workPromise.promise),this._doWork=()=>{if(this.destroyed)return;const{map:e}=this.view;if(!e)return void this.clear();if(this._map!==e&&(this.clear(),this._map=e),null==this._workPromise)return void this.notifyChange("updating");this.removeHandles("reschedule"),this.removeHandles("collection-change");const r=new Set,t=[],i=this.view.ready,o=e=>{if(null!=e)for(const s of e)if(s){if(!1===this.layerViewFilter?.(s))continue;r.add(s);const e=this._layerLayerViewInfoMap.get(s);e&&i?e.start():e||this._recyclingInfoMap.has(s)||t.push(s),"layers"in s&&s.layers&&o(s.layers)}};for(const n of this._rootCollectionNames)o(w(this,n));const s=new Array,a=e=>{const r=e.tryRecycle(t);r?(this._recyclingInfoMap.set(e.layer,e),this.notifyChange("updating"),r.then(()=>{this._recyclingInfoMap.delete(e.layer),this._layerLayerViewInfoMap.set(e.layer,e),this._reschedule(),this.notifyChange("updating")}).catch(r=>{n(r)||(this._recyclingInfoMap.delete(e.layer),e.destroy(),this._reschedule(),this.notifyChange("updating"))})):s.push(e)};for(const n of this._layerLayerViewInfoMap.values())r.has(n.layer)||(this._layerLayerViewInfoMap.delete(n.layer),a(n));for(const n of this._recyclingInfoMap.values())r.has(n.layer)||(this._recyclingInfoMap.delete(n.layer),a(n));for(const n of t)this._createLayerView(n);this._refreshCollections(),s.forEach(e=>e.destroy());const l=[e?.ground?.layers,e?.basemap?.baseLayers,e?.basemap?.groundLayers,e?.basemap?.referenceLayers,e?.layers].filter(e=>!!e);r.forEach(e=>"layers"in e&&l.push(e.layers)),this.addHandles(l.map(e=>this._watchUpdatingTracking.addOnCollectionChange(()=>e,this._reschedule)),"collection-change"),this._workPromise.resolve(),this._workPromise=null},this._layersToLayerViews=new Map(e.layerviewMapping)}initialize(){this.addHandles([l(()=>this.view?.map?.allLayers,"change",this._preloadLayerViewModules,{onListenerAdd:this._preloadLayerViewModules}),y(()=>{const e=this.view,r=e?.map;return[r?.basemap,r?.ground,r?.layers,e?.ready]},()=>this._reschedule(),h)]),this._preloadLayerViewModules(),this._reschedule()}clearHandles(){this._watchUpdatingTracking.removeAll()}destroy(){this.clear(),u(this._recyclingInfoMap),u(this._layerLayerViewInfoMap),this._watchUpdatingTracking.destroy(),this._map=null,null!=this._workPromise&&(this._workPromise.reject(a()),this._workPromise=null)}get _rootCollectionNames(){return Array.from(this._layersToLayerViews.keys())}get updating(){return null!=this._workPromise||this._watchUpdatingTracking.updating||o(this._layerLayerViewInfoMap,e=>!e.done)||this._recyclingInfoMap.size>0}get updatingRemaining(){let e=0;for(const r of this._layerLayerViewInfoMap.values())r.done||++e;return e}clear(){this.destroyed||(this._clearCollections(),u(this._layerLayerViewInfoMap))}async whenLayerView(e){await this._reschedule();const r=this._layerLayerViewInfoMap.get(e)?.promise;if(!r){const r=this._recyclingInfoMap.get(e)?.promise;if(!r)throw new t("view:no-layerview-for-layer","No layerview has been found for the layer",{layer:e});return r}return r}isCreatingLayerViewsForLayer(e,r){this.commitProperty("updatingRemaining");const t=this._layerLayerViewInfoMap.get(e);if(!t?.done)return!0;const i=t.layerView;return!(!i||!r||i.parent===r)||!!(t.done&&i&&"layers"in e&&e.layers?.length)&&e.layers.some(e=>this.isCreatingLayerViewsForLayer(e,i))}_refreshCollections(){for(const[e,r]of this._layersToLayerViews)this._populateLayerViewsOwners(w(this,e),w(this,r),this.view);this.notifyChange("updating"),this.notifyChange("updatingRemaining")}_clearCollections(){for(const e of this._layersToLayerViews.values())w(this,e)?.removeAll()}_populateLayerViewsOwners(e,r,t){if(!e||!r)return void r?.removeAll();let i=0;for(const o of e){const e=this._layerLayerViewInfoMap.get(o);if(!e?.layerView)continue;const{layerView:s}=e;s.layer=o,s.parent=t,r.at(i)!==s&&r.splice(i,0,s),"layers"in o&&g(s)&&this._populateLayerViewsOwners(o.layers,s.layerViews,s),++i}i<r.length&&r.splice(i)}_createLayerView(e){e.load().catch(r=>{i.getLogger("LayerViewManager").error(`Error loading layer "${e.title}"`,r)}),this.layerViewImporter.hasLayerViewModule(e)&&this.layerViewImporter.importLayerView(e);const r=new m(e,this.view,this.layerViewImporter);r.promise?.then(()=>this._refreshCollections(),r=>{r&&(n(r)||"cancelled:layerview-create"===r.name)||i.getLogger(this).error(`Failed to create layerview for layer title:'${e.title??"no title"}', id:'${e.id??"no id"}' of type '${e.type}'.`,{layer:e,error:r}),this.destroyed||this._refreshCollections()}),this._layerLayerViewInfoMap.set(e,r),this.view.ready&&r.start(),this.notifyChange("updating"),this.notifyChange("updatingRemaining")}};e([c()],_.prototype,"_workPromise",void 0),e([c({readOnly:!0})],_.prototype,"_watchUpdatingTracking",void 0),e([c({readOnly:!0})],_.prototype,"_layersToLayerViews",void 0),e([c({constructOnly:!0})],_.prototype,"layerviewMapping",void 0),e([c({readOnly:!0})],_.prototype,"_rootCollectionNames",null),e([c({constructOnly:!0})],_.prototype,"layerViewFilter",void 0),e([c()],_.prototype,"layerViewImporter",void 0),e([c()],_.prototype,"supportsGround",void 0),e([c({readOnly:!0})],_.prototype,"updating",null),e([c({readOnly:!0})],_.prototype,"updatingRemaining",null),e([c({constructOnly:!0})],_.prototype,"view",void 0),_=e([d("esri.views.support.LayerViewManager")],_);const V=_;export{V 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.34/esri/copyright.txt for details.
4
4
  */
5
- import{getBytesPerElementFormat as t}from"./Util.js";class i{constructor(t,i=0,h=i,r=!1,s=1){this.internalFormat=t,this.width=i,this.height=h,this.multisampled=r,this.samples=s}}function h(i){return i.width<=0||i.height<=0||null==i.internalFormat?0:i.width*i.height*t(i.internalFormat)}export{i as RenderbufferDescriptor,h as estimateMemory};
5
+ import{getFormatBytesPerElement as t}from"./Util.js";class i{constructor(t,i=0,h=i,r=!1,s=1){this.internalFormat=t,this.width=i,this.height=h,this.multisampled=r,this.samples=s}}function h(i){return i.width<=0||i.height<=0||null==i.internalFormat?0:i.width*i.height*t(i.internalFormat)}export{i as RenderbufferDescriptor,h as estimateMemory};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{PixelType as t}from"./enums.js";import{getBytesPerElementFormat as i}from"./Util.js";class h{constructor(i=0,h=i){this.width=i,this.height=h,this.type=0,this.target=3553,this.pixelFormat=6408,this.dataType=t.UNSIGNED_BYTE,this.samplingMode=9729,this.wrapMode=10497,this.maxAnisotropy=1,this.flipped=!1,this.hasMipmap=!1,this.isOpaque=!1,this.unpackAlignment=4,this.preMultiplyAlpha=!1,this.compareEnabled=!1,this.linearFilterDepth=!1,this.depth=1,this.isImmutable=!1}}function s(t){return t.width<=0||t.height<=0||t.depth<=0?0:Math.round(t.width*t.height*t.depth*(t.hasMipmap?4/3:1)*(null==t.internalFormat?4:i(t.internalFormat))*(34067===t.target?6:1))}export{h as TextureDescriptor,s as estimateMemory};
5
+ import{PixelType as t}from"./enums.js";import{getFormatBytesPerElement as i}from"./Util.js";class h{constructor(i=0,h=i){this.width=i,this.height=h,this.type=0,this.target=3553,this.pixelFormat=6408,this.dataType=t.UNSIGNED_BYTE,this.samplingMode=9729,this.wrapMode=10497,this.maxAnisotropy=1,this.flipped=!1,this.hasMipmap=!1,this.isOpaque=!1,this.unpackAlignment=4,this.preMultiplyAlpha=!1,this.compareEnabled=!1,this.linearFilterDepth=!1,this.depth=1,this.isImmutable=!1}}function s(t){return t.width<=0||t.height<=0||t.depth<=0?0:Math.round(t.width*t.height*t.depth*(t.hasMipmap?4/3:1)*(null==t.internalFormat?4:i(t.internalFormat))*(34067===t.target?6:1))}export{h as TextureDescriptor,s as estimateMemory};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import"../../core/has.js";import{webglDebugEnabled as e,getErrorMessage as s}from"./checkWebGLError.js";import{CompressedTextureFormat as c,SizedPixelFormat as a,SizedDepthStencilFormat as r,SizedDepthFormat as t}from"./enums.js";function R(c,a,r,t=0){const R=c.gl;c.bindBuffer(r);for(const _ of r.layout){const r=a.get(_.name);if(null==r){console.warn(`There is no location for vertex attribute '${_.name}' defined.`);continue}const n=t*_.stride;if(_.count<=4)R.vertexAttribPointer(r,_.count,_.type,_.normalized,_.stride,_.offset+n),R.enableVertexAttribArray(r),_.divisor>0&&R.vertexAttribDivisor(r,_.divisor);else if(9===_.count)for(let e=0;e<3;e++)R.vertexAttribPointer(r+e,3,_.type,_.normalized,_.stride,_.offset+12*e+n),R.enableVertexAttribArray(r+e),_.divisor>0&&R.vertexAttribDivisor(r+e,_.divisor);else if(16===_.count)for(let e=0;e<4;e++)R.vertexAttribPointer(r+e,4,_.type,_.normalized,_.stride,_.offset+16*e+n),R.enableVertexAttribArray(r+e),_.divisor>0&&R.vertexAttribDivisor(r+e,_.divisor);else console.error("Unsupported vertex attribute element count: "+_.count);if(e()){const e=s(c.gl);e&&console.error(`Unable to bind vertex attribute "${_.name}" with baseInstanceOffset ${n}:`,e,_)}}}function _(e){switch(e){case 6406:case 6409:case 6403:case 36244:case a.R8:case a.R8I:case a.R8UI:case a.R8_SNORM:case 36168:return 1;case 6410:case 33319:case 33320:case a.RGBA4:case a.R16F:case a.R16I:case a.R16UI:case a.RG8:case a.RG8I:case a.RG8UI:case a.RG8_SNORM:case a.RGB565:case a.RGB5_A1:case t.DEPTH_COMPONENT16:return 2;case 6407:case 36248:case a.RGB8:case a.RGB8I:case a.RGB8UI:case a.RGB8_SNORM:case a.SRGB8:case t.DEPTH_COMPONENT24:return 3;case 6408:case 36249:case a.RGBA8:case a.R32F:case a.R11F_G11F_B10F:case a.RG16F:case a.R32I:case a.R32UI:case a.RG16I:case a.RG16UI:case a.RGBA8I:case a.RGBA8UI:case a.RGBA8_SNORM:case a.SRGB8_ALPHA8:case a.RGB9_E5:case a.RGB10_A2UI:case a.RGB10_A2:case t.DEPTH_COMPONENT32F:case r.DEPTH24_STENCIL8:return 4;case r.DEPTH32F_STENCIL8:return 5;case a.RGB16F:case a.RGB16I:case a.RGB16UI:return 6;case a.RG32F:case a.RG32I:case a.RG32UI:case a.RGBA16F:case a.RGBA16I:case a.RGBA16UI:return 8;case a.RGB32F:case a.RGB32I:case a.RGB32UI:return 12;case a.RGBA32F:case a.RGBA32I:case a.RGBA32UI:return 16;case c.COMPRESSED_RGB_S3TC_DXT1_EXT:case c.COMPRESSED_RGBA_S3TC_DXT1_EXT:return.5;case c.COMPRESSED_RGBA_S3TC_DXT3_EXT:case c.COMPRESSED_RGBA_S3TC_DXT5_EXT:return 1;case c.COMPRESSED_R11_EAC:case c.COMPRESSED_SIGNED_R11_EAC:case c.COMPRESSED_RGB8_ETC2:case c.COMPRESSED_SRGB8_ETC2:case c.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:case c.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:return.5;case c.COMPRESSED_RG11_EAC:case c.COMPRESSED_SIGNED_RG11_EAC:case c.COMPRESSED_RGBA8_ETC2_EAC:case c.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:return 1}return 0}export{R as bindVertexBufferLayout,_ as getBytesPerElementFormat};
5
+ import"../../core/has.js";import{webglDebugEnabled as e,getErrorMessage as s}from"./checkWebGLError.js";import{CompressedTextureFormat as c,SizedPixelFormat as a,SizedDepthStencilFormat as r,SizedDepthFormat as t}from"./enums.js";function R(c,a,r,t=0){const R=c.gl;c.bindBuffer(r);for(const n of r.layout){const r=a.get(n.name);if(null==r){console.warn(`There is no location for vertex attribute '${n.name}' defined.`);continue}const _=t*n.stride;if(n.count<=4)R.vertexAttribPointer(r,n.count,n.type,n.normalized,n.stride,n.offset+_),R.enableVertexAttribArray(r),n.divisor>0&&R.vertexAttribDivisor(r,n.divisor);else if(9===n.count)for(let e=0;e<3;e++)R.vertexAttribPointer(r+e,3,n.type,n.normalized,n.stride,n.offset+12*e+_),R.enableVertexAttribArray(r+e),n.divisor>0&&R.vertexAttribDivisor(r+e,n.divisor);else if(16===n.count)for(let e=0;e<4;e++)R.vertexAttribPointer(r+e,4,n.type,n.normalized,n.stride,n.offset+16*e+_),R.enableVertexAttribArray(r+e),n.divisor>0&&R.vertexAttribDivisor(r+e,n.divisor);else console.error("Unsupported vertex attribute element count: "+n.count);if(e()){const e=s(c.gl);e&&console.error(`Unable to bind vertex attribute "${n.name}" with baseInstanceOffset ${_}:`,e,n)}}}function n(e){switch(e){case 6406:case 6409:case 6403:case 36244:case 6402:case 34041:return 1;case 6410:case 33319:case 33320:return 2;case 6407:case 36248:return 3;case 6408:case 36249:return 4}return 0}function _(e){switch(e){case 6406:case 6409:case 6403:case 36244:case a.R8:case a.R8I:case a.R8UI:case a.R8_SNORM:case 36168:return 1;case 6410:case 33319:case 33320:case a.RGBA4:case a.R16F:case a.R16I:case a.R16UI:case a.RG8:case a.RG8I:case a.RG8UI:case a.RG8_SNORM:case a.RGB565:case a.RGB5_A1:case t.DEPTH_COMPONENT16:return 2;case 6407:case 36248:case a.RGB8:case a.RGB8I:case a.RGB8UI:case a.RGB8_SNORM:case a.SRGB8:case t.DEPTH_COMPONENT24:return 3;case 6408:case 36249:case a.RGBA8:case a.R32F:case a.R11F_G11F_B10F:case a.RG16F:case a.R32I:case a.R32UI:case a.RG16I:case a.RG16UI:case a.RGBA8I:case a.RGBA8UI:case a.RGBA8_SNORM:case a.SRGB8_ALPHA8:case a.RGB9_E5:case a.RGB10_A2UI:case a.RGB10_A2:case t.DEPTH_COMPONENT32F:case r.DEPTH24_STENCIL8:return 4;case r.DEPTH32F_STENCIL8:return 5;case a.RGB16F:case a.RGB16I:case a.RGB16UI:return 6;case a.RG32F:case a.RG32I:case a.RG32UI:case a.RGBA16F:case a.RGBA16I:case a.RGBA16UI:return 8;case a.RGB32F:case a.RGB32I:case a.RGB32UI:return 12;case a.RGBA32F:case a.RGBA32I:case a.RGBA32UI:return 16;case c.COMPRESSED_RGB_S3TC_DXT1_EXT:case c.COMPRESSED_RGBA_S3TC_DXT1_EXT:return.5;case c.COMPRESSED_RGBA_S3TC_DXT3_EXT:case c.COMPRESSED_RGBA_S3TC_DXT5_EXT:return 1;case c.COMPRESSED_R11_EAC:case c.COMPRESSED_SIGNED_R11_EAC:case c.COMPRESSED_RGB8_ETC2:case c.COMPRESSED_SRGB8_ETC2:case c.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:case c.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:return.5;case c.COMPRESSED_RG11_EAC:case c.COMPRESSED_SIGNED_RG11_EAC:case c.COMPRESSED_RGBA8_ETC2_EAC:case c.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:return 1}return 0}export{R as bindVertexBufferLayout,_ as getFormatBytesPerElement,n as getFormatComponents};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{toConst as e}from"../../core/compilerUtils.js";import t from"../../core/Logger.js";import{disposeMaybe as r}from"../../core/maybe.js";import{baseTypedArrayMemory as s}from"../../core/memoryEstimations.js";import{ResourceType as i}from"./enums.js";import{bindVertexBufferLayout as n}from"./Util.js";import{fromBuffers as o}from"./VertexAttributeLocations.js";const f=()=>t.getLogger("esri.views.webgl.VertexArrayObject");let u=class{constructor(t,r,s){this._context=t,this._indexBuffer=s,this._buffers=r instanceof Map?r:new Map([["geometry",r]]),this.locations=e(o(this._buffers))}get glName(){return this._glName}get context(){return this._context}get buffers(){return e(this._buffers)}buffer(e="geometry"){return this.buffers.get(e)}get indexBuffer(){return this._indexBuffer}getByteLength(e){return this.buffer(e)?.sizeBytes??0}vertexCount(e){const t=this.buffer(e);return t?t.sizeBytes/t.layout[0].stride:0}get usedMemory(){return Array.from(this._buffers.values()).reduce((e,t)=>e+t.usedMemory,this._indexBuffer?.usedMemory??0+(this._buffers.size+(this._indexBuffer?1:0))*s)}dispose(){this._context?(this._buffers.forEach(e=>e.dispose()),this._buffers.clear(),this._indexBuffer=r(this._indexBuffer),this.disposeVAOOnly()):(this._glName||this._buffers.size>0)&&f().warn("Leaked WebGL VAO")}disposeVAOOnly(){this._context.getBoundVAO()===this&&this._context.bindVAO(null),this._glName&&(this._context.gl.deleteVertexArray(this._glName),this._glName=null,this._context.instanceCounter.decrement(i.VertexArrayObject,this)),this._context=null}bind(e=this.locations){const t=this._context.gl;this._glName?t.bindVertexArray(this._glName):(this._context.instanceCounter.increment(i.VertexArrayObject,this),this._glName=t.createVertexArray(),t.bindVertexArray(this._glName),this._bindLayout(e))}_bindLayout(e){const{_buffers:t,_indexBuffer:r}=this;if(t||f().error("Vertex buffer dictionary is empty!"),t.forEach(t=>n(this._context,e,t)),null!=r){const e=this._context.gl;this._context.gl.bindBuffer(e.ELEMENT_ARRAY_BUFFER,r.glName)}}unbind(){this._context.gl.bindVertexArray(null)}};export{u as VertexArrayObject};
5
+ import{toConst as e}from"../../core/compilerUtils.js";import t from"../../core/Logger.js";import{disposeMaybe as r}from"../../core/maybe.js";import{baseTypedArrayMemory as s}from"../../core/memoryEstimations.js";import{ResourceType as i}from"./enums.js";import{bindVertexBufferLayout as n}from"./Util.js";import{fromBuffers as o}from"./VertexAttributeLocations.js";const f=()=>t.getLogger("esri.views.webgl.VertexArrayObject");let h=class t{constructor(t,r,s,i){this._context=t,this._indexBuffer=s,this._buffers=r instanceof Map?r:new Map([["geometry",r]]),this._baseInstances=null==i?new Map:"number"==typeof i?new Map([["geometry",i]]):i,this.locations=e(o(this._buffers))}get glName(){return this._glName}get context(){return this._context}get buffers(){return e(this._buffers)}buffer(e="geometry"){return this.buffers.get(e)}get indexBuffer(){return this._indexBuffer}getByteLength(e){return this.buffer(e)?.sizeBytes??0}vertexCount(e){const t=this.buffer(e);return t?t.sizeBytes/t.layout[0].stride:0}get usedMemory(){return Array.from(this._buffers.values()).reduce((e,t)=>e+t.usedMemory,this._indexBuffer?.usedMemory??0+(this._buffers.size+(this._indexBuffer?1:0))*s)}dispose(){this._context?(this._buffers.forEach(e=>e.dispose()),this._buffers.clear(),this._indexBuffer=r(this._indexBuffer),this.disposeVAOOnly()):(this._glName||this._buffers.size>0)&&f().warn("Leaked WebGL VAO")}disposeVAOOnly(){this._context?(this._context.getBoundVAO()===this&&this._context.bindVAO(null),this._glName&&(this._context.gl.deleteVertexArray(this._glName),this._glName=null,this._context.instanceCounter.decrement(i.VertexArrayObject,this)),this._context=null):this._glName&&f().warn("Leaked WebGL VAO")}bind(e=this.locations){const t=this._context.gl;this._glName?t.bindVertexArray(this._glName):(this._context.instanceCounter.increment(i.VertexArrayObject,this),this._glName=t.createVertexArray(),t.bindVertexArray(this._glName),this._bindLayout(e))}_bindLayout(e){const{_buffers:t,_indexBuffer:r}=this;if(t||f().error("Vertex buffer dictionary is empty!"),t.forEach((t,r)=>n(this._context,e,t,this._baseInstances.get(r)??0)),null!=r){const e=this._context.gl;this._context.gl.bindBuffer(e.ELEMENT_ARRAY_BUFFER,r.glName)}}unbind(){this._context.gl.bindVertexArray(null)}shallowCloneWithBaseInstances(e){return new t(this._context,this._buffers,this._indexBuffer,e)}};export{h as VertexArrayObject};
package/webscene/Slide.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../Basemap.js";import i from"../Viewpoint.js";import{result as n}from"../core/asyncUtils.js";import{ClonableMixin as r}from"../core/Clonable.js";import o from"../core/Collection.js";import{referenceSetter as s}from"../core/collectionUtils.js";import{JSONSupport as a}from"../core/JSONSupport.js";import l from"../core/Logger.js";import{moduloPositive as p}from"../core/mathUtils.js";import{destroyMaybe as m,removeMaybe as c}from"../core/maybe.js";import{onAbortOrThrow as h,createAbortError as d,isAbortError as u}from"../core/promiseUtils.js";import{whenOnce as y,when as g}from"../core/reactiveUtils.js";import{Milliseconds as b,Seconds as v}from"../core/time.js";import{property as w}from"../core/accessorSupport/decorators/property.js";import{cast as f}from"../core/accessorSupport/decorators/cast.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as T}from"../core/accessorSupport/decorators/subclass.js";import{ensureType as j}from"../core/accessorSupport/ensureType.js";import{s as L}from"../chunks/vec32.js";import{create as C}from"../core/libs/gl-matrix-2/factories/vec3f64.js";import _ from"../layers/Layer.js";import{basemapEnsureType as E,clonePreservingTiledLayers as S}from"../support/basemapEnsureType.js";import{TaskPriority as k}from"../views/support/Scheduler.js";import{SlideThumbnail as A}from"../webdoc/support/SlideThumbnail.js";import{timeExtent as V}from"../webdoc/support/timeProperties.js";import U from"./SunLighting.js";import x from"./VirtualLighting.js";import F from"./support/Description.js";import I from"./support/SlideElements.js";import{SlideEnvironment as D}from"./support/SlideEnvironment.js";import R from"./support/SlideGround.js";import{SlideVisibleLayer as O}from"./support/SlideVisibleLayer.js";import P from"./support/Title.js";let q=0;const B=o.ofType(O),M=["caption","cover","none"];let G=class extends(r(a)){constructor(e){super(e),this.id=Date.now().toString(16)+"-slide-"+q++,this.title=new P,this.description=new F,this.hidden=!1,this.thumbnail=new A,this.viewpoint=null,this.basemap=null,this.ground=null,this.layout="caption",this.enabledFocusAreas=null,this.environment=new D,this.timeExtent=null,this.elements=new I,this.visibleLayers=new B}destroy(){this.visibleLayers.removeAll(),this.enabledFocusAreas=null,this.basemap=null,this.thumbnail=m(this.thumbnail),this.description=null,this.title=null,this.thumbnail=null,this.elements=null}castTitle(e){return"string"==typeof e?new P({text:e}):j(P,e)}castDescription(e){return"string"==typeof e?new F({text:e}):j(F,e)}castThumbnail(e){return"string"==typeof e?new A({url:e}):j(A,e)}castBasemap(e){return E(e)}set visibleLayers(e){this._set("visibleLayers",s(e,this._get("visibleLayers"),B))}castVisibleLayers(e){return e&&"function"==typeof e.map?e.map(e=>{if("string"==typeof e)return{id:e};if(e instanceof _){const t=H(e);return{id:e.id,sublayerIds:t}}return e.id?{id:e.id,sublayerIds:"sublayerIds"in e?e.sublayerIds:void 0}:(l.getLogger(this).warn('Invalid visible layer, expected { id }, Layer or "id"'),e)}):null}async _updateVisibleLayers(e){const t=[];await Promise.allSettled(this._getLayers(e.map).map(i=>e.whenLayerView(i).then(e=>{if(e.visible){const n=H(i);t.push(new O({id:e.layer.id,sublayerIds:n}))}})).toArray()),this.visibleLayers.removeAll(),this.visibleLayers.addMany(t)}async updateFrom(e,t){const i={format:"png",quality:80,width:120,height:75,disableDecorations:!0,...t?.screenshot};await e.when(),this.viewpoint=e.viewpoint.clone(),this.environment.lighting="virtual"===e.environment.lighting.type?x.prototype.clone.apply(e.environment.lighting):U.prototype.clone.apply(e.environment.lighting),this.environment.weather=e.environment.weather.clone(),this.enabledFocusAreas=new o(e.focusAreasView?.enabledAreas.map(({id:e})=>e)??[]),this.basemap=e.map.basemap?.clone()||null,this.ground=e.map.ground?R.fromGround(e.map.ground):null,this.timeExtent=e.timeExtent?.clone()??null,this.elements.analyses.updateFrom(e),await this._updateVisibleLayers(e);const n=await e.takeScreenshot(i);return this.thumbnail=new A({url:n.dataUrl}),this}async applyTo(e,t){null!=this._applyToController&&this._applyToController.abort();let i=new AbortController;this._applyToController=i;const r=h(t,()=>i?.abort()),o=()=>{this._applyToController===i&&(this._applyToController=null),i=null,r?.remove()};try{await y(()=>e.ready,i.signal)}catch(c){throw o(),c}if(i.signal.aborted)throw o(),d();const s=e.resourceController.scheduler.registerTask(k.SLIDE);let a=!1;const l={animate:!0,...t,signal:this._applyToController.signal},p=async()=>{await Promise.all([s.schedule(async()=>a=await this._setViewpointOfInterest(e,l)),s.schedule(()=>this._applyBasemap(e,l),l.signal),s.schedule(()=>this._loadLayersWithSublayerVisibility(e))]),await Promise.all([s.schedule(()=>this._applyLayerVisibility(e),l.signal),s.schedule(()=>this._applyFocusAreaEnabled(e.map?.focusAreas.areas)),s.schedule(()=>this._applyGround(e),l.signal),s.schedule(()=>this.elements.analyses.applyTo(e),l.signal),s.schedule(()=>this._applyViewpoint(e,l),l.signal),s.schedule(()=>e.timeExtent=this.timeExtent?.clone()??null,l.signal),s.schedule(()=>e.environment.weather=this.environment.weather.clone())])},m=await n(e.addUpdatingPromise(p()));if(a&&(e.contentCamera=null),s.remove(),o(),!1===m.ok)throw m.error;return this}async _applyBasemap(e,t){if(this.basemap){try{await this.basemap.load(t)}catch(i){if(u(i))throw i}e.map.basemap=S(this.basemap,e.map.basemap)}}_applyGround(e){this.ground&&(e.map.ground=this.ground.cloneAndApplyTo(e.map.ground))}_applyFocusAreaEnabled(e){if(e&&this.enabledFocusAreas)for(const t of e)t.enabled=this.enabledFocusAreas.includes(t.id)}_getLayers(e){const t=new o;return this._collectLayers(e,t),this._collectLayers(e.ground,t),t}_collectLayers(e,t){e.layers.forEach(e=>{e.persistenceEnabled&&(t.add(e),"layers"in e&&this._collectLayers(e,t))})}async _loadLayersWithSublayerVisibility(e){this.visibleLayers&&await Promise.allSettled(this._getLayers(e.map).items.map(e=>{const t=this.visibleLayers.find(t=>t.id===e.id)?.sublayerIds;return t?e.load():null}))}_applyLayerVisibility(e){if(!this.visibleLayers)return;this._getLayers(e.map).forEach(e=>{const t=this.visibleLayers.find(t=>t.id===e.id);e.visible=null!=t;const i=t?.sublayerIds,n=W(e);i&&n&&n.forEach(e=>e.visible=i.includes(e.id))})}async _setViewpointOfInterest(e,t){if(e.state.fixedContentCamera||!this.viewpoint||t?.ignoreViewpoint||!t?.useDestinationCamera)return!1;const{toCameraAsync:i}=await import("../views/3d/support/viewpointUtils.js"),n=await i(e,this.viewpoint);return e.contentCamera=n,null!=n}async _applyViewpoint(e,t){if(this._applyCachedCameraTrackingEnabled(e),this.viewpoint&&!t.ignoreViewpoint){const i=this.environment.lighting;if(t.animate&&"sun"===i.type&&i.date)return this._animateToLighting(e,t);t.animate&&(e.environment.applyLighting(i.clone()),await e.goTo(this.viewpoint,t)),e.viewpoint=this.viewpoint}e.environment.applyLighting(this.environment.lighting.clone())}async _animateToLighting(e,t){let i=null;"virtual"!==e.environment.lighting.type&&"virtual"!==this.environment.lighting.type&&("global"===e.viewingMode&&(i=this._animateLightingWithCamera(e,e.environment.lighting,this.environment.lighting)),e.environment.cachedCameraTrackingEnabled=e.environment.lighting.cameraTrackingEnabled,e.environment.lighting.cameraTrackingEnabled=!1),e.environment.lighting.directShadowsEnabled=this.environment.lighting.directShadowsEnabled,"virtual"===this.environment.lighting.type||"virtual"===e.environment.lighting.type?(e.environment.applyLighting(this.environment.lighting.clone()),"virtual"!==e.environment.lighting.type&&(e.environment.cachedCameraTrackingEnabled=e.environment.lighting.cameraTrackingEnabled,e.environment.lighting.cameraTrackingEnabled=!1)):null!=this.environment.lighting.displayUTCOffset&&(e.environment.lighting.displayUTCOffset=this.environment.lighting.displayUTCOffset);return e.goTo(this.viewpoint,t).then(()=>{this._applyCachedCameraTrackingEnabled(e),e.environment.applyLighting(this.environment.lighting.clone())}).catch(t=>{throw null==e.animation&&this._applyCachedCameraTrackingEnabled(e),t}).finally(()=>{c(i)})}_applyCachedCameraTrackingEnabled(e){null!=e.environment.cachedCameraTrackingEnabled&&(e.environment.lighting.cameraTrackingEnabled=e.environment.cachedCameraTrackingEnabled,e.environment.cachedCameraTrackingEnabled=null)}_getTime(e){return[b(e.getTime()),v(3600*e.getUTCHours()+60*e.getUTCMinutes()+e.getUTCSeconds())]}_setTime(e,t,i){return e.setTime(t),e.setUTCHours(i/3600),e.setUTCMinutes(i%3600/60),e.setUTCSeconds(i%3600%60),e}_animateLightingWithCamera(e,t,i){const n=new Date(t.date.toString()),[r,o]=this._getTime(n),[s,a]=this._getTime(i.date),l=K(o,a),p=e.renderCoordsHelper,m=C();p.toRenderCoords(e.camera.position,m);const c=C(),h=C();null!=this.viewpoint.camera&&p.toRenderCoords(this.viewpoint.camera.position,c);const d=new Date;return g(()=>e.camera,e=>{p.toRenderCoords(e.position,h);const i=L(m,h),n=L(c,h);let a=0;i+n!==0&&(a=i/(i+n));const u=r+(s-r)*a,y=Q(o,v(l*a));t.date=this._setTime(d,u,y)})}write(e,t){const i=super.write(e,t);return i?.elements&&0===Object.keys(i.elements).length&&delete i.elements,i}static createFrom(e,t){return(new this).updateFrom(e,t)}};e([w({type:String,json:{write:{isRequired:!0}}})],G.prototype,"id",void 0),e([w({type:P,json:{default:()=>new P({text:""}),write:{isRequired:!0}}})],G.prototype,"title",void 0),e([f("title")],G.prototype,"castTitle",null),e([w({type:F,json:{write:{overridePolicy:e=>({enabled:!(!e||!e.text)})}}})],G.prototype,"description",void 0),e([f("description")],G.prototype,"castDescription",null),e([w({type:Boolean,nonNullable:!0,json:{write:!0,default:!1}})],G.prototype,"hidden",void 0),e([w({type:A,json:{default:()=>new A({url:""}),write:{isRequired:!0}}})],G.prototype,"thumbnail",void 0),e([f("thumbnail")],G.prototype,"castThumbnail",null),e([w({type:i,nonNullable:!0,json:{write:{isRequired:!0}}})],G.prototype,"viewpoint",void 0),e([w({type:t,json:{read:{source:"baseMap"},write:{target:"baseMap"}}})],G.prototype,"basemap",void 0),e([f("basemap")],G.prototype,"castBasemap",null),e([w({type:R,json:{write:!0}})],G.prototype,"ground",void 0),e([w({type:M,json:{write:!0,default:"caption"},nonNullable:!0})],G.prototype,"layout",void 0),e([w({type:B,json:{write:{isRequired:!0}}})],G.prototype,"visibleLayers",null),e([f("visibleLayers")],G.prototype,"castVisibleLayers",null),e([w({type:o.ofType(String),json:{write:!0},clonable:e=>e?new o(e.items):null})],G.prototype,"enabledFocusAreas",void 0),e([w({type:D,json:{write:!0}})],G.prototype,"environment",void 0),e([w(V)],G.prototype,"timeExtent",void 0),e([w({type:I,nonNullable:!0,json:{write:!0}})],G.prototype,"elements",void 0),G=e([T("esri.webscene.Slide")],G);const N=G;function W(e){if("building-scene"===e.type||"map-image"===e.type)return e.allSublayers.toArray()}function H(e){const t=W(e);if(t)return t.filter(e=>e.visible).map(e=>e.id)}const J=v(86400),z=v(43200);function K(e,t){let i=t-e;return i>z&&(i-=J),i<-z&&(i+=J),v(i)}function Q(e,t){return v(p(e+t,J))}export{N as default};
5
+ import{__decorate as e}from"tslib";import t from"../Basemap.js";import i from"../Viewpoint.js";import{result as n}from"../core/asyncUtils.js";import{ClonableMixin as r}from"../core/Clonable.js";import o from"../core/Collection.js";import{referenceSetter as s}from"../core/collectionUtils.js";import{JSONSupport as a}from"../core/JSONSupport.js";import l from"../core/Logger.js";import{moduloPositive as p}from"../core/mathUtils.js";import{destroyMaybe as m,removeMaybe as c}from"../core/maybe.js";import{onAbortOrThrow as h,createAbortError as d,isAbortError as u}from"../core/promiseUtils.js";import{whenOnce as y,when as g}from"../core/reactiveUtils.js";import{Milliseconds as b,Seconds as v}from"../core/time.js";import{property as w}from"../core/accessorSupport/decorators/property.js";import{cast as f}from"../core/accessorSupport/decorators/cast.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as T}from"../core/accessorSupport/decorators/subclass.js";import{ensureType as j}from"../core/accessorSupport/ensureType.js";import{s as L}from"../chunks/vec32.js";import{create as C}from"../core/libs/gl-matrix-2/factories/vec3f64.js";import _ from"../layers/Layer.js";import{basemapEnsureType as E,clonePreservingTiledLayers as S}from"../support/basemapEnsureType.js";import{TaskPriority as k}from"../views/support/Scheduler.js";import{SlideThumbnail as A}from"../webdoc/support/SlideThumbnail.js";import{timeExtent as V}from"../webdoc/support/timeProperties.js";import U from"./SunLighting.js";import x from"./VirtualLighting.js";import F from"./support/Description.js";import I from"./support/SlideElements.js";import{SlideEnvironment as D}from"./support/SlideEnvironment.js";import R from"./support/SlideGround.js";import{SlideVisibleLayer as O}from"./support/SlideVisibleLayer.js";import P from"./support/Title.js";let q=0;const B=o.ofType(O),M=["caption","cover","none"];let G=class extends(r(a)){constructor(e){super(e),this.id=Date.now().toString(16)+"-slide-"+q++,this.title=new P,this.description=new F,this.hidden=!1,this.thumbnail=new A,this.viewpoint=null,this.basemap=null,this.ground=null,this.layout="caption",this.enabledFocusAreas=null,this.environment=new D,this.timeExtent=null,this.elements=new I,this.visibleLayers=new B}destroy(){this.visibleLayers.removeAll(),this.enabledFocusAreas=null,this.basemap=null,this.thumbnail=m(this.thumbnail),this.description=null,this.title=null,this.thumbnail=null,this.elements.destroy()}castTitle(e){return"string"==typeof e?new P({text:e}):j(P,e)}castDescription(e){return"string"==typeof e?new F({text:e}):j(F,e)}castThumbnail(e){return"string"==typeof e?new A({url:e}):j(A,e)}castBasemap(e){return E(e)}set visibleLayers(e){this._set("visibleLayers",s(e,this._get("visibleLayers"),B))}castVisibleLayers(e){return e&&"function"==typeof e.map?e.map(e=>{if("string"==typeof e)return{id:e};if(e instanceof _){const t=H(e);return{id:e.id,sublayerIds:t}}return e.id?{id:e.id,sublayerIds:"sublayerIds"in e?e.sublayerIds:void 0}:(l.getLogger(this).warn('Invalid visible layer, expected { id }, Layer or "id"'),e)}):null}async _updateVisibleLayers(e){const t=[];await Promise.allSettled(this._getLayers(e.map).map(i=>e.whenLayerView(i).then(e=>{if(e.visible){const n=H(i);t.push(new O({id:e.layer.id,sublayerIds:n}))}})).toArray()),this.visibleLayers.removeAll(),this.visibleLayers.addMany(t)}async updateFrom(e,t){const i={format:"png",quality:80,width:120,height:75,disableDecorations:!0,...t?.screenshot};await e.when(),this.viewpoint=e.viewpoint.clone(),this.environment.lighting="virtual"===e.environment.lighting.type?x.prototype.clone.apply(e.environment.lighting):U.prototype.clone.apply(e.environment.lighting),this.environment.weather=e.environment.weather.clone(),this.enabledFocusAreas=new o(e.focusAreasView?.enabledAreas.map(({id:e})=>e)??[]),this.basemap=e.map.basemap?.clone()||null,this.ground=e.map.ground?R.fromGround(e.map.ground):null,this.timeExtent=e.timeExtent?.clone()??null,this.elements.analyses.updateFrom(e),await this._updateVisibleLayers(e);const n=await e.takeScreenshot(i);return this.thumbnail=new A({url:n.dataUrl}),this}async applyTo(e,t){null!=this._applyToController&&this._applyToController.abort();let i=new AbortController;this._applyToController=i;const r=h(t,()=>i?.abort()),o=()=>{this._applyToController===i&&(this._applyToController=null),i=null,r?.remove()};try{await y(()=>e.ready,i.signal)}catch(c){throw o(),c}if(i.signal.aborted)throw o(),d();const s=e.resourceController.scheduler.registerTask(k.SLIDE);let a=!1;const l={animate:!0,...t,signal:this._applyToController.signal},p=async()=>{await Promise.all([s.schedule(async()=>a=await this._setViewpointOfInterest(e,l)),s.schedule(()=>this._applyBasemap(e,l),l.signal),s.schedule(()=>this._loadLayersWithSublayerVisibility(e))]),await Promise.all([s.schedule(()=>this._applyLayerVisibility(e),l.signal),s.schedule(()=>this._applyFocusAreaEnabled(e.map?.focusAreas.areas)),s.schedule(()=>this._applyGround(e),l.signal),s.schedule(()=>this.elements.analyses.applyTo(e),l.signal),s.schedule(()=>this._applyViewpoint(e,l),l.signal),s.schedule(()=>e.timeExtent=this.timeExtent?.clone()??null,l.signal),s.schedule(()=>e.environment.weather=this.environment.weather.clone())])},m=await n(e.addUpdatingPromise(p()));if(a&&(e.contentCamera=null),s.remove(),o(),!1===m.ok)throw m.error;return this}async _applyBasemap(e,t){if(this.basemap){try{await this.basemap.load(t)}catch(i){if(u(i))throw i}e.map.basemap=S(this.basemap,e.map.basemap)}}_applyGround(e){this.ground&&(e.map.ground=this.ground.cloneAndApplyTo(e.map.ground))}_applyFocusAreaEnabled(e){if(e&&this.enabledFocusAreas)for(const t of e)t.enabled=this.enabledFocusAreas.includes(t.id)}_getLayers(e){const t=new o;return this._collectLayers(e,t),this._collectLayers(e.ground,t),t}_collectLayers(e,t){e.layers.forEach(e=>{e.persistenceEnabled&&(t.add(e),"layers"in e&&this._collectLayers(e,t))})}async _loadLayersWithSublayerVisibility(e){this.visibleLayers&&await Promise.allSettled(this._getLayers(e.map).items.map(e=>{const t=this.visibleLayers.find(t=>t.id===e.id)?.sublayerIds;return t?e.load():null}))}_applyLayerVisibility(e){if(!this.visibleLayers)return;this._getLayers(e.map).forEach(e=>{const t=this.visibleLayers.find(t=>t.id===e.id);e.visible=null!=t;const i=t?.sublayerIds,n=W(e);i&&n&&n.forEach(e=>e.visible=i.includes(e.id))})}async _setViewpointOfInterest(e,t){if(e.state.fixedContentCamera||!this.viewpoint||t?.ignoreViewpoint||!t?.useDestinationCamera)return!1;const{toCameraAsync:i}=await import("../views/3d/support/viewpointUtils.js"),n=await i(e,this.viewpoint);return e.contentCamera=n,null!=n}async _applyViewpoint(e,t){if(this._applyCachedCameraTrackingEnabled(e),this.viewpoint&&!t.ignoreViewpoint){const i=this.environment.lighting;if(t.animate&&"sun"===i.type&&i.date)return this._animateToLighting(e,t);t.animate&&(e.environment.applyLighting(i.clone()),await e.goTo(this.viewpoint,t)),e.viewpoint=this.viewpoint}e.environment.applyLighting(this.environment.lighting.clone())}async _animateToLighting(e,t){let i=null;"virtual"!==e.environment.lighting.type&&"virtual"!==this.environment.lighting.type&&("global"===e.viewingMode&&(i=this._animateLightingWithCamera(e,e.environment.lighting,this.environment.lighting)),e.environment.cachedCameraTrackingEnabled=e.environment.lighting.cameraTrackingEnabled,e.environment.lighting.cameraTrackingEnabled=!1),e.environment.lighting.directShadowsEnabled=this.environment.lighting.directShadowsEnabled,"virtual"===this.environment.lighting.type||"virtual"===e.environment.lighting.type?(e.environment.applyLighting(this.environment.lighting.clone()),"virtual"!==e.environment.lighting.type&&(e.environment.cachedCameraTrackingEnabled=e.environment.lighting.cameraTrackingEnabled,e.environment.lighting.cameraTrackingEnabled=!1)):null!=this.environment.lighting.displayUTCOffset&&(e.environment.lighting.displayUTCOffset=this.environment.lighting.displayUTCOffset);return e.goTo(this.viewpoint,t).then(()=>{this._applyCachedCameraTrackingEnabled(e),e.environment.applyLighting(this.environment.lighting.clone())}).catch(t=>{throw null==e.animation&&this._applyCachedCameraTrackingEnabled(e),t}).finally(()=>{c(i)})}_applyCachedCameraTrackingEnabled(e){null!=e.environment.cachedCameraTrackingEnabled&&(e.environment.lighting.cameraTrackingEnabled=e.environment.cachedCameraTrackingEnabled,e.environment.cachedCameraTrackingEnabled=null)}_getTime(e){return[b(e.getTime()),v(3600*e.getUTCHours()+60*e.getUTCMinutes()+e.getUTCSeconds())]}_setTime(e,t,i){return e.setTime(t),e.setUTCHours(i/3600),e.setUTCMinutes(i%3600/60),e.setUTCSeconds(i%3600%60),e}_animateLightingWithCamera(e,t,i){const n=new Date(t.date.toString()),[r,o]=this._getTime(n),[s,a]=this._getTime(i.date),l=K(o,a),p=e.renderCoordsHelper,m=C();p.toRenderCoords(e.camera.position,m);const c=C(),h=C();null!=this.viewpoint.camera&&p.toRenderCoords(this.viewpoint.camera.position,c);const d=new Date;return g(()=>e.camera,e=>{p.toRenderCoords(e.position,h);const i=L(m,h),n=L(c,h);let a=0;i+n!==0&&(a=i/(i+n));const u=r+(s-r)*a,y=Q(o,v(l*a));t.date=this._setTime(d,u,y)})}write(e,t){const i=super.write(e,t);return i?.elements&&0===Object.keys(i.elements).length&&delete i.elements,i}static createFrom(e,t){return(new this).updateFrom(e,t)}};e([w({type:String,json:{write:{isRequired:!0}}})],G.prototype,"id",void 0),e([w({type:P,json:{default:()=>new P({text:""}),write:{isRequired:!0}}})],G.prototype,"title",void 0),e([f("title")],G.prototype,"castTitle",null),e([w({type:F,json:{write:{overridePolicy:e=>({enabled:!(!e||!e.text)})}}})],G.prototype,"description",void 0),e([f("description")],G.prototype,"castDescription",null),e([w({type:Boolean,nonNullable:!0,json:{write:!0,default:!1}})],G.prototype,"hidden",void 0),e([w({type:A,json:{default:()=>new A({url:""}),write:{isRequired:!0}}})],G.prototype,"thumbnail",void 0),e([f("thumbnail")],G.prototype,"castThumbnail",null),e([w({type:i,nonNullable:!0,json:{write:{isRequired:!0}}})],G.prototype,"viewpoint",void 0),e([w({type:t,json:{read:{source:"baseMap"},write:{target:"baseMap"}}})],G.prototype,"basemap",void 0),e([f("basemap")],G.prototype,"castBasemap",null),e([w({type:R,json:{write:!0}})],G.prototype,"ground",void 0),e([w({type:M,json:{write:!0,default:"caption"},nonNullable:!0})],G.prototype,"layout",void 0),e([w({type:B,json:{write:{isRequired:!0}}})],G.prototype,"visibleLayers",null),e([f("visibleLayers")],G.prototype,"castVisibleLayers",null),e([w({type:o.ofType(String),json:{write:!0},clonable:e=>e?new o(e.items):null})],G.prototype,"enabledFocusAreas",void 0),e([w({type:D,json:{write:!0}})],G.prototype,"environment",void 0),e([w(V)],G.prototype,"timeExtent",void 0),e([w({type:I,nonNullable:!0,json:{write:!0}})],G.prototype,"elements",void 0),G=e([T("esri.webscene.Slide")],G);const N=G;function W(e){if("building-scene"===e.type||"map-image"===e.type)return e.allSublayers.toArray()}function H(e){const t=W(e);if(t)return t.filter(e=>e.visible).map(e=>e.id)}const J=v(86400),z=v(43200);function K(e,t){let i=t-e;return i>z&&(i-=J),i<-z&&(i+=J),v(i)}function Q(e,t){return v(p(e+t,J))}export{N 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.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../Graphic.js";import a from"../../core/Error.js";import{makeHandle as i,handlesGroup as r,abortHandle as s}from"../../core/handleUtils.js";import"../../core/has.js";import o from"../../core/Logger.js";import{removeMaybe as n,destroyMaybe as l}from"../../core/maybe.js";import{debounce as d,isPromiseLike as c}from"../../core/promiseUtils.js";import{watch as u,when as h,initial as p,whenOnce as m,syncAndInitial as f}from"../../core/reactiveUtils.js";import{generateBracedUUID as w}from"../../core/uuid.js";import{property as g}from"../../core/accessorSupport/decorators/property.js";import"../../core/RandomLCG.js";import{subclass as y}from"../../core/accessorSupport/decorators/subclass.js";import{isSharedTemplateOrMetadata as v,isSharedTemplate as F,isStandardFeatureTemplate as _}from"../../editing/templateUtils.js";import b from"../../layers/GraphicsLayer.js";import{isTable as M}from"../../layers/support/layerUtils.js";import{isNumber as I}from"../../support/guards.js";import{getDisplayedSymbol as V}from"../../symbols/support/symbolUtils.js";import{getDrawHelpMessage as S}from"../../views/draw/support/helpMessageUtils.js";import k from"../../views/draw/support/HighlightHelper.js";import A from"../../views/interactive/sketch/SketchOptions.js";import C from"../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{temporaryHighlightName as P}from"../../views/support/HighlightDefaults.js";import E from"./CreateFeaturesWorkflowData.js";import{isModelUpload as T,handleModelUpload as H}from"./modelUploadUtils.js";import U from"./Workflow.js";import{createToolFromGeometryType as j,getServiceEditsFromWorkflowData as L,getServiceInfoForLayer as x,orderEditsByRelationshipDependencies as O,getFullTemplateForCreationInfo as z,getServiceLayersById as W,startCreatingNewFeature as D,findLayerInfo as R,updateGraphicSymbolWhenRequired as N,isTerminalUpdateEventType as G,getVisualVariableAttributes as K,startUpdatingFeatureGeometry as Z,createWorkflowSteps as q,avoidFeatureTemplateSelectionWithOnlyOneItem as B,getCreationAttributes as J,setUpSketchCreateWatchers as Q,setRelationshipFields as X,prepareAttachmentsForCreateFeaturesWorkflow as Y,showProgressCursor as $,setVisualVariablesAndElevationInfoForUpdate as ee,visualVariableInteractiveUpdate as te}from"./workflowUtils.js";import ae from"../FeatureForm/FeatureFormViewModel.js";import ie from"../Sketch/SketchViewModel.js";var re;const se=Symbol(),oe=Symbol(),ne=Symbol(),le=Symbol(),de={point:["point"],multipoint:["multipoint"],polygon:["polygon","freehandPolygon","rectangle","circle"],polyline:["polyline","freehandPolyline"],mesh:[],multipatch:[]};let ce=re=class extends U{constructor(e){super(e),this.type="create-features",this.createFeatureState="create-new",this.data=void 0,this.isNested=!1,this._getDrawMeshHelpMessage=void 0,this._webStyleCache=new Map,this._featureFormHandle=null,this._visualVariableAttributes={rotation:null,size:null},this._featureFormViewModel=new ae,this._sketchViewModel=null,this._attachmentFileInfos=new Map,this._isActive=!0}initialize(){this.isNested&&(this._isActive=!1),this._initializeSketchViewModel()}destroy(){this._sketchViewModel.destroy()}get featureFormViewModel(){return this._featureFormViewModel}get hasPendingEdits(){if(this.pendingFeatures.some(e=>!!this.data.getEditsForPendingFeature(e)?.modified))return!0;const{creationInfo:e,upload:t}=this.data,a=this._sketchViewModel,{activeComponent:i}=a,r=a.createGraphic?.geometry?.type;return!("polyline"!==r&&"polygon"!==r&&"multipoint"!==r||"draw-2d"!==i?.type&&"draw-3d"!==i?.type)&&i.drawOperation.committedVertices.length>0||(!(!t||"pending"!==t.state&&"success"!==t.state)||!!e?.geometryToPlace)}get hasPreviousStep(){return this._stepIndex>0||"update-pending"===this.createFeatureState&&!!this.data.selectedPendingFeature&&!this.parent&&!T(this.data.creationInfo)}get helpMessage(){const{creationInfo:e,viewModel:t}=this.data;if("creating-features"!==this.stepId||!e)return;const a=e.layer.geometryType,i=this._sketchViewModel.createGraphic;if("mesh"===a){this._getDrawMeshHelpMessage||import("../../views/draw/support/helpMessageUtils3d.js").then(e=>{this._getDrawMeshHelpMessage=e.getDrawMeshHelpMessage});const{view:e}=t;return"3d"===e?.type?this._getDrawMeshHelpMessage?.(i,e):void 0}const r=this._sketchViewModel.activeCreateToolDrawMode,s=this._sketchViewModel.activeTool;return S("rectangle"===s?"rectangle":"circle"===s?"circle":a,i?.geometry,r)}get layer(){return this.data.creationInfo?.layer}get numPendingFeatures(){return this.pendingFeatures.length}get numPendingFeaturesExcludingHidden(){return this.pendingFeatures.filter(e=>this.data.isDisplayable(e)).length}get parent(){return this.data.parent}get parentLayer(){return this.parent?.data.editorItem.layer}get pendingFeatures(){return this.data.pendingFeatures}get keyboardCancellationEnabled(){return 0===this.numPendingFeatures}get reliesOnOwnerAdminPrivileges(){return this.data.editorItem?.capabilities.create.reliesOnOwnerAdminPrivileges??!1}get shouldShowAttachments(){return(this.data.selectedPendingFeature&&this.data.editorItem?.capabilities.create.attachments.enabled)??!1}get shouldAllowAttachmentEditing(){return this.shouldShowAttachments}get sketchViewModel(){return this._sketchViewModel}get test(){}get availableCreateTools(){const e=this.data.creationInfo?.layer.geometryType,t=this.data.viewModel.view;if(!e)return[];if(this.data.creationInfo?.maxFeatures&&this.data.creationInfo.maxFeatures<=this.numPendingFeatures)return[];if(v(this.data.fullTemplate)){const{tool:t}=j(e,this.data.fullTemplate);return[t]}return"2d"!==t?.type&&"multipoint"===e?[]:[...de[e]]}get _attachmentsActive(){const e=this.data.viewModel.attachmentsViewModel.mode,t=this.stepId;return this.shouldShowAttachments&&("add"===e||"edit"===e||"adding-attachment"===t||"editing-attachment"===t)}async enter(){this._isActive=!0,"awaiting-feature-creation-info"!==this.stepId&&await this._updatingHandles.addPromise(this._setUpCreatingFeaturesStep())}exit(){this._isActive=!1,this.removeHandles([ne])}async updatePendingFeature(e){if(e!==this.data.selectedPendingFeature)return this._sketchViewModel.cancel(),this._startUpdating({feature:e})}async start(){return await super.start(),M(this.data.creationInfo?.layer)?null:{enter:async()=>{},exit:async()=>{},viewModel:this._sketchViewModel}}async save(){const{featureFormViewModel:e}=this;if(e.pendingSubtypeChoice)return;e.submit(),this._stashValidationState();const t=this.data.selectedPendingFeature,a=this._hasValidationErrors(t)?t:this.data.pendingFeatures.find(e=>this._hasValidationErrors(e));return a?(await this._startUpdating({feature:a}),void e?.submit()):super.save()}back(e){return"update-pending"!==this.createFeatureState||!this.data.selectedPendingFeature||T(this.data.creationInfo)||this._attachmentsActive||this.parent?super.back(e):this._clearSelectedFeature()}previous(e){return"update-pending"!==this.createFeatureState||!this.data.selectedPendingFeature||T(this.data.creationInfo)||this._attachmentsActive?super.previous(e):this._clearSelectedFeature()}cancelFeature(e){this.data.isSharedTemplateWorkflow?o.getLogger(this).warn("Cannot cancel individual features created by shared templates."):(this.data.removePendingFeature(e),this.sketchViewModel.layer.graphics.remove(e))}static create(e){const{addAttachmentsCallback:t,applyEdits:a,applyEditsFeatureService:i,isNested:r,creationInfo:s,parent:o,snappingManager:n,startAt:l,viewModel:d}=e,c=e.sketchOptions??new A,u=s?.layer,h=u?d.findEditorItemForLayer(u):void 0,p=new re({data:new E({creationInfo:s,editorItem:h,parent:o,sketchOptions:c,snappingManager:n,viewModel:d}),isNested:r,onCommit:async e=>{const{creationInfo:r}=e;if(!r)return;p._sketchViewModel.cancel();const s=e.pendingFeatures.toArray(),{layer:o}=r,n=o.capabilities?.editing.supportsGlobalId&&"globalIdField"in o,l=p._attachmentFileInfos,{fullTemplate:c}=e,u=L(p.data),h=F(c)&&u;if(n){if(me(s),h){let t=we(u,l);const a=await x(o,d.view);a&&(t=O({edits:t,serviceInfo:a,view:d.view,findOriginalFeature:t=>e.getEditsForPendingFeature(t)?.initialFeature??t})),await i(c.featureService,t,{globalIdUsed:!0,gdbVersion:c.layer.gdbVersion??void 0})}else{const e=fe(s,l);await a(o,e,{globalIdUsed:!0})}return}const m=h?await i(c.featureService,u,{gdbVersion:c.layer.gdbVersion??void 0}):[await a(o,{addFeatures:s})];m&&l.size>0&&await Promise.all(m.map(e=>{if(e?.addFeatureResults)return t(o,pe(s,e.addFeatureResults,o,l))}))}});return p._set("steps",this._createWorkflowSteps(p,l)),p}_fadeExistingFeatures(e){if("effect"in e){const t=e.effect;return e.effect="saturate(0.6) opacity(0.8)",i(()=>e.effect=t)}const t=e.opacity;return e.opacity=.7,i(()=>e.opacity=t)}async _initializeFullTemplateAndExecutorInfo(e){const{creationInfo:t}=e,{view:a}=e.viewModel;if(!t||!a)return null;const i=await z(t,a);if(e.fullTemplate=i,i&&F(i)){const{createTemplateExecutor:r}=await import("../../editing/sharedTemplates/executor/createTemplateExecutor.js"),s={completionResults:[],executor:await r(i),serviceLayersById:await W(t.layer,a)};e.templateExecutorInfo=s}return i}async _startCreating(){this.removeHandles(oe);const{data:e}=this;if(!e.creationInfo)return;const t=this.data.creationInfo?.maxFeatures;if(t&&this.numPendingFeatures>=t)return this.sketchViewModel.cancel(),void(this.numPendingFeatures&&await this._startUpdating({feature:this.pendingFeatures.at(-1)}));this.createFeatureState="create-new",await D(this._sketchViewModel,e,this._webStyleCache)}async _clearSelectedFeature(){const e=this._featureFormViewModel.pendingSubtypeChoice;e&&(e.resolve("undo"),await e.promise),this._stashValidationState(),this.sketchViewModel.cancel(),this.data.selectedPendingFeature=null,this._featureFormHandle=n(this._featureFormHandle),this._featureFormViewModel.feature=null;const t=this.data.viewModel.attachmentsViewModel;"add"!==t.mode&&"edit"!==t.mode||await(this.data.viewModel.activeWorkflow?.previous())}_stashValidationState(){const e=this._featureFormViewModel.feature,t=e&&this.data.getEditsForPendingFeature(e);t&&(t.submittable=this._featureFormViewModel.submittable)}async _selectFeatureForUpdate({feature:e,initialFeature:t=e}){this._stashValidationState();const{data:a,pendingFeatures:i,_webStyleCache:s}=this;i.includes(e)||a.addPendingFeature(e,t),a.selectedPendingFeature=e;const{_featureFormViewModel:o,_sketchViewModel:l}=this,{creationInfo:d,viewModel:c}=a,{attachmentsViewModel:h,layerInfos:p,view:m}=c;if(!m||!d)return;n(this._featureFormHandle);const f=e.sourceLayer,w=R(p,f),g=w?.formTemplate,y=m.spatialReference;o.set({editType:"INSERT",feature:e,formTemplate:g,spatialReference:y,map:m.map}),"add"!==h.mode&&"edit"!==h.mode||await(c.activeWorkflow?.previous()),h.graphic=e,h.fileInfos.removeAll(),h.mode="view";(this._attachmentFileInfos.get(e)||[]).forEach(({file:e,form:t})=>h.addFile(e,t)),await N(e,s,"2d"===m.type?m.scale:null);const v=a.getEditsForPendingFeature(e);this._featureFormHandle=r([o.on("value-change",async({fieldName:t,value:a})=>{if(v?.updateAttributes(o.getValues()),I(a)){const e=this._visualVariableAttributes;e.size&&!e.size.isUpdatingInteractively&&t===e.size.field&&e.size.setInitialValue(a),e.rotation&&!e.rotation.isUpdatingInteractively&&t===e.rotation.field&&e.rotation.setInitialValue(a)}await N(e,s,"2d"===m.type?m.scale:null)}),l.on(["update","undo","redo"],e=>{("undo"===e.type||"redo"===e.type||"update"===e.type&&null!=e.toolEventInfo&&G(e.toolEventInfo.type))&&o.notifyFeatureGeometryChanged()}),u(()=>o.feature?.sourceLayer,t=>e.sourceLayer=t),u(()=>[o.feature,o.submittable],()=>this._stashValidationState())]),this.createFeatureState="update-pending"}async _startUpdating({feature:e,initialFeature:t=e}){await this._selectFeatureForUpdate({feature:e,initialFeature:t});const{_sketchViewModel:a,data:i}=this,{creationInfo:r,viewModel:s}=i,{view:o}=s;if(!o||!r)return;const n=e.sourceLayer??r.layer;return M(n)?void 0:(this._visualVariableAttributes=K(e),Z({graphic:e,sketchViewModel:a,sourceLayer:n,visualVariables:this._visualVariableAttributes,webStyleCache:this._webStyleCache}))}static _createWorkflowSteps(e,t="awaiting-feature-creation-info"){const{data:a}=e,i=q(["awaiting-feature-creation-info","creating-features","adding-attachment","editing-attachment"],t,{"awaiting-feature-creation-info":()=>({id:"awaiting-feature-creation-info",async setUp(){const{creationInfo:t,viewModel:i}=a,{view:r}=i;r&&(T(t)?e.addHandles(await H({view:r,data:a,next:()=>e.next(),cancel:()=>i.cancelWorkflow({warnIfNoWorkflow:!1})}),this.id):(a.parent&&t&&e.addHandles(i.restrictFeatureTemplatesViewModelToLayer(t.layer),this.id),e.addHandles(i.featureTemplatesViewModel.on("select",({item:t})=>{t&&(a.creationInfo={...a.creationInfo,layer:t.layer,template:t.template},e.next())}),this.id)))},async tearDown(){e.removeHandles(this.id)}}),"creating-features":()=>({id:"creating-features",async setUp(){e._isActive&&await e._setUpCreatingFeaturesStep()},async tearDown(t){const{viewModel:i}=a;t.canceled&&(e.removeHandles([ne,se,oe,le]),i.attachmentsViewModel.fileInfos.removeAll(),e._attachmentFileInfos.clear())}}),"adding-attachment":()=>({id:"adding-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=a.viewModel,{graphic:i,fileInfos:r}=t;e._attachmentFileInfos.set(i,r.toArray()),t.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=a.viewModel,{graphic:i,fileInfos:r}=t;e._attachmentFileInfos.set(i,r.toArray()),t.mode="view"}})});return B(a,i)}static _configureSketchViewModel(e){const{data:t}=e,a=e._webStyleCache,{creationInfo:s,viewModel:o}=t,{view:n}=o,l=e._sketchViewModel,c=[];if(!n)return i();if("2d"===n.type){s&&c.push(e._fadeExistingFeatures(s.layer));const t=d((e,t)=>Promise.all(e.map(e=>N(e,a,t))));c.push(u(()=>n.scale,e=>t(l.layer.graphics,e)))}const p=J(t.fullTemplate,s?.attributeOverrides),m=u(()=>l.createGraphic,i=>{i&&!e.hasHandles(oe)&&e._updatingHandles.addPromise(Q({creationAttributes:p,data:t,sketchViewModel:l,view:n,webStyleCache:a}).then(t=>e.addHandles(t,oe)))}),f=async t=>{if("cancel"!==t.state&&"complete"!==t.state||e.removeHandles(oe),"cancel"===t.state&&null!==n.activeTool&&n.activeTool!==e.sketchViewModel.activeComponent&&(await e._waitForActiveToolCleared(),await e._startCreating()),"complete"===t.state&&t.graphic){const a=await e._processEdits(t.graphic,{scale:"2d"===n.type?n.scale:null,useSourceLayer:!0,webStyleCache:e._webStyleCache});a&&(await e._waitForActiveToolCleared(),await e._startUpdating({feature:a}))}},w=async a=>{const{attachmentsViewModel:i}=o,{_featureFormViewModel:r}=e;if(a.graphics.length>1)return void await e._clearSelectedFeature();const d=a.graphics[0];if("complete"===a.state){const{submittable:t}=r;if(e.numPendingFeatures!==s?.maxFeatures&&t||r.submit(),await e._clearSelectedFeature(),"add"!==i.mode&&"edit"!==i.mode||await(o.activeWorkflow?.previous()),!a.aborted&&n.activeTool===e.sketchViewModel.activeComponent&&(await e.sketchViewModel.wait(),"ready"===e.sketchViewModel.state&&"mesh"!==e.data.creationInfo?.layer.geometryType))return e._startCreating()}else{if("start"===a.state)return d.sourceLayer??=t.creationInfo?.layer,await ee({sketchViewModel:l,graphic:d,visualVariables:e._visualVariableAttributes,webStyleCache:e._webStyleCache,sourceLayer:d.sourceLayer}),e._selectFeatureForUpdate({feature:d});if("active"===a.state){await e.updatePendingFeature(d);const t=e._visualVariableAttributes;te(n,d,a,t)&&await N(d,e._webStyleCache,"2d"===n.type?n.scale:null);const i=d.attributes,{rotation:s,size:o}=t;if(null!=s){const{field:e}=s;r.setValue(e,i[e])}if(null!=o){const{field:e}=o;r.setValue(e,i[e])}}}},g=async a=>{if(a.graphics.forEach(e=>{t.removePendingFeature(e)}),!T(t.creationInfo))return e._startCreating()},y=async()=>{if(T(t.creationInfo))try{await e.data.viewModel.back()}catch{}return e._startCreating()};c.push(m,l.on("create",t=>e._updatingHandles.addPromise(f(t))),l.on("update",t=>e._updatingHandles.addPromise(w(t))),l.on("delete",t=>e._updatingHandles.addPromise(g(t))),h(()=>!e.numPendingFeatures,()=>e._updatingHandles.addPromise(y())),i(()=>{l.cancel()}),ue(l,t),...he(t));const v=r(c);return l.addHandles(v),v}_initializeSketchViewModel(){const{data:e}=this,{view:t}=e.viewModel,a=new b({elevationInfo:e.creationInfo?.layer.elevationInfo,internal:!0,listMode:"hide",title:"createFeaturesWorkflow-internal"}),r=new ie({layer:a,creationMode:"single",sketchOptions:e.sketchOptions,snappingManager:e.snappingManager,updateOnGraphicClick:!1,defaultUpdateOptions:{multipleSelectionEnabled:!1},view:t});this._sketchViewModel=r,t?.map.add(a),this.addHandles([i(()=>{t?.destroyed||t?.map.remove(a),a.destroy()}),u(()=>this.numPendingFeatures>0,e=>this._sketchViewModel.updateOnGraphicClick=e,p)])}_hasValidationErrors(e){return!!e&&(!this.data.isSubmittable(e)||!!this._featureFormViewModel.validateContingencyConstraints(e.attributes,{includeIncompleteViolations:!0})?.length)}async _processEdits(e,t){const{data:a,_featureFormViewModel:i}=this,{layerInfos:r,view:s}=a.viewModel;i.editType="INSERT",i.map=s?.map,i.spatialReference=s?.spatialReference;const{templateExecutorInfo:o}=a;if(!o){const t=e.clone();return t.geometry=null,await this._addAndInitializeEdits(e,t),e}const n=this.sketchViewModel.layer;n.remove(e);const{executor:l}=o,d=l(e.geometry,"completion"),u=c(d)?await d:d;o.completionResults.push(u),X(u.relationships),i.editType="INSERT",i.map=s?.map,i.spatialReference=s?.spatialReference,u.primary&&a.creationInfo?.attributeOverrides&&(u.primary.graphic.attributes={...u.primary.graphic.attributes,...a.creationInfo.attributeOverrides});for(const c of u.edits){let e=null;if(c.addFeatures)for(const a of c.addFeatures){const i=a.clone();i.geometry=null,null!=a.geometry&&(a.symbol=await V(a,t),n.add(a)),a.sourceLayer!==e?.layer&&(e=R(r,a.sourceLayer));const s=!!u.associationGraphics?.has(a);await this._addAndInitializeEdits(a,i,e,s)}}i.feature=null,await m(()=>!i.updating);return u.edits.reduce((e,t)=>e+(t.addFeatures?.length??0),0)>1?null:u.primary?.graphic}async _addAndInitializeEdits(e,t,a,i=!1){const{data:r,_featureFormViewModel:s}=this,{layerInfos:o}=r.viewModel,n=r.addPendingFeature(e,t,{isAssociation:i});a??=R(o,e.sourceLayer),s.feature=e,s.formTemplate=a?.formTemplate,await m(()=>!s.updating),n.submittable=s.submittable}async _setUpCreatingFeaturesStep(){if(this.hasHandles(ne))return;const{data:e,sketchViewModel:s}=this,{creationInfo:o,viewModel:l}=e,{attachmentsViewModel:d,view:c}=l;if(!c||!o?.layer)throw new a("missing-parameters","CreateFeaturesWorkflow requires a view and creationInfo.");const{initialFeature:h,layer:m}=o,f=[],w=[];this._featureFormHandle=n(this._featureFormHandle),this._visualVariableAttributes={rotation:null,size:null},e.editorItem=l.findEditorItemForLayer(o.layer),o.template&&(null==e.fullTemplate&&await this._initializeFullTemplateAndExecutorInfo(e),w.push(i(()=>{e.templateExecutorInfo&&(e.templateExecutorInfo.completionResults=[])}))),s.allowDeleteKey=!e.isSharedTemplateWorkflow,Y(d),f.push(u(()=>d.mode,e=>{switch(e){case"add":this.go("adding-attachment");break;case"edit":this.go("editing-attachment")}}));const g=$(c);f.push(g);const y=M(o.layer),{template:F}=o,b=!F||_(F)||v(F)&&"feature"===F.type,I=y&&b;try{if(I){const a=h??new t({attributes:J(e.fullTemplate,o.attributeOverrides),sourceLayer:m}),i=await this._processEdits(a);i&&await this._startUpdating({feature:i})}else f.push(re._configureSketchViewModel(this)),h?(T(o)&&o.geometryToPlace&&(h.attributes=J(e.fullTemplate,o.attributeOverrides)),s.layer.add(h),await this._startUpdating({feature:h})):await this._startCreating()}finally{g.remove()}const V=i(()=>{for(const t of e.pendingFeatures)s.layer.remove(t),e.removePendingFeature(t)}),S=u(()=>c?.timeZone,e=>{this._featureFormViewModel.timeZone=e,this.data.timeZone=e},p),k=i(()=>{T(o)&&l.cancelWorkflow({warnIfNoWorkflow:!1})});this._featureFormHandle&&f.push(this._featureFormHandle),this.addHandles(f,this._handleKeys.beforeCommit),this.addHandles(w,this._handleKeys.afterCommit),this.addHandles([i(()=>d.fileInfos.removeAll()),r(f),r(w),k,V,S],ne)}async _waitForActiveToolCleared(){const e=this.data.viewModel.view;if(null==e?.activeTool)return;const t=new AbortController;this.addHandles(s(t),le),await m(()=>null==e?.activeTool,t.signal),t.abort()}};function ue(e,t){let a=null;const s=()=>e.snappingOptions.featureSources,o=()=>(a=new C({layer:e.layer}),s().add(a),a),n=()=>{null!=a&&(s().remove(a),a=l(a))};return r([u(()=>{const e=t.creationInfo?.layer,a=s().find(t=>t.layer===e);return{hasFeatureLayerSource:!!a,enabled:a?.enabled??!1}},({hasFeatureLayerSource:e,enabled:t})=>{if(!e)return n();a??=o(),a.enabled=t},f),i(n)])}function he(e){const t=e.viewModel.view;if(!t)return[];const a=[];if("3d"===t.type){const r=new k({view:t});a.push(u(()=>e.selectedPendingFeature,(e,t)=>{r.remove(e),r.add(t)}),i(()=>r.destroy()))}const r=new k({view:t,highlightName:P});return a.push(u(()=>e.temporaryHighlightFeature,e=>{r.removeAll(),r.add(e)}),i(()=>r.destroy())),a}function pe(e,t,a,i){const r=[];return t.forEach((t,s)=>{if(!t.error){const o=e[s],n=i.get(o)||[];o.attributes[a.objectIdField]=t.objectId,n.forEach(({form:e})=>r.push({feature:o,attachment:e}))}}),r}function me(e){for(const t of e){const{sourceLayer:e}=t;e&&"globalIdField"in e&&null!=e.globalIdField&&(t.attributes[e.globalIdField]??=w())}}function fe(e,t){const a=[];if(!t||0===t.size)return{addFeatures:e};for(const[i,r]of t)for(const{file:e}of r)a.push({feature:i,attachment:{globalId:w(),data:e}});return a.length?{addFeatures:e,addAttachments:a}:{addFeatures:e}}function we(e,t){return e.map(e=>{const{addFeatures:a}=e;if(!a||0===a.length)return e;const i=[];for(const r of a){const e=t.get(r);if(e)for(const{file:t}of e)i.push({feature:r,attachment:{globalId:w(),data:t}})}return i.length?{...e,addAttachments:i}:e})}e([g()],ce.prototype,"createFeatureState",void 0),e([g()],ce.prototype,"data",void 0),e([g({constructOnly:!0})],ce.prototype,"isNested",void 0),e([g()],ce.prototype,"featureFormViewModel",null),e([g()],ce.prototype,"hasPendingEdits",null),e([g()],ce.prototype,"hasPreviousStep",null),e([g()],ce.prototype,"_getDrawMeshHelpMessage",void 0),e([g()],ce.prototype,"helpMessage",null),e([g()],ce.prototype,"layer",null),e([g()],ce.prototype,"parent",null),e([g()],ce.prototype,"parentLayer",null),e([g()],ce.prototype,"keyboardCancellationEnabled",null),e([g()],ce.prototype,"reliesOnOwnerAdminPrivileges",null),e([g()],ce.prototype,"shouldShowAttachments",null),e([g()],ce.prototype,"shouldAllowAttachmentEditing",null),e([g()],ce.prototype,"sketchViewModel",null),e([g()],ce.prototype,"availableCreateTools",null),e([g()],ce.prototype,"_attachmentsActive",null),ce=re=e([y("esri.widgets.Editor.CreateFeaturesWorkflow")],ce);const ge=ce;export{ge as default};
5
+ import{__decorate as e}from"tslib";import t from"../../Graphic.js";import a from"../../core/Error.js";import{makeHandle as i,handlesGroup as r,abortHandle as s}from"../../core/handleUtils.js";import"../../core/has.js";import o from"../../core/Logger.js";import{removeMaybe as n,destroyMaybe as l}from"../../core/maybe.js";import{debounce as d,isPromiseLike as c}from"../../core/promiseUtils.js";import{watch as u,when as h,initial as p,whenOnce as m,syncAndInitial as f}from"../../core/reactiveUtils.js";import{generateBracedUUID as w}from"../../core/uuid.js";import{property as g}from"../../core/accessorSupport/decorators/property.js";import"../../core/RandomLCG.js";import{subclass as y}from"../../core/accessorSupport/decorators/subclass.js";import{isSharedTemplateOrMetadata as v,isSharedTemplate as F,isStandardFeatureTemplate as _}from"../../editing/templateUtils.js";import b from"../../layers/GraphicsLayer.js";import{isTable as M}from"../../layers/support/layerUtils.js";import{isNumber as I}from"../../support/guards.js";import{getDisplayedSymbol as V}from"../../symbols/support/symbolUtils.js";import{getDrawHelpMessage as k}from"../../views/draw/support/helpMessageUtils.js";import S from"../../views/draw/support/HighlightHelper.js";import A from"../../views/interactive/sketch/SketchOptions.js";import C from"../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{temporaryHighlightName as P}from"../../views/support/HighlightDefaults.js";import E from"./CreateFeaturesWorkflowData.js";import{isModelUpload as T,handleModelUpload as H}from"./modelUploadUtils.js";import L from"./Workflow.js";import{createToolFromGeometryType as U,getServiceEditsFromWorkflowData as j,getServiceInfoForLayer as x,orderEditsByRelationshipDependencies as O,getFullTemplateForCreationInfo as z,getServiceLayersById as W,startCreatingNewFeature as D,findLayerInfo as R,updateGraphicSymbolWhenRequired as G,isTerminalUpdateEventType as N,getVisualVariableAttributes as K,startUpdatingFeatureGeometry as Z,createWorkflowSteps as q,avoidFeatureTemplateSelectionWithOnlyOneItem as B,getCreationAttributes as J,setUpSketchCreateWatchers as Q,setRelationshipFields as X,prepareAttachmentsForCreateFeaturesWorkflow as Y,showProgressCursor as $,setVisualVariablesAndElevationInfoForUpdate as ee,visualVariableInteractiveUpdate as te}from"./workflowUtils.js";import ae from"../FeatureForm/FeatureFormViewModel.js";import ie from"../Sketch/SketchViewModel.js";var re;const se=Symbol(),oe=Symbol(),ne=Symbol(),le=Symbol(),de={point:["point"],multipoint:["multipoint"],polygon:["polygon","freehandPolygon","rectangle","circle"],polyline:["polyline","freehandPolyline"],mesh:[],multipatch:[]};let ce=re=class extends L{constructor(e){super(e),this.type="create-features",this.createFeatureState="create-new",this.data=void 0,this.isNested=!1,this._getDrawMeshHelpMessage=void 0,this._webStyleCache=new Map,this._featureFormHandle=null,this._visualVariableAttributes={rotation:null,size:null},this._featureFormViewModel=new ae,this._sketchLayer=null,this._sketchViewModel=null,this._attachmentFileInfos=new Map,this._isActive=!0}initialize(){this.isNested&&(this._isActive=!1),this._initializeSketchViewModel()}destroy(){this._sketchViewModel.destroy()}get featureFormViewModel(){return this._featureFormViewModel}get hasPendingEdits(){if(this.pendingFeatures.some(e=>!!this.data.getEditsForPendingFeature(e)?.modified))return!0;const{creationInfo:e,upload:t}=this.data,{activeComponent:a,createGraphic:i}=this._sketchViewModel,r=i?.geometry?.type;return!("polyline"!==r&&"polygon"!==r&&"multipoint"!==r||"draw-2d"!==a?.type&&"draw-3d"!==a?.type)&&a.drawOperation.committedVertices.length>0||(!(!t||"pending"!==t.state&&"success"!==t.state)||!!e?.geometryToPlace)}get hasPreviousStep(){return this._stepIndex>0||"update-pending"===this.createFeatureState&&!!this.data.selectedPendingFeature&&!this.parent&&!T(this.data.creationInfo)}get helpMessage(){const{creationInfo:e,viewModel:t}=this.data;if("creating-features"!==this.stepId||!e)return;const{_sketchViewModel:a}=this,i=e.layer.geometryType,r=a.createGraphic;if("mesh"===i){this._getDrawMeshHelpMessage||import("../../views/draw/support/helpMessageUtils3d.js").then(e=>{this._getDrawMeshHelpMessage=e.getDrawMeshHelpMessage});const{view:e}=t;return"3d"===e?.type?this._getDrawMeshHelpMessage?.(r,e):void 0}const{activeCreateToolDrawMode:s,activeTool:o}=a;return k("rectangle"===o?"rectangle":"circle"===o?"circle":i,r?.geometry,s)}get layer(){return this.data.creationInfo?.layer}get numPendingFeatures(){return this.pendingFeatures.length}get numPendingFeaturesExcludingHidden(){return this.pendingFeatures.filter(e=>this.data.isDisplayable(e)).length}get parent(){return this.data.parent}get parentLayer(){return this.parent?.data.editorItem.layer}get pendingFeatures(){return this.data.pendingFeatures}get keyboardCancellationEnabled(){return 0===this.numPendingFeatures}get reliesOnOwnerAdminPrivileges(){return this.data.editorItem?.capabilities.create.reliesOnOwnerAdminPrivileges??!1}get shouldShowAttachments(){return(this.data.selectedPendingFeature&&this.data.editorItem?.capabilities.create.attachments.enabled)??!1}get shouldAllowAttachmentEditing(){return this.shouldShowAttachments}get sketchViewModel(){return this._sketchViewModel}get test(){}get availableCreateTools(){const e=this.data.creationInfo?.layer.geometryType,t=this.data.viewModel.view;if(!e)return[];if(this.data.creationInfo?.maxFeatures&&this.data.creationInfo.maxFeatures<=this.numPendingFeatures)return[];if(v(this.data.fullTemplate)){const{tool:t}=U(e,this.data.fullTemplate);return[t]}return"2d"!==t?.type&&"multipoint"===e?[]:[...de[e]]}get _attachmentsActive(){const e=this.data.viewModel.attachmentsViewModel.mode,t=this.stepId;return this.shouldShowAttachments&&("add"===e||"edit"===e||"adding-attachment"===t||"editing-attachment"===t)}async enter(){this._isActive=!0,"awaiting-feature-creation-info"!==this.stepId&&await this._updatingHandles.addPromise(this._setUpCreatingFeaturesStep())}exit(){this._isActive=!1,this.removeHandles([ne])}async updatePendingFeature(e){if(e!==this.data.selectedPendingFeature)return this._sketchViewModel.cancel(),this._startUpdating({feature:e})}async start(){return await super.start(),M(this.data.creationInfo?.layer)?null:{enter:async()=>{},exit:async()=>{},viewModel:this._sketchViewModel}}async save(){const{featureFormViewModel:e}=this;if(e.pendingSubtypeChoice)return;e.submit(),this._stashValidationState();const t=this.data.selectedPendingFeature,a=this._hasValidationErrors(t)?t:this.data.pendingFeatures.find(e=>this._hasValidationErrors(e));return a?(await this._startUpdating({feature:a}),void e?.submit()):super.save()}back(e){return"update-pending"!==this.createFeatureState||!this.data.selectedPendingFeature||T(this.data.creationInfo)||this._attachmentsActive||this.parent?super.back(e):this._clearSelectedFeature()}previous(e){return"update-pending"!==this.createFeatureState||!this.data.selectedPendingFeature||T(this.data.creationInfo)||this._attachmentsActive?super.previous(e):this._clearSelectedFeature()}cancelFeature(e){this.data.isSharedTemplateWorkflow?o.getLogger(this).warn("Cannot cancel individual features created by shared templates."):(this.data.removePendingFeature(e),this.sketchViewModel.removeGraphic(e))}static create(e){const{addAttachmentsCallback:t,applyEdits:a,applyEditsFeatureService:i,isNested:r,creationInfo:s,parent:o,snappingManager:n,startAt:l,viewModel:d}=e,c=e.sketchOptions??new A,u=s?.layer,h=u?d.findEditorItemForLayer(u):void 0,p=new re({data:new E({creationInfo:s,editorItem:h,parent:o,sketchOptions:c,snappingManager:n,viewModel:d}),isNested:r,onCommit:async e=>{const{creationInfo:r}=e;if(!r)return;p._sketchViewModel.cancel();const s=e.pendingFeatures.toArray(),{layer:o}=r,n=o.capabilities?.editing.supportsGlobalId&&"globalIdField"in o,l=p._attachmentFileInfos,{fullTemplate:c}=e,u=j(p.data),h=F(c)&&u;if(n){if(me(s),h){let t=we(u,l);const a=await x(o,d.view);a&&(t=O({edits:t,serviceInfo:a,view:d.view,findOriginalFeature:t=>e.getEditsForPendingFeature(t)?.initialFeature??t})),await i(c.featureService,t,{globalIdUsed:!0,gdbVersion:c.layer.gdbVersion??void 0})}else{const e=fe(s,l);await a(o,e,{globalIdUsed:!0})}return}const m=h?await i(c.featureService,u,{gdbVersion:c.layer.gdbVersion??void 0}):[await a(o,{addFeatures:s})];m&&l.size>0&&await Promise.all(m.map(e=>{if(e?.addFeatureResults)return t(o,pe(s,e.addFeatureResults,o,l))}))}});return p._set("steps",this._createWorkflowSteps(p,l)),p}_fadeExistingFeatures(e){if("effect"in e){const t=e.effect;return e.effect="saturate(0.6) opacity(0.8)",i(()=>e.effect=t)}const t=e.opacity;return e.opacity=.7,i(()=>e.opacity=t)}async _initializeFullTemplateAndExecutorInfo(e){const{creationInfo:t}=e,{view:a}=e.viewModel;if(!t||!a)return null;const i=await z(t,a);if(e.fullTemplate=i,i&&F(i)){const{createTemplateExecutor:r}=await import("../../editing/sharedTemplates/executor/createTemplateExecutor.js"),s={completionResults:[],executor:await r(i),serviceLayersById:await W(t.layer,a)};e.templateExecutorInfo=s}return i}async _startCreating(){this.removeHandles(oe);const{data:e}=this;if(!e.creationInfo)return;const t=this.data.creationInfo?.maxFeatures;if(t&&this.numPendingFeatures>=t)return this.sketchViewModel.cancel(),void(this.numPendingFeatures&&await this._startUpdating({feature:this.pendingFeatures.at(-1)}));this.createFeatureState="create-new",await D(this._sketchViewModel,this._sketchLayer,e,this._webStyleCache)}async _clearSelectedFeature(){const e=this._featureFormViewModel.pendingSubtypeChoice;e&&(e.resolve("undo"),await e.promise),this._stashValidationState(),this.sketchViewModel.cancel(),this.data.selectedPendingFeature=null,this._featureFormHandle=n(this._featureFormHandle),this._featureFormViewModel.feature=null;const t=this.data.viewModel.attachmentsViewModel;"add"!==t.mode&&"edit"!==t.mode||await(this.data.viewModel.activeWorkflow?.previous())}_stashValidationState(){const e=this._featureFormViewModel.feature,t=e&&this.data.getEditsForPendingFeature(e);t&&(t.submittable=this._featureFormViewModel.submittable)}async _selectFeatureForUpdate({feature:e,initialFeature:t=e}){this._stashValidationState();const{data:a,pendingFeatures:i,_webStyleCache:s}=this;i.includes(e)||a.addPendingFeature(e,t),a.selectedPendingFeature=e;const{_featureFormViewModel:o,_sketchViewModel:l}=this,{creationInfo:d,viewModel:c}=a,{attachmentsViewModel:h,layerInfos:p,view:m}=c;if(!m||!d)return;n(this._featureFormHandle);const f=e.sourceLayer,w=R(p,f),g=w?.formTemplate,y=m.spatialReference;o.set({editType:"INSERT",feature:e,formTemplate:g,spatialReference:y,map:m.map}),"add"!==h.mode&&"edit"!==h.mode||await(c.activeWorkflow?.previous()),h.graphic=e,h.fileInfos.removeAll(),h.mode="view";(this._attachmentFileInfos.get(e)||[]).forEach(({file:e,form:t})=>h.addFile(e,t)),await G(e,s,"2d"===m.type?m.scale:null);const v=a.getEditsForPendingFeature(e);this._featureFormHandle=r([o.on("value-change",async({fieldName:t,value:a})=>{if(v?.updateAttributes(o.getValues()),I(a)){const e=this._visualVariableAttributes;e.size&&!e.size.isUpdatingInteractively&&t===e.size.field&&e.size.setInitialValue(a),e.rotation&&!e.rotation.isUpdatingInteractively&&t===e.rotation.field&&e.rotation.setInitialValue(a)}await G(e,s,"2d"===m.type?m.scale:null)}),l.on(["update","undo","redo"],e=>{("undo"===e.type||"redo"===e.type||"update"===e.type&&null!=e.toolEventInfo&&N(e.toolEventInfo.type))&&o.notifyFeatureGeometryChanged()}),u(()=>o.feature?.sourceLayer,t=>e.sourceLayer=t),u(()=>[o.feature,o.submittable],()=>this._stashValidationState())]),this.createFeatureState="update-pending"}async _startUpdating({feature:e,initialFeature:t=e}){await this._selectFeatureForUpdate({feature:e,initialFeature:t});const{_sketchLayer:a,_sketchViewModel:i,data:r}=this,{creationInfo:s,viewModel:o}=r,{view:n}=o;if(!n||!s)return;const l=e.sourceLayer??s.layer;return M(l)?void 0:(this._visualVariableAttributes=K(e),Z({graphic:e,sketchLayer:a,sketchViewModel:i,sourceLayer:l,visualVariables:this._visualVariableAttributes,webStyleCache:this._webStyleCache}))}static _createWorkflowSteps(e,t="awaiting-feature-creation-info"){const{data:a}=e,i=q(["awaiting-feature-creation-info","creating-features","adding-attachment","editing-attachment"],t,{"awaiting-feature-creation-info":()=>({id:"awaiting-feature-creation-info",async setUp(){const{creationInfo:t,viewModel:i}=a,{view:r}=i;r&&(T(t)?e.addHandles(await H({view:r,data:a,next:()=>e.next(),cancel:()=>i.cancelWorkflow({warnIfNoWorkflow:!1})}),this.id):(a.parent&&t&&e.addHandles(i.restrictFeatureTemplatesViewModelToLayer(t.layer),this.id),e.addHandles(i.featureTemplatesViewModel.on("select",({item:t})=>{t&&(a.creationInfo={...a.creationInfo,layer:t.layer,template:t.template},e.next())}),this.id)))},async tearDown(){e.removeHandles(this.id)}}),"creating-features":()=>({id:"creating-features",async setUp(){e._isActive&&await e._setUpCreatingFeaturesStep()},async tearDown(t){const{viewModel:i}=a;t.canceled&&(e.removeHandles([ne,se,oe,le]),i.attachmentsViewModel.fileInfos.removeAll(),e._attachmentFileInfos.clear())}}),"adding-attachment":()=>({id:"adding-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=a.viewModel,{graphic:i,fileInfos:r}=t;e._attachmentFileInfos.set(i,r.toArray()),t.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=a.viewModel,{graphic:i,fileInfos:r}=t;e._attachmentFileInfos.set(i,r.toArray()),t.mode="view"}})});return B(a,i)}static _configureSketchViewModel(e){const{data:t,_sketchLayer:a,_sketchViewModel:s,_webStyleCache:o}=e,{creationInfo:n,viewModel:l}=t,{view:c}=l,p=[];if(!c)return i();if("2d"===c.type){n&&p.push(e._fadeExistingFeatures(n.layer));const t=d((e,t)=>Promise.all(e.map(e=>G(e,o,t))));p.push(u(()=>c.scale,e=>t(a.graphics,e)))}const m=J(t.fullTemplate,n?.attributeOverrides),f=u(()=>s.createGraphic,a=>{a&&!e.hasHandles(oe)&&e._updatingHandles.addPromise(Q({creationAttributes:m,data:t,sketchViewModel:s,view:c,webStyleCache:o}).then(t=>e.addHandles(t,oe)))}),w=async t=>{if("cancel"!==t.state&&"complete"!==t.state||e.removeHandles(oe),"cancel"===t.state&&null!==c.activeTool&&c.activeTool!==e.sketchViewModel.activeComponent&&(await e._waitForActiveToolCleared(),await e._startCreating()),"complete"===t.state&&t.graphic){const a=await e._processEdits(t.graphic,{scale:"2d"===c.type?c.scale:null,useSourceLayer:!0,webStyleCache:e._webStyleCache});a&&(await e._waitForActiveToolCleared(),await e._startUpdating({feature:a}))}},g=async i=>{const{attachmentsViewModel:r}=l,{_featureFormViewModel:o}=e;if(i.graphics.length>1)return void await e._clearSelectedFeature();const d=i.graphics[0];if("complete"===i.state){const{submittable:t}=o;if(e.numPendingFeatures!==n?.maxFeatures&&t||o.submit(),await e._clearSelectedFeature(),"add"!==r.mode&&"edit"!==r.mode||await(l.activeWorkflow?.previous()),!i.aborted&&c.activeTool===e.sketchViewModel.activeComponent&&(await e.sketchViewModel.wait(),"ready"===e.sketchViewModel.state&&"mesh"!==e.data.creationInfo?.layer.geometryType))return e._startCreating()}else{if("start"===i.state)return d.sourceLayer??=t.creationInfo?.layer,await ee({graphic:d,sketchLayer:a,sketchViewModel:s,visualVariables:e._visualVariableAttributes,webStyleCache:e._webStyleCache,sourceLayer:d.sourceLayer}),e._selectFeatureForUpdate({feature:d});if("active"===i.state){await e.updatePendingFeature(d);const t=e._visualVariableAttributes;te(c,d,i,t)&&await G(d,e._webStyleCache,"2d"===c.type?c.scale:null);const a=d.attributes,{rotation:r,size:s}=t;if(null!=r){const{field:e}=r;o.setValue(e,a[e])}if(null!=s){const{field:e}=s;o.setValue(e,a[e])}}}},y=async a=>{if(a.graphics.forEach(e=>{t.removePendingFeature(e)}),!T(t.creationInfo))return e._startCreating()},v=async()=>{if(T(t.creationInfo))try{await e.data.viewModel.back()}catch{}return e._startCreating()};p.push(f,s.on("create",t=>e._updatingHandles.addPromise(w(t))),s.on("update",t=>e._updatingHandles.addPromise(g(t))),s.on("delete",t=>e._updatingHandles.addPromise(y(t))),h(()=>!e.numPendingFeatures,()=>e._updatingHandles.addPromise(v())),i(()=>{s.cancel()}),ue(s,a,t),...he(t));const F=r(p);return s.addHandles(F),F}_initializeSketchViewModel(){const{data:e}=this,{view:t}=e.viewModel,a=new b({elevationInfo:e.creationInfo?.layer.elevationInfo,internal:!0,listMode:"hide",title:"createFeaturesWorkflow-internal"}),r=new ie({layer:a,creationMode:"single",sketchOptions:e.sketchOptions,snappingManager:e.snappingManager,updateOnGraphicClick:!1,defaultUpdateOptions:{multipleSelectionEnabled:!1},view:t});this._sketchLayer=a,this._sketchViewModel=r,t?.map.add(a),this.addHandles([i(()=>{t?.destroyed||t?.map.remove(a),a.destroy()}),u(()=>this.numPendingFeatures>0,e=>this._sketchViewModel.updateOnGraphicClick=e,p)])}_hasValidationErrors(e){return!!e&&(!this.data.isSubmittable(e)||!!this._featureFormViewModel.validateContingencyConstraints(e.attributes,{includeIncompleteViolations:!0})?.length)}async _processEdits(e,t){const{data:a,_featureFormViewModel:i,_sketchLayer:r}=this,{layerInfos:s,view:o}=a.viewModel;i.editType="INSERT",i.map=o?.map,i.spatialReference=o?.spatialReference;const{templateExecutorInfo:n}=a;if(!n){const t=e.clone();return t.geometry=null,await this._addAndInitializeEdits(e,t),e}r.remove(e);const{executor:l}=n,d=l(e.geometry,"completion"),u=c(d)?await d:d;n.completionResults.push(u),X(u.relationships),i.editType="INSERT",i.map=o?.map,i.spatialReference=o?.spatialReference,u.primary&&a.creationInfo?.attributeOverrides&&(u.primary.graphic.attributes={...u.primary.graphic.attributes,...a.creationInfo.attributeOverrides});for(const c of u.edits){let e=null;if(c.addFeatures)for(const a of c.addFeatures){const i=a.clone();i.geometry=null,null!=a.geometry&&(a.symbol=await V(a,t),r.add(a)),a.sourceLayer!==e?.layer&&(e=R(s,a.sourceLayer));const o=!!u.associationGraphics?.has(a);await this._addAndInitializeEdits(a,i,e,o)}}i.feature=null,await m(()=>!i.updating);return u.edits.reduce((e,t)=>e+(t.addFeatures?.length??0),0)>1?null:u.primary?.graphic}async _addAndInitializeEdits(e,t,a,i=!1){const{data:r,_featureFormViewModel:s}=this,{layerInfos:o}=r.viewModel,n=r.addPendingFeature(e,t,{isAssociation:i});a??=R(o,e.sourceLayer),s.feature=e,s.formTemplate=a?.formTemplate,await m(()=>!s.updating),n.submittable=s.submittable}async _setUpCreatingFeaturesStep(){if(this.hasHandles(ne))return;const{data:e,sketchViewModel:s}=this,{creationInfo:o,viewModel:l}=e,{attachmentsViewModel:d,view:c}=l;if(!c||!o?.layer)throw new a("missing-parameters","CreateFeaturesWorkflow requires a view and creationInfo.");const{initialFeature:h,layer:m}=o,f=[],w=[];this._featureFormHandle=n(this._featureFormHandle),this._visualVariableAttributes={rotation:null,size:null},e.editorItem=l.findEditorItemForLayer(o.layer),o.template&&(null==e.fullTemplate&&await this._initializeFullTemplateAndExecutorInfo(e),w.push(i(()=>{e.templateExecutorInfo&&(e.templateExecutorInfo.completionResults=[])}))),s.allowDeleteKey=!e.isSharedTemplateWorkflow,Y(d),f.push(u(()=>d.mode,e=>{switch(e){case"add":this.go("adding-attachment");break;case"edit":this.go("editing-attachment")}}));const g=$(c);f.push(g);const y=M(o.layer),{template:F}=o,b=!F||_(F)||v(F)&&"feature"===F.type,I=y&&b;try{if(I){const a=h??new t({attributes:J(e.fullTemplate,o.attributeOverrides),sourceLayer:m}),i=await this._processEdits(a);i&&await this._startUpdating({feature:i})}else f.push(re._configureSketchViewModel(this)),h?(T(o)&&o.geometryToPlace&&(h.attributes=J(e.fullTemplate,o.attributeOverrides)),s.addGraphic(h),await this._startUpdating({feature:h})):await this._startCreating()}finally{g.remove()}const V=i(()=>{for(const t of e.pendingFeatures)s.removeGraphic(t),e.removePendingFeature(t)}),k=u(()=>c?.timeZone,e=>{this._featureFormViewModel.timeZone=e,this.data.timeZone=e},p),S=i(()=>{T(o)&&l.cancelWorkflow({warnIfNoWorkflow:!1})});this._featureFormHandle&&f.push(this._featureFormHandle),this.addHandles(f,this._handleKeys.beforeCommit),this.addHandles(w,this._handleKeys.afterCommit),this.addHandles([i(()=>d.fileInfos.removeAll()),r(f),r(w),S,V,k],ne)}async _waitForActiveToolCleared(){const e=this.data.viewModel.view;if(null==e?.activeTool)return;const t=new AbortController;this.addHandles(s(t),le),await m(()=>null==e?.activeTool,t.signal),t.abort()}};function ue(e,t,a){let s=null;const o=()=>e.snappingOptions.featureSources,n=()=>(s=new C({layer:t}),o().add(s),s),d=()=>{null!=s&&(o().remove(s),s=l(s))};return r([u(()=>{const e=a.creationInfo?.layer,t=o().find(t=>t.layer===e);return{hasFeatureLayerSource:!!t,enabled:t?.enabled??!1}},({hasFeatureLayerSource:e,enabled:t})=>{if(!e)return d();s??=n(),s.enabled=t},f),i(d)])}function he(e){const t=e.viewModel.view;if(!t)return[];const a=[];if("3d"===t.type){const r=new S({view:t});a.push(u(()=>e.selectedPendingFeature,(e,t)=>{r.remove(e),r.add(t)}),i(()=>r.destroy()))}const r=new S({view:t,highlightName:P});return a.push(u(()=>e.temporaryHighlightFeature,e=>{r.removeAll(),r.add(e)}),i(()=>r.destroy())),a}function pe(e,t,a,i){const r=[];return t.forEach((t,s)=>{if(!t.error){const o=e[s],n=i.get(o)||[];o.attributes[a.objectIdField]=t.objectId,n.forEach(({form:e})=>r.push({feature:o,attachment:e}))}}),r}function me(e){for(const t of e){const{sourceLayer:e}=t;e&&"globalIdField"in e&&null!=e.globalIdField&&(t.attributes[e.globalIdField]??=w())}}function fe(e,t){const a=[];if(!t||0===t.size)return{addFeatures:e};for(const[i,r]of t)for(const{file:e}of r)a.push({feature:i,attachment:{globalId:w(),data:e}});return a.length?{addFeatures:e,addAttachments:a}:{addFeatures:e}}function we(e,t){return e.map(e=>{const{addFeatures:a}=e;if(!a||0===a.length)return e;const i=[];for(const r of a){const e=t.get(r);if(e)for(const{file:t}of e)i.push({feature:r,attachment:{globalId:w(),data:t}})}return i.length?{...e,addAttachments:i}:e})}e([g()],ce.prototype,"createFeatureState",void 0),e([g()],ce.prototype,"data",void 0),e([g({constructOnly:!0})],ce.prototype,"isNested",void 0),e([g()],ce.prototype,"featureFormViewModel",null),e([g()],ce.prototype,"hasPendingEdits",null),e([g()],ce.prototype,"hasPreviousStep",null),e([g()],ce.prototype,"_getDrawMeshHelpMessage",void 0),e([g()],ce.prototype,"helpMessage",null),e([g()],ce.prototype,"layer",null),e([g()],ce.prototype,"parent",null),e([g()],ce.prototype,"parentLayer",null),e([g()],ce.prototype,"keyboardCancellationEnabled",null),e([g()],ce.prototype,"reliesOnOwnerAdminPrivileges",null),e([g()],ce.prototype,"shouldShowAttachments",null),e([g()],ce.prototype,"shouldAllowAttachmentEditing",null),e([g()],ce.prototype,"sketchViewModel",null),e([g()],ce.prototype,"availableCreateTools",null),e([g()],ce.prototype,"_attachmentsActive",null),ce=re=e([y("esri.widgets.Editor.CreateFeaturesWorkflow")],ce);const ge=ce;export{ge 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.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../core/Error.js";import{makeHandle as i,handlesGroup as r}from"../../core/handleUtils.js";import"../../core/has.js";import o from"../../core/Logger.js";import{destroyMaybe as a}from"../../core/maybe.js";import{debounce as s}from"../../core/promiseUtils.js";import{watch as l,on as n,whenOnce as p}from"../../core/reactiveUtils.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import"../../core/RandomLCG.js";import{subclass as h}from"../../core/accessorSupport/decorators/subclass.js";import u from"../../layers/GraphicsLayer.js";import m from"../../views/draw/support/HighlightHelper.js";import{temporaryHighlightName as c}from"../../views/support/HighlightDefaults.js";import w from"./Edits.js";import g from"./SplitFeatureWorkflowData.js";import y from"./Workflow.js";import{createWorkflowSteps as f,swapForEditingSession as _,updateGraphicSymbolWhenRequired as v,makeMinimalAttributes as F}from"./workflowUtils.js";import{getCompatibleSpitterGeometryType as M,ensureSplittableGeometry as k,makeNewFeatureAttributes as S,splitGeometry as b,isSplitterGeometry as V}from"./support/splitFeatureUtils.js";import j from"../FeatureForm/FeatureFormViewModel.js";import G from"../Sketch/SketchViewModel.js";var T;const E=()=>o.getLogger("esri.widgets.Editor.SplitFeatureWorkflow");let H=T=class extends y{constructor(e){super(e),this.defaultSplitterGeometryType=null,this.type="split-feature",this._formViewModel=null,this._graphicsLayer=null,this._highlightHelper=null,this._sketchViewModel=null,this._webStyleCache=new Map}initialize(){const e=this.data.viewModel.view;this._highlightHelper=e?new m({view:e,highlightName:c}):null,this._initializeFeatureFormViewModel();const t=this._initializeGraphicsLayer();this._initializeSketchViewModel(t)}destroy(){const e=this._graphicsLayer,{view:t}=this.data.viewModel;t?.destroyed||t?.map.remove(e),this._graphicsLayer=a(this._graphicsLayer),this._formViewModel.destroy(),this._sketchViewModel.destroy(),this._highlightHelper?.destroy()}get formViewModel(){return this._formViewModel}get parent(){return this.data.parent}get parentLayer(){return this.parent?.data.editorItem.layer}get updating(){return this._updatingHandles.updating||this._formViewModel.updating||this._sketchViewModel.updating}static create(e){const{applyEdits:i,applyEditsFeatureService:r,defaultSplitterGeometryType:o,startAt:a,...s}=e;if("reviewing-features"===a){if(!s.splitterGeometry)throw new t("editing:split-geometry-required","Must provide the split geometry to start at the 'reviewing-features' step.");const e=M(k(s.originalFeature.geometry),s.splitterGeometry.type);if(s.splitterGeometry.type!==e)throw new t("editing:incompatible-split-geometries",`Geometry of type '${s.splitterGeometry.type}' cannot be used to split geometry of type '${s.originalFeature.geometry?.type}'.`)}const l=new T({data:new g(s),defaultSplitterGeometryType:o,onCommit:I(e.applyEdits)});return l._set("steps",T._createWorkflowSteps(l,a)),l}async enter(){}exit(){}async setActiveFeature(e){const i=this.data.getRoleForFeature(e);if(!i)throw new t("editing:unknown-feature","The provided feature is not part of this workflow.");const r=this._highlightHelper;r?.removeAll(),r?.add(e),await this._setFeatureOnFormViewModel(e,i)}async _createAndInitializeEdits({newPart:e,remainingPart:t}){const{data:i}=this,r=i.originalFeature,o=this._formViewModel,a=r.clone();a.geometry=t;const s=new w({feature:a});i.existingFeatureEdits=s,s.trackChanges(r),await this._setFeatureOnFormViewModel(a,"existing"),s.submittable=o.submittable;const l=r.clone();l.geometry=e,l.attributes=S(r.attributes,i.editorItem.layer);const n=new w({feature:l});return i.newFeatureEdits=n,n.trackChanges(),await this._setFeatureOnFormViewModel(l,"new"),n.submittable=o.submittable,{featureToCreate:l,featureToUpdate:a}}static _createWorkflowSteps(e,i="drawing-split-geometry"){const{data:r}=e;return f(["drawing-split-geometry","reviewing-features"],i,{"drawing-split-geometry":()=>({id:"drawing-split-geometry",async setUp(){const t=k(r.originalFeature.geometry),i=M(t,e.defaultSplitterGeometryType),o=e._sketchViewModel;e.addHandles(n(()=>o,"create",t=>{if("complete"===t.state){const a=t.graphic?.geometry;if(!V(a))return E().warn("editing:invalid-split-geometry","The geometry produced by the Sketch operation cannot be used for splitting."),void o.create(i);r.splitterGeometry=a,e.next()}}),this.id),await o.create(i)},async tearDown(){e.removeHandles(this.id)}}),"reviewing-features":()=>({id:"reviewing-features",async setUp(){const i=r.splitterGeometry;if(!i)throw new t("editing:missing-splitter-geometry","The `splitterGeometry` property of the workflow's data must be set in order to start the 'reviewing-features' step.");const o=await e._executeSplit(i),{featureToCreate:a,featureToUpdate:s}=await e._createAndInitializeEdits(o),l=await e._displayFeatureGraphics(s,a);e.addHandles(l,this.id)},async tearDown(){e._highlightHelper?.removeAll()}})})}async _displayFeatureGraphics(e,t){const{data:o,_graphicsLayer:a}=this,n=o.viewModel.view,p=[];if(!e||!t)return i();const d=s(i=>Promise.all([v(e,this._webStyleCache,i),v(t,this._webStyleCache,i)]));return await d("2d"===n?.type?n.scale:null),"2d"===n?.type&&p.push(l(()=>n.scale,e=>d(e))),a.add(t),p.push(i(()=>a.remove(t))),p.push(await _(this._sketchViewModel,o.originalFeature,e)),r(p)}async _executeSplit(e){const{data:i}=this,{originalFeature:r}=i,o=r.geometry;if(!o)throw new t("editing:feature-has-no-geometry","Cannot split the provided feature as it has no geometry.");const a=await b(o,e);if(!a||!a.newPart)throw new t("editing:split-failed","The split operation did not produce a valid result.");return a}_initializeFeatureFormViewModel(){const{data:e,_webStyleCache:t}=this,i=e.viewModel.view,r=i?.spatialReference??e.editorItem.layer.spatialReference,o=new j({formTemplate:e.editorItem.formTemplate,highlightHelper:this._highlightHelper,map:i?.map,spatialReference:r,timeZone:e.timeZone});this._formViewModel=o,this.addHandles(n(()=>o,"value-change",({feature:r,fieldName:o,value:a})=>{r&&(e.getEditsForFeature(r)?.setAttribute(o,a),v(r,t,i?.scale))}))}_initializeGraphicsLayer(){const{data:e}=this,{view:t}=e.viewModel,i=new u({elevationInfo:e.editorItem.layer.elevationInfo,internal:!0,listMode:"hide",title:"splitFeatureWorkflow-internal"});return this._graphicsLayer=i,t?.map.add(i),i}_initializeSketchViewModel(e){const{data:t}=this,{view:i}=t.viewModel;this._sketchViewModel=new G({layer:e,creationMode:"single",sketchOptions:t.sketchOptions,snappingManager:t.snappingManager,updateOnGraphicClick:!1,defaultUpdateOptions:{multipleSelectionEnabled:!1},view:i})}async _setFeatureOnFormViewModel(e,t){const{data:i}=this,r=this._formViewModel;r.feature=e,"existing"===t?(r.editType="UPDATE",r.overrideInitialFeature(i.originalFeature)):r.editType="INSERT",await p(()=>!r.updating)}get test(){}};e([d()],H.prototype,"defaultSplitterGeometryType",void 0),e([d()],H.prototype,"formViewModel",null),e([d()],H.prototype,"parent",null),e([d()],H.prototype,"parentLayer",null),e([d()],H.prototype,"type",void 0),e([d()],H.prototype,"updating",null),e([d()],H.prototype,"_formViewModel",void 0),e([d()],H.prototype,"_graphicsLayer",void 0),e([d()],H.prototype,"_highlightHelper",void 0),e([d()],H.prototype,"_sketchViewModel",void 0),H=T=e([h("esri.widgets.Editor.SplitFeatureWorkflow")],H);const L=H;function I(e){return async i=>{const{existingFeatureEdits:r,newFeatureEdits:o}=i,a=r?.feature?.cloneShallow(),s=o?.feature?.cloneShallow(),l=i.editorItem.layer;if(null==a||null==s)throw new t("editing:missing-features","Expected both a feature to update and a feature to add for the split operation.");r?.attributesModified||(a.attributes=F(a,i.editorItem.layer)),await e(l,{addFeatures:[s],updateFeatures:[a]})}}export{L as default};
5
+ import{__decorate as e}from"tslib";import t from"../../core/Error.js";import{makeHandle as i,handlesGroup as r}from"../../core/handleUtils.js";import"../../core/has.js";import a from"../../core/Logger.js";import{destroyMaybe as o}from"../../core/maybe.js";import{debounce as s}from"../../core/promiseUtils.js";import{watch as l,on as n,whenOnce as p}from"../../core/reactiveUtils.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import"../../core/RandomLCG.js";import{subclass as h}from"../../core/accessorSupport/decorators/subclass.js";import u from"../../layers/GraphicsLayer.js";import m from"../../views/draw/support/HighlightHelper.js";import{temporaryHighlightName as c}from"../../views/support/HighlightDefaults.js";import w from"./Edits.js";import g from"./SplitFeatureWorkflowData.js";import y from"./Workflow.js";import{createWorkflowSteps as f,swapForEditingSession as _,updateGraphicSymbolWhenRequired as v,makeMinimalAttributes as F}from"./workflowUtils.js";import{getCompatibleSpitterGeometryType as M,ensureSplittableGeometry as S,makeNewFeatureAttributes as b,splitGeometry as k,isSplitterGeometry as V}from"./support/splitFeatureUtils.js";import j from"../FeatureForm/FeatureFormViewModel.js";import G from"../Sketch/SketchViewModel.js";var T;const E=()=>a.getLogger("esri.widgets.Editor.SplitFeatureWorkflow");let H=T=class extends y{constructor(e){super(e),this.defaultSplitterGeometryType=null,this.type="split-feature",this._formViewModel=null,this._graphicsLayer=null,this._highlightHelper=null,this._sketchViewModel=null,this._webStyleCache=new Map}initialize(){const e=this.data.viewModel.view;this._highlightHelper=e?new m({view:e,highlightName:c}):null,this._initializeFeatureFormViewModel();const t=this._initializeGraphicsLayer();this._initializeSketchViewModel(t)}destroy(){const e=this._graphicsLayer,{view:t}=this.data.viewModel;t?.destroyed||t?.map.remove(e),this._graphicsLayer=o(this._graphicsLayer),this._formViewModel.destroy(),this._sketchViewModel.destroy(),this._highlightHelper?.destroy()}get formViewModel(){return this._formViewModel}get parent(){return this.data.parent}get parentLayer(){return this.parent?.data.editorItem.layer}get updating(){return this._updatingHandles.updating||this._formViewModel.updating||this._sketchViewModel.updating}static create(e){const{applyEdits:i,applyEditsFeatureService:r,defaultSplitterGeometryType:a,startAt:o,...s}=e;if("reviewing-features"===o){if(!s.splitterGeometry)throw new t("editing:split-geometry-required","Must provide the split geometry to start at the 'reviewing-features' step.");const e=M(S(s.originalFeature.geometry),s.splitterGeometry.type);if(s.splitterGeometry.type!==e)throw new t("editing:incompatible-split-geometries",`Geometry of type '${s.splitterGeometry.type}' cannot be used to split geometry of type '${s.originalFeature.geometry?.type}'.`)}const l=new T({data:new g(s),defaultSplitterGeometryType:a,onCommit:I(e.applyEdits)});return l._set("steps",T._createWorkflowSteps(l,o)),l}async enter(){}exit(){}async setActiveFeature(e){const i=this.data.getRoleForFeature(e);if(!i)throw new t("editing:unknown-feature","The provided feature is not part of this workflow.");const r=this._highlightHelper;r?.removeAll(),r?.add(e),await this._setFeatureOnFormViewModel(e,i)}async _createAndInitializeEdits({newPart:e,remainingPart:t}){const{data:i}=this,r=i.originalFeature,a=this._formViewModel,o=r.clone();o.geometry=t;const s=new w({feature:o});i.existingFeatureEdits=s,s.trackChanges(r),await this._setFeatureOnFormViewModel(o,"existing"),s.submittable=a.submittable;const l=r.clone();l.geometry=e,l.attributes=b(r.attributes,i.editorItem.layer);const n=new w({feature:l});return i.newFeatureEdits=n,n.trackChanges(),await this._setFeatureOnFormViewModel(l,"new"),n.submittable=a.submittable,{featureToCreate:l,featureToUpdate:o}}static _createWorkflowSteps(e,i="drawing-split-geometry"){const{data:r}=e;return f(["drawing-split-geometry","reviewing-features"],i,{"drawing-split-geometry":()=>({id:"drawing-split-geometry",async setUp(){const t=S(r.originalFeature.geometry),i=M(t,e.defaultSplitterGeometryType),a=e._sketchViewModel;e.addHandles(n(()=>a,"create",t=>{if("complete"===t.state){const o=t.graphic?.geometry;if(!V(o))return E().warn("editing:invalid-split-geometry","The geometry produced by the Sketch operation cannot be used for splitting."),void a.create(i);r.splitterGeometry=o,e.next()}}),this.id),await a.create(i)},async tearDown(){e.removeHandles(this.id)}}),"reviewing-features":()=>({id:"reviewing-features",async setUp(){const i=r.splitterGeometry;if(!i)throw new t("editing:missing-splitter-geometry","The `splitterGeometry` property of the workflow's data must be set in order to start the 'reviewing-features' step.");const a=await e._executeSplit(i),{featureToCreate:o,featureToUpdate:s}=await e._createAndInitializeEdits(a),l=await e._displayFeatureGraphics(s,o);e.addHandles(l,this.id)},async tearDown(){e._highlightHelper?.removeAll()}})})}async _displayFeatureGraphics(e,t){const{data:a,_graphicsLayer:o}=this,n=a.viewModel.view,p=[];if(!e||!t||!n)return i();const d=s(i=>Promise.all([v(e,this._webStyleCache,i),v(t,this._webStyleCache,i)]));return await d("2d"===n.type?n.scale:null),"2d"===n.type&&p.push(l(()=>n.scale,e=>d(e))),o.add(t),p.push(i(()=>o.remove(t))),p.push(await _(o,n,a.originalFeature,e)),r(p)}async _executeSplit(e){const{data:i}=this,{originalFeature:r}=i,a=r.geometry;if(!a)throw new t("editing:feature-has-no-geometry","Cannot split the provided feature as it has no geometry.");const o=await k(a,e);if(!o||!o.newPart)throw new t("editing:split-failed","The split operation did not produce a valid result.");return o}_initializeFeatureFormViewModel(){const{data:e,_webStyleCache:t}=this,i=e.viewModel.view,r=i?.spatialReference??e.editorItem.layer.spatialReference,a=new j({formTemplate:e.editorItem.formTemplate,highlightHelper:this._highlightHelper,map:i?.map,spatialReference:r,timeZone:e.timeZone});this._formViewModel=a,this.addHandles(n(()=>a,"value-change",({feature:r,fieldName:a,value:o})=>{r&&(e.getEditsForFeature(r)?.setAttribute(a,o),v(r,t,i?.scale))}))}_initializeGraphicsLayer(){const{data:e}=this,{view:t}=e.viewModel,i=new u({elevationInfo:e.editorItem.layer.elevationInfo,internal:!0,listMode:"hide",title:"splitFeatureWorkflow-internal"});return this._graphicsLayer=i,t?.map.add(i),i}_initializeSketchViewModel(e){const{data:t}=this,{view:i}=t.viewModel;this._sketchViewModel=new G({layer:e,creationMode:"single",sketchOptions:t.sketchOptions,snappingManager:t.snappingManager,updateOnGraphicClick:!1,defaultUpdateOptions:{multipleSelectionEnabled:!1},view:i})}async _setFeatureOnFormViewModel(e,t){const{data:i}=this,r=this._formViewModel;r.feature=e,"existing"===t?(r.editType="UPDATE",r.overrideInitialFeature(i.originalFeature)):r.editType="INSERT",await p(()=>!r.updating)}get test(){}};e([d()],H.prototype,"defaultSplitterGeometryType",void 0),e([d()],H.prototype,"formViewModel",null),e([d()],H.prototype,"parent",null),e([d()],H.prototype,"parentLayer",null),e([d()],H.prototype,"type",void 0),e([d()],H.prototype,"updating",null),e([d()],H.prototype,"_formViewModel",void 0),e([d()],H.prototype,"_graphicsLayer",void 0),e([d()],H.prototype,"_highlightHelper",void 0),e([d()],H.prototype,"_sketchViewModel",void 0),H=T=e([h("esri.widgets.Editor.SplitFeatureWorkflow")],H);const L=H;function I(e){return async i=>{const{existingFeatureEdits:r,newFeatureEdits:a}=i,o=r?.feature?.cloneShallow(),s=a?.feature?.cloneShallow(),l=i.editorItem.layer;if(null==o||null==s)throw new t("editing:missing-features","Expected both a feature to update and a feature to add for the split operation.");r?.attributesModified||(o.attributes=F(o,i.editorItem.layer)),await e(l,{addFeatures:[s],updateFeatures:[o]})}}export{L 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.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../core/Error.js";import{makeHandle as i}from"../../core/handleUtils.js";import"../../core/has.js";import{destroyMaybe as o}from"../../core/maybe.js";import{watch as s}from"../../core/reactiveUtils.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as r}from"../../core/accessorSupport/decorators/subclass.js";import l from"../../layers/GraphicsLayer.js";import{highlightsSupported as d}from"../../views/support/layerViewUtils.js";import h from"./UpdateFeatureWorkflowData.js";import{UpdateRecordWorkflow as n,handleKeys as c}from"./UpdateRecordWorkflow.js";import{getVisualVariableAttributes as p,setUpGeometryUpdate as w,updateGraphicSymbolWhenRequired as u,swapForEditingSession as m,cloneGraphicExceptMesh as y,canCreateInteractiveEditSession as f,isTerminalUpdateEventType as g}from"./workflowUtils.js";import k from"../Sketch/SketchViewModel.js";var _;const V={...c,highlights:Symbol(),sketchGraphics:Symbol(),sketchViewModel:Symbol(),waitingForTool:Symbol()};let v=_=class extends n{constructor(e){super(e),this.type="update-feature",this._layerViewEditSession=null,this._sketchGraphicClone=null,this._sketchViewModel=null,this._webStyleCache=new Map}destroy(){this._layerViewEditSession?.rollback()}async commit(){this.removeHandles(V.sketchGraphics);try{const e=this.data.edits.stagedForDelete;await super.commit();const t=this._layerViewEditSession;e?t?.rollback():t?.commit()}catch(e){throw await this._configureSketchViewModel(),new t("editor-workflow:failed-to-commit","An error occurred when sending the updates to the service",{error:e})}}async start(){return await super.start(),await this._initializeSketchViewModel()}_initializeFeatureFormViewModel(){super._initializeFeatureFormViewModel(),this.addHandles([this._featureFormViewModel.on("value-change",e=>{this._layerViewEditSession?.setAttribute(e.fieldName,e.value)}),s(()=>this._featureFormViewModel.feature?.sourceLayer,e=>this._sketchGraphicClone.sourceLayer=e)])}_configureHighlight(){const{edits:e,layerView:t}=this.data;d(t)&&this.addHandles(t.highlight(e.feature),V.highlights)}async _configureSketchViewModel(){const e=this._sketchViewModel;if(!e)return;const{data:t,_featureFormViewModel:i,_sketchGraphicClone:o}=this,{edits:s,viewModel:a}=t,r=s.feature,{view:l}=a,d=p(r),h=await w({feature:r,featureClone:o,visualVariableAttributes:d,sketchViewModel:e,view:l,onUpdate:({geometry:e,attributes:t},o)=>{if(s.updateAttributes(t),s.updateGeometry(e),i.feature&&(i.feature.geometry=e),null!=d.rotation){const{field:e}=d.rotation;i.setValue(e,t[e])}if(null!=d.size){const{field:e}=d.size;i.setValue(e,t[e])}("undo"===o.type||"redo"===o.type||"update"===o.type&&null!=o.toolEventInfo&&g(o.toolEventInfo.type))&&i.notifyFeatureGeometryChanged()},addUpdatingPromise:e=>{this._updatingHandles.addPromise(e)},addHandle:e=>{this.addHandles(e,V.waitingForTool)},webStyleCache:this._webStyleCache});this.addHandles(h,V.sketchGraphics),e.addHandles(h)}async _initializeSketchViewModel(){const{data:e,_sketchGraphicClone:t}=this,{readOnly:s}=e,a=e.edits.feature,{capabilities:r,layer:d}=e.editorItem,{view:h}=e.viewModel;if(this.removeHandles([V.highlights,V.sketchGraphics,V.sketchViewModel,V.waitingForTool]),!r.update.geometry||s)return{enter:async()=>{this.hasHandles(V.highlights)||this._configureHighlight()},exit:()=>this.removeHandles([V.highlights])};const n=new l({elevationInfo:d.elevationInfo,internal:!0,listMode:"hide",title:"updateFeaturesWorkflow-internal"}),c=new k({allowDeleteKey:!1,layer:n,sketchOptions:e.sketchOptions,snappingManager:e.snappingManager,updateOnGraphicClick:!1,view:h});return this._sketchViewModel=c,h?.map.add(n),await(h?.whenLayerView(n)),this.addHandles(i(()=>{h?.destroyed||h?.map.remove(n),n.destroyed||n.destroy(),this._sketchViewModel=o(c)}),V.sketchViewModel),await u(t,this._webStyleCache,"2d"===h?.type?h.scale:null),this.addHandles([await m(c,a,t)]),{enter:async()=>{this.hasHandles(V.sketchGraphics)||await this._configureSketchViewModel()},exit:()=>this.removeHandles([V.sketchGraphics]),viewModel:c}}_onFullFeatureLoaded(e){super._onFullFeatureLoaded(e);const t=this._sketchGraphicClone=y(e),{edits:i,layerView:o}=this.data;i.updateGeometry(e.geometry),i.trackChanges(),f(o)&&(this._layerViewEditSession=o.createInteractiveEditSession(t))}static async create(e){const t=new _({data:await h.create(e),onCommit:this._onCommitFactory(e.applyEdits)});return t._set("steps",this._createWorkflowSteps(t)),t}get test(){}};e([a()],v.prototype,"_layerViewEditSession",void 0),e([a()],v.prototype,"_sketchGraphicClone",void 0),e([a()],v.prototype,"_sketchViewModel",void 0),v=_=e([r("esri.widgets.Editor.UpdateFeatureWorkflow")],v);export{v as UpdateFeatureWorkflow,V as handleKeys};
5
+ import{__decorate as e}from"tslib";import t from"../../core/Error.js";import{makeHandle as i}from"../../core/handleUtils.js";import"../../core/has.js";import{destroyMaybe as s}from"../../core/maybe.js";import{watch as o}from"../../core/reactiveUtils.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import l from"../../layers/GraphicsLayer.js";import{highlightsSupported as h}from"../../views/support/layerViewUtils.js";import d from"./UpdateFeatureWorkflowData.js";import{UpdateRecordWorkflow as n,handleKeys as c}from"./UpdateRecordWorkflow.js";import{getVisualVariableAttributes as p,setUpGeometryUpdate as w,updateGraphicSymbolWhenRequired as u,swapForEditingSession as m,cloneGraphicExceptMesh as y,canCreateInteractiveEditSession as f,isTerminalUpdateEventType as k}from"./workflowUtils.js";import g from"../Sketch/SketchViewModel.js";var _;const V={...c,highlights:Symbol(),sketchGraphics:Symbol(),sketchViewModel:Symbol(),waitingForTool:Symbol()};let v=_=class extends n{constructor(e){super(e),this.type="update-feature",this._layerViewEditSession=null,this._sketchGraphicClone=null,this._sketchLayer=null,this._sketchViewModel=null,this._webStyleCache=new Map}destroy(){this._layerViewEditSession?.rollback()}async commit(){this.removeHandles(V.sketchGraphics);try{const e=this.data.edits.stagedForDelete;await super.commit();const t=this._layerViewEditSession;e?t?.rollback():t?.commit()}catch(e){throw await this._configureSketchViewModel(),new t("editor-workflow:failed-to-commit","An error occurred when sending the updates to the service",{error:e})}}async start(){return await super.start(),await this._initializeSketchViewModel()}_initializeFeatureFormViewModel(){super._initializeFeatureFormViewModel(),this.addHandles([this._featureFormViewModel.on("value-change",e=>{this._layerViewEditSession?.setAttribute(e.fieldName,e.value)}),o(()=>this._featureFormViewModel.feature?.sourceLayer,e=>this._sketchGraphicClone.sourceLayer=e)])}_configureHighlight(){const{edits:e,layerView:t}=this.data;h(t)&&this.addHandles(t.highlight(e.feature),V.highlights)}async _configureSketchViewModel(){const{_sketchLayer:e,_sketchViewModel:t}=this;if(!t||!e)return;const{data:i,_featureFormViewModel:s,_sketchGraphicClone:o}=this,{edits:r,viewModel:a}=i,l=r.feature,{view:h}=a,d=p(l),n=await w({feature:l,featureClone:o,visualVariableAttributes:d,sketchLayer:e,sketchViewModel:t,view:h,onUpdate:({geometry:e,attributes:t},i)=>{if(r.updateAttributes(t),r.updateGeometry(e),s.feature&&(s.feature.geometry=e),null!=d.rotation){const{field:e}=d.rotation;s.setValue(e,t[e])}if(null!=d.size){const{field:e}=d.size;s.setValue(e,t[e])}("undo"===i.type||"redo"===i.type||"update"===i.type&&null!=i.toolEventInfo&&k(i.toolEventInfo.type))&&s.notifyFeatureGeometryChanged()},addUpdatingPromise:e=>{this._updatingHandles.addPromise(e)},addHandle:e=>{this.addHandles(e,V.waitingForTool)},webStyleCache:this._webStyleCache});this.addHandles(n,V.sketchGraphics),t.addHandles(n)}async _initializeSketchViewModel(){const{data:e,_sketchGraphicClone:t}=this,{readOnly:o}=e,r=e.edits.feature,{capabilities:a,layer:h}=e.editorItem,d=e.viewModel.view;if(this.removeHandles([V.highlights,V.sketchGraphics,V.sketchViewModel,V.waitingForTool]),!a.update.geometry||o)return{enter:async()=>{this.hasHandles(V.highlights)||this._configureHighlight()},exit:()=>this.removeHandles([V.highlights])};const n=new l({elevationInfo:h.elevationInfo,internal:!0,listMode:"hide",title:"updateFeaturesWorkflow-internal"}),c=new g({allowDeleteKey:!1,layer:n,sketchOptions:e.sketchOptions,snappingManager:e.snappingManager,updateOnGraphicClick:!1,view:d});return this._sketchLayer=n,this._sketchViewModel=c,d?.map.add(n),await(d?.whenLayerView(n)),this.addHandles(i(()=>{d?.destroyed||d?.map.remove(n),n.destroyed||n.destroy(),this._sketchViewModel=s(c)}),V.sketchViewModel),await u(t,this._webStyleCache,"2d"===d?.type?d.scale:null),this.addHandles([await m(n,d,r,t)]),{enter:async()=>{this.hasHandles(V.sketchGraphics)||await this._configureSketchViewModel()},exit:()=>this.removeHandles([V.sketchGraphics]),viewModel:c}}_onFullFeatureLoaded(e){super._onFullFeatureLoaded(e);const t=this._sketchGraphicClone=y(e),{edits:i,layerView:s}=this.data;i.updateGeometry(e.geometry),i.trackChanges(),f(s)&&(this._layerViewEditSession=s.createInteractiveEditSession(t))}static async create(e){const t=new _({data:await d.create(e),onCommit:this._onCommitFactory(e.applyEdits)});return t._set("steps",this._createWorkflowSteps(t)),t}get test(){}};e([r()],v.prototype,"_layerViewEditSession",void 0),e([r()],v.prototype,"_sketchGraphicClone",void 0),e([r()],v.prototype,"_sketchLayer",void 0),e([r()],v.prototype,"_sketchViewModel",void 0),v=_=e([a("esri.widgets.Editor.UpdateFeatureWorkflow")],v);export{v as UpdateFeatureWorkflow,V as handleKeys};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import{isSome as i}from"../../../core/arrayUtils.js";import{abortHandle as s}from"../../../core/handleUtils.js";import{debounce as a}from"../../../core/promiseUtils.js";import{whenOnce as r,watch as o}from"../../../core/reactiveUtils.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as c}from"../../../core/support/UpdatingHandles.js";import p from"../../../layers/GraphicsLayer.js";import d from"../../../views/interactive/sketch/SketchOptions.js";import{getVisualVariablesForLayer as h,updateGraphicSymbolWhenRequired as u,setVisualVariablesAndElevationInfoForUpdate as y,swapForEditingSession as m,visualVariableInteractiveUpdate as w,getSizeVariableAttribute as v,getRotationVariableAttribute as g}from"../workflowUtils.js";import f from"../../Sketch/SketchViewModel.js";const _=Symbol();let b=class extends t{constructor(e){super(e),this.features=[],this.sketchOptions=new d,this.snappingManager=null,this.sourceLayer=null,this.view=null,this.viewModel=null,this._sketchGraphics=new Map,this._sketchLayer=null,this._updatingHandles=new c,this._visualVariableAttributes=new Map,this._visualVariablesForLayer=null,this._webStyleCache=new Map}async initialize(){this._visualVariablesForLayer=h(this.sourceLayer),this._initializeSketchGraphics(),this._initializeSketchLayer(),await this._updatingHandles.addPromise(this._initializeSketchViewModel())}destroy(){const{_sketchLayer:e,view:t}=this;t?.destroyed||t?.map.remove(e),e.destroy(),this.viewModel.destroy()}get updating(){return this._updatingHandles.updating}async enter(){throw new Error("enter() not implemented")}async exit(){throw new Error("exit() not implemented")}notifyAttributesChanged({features:e,fieldName:t}){const i=this._webStyleCache,s=this.view.scale,a=this._updatingHandles;for(const r of e){const e=this._sketchGraphics.get(r),o=r.getAttribute(t);if(!e||e.getAttribute(t)===o)continue;e.setAttribute(t,o);const n=this._visualVariableAttributes.get(r);null==n?.size||n.size.isUpdatingInteractively||n.size.field!==t||n.size.setInitialValue(o),null==n?.rotation||n.rotation.isUpdatingInteractively||n.rotation.field!==t||n.rotation.setInitialValue(o),a.addPromise(u(e,i,s))}}async startUpdatingFeatures(e,t,a){const{_sketchGraphics:o,sourceLayer:n,view:l,viewModel:c,_webStyleCache:p}=this,d=e.map(e=>o.get(e)).filter(i),h={};this.removeHandles(_),c.complete();let m=null;if(1===e.length){const t=e[0],i=this._visualVariableAttributes.get(t);!(!i?.rotation&&!i?.size)&&(await y({sketchViewModel:c,graphic:d[0],sourceLayer:n,visualVariables:i,webStyleCache:p}),"point"===n.geometryType&&(h.enableRotation=null!=i.rotation,h.enableScaling=null!=i.size,m=async e=>{const s=e.graphics[0];w(l,s,e,i)&&(a?.([{feature:t,attributes:s.attributes}],e),this._updatingHandles.addPromise(u(s,p,"2d"===l.type?l.scale:null)))}))}else h.tool="move";const v=()=>c.update(d,h),g=c.on("update",a=>{if("complete"===a.state){if(null===l.activeTool)return void v();const e=new AbortController,t=s(e);return this.addHandles(t,_),void this._updatingHandles.addPromise(r(()=>null===l.activeTool,e.signal).then(async()=>{e.signal.aborted||(e.abort(),await v())}))}const n=e.map(e=>{const t=o.get(e);return t?{feature:e,geometry:t.geometry}:null}).filter(i);t(n,a),m?.(a)});await v(),this.addHandles(g,_),c.addHandles(g)}_initializeSketchGraphics(){const{features:e,_sketchGraphics:t,sourceLayer:i,_visualVariableAttributes:s}=this,a=this._visualVariablesForLayer,r=a.rotation?.field,o=a.size?.field,n={rotation:r?i.getField(r):null,size:o?i.getField(o):null},l=!(!n.rotation&&!n.size);for(const c of e)t.set(c,c.clone()),l&&s.set(c,k(a,n))}_initializeSketchLayer(){const{view:e}=this,t=new p({elevationInfo:this.sourceLayer.elevationInfo,internal:!0,listMode:"hide",title:"SketchController layer"});this._sketchLayer=t,e.map.add(t),this._updatingHandles.addPromise(e.whenLayerView(t))}async _initializeSketchViewModel(){const{_sketchGraphics:e,view:t,_webStyleCache:i}=this,s=Array.from(e.entries()),r=new f({allowDeleteKey:!1,defaultUpdateOptions:{multipleSelectionEnabled:!1},layer:this._sketchLayer,sketchOptions:this.sketchOptions,snappingManager:this.snappingManager,updateOnGraphicClick:!1,view:this.view});this.viewModel=r;const n=a(e=>Promise.all(s.map(([,t])=>u(t,i,e))));await n("2d"===t.type?t.scale:null),"2d"===t.type&&this.addHandles(o(()=>t.scale,e=>n(e))),this.addHandles(await Promise.all(s.map(([e,t])=>m(r,e,t))))}};function k({rotation:e,size:t},i){return{rotation:e?g(e,i.rotation):null,size:t?v(t,i.size):null}}e([n()],b.prototype,"features",void 0),e([n()],b.prototype,"sketchOptions",void 0),e([n()],b.prototype,"snappingManager",void 0),e([n()],b.prototype,"sourceLayer",void 0),e([n()],b.prototype,"updating",null),e([n()],b.prototype,"view",void 0),e([n()],b.prototype,"viewModel",void 0),e([n()],b.prototype,"_sketchGraphics",void 0),e([n()],b.prototype,"_sketchLayer",void 0),e([n()],b.prototype,"_visualVariablesForLayer",void 0),b=e([l("esri.widgets.Editor.support.SketchController")],b);export{b as SketchController};
5
+ import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import{isSome as i}from"../../../core/arrayUtils.js";import{abortHandle as s}from"../../../core/handleUtils.js";import{debounce as a}from"../../../core/promiseUtils.js";import{whenOnce as r,watch as o}from"../../../core/reactiveUtils.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as c}from"../../../core/support/UpdatingHandles.js";import p from"../../../layers/GraphicsLayer.js";import d from"../../../views/interactive/sketch/SketchOptions.js";import{getVisualVariablesForLayer as h,updateGraphicSymbolWhenRequired as u,setVisualVariablesAndElevationInfoForUpdate as y,swapForEditingSession as m,visualVariableInteractiveUpdate as w,getSizeVariableAttribute as g,getRotationVariableAttribute as v}from"../workflowUtils.js";import f from"../../Sketch/SketchViewModel.js";const _=Symbol();let b=class extends t{constructor(e){super(e),this.features=[],this.sketchOptions=new d,this.snappingManager=null,this.sourceLayer=null,this.view=null,this.viewModel=null,this._sketchGraphicsMap=new Map,this._sketchLayer=null,this._updatingHandles=new c,this._visualVariableAttributes=new Map,this._visualVariablesForLayer=null,this._webStyleCache=new Map}async initialize(){this._visualVariablesForLayer=h(this.sourceLayer),this._initializeSketchGraphics(),this._initializeSketchLayer(),await this._updatingHandles.addPromise(this._initializeSketchViewModel())}destroy(){const{_sketchLayer:e,view:t}=this;t?.destroyed||t?.map.remove(e),e.destroy(),this.viewModel.destroy()}get updating(){return this._updatingHandles.updating}async enter(){throw new Error("enter() not implemented")}async exit(){throw new Error("exit() not implemented")}notifyAttributesChanged({features:e,fieldName:t}){const i=this._webStyleCache,s=this.view.scale,a=this._updatingHandles;for(const r of e){const e=this._sketchGraphicsMap.get(r),o=r.getAttribute(t);if(!e||e.getAttribute(t)===o)continue;e.setAttribute(t,o);const n=this._visualVariableAttributes.get(r);null==n?.size||n.size.isUpdatingInteractively||n.size.field!==t||n.size.setInitialValue(o),null==n?.rotation||n.rotation.isUpdatingInteractively||n.rotation.field!==t||n.rotation.setInitialValue(o),a.addPromise(u(e,i,s))}}async startUpdatingFeatures(e,t,a){const{_sketchGraphicsMap:o,_sketchLayer:n,sourceLayer:l,view:c,viewModel:p,_webStyleCache:d}=this,h=e.map(e=>o.get(e)).filter(i),m={};this.removeHandles(_),p.complete();let g=null;if(1===e.length){const t=e[0],i=this._visualVariableAttributes.get(t);!(!i?.rotation&&!i?.size)&&(await y({graphic:h[0],sketchLayer:n,sketchViewModel:p,sourceLayer:l,visualVariables:i,webStyleCache:d}),"point"===l.geometryType&&(m.enableRotation=null!=i.rotation,m.enableScaling=null!=i.size,g=async e=>{const s=e.graphics[0];w(c,s,e,i)&&(a?.([{feature:t,attributes:s.attributes}],e),this._updatingHandles.addPromise(u(s,d,"2d"===c.type?c.scale:null)))}))}else m.tool="move";const v=()=>p.update(h,m),f=p.on("update",a=>{if("complete"===a.state){if(null===c.activeTool)return void v();const e=new AbortController,t=s(e);return this.addHandles(t,_),void this._updatingHandles.addPromise(r(()=>null===c.activeTool,e.signal).then(async()=>{e.signal.aborted||(e.abort(),await v())}))}const n=e.map(e=>{const t=o.get(e);return t?{feature:e,geometry:t.geometry}:null}).filter(i);t(n,a),g?.(a)});await v(),this.addHandles(f,_),p.addHandles(f)}_initializeSketchGraphics(){const{features:e,_sketchGraphicsMap:t,sourceLayer:i,_visualVariableAttributes:s}=this,a=this._visualVariablesForLayer,r=a.rotation?.field,o=a.size?.field,n={rotation:r?i.getField(r):null,size:o?i.getField(o):null},l=!(!n.rotation&&!n.size);for(const c of e)t.set(c,c.clone()),l&&s.set(c,k(a,n))}_initializeSketchLayer(){const{view:e}=this,t=new p({elevationInfo:this.sourceLayer.elevationInfo,internal:!0,listMode:"hide",title:"SketchController layer"});this._sketchLayer=t,e.map.add(t),this._updatingHandles.addPromise(e.whenLayerView(t))}async _initializeSketchViewModel(){const{_sketchGraphicsMap:e,_sketchLayer:t,view:i,_webStyleCache:s}=this,r=Array.from(e.entries()),n=new f({allowDeleteKey:!1,defaultUpdateOptions:{multipleSelectionEnabled:!1},layer:t,sketchOptions:this.sketchOptions,snappingManager:this.snappingManager,updateOnGraphicClick:!1,view:i});this.viewModel=n;const l=a(e=>Promise.all(r.map(([,t])=>u(t,s,e))));await l("2d"===i.type?i.scale:null),"2d"===i.type&&this.addHandles(o(()=>i.scale,e=>l(e))),this.addHandles(await Promise.all(r.map(([e,s])=>m(t,i,e,s))))}};function k({rotation:e,size:t},i){return{rotation:e?v(e,i.rotation):null,size:t?g(t,i.size):null}}e([n()],b.prototype,"features",void 0),e([n()],b.prototype,"sketchOptions",void 0),e([n()],b.prototype,"snappingManager",void 0),e([n()],b.prototype,"sourceLayer",void 0),e([n()],b.prototype,"updating",null),e([n()],b.prototype,"view",void 0),e([n()],b.prototype,"viewModel",void 0),e([n()],b.prototype,"_sketchGraphicsMap",void 0),e([n()],b.prototype,"_sketchLayer",void 0),e([n()],b.prototype,"_visualVariablesForLayer",void 0),b=e([l("esri.widgets.Editor.support.SketchController")],b);export{b as SketchController};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../core/Error.js";import{splitSegmentAtPoint as t}from"../../../editing/geometry/lineUtils.js";import n from"../../../geometry/Polyline.js";import{isCurvedGeometry as r,getEndpoint as o}from"../../../geometry/support/curves/curveUtils.js";import{createCoordinateHelper as i}from"../../../views/interactive/coordinateHelper.js";async function a(t,n){if("point"===t.type||"extent"===t.type||"mesh"===t.type)throw new e("editing:unsupported-split-geometry",`Cannot split geometry of type ${t.type}`);if("point"===n.type&&c(t))return await p(t,n);if("polyline"===n.type&&y(t))return l(t,n);if("polygon"===n.type&&u(t))return s(t,n);throw new e("editing:unsupported-split-geometry",`Geometry of type ${n.type} cannot be used to split geometry of type ${t.type}`)}async function p(a,p){const{apiConverter:s,arcadeGeometryFunctions:{planarLength3D:l},arcadeMeasures:{pointToCoordinate:c},lengthOperator:u}=await f(),y=s.fromSpatialReference(a.spatialReference)?.getTolerance()??.001,d=c(a,p);if(null==d||null==d.distance||d.distance>y)return null;const m=c(a,d.coordinate);if(null==m||null==m.distanceAlong||null==m.partId||null==m.segmentId)throw new e("editing:split-by-point-failed","Failed to determine the split point on the polyline.");const g=m.coordinate.hasZ&&a.hasZ,h=g?l:u.execute,w=i(g,a.hasM,a.spatialReference),j=r(a),I=j?a.curvePaths:a.paths,P=[],F=[];for(let e=0;e<I.length;e++){const n=I[e];if(e<m.partId)P.push(n);else if(e>m.partId)F.push(n);else{const e=[],r=[];for(let i=0;i<n.length;i++){const a=n[i];if(i<m.segmentId)e.push(a);else if(i>m.segmentId)r.push(a);else{const p=o(a),s=n.at(i+1),l=w.pointToArray(m.coordinate);if(i++,!s){e.push(a,l),r.push(l);continue}const[c,u]=t(p,s,l,y);e.push(...c),r.push(...u)}}e.length>0&&P.push(e),r.length>0&&F.push(r)}}const O=new n({[j?"curvePaths":"paths"]:P,spatialReference:a.spatialReference,hasZ:a.hasZ,hasM:a.hasM}),v=new n({[j?"curvePaths":"paths"]:F,spatialReference:a.spatialReference,hasZ:a.hasZ,hasM:a.hasM}),b=h(O),M=h(v),x=Math.max(b,M);if(0===x)return null;const R=x===b?O:v;return{remainingPart:R,newPart:0===Math.min(b,M)?null:R===O?v:O}}async function s(e,t){const{differenceOperator:n,intersectionOperator:r}=await d(),o=r.execute(e,t);if(!o)return null;const i=n.execute(e,t);return i?{newPart:o,remainingPart:i}:{newPart:null,remainingPart:o}}async function l(e,t){const{cutOperator:n}=await m(),r=n.execute(e,t);if(2!==r.length)return null;const o=r[0];return{newPart:r[1]??null,remainingPart:o}}function c(e){return"polyline"===e.type}function u(e){return"polygon"===e.type||"polyline"===e.type||"multipoint"===e.type}function y(e){return"polygon"===e.type||"polyline"===e.type}async function f(){const[e,t,n,r]=await Promise.all([import("../../../geometry/operators/support/apiConverter.js"),import("../../../arcade/geometry/functions.js"),import("../../../arcade/functions/measures.js"),import("../../../geometry/operators/lengthOperator.js")]);return{apiConverter:e,arcadeGeometryFunctions:t,lengthOperator:r,arcadeMeasures:n}}async function d(){const[e,t]=await Promise.all([import("../../../geometry/operators/differenceOperator.js"),import("../../../geometry/operators/intersectionOperator.js")]);return{differenceOperator:e,intersectionOperator:t}}async function m(){return{cutOperator:await import("../../../geometry/operators/cutOperator.js")}}function g(t){if(!t)throw new e("editing:cannot-split-geometry","No geometry provided.");if(u(t)||y(t)||c(t))return t;throw new e("editing:cannot-split-geometry",`Cannot split geometry of type ${t.type}`)}function h(e,t){return"point"===t&&c(e)||"polyline"===t&&y(e)||"polygon"===t&&u(e)?t:w(e)}function w(e){return"polyline"===e.type?"point":"polyline"}function j(e){return"point"===e?.type||"polyline"===e?.type||"polygon"===e?.type}function I(e,t){const{fieldsIndex:n}=t,r={...e};if("globalIdField"in t&&t.globalIdField){delete r[n.get(t.globalIdField)?.name??t.globalIdField]}if(t.objectIdField){delete r[n.get(t.objectIdField)?.name??t.objectIdField]}if("relationships"in t&&t.relationships)for(const o of t.relationships)if("one-to-one"===o.cardinality||"origin"===o.role&&"one-to-many"===o.cardinality){const e=n.get(o.keyField)?.name??o.keyField;null!=r[e]&&delete r[e]}return r}export{g as ensureSplittableGeometry,h as getCompatibleSpitterGeometryType,w as getDefaultSplitterGeometryType,j as isSplitterGeometry,I as makeNewFeatureAttributes,a as splitGeometry};
5
+ import e from"../../../core/Error.js";import{splitSegmentAtPoint as t}from"../../../editing/geometry/lineUtils.js";import n from"../../../geometry/Polyline.js";import{isCurvedGeometry as r,getEndpoint as o}from"../../../geometry/support/curves/curveUtils.js";import{createCoordinateHelper as i}from"../../../views/interactive/coordinateHelper.js";async function a(t,n){if("point"===t.type||"extent"===t.type||"mesh"===t.type)throw new e("editing:unsupported-split-geometry",`Cannot split geometry of type ${t.type}`);if("point"===n.type&&c(t))return await p(t,n);if("polyline"===n.type&&y(t))return s(t,n);if("polygon"===n.type&&u(t))return l(t,n);throw new e("editing:unsupported-split-geometry",`Geometry of type ${n.type} cannot be used to split geometry of type ${t.type}`)}async function p(a,p){const{apiConverter:l,arcadeMeasures:{pointToCoordinate:s},lengthOperator:c}=await f(),u=l.fromSpatialReference(a.spatialReference)?.getTolerance()??.001,y=s(a,p);if(null==y||null==y.distance||y.distance>u)return null;const d=s(a,y.coordinate);if(null==d||null==d.distanceAlong||null==d.partId||null==d.segmentId)throw new e("editing:split-by-point-failed","Failed to determine the split point on the polyline.");const m=d.coordinate.hasZ&&a.hasZ,g=i(m,a.hasM,a.spatialReference),h=r(a),w=h?a.curvePaths:a.paths,j=[],I=[];for(let e=0;e<w.length;e++){const n=w[e];if(e<d.partId)j.push(n);else if(e>d.partId)I.push(n);else{const e=[],r=[];for(let i=0;i<n.length;i++){const a=n[i];if(i<d.segmentId)e.push(a);else if(i>d.segmentId)r.push(a);else{const p=o(a),l=n.at(i+1),s=g.pointToArray(d.coordinate);if(i++,!l){e.push(a,s),r.push(s);continue}const[c,y]=t(p,l,s,m,u);e.push(...c),r.push(...y)}}e.length>0&&j.push(e),r.length>0&&I.push(r)}}const P=new n({[h?"curvePaths":"paths"]:j,spatialReference:a.spatialReference,hasZ:a.hasZ,hasM:a.hasM}),O=new n({[h?"curvePaths":"paths"]:I,spatialReference:a.spatialReference,hasZ:a.hasZ,hasM:a.hasM}),v=c.execute(P),F=c.execute(O),b=Math.max(v,F);if(0===b)return null;const x=b===v?P:O;return{remainingPart:x,newPart:0===Math.min(v,F)?null:x===P?O:P}}async function l(e,t){const{differenceOperator:n,intersectionOperator:r}=await d(),o=r.execute(e,t);if(!o)return null;const i=n.execute(e,t);return i?{newPart:o,remainingPart:i}:{newPart:null,remainingPart:o}}async function s(e,t){const{cutOperator:n}=await m(),r=n.execute(e,t);if(2!==r.length)return null;const o=r[0];return{newPart:r[1]??null,remainingPart:o}}function c(e){return"polyline"===e.type}function u(e){return"polygon"===e.type||"polyline"===e.type||"multipoint"===e.type}function y(e){return"polygon"===e.type||"polyline"===e.type}async function f(){const[e,t,n]=await Promise.all([import("../../../geometry/operators/support/apiConverter.js"),import("../../../arcade/functions/measures.js"),import("../../../geometry/operators/lengthOperator.js")]);return{apiConverter:e,lengthOperator:n,arcadeMeasures:t}}async function d(){const[e,t]=await Promise.all([import("../../../geometry/operators/differenceOperator.js"),import("../../../geometry/operators/intersectionOperator.js")]);return{differenceOperator:e,intersectionOperator:t}}async function m(){return{cutOperator:await import("../../../geometry/operators/cutOperator.js")}}function g(t){if(!t)throw new e("editing:cannot-split-geometry","No geometry provided.");if(u(t)||y(t)||c(t))return t;throw new e("editing:cannot-split-geometry",`Cannot split geometry of type ${t.type}`)}function h(e,t){return"point"===t&&c(e)||"polyline"===t&&y(e)||"polygon"===t&&u(e)?t:w(e)}function w(e){return"polyline"===e.type?"point":"polyline"}function j(e){return"point"===e?.type||"polyline"===e?.type||"polygon"===e?.type}function I(e,t){const{fieldsIndex:n}=t,r={...e};if("globalIdField"in t&&t.globalIdField){delete r[n.get(t.globalIdField)?.name??t.globalIdField]}if(t.objectIdField){delete r[n.get(t.objectIdField)?.name??t.objectIdField]}if("relationships"in t&&t.relationships)for(const o of t.relationships)if("one-to-one"===o.cardinality||"origin"===o.role&&"one-to-many"===o.cardinality){const e=n.get(o.keyField)?.name??o.keyField;null!=r[e]&&delete r[e]}return r}export{g as ensureSplittableGeometry,h as getCompatibleSpitterGeometryType,w as getDefaultSplitterGeometryType,j as isSplitterGeometry,I as makeNewFeatureAttributes,a as splitGeometry};