@arcgis/core 5.0.0-next.16 → 5.0.0-next.17

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 (182) hide show
  1. package/analysis/ElevationProfile/ElevationProfileLineInput.js +1 -1
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/234b52b2a391631ceff6.js +1 -0
  4. package/assets/esri/core/workers/chunks/{8f3503b2fb6cd38757b9.js → 458e87902abc24b375da.js} +1 -1
  5. package/assets/esri/core/workers/chunks/{57b410198d83bf0ab708.js → 4a89e120be142ab58a27.js} +1 -1
  6. package/assets/esri/core/workers/chunks/{a410dcf80d17a2383337.js → 65a4099bdbe31834d0cc.js} +1 -1
  7. package/assets/esri/core/workers/chunks/722da7a39a0ad9300752.js +1 -0
  8. package/assets/esri/core/workers/chunks/{cdb4664fd59860ddeb5a.js → 888f188541f8bd68e33e.js} +1 -1
  9. package/assets/esri/core/workers/chunks/{319c3f46f2afb8f3e5a9.js → 89c9cf7f799858d14c76.js} +1 -1
  10. package/assets/esri/core/workers/chunks/{e19cd07df8ce87e18832.js → 8b33732e3c2924c1f60d.js} +1 -1
  11. package/assets/esri/core/workers/chunks/98739414c107ad78e4d8.js +1 -0
  12. package/assets/esri/core/workers/chunks/{bc318b6fef192cee2a72.js → a4518f25b9f8fe704286.js} +17 -17
  13. package/assets/esri/core/workers/chunks/{8b73db0f4d6714396eb0.js → a6fa90eab77ac0e1cdfc.js} +1 -1
  14. package/assets/esri/core/workers/chunks/ac366221e8636b60aee5.js +1 -0
  15. package/assets/esri/core/workers/chunks/{23e17b745adf71a5efc7.js → aca72ca7f43f70eb8077.js} +1 -1
  16. package/assets/esri/core/workers/chunks/ad0c7225941437d18408.js +1 -0
  17. package/assets/esri/core/workers/chunks/b30897952494a3e5b9fe.js +1 -0
  18. package/assets/esri/core/workers/chunks/bfd3d81e8e148be99686.js +1 -0
  19. package/assets/esri/libs/lyr3d/lyr3DMain.wasm +0 -0
  20. package/assets/esri/libs/lyr3d/lyr3DWorker.wasm +0 -0
  21. package/assets/esri/themes/base/widgets/_Editor.scss +2 -1
  22. package/assets/esri/themes/base/widgets/_FeatureForm.scss +1 -1
  23. package/assets/esri/themes/dark/main.css +1 -1
  24. package/assets/esri/themes/light/main.css +1 -1
  25. package/assets/esri/themes/light/view.css +1 -1
  26. package/chunks/GaussianSplat.glsl.js +2 -2
  27. package/chunks/lyr3DMain.js +1 -1
  28. package/config.js +1 -1
  29. package/graphic/graphicOriginUtils.js +1 -1
  30. package/interfaces.d.ts +66 -26
  31. package/kernel.js +1 -1
  32. package/layers/BingMapsLayer.js +1 -1
  33. package/layers/Lyr3DWasmPerSceneView.js +1 -1
  34. package/layers/support/attributionUtils.js +5 -0
  35. package/layers/support/fieldConfigUtils.js +1 -1
  36. package/layers/support/fieldFormatUtils.js +1 -1
  37. package/layers/video/VideoController.js +1 -1
  38. package/libs/parquet/parquet.js +1 -1
  39. package/package.json +1 -1
  40. package/support/revision.js +1 -1
  41. package/symbols/cim/SDFHelper.js +1 -1
  42. package/symbols/cim/cimAnalyzer.js +1 -1
  43. package/views/2d/analysis/ElevationProfile/ElevationProfileLineVisualization2D.js +1 -1
  44. package/views/2d/engine/flow/dataUtils.js +1 -1
  45. package/views/2d/engine/webgl/TextureManager.js +1 -1
  46. package/views/2d/engine/webgl/shaderGraph/techniques/animated/AAnimatedPolyShader.js +1 -1
  47. package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedFillShader.js +1 -1
  48. package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedLineShader.js +1 -1
  49. package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedPolyMeshWriters.js +1 -1
  50. package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedTechnique.js +1 -1
  51. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/LineShader.js +1 -1
  52. package/views/2d/layers/features/Processor.js +1 -1
  53. package/views/2d/layers/features/processor/BinningStrategy.js +1 -1
  54. package/views/2d/layers/features/processor/ClusterStrategy.js +1 -1
  55. package/views/2d/layers/features/processor/TrackStrategy.js +1 -1
  56. package/views/2d/layers/features/support/FeatureMetadata.js +1 -1
  57. package/views/3d/analysis/ElevationProfile/ElevationProfileGeometryVisualization3D.js +1 -1
  58. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillComputation.js +1 -1
  59. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementTool.js +1 -1
  60. package/views/3d/environment/ChapmanAtmosphereTechnique.js +1 -1
  61. package/views/3d/environment/CloudsCompositionTechnique.js +1 -1
  62. package/views/3d/environment/CloudsTechnique.js +1 -1
  63. package/views/3d/environment/FogTechnique.js +1 -1
  64. package/views/3d/environment/NoiseTextureAtlasTechnique.js +1 -1
  65. package/views/3d/environment/PrecipitationTechnique.js +1 -1
  66. package/views/3d/environment/SimpleAtmosphereTechnique.js +1 -1
  67. package/views/3d/layers/FlowSubView3D.js +1 -1
  68. package/views/3d/layers/ImageryTileLayerView3D.js +1 -1
  69. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  70. package/views/3d/layers/TiledLayerView3D.js +1 -1
  71. package/views/3d/layers/graphics/defaultSymbolComplexity.js +1 -1
  72. package/views/3d/support/DisplayQualityProfile.js +1 -1
  73. package/views/3d/support/QualitySettings.js +1 -1
  74. package/views/3d/support/flow/FlowSubViewTiles3D.js +1 -1
  75. package/views/3d/support/flow/FlowWorker.js +1 -1
  76. package/views/3d/support/flow/FlowWorkerHandle.js +1 -1
  77. package/views/3d/support/flow/StreamlineResources3D.js +1 -1
  78. package/views/3d/support/flow/StreamlineResources3DOverlay.js +1 -1
  79. package/views/3d/support/flow/StreamlineResources3DShape.js +1 -1
  80. package/views/3d/support/flow/constants.js +1 -1
  81. package/views/3d/support/flow/loadUtils.js +1 -1
  82. package/views/3d/support/popupHitTest.js +1 -1
  83. package/views/3d/terrain/BlendLayersTechnique.js +1 -1
  84. package/views/3d/terrain/RasterColorizerTechnique.js +1 -1
  85. package/views/3d/terrain/TerrainSurface.js +1 -1
  86. package/views/3d/terrain/TileAgent.js +1 -1
  87. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechnique.js +1 -1
  88. package/views/3d/webgl-engine/core/shaderTechnique/{ReloadableShaderModule.js → ReloadableShader.js} +1 -1
  89. package/views/3d/webgl-engine/core/shaderTechnique/ShaderTechnique.js +1 -1
  90. package/views/3d/webgl-engine/effects/focusArea/FocusAreaColorTechnique.js +1 -1
  91. package/views/3d/webgl-engine/effects/focusArea/FocusAreaMaskTechnique.js +1 -1
  92. package/views/3d/webgl-engine/effects/glow/GlowBlurTechnique.js +1 -1
  93. package/views/3d/webgl-engine/effects/glow/GlowCompositionTechnique.js +1 -1
  94. package/views/3d/webgl-engine/effects/haze/HazeCompositingTechnique.js +1 -1
  95. package/views/3d/webgl-engine/effects/haze/HazeTechnique.js +1 -1
  96. package/views/3d/webgl-engine/effects/highlight/HighlightApplyTechnique.js +1 -1
  97. package/views/3d/webgl-engine/effects/highlight/HighlightBlurTechnique.js +1 -1
  98. package/views/3d/webgl-engine/effects/highlight/HighlightDownsampleTechnique.js +1 -1
  99. package/views/3d/webgl-engine/effects/highlight/HighlightToSingleTechnique.js +1 -1
  100. package/views/3d/webgl-engine/effects/highlight/ShadowHighlightTechnique.js +1 -1
  101. package/views/3d/webgl-engine/effects/laserlines/LaserlinePathTechnique.js +1 -1
  102. package/views/3d/webgl-engine/effects/laserlines/LaserlineTechnique.js +1 -1
  103. package/views/3d/webgl-engine/effects/magnifier/MagnifierTechnique.js +1 -1
  104. package/views/3d/webgl-engine/effects/smaa/SMAABlendWeightsTechnique.js +1 -1
  105. package/views/3d/webgl-engine/effects/smaa/SMAABlurTechnique.js +1 -1
  106. package/views/3d/webgl-engine/effects/smaa/SMAAEdgeDetectTechnique.js +1 -1
  107. package/views/3d/webgl-engine/effects/ssao/SSAOBlurTechnique.js +1 -1
  108. package/views/3d/webgl-engine/effects/ssao/SSAOTechnique.js +1 -1
  109. package/views/3d/webgl-engine/effects/stars/StarsTechnique.js +1 -1
  110. package/views/3d/webgl-engine/effects/transparency/OITBlendTechnique.js +1 -1
  111. package/views/3d/webgl-engine/lib/GaussianSplatRenderNode.js +1 -1
  112. package/views/3d/webgl-engine/lib/Program.js +1 -1
  113. package/views/3d/webgl-engine/lib/RenderingContext.js +1 -1
  114. package/views/3d/webgl-engine/lib/TextureTechnique.js +1 -1
  115. package/views/3d/webgl-engine/lib/edgeRendering/EdgeShaderTechnique.js +1 -1
  116. package/views/3d/webgl-engine/materials/PathTechnique.js +1 -1
  117. package/views/3d/webgl-engine/materials/WaterTechnique.js +1 -1
  118. package/views/3d/webgl-engine/shaders/AtmosphereCompositingTechnique.js +1 -1
  119. package/views/3d/webgl-engine/shaders/CheckerBoardTechnique.js +1 -1
  120. package/views/3d/webgl-engine/shaders/ColorMaterialTechnique.js +1 -1
  121. package/views/3d/webgl-engine/shaders/CompositingTechnique.js +1 -1
  122. package/views/3d/webgl-engine/shaders/CutFillCompositionTechnique.js +1 -1
  123. package/views/3d/webgl-engine/shaders/CutFillDepthTechnique.js +1 -1
  124. package/views/3d/webgl-engine/shaders/CutFillMaskTechnique.js +1 -1
  125. package/views/3d/webgl-engine/shaders/CutFillReductionTechnique.js +1 -1
  126. package/views/3d/webgl-engine/shaders/CutFillTargetDepthTechnique.js +1 -1
  127. package/views/3d/webgl-engine/shaders/DefaultMaterialTechnique.js +1 -1
  128. package/views/3d/webgl-engine/shaders/GaussianSplat.glsl.js +1 -1
  129. package/views/3d/webgl-engine/shaders/GaussianSplatCompositionTechnique.js +1 -1
  130. package/views/3d/webgl-engine/shaders/GaussianSplatDepthCompositionTechnique.js +1 -1
  131. package/views/3d/webgl-engine/shaders/GaussianSplatDepthTechnique.js +1 -1
  132. package/views/3d/webgl-engine/shaders/GaussianSplatTechnique.js +1 -1
  133. package/views/3d/webgl-engine/shaders/GaussianSplatTechniqueConfiguration.js +1 -1
  134. package/views/3d/webgl-engine/shaders/HUDCompositingTechnique.js +1 -1
  135. package/views/3d/webgl-engine/shaders/HUDMaterialTechnique.js +1 -1
  136. package/views/3d/webgl-engine/shaders/HeatmapDensityTechnique.js +1 -1
  137. package/views/3d/webgl-engine/shaders/HeatmapTechnique.js +1 -1
  138. package/views/3d/webgl-engine/shaders/ImageMaterialTechnique.js +1 -1
  139. package/views/3d/webgl-engine/shaders/LineCalloutTechnique.js +1 -1
  140. package/views/3d/webgl-engine/shaders/LineMarkerTechnique.js +1 -1
  141. package/views/3d/webgl-engine/shaders/MeasurementArrowTechnique.js +1 -1
  142. package/views/3d/webgl-engine/shaders/NativeLineTechnique.js +1 -1
  143. package/views/3d/webgl-engine/shaders/OverlayCompositingTechnique.js +1 -1
  144. package/views/3d/webgl-engine/shaders/PatternTechnique.js +1 -1
  145. package/views/3d/webgl-engine/shaders/PointRendererTechnique.js +1 -1
  146. package/views/3d/webgl-engine/shaders/RealisticTreeTechnique.js +1 -1
  147. package/views/3d/webgl-engine/shaders/RibbonLineTechnique.js +1 -1
  148. package/views/3d/webgl-engine/shaders/ShadedColorMaterialTechnique.js +1 -1
  149. package/views/3d/webgl-engine/shaders/ShadowCastAccumulateTechnique.js +1 -1
  150. package/views/3d/webgl-engine/shaders/ShadowCastClearTechnique.js +1 -1
  151. package/views/3d/webgl-engine/shaders/ShadowCastVisualizeTechnique.js +1 -1
  152. package/views/3d/webgl-engine/shaders/SlicePlaneMaterialTechnique.js +1 -1
  153. package/views/3d/webgl-engine/shaders/TerrainTechnique.js +1 -1
  154. package/views/3d/webgl-engine/shaders/ViewshedTechnique.js +1 -1
  155. package/views/SceneView.js +1 -1
  156. package/views/analysis/ElevationProfile/ElevationProfileTool.js +1 -1
  157. package/views/analysis/ElevationProfile/types.d.ts +5 -0
  158. package/views/analysis/ElevationProfile/types.js +5 -0
  159. package/views/webgl/VertexAttributeLocations.js +1 -1
  160. package/widgets/Attribution/AttributionViewModel.js +1 -1
  161. package/widgets/Editor/MergeFeaturesWorkflow.js +1 -1
  162. package/widgets/Editor/SplitFeatureWorkflow.js +1 -1
  163. package/widgets/Editor/UpdateWorkflow.js +1 -1
  164. package/widgets/Editor/Workflow.js +1 -1
  165. package/widgets/Editor/components/CreateFeaturesPanelContent.js +1 -1
  166. package/widgets/Editor/components/PendingFeatureList.js +1 -1
  167. package/widgets/Editor/components/UpdateFeaturePanelContent.js +1 -1
  168. package/widgets/Editor.js +1 -1
  169. package/widgets/Feature/support/featureUtils.js +1 -1
  170. package/widgets/FeatureTable/FieldColumn.js +1 -1
  171. package/widgets/FeatureTable/Grid/Column.js +1 -1
  172. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  173. package/widgets/OrientedImageryViewer/adapters/view/MapViewAdapter.js +1 -1
  174. package/widgets/OrientedImageryViewer/adapters/view/SceneViewAdapter.js +1 -1
  175. package/widgets/OrientedImageryViewer/components/OrientedImageryVideoViewModel.js +1 -1
  176. package/assets/esri/core/workers/chunks/38ee69125da60464d5a1.js +0 -1
  177. package/assets/esri/core/workers/chunks/4f0016111fd84c612f41.js +0 -1
  178. package/assets/esri/core/workers/chunks/8208dfa8f7fae7e616b9.js +0 -1
  179. package/assets/esri/core/workers/chunks/847f4fc39100fac1df01.js +0 -1
  180. package/assets/esri/core/workers/chunks/ab005fe84952f0676020.js +0 -1
  181. package/assets/esri/core/workers/chunks/bc19a232076d98825eef.js +0 -1
  182. package/assets/esri/core/workers/chunks/c3dcfe26c2c3c829762d.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/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,destroyHandle as a}from"../../core/handleUtils.js";import"../../core/has.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,initial as d}from"../../core/reactiveUtils.js";import{property as u}from"../../core/accessorSupport/decorators/property.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import h from"../../layers/GraphicsLayer.js";import{getDrawHelpMessage as m}from"../../views/draw/support/helpMessageUtils.js";import w from"../../views/draw/support/HighlightHelper.js";import y from"../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{temporaryHighlightName as g}from"../../views/support/HighlightDefaults.js";import f from"./Edits.js";import v from"./SplitFeatureWorkflowData.js";import _ from"./Workflow.js";import{createWorkflowSteps as F,swapForEditingSession as M,updateGraphicSymbolWhenRequired as b,makeMinimalAttributes as S}from"./workflowUtils.js";import{assertViewNot3D as k,assertSplitWorkflowCapabilities as T}from"./support/errors.js";import{getCompatibleSpitterGeometryType as V,ensureSplittableGeometry as G,makeNewFeatureAttributes as I,splitGeometry as E,canSplitByPoint as H,isSplitterGeometry as j}from"./support/splitFeatureUtils.js";import x from"../FeatureForm/FeatureFormViewModel.js";import C from"../Sketch/SketchViewModel.js";var L;const W=Symbol(),U=Symbol();let P=L=class extends _{constructor(e){super(e),this.defaultSplitterGeometryType=null,this.type="split-feature",this._activeFeature=null,this._formViewModel=null,this._graphicsLayer=null,this._highlightHelper=null,this._lastSplitterGeometryWasInvalid=!1,this._sketchViewModel=null,this._webStyleCache=new Map}initialize(){const e=this.data.viewModel.view;this._highlightHelper=e?new w({view:e,highlightName:g}):null,this._initializeFormViewModel();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 activeFeature(){return this._activeFeature}get allowSave(){const{data:e}=this;return null!=e.existingFeatureEdits&&null!=e.newFeatureEdits&&!this.updating}get availableCreateTools(){const e=["polyline","polygon","rectangle","circle","freehandPolyline","freehandPolygon"];switch(this.data.editorItem.layer.geometryType){case"polygon":case"multipoint":return e;case"polyline":return["point",...e];default:return[]}}get formViewModel(){return this._formViewModel}get hasInvalidFormTemplate(){return!!this.data.editorItem?.hasInvalidFormTemplate}get hasPreviousStep(){return null!==this._activeFeature||this._stepIndex>0}get helpMessage(){if(this._lastSplitterGeometryWasInvalid)return"invalidSplitterGeometry";const{activeCreateToolDrawMode:e,activeTool:t,createGraphic:i}=this._sketchViewModel,r="rectangle"===t||"circle"===t?t:this.data.editorItem.layer.geometryType;return"mesh"!==r?m(r,i?.geometry,e):void 0}get layer(){return this.data.editorItem.layer}get parent(){return this.data.parent}get updating(){return this._updatingHandles.updating||this._formViewModel.updating||this._sketchViewModel.updating}async back(e){return this.activeFeature?await this.setActiveFeature(null):await super.back(e)}static create(e){const{applyEdits:i,applyEditsFeatureService:r,defaultSplitterGeometryType:a,startAt:o,...s}=e;if(k(e.viewModel,"split-feature"),T(s.editorItem),"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=V(G(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 L({data:new v(s),defaultSplitterGeometryType:a,onCommit:A(e.applyEdits)});return l._set("steps",L._createWorkflowSteps(l,o)),l}async enter(){}exit(){if("reviewing-features"!==this.stepId)throw new t("editing:invalid-exit-state","The SplitFeatureWorkflow can only be exited when in the 'reviewing-features' step.")}async setActiveFeature(e){const i=this._activeFeature;if(e===i)return;const r=this.data,a=i?r.getEditsForFeature(i):null;if(a&&(a.submittable=this._formViewModel.submittable),this._activeFeature=e,null==e)return;const o=this.data.getRoleForFeature(e);if(!o)throw new t("editing:unknown-feature","The provided feature is not part of this workflow.");await this._setFeatureOnFormViewModel(e,o)}async start(){return await super.start(),this._makeSketchController()}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 f({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=I(r.attributes,i.editorItem.layer);const n=new f({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-splitter-geometry"){const{data:r}=e;return F(["drawing-splitter-geometry","reviewing-features"],i,{"drawing-splitter-geometry":()=>({id:"drawing-splitter-geometry",async setUp(){const i=G(r.originalFeature.geometry),a=V(i,e.defaultSplitterGeometryType),{snappingManager:o}=r;H(i)&&o&&e.addHandles(O(o,e.layer));const s=e._sketchViewModel;e.addHandles([n(()=>s,"create",async i=>{if("start"===i.state&&e._lastSplitterGeometryWasInvalid&&(e._lastSplitterGeometryWasInvalid=!1),"complete"===i.state){e._graphicsLayer.removeAll();const o=i.graphic?.geometry;try{if(!j(o))throw new t("editing:invalid-split-geometry","The geometry produced by the Sketch operation cannot be used for splitting.");r.splitterGeometry=o,r.splitResult=await e._updatingHandles.addPromise(e._executeSplit(o)),await e.next()}catch(a){e._lastSplitterGeometryWasInvalid=!0,await s.create(i.tool)}}}),l(()=>s.activeTool,(t,i)=>{"point"===t&&!e.hasHandles(W)&&o?e.addHandles(R(o,e.layer),W):"point"===i&&e.removeHandles(W)})],this.id),await s.create(a)},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=r.splitResult??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.removeHandles(this.id)}})})}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([b(e,this._webStyleCache,i),b(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 M(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 E(a,e);if(!o||!o.newPart)throw new t("editing:split-failed","The split operation did not produce a valid result.");return o}_initializeFormViewModel(){const{data:e,_webStyleCache:t}=this,i=e.viewModel.view,r=new x({formTemplate:e.editorItem.formTemplate,highlightHelper:this._highlightHelper,map:i?.map,spatialReference:i?.spatialReference,timeZone:e.timeZone});this._formViewModel=r,this.addHandles(n(()=>r,"value-change",({feature:r,fieldName:a,value:o})=>{r&&(e.getEditsForFeature(r)?.setAttribute(a,o),b(r,t,i?.scale))}))}_initializeGraphicsLayer(){const{data:e}=this,{view:t}=e.viewModel,i=new h({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 C({layer:e,creationMode:"single",sketchOptions:t.sketchOptions,snappingManager:t.snappingManager,updateOnGraphicClick:!1,defaultUpdateOptions:{multipleSelectionEnabled:!1},view:i})}_makeSketchController(){return{enter:async()=>this.addHandles(D(this)),exit:()=>this.removeHandles(U),viewModel:this._sketchViewModel}}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([u()],P.prototype,"activeFeature",null),e([u()],P.prototype,"allowSave",null),e([u()],P.prototype,"availableCreateTools",null),e([u()],P.prototype,"defaultSplitterGeometryType",void 0),e([u()],P.prototype,"formViewModel",null),e([u()],P.prototype,"hasInvalidFormTemplate",null),e([u()],P.prototype,"hasPreviousStep",null),e([u()],P.prototype,"helpMessage",null),e([u()],P.prototype,"layer",null),e([u()],P.prototype,"parent",null),e([u()],P.prototype,"type",void 0),e([u()],P.prototype,"updating",null),e([u()],P.prototype,"_activeFeature",void 0),e([u()],P.prototype,"_formViewModel",void 0),e([u()],P.prototype,"_graphicsLayer",void 0),e([u()],P.prototype,"_highlightHelper",void 0),e([u()],P.prototype,"_lastSplitterGeometryWasInvalid",void 0),e([u()],P.prototype,"_sketchViewModel",void 0),P=L=e([c("esri.widgets.Editor.SplitFeatureWorkflow")],P);const z=P;function A(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=S(o,i.editorItem.layer)),await e(l,{addFeatures:[s],updateFeatures:[o]})}}function O(e,t){if(e.options.featureSources.some(e=>e.layer===t))return i();const r=new y({enabled:!1,layer:t});return e.options.featureSources.add(r),i(()=>{e.options.featureSources.remove(r),r.destroy()})}function R(e,t){const{options:r}=e,a=r.enabled;r.enabled=!0;const o=r.featureEnabled;r.featureEnabled=!0;const s=r.distance;r.distance=15;const l=new Map;for(const i of r.featureSources)l.set(i,i.enabled),i.layer===t?i.enabled=!0:i.enabled=!1;return i(()=>{r.enabled=a,r.featureEnabled=o,r.distance=s;for(const[e,t]of l)e.enabled=t})}function D(e){const t=e.data,{originalFeature:o,viewModel:s}=t,{view:n}=s;if(!n)return i();const p=new w({view:n}),u=l(()=>e.stepId,e=>{switch(p.removeAll(),e){case"drawing-splitter-geometry":p.add(o);break;case"reviewing-features":p.add(t.existingFeatureEdits?.feature),p.add(t.newFeatureEdits?.feature)}},d),c=new w({view:n,highlightName:g}),h=l(()=>t.temporaryHighlightFeature,(t,i)=>{i&&i!==e.activeFeature&&c.remove(i),t&&c.add(t)}),m=l(()=>e.activeFeature,(e,i)=>{i&&i!==t.temporaryHighlightFeature&&c.remove(i),e&&c.add(e)});return r([u,h,m,a(p),a(c)])}export{z as default};
5
+ import{__decorate as e}from"tslib";import t from"../../core/Error.js";import{makeHandle as i,handlesGroup as r,destroyHandle as a}from"../../core/handleUtils.js";import"../../core/has.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,initial as d}from"../../core/reactiveUtils.js";import{property as u}from"../../core/accessorSupport/decorators/property.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import h from"../../layers/GraphicsLayer.js";import{getDrawHelpMessage as m}from"../../views/draw/support/helpMessageUtils.js";import w from"../../views/draw/support/HighlightHelper.js";import y from"../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{temporaryHighlightName as g}from"../../views/support/HighlightDefaults.js";import f from"./Edits.js";import v from"./SplitFeatureWorkflowData.js";import _ from"./Workflow.js";import{createWorkflowSteps as F,swapForEditingSession as M,updateGraphicSymbolWhenRequired as S,makeMinimalAttributes as b}from"./workflowUtils.js";import{assertViewNot3D as k,assertSplitWorkflowCapabilities as T}from"./support/errors.js";import{getCompatibleSpitterGeometryType as V,ensureSplittableGeometry as G,makeNewFeatureAttributes as I,splitGeometry as E,canSplitByPoint as j,isSplitterGeometry as H}from"./support/splitFeatureUtils.js";import x from"../FeatureForm/FeatureFormViewModel.js";import C from"../Sketch/SketchViewModel.js";import{getDrawToolGeometryTypeFromCreateTool as L}from"../Sketch/support/sketchUtils.js";var U;const W=Symbol(),P=Symbol();let z=U=class extends _{constructor(e){super(e),this.defaultSplitterGeometryType=null,this.type="split-feature",this._activeFeature=null,this._formViewModel=null,this._graphicsLayer=null,this._highlightHelper=null,this._lastSplitterGeometryWasInvalid=!1,this._sketchViewModel=null,this._webStyleCache=new Map}initialize(){const e=this.data.viewModel.view;this._highlightHelper=e?new w({view:e,highlightName:g}):null,this._initializeFormViewModel();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 activeFeature(){return this._activeFeature}get allowSave(){const{data:e}=this;return null!=e.existingFeatureEdits&&null!=e.newFeatureEdits&&!this.updating}get availableCreateTools(){const e=["polyline","polygon","rectangle","circle","freehandPolyline","freehandPolygon"];switch(this.data.editorItem.layer.geometryType){case"polygon":case"multipoint":return e;case"polyline":return["point",...e];default:return[]}}get formViewModel(){return this._formViewModel}get hasInvalidFormTemplate(){return!!this.data.editorItem?.hasInvalidFormTemplate}get hasPreviousStep(){return null!==this._activeFeature||this._stepIndex>0}get helpMessage(){const{activeCreateToolDrawMode:e,activeTool:t,createGraphic:i}=this._sketchViewModel,r=L(t);if("mesh"!==r)return m(r,i?.geometry,e)}get layer(){return this.data.editorItem.layer}get parent(){return this.data.parent}get updating(){return this._updatingHandles.updating||this._formViewModel.updating||this._sketchViewModel.updating}get noticeMessage(){return this._lastSplitterGeometryWasInvalid?"invalidSplitterGeometry":void 0}async back(e){return this.activeFeature?await this.setActiveFeature(null):await super.back(e)}static create(e){const{applyEdits:i,applyEditsFeatureService:r,defaultSplitterGeometryType:a,startAt:o,...s}=e;if(k(e.viewModel,"split-feature"),T(s.editorItem),"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=V(G(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 U({data:new v(s),defaultSplitterGeometryType:a,onCommit:O(e.applyEdits)});return l._set("steps",U._createWorkflowSteps(l,o)),l}async enter(){}exit(){if("reviewing-features"!==this.stepId)throw new t("editing:invalid-exit-state","The SplitFeatureWorkflow can only be exited when in the 'reviewing-features' step.")}async setActiveFeature(e){const i=this._activeFeature;if(e===i)return;const r=this.data,a=i?r.getEditsForFeature(i):null;if(a&&(a.submittable=this._formViewModel.submittable),this._activeFeature=e,null==e)return;const o=this.data.getRoleForFeature(e);if(!o)throw new t("editing:unknown-feature","The provided feature is not part of this workflow.");await this._setFeatureOnFormViewModel(e,o)}async start(){return await super.start(),this._makeSketchController()}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 f({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=I(r.attributes,i.editorItem.layer);const n=new f({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-splitter-geometry"){const{data:r}=e;return F(["drawing-splitter-geometry","reviewing-features"],i,{"drawing-splitter-geometry":()=>({id:"drawing-splitter-geometry",async setUp(){const i=G(r.originalFeature.geometry),a=V(i,e.defaultSplitterGeometryType),{snappingManager:o}=r;j(i)&&o&&e.addHandles(R(o,e.layer));const s=e._sketchViewModel;e.addHandles([n(()=>s,"create",async i=>{if("start"===i.state&&e._lastSplitterGeometryWasInvalid&&(e._lastSplitterGeometryWasInvalid=!1),"complete"===i.state){e._graphicsLayer.removeAll();const o=i.graphic?.geometry;try{if(!H(o))throw new t("editing:invalid-split-geometry","The geometry produced by the Sketch operation cannot be used for splitting.");r.splitterGeometry=o,r.splitResult=await e._updatingHandles.addPromise(e._executeSplit(o)),await e.next()}catch(a){e._lastSplitterGeometryWasInvalid=!0,await s.create(i.tool)}}}),l(()=>s.activeTool,(t,i)=>{"point"===t&&!e.hasHandles(W)&&o?e.addHandles(D(o,e.layer),W):"point"===i&&e.removeHandles(W)})],this.id),await s.create(a)},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=r.splitResult??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.removeHandles(this.id)}})})}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([S(e,this._webStyleCache,i),S(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 M(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 E(a,e);if(!o||!o.newPart)throw new t("editing:split-failed","The split operation did not produce a valid result.");return o}_initializeFormViewModel(){const{data:e,_webStyleCache:t}=this,i=e.viewModel.view,r=new x({formTemplate:e.editorItem.formTemplate,highlightHelper:this._highlightHelper,map:i?.map,spatialReference:i?.spatialReference,timeZone:e.timeZone});this._formViewModel=r,this.addHandles(n(()=>r,"value-change",({feature:r,fieldName:a,value:o})=>{r&&(e.getEditsForFeature(r)?.setAttribute(a,o),S(r,t,i?.scale))}))}_initializeGraphicsLayer(){const{data:e}=this,{view:t}=e.viewModel,i=new h({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 C({layer:e,creationMode:"single",sketchOptions:t.sketchOptions,snappingManager:t.snappingManager,updateOnGraphicClick:!1,defaultUpdateOptions:{multipleSelectionEnabled:!1},view:i})}_makeSketchController(){return{enter:async()=>this.addHandles(N(this)),exit:()=>this.removeHandles(P),viewModel:this._sketchViewModel}}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([u()],z.prototype,"activeFeature",null),e([u()],z.prototype,"allowSave",null),e([u()],z.prototype,"availableCreateTools",null),e([u()],z.prototype,"defaultSplitterGeometryType",void 0),e([u()],z.prototype,"formViewModel",null),e([u()],z.prototype,"hasInvalidFormTemplate",null),e([u()],z.prototype,"hasPreviousStep",null),e([u()],z.prototype,"helpMessage",null),e([u()],z.prototype,"layer",null),e([u()],z.prototype,"parent",null),e([u()],z.prototype,"type",void 0),e([u()],z.prototype,"updating",null),e([u()],z.prototype,"noticeMessage",null),e([u()],z.prototype,"_activeFeature",void 0),e([u()],z.prototype,"_formViewModel",void 0),e([u()],z.prototype,"_graphicsLayer",void 0),e([u()],z.prototype,"_highlightHelper",void 0),e([u()],z.prototype,"_lastSplitterGeometryWasInvalid",void 0),e([u()],z.prototype,"_sketchViewModel",void 0),z=U=e([c("esri.widgets.Editor.SplitFeatureWorkflow")],z);const A=z;function O(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=b(o,i.editorItem.layer)),await e(l,{addFeatures:[s],updateFeatures:[o]})}}function R(e,t){if(e.options.featureSources.some(e=>e.layer===t))return i();const r=new y({enabled:!1,layer:t});return e.options.featureSources.add(r),i(()=>{e.options.featureSources.remove(r),r.destroy()})}function D(e,t){const{options:r}=e,a=r.enabled;r.enabled=!0;const o=r.featureEnabled;r.featureEnabled=!0;const s=r.distance;r.distance=15;const l=new Map;for(const i of r.featureSources)l.set(i,i.enabled),i.layer===t?i.enabled=!0:i.enabled=!1;return i(()=>{r.enabled=a,r.featureEnabled=o,r.distance=s;for(const[e,t]of l)e.enabled=t})}function N(e){const t=e.data,{originalFeature:o,viewModel:s}=t,{view:n}=s;if(!n)return i();const p=new w({view:n}),u=l(()=>e.stepId,e=>{switch(p.removeAll(),e){case"drawing-splitter-geometry":p.add(o);break;case"reviewing-features":p.add(t.existingFeatureEdits?.feature),p.add(t.newFeatureEdits?.feature)}},d),c=new w({view:n,highlightName:g}),h=l(()=>t.temporaryHighlightFeature,(t,i)=>{i&&i!==e.activeFeature&&c.remove(i),t&&c.add(t)}),m=l(()=>e.activeFeature,(e,i)=>{i&&i!==t.temporaryHighlightFeature&&c.remove(i),e&&c.add(e)});return r([u,h,m,a(p),a(c)])}export{A as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{remove as i}from"../../core/arrayUtils.js";import a from"../../core/Error.js";import{makeHandle as o}from"../../core/handleUtils.js";import r from"../../core/Logger.js";import{abortMaybe as s}from"../../core/maybe.js";import{createResolver as n,debounce as l,onAbort as d,createAbortError as c,throwIfAborted as p}from"../../core/promiseUtils.js";import u from"../../core/Queue.js";import{whenOnce as w,watch as h,sync as f,on as g,when as v}from"../../core/reactiveUtils.js";import{last as k}from"../../core/SetUtils.js";import{property as m}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as y}from"../../core/accessorSupport/decorators/subclass.js";import{getGraphicLayer as W}from"../../graphic/graphicOriginUtils.js";import{isEditableLayer as A}from"../../layers/support/editableLayers.js";import{isFeatureLayer as _,isSubtypeSublayer as b,isSubtypeGroupLayer as S,isTable as C}from"../../layers/support/layerUtils.js";import{createFeatureServices as M}from"../../rest/featureService/utils.js";import F from"../../views/draw/support/HighlightHelper.js";import{ViewEventPriorities as E}from"../../views/input/InputManager.js";import{temporaryHighlightName as U}from"../../views/support/HighlightDefaults.js";import I from"./CreateFeaturesWorkflow.js";import R from"./MergeFeaturesWorkflow.js";import j from"./SplitFeatureWorkflow.js";import V from"./UpdateFeaturesWorkflow.js";import{UpdateFeatureWorkflow as P}from"./UpdateFeatureWorkflow.js";import{UpdateRecordWorkflow as L}from"./UpdateRecordWorkflow.js";import N from"./UpdateWorkflowData.js";import O from"./Workflow.js";import{isFeatureFormViewModel as T,findEditorItemForLayer as x,isSplitFeatureWorkflow as H,workflowInfluencesOutcomeOfParent as D,isAnyUpdateLeafWorkflow as q,isUpdateRecordWorkflow as z,isParentWorkflow as G,findEditorItemForLayerOrThrow as Q,createWorkflowSteps as $,fetchCandidates as B,isUpdateFeaturesWorkflowOptions as J,toFeatureInfos as K,isMergeWorkflowOptions as X,isSplitWorkflowOptions as Y}from"./workflowUtils.js";import{assertFeaturesAreFromSameLayer as Z}from"./support/errors.js";import{findUtilityNetwork as ee,isGraphicForRelatableFeatureSupportedLayer as te}from"../Feature/support/featureUtils.js";var ie;let ae=ie=class extends O{constructor(e){super(e),this._workflowStack=new u(k),this._sketchStack=new u(k),this.data=void 0,this.type="update"}destroy(){this._drainWorkflowStack(e=>e.cancel({force:!0}))}get formViewModel(){return this.activeWorkflow?.formViewModel}get activeUtilityNetworkAssociationAddAssociationViewModel(){return"add-association"===this.activeWorkflow?.type?this.activeWorkflow.utilityNetworkAssociationAddAssociationViewModel:null}get activeSketchViewModel(){return this._sketchStack.peek()?.viewModel}get canDeleteAssociation(){const{formViewModel:e}=this;if(!this.activeWorkflow||!this.data.viewModel.view?.map||!T(e))return!1;const{activeAssociation:t,feature:i}=e;return!(!t||!i?.sourceLayer||!_(i?.sourceLayer)&&!b(i?.sourceLayer))}get activeWorkflow(){return this._workflowStack.last()}get updating(){return this._updatingHandles.updating||!!this.activeWorkflow?.updating}get hasPreviousStep(){const e=this.activeWorkflow?.formViewModel;return this._stepIndex>0||this.nestedWorkflowCount>1||this.activeWorkflow?.hasPreviousStep||"view"!==this.data.viewModel.attachmentsViewModel.mode||T(e)&&(null!=e.relationshipId||null!=e.associationId||null!=e.associatedLayer)}get hasUpdatableCandidates(){const{candidates:e,viewModel:t}=this.data;return e.some(({layer:e})=>x(t.editorItems,e)?.supportsUpdateWorkflow)}get nestedWorkflowCount(){return this._workflowStack.length}get shouldShowAttachments(){return this.activeWorkflow?.shouldShowAttachments??!1}get shouldAllowAttachmentEditing(){return this.activeWorkflow?.shouldAllowAttachmentEditing??!1}get hasPendingEdits(){return Array.from(this._workflowStack).some(e=>e.hasPendingEdits)}get helpMessage(){return this.activeWorkflow?.helpMessage?this.activeWorkflow.helpMessage:"awaiting-feature-to-update"===this.stepId?"select":void 0}get reliesOnOwnerAdminPrivileges(){return this.activeWorkflow?.reliesOnOwnerAdminPrivileges??!1}get hasInvalidFormTemplate(){return this.activeWorkflow?.hasInvalidFormTemplate??!1}async back(e=()=>Promise.resolve(!0)){const{activeWorkflow:t}=this,i=t?.formViewModel;if(T(i)){if(i?.activeRelationshipInput){const e=i.activeRelationshipInput;if(e.activeCategory)return void(e.activeCategory=null);if(null!=i.relationshipId)return void(i.relationshipId=null);if(e.showAllEnabled)return void(e.showAllEnabled=!1)}if("add-association"===t?.type){const{activeUtilityNetworkAssociationAddAssociationViewModel:e}=this;if(e?.filterOptionsVisible)return void(e.filterOptionsVisible=!1);e?.featureSpatialItems.length&&e.reset()}if(null!=i?.associatedLayer)return void(i.associatedLayer=null);if(null!=i?.associationId)return void(i.associationId=null)}if("create-features"===t?.type&&t.hasPreviousStep)await t.previous({cancelCurrentStep:!0});else{if(H(t)&&t.hasPreviousStep)return await t.back();if(t){if(t.hasPendingEdits){if(!await e())return}t.hasPreviousStep?await t.previous({cancelCurrentStep:!0}):await this.cancelActiveWorkflow({force:!0})}else this.hasPreviousStep?await this.previous({cancelCurrentStep:!0}):await this.cancel({force:!0})}}async cancelActiveWorkflow(e){await(this.activeWorkflow?.cancel(e)),await this._popWorkflowAndReconcile()}async commit(){await this._drainWorkflowStack(e=>e.commit()),await super.commit()}static create(e){const{startAt:t,applyEdits:i,applyEditsFeatureService:a,...o}=e,r=new ie({data:new N({applyEditsCallback:i,applyEditsFeatureServiceCallback:a,...o}),onCommit:async()=>{}});return r._set("steps",this._createWorkflowSteps(r,t)),r}async save(){const{formViewModel:e}=this;if(e&&(e.submit(),!e.submittable||T(e)&&re(e)))return;if(this.nestedWorkflowCount<2)return await this.commit();const{activeWorkflow:t}=this;if(await(t?.commit()),!D(t))return void await this._popWorkflowAndReconcile();this._popWorkflow();const i=this._workflowStack.peek();if(i&&i===t?.parent&&(await i.cancel(),this._popWorkflow(),0===this.nestedWorkflowCount))return await this.commit();await this._reconcileWorkflowStack()}async startCreatingRelatedRecord(e){const t=this._makeUpdatingResolver();try{const t=this._createNestedCreateFeaturesWorkflow(e);await this._pushWorkflowAndReconcile(t)}catch(i){throw new a("editor:unable-to-start-creating","Could not begin updating the provided feature or table record.",{error:i})}finally{t.resolve()}}async startMergingFeatures(e,t){const i=this._makeUpdatingResolver();try{const i=await this._createNestedMergeFeaturesWorkflow(e,t);await this._pushWorkflowAndReconcile(i)}catch(o){throw new a("editor:unable-to-start-merging","Could not begin merging the provided features.",{error:o})}finally{i.resolve()}}async startSplittingFeature(e,t){const i=this._makeUpdatingResolver();try{const i=await this._createNestedSplitFeatureWorkflow(e,t);await this._pushWorkflowAndReconcile(i)}catch(o){throw new a("editor:unable-to-start-splitting","Could not begin splitting the provided feature.",{error:o})}finally{i.resolve()}}async startUpdatingSingle(e,t){const i=this._makeUpdatingResolver();try{const i=await this._createNestedUpdateWorkflow(e,t);await this._pushWorkflowAndReconcile(i)}catch(o){throw new a("editor:unable-to-start-updating","Could not begin updating the provided feature or table record.",{error:o})}finally{i.resolve()}}async startUpdatingMultiple(e,t){const i=this._makeUpdatingResolver();try{const i=await this._createNestedUpdateFeaturesWorkflow(e,t);await this._pushWorkflowAndReconcile(i)}catch(o){throw new a("editor:unable-to-start-updating","Could not begin updating the provided features or table records.",{error:o})}finally{i.resolve()}}async startAddAssociation(e,t,i){const o=this._makeUpdatingResolver();try{const a=await this._createNestedAddAssociationWorkflow(e,t,i);await this._pushWorkflowAndReconcile(a)}catch(r){throw new a("editor:unable-to-start-updating","Could not begin updating the provided feature or table record.",{error:r})}finally{o.resolve()}}async deleteActiveFeatures(){const{activeWorkflow:e}=this;if(!e)throw new a("editor:nothing-to-delete","There is no feature to delete");const t=q(e);if(t){e.data.stageDelete();const t=z(e)?e.data.edits.feature?[e.data.edits.feature]:[]:e.data.features;this._removeFeaturesFromCandidates(t)}else await e.cancel();this.nestedWorkflowCount<2?t?await this.commit():await this.cancel({force:!0}):(t&&await e.commit(),await this._popWorkflowAndReconcile(),await this._returnToPageWithContent())}async deleteActiveAssociation(){if(!this.canDeleteAssociation)throw new a("editor:nothing-to-delete","There is no association to delete");await this._deleteActiveAssociation(),await this._popWorkflowAndReconcile(),await this._returnToPageWithContent()}async cancelAll(){await this._drainWorkflowStack(e=>e.cancel({force:!0}))}async _deleteActiveAssociation(){const{formViewModel:e}=this;if(!T(e))throw new a("editing:failed-to-delete-association","The active workflow does not support editing associations");const{activeAssociation:t,feature:i}=e,{applyEditsFeatureServiceCallback:o,viewModel:r}=this.data,{sourceLayer:s}=i,n=b(s)&&s.parent?s.parent:s,l=M([n]),d=l.values().next().value?.featureService;if(!d)throw new a("editor:failed-to-delete-association","Could not retrieve feature service needed to delete association");await(d?.load());const c=r.view.map,p=ee(c,n);await(p?.networkSystemLayers.loadAssociationsTable());const u=p?.generateDeleteAssociations([t]);if(!u)throw new a("editor:failed-to-delete-association","Could not create payload needed to delete association");const w=p?.gdbVersion??void 0;await o(d,[u],{gdbVersion:w,globalIdUsed:!0})}_removeFeaturesFromCandidates(e){const{candidates:t}=this.data;if(0!==t.length&&0!==e.length)for(const a of e)i(t,a)}async _returnToPageWithContent(){const{formViewModel:e}=this;if(!T(e)||!e?.activeAssociationInput)return;const{activeAssociationInput:t,associationId:i}=e;await t.refresh(),t.associatedLayer&&!t.associatedFeatures?.length&&(e.associatedLayer=null),null==i||t.associatedFeatureInfos.size||(e.associationId=null)}_createNestedCreateFeaturesWorkflow(e){const{relatedLayer:t}=e,{addAttachmentsCallback:i,applyEditsCallback:o,applyEditsFeatureServiceCallback:r,sketchOptions:s,snappingManager:n,viewModel:l}=this.data;if(!A(t))throw new a("editor:unsupported-layer","Editing is not supported on the provided layer");const d=this._getCreationInfoForNestedCreateFeaturesWorkflow(e),c=d.template||d.initialFeature?"creating-features":"awaiting-feature-creation-info",p=G(this.activeWorkflow)?this.activeWorkflow:void 0;return I.create({addAttachmentsCallback:i,applyEdits:o,applyEditsFeatureService:r,creationInfo:d,isNested:!0,parent:p,sketchOptions:s,snappingManager:n,startAt:c,viewModel:l})}_getCreationInfoForNestedCreateFeaturesWorkflow(e){const{relatedLayer:i}=e;if(!A(i)||S(i))throw new a("editor:unsupported-layer","Editing is not supported on the provided layer");const{viewModel:o}=this.data,r={layer:i,maxFeatures:1},s=this._makeRelatedRecordAttributes(e),n=o.getTemplatesForLayer(i);return n?.length>0?(r.attributeOverrides=s,1===n.length&&(r.template=n[0])):r.initialFeature=new t({sourceLayer:i,attributes:s}),r}async _createNestedUpdateWorkflow(e,t={}){const i=C(e.sourceLayer)?L:P,{applyEditsCallback:a,applyEditsFeatureServiceCallback:o,sketchOptions:r,snappingManager:s,viewModel:n}=this.data,l=G(this.activeWorkflow)?this.activeWorkflow:void 0,d=await i.create({feature:e,parent:l,sketchOptions:r,snappingManager:s,viewModel:n,applyEdits:a,applyEditsFeatureService:o,featureFormCallbacks:{addRelatedRecord:e=>{this.startCreatingRelatedRecord(e)},editRelatedRecord:({relatedFeature:e,readOnly:t})=>{this.startUpdatingSingle(e,{readOnly:t})},selectAssociatedFeature:async({feature:e,association:t})=>await this.startUpdatingSingle(e,{association:t}),addAssociation:e=>{this.startAddAssociation(e.feature,e.utilityNetwork,e.associationType)}},...t});return await w(()=>!d.updating),d}async _createNestedUpdateFeaturesWorkflow(e,t={}){const{applyEditsCallback:i,applyEditsFeatureServiceCallback:a,viewModel:o}=this.data,r=V.create({applyEdits:i,applyEditsFeatureService:a,featureInfos:e,viewModel:o,...t});return await w(()=>!r.updating),r}async _createNestedAddAssociationWorkflow(e,t,i){const{AddAssociationWorkflow:o}=await import("./AddAssociationWorkflow.js"),{applyEditsCallback:r,applyEditsFeatureServiceCallback:s,viewModel:n}=this.data,l=G(this.activeWorkflow)?this.activeWorkflow:void 0,{formViewModel:d}=this,c=T(d)?d.activeAssociationInput:null;if(!c)throw new a("editing:unable-to-add-association","There is no active association input in the current workflow's form.");const p=await o.create({utilityNetwork:t,associationType:i,feature:e,parent:l,viewModel:n,associationInput:c,applyEdits:r,applyEditsFeatureService:s});return await w(()=>!p.updating),p}async _createNestedMergeFeaturesWorkflow(e,t){const{applyEditsCallback:i,applyEditsFeatureServiceCallback:a,viewModel:o}=this.data;Z(e);const r=Q(this.data.viewModel.editorItems,W(e[0])),s=G(this.activeWorkflow)?this.activeWorkflow:void 0,n=await R.create({applyEdits:i,applyEditsFeatureService:a,editorItem:r,features:e,parent:s,viewModel:o,...t});return await w(()=>!n.updating),n}async _createNestedSplitFeatureWorkflow(e,t){const{applyEditsCallback:i,applyEditsFeatureServiceCallback:a,sketchOptions:o,snappingManager:r,viewModel:s}=this.data,n=G(this.activeWorkflow)?this.activeWorkflow:void 0,l=Q(s.editorItems,e.sourceLayer),d=j.create({applyEdits:i,applyEditsFeatureService:a,editorItem:l,originalFeature:e,parent:n,sketchOptions:o,snappingManager:r,viewModel:s,...t});return await w(()=>!d.updating),d}async _drainWorkflowStack(e){const t=this._workflowStack,i=[];for(const a of t){const t=e(a).finally(()=>a.destroy());this._updatingHandles.addPromise(t),i.push(t)}await Promise.all(i),this._workflowStack.clear(),this._sketchStack.clear()}_makeUpdatingResolver(){const e=n();return this._updatingHandles.addPromise(e.promise),e}_makeRelatedRecordAttributes(e){const{parentFeature:t,relatedLayer:i,relationshipId:a}=e;if(!te(t))return;const o=i.relationships?.find(e=>e.id===a);if(!o)return void this._logContinuingWithoutRelationshipWarning("relationship-not-found","Could not begin creating a related record because the relationship specified could not be found on the destination layer.");if("origin"===o.role)return void this._logContinuingWithoutRelationshipWarning("unsupported-role","Creating new related records in the 'origin' table of a relationship is not yet supported");const r=t.sourceLayer;o.relatedTableId!==r.layerId&&this._logContinuingWithoutRelationshipWarning("invalid-argument-combination","The given parent feature does not belong to the relationship designated by the given relationship ID.");const s=r.relationships?.find(e=>e.id===a);if(!s)return void this._logContinuingWithoutRelationshipWarning("relationship-not-found","Could not begin creating a related record because the relationship specified could not be found on the origin layer.");const n=oe(r,s),l=t.getAttribute(n);l||this._logContinuingWithoutRelationshipWarning("no-key-on-origin-feature","The given parent feature does not have a value for the relationship's origin primary key field.");const d=oe(i,o);return{[d]:l}}_popWorkflow(){this._workflowStack.pop()?.destroy(),this._sketchStack.pop()}async _popWorkflowAndReconcile(){this._popWorkflow();const e=await this._reconcileWorkflowStack();if(e.failureCount>0)throw new a("editor:next-workflow-failed","Popped the top workflow, but the next workflow in the stack failed to activate",e)}async _pushWorkflowAndReconcile(e){const t=this._workflowRequiresSketchViewModel(e);this.activeWorkflow?.exit({removeSketchHandles:t});const i=this._sketchStack,o=await(e?.start()),r=i.peek();o?(r?.exit(),i.push(o)):i.push(this._cloneSketchController(r)),this._workflowStack.push(e);const s=await this._reconcileWorkflowStack();if(s.failureCount>0)throw new a("editor:failed-to-start-updating-feature","Failed to enter the provided workflow.",s)}async _reconcileWorkflowStack(){const e=this._workflowStack,t=this._sketchStack;try{const i=e.peek();return await(i?.enter()),await(t.peek()?.enter()),{activeWorkflow:i,failureCount:0}}catch(i){e.pop().destroy(),t.pop();const{activeWorkflow:a,failureCount:o}=await this._reconcileWorkflowStack();return{activeWorkflow:a,failureCount:o+1}}}_cloneSketchController(e){return{enter:e?.enter??(async()=>{}),exit:e?.exit??(async()=>{}),viewModel:e?.viewModel}}_workflowRequiresSketchViewModel(e){const{type:t}=e;return"update-feature"===t||"create-features"===t&&!C(e.data.creationInfo?.layer)}static _createWorkflowSteps(e,t="awaiting-feature-to-update"){const{data:i}=e;return $(["awaiting-feature-to-update","awaiting-update-feature-candidate","editing-existing-feature","adding-attachment","editing-attachment"],t,{"awaiting-feature-to-update":()=>({id:"awaiting-feature-to-update",async setUp(){const{spinnerViewModel:t}=i.viewModel,a=i.viewModel.view;a.activeTool=null;let r=null;e.addHandles(o(()=>{r=s(r)}),this.id),i.rootFeatures.removeAll(),i.candidates=[];const l=a.on("immediate-click",async o=>{const s=n();e._updatingHandles.addPromise(s.promise);try{t.location=o.mapPoint,t.visible=!0,r?.abort();const{editorItems:s}=i.viewModel;r=new AbortController;const n=await o.defer(()=>new Promise((e,t)=>{d(r?.signal,()=>t(c())),e(B(s,a,o,r?.signal))}));if(p(r),i.candidates=n.filter(e=>"fulfilled"===e.status).flatMap(e=>e.value).filter(e=>!e.isAggregate),t.visible=1===i.candidates.length,0===i.candidates.length)return;if(o.stopPropagation(),1===i.candidates.length){const{rootFeatures:a}=i;a.removeAll(),a.add(i.candidates[0]),e.go("editing-existing-feature").catch(()=>{}).then(()=>t.visible=!1)}else e.next()}finally{s.resolve()}},E.TOOL),u=v(()=>null!=a.activeTool,()=>e.cancel({force:!0}),{once:!0});a.focus(),e.addHandles([l,u],this.id)},async tearDown(){0===i.candidates.length&&(i.viewModel.spinnerViewModel.visible=!1),e.removeHandles(this.id)}}),"awaiting-update-feature-candidate":()=>({id:"awaiting-update-feature-candidate",async setUp(){i.rootFeatures.removeAll();const{view:t}=i.viewModel;if(!t)return;const a=new F({view:t,highlightName:U});e.addHandles([g(()=>i.rootFeatures,"change",({added:e,removed:t})=>{t.forEach(e=>a.remove(e)),e.forEach(e=>a.add(e))},f),o(()=>a.removeAll())],this.id)},async tearDown(){e.removeHandles(this.id)}}),"editing-existing-feature":()=>({id:"editing-existing-feature",async setUp(){await se(e);const{data:t}=e;t.viewModel.spinnerViewModel.visible=!1;const i=l(async()=>{await w(()=>!e.updating),e.previous()});e.addHandles([h(()=>e.nestedWorkflowCount,(e,t)=>{0===e&&0!==t&&i()},f)],this.id)},async tearDown(){await e.cancelAll(),e.removeHandles(this.id)}}),"adding-attachment":()=>({id:"adding-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){i.viewModel.attachmentsViewModel.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){i.viewModel.attachmentsViewModel.mode="view"}})})}_logContinuingWithoutRelationshipWarning(e,t){r.getLogger(this).warn(`editor:${e}`,t,"The create operation will be allowed to proceed, but the resulting feature may not be related to the given parent feature.")}};function oe(e,{keyField:t}){return e.getField(t)?.name??t}function re(e){if(e.pendingSubtypeChoice)return!0;const t=e.getValues();return e.validateContingencyConstraints(t,{includeIncompleteViolations:!0}).length>0}async function se(e){const{data:t}=e,{rootWorkflowOptions:i}=t;if(J(i)){const{rootFeatureInfos:o}=t,r=o.length>0?o:K(t.rootFeatures.toArray());if(0===r.length)throw new a("editing:invalid-parameter","Must supply `rootFeatureInfos` or `rootFeatures` when root workflow type is 'update-multiple'");return await e.startUpdatingMultiple(r,i.props)}const{rootFeatures:o}=t,r=o.getItemAt(0);if(!r)throw new a("editor:no-feature-specified","Cannot setup the 'updating-existing-feature' step until one or more root features are provided");X(i)?await e.startMergingFeatures(o.toArray(),i.props):Y(i)?await e.startSplittingFeature(r,i.props):await e.startUpdatingSingle(r)}e([m()],ae.prototype,"formViewModel",null),e([m()],ae.prototype,"activeUtilityNetworkAssociationAddAssociationViewModel",null),e([m()],ae.prototype,"activeSketchViewModel",null),e([m()],ae.prototype,"canDeleteAssociation",null),e([m()],ae.prototype,"activeWorkflow",null),e([m()],ae.prototype,"updating",null),e([m()],ae.prototype,"data",void 0),e([m()],ae.prototype,"hasPreviousStep",null),e([m()],ae.prototype,"hasUpdatableCandidates",null),e([m()],ae.prototype,"nestedWorkflowCount",null),e([m()],ae.prototype,"shouldShowAttachments",null),e([m()],ae.prototype,"shouldAllowAttachmentEditing",null),e([m()],ae.prototype,"hasPendingEdits",null),e([m()],ae.prototype,"helpMessage",null),e([m()],ae.prototype,"reliesOnOwnerAdminPrivileges",null),e([m()],ae.prototype,"hasInvalidFormTemplate",null),ae=ie=e([y("esri.widgets.Editor.UpdateWorkflow")],ae);const ne=ae;export{ne as default};
5
+ import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{remove as i}from"../../core/arrayUtils.js";import o from"../../core/Error.js";import{makeHandle as a}from"../../core/handleUtils.js";import r from"../../core/Logger.js";import{abortMaybe as s}from"../../core/maybe.js";import{createResolver as n,debounce as l,onAbort as d,createAbortError as c,throwIfAborted as p}from"../../core/promiseUtils.js";import u from"../../core/Queue.js";import{whenOnce as w,watch as h,sync as f,on as g,when as v}from"../../core/reactiveUtils.js";import{last as k}from"../../core/SetUtils.js";import{property as m}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as y}from"../../core/accessorSupport/decorators/subclass.js";import{getGraphicLayer as W}from"../../graphic/graphicOriginUtils.js";import{isEditableLayer as A}from"../../layers/support/editableLayers.js";import{isFeatureLayer as _,isSubtypeSublayer as b,isSubtypeGroupLayer as S,isTable as C}from"../../layers/support/layerUtils.js";import{createFeatureServices as M}from"../../rest/featureService/utils.js";import F from"../../views/draw/support/HighlightHelper.js";import{ViewEventPriorities as E}from"../../views/input/InputManager.js";import{temporaryHighlightName as U}from"../../views/support/HighlightDefaults.js";import I from"./CreateFeaturesWorkflow.js";import R from"./MergeFeaturesWorkflow.js";import j from"./SplitFeatureWorkflow.js";import V from"./UpdateFeaturesWorkflow.js";import{UpdateFeatureWorkflow as P}from"./UpdateFeatureWorkflow.js";import{UpdateRecordWorkflow as L}from"./UpdateRecordWorkflow.js";import N from"./UpdateWorkflowData.js";import O from"./Workflow.js";import{isFeatureFormViewModel as T,findEditorItemForLayer as x,isSplitFeatureWorkflow as H,workflowInfluencesOutcomeOfParent as D,isAnyUpdateLeafWorkflow as q,isUpdateRecordWorkflow as z,isParentWorkflow as G,findEditorItemForLayerOrThrow as Q,createWorkflowSteps as $,fetchCandidates as B,isUpdateFeaturesWorkflowOptions as J,toFeatureInfos as K,isMergeWorkflowOptions as X,isSplitWorkflowOptions as Y}from"./workflowUtils.js";import{assertFeaturesAreFromSameLayer as Z}from"./support/errors.js";import{findUtilityNetwork as ee,isGraphicForRelatableFeatureSupportedLayer as te}from"../Feature/support/featureUtils.js";var ie;let oe=ie=class extends O{constructor(e){super(e),this._workflowStack=new u(k),this._sketchStack=new u(k),this.data=void 0,this.type="update"}destroy(){this._drainWorkflowStack(e=>e.cancel({force:!0}))}get formViewModel(){return this.activeWorkflow?.formViewModel}get activeUtilityNetworkAssociationAddAssociationViewModel(){return"add-association"===this.activeWorkflow?.type?this.activeWorkflow.utilityNetworkAssociationAddAssociationViewModel:null}get activeSketchViewModel(){return this._sketchStack.peek()?.viewModel}get canDeleteAssociation(){const{formViewModel:e}=this;if(!this.activeWorkflow||!this.data.viewModel.view?.map||!T(e))return!1;const{activeAssociation:t,feature:i}=e;return!(!t||!i?.sourceLayer||!_(i?.sourceLayer)&&!b(i?.sourceLayer))}get activeWorkflow(){return this._workflowStack.last()}get updating(){return this._updatingHandles.updating||!!this.activeWorkflow?.updating}get hasPreviousStep(){const e=this.activeWorkflow?.formViewModel;return this._stepIndex>0||this.nestedWorkflowCount>1||this.activeWorkflow?.hasPreviousStep||"view"!==this.data.viewModel.attachmentsViewModel.mode||T(e)&&(null!=e.relationshipId||null!=e.associationId||null!=e.associatedLayer)}get hasUpdatableCandidates(){const{candidates:e,viewModel:t}=this.data;return e.some(({layer:e})=>x(t.editorItems,e)?.supportsUpdateWorkflow)}get nestedWorkflowCount(){return this._workflowStack.length}get shouldShowAttachments(){return this.activeWorkflow?.shouldShowAttachments??!1}get shouldAllowAttachmentEditing(){return this.activeWorkflow?.shouldAllowAttachmentEditing??!1}get hasPendingEdits(){return Array.from(this._workflowStack).some(e=>e.hasPendingEdits)}get helpMessage(){return this.activeWorkflow?.helpMessage?this.activeWorkflow.helpMessage:"awaiting-feature-to-update"===this.stepId?"select":void 0}get noticeMessage(){return this.activeWorkflow?.noticeMessage}get reliesOnOwnerAdminPrivileges(){return this.activeWorkflow?.reliesOnOwnerAdminPrivileges??!1}get hasInvalidFormTemplate(){return this.activeWorkflow?.hasInvalidFormTemplate??!1}async back(e=()=>Promise.resolve(!0)){const{activeWorkflow:t}=this,i=t?.formViewModel;if(T(i)){if(i?.activeRelationshipInput){const e=i.activeRelationshipInput;if(e.activeCategory)return void(e.activeCategory=null);if(null!=i.relationshipId)return void(i.relationshipId=null);if(e.showAllEnabled)return void(e.showAllEnabled=!1)}if("add-association"===t?.type){const{activeUtilityNetworkAssociationAddAssociationViewModel:e}=this;if(e?.filterOptionsVisible)return void(e.filterOptionsVisible=!1);e?.featureSpatialItems.length&&e.reset()}if(null!=i?.associatedLayer)return void(i.associatedLayer=null);if(null!=i?.associationId)return void(i.associationId=null)}if("create-features"===t?.type&&t.hasPreviousStep)await t.previous({cancelCurrentStep:!0});else{if(H(t)&&t.hasPreviousStep)return await t.back();if(t){if(t.hasPendingEdits){if(!await e())return}t.hasPreviousStep?await t.previous({cancelCurrentStep:!0}):await this.cancelActiveWorkflow({force:!0})}else this.hasPreviousStep?await this.previous({cancelCurrentStep:!0}):await this.cancel({force:!0})}}async cancelActiveWorkflow(e){await(this.activeWorkflow?.cancel(e)),await this._popWorkflowAndReconcile()}async commit(){await this._drainWorkflowStack(e=>e.commit()),await super.commit()}static create(e){const{startAt:t,applyEdits:i,applyEditsFeatureService:o,...a}=e,r=new ie({data:new N({applyEditsCallback:i,applyEditsFeatureServiceCallback:o,...a}),onCommit:async()=>{}});return r._set("steps",this._createWorkflowSteps(r,t)),r}async save(){const{formViewModel:e}=this;if(e&&(e.submit(),!e.submittable||T(e)&&re(e)))return;if(this.nestedWorkflowCount<2)return await this.commit();const{activeWorkflow:t}=this;if(await(t?.commit()),!D(t))return void await this._popWorkflowAndReconcile();this._popWorkflow();const i=this._workflowStack.peek();if(i&&i===t?.parent&&(await i.cancel(),this._popWorkflow(),0===this.nestedWorkflowCount))return await this.commit();await this._reconcileWorkflowStack()}async startCreatingRelatedRecord(e){const t=this._makeUpdatingResolver();try{const t=this._createNestedCreateFeaturesWorkflow(e);await this._pushWorkflowAndReconcile(t)}catch(i){throw new o("editor:unable-to-start-creating","Could not begin updating the provided feature or table record.",{error:i})}finally{t.resolve()}}async startMergingFeatures(e,t){const i=this._makeUpdatingResolver();try{const i=await this._createNestedMergeFeaturesWorkflow(e,t);await this._pushWorkflowAndReconcile(i)}catch(a){throw new o("editor:unable-to-start-merging","Could not begin merging the provided features.",{error:a})}finally{i.resolve()}}async startSplittingFeature(e,t){const i=this._makeUpdatingResolver();try{const i=await this._createNestedSplitFeatureWorkflow(e,t);await this._pushWorkflowAndReconcile(i)}catch(a){throw new o("editor:unable-to-start-splitting","Could not begin splitting the provided feature.",{error:a})}finally{i.resolve()}}async startUpdatingSingle(e,t){const i=this._makeUpdatingResolver();try{const i=await this._createNestedUpdateWorkflow(e,t);await this._pushWorkflowAndReconcile(i)}catch(a){throw new o("editor:unable-to-start-updating","Could not begin updating the provided feature or table record.",{error:a})}finally{i.resolve()}}async startUpdatingMultiple(e,t){const i=this._makeUpdatingResolver();try{const i=await this._createNestedUpdateFeaturesWorkflow(e,t);await this._pushWorkflowAndReconcile(i)}catch(a){throw new o("editor:unable-to-start-updating","Could not begin updating the provided features or table records.",{error:a})}finally{i.resolve()}}async startAddAssociation(e,t,i){const a=this._makeUpdatingResolver();try{const o=await this._createNestedAddAssociationWorkflow(e,t,i);await this._pushWorkflowAndReconcile(o)}catch(r){throw new o("editor:unable-to-start-updating","Could not begin updating the provided feature or table record.",{error:r})}finally{a.resolve()}}async deleteActiveFeatures(){const{activeWorkflow:e}=this;if(!e)throw new o("editor:nothing-to-delete","There is no feature to delete");const t=q(e);if(t){e.data.stageDelete();const t=z(e)?e.data.edits.feature?[e.data.edits.feature]:[]:e.data.features;this._removeFeaturesFromCandidates(t)}else await e.cancel();this.nestedWorkflowCount<2?t?await this.commit():await this.cancel({force:!0}):(t&&await e.commit(),await this._popWorkflowAndReconcile(),await this._returnToPageWithContent())}async deleteActiveAssociation(){if(!this.canDeleteAssociation)throw new o("editor:nothing-to-delete","There is no association to delete");await this._deleteActiveAssociation(),await this._popWorkflowAndReconcile(),await this._returnToPageWithContent()}async cancelAll(){await this._drainWorkflowStack(e=>e.cancel({force:!0}))}async _deleteActiveAssociation(){const{formViewModel:e}=this;if(!T(e))throw new o("editing:failed-to-delete-association","The active workflow does not support editing associations");const{activeAssociation:t,feature:i}=e,{applyEditsFeatureServiceCallback:a,viewModel:r}=this.data,{sourceLayer:s}=i,n=b(s)&&s.parent?s.parent:s,l=M([n]),d=l.values().next().value?.featureService;if(!d)throw new o("editor:failed-to-delete-association","Could not retrieve feature service needed to delete association");await(d?.load());const c=r.view.map,p=ee(c,n);await(p?.networkSystemLayers.loadAssociationsTable());const u=p?.generateDeleteAssociations([t]);if(!u)throw new o("editor:failed-to-delete-association","Could not create payload needed to delete association");const w=p?.gdbVersion??void 0;await a(d,[u],{gdbVersion:w,globalIdUsed:!0})}_removeFeaturesFromCandidates(e){const{candidates:t}=this.data;if(0!==t.length&&0!==e.length)for(const o of e)i(t,o)}async _returnToPageWithContent(){const{formViewModel:e}=this;if(!T(e)||!e?.activeAssociationInput)return;const{activeAssociationInput:t,associationId:i}=e;await t.refresh(),t.associatedLayer&&!t.associatedFeatures?.length&&(e.associatedLayer=null),null==i||t.associatedFeatureInfos.size||(e.associationId=null)}_createNestedCreateFeaturesWorkflow(e){const{relatedLayer:t}=e,{addAttachmentsCallback:i,applyEditsCallback:a,applyEditsFeatureServiceCallback:r,sketchOptions:s,snappingManager:n,viewModel:l}=this.data;if(!A(t))throw new o("editor:unsupported-layer","Editing is not supported on the provided layer");const d=this._getCreationInfoForNestedCreateFeaturesWorkflow(e),c=d.template||d.initialFeature?"creating-features":"awaiting-feature-creation-info",p=G(this.activeWorkflow)?this.activeWorkflow:void 0;return I.create({addAttachmentsCallback:i,applyEdits:a,applyEditsFeatureService:r,creationInfo:d,isNested:!0,parent:p,sketchOptions:s,snappingManager:n,startAt:c,viewModel:l})}_getCreationInfoForNestedCreateFeaturesWorkflow(e){const{relatedLayer:i}=e;if(!A(i)||S(i))throw new o("editor:unsupported-layer","Editing is not supported on the provided layer");const{viewModel:a}=this.data,r={layer:i,maxFeatures:1},s=this._makeRelatedRecordAttributes(e),n=a.getTemplatesForLayer(i);return n?.length>0?(r.attributeOverrides=s,1===n.length&&(r.template=n[0])):r.initialFeature=new t({sourceLayer:i,attributes:s}),r}async _createNestedUpdateWorkflow(e,t={}){const i=C(e.sourceLayer)?L:P,{applyEditsCallback:o,applyEditsFeatureServiceCallback:a,sketchOptions:r,snappingManager:s,viewModel:n}=this.data,l=G(this.activeWorkflow)?this.activeWorkflow:void 0,d=await i.create({feature:e,parent:l,sketchOptions:r,snappingManager:s,viewModel:n,applyEdits:o,applyEditsFeatureService:a,featureFormCallbacks:{addRelatedRecord:e=>{this.startCreatingRelatedRecord(e)},editRelatedRecord:({relatedFeature:e,readOnly:t})=>{this.startUpdatingSingle(e,{readOnly:t})},selectAssociatedFeature:async({feature:e,association:t})=>await this.startUpdatingSingle(e,{association:t}),addAssociation:e=>{this.startAddAssociation(e.feature,e.utilityNetwork,e.associationType)}},...t});return await w(()=>!d.updating),d}async _createNestedUpdateFeaturesWorkflow(e,t={}){const{applyEditsCallback:i,applyEditsFeatureServiceCallback:o,viewModel:a}=this.data,r=V.create({applyEdits:i,applyEditsFeatureService:o,featureInfos:e,viewModel:a,...t});return await w(()=>!r.updating),r}async _createNestedAddAssociationWorkflow(e,t,i){const{AddAssociationWorkflow:a}=await import("./AddAssociationWorkflow.js"),{applyEditsCallback:r,applyEditsFeatureServiceCallback:s,viewModel:n}=this.data,l=G(this.activeWorkflow)?this.activeWorkflow:void 0,{formViewModel:d}=this,c=T(d)?d.activeAssociationInput:null;if(!c)throw new o("editing:unable-to-add-association","There is no active association input in the current workflow's form.");const p=await a.create({utilityNetwork:t,associationType:i,feature:e,parent:l,viewModel:n,associationInput:c,applyEdits:r,applyEditsFeatureService:s});return await w(()=>!p.updating),p}async _createNestedMergeFeaturesWorkflow(e,t){const{applyEditsCallback:i,applyEditsFeatureServiceCallback:o,viewModel:a}=this.data;Z(e);const r=Q(this.data.viewModel.editorItems,W(e[0])),s=G(this.activeWorkflow)?this.activeWorkflow:void 0,n=await R.create({applyEdits:i,applyEditsFeatureService:o,editorItem:r,features:e,parent:s,viewModel:a,...t});return await w(()=>!n.updating),n}async _createNestedSplitFeatureWorkflow(e,t){const{applyEditsCallback:i,applyEditsFeatureServiceCallback:o,sketchOptions:a,snappingManager:r,viewModel:s}=this.data,n=G(this.activeWorkflow)?this.activeWorkflow:void 0,l=Q(s.editorItems,e.sourceLayer),d=j.create({applyEdits:i,applyEditsFeatureService:o,editorItem:l,originalFeature:e,parent:n,sketchOptions:a,snappingManager:r,viewModel:s,...t});return await w(()=>!d.updating),d}async _drainWorkflowStack(e){const t=this._workflowStack,i=[];for(const o of t){const t=e(o).finally(()=>o.destroy());this._updatingHandles.addPromise(t),i.push(t)}await Promise.all(i),this._workflowStack.clear(),this._sketchStack.clear()}_makeUpdatingResolver(){const e=n();return this._updatingHandles.addPromise(e.promise),e}_makeRelatedRecordAttributes(e){const{parentFeature:t,relatedLayer:i,relationshipId:o}=e;if(!te(t))return;const a=i.relationships?.find(e=>e.id===o);if(!a)return void this._logContinuingWithoutRelationshipWarning("relationship-not-found","Could not begin creating a related record because the relationship specified could not be found on the destination layer.");if("origin"===a.role)return void this._logContinuingWithoutRelationshipWarning("unsupported-role","Creating new related records in the 'origin' table of a relationship is not yet supported");const r=t.sourceLayer;a.relatedTableId!==r.layerId&&this._logContinuingWithoutRelationshipWarning("invalid-argument-combination","The given parent feature does not belong to the relationship designated by the given relationship ID.");const s=r.relationships?.find(e=>e.id===o);if(!s)return void this._logContinuingWithoutRelationshipWarning("relationship-not-found","Could not begin creating a related record because the relationship specified could not be found on the origin layer.");const n=ae(r,s),l=t.getAttribute(n);l||this._logContinuingWithoutRelationshipWarning("no-key-on-origin-feature","The given parent feature does not have a value for the relationship's origin primary key field.");const d=ae(i,a);return{[d]:l}}_popWorkflow(){this._workflowStack.pop()?.destroy(),this._sketchStack.pop()}async _popWorkflowAndReconcile(){this._popWorkflow();const e=await this._reconcileWorkflowStack();if(e.failureCount>0)throw new o("editor:next-workflow-failed","Popped the top workflow, but the next workflow in the stack failed to activate",e)}async _pushWorkflowAndReconcile(e){const t=this._workflowRequiresSketchViewModel(e);this.activeWorkflow?.exit({removeSketchHandles:t});const i=this._sketchStack,a=await(e?.start()),r=i.peek();a?(r?.exit(),i.push(a)):i.push(this._cloneSketchController(r)),this._workflowStack.push(e);const s=await this._reconcileWorkflowStack();if(s.failureCount>0)throw new o("editor:failed-to-start-updating-feature","Failed to enter the provided workflow.",s)}async _reconcileWorkflowStack(){const e=this._workflowStack,t=this._sketchStack;try{const i=e.peek();return await(i?.enter()),await(t.peek()?.enter()),{activeWorkflow:i,failureCount:0}}catch(i){e.pop().destroy(),t.pop();const{activeWorkflow:o,failureCount:a}=await this._reconcileWorkflowStack();return{activeWorkflow:o,failureCount:a+1}}}_cloneSketchController(e){return{enter:e?.enter??(async()=>{}),exit:e?.exit??(async()=>{}),viewModel:e?.viewModel}}_workflowRequiresSketchViewModel(e){const{type:t}=e;return"update-feature"===t||"create-features"===t&&!C(e.data.creationInfo?.layer)}static _createWorkflowSteps(e,t="awaiting-feature-to-update"){const{data:i}=e;return $(["awaiting-feature-to-update","awaiting-update-feature-candidate","editing-existing-feature","adding-attachment","editing-attachment"],t,{"awaiting-feature-to-update":()=>({id:"awaiting-feature-to-update",async setUp(){const{spinnerViewModel:t}=i.viewModel,o=i.viewModel.view;o.activeTool=null;let r=null;e.addHandles(a(()=>{r=s(r)}),this.id),i.rootFeatures.removeAll(),i.candidates=[];const l=o.on("immediate-click",async a=>{const s=n();e._updatingHandles.addPromise(s.promise);try{t.location=a.mapPoint,t.visible=!0,r?.abort();const{editorItems:s}=i.viewModel;r=new AbortController;const n=await a.defer(()=>new Promise((e,t)=>{d(r?.signal,()=>t(c())),e(B(s,o,a,r?.signal))}));if(p(r),i.candidates=n.filter(e=>"fulfilled"===e.status).flatMap(e=>e.value).filter(e=>!e.isAggregate),t.visible=1===i.candidates.length,0===i.candidates.length)return;if(a.stopPropagation(),1===i.candidates.length){const{rootFeatures:o}=i;o.removeAll(),o.add(i.candidates[0]),e.go("editing-existing-feature").catch(()=>{}).then(()=>t.visible=!1)}else e.next()}finally{s.resolve()}},E.TOOL),u=v(()=>null!=o.activeTool,()=>e.cancel({force:!0}),{once:!0});o.focus(),e.addHandles([l,u],this.id)},async tearDown(){0===i.candidates.length&&(i.viewModel.spinnerViewModel.visible=!1),e.removeHandles(this.id)}}),"awaiting-update-feature-candidate":()=>({id:"awaiting-update-feature-candidate",async setUp(){i.rootFeatures.removeAll();const{view:t}=i.viewModel;if(!t)return;const o=new F({view:t,highlightName:U});e.addHandles([g(()=>i.rootFeatures,"change",({added:e,removed:t})=>{t.forEach(e=>o.remove(e)),e.forEach(e=>o.add(e))},f),a(()=>o.removeAll())],this.id)},async tearDown(){e.removeHandles(this.id)}}),"editing-existing-feature":()=>({id:"editing-existing-feature",async setUp(){await se(e);const{data:t}=e;t.viewModel.spinnerViewModel.visible=!1;const i=l(async()=>{await w(()=>!e.updating),e.previous()});e.addHandles([h(()=>e.nestedWorkflowCount,(e,t)=>{0===e&&0!==t&&i()},f)],this.id)},async tearDown(){await e.cancelAll(),e.removeHandles(this.id)}}),"adding-attachment":()=>({id:"adding-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){i.viewModel.attachmentsViewModel.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){i.viewModel.attachmentsViewModel.mode="view"}})})}_logContinuingWithoutRelationshipWarning(e,t){r.getLogger(this).warn(`editor:${e}`,t,"The create operation will be allowed to proceed, but the resulting feature may not be related to the given parent feature.")}};function ae(e,{keyField:t}){return e.getField(t)?.name??t}function re(e){if(e.pendingSubtypeChoice)return!0;const t=e.getValues();return e.validateContingencyConstraints(t,{includeIncompleteViolations:!0}).length>0}async function se(e){const{data:t}=e,{rootWorkflowOptions:i}=t;if(J(i)){const{rootFeatureInfos:a}=t,r=a.length>0?a:K(t.rootFeatures.toArray());if(0===r.length)throw new o("editing:invalid-parameter","Must supply `rootFeatureInfos` or `rootFeatures` when root workflow type is 'update-multiple'");return await e.startUpdatingMultiple(r,i.props)}const{rootFeatures:a}=t,r=a.getItemAt(0);if(!r)throw new o("editor:no-feature-specified","Cannot setup the 'updating-existing-feature' step until one or more root features are provided");X(i)?await e.startMergingFeatures(a.toArray(),i.props):Y(i)?await e.startSplittingFeature(r,i.props):await e.startUpdatingSingle(r)}e([m()],oe.prototype,"formViewModel",null),e([m()],oe.prototype,"activeUtilityNetworkAssociationAddAssociationViewModel",null),e([m()],oe.prototype,"activeSketchViewModel",null),e([m()],oe.prototype,"canDeleteAssociation",null),e([m()],oe.prototype,"activeWorkflow",null),e([m()],oe.prototype,"updating",null),e([m()],oe.prototype,"data",void 0),e([m()],oe.prototype,"hasPreviousStep",null),e([m()],oe.prototype,"hasUpdatableCandidates",null),e([m()],oe.prototype,"nestedWorkflowCount",null),e([m()],oe.prototype,"shouldShowAttachments",null),e([m()],oe.prototype,"shouldAllowAttachmentEditing",null),e([m()],oe.prototype,"hasPendingEdits",null),e([m()],oe.prototype,"helpMessage",null),e([m()],oe.prototype,"noticeMessage",null),e([m()],oe.prototype,"reliesOnOwnerAdminPrivileges",null),e([m()],oe.prototype,"hasInvalidFormTemplate",null),oe=ie=e([y("esri.widgets.Editor.UpdateWorkflow")],oe);const ne=oe;export{ne as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as t}from"tslib";import e from"../../core/Error.js";import{EventedAccessor as s}from"../../core/Evented.js";import{throwIfNotAbortError as i,createResolver as n}from"../../core/promiseUtils.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as r}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as a}from"../../core/support/UpdatingHandles.js";let p=class extends s{constructor(t){super(t),this._indexHistory=[],this._lastStepIndex=-1,this._stepIndex=-1,this._updatingHandles=new a,this._handleKeys={afterCommit:"after-commit",beforeCommit:"before-commit"},this.data=void 0,this.started=!1,this.steps=[],this.type=null,this._pendingOperation=null}destroy(){this._updatingHandles.destroy()}get formViewModel(){return null}get hasNextStep(){const{steps:t}=this;return!!(t&&this._stepIndex<t.filter(t=>!t.parent).length-1)}get hasPreviousStep(){return this._stepIndex>0}get reliesOnOwnerAdminPrivileges(){return!1}get hasInvalidFormTemplate(){return!1}get shouldShowAttachments(){return!1}get shouldAllowAttachmentEditing(){return!1}get stepId(){const{steps:t}=this,e=t&&t[this._stepIndex];return e&&e.id}get allowSave(){return!this.updating}get helpMessage(){}get hasPendingEdits(){return!1}get keyboardCancellationEnabled(){return!0}get saveActionLabel(){return"submit"}get updating(){return this._updatingHandles.updating||!!this.formViewModel?.updating}async back(t=()=>Promise.resolve(!0)){if(this.hasPendingEdits){if(!await t())return}this.hasPreviousStep?await this.previous({cancelCurrentStep:!0}):await this.cancel({force:!0})}async cancel(t={force:!0}){return!1!==t.force?this._cancel(t):new Promise((s,i)=>{this.emit("cancel-request",{controller:{allow:()=>{this._cancel({...t,force:!0}).then(s)},deny:()=>i(new e("workflow:cancel-denied","Request to cancel workflow was denied."))}})})}async commit(){this.removeHandles(this._handleKeys.beforeCommit),this.onCommit&&await this.onCommit(this.data),this.removeHandles(this._handleKeys.afterCommit),this.emit("commit")}async go(t){const{steps:e}=this,s=e.findIndex(e=>e.id===t);this._indexHistory.push(this._stepIndex),await this._go(s)}async next(){this._indexHistory.push(this._stepIndex),await this._go(this._stepIndex+1)}async previous(t={cancelCurrentStep:!1}){await this._go(this._indexHistory.pop(),t.cancelCurrentStep)}async reset(){await this._cancel({emitCancelEvent:!1}),await this.start()}async save(){await this.commit(),await this.reset()}async start(){this._set("started",!0);const t=-1===this._stepIndex?0:this._stepIndex;await this._go(t)}async _cancel({emitCancelEvent:t=!0,error:e}={}){this.started&&(this._set("started",!1),await this._transaction(()=>this.steps[this._stepIndex]?.tearDown({canceled:!0}))),this.removeHandles([this._handleKeys.afterCommit,this._handleKeys.beforeCommit]),this._resetIndexing(t),t&&this.emit("cancel",{error:e})}_go(t=-1,e=!1){return this._transaction(async()=>{const{steps:s}=this;if(!(t<=-1||t>=s.length)){if(!this.started)return this._stepIndex=t,void this._notifyStepProps();this._lastStepIndex>-1&&await s[this._lastStepIndex].tearDown({canceled:e});try{await s[t].setUp()}catch(n){i(n)}this._lastStepIndex=t,this._stepIndex=t,this._notifyStepProps()}})}async _transaction(t){const e=this._pendingOperation,s=n(),i=(e??Promise.resolve()).then(()=>s.promise);this._pendingOperation=i,this._updatingHandles.addPromise(i);try{e&&await e,await t()}finally{s.resolve(),i===this._pendingOperation&&(this._pendingOperation=null)}}_resetIndexing(t=!0){this._stepIndex=-1,this._lastStepIndex=-1,this._indexHistory.length=0,t&&this._notifyStepProps()}_notifyStepProps(){this.notifyChange("stepId"),this.notifyChange("hasPreviousStep"),this.notifyChange("hasNextStep")}};t([o()],p.prototype,"data",void 0),t([o()],p.prototype,"formViewModel",null),t([o()],p.prototype,"hasNextStep",null),t([o()],p.prototype,"hasPreviousStep",null),t([o()],p.prototype,"onCommit",void 0),t([o()],p.prototype,"reliesOnOwnerAdminPrivileges",null),t([o()],p.prototype,"hasInvalidFormTemplate",null),t([o()],p.prototype,"shouldShowAttachments",null),t([o()],p.prototype,"shouldAllowAttachmentEditing",null),t([o()],p.prototype,"started",void 0),t([o({readOnly:!0})],p.prototype,"stepId",null),t([o()],p.prototype,"steps",void 0),t([o({readOnly:!0})],p.prototype,"type",void 0),t([o()],p.prototype,"allowSave",null),t([o()],p.prototype,"helpMessage",null),t([o()],p.prototype,"hasPendingEdits",null),t([o()],p.prototype,"keyboardCancellationEnabled",null),t([o()],p.prototype,"updating",null),p=t([r("esri.widgets.Editor.Workflow")],p);const h=p;export{h as default};
5
+ import{__decorate as t}from"tslib";import e from"../../core/Error.js";import{EventedAccessor as s}from"../../core/Evented.js";import{throwIfNotAbortError as i,createResolver as n}from"../../core/promiseUtils.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as r}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as a}from"../../core/support/UpdatingHandles.js";let p=class extends s{constructor(t){super(t),this._indexHistory=[],this._lastStepIndex=-1,this._stepIndex=-1,this._updatingHandles=new a,this._handleKeys={afterCommit:"after-commit",beforeCommit:"before-commit"},this.data=void 0,this.started=!1,this.steps=[],this.type=null,this._pendingOperation=null}destroy(){this._updatingHandles.destroy()}get formViewModel(){return null}get hasNextStep(){const{steps:t}=this;return!!(t&&this._stepIndex<t.filter(t=>!t.parent).length-1)}get hasPreviousStep(){return this._stepIndex>0}get reliesOnOwnerAdminPrivileges(){return!1}get hasInvalidFormTemplate(){return!1}get shouldShowAttachments(){return!1}get shouldAllowAttachmentEditing(){return!1}get stepId(){const{steps:t}=this,e=t&&t[this._stepIndex];return e&&e.id}get allowSave(){return!this.updating}get helpMessage(){}get noticeMessage(){}get hasPendingEdits(){return!1}get keyboardCancellationEnabled(){return!0}get saveActionLabel(){return"submit"}get updating(){return this._updatingHandles.updating||!!this.formViewModel?.updating}async back(t=()=>Promise.resolve(!0)){if(this.hasPendingEdits){if(!await t())return}this.hasPreviousStep?await this.previous({cancelCurrentStep:!0}):await this.cancel({force:!0})}async cancel(t={force:!0}){return!1!==t.force?this._cancel(t):new Promise((s,i)=>{this.emit("cancel-request",{controller:{allow:()=>{this._cancel({...t,force:!0}).then(s)},deny:()=>i(new e("workflow:cancel-denied","Request to cancel workflow was denied."))}})})}async commit(){this.removeHandles(this._handleKeys.beforeCommit),this.onCommit&&await this.onCommit(this.data),this.removeHandles(this._handleKeys.afterCommit),this.emit("commit")}async go(t){const{steps:e}=this,s=e.findIndex(e=>e.id===t);this._indexHistory.push(this._stepIndex),await this._go(s)}async next(){this._indexHistory.push(this._stepIndex),await this._go(this._stepIndex+1)}async previous(t={cancelCurrentStep:!1}){await this._go(this._indexHistory.pop(),t.cancelCurrentStep)}async reset(){await this._cancel({emitCancelEvent:!1}),await this.start()}async save(){await this.commit(),await this.reset()}async start(){this._set("started",!0);const t=-1===this._stepIndex?0:this._stepIndex;await this._go(t)}async _cancel({emitCancelEvent:t=!0,error:e}={}){this.started&&(this._set("started",!1),await this._transaction(()=>this.steps[this._stepIndex]?.tearDown({canceled:!0}))),this.removeHandles([this._handleKeys.afterCommit,this._handleKeys.beforeCommit]),this._resetIndexing(t),t&&this.emit("cancel",{error:e})}_go(t=-1,e=!1){return this._transaction(async()=>{const{steps:s}=this;if(!(t<=-1||t>=s.length)){if(!this.started)return this._stepIndex=t,void this._notifyStepProps();this._lastStepIndex>-1&&await s[this._lastStepIndex].tearDown({canceled:e});try{await s[t].setUp()}catch(n){i(n)}this._lastStepIndex=t,this._stepIndex=t,this._notifyStepProps()}})}async _transaction(t){const e=this._pendingOperation,s=n(),i=(e??Promise.resolve()).then(()=>s.promise);this._pendingOperation=i,this._updatingHandles.addPromise(i);try{e&&await e,await t()}finally{s.resolve(),i===this._pendingOperation&&(this._pendingOperation=null)}}_resetIndexing(t=!0){this._stepIndex=-1,this._lastStepIndex=-1,this._indexHistory.length=0,t&&this._notifyStepProps()}_notifyStepProps(){this.notifyChange("stepId"),this.notifyChange("hasPreviousStep"),this.notifyChange("hasNextStep")}};t([o()],p.prototype,"data",void 0),t([o()],p.prototype,"formViewModel",null),t([o()],p.prototype,"hasNextStep",null),t([o()],p.prototype,"hasPreviousStep",null),t([o()],p.prototype,"onCommit",void 0),t([o()],p.prototype,"reliesOnOwnerAdminPrivileges",null),t([o()],p.prototype,"hasInvalidFormTemplate",null),t([o()],p.prototype,"shouldShowAttachments",null),t([o()],p.prototype,"shouldAllowAttachmentEditing",null),t([o()],p.prototype,"started",void 0),t([o({readOnly:!0})],p.prototype,"stepId",null),t([o()],p.prototype,"steps",void 0),t([o({readOnly:!0})],p.prototype,"type",void 0),t([o()],p.prototype,"allowSave",null),t([o()],p.prototype,"helpMessage",null),t([o()],p.prototype,"noticeMessage",null),t([o()],p.prototype,"hasPendingEdits",null),t([o()],p.prototype,"keyboardCancellationEnabled",null),t([o()],p.prototype,"updating",null),p=t([r("esri.widgets.Editor.Workflow")],p);const l=p;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/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{loadPanelContentComponents as e,PanelContent as t,PanelContentMessage as n}from"./PanelContent.js";import{tsx as o,tsxFragment as r}from"../../support/widget.js";const s=()=>e();function a({helpMessage:e,renderSketchToolbar:s}){return o(r,null,s(),o(t,{key:"creating-features-panel-content"},o(n,{key:"content-message"},e)))}export{a as CreateFeaturesPanelContent,s as loadCreateFeaturesPanelContentComponents};
5
+ import{Notice as e}from"./Notices.js";import{loadPanelContentComponents as t,PanelContent as n,PanelContentMessage as o}from"./PanelContent.js";import{tsx as r,tsxFragment as s}from"../../support/widget.js";const i=()=>t();function a({helpMessage:t,noticeMessage:i,renderSketchToolbar:a}){return r(s,null,a(),r(n,{key:"creating-features-panel-content"},i?r(e,{key:"creating-features-notice",kind:"warning",message:i}):void 0,r(o,{key:"content-message"},t)))}export{a as CreateFeaturesPanelContent,i as loadCreateFeaturesPanelContentComponents};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import{substitute as t}from"../../../intl.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import i from"../../Widget.js";import{css as s}from"../css.js";import{isCreateFeaturesWorkflow as n,isSplitFeatureWorkflow as a}from"../workflowUtils.js";import{CreateFeaturesWorkflowPendingFeatureListAdapter as c}from"./workflowAdapters/pendingFeatureList/CreateFeaturesWorkflowPendingFeatureListAdapter.ts.js";import{SplitFeatureWorkflowPendingFeatureListAdapter as l}from"./workflowAdapters/pendingFeatureList/SplitFeatureWorkflowPendingFeatureListAdapter.js";import{loadCalciteComponents as d}from"../../support/componentsUtils.js";import{Heading as m,incrementHeadingLevel as p}from"../../support/Heading.js";import{ItemList as u}from"../../support/ItemList.js";import{fetchThumbnail as h}from"../../support/symbolPreviewUtils.js";import{messageBundle as f,tsx as g,tsxFragment as w}from"../../support/widget.js";let b=class extends i{constructor(){super(...arguments),this.workflow=null,this.workflowAdapter=null,this.headingLevel=4,this._iconIntersectionObserver=new IntersectionObserver((e,r)=>{e.forEach(async e=>{if(e.isIntersecting){const o=e.target;if(I(o))return void r.unobserve(o);const i=v(o),{graphic:s}=i,n=s.sourceLayer??this.workflowAdapter?.layer;if(!n||!s)return;k(o,!0);const a=i.id?t(this.messages.previewTemplateAriaLabel,{label:i.id}):this.messagesCommon.preview,c=await h(s,n,{ariaLabel:a}).catch(()=>(k(o,!1),null));if(null==c)return;o.appendChild(c)}})}),this.messages=null,this.messagesCommon=null,this._renderActionEnd=({graphic:e})=>{const{workflowAdapter:t,messages:r}=this;if(!t)return;const o=e.geometry?g("calcite-action",{appearance:"transparent",icon:"zoom-to-object",onblur:()=>t.clearHighlights(),onclick:()=>t.zoomToFeature(e),onfocus:()=>t.highlightFeature(e),scale:"s",slot:"actions-end",text:this.messages.zoomTo,title:this.messages.zoomTo}):void 0,i=t.allowCancel?g("calcite-action",{appearance:"transparent",icon:"trash",onblur:()=>t.clearHighlights(),onclick:()=>t.cancelFeature(e),onfocus:()=>t.highlightFeature(e),scale:"s",slot:"actions-end",text:r.createFeaturesSelectionList.discard,title:r.createFeaturesSelectionList.discard}):void 0;return g(w,null,o,i)},this._renderItemContentEnd=({graphic:e})=>{const{workflowAdapter:t}=this,r=t?.isSubmittable(e);return[r?void 0:g("calcite-icon",{class:s.pendingFeatureListIcon,icon:"exclamation-mark-triangle",scale:"s",slot:"content-end"})]},this._renderItemIcon=e=>{if(null!=e?.graphic?.geometry)return g("span",{afterCreate:this._afterItemCreateOrUpdate,afterRemoved:this._afterItemRemoved,afterUpdate:this._afterItemCreateOrUpdate,"data-has-icon":!1,"data-item":e,key:"icon"})},this._afterItemCreateOrUpdate=e=>{this._iconIntersectionObserver?.observe(e)},this._afterItemRemoved=e=>{this._iconIntersectionObserver?.unobserve(e)}}loadDependencies(){return d({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),list:()=>import("@esri/calcite-components/dist/components/calcite-list")})}initialize(){this.workflowAdapter=L(this.workflow)}destroy(){this._iconIntersectionObserver?.disconnect(),this._iconIntersectionObserver=null}render(){const e=this.workflowAdapter;if(!e)return g(w,null,void 0);const t=this.messages,r=e.features.filter(t=>e.isVisible(t)).map((r,o)=>{const i=e.isSubmittable(r),s=i?t.createFeaturesSelectionList.featureReadyToSubmit:t.createFeaturesSelectionList.featureNotReadyToSubmit;return{disabled:!1,id:`${e.getFeatureTitle(r)??o}`,graphic:r,label:s,submittable:i}});return g("div",null,g(m,{level:p(this.headingLevel)},t.createFeaturesSelectionList.heading),g("calcite-list",{label:t.createFeaturesSelectionList.heading},u({enableListScroll:!1,filterEnabled:!1,filterText:"",id:"update-features-pick-list",items:r,messages:{filterPlaceholder:"",noItems:"",noMatches:""},renderIcon:this._renderItemIcon,renderItemTitle:e=>e.label,renderItemLabel:e=>e.id,onItemMouseEnter:e=>this.workflowAdapter?.highlightFeature(e.graphic),onItemMouseLeave:()=>this.workflowAdapter?.clearHighlights(),onItemSelect:e=>this.workflowAdapter?.onSelectFeature(e.graphic),renderItemContentEnd:this._renderItemContentEnd,renderItemActionEnd:this._renderActionEnd})))}};function v(e){return e?.["data-item"]}function I(e){return!!e?.["data-has-icon"]}function k(e,t){e&&(e["data-has-icon"]=t)}function L(e){return n(e)?new c({workflow:e}):a(e)?new l({workflow:e}):null}e([r()],b.prototype,"workflow",void 0),e([r()],b.prototype,"workflowAdapter",void 0),e([r()],b.prototype,"headingLevel",void 0),e([r(),f("esri/widgets/Editor/t9n/Editor")],b.prototype,"messages",void 0),e([r(),f("esri/t9n/common")],b.prototype,"messagesCommon",void 0),b=e([o("esri.widgets.Editor.components.PendingFeatureList")],b);const F=b;export{F as default};
5
+ import{__decorate as e}from"tslib";import{substitute as t}from"../../../intl.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import i from"../../Widget.js";import{css as s}from"../css.js";import{isSplitFeatureWorkflow as n,isCreateFeaturesWorkflow as a}from"../workflowUtils.js";import{CreateFeaturesWorkflowPendingFeatureListAdapter as c}from"./workflowAdapters/pendingFeatureList/CreateFeaturesWorkflowPendingFeatureListAdapter.ts.js";import{SplitFeatureWorkflowPendingFeatureListAdapter as l}from"./workflowAdapters/pendingFeatureList/SplitFeatureWorkflowPendingFeatureListAdapter.js";import{loadCalciteComponents as d}from"../../support/componentsUtils.js";import{Heading as m,incrementHeadingLevel as p}from"../../support/Heading.js";import{ItemList as u}from"../../support/ItemList.js";import{fetchThumbnail as h}from"../../support/symbolPreviewUtils.js";import{messageBundle as f,tsx as g,tsxFragment as w}from"../../support/widget.js";let b=class extends i{constructor(){super(...arguments),this.workflow=null,this.workflowAdapter=null,this.headingLevel=4,this._iconIntersectionObserver=new IntersectionObserver((e,r)=>{e.forEach(async e=>{if(e.isIntersecting){const o=e.target;if(I(o))return void r.unobserve(o);const i=v(o),{graphic:s}=i,n=s.sourceLayer??this.workflowAdapter?.layer;if(!n||!s)return;k(o,!0);const a=i.id?t(this.messages.previewTemplateAriaLabel,{label:i.id}):this.messagesCommon.preview,c=await h(s,n,{ariaLabel:a}).catch(()=>(k(o,!1),null));if(null==c)return;o.appendChild(c)}})}),this.messages=null,this.messagesCommon=null,this._renderActionEnd=({graphic:e})=>{const{workflowAdapter:t,messages:r}=this;if(!t)return;const o=e.geometry?g("calcite-action",{appearance:"transparent",icon:"zoom-to-object",onblur:()=>t.clearHighlights(),onclick:()=>t.zoomToFeature(e),onfocus:()=>t.highlightFeature(e),scale:"s",slot:"actions-end",text:this.messages.zoomTo,title:this.messages.zoomTo}):void 0,i=t.allowCancel?g("calcite-action",{appearance:"transparent",icon:"trash",onblur:()=>t.clearHighlights(),onclick:()=>t.cancelFeature(e),onfocus:()=>t.highlightFeature(e),scale:"s",slot:"actions-end",text:r.createFeaturesSelectionList.discard,title:r.createFeaturesSelectionList.discard}):void 0;return g(w,null,o,i)},this._renderItemContentEnd=({graphic:e})=>{const{workflowAdapter:t}=this,r=t?.isSubmittable(e);return[r?void 0:g("calcite-icon",{class:s.pendingFeatureListIcon,icon:"exclamation-mark-triangle",scale:"s",slot:"content-end"})]},this._renderItemIcon=e=>{if(null!=e?.graphic?.geometry)return g("span",{afterCreate:this._afterItemCreateOrUpdate,afterRemoved:this._afterItemRemoved,afterUpdate:this._afterItemCreateOrUpdate,"data-has-icon":!1,"data-item":e,key:"icon"})},this._afterItemCreateOrUpdate=e=>{this._iconIntersectionObserver?.observe(e)},this._afterItemRemoved=e=>{this._iconIntersectionObserver?.unobserve(e)}}loadDependencies(){return d({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),list:()=>import("@esri/calcite-components/dist/components/calcite-list")})}initialize(){this.workflowAdapter=L(this.workflow)}destroy(){this._iconIntersectionObserver?.disconnect(),this._iconIntersectionObserver=null}render(){const e=this.workflowAdapter;if(!e)return g(w,null,void 0);const t=this.messages,r=e.features.filter(t=>e.isVisible(t)).map((r,o)=>{const i=e.isSubmittable(r),s=i?t.createFeaturesSelectionList.featureReadyToSubmit:t.createFeaturesSelectionList.featureNotReadyToSubmit;return{disabled:!1,id:`${e.getFeatureTitle(r)??o}`,graphic:r,label:s,submittable:i}}),o=n(this.workflow)?t.result:t.createFeaturesSelectionList.heading;return g("div",null,g(m,{level:p(this.headingLevel)},o),g("calcite-list",{label:o},u({enableListScroll:!1,filterEnabled:!1,filterText:"",id:"update-features-pick-list",items:r,messages:{filterPlaceholder:"",noItems:"",noMatches:""},renderIcon:this._renderItemIcon,renderItemTitle:e=>e.label,renderItemLabel:e=>e.id,onItemMouseEnter:e=>this.workflowAdapter?.highlightFeature(e.graphic),onItemMouseLeave:()=>this.workflowAdapter?.clearHighlights(),onItemSelect:e=>this.workflowAdapter?.onSelectFeature(e.graphic),renderItemContentEnd:this._renderItemContentEnd,renderItemActionEnd:this._renderActionEnd})))}};function v(e){return e?.["data-item"]}function I(e){return!!e?.["data-has-icon"]}function k(e,t){e&&(e["data-has-icon"]=t)}function L(e){return a(e)?new c({workflow:e}):n(e)?new l({workflow:e}):null}e([r()],b.prototype,"workflow",void 0),e([r()],b.prototype,"workflowAdapter",void 0),e([r()],b.prototype,"headingLevel",void 0),e([r(),f("esri/widgets/Editor/t9n/Editor")],b.prototype,"messages",void 0),e([r(),f("esri/t9n/common")],b.prototype,"messagesCommon",void 0),b=e([o("esri.widgets.Editor.components.PendingFeatureList")],b);const F=b;export{F 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/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{substitute as e}from"../../../intl/substitute.js";import{css as t}from"../css.js";import{isCreateFeaturesWorkflow as o,isSplitFeatureWorkflow as i,isMergeFeaturesWorkflow as n,isUpdateFeaturesWorkflow as s,isBatchAttributeFormViewModel as a,isUpdateFeatureWorkflow as r}from"../workflowUtils.js";import{loadFooterActionsComponents as l,FooterActions as c}from"./FooterActions.js";import u from"./MergeFeaturesList.js";import{loadNoticesComponents as p,Notices as m}from"./Notices.js";import{loadPanelContentComponents as d,PanelContentSection as f,PanelContentSectionGroup as g,PanelContent as w}from"./PanelContent.js";import h from"./PendingFeatureList.js";import{loadCalciteComponents as k}from"../../support/componentsUtils.js";import{Heading as b,incrementHeadingLevel as v}from"../../support/Heading.js";import{tsx as F,tsxFragment as y}from"../../support/widget.js";import{classes as A}from"../../support/widgetUtils.js";const j=()=>Promise.all([k({"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar"),action:()=>import("@esri/calcite-components/dist/components/calcite-action")}),l(),p(),d()]);function C(e){const{editorViewModel:r,headingLevel:l,messages:p,renderAttachments:d,renderFeatureForm:k,renderBatchAttributeForm:A,renderSketchToolbar:j}=e,{activeFeatureCount:C,activeLeafWorkflow:L,activeWorkflow:T,formViewModel:V}=r;if(!L||!T||!V)return null;const z=a(V),I=o(L)&&!L.data.selectedPendingFeature||i(L)&&!L.activeFeature,x=n(L),B="shouldShowAttachments"in L&&L.shouldShowAttachments&&!z&&!V.activeRelationshipInput&&!V.activeAssociationInput,D=z?V.activeForm.inputs:V.inputs,W=o(L)&&D.every(e=>!e.visible)&&!B,H=null!=r.featureFormViewModel?.activeAssociationInput,P=!I&&!W&&!H,U=s(L)?A:k,E=W?F(f,null,F(h,{headingLevel:l,key:"pending-feature-list",workflow:L})):F(y,null,F(m,{activeFeatureCount:C,messages:p,workflow:T}),x?F(f,{class:t.mergeFeaturesListSection,key:"panel-section-merge"},F(u,{headingLevel:l,key:"merge-features-list",workflow:L})):void 0,F(f,{key:"panel-content-section-main"},F(g,null,I?F(h,{headingLevel:l,key:"pending-feature-list",workflow:L}):U(),B?F("div",{key:"attachments"},F(b,{level:v(l)},p.attachments),d()):null)));return F(y,null,P?M(L,e):void 0,W?j?.():void 0,F(w,{key:"attribute-panel-content"},E),F(c,{buttons:S(e)}))}function M(e,o){const i=[],n="3d"===o.editorViewModel.view?.type;if(o.visibleElements.zoomToButton&&o.editorViewModel.canZoomTo&&i.push(F("calcite-action",{alignment:"center",appearance:"transparent",icon:"zoom-to-object",key:"zoom-to-button",onclick:()=>o.editorViewModel.zoomTo(),scale:"s",text:o.messages.zoomTo,title:o.messages.zoomTo})),r(e)&&e.editorItem.supportsSplitFeatureWorkflow&&!n&&o.onSplit){const{onSplit:e,messages:t}=o;i.push(F("calcite-action",{icon:"split-geometry",key:"split-button",onclick:e,scale:"s",text:t.split,title:t.split}))}if(s(e)&&e.supportsMergeFeaturesWorkflow&&!n&&o.onMerge){const{onMerge:e,messages:t}=o;i.push(F("calcite-action",{icon:"merge",key:"merge-button",onclick:e,scale:"s",text:t.mergeFeatures,title:t.mergeFeatures}))}return i.length>0?F("calcite-action-bar",{class:A(t.sketchContainer,t.updateActionBar),"data-testid":"update-feature-panel-action-bar",expandDisabled:!0,layout:"horizontal"},i):void 0}function S({editorViewModel:t,messages:o,messagesCommon:i,onDelete:n,onDeleteAssociation:s,onSave:a}){const{activeFeatureCount:r,activeLeafWorkflow:l,syncing:c}=t;if(!l)return[];const{page:u}=t;if("viewing-associated-features"===u||"viewing-associated-layers"===u)return[{appearance:"outline",onClick:()=>{const{featureFormViewModel:e}=t;null!=e?.associationId&&(e.associationId=null)},disabled:c,label:i.cancel,type:"button"}];const p=[],m=r>1?o.multiFeature:o.singleFeature,d=!l.allowSave||c,f=e(m[l.saveActionLabel],{count:r});p.push({appearance:"solid",onClick:a,disabled:d,label:f,type:"button"});const g={appearance:"outline",disabled:c,kind:"danger",label:e(m.delete,{count:r}),type:"button"};return t.shouldShowDeleteButton&&!t.featureFormHasAssociation&&n&&p.push({...g,onClick:n}),t.featureFormHasAssociation&&!t.shouldShowDeleteButton&&s&&p.push({...g,onClick:s,label:o.deleteAssociationTitle}),t.featureFormHasAssociation&&t.shouldShowDeleteButton&&s&&n&&p.push({...g,primaryLabel:i.delete,primaryText:i.delete,onClick:n,dropdownItems:[{onClick:s,label:o.deleteAssociationTitle}],type:"split-button"}),p}export{C as UpdateFeaturePanelContent,j as loadUpdateFeaturePanelContentComponents};
5
+ import{substitute as e}from"../../../intl/substitute.js";import{css as t}from"../css.js";import{isCreateFeaturesWorkflow as o,isSplitFeatureWorkflow as i,isMergeFeaturesWorkflow as n,isUpdateFeaturesWorkflow as s,isBatchAttributeFormViewModel as a,isUpdateFeatureWorkflow as r}from"../workflowUtils.js";import{loadFooterActionsComponents as l,FooterActions as c}from"./FooterActions.js";import u from"./MergeFeaturesList.js";import{loadNoticesComponents as p,Notices as m}from"./Notices.js";import{loadPanelContentComponents as d,PanelContentSection as f,PanelContentSectionGroup as g,PanelContent as w}from"./PanelContent.js";import k from"./PendingFeatureList.js";import{loadCalciteComponents as b}from"../../support/componentsUtils.js";import{Heading as v,incrementHeadingLevel as h}from"../../support/Heading.js";import{tsx as F,tsxFragment as y}from"../../support/widget.js";import{classes as A}from"../../support/widgetUtils.js";const j=()=>Promise.all([b({"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar"),action:()=>import("@esri/calcite-components/dist/components/calcite-action")}),l(),p(),d()]);function C(e){const{editorViewModel:r,headingLevel:l,messages:p,renderAttachments:d,renderFeatureForm:b,renderBatchAttributeForm:A,renderSketchToolbar:j}=e,{activeFeatureCount:C,activeLeafWorkflow:S,activeWorkflow:T,formViewModel:V}=r;if(!S||!T||!V)return null;const z=a(V),I=o(S)&&!S.data.selectedPendingFeature||i(S)&&!S.activeFeature,x=n(S),B=S.shouldShowAttachments&&!z&&!V.activeRelationshipInput&&!V.activeAssociationInput,D=z?V.activeForm.inputs:V.inputs,W=o(S)&&D.every(e=>!e.visible)&&!B,H=null!=r.featureFormViewModel?.activeAssociationInput,P=!I&&!W&&!H,U=s(S)?A:b,E=W?F(f,null,F(k,{headingLevel:l,key:"pending-feature-list",workflow:S})):F(y,null,F(m,{activeFeatureCount:C,messages:p,workflow:T}),x?F(f,{class:t.mergeFeaturesListSection,key:"panel-section-merge"},F(u,{headingLevel:l,key:"merge-features-list",workflow:S})):void 0,F(f,{key:"panel-content-section-main"},F(g,null,I?F(k,{headingLevel:l,key:"pending-feature-list",workflow:S}):U(),B?F("div",{key:"attachments"},F(v,{level:h(l)},p.attachments),d()):null)));return F(y,null,P?M(S,e):void 0,W?j?.():void 0,F(w,{key:"attribute-panel-content"},E),F(c,{buttons:L(e)}))}function M(e,o){const i=[],n="3d"===o.editorViewModel.view?.type;if(o.visibleElements.zoomToButton&&o.editorViewModel.canZoomTo&&i.push(F("calcite-action",{alignment:"center",appearance:"transparent",icon:"zoom-to-object",key:"zoom-to-button",onclick:()=>o.editorViewModel.zoomTo(),scale:"s",text:o.messages.zoomTo,title:o.messages.zoomTo})),r(e)&&e.editorItem.supportsSplitFeatureWorkflow&&!n&&o.onSplit){const{onSplit:e,messages:t}=o;i.push(F("calcite-action",{icon:"split-geometry",key:"split-button",onclick:e,scale:"s",text:t.split,title:t.split}))}if(s(e)&&e.supportsMergeFeaturesWorkflow&&!n&&o.onMerge){const{onMerge:e,messages:t}=o;i.push(F("calcite-action",{icon:"merge",key:"merge-button",onclick:e,scale:"s",text:t.mergeFeatures,title:t.mergeFeatures}))}return i.length>0?F("calcite-action-bar",{class:A(t.sketchContainer,t.updateActionBar),"data-testid":"update-feature-panel-action-bar",expandDisabled:!0,layout:"horizontal"},i):void 0}function L({editorViewModel:t,messages:o,messagesCommon:i,onDelete:n,onDeleteAssociation:s,onSave:a}){const{activeFeatureCount:r,activeLeafWorkflow:l,syncing:c}=t;if(!l)return[];const{page:u}=t;if("viewing-associated-features"===u||"viewing-associated-layers"===u)return[{appearance:"outline",onClick:()=>{const{featureFormViewModel:e}=t;null!=e?.associationId&&(e.associationId=null)},disabled:c,label:i.cancel,type:"button"}];const p=[],m=r>1?o.multiFeature:o.singleFeature,d=!l.allowSave||c,f=e(m[l.saveActionLabel],{count:r});p.push({appearance:"solid",onClick:a,disabled:d,label:f,type:"button"});const g={appearance:"outline",disabled:c,kind:"danger",label:e(m.delete,{count:r}),type:"button"};return t.shouldShowDeleteButton&&!t.featureFormHasAssociation&&n&&p.push({...g,onClick:n}),t.featureFormHasAssociation&&!t.shouldShowDeleteButton&&s&&p.push({...g,onClick:s,label:o.deleteAssociationTitle}),t.featureFormHasAssociation&&t.shouldShowDeleteButton&&s&&n&&p.push({...g,primaryLabel:i.delete,primaryText:i.delete,onClick:n,dropdownItems:[{onClick:s,label:o.deleteAssociationTitle}],type:"split-button"}),p}export{C as UpdateFeaturePanelContent,j as loadUpdateFeaturePanelContentComponents};
package/widgets/Editor.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/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import{substitute as t}from"../intl.js";import{deprecatedFunction as i}from"../core/deprecate.js";import s from"../core/Logger.js";import{destroyMaybe as o,abortMaybe as r,mappedFind as a}from"../core/maybe.js";import{createResolver as n}from"../core/promiseUtils.js";import{watch as l,on as c,when as d,initial as h}from"../core/reactiveUtils.js";import{property as m}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as p}from"../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as u}from"../core/support/UpdatingHandles.js";import g from"../views/interactive/sketch/SketchValueOptions.js";import w from"./Attachments.js";import _ from"./BatchAttributeForm.js";import v from"./FeatureForm.js";import f from"./FeatureTemplates.js";import y from"./Spinner.js";import b from"./Widget.js";import{VisibleElements as k}from"./BatchAttributeForm/VisibleElements.js";import{css as F}from"./Editor/css.js";import A from"./Editor/EditorViewModel.js";import{isModelUpload as M}from"./Editor/modelUploadUtils.js";import T from"./Editor/VisibleElements.js";import{isFeatureFormViewModel as S,isUpdateWorkflow as C,isUpdateFeaturesWorkflow as L,isUpdateFeatureWorkflow as E,isBatchAttributeFormViewModel as W}from"./Editor/workflowUtils.js";import{loadCreateFeaturesPanelContentComponents as P,CreateFeaturesPanelContent as I}from"./Editor/components/CreateFeaturesPanelContent.js";import{loadFeatureListComponents as j,FeatureList as U}from"./Editor/components/FeatureList.js";import{loadFooterActionsComponents as V,FooterActions as D}from"./Editor/components/FooterActions.js";import{loadNoticesComponents as x,Notice as B}from"./Editor/components/Notices.js";import{loadPanelContentComponents as O,PanelContent as N,PanelContentSection as G,PanelContentMessage as H}from"./Editor/components/PanelContent.js";import{PanelToolbar as R,loadPanelToolbarComponents as z}from"./Editor/components/PanelToolbar.js";import{loadPromptComponents as q,Prompt as K}from"./Editor/components/Prompt.js";import{loadUpdateFeaturePanelContentComponents as Z,UpdateFeaturePanelContent as $}from"./Editor/components/UpdateFeaturePanelContent.js";import{loadUploadDetailsComponents as J,UploadDetails as Q}from"./Editor/components/UploadDetails.js";import{CreateToolVisibilityMap as X}from"./Sketch/CreateToolVisibilityMap.js";import{SelectionToolVisibilityMap as Y}from"./Sketch/SelectionToolVisibilityMap.js";import{VisibleElements as ee}from"./Sketch/VisibleElements.js";import{loadCalciteComponents as te}from"./support/componentsUtils.js";import{globalCss as ie}from"./support/globalCss.js";import{incrementHeadingLevel as se,Heading as oe}from"./support/Heading.js";import{renderItem as re}from"./support/ItemList.js";import{connectDelayedLoading as ae}from"./support/loaderUtils.js";import ne from"./support/SelectionList.js";import le from"./support/SelectionToolbar.js";import{messageBundle as ce,vmEvent as de,tsx as he}from"./support/widget.js";import me from"./support/SelectionList/VisibleElements.js";import pe from"./support/SelectionToolbar/VisibleElements.js";const ue=Symbol("sketch-setup-handles");let ge=class extends b{constructor(e,i){super(e,i),this._batchAttributeForm=new _({visibleElements:new k({loadingIndicator:!1})}),this._featureForm=new v,this._sketchToolbar=null,this._attachments=new w({visibleElements:{addSubmitButton:!1,cancelAddButton:!1,cancelUpdateButton:!1,deleteButton:!1,errorMessage:!1,progressBar:!1,updateButton:!1}}),this._associationItemList=null,this._associationSettings=null,this._featureTemplates=new f({enableListScroll:!1,renderItemContentEnd:e=>e.supportsUpload?he("calcite-icon",{class:F.templateItemContentEnd,icon:"upload-to",key:"upload-icon"}):null,renderItemLabel:e=>e.label,renderCustomGroupContent:e=>this._renderCustomTemplateGroupContent(e)}),this._filterText="",this._prompt=null,this._spinner=new y,this._loading=!1,this._selectionList=new ne({displayMode:"layer",itemActionConfigs:this._selectionListItemActionConfigs,onListItemSelect:({item:e})=>this._onSelectionListItemSelect(e),visibleElements:new me({header:!1})}),this._selectionToolbar=new le({visibleElements:new pe({chip:!1})}),this._updatingHandles=new u,this.headingLevel=4,this.messages=null,this.messagesCommon=null,this.messagesTemplates=null,this.messagesFeature=null,this.supportingWidgetDefaults=null,this.viewModel=new A,this.visibleElements=new T,this._renderAttachments=()=>this._attachments.render(),this._renderFeatureForm=()=>this._featureForm.render(),this._renderBatchAttributeForm=()=>this._batchAttributeForm.render(),this._renderFeatureTemplates=()=>this._featureTemplates.render(),this._renderSelectionList=()=>this._selectionList.render(),this._renderSelectionToolbar=()=>this._selectionToolbar.render(),this._renderSketch=()=>this._sketchToolbar?he("div",{class:F.sketchContainer,key:"editor-sketch-container"},this._sketchToolbar?.render()):void 0,this._renderSelectIcon=()=>he("calcite-icon",{icon:"cursor",slot:"content-start"}),this.EditorPanel=({heading:e,key:t,selected:i},...s)=>{const{visibleElements:o}=this;return he("calcite-flow-item",{closable:!1,heading:e,headingLevel:this.headingLevel,key:t,loading:this._loading,selected:i,onCalciteFlowItemBack:this._onBack},o.settingsMenu?he(R,{editorViewModel:this.viewModel,messagesCommon:this.messagesCommon,visibleElements:o}):null,...s)},this._showDiscardEditsPrompt=()=>{const{messages:e,activeWorkflow:t}=this,i={title:e.cancelEditTitle,message:e.cancelEditWarningMessage,yesLabel:e.discardEdits,noLabel:e.continueEditing};return"create-features"===t?.type&&M(t.data.creationInfo)?this._showPromptAndWait("success"===t.data.upload?.state?e.modelUploads.cancelPlacementPrompt:e.modelUploads.cancelUploadPrompt):"update"===t?.type&&S(t.formViewModel)&&t.formViewModel.activeAssociation?this._showPromptAndWait({...i,message:e.cancelAssociationEditWarning}):this._showPromptAndWait(i)},this._showGenericCancelPrompt=()=>{const{messages:e,messagesCommon:t}=this;return this._showPromptAndWait({title:e.cancelRequestTitle,message:e.cancelRequestWarningMessage,yesLabel:t.form.yes,noLabel:t.form.no})},this._showPrompt=e=>{this._prompt?.cancel?.(),this._prompt=e},this._clearPrompt=()=>{this._prompt=null},this._onSave=()=>{this.viewModel.saveWorkflow()},this._onMerge=()=>{const{activeWorkflow:e}=this.viewModel;if(C(e)){const t=e.activeWorkflow;L(t)&&e.startMergingFeatures(t.viewGraphics)}},this._onSplit=()=>{const{activeWorkflow:e}=this.viewModel;if(C(e)){const t=e.activeWorkflow;if(E(t)){const i=t.viewGraphic;i&&e.startSplittingFeature(i)}}},this._onDelete=()=>{const e=this.viewModel.activeFeatureCount,i=e>1?this.messages.multiFeature:this.messages.singleFeature;this._showPrompt({title:i.deleteWarningTitle,message:i.deleteWarningMessage,context:"danger",actions:{primary:{label:t(i.delete,{count:e}),action:()=>{this.deleteFeatures(),this._clearPrompt()}},secondary:{label:i.keep,action:this._clearPrompt}}})},this._onDeleteAssociation=()=>{const{messages:e,messagesCommon:t}=this;this._showPrompt({title:e.deleteAssociationTitle,message:e.deleteAssociationMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{this.deleteAssociationFromWorkflow(),this._clearPrompt()}},secondary:{label:e.keepAssociation,action:this._clearPrompt}}})},this._onToggleUpdateWorkflow=()=>this.viewModel.toggleUpdateWorkflow(),this._onBack=e=>(e?.stopPropagation(),this.viewModel.back()),this._onAttachmentAdd=()=>{const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type||"update"===e.type&&"create-features"===e.activeWorkflow?.type?(this._attachments.addFile(),e.back()):this._attachments.addAttachment().then(()=>e.back()))},this._onAttachmentUpdate=()=>{const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type?(this._attachments.updateFile(),e.back()):this._attachments.updateAttachment().then(()=>e.back()))},this._onAttachmentDelete=()=>{const{messages:e,messagesCommon:t}=this;this._showPrompt({title:e.deleteAttachmentWarningTitle,message:e.deleteAttachmentWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:this._onAttachmentDeleteConfirm},secondary:{label:e.keepAttachment,action:this._clearPrompt}}})},this._onAttachmentDeleteConfirm=async()=>{const e=this._attachments,{activeWorkflow:t}=this.viewModel;t&&("create-features"===t.type?e.deleteFile():(await e.deleteAttachment(e.viewModel.activeAttachmentInfo),this._clearPrompt()),await t.back(),this._clearPrompt())},this._onAttachmentsError=e=>{this._showPrompt({title:this.messages.errorWarningTitle,message:e.message,context:"warning",actions:{primary:{label:this.messagesCommon.form.ok,action:this._clearPrompt}}})}}initialize(){this._featureForm.showPrompt=this._showPrompt,this._featureForm.clearPrompt=this._clearPrompt,this.addHandles([l(()=>se(this.headingLevel),e=>{this._featureForm.headingLevel=e,this._featureTemplates.headingLevel=e},h),c(()=>this.viewModel.activeWorkflow,"cancel-request",({controller:e})=>{(this.viewModel.hasPendingEdits?this._showDiscardEditsPrompt():this._showGenericCancelPrompt()).then(t=>t?e.allow():e.deny())}),d(()=>this.viewModel.formViewModel,e=>{W(e)?this._batchAttributeForm.viewModel=e:this._featureForm.viewModel=e},h),d(()=>this.viewModel.utilityNetworkAssociationAddAssociationViewModel,e=>{this._associationItemList?this._associationItemList.viewModel=e:this._updatingHandles.addPromise(this._initializeAssociationItemList(e))},h),d(()=>this.viewModel.utilityNetworkAssociationAddAssociationViewModel?.association,()=>{this._setUpAssociationSettings()}),l(()=>[this.viewModel,this.viewModel?.attachmentsViewModel,this.viewModel?.featureTemplatesViewModel,this.viewModel?.spinnerViewModel,this.viewModel?.selectionListViewModel,this.viewModel?.selectionToolbarViewModel],([e,t,i,s,o,r])=>{this._attachments.viewModel=t,this._featureTemplates.viewModel=i,this._spinner.viewModel=s,this._selectionList.viewModel=o,this._selectionToolbar.viewModel=r,e.showDiscardEditsPrompt=this._showDiscardEditsPrompt},h),l(()=>this.view,(e,t)=>{const i=`editor-${this.id}-spinner`;t?.ui.remove(this._spinner,i),e?.ui.add(this._spinner,{key:i,position:"manual"}),this._associationItemList&&(this._associationItemList.view=e)},h),l(()=>[this.supportingWidgetDefaults,this.viewModel.sketchViewModel],([e])=>{e&&(this._featureForm.set(e.featureForm),this._attachments.set(e.attachments),this._featureTemplates.set(e.featureTemplates),this.viewModel.sketchViewModel?.set(e.sketch))},h),d(()=>this._attachments?.error,e=>this._onAttachmentsError(e)),d(()=>this._selectionListItemActionConfigs,()=>{this._selectionList.itemActionConfigs=this._selectionListItemActionConfigs}),d(()=>this.viewModel?.failures,e=>{const{messages:i}=this,[{error:s,retry:o,cancel:r}]=e;this._showPrompt({title:i.errorWarningTitle,message:t(i.errorWarningMessageTemplate,{errorMessage:s.message}),context:"warning",actions:{primary:{label:i.retry,action:()=>{o(),this._clearPrompt()}},secondary:{label:i.ignore,action:()=>{r(),this._clearPrompt()}}}})}),l(()=>this.viewModel?.state,e=>{switch(e){case"awaiting-feature-to-update":case"ready":case"disabled":this._filterText="",this._featureTemplates.filterText=""}}),l(()=>this.viewModel.featureFormDisabled,e=>this._featureForm.disabled=e),l(()=>this.visibleElements.sketch,()=>this._setupSketch(),h),ae({getLoading:()=>{const{viewModel:e}=this;return e.syncing||e.updating||this._attachments.submitting||this._updatingHandles.updating},setEffectiveLoading:e=>{this._loading=e}})])}destroy(){this._associationItemList?.destroy(),this._associationSettings?.destroy(),this._selectionList.destroy(),this._selectionToolbar.destroy(),this._attachments.destroy(),this._batchAttributeForm.destroy(),this._featureForm.destroy(),this._featureTemplates.destroy(),this._spinner.destroy(),this._sketchToolbar=o(this._sketchToolbar),this._sketchImportAbortController=r(this._sketchImportAbortController)}loadDependencies(){return Promise.all([te({flow:()=>import("@esri/calcite-components/dist/components/calcite-flow"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),list:()=>import("@esri/calcite-components/dist/components/calcite-list")}),P(),j(),V(),x(),O(),z(),q(),Z(),J()])}get _hasInvalidBatchSelection(){return this._hasSelectionFromMultipleLayers||this._selectionCountExceedsMaximum||0===this._selectionList.visibleFeatureCount}get _hasSelectionFromMultipleLayers(){return this._selectionList.visibleLayerCount>1}get _deleteButtonCommonInfo(){return{appearance:"outline",kind:"danger"}}get _selectionCountExceedsMaximum(){const e=this._batchAttributeForm.maximumFeatureCount,{activeLayerItem:t,effectiveCount:i,filterText:s,visibleFeatureCount:o}=this._selectionList;return null!=s&&""!==s?o>e:t?t.total>e:i>e}get _selectionListItemActionConfigs(){const{messages:e}=this;return[{label:e?.batchEditing?.editThisFeature,icon:"edit-attributes",type:"feature",callback:({item:e})=>this._onSelectionListMenuItemSelect(e,"update")},{label:e?.batchEditing.editTheseFeatures,icon:"edit-attributes",type:"layer",callback:({item:e})=>this._onSelectionListMenuItemSelect(e,"update")},{label:e?.batchEditing.mergeTheseFeatures,icon:"merge",type:"layer",callback:({item:e})=>this._onSelectionListMenuItemSelect(e,"merge")}]}get _visibleSelectionCount(){const{activeLayerItem:e,effectiveCount:t,filterText:i,visibleFeatureCount:s}=this._selectionList;return null!=i&&""!==i?s:e?e.total:t}get activeWorkflow(){return this.viewModel.activeWorkflow}get effectiveSelectionManager(){return this.viewModel.effectiveSelectionManager}get hideTemplatesForInactiveLayers(){return this.viewModel.hideTemplatesForInactiveLayers}set hideTemplatesForInactiveLayers(e){this.viewModel.hideTemplatesForInactiveLayers=e}get icon(){return"pencil"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get labelOptions(){return this.viewModel.labelOptions}set labelOptions(e){this.viewModel.labelOptions=e}get layerInfos(){return this.viewModel.layerInfos}set layerInfos(e){this.viewModel.layerInfos=e}get snappingOptions(){return this.viewModel.snappingOptions}set snappingOptions(e){this.viewModel.snappingOptions=e}get tooltipOptions(){return this.viewModel.tooltipOptions}set tooltipOptions(e){this.viewModel.tooltipOptions=e}get valueOptions(){return this.viewModel.valueOptions}set valueOptions(e){this.viewModel.valueOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.viewModel.startCreateFeaturesWorkflowAtFeatureTypeSelection()}startCreateFeaturesWorkflowAtFeatureCreation(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureCreation(e)}startCreateFeaturesWorkflowAtFeatureEdit(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureEdit(e)}startMergeFeaturesWorkflow(e,t={}){return this.viewModel.startMergeFeaturesWorkflow(e,t)}startSplitFeatureWorkflow(e,t={}){return this.viewModel.startSplitFeatureWorkflow(e,t)}async startUpdateFeaturesWorkflow(e){return this.viewModel.startUpdateFeaturesWorkflow(e)}startUpdateWorkflowAtFeatureSelection(){return this.viewModel.startUpdateWorkflowAtFeatureSelection()}startUpdateWorkflowAtMultipleFeatureSelection(e){return this.viewModel.startUpdateWorkflowAtMultipleFeatureSelection(e)}startUpdateWorkflowAtFeatureEdit(e){return this.viewModel.startUpdateWorkflowAtFeatureEdit(e)}startUpdateWorkflowWithActiveSelection(){return this.viewModel.startUpdateWorkflowWithActiveSelection()}deleteFeatureFromWorkflow(){return i(s.getLogger(this),"Editor.deleteFeatureFromWorkflow is deprecated. Use Editor.deleteFeatures instead.",{version:"4.33",replacement:"Editor.deleteFeatures",warnOnce:!0}),this.deleteFeatures()}async deleteFeatures(){await this.viewModel.deleteFeatures()}deleteAssociationFromWorkflow(){return this.viewModel.deleteAssociationFromWorkflow()}cancelWorkflow(e){return this.viewModel.cancelWorkflow(e)}render(){const{visibleElements:e,viewModel:t}=this,i=this.classes(F.base,ie.widget,ie.panel);if(!t)return he("div",{class:i,key:"empty"});const{pageStack:s}=t,o=s.length-1,r=s.map((e,t)=>this._renderPage(e,t===o));return he("div",{class:i,key:"base"},e.flow?he("calcite-flow",{inert:!!this._prompt,key:"flow"},r):r,this._prompt?he(K,{...this._prompt,headingLevel:this.headingLevel}):void 0)}_renderPage(e,t){const i={selected:t};switch(e){case"disabled":break;case"ready":return this._renderReady(i);case"viewing-selection-list":return this._renderSelectionListPage(i);case"awaiting-feature-creation-info":return this._renderAwaitingFeatureCreationInfo(i);case"creating-features-upload-details":return this._renderUploadDetails(i);case"creating-features":return this._renderCreatingFeatures(i);case"editing-existing-feature":case"editing-features":case"editing-attributes":case"choosing-key-feature":return this._renderUpdateFeature(i);case"awaiting-update-feature-candidate":return this._renderFeatureList(i);case"adding-attachment":return this._renderAttachmentAdding(i);case"editing-attachment":return this._renderAttachmentEditing(i);case"viewing-associated-layers":case"viewing-associated-features":return this._renderViewAssociatedLayers(i);case"add-association-select-layer":case"add-association-select-feature":return this._renderSelectFeature(i);case"add-association-create-association":return this._renderAddAssociation(i);case"drawing-splitter-geometry":return this._renderDrawingSplitGeometry(i);case"reviewing-features":return this._renderReviewingSplitFeatures(i)}return he("div",{key:"empty-page"})}_renderAwaitingFeatureCreationInfo(e){const{EditorPanel:t,messages:i}=this;return he(t,{heading:i.selectTemplate,key:"templates-panel",...e},he(N,{key:"feature-templates"},he(G,null,this._renderFeatureTemplates())))}_renderUploadDetails(e){const{EditorPanel:t,activeWorkflow:i,messages:s}=this;if("create-features"!==i?.type)return null;const o=i.data.upload;return o?he(t,{heading:s.createFeatures,key:"upload-details-panel",...e},he(Q,{helpMessage:this._helpMessage,messages:s,upload:o})):null}_renderCreatingFeatures(e){const{EditorPanel:t,activeWorkflow:i,messages:s,messagesCommon:o,headingLevel:r,viewModel:a}=this;if(!i)return null;const n="create-features"===i.type&&i.numPendingFeatures>0||"update"===i.type&&"create-features"===i?.activeWorkflow?.type&&i.activeWorkflow?.numPendingFeatures>0;return he(t,{heading:s.createFeatures,key:"create-features-panel",...e},n?he($,{editorViewModel:a,headingLevel:r,messages:s,messagesCommon:o,renderAttachments:this._renderAttachments,renderBatchAttributeForm:this._renderBatchAttributeForm,renderFeatureForm:this._renderFeatureForm,renderSketchToolbar:this._renderSketch,visibleElements:this.visibleElements,onDelete:this._onDelete,onDeleteAssociation:this._onDeleteAssociation,onSave:this._onSave}):he(I,{helpMessage:this._helpMessage,renderSketchToolbar:this._renderSketch}))}_renderUpdateFeature(e){const{EditorPanel:t,messages:i,messagesCommon:s,headingLevel:o,viewModel:r}=this,a=r.activeFeatureCount>1?i.multiFeature.editPanelTitle:i.singleFeature.editPanelTitle;return he(t,{heading:a,key:"update-feature-panel",...e},he($,{editorViewModel:r,headingLevel:o,messages:i,messagesCommon:s,renderAttachments:this._renderAttachments,renderBatchAttributeForm:this._renderBatchAttributeForm,renderFeatureForm:this._renderFeatureForm,visibleElements:this.visibleElements,onDelete:this._onDelete,onDeleteAssociation:this._onDeleteAssociation,onMerge:this._onMerge,onSave:this._onSave,onSplit:this._onSplit}))}_renderDrawingSplitGeometry(e){const{EditorPanel:t}=this;return he(t,{heading:this.messages.splitFeature,key:"draw-split-geometry-panel",...e},he(I,{helpMessage:this._helpMessage,renderSketchToolbar:this._renderSketch}))}_renderReviewingSplitFeatures(e){const{EditorPanel:t,messages:i,messagesCommon:s,headingLevel:o,viewModel:r}=this;return he(t,{heading:i.splitFeature,key:"review-split-features-panel",...e},he($,{editorViewModel:r,headingLevel:o,messages:i,messagesCommon:s,renderAttachments:this._renderAttachments,renderBatchAttributeForm:this._renderBatchAttributeForm,renderFeatureForm:this._renderFeatureForm,visibleElements:this.visibleElements,onSave:this._onSave}))}_getAssociationTypeTitle(e){const{messages:t}=this;if(!e)return t.singleFeature.editPanelTitle;if(e.title)return e.title;const{messagesFeature:i}=this;switch(e.type){case"attachment":return i.associationsAttachments;case"connectivity":return i.associationsConnectivity;case"structure":return i.associationsStructure;case"content":return i.associationsContents;case"container":return i.associationsContainer}}_getAddAssociationTypeTitle(e){const{messages:t}=this;if(!e)return t.singleFeature.editPanelTitle;const i=t.associations;switch(e.type){case"attachment":return i.addAttachment;case"connectivity":return i.addConnectivity;case"structure":return i.addStructure;case"content":return i.addContent;case"container":return i.addContainer}}async _initializeAssociationItemList(e){const t=(await import("./FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationItemList.js")).default;this._associationItemList=new t({view:this.view,viewModel:e})}async _initializeAssociationSettings(){const e=new(0,(await import("./FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationSettings.js")).default);return this._associationSettings=e,e}_renderViewAssociatedLayers(e){const{EditorPanel:t,messages:i,messagesCommon:s,headingLevel:o,viewModel:r}=this,a=r.featureFormViewModel?.activeAssociationInput?.activeAssociationType,n=this._getAssociationTypeTitle(a);return he(t,{heading:n,key:"viewing-associated-layers-panel",...e},he($,{editorViewModel:r,headingLevel:o,messages:i,messagesCommon:s,renderAttachments:this._renderAttachments,renderBatchAttributeForm:this._renderBatchAttributeForm,renderFeatureForm:this._renderFeatureForm,renderSketchToolbar:this._renderSketch,visibleElements:this.visibleElements,onDelete:this._onDelete,onDeleteAssociation:this._onDeleteAssociation,onSave:this._onSave}))}_renderSelectFeature(e){const{_associationItemList:t,EditorPanel:i,viewModel:s,messagesCommon:o}=this,r=s.utilityNetworkAssociationAddAssociationViewModel,a=this._getAddAssociationTypeTitle(r?.associationType),n="ready"!==r?.state||this.viewModel.featureFormDisabled;return t?he(i,{heading:a,key:"add-association-select-feature",...e},he(N,{key:"select-feature"},he(G,null,t.render())),he(D,{buttons:[t.filterOptionsVisible?{appearance:"solid",label:o.apply,disabled:n,onClick:()=>t.applyFilterOptions(),type:"button"}:void 0,{appearance:"outline",label:o.cancel,disabled:n,onClick:()=>{"update"===s.activeWorkflow?.type&&(r?.reset(),s.activeWorkflow.cancelActiveWorkflow())},type:"button"}]})):he(i,{heading:a,key:"add-association-select-feature",...e})}async _setUpAssociationSettings(){const{viewModel:e}=this,t=this._associationSettings??await this._updatingHandles.addPromise(this._initializeAssociationSettings()),i=e.utilityNetworkAssociationAddAssociationViewModel,s="update"===e.activeWorkflow?.type?e.activeWorkflow:null,o=s?s.activeWorkflow:null,r="add-association"===o?.type?o.sourceFeatureItem:null,a=i?.selectedFeature,n=i?.association,l=i?.utilityNetwork;r&&a&&n&&l&&(t.sourceFeature=r,t.targetFeature=a,t.association=n,t.utilityNetwork=l)}_renderAddAssociation(e){const{_associationSettings:t,EditorPanel:i,viewModel:s,messagesCommon:o}=this;if(!t)return null;const r=s.utilityNetworkAssociationAddAssociationViewModel,a=this._getAddAssociationTypeTitle(r?.associationType),n="ready"!==r?.state;return he(i,{heading:a,key:"add-association",...e},he(N,{key:"add-association-content"},he(G,null,t.render())),he(D,{buttons:[{label:o.add,disabled:n||!r.canAddAssociation,onClick:()=>this._onSave(),type:"button"},{appearance:"outline",label:o.cancel,disabled:n,onClick:()=>{"update"===s.activeWorkflow?.type&&s.activeWorkflow.cancelActiveWorkflow()},type:"button"}]}))}_renderCustomTemplateGroupContent(e){const{messages:t,viewModel:i}=this,s=a(e.group.items,e=>i.itemHasInvalidFormTemplate(e)?t.formFieldCreateError:void 0);return s?he(B,{kind:"warning",message:s}):null}_renderAttachmentAdding(e){const{EditorPanel:t,_attachments:i,messages:s,messagesCommon:o}=this;return he(t,{heading:s.addAttachment,key:"attachment-adding-panel",...e},he(N,{key:"attachments"},this._renderAttachments()),he(D,{buttons:[{label:i.submitting?o.cancel:o.add,disabled:i.submitting||!i.selectedFile,onClick:this._onAttachmentAdd,type:"button"}]}))}_renderSelectionListPage(e){const{_hasSelectionFromMultipleLayers:i,_hasInvalidBatchSelection:s,_selectionCountExceedsMaximum:o,_selectionList:r,_visibleSelectionCount:a,messages:n,EditorPanel:l}=this,{batchUpdateActions:c}=this.visibleElements,{maxVisibleFeatureCountPerLayer:d}=r;return he(l,{heading:n.widgetLabel,key:"selection-list-panel",...e},this.visibleElements.selectionToolbar&&"3d"!==this.view?.type?he("div",{class:F.selectionToolbarContainer},this._renderSelectionToolbar()):void 0,he(N,{key:"selection-list"},he(G,null,this._renderSelectionList())),he(D,{buttons:[c?{label:t(n.batchEditing.editCount,{count:a}),disabled:s,onClick:()=>this.startUpdateWorkflowWithActiveSelection(),type:"button"}:void 0],notice:c&&i?{text:n.batchEditing.selectOneLayer,icon:"information"}:c&&o?{text:t(this.messages.multiFeature.formFailedToLoadTooManyFeatures,{num:d}),icon:"information"}:void 0}))}_renderAttachmentEditing(e){const{EditorPanel:t,_attachments:i,activeWorkflow:s,messages:o,messagesCommon:r}=this;return s?he(t,{heading:o.editAttachment,key:"attachment-editing-panel",...e},he(N,{key:"attachments"},this._renderAttachments()),s.shouldAllowAttachmentEditing?he(D,{buttons:[{label:r.update,disabled:i.submitting||!i.selectedFile,onClick:this._onAttachmentUpdate,type:"button"},{...this._deleteButtonCommonInfo,onClick:this._onAttachmentDelete,disabled:i.submitting,label:r.delete,type:"button"}]}):void 0):null}_renderReady(e){const{EditorPanel:t,messages:i,viewModel:s,visibleElements:o}=this,r=this._helpMessage;return he(t,{heading:i.widgetLabel,key:"landing-panel",...e},he(N,{key:"landing-content"},s.editorItems.length?[o.editFeaturesSection?he(G,{key:"edit-actions"},this._renderUpdateActions()):null,o.createFeaturesSection&&s.canCreateVisible?he(G,{key:"create-actions"},this._renderCreateActions()):null]:he(H,{key:"no-content"},i.noEditableLayers)),r?he("div",{class:F.helpMessage,key:"footer-actions",slot:"footer"},r):void 0)}get _helpMessage(){const{activeWorkflow:e,messages:t,view:i}=this,s=e?.helpMessage;return s?t["3d"===i?.type?"helpMessages3d":"helpMessages2d"]?.[s]:void 0}_renderUpdateActions(){const{messages:e,messagesCommon:t,viewModel:i}=this,s={id:"select",label:t.select};return he("div",{class:F.updateActions,key:"update-actions"},he(oe,{level:se(this.headingLevel)},e.editFeatures),this.visibleElements.selectionToolbar&&"3d"!==this.view?.type?he("div",{class:F.selectionToolbarContainer},this._renderSelectionToolbar()):he("calcite-list",{class:F.updateActionsList,label:e.editFeaturesList,selectionAppearance:"border",selectionMode:"single"},re({disabled:!i.canUpdateVisible,grouped:!1,item:s,selectedItem:"awaiting-feature-to-update"===i.activeWorkflow?.stepId?s:void 0,renderIcon:this._renderSelectIcon,onItemSelect:this._onToggleUpdateWorkflow})))}_renderCreateActions(){return he("div",{key:"create-actions"},he(oe,{level:se(this.headingLevel)},this.messages.createFeatures),he("div",{class:F.featureTemplatesContainer,key:"templates"},this._renderFeatureTemplates()))}_renderFeatureList(e){const{EditorPanel:i,viewModel:s}=this,{activeWorkflow:o}=s;if("update"!==o?.type)return null;const r=o.data.candidates,a=t(this.messages.multipleFeaturesTemplate,{total:r.length});return he(i,{heading:a,key:"feature-list",...e},he(U,{editorItems:s.editorItems,editorMessages:this.messages,filterText:this._filterText,id:this.id,messagesTemplates:this.messagesTemplates,workflow:o,onFilterTextChange:e=>this._filterText=e,onSelectFeature:(e,t)=>s.selectFeature(e,t),onZoomTo:e=>s.zoomTo(e)}))}_showPromptAndWait({title:e,message:t,yesLabel:i,noLabel:s}){const o=n(),{view:r}=this,a=r?.focused;return this._showPrompt({title:e,message:t,context:"danger",actions:{primary:{label:i,action:()=>o.resolve(!0)},secondary:{label:s,action:()=>o.resolve(!1)}}}),o.promise.finally(()=>{this._clearPrompt(),a&&r?.focus()})}async _onSelectionListItemSelect(e){await this.viewModel.onSelectionListItemSelect(e)}async _onSelectionListMenuItemSelect(e,t){await this.viewModel.onSelectionListMenuItemSelect(e,t)}async _setupSketch(){if(!!!this.visibleElements.sketch)return this._sketchImportAbortController=r(this._sketchImportAbortController),this._sketchToolbar=o(this._sketchToolbar),void this.removeHandles(ue);if(this._sketchImportAbortController)return;const e=new AbortController;this._sketchImportAbortController=e;const t=await import("./Sketch.js");if(!e.signal.aborted)try{this._sketchToolbar=new t.default({toolbarKind:"docked",contextualToolLocation:"inline-end",scale:"s",visibleElements:new ee({deleteButton:!1,settingsMenu:!1,directionModePicker:!1,selectionCountLabel:!1,duplicateButton:!1,createTools:new X({freehandPolygon:!0,freehandPolyline:!0}),selectionTools:new Y({"lasso-selection":!1,"rectangle-selection":!1})})}),this.addHandles([l(()=>{const e=this.viewModel.activeLeafWorkflow;return e&&"availableCreateTools"in e?e.availableCreateTools:null},e=>{this._sketchToolbar&&(this._sketchToolbar.availableCreateTools=e)},h),l(()=>this.visibleElements.undoRedoButtons,e=>{this._sketchToolbar&&(this._sketchToolbar.visibleElements.undoRedoMenu=e)},h),d(()=>this.viewModel?.sketchViewModel,e=>{this._sketchToolbar&&(this._sketchToolbar.viewModel=e)},h)],ue)}finally{this._sketchImportAbortController=null}}get test(){return{sketch:this._sketchToolbar,showPrompt:this._showPromptAndWait.bind(this)}}};e([m()],ge.prototype,"_batchAttributeForm",void 0),e([m()],ge.prototype,"_featureForm",void 0),e([m()],ge.prototype,"_sketchToolbar",void 0),e([m()],ge.prototype,"_attachments",void 0),e([m()],ge.prototype,"_associationItemList",void 0),e([m()],ge.prototype,"_associationSettings",void 0),e([m()],ge.prototype,"_featureTemplates",void 0),e([m()],ge.prototype,"_filterText",void 0),e([m()],ge.prototype,"_hasInvalidBatchSelection",null),e([m()],ge.prototype,"_hasSelectionFromMultipleLayers",null),e([m()],ge.prototype,"_prompt",void 0),e([m()],ge.prototype,"_spinner",void 0),e([m()],ge.prototype,"_deleteButtonCommonInfo",null),e([m()],ge.prototype,"_loading",void 0),e([m()],ge.prototype,"_selectionCountExceedsMaximum",null),e([m()],ge.prototype,"_selectionList",void 0),e([m()],ge.prototype,"_selectionListItemActionConfigs",null),e([m()],ge.prototype,"_selectionToolbar",void 0),e([m()],ge.prototype,"_visibleSelectionCount",null),e([m({readOnly:!0})],ge.prototype,"activeWorkflow",null),e([m()],ge.prototype,"effectiveSelectionManager",null),e([m()],ge.prototype,"headingLevel",void 0),e([m()],ge.prototype,"hideTemplatesForInactiveLayers",null),e([m()],ge.prototype,"icon",null),e([m()],ge.prototype,"label",null),e([m()],ge.prototype,"labelOptions",null),e([m()],ge.prototype,"layerInfos",null),e([m(),ce("esri/widgets/Editor/t9n/Editor")],ge.prototype,"messages",void 0),e([m(),ce("esri/t9n/common")],ge.prototype,"messagesCommon",void 0),e([m(),ce("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],ge.prototype,"messagesTemplates",void 0),e([m(),ce("esri/widgets/Feature/t9n/Feature")],ge.prototype,"messagesFeature",void 0),e([m()],ge.prototype,"snappingOptions",null),e([m()],ge.prototype,"tooltipOptions",null),e([m()],ge.prototype,"supportingWidgetDefaults",void 0),e([m({type:g,nonNullable:!0})],ge.prototype,"valueOptions",null),e([m()],ge.prototype,"view",null),e([m(),de(["sketch-create","sketch-delete","sketch-update","workflow-cancel","workflow-commit"])],ge.prototype,"viewModel",void 0),e([m({type:T,nonNullable:!0})],ge.prototype,"visibleElements",void 0),e([m()],ge.prototype,"_helpMessage",null),ge=e([p("esri.widgets.Editor")],ge);const we=ge;export{we as default};
5
+ import{__decorate as e}from"tslib";import{substitute as t}from"../intl.js";import{deprecatedFunction as i}from"../core/deprecate.js";import s from"../core/Logger.js";import{destroyMaybe as o,abortMaybe as r,mappedFind as a}from"../core/maybe.js";import{createResolver as n}from"../core/promiseUtils.js";import{watch as l,on as c,when as d,initial as h}from"../core/reactiveUtils.js";import{property as m}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as p}from"../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as u}from"../core/support/UpdatingHandles.js";import g from"../views/interactive/sketch/SketchValueOptions.js";import w from"./Attachments.js";import _ from"./BatchAttributeForm.js";import v from"./FeatureForm.js";import f from"./FeatureTemplates.js";import y from"./Spinner.js";import b from"./Widget.js";import{VisibleElements as k}from"./BatchAttributeForm/VisibleElements.js";import{css as F}from"./Editor/css.js";import M from"./Editor/EditorViewModel.js";import{isModelUpload as A}from"./Editor/modelUploadUtils.js";import T from"./Editor/VisibleElements.js";import{isFeatureFormViewModel as S,isUpdateWorkflow as C,isUpdateFeaturesWorkflow as L,isUpdateFeatureWorkflow as E,isBatchAttributeFormViewModel as W}from"./Editor/workflowUtils.js";import{loadCreateFeaturesPanelContentComponents as P,CreateFeaturesPanelContent as I}from"./Editor/components/CreateFeaturesPanelContent.js";import{loadFeatureListComponents as j,FeatureList as U}from"./Editor/components/FeatureList.js";import{loadFooterActionsComponents as V,FooterActions as D}from"./Editor/components/FooterActions.js";import{loadNoticesComponents as x,Notice as B}from"./Editor/components/Notices.js";import{loadPanelContentComponents as O,PanelContent as N,PanelContentSection as H,PanelContentMessage as G}from"./Editor/components/PanelContent.js";import{PanelToolbar as R,loadPanelToolbarComponents as z}from"./Editor/components/PanelToolbar.js";import{loadPromptComponents as q,Prompt as K}from"./Editor/components/Prompt.js";import{loadUpdateFeaturePanelContentComponents as Z,UpdateFeaturePanelContent as $}from"./Editor/components/UpdateFeaturePanelContent.js";import{loadUploadDetailsComponents as J,UploadDetails as Q}from"./Editor/components/UploadDetails.js";import{CreateToolVisibilityMap as X}from"./Sketch/CreateToolVisibilityMap.js";import{SelectionToolVisibilityMap as Y}from"./Sketch/SelectionToolVisibilityMap.js";import{VisibleElements as ee}from"./Sketch/VisibleElements.js";import{loadCalciteComponents as te}from"./support/componentsUtils.js";import{globalCss as ie}from"./support/globalCss.js";import{incrementHeadingLevel as se,Heading as oe}from"./support/Heading.js";import{renderItem as re}from"./support/ItemList.js";import{connectDelayedLoading as ae}from"./support/loaderUtils.js";import ne from"./support/SelectionList.js";import le from"./support/SelectionToolbar.js";import{messageBundle as ce,vmEvent as de,tsx as he}from"./support/widget.js";import me from"./support/SelectionList/VisibleElements.js";import pe from"./support/SelectionToolbar/VisibleElements.js";const ue=Symbol("sketch-setup-handles");let ge=class extends b{constructor(e,i){super(e,i),this._batchAttributeForm=new _({visibleElements:new k({loadingIndicator:!1})}),this._featureForm=new v,this._sketchToolbar=null,this._attachments=new w({visibleElements:{addSubmitButton:!1,cancelAddButton:!1,cancelUpdateButton:!1,deleteButton:!1,errorMessage:!1,progressBar:!1,updateButton:!1}}),this._associationItemList=null,this._associationSettings=null,this._featureTemplates=new f({enableListScroll:!1,renderItemContentEnd:e=>e.supportsUpload?he("calcite-icon",{class:F.templateItemContentEnd,icon:"upload-to",key:"upload-icon"}):null,renderItemLabel:e=>e.label,renderCustomGroupContent:e=>this._renderCustomTemplateGroupContent(e)}),this._filterText="",this._prompt=null,this._spinner=new y,this._loading=!1,this._selectionList=new ne({displayMode:"layer",itemActionConfigs:this._selectionListItemActionConfigs,onListItemSelect:({item:e})=>this._onSelectionListItemSelect(e),visibleElements:new me({header:!1})}),this._selectionToolbar=new le({visibleElements:new pe({chip:!1})}),this._updatingHandles=new u,this.headingLevel=4,this.messages=null,this.messagesCommon=null,this.messagesTemplates=null,this.messagesFeature=null,this.supportingWidgetDefaults=null,this.viewModel=new M,this.visibleElements=new T,this._renderAttachments=()=>this._attachments.render(),this._renderFeatureForm=()=>this._featureForm.render(),this._renderBatchAttributeForm=()=>this._batchAttributeForm.render(),this._renderFeatureTemplates=()=>this._featureTemplates.render(),this._renderSelectionList=()=>this._selectionList.render(),this._renderSelectionToolbar=()=>this._selectionToolbar.render(),this._renderSketch=()=>this._sketchToolbar?he("div",{class:F.sketchContainer,key:"editor-sketch-container"},this._sketchToolbar?.render()):void 0,this._renderSelectIcon=()=>he("calcite-icon",{icon:"cursor",slot:"content-start"}),this.EditorPanel=({heading:e,key:t,selected:i},...s)=>{const{visibleElements:o}=this;return he("calcite-flow-item",{closable:!1,heading:e,headingLevel:this.headingLevel,key:t,loading:this._loading,selected:i,onCalciteFlowItemBack:this._onBack},o.settingsMenu?he(R,{editorViewModel:this.viewModel,messagesCommon:this.messagesCommon,visibleElements:o}):null,...s)},this._showDiscardEditsPrompt=()=>{const{messages:e,activeWorkflow:t}=this,i={title:e.cancelEditTitle,message:e.cancelEditWarningMessage,yesLabel:e.discardEdits,noLabel:e.continueEditing};return"create-features"===t?.type&&A(t.data.creationInfo)?this._showPromptAndWait("success"===t.data.upload?.state?e.modelUploads.cancelPlacementPrompt:e.modelUploads.cancelUploadPrompt):"update"===t?.type&&S(t.formViewModel)&&t.formViewModel.activeAssociation?this._showPromptAndWait({...i,message:e.cancelAssociationEditWarning}):this._showPromptAndWait(i)},this._showGenericCancelPrompt=()=>{const{messages:e,messagesCommon:t}=this;return this._showPromptAndWait({title:e.cancelRequestTitle,message:e.cancelRequestWarningMessage,yesLabel:t.form.yes,noLabel:t.form.no})},this._showPrompt=e=>{this._prompt?.cancel?.(),this._prompt=e},this._clearPrompt=()=>{this._prompt=null},this._onSave=()=>{this.viewModel.saveWorkflow()},this._onMerge=()=>{const{activeWorkflow:e}=this.viewModel;if(C(e)){const t=e.activeWorkflow;L(t)&&e.startMergingFeatures(t.viewGraphics)}},this._onSplit=()=>{const{activeWorkflow:e}=this.viewModel;if(C(e)){const t=e.activeWorkflow;if(E(t)){const i=t.viewGraphic;i&&e.startSplittingFeature(i)}}},this._onDelete=()=>{const e=this.viewModel.activeFeatureCount,i=e>1?this.messages.multiFeature:this.messages.singleFeature;this._showPrompt({title:i.deleteWarningTitle,message:i.deleteWarningMessage,context:"danger",actions:{primary:{label:t(i.delete,{count:e}),action:()=>{this.deleteFeatures(),this._clearPrompt()}},secondary:{label:i.keep,action:this._clearPrompt}}})},this._onDeleteAssociation=()=>{const{messages:e,messagesCommon:t}=this;this._showPrompt({title:e.deleteAssociationTitle,message:e.deleteAssociationMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{this.deleteAssociationFromWorkflow(),this._clearPrompt()}},secondary:{label:e.keepAssociation,action:this._clearPrompt}}})},this._onToggleUpdateWorkflow=()=>this.viewModel.toggleUpdateWorkflow(),this._onBack=e=>(e?.stopPropagation(),this.viewModel.back()),this._onAttachmentAdd=()=>{const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type||"update"===e.type&&"create-features"===e.activeWorkflow?.type?(this._attachments.addFile(),e.back()):this._attachments.addAttachment().then(()=>e.back()))},this._onAttachmentUpdate=()=>{const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type?(this._attachments.updateFile(),e.back()):this._attachments.updateAttachment().then(()=>e.back()))},this._onAttachmentDelete=()=>{const{messages:e,messagesCommon:t}=this;this._showPrompt({title:e.deleteAttachmentWarningTitle,message:e.deleteAttachmentWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:this._onAttachmentDeleteConfirm},secondary:{label:e.keepAttachment,action:this._clearPrompt}}})},this._onAttachmentDeleteConfirm=async()=>{const e=this._attachments,{activeWorkflow:t}=this.viewModel;t&&("create-features"===t.type?e.deleteFile():(await e.deleteAttachment(e.viewModel.activeAttachmentInfo),this._clearPrompt()),await t.back(),this._clearPrompt())},this._onAttachmentsError=e=>{this._showPrompt({title:this.messages.errorWarningTitle,message:e.message,context:"warning",actions:{primary:{label:this.messagesCommon.form.ok,action:this._clearPrompt}}})}}initialize(){this._featureForm.showPrompt=this._showPrompt,this._featureForm.clearPrompt=this._clearPrompt,this.addHandles([l(()=>se(this.headingLevel),e=>{this._featureForm.headingLevel=e,this._featureTemplates.headingLevel=e},h),c(()=>this.viewModel.activeWorkflow,"cancel-request",({controller:e})=>{(this.viewModel.hasPendingEdits?this._showDiscardEditsPrompt():this._showGenericCancelPrompt()).then(t=>t?e.allow():e.deny())}),d(()=>this.viewModel.formViewModel,e=>{W(e)?this._batchAttributeForm.viewModel=e:this._featureForm.viewModel=e},h),d(()=>this.viewModel.utilityNetworkAssociationAddAssociationViewModel,e=>{this._associationItemList?this._associationItemList.viewModel=e:this._updatingHandles.addPromise(this._initializeAssociationItemList(e))},h),d(()=>this.viewModel.utilityNetworkAssociationAddAssociationViewModel?.association,()=>{this._setUpAssociationSettings()}),l(()=>[this.viewModel,this.viewModel?.attachmentsViewModel,this.viewModel?.featureTemplatesViewModel,this.viewModel?.spinnerViewModel,this.viewModel?.selectionListViewModel,this.viewModel?.selectionToolbarViewModel],([e,t,i,s,o,r])=>{this._attachments.viewModel=t,this._featureTemplates.viewModel=i,this._spinner.viewModel=s,this._selectionList.viewModel=o,this._selectionToolbar.viewModel=r,e.showDiscardEditsPrompt=this._showDiscardEditsPrompt},h),l(()=>this.view,(e,t)=>{const i=`editor-${this.id}-spinner`;t?.ui.remove(this._spinner,i),e?.ui.add(this._spinner,{key:i,position:"manual"}),this._associationItemList&&(this._associationItemList.view=e)},h),l(()=>[this.supportingWidgetDefaults,this.viewModel.sketchViewModel],([e])=>{e&&(this._featureForm.set(e.featureForm),this._attachments.set(e.attachments),this._featureTemplates.set(e.featureTemplates),this.viewModel.sketchViewModel?.set(e.sketch))},h),d(()=>this._attachments?.error,e=>this._onAttachmentsError(e)),d(()=>this._selectionListItemActionConfigs,()=>{this._selectionList.itemActionConfigs=this._selectionListItemActionConfigs}),d(()=>this.viewModel?.failures,e=>{const{messages:i}=this,[{error:s,retry:o,cancel:r}]=e;this._showPrompt({title:i.errorWarningTitle,message:t(i.errorWarningMessageTemplate,{errorMessage:s.message}),context:"warning",actions:{primary:{label:i.retry,action:()=>{o(),this._clearPrompt()}},secondary:{label:i.ignore,action:()=>{r(),this._clearPrompt()}}}})}),l(()=>this.viewModel?.state,e=>{switch(e){case"awaiting-feature-to-update":case"ready":case"disabled":this._filterText="",this._featureTemplates.filterText=""}}),l(()=>this.viewModel.featureFormDisabled,e=>this._featureForm.disabled=e),l(()=>this.visibleElements.sketch,()=>this._setupSketch(),h),ae({getLoading:()=>{const{viewModel:e}=this;return e.syncing||e.updating||this._attachments.submitting||this._updatingHandles.updating},setEffectiveLoading:e=>{this._loading=e}})])}destroy(){this._associationItemList?.destroy(),this._associationSettings?.destroy(),this._selectionList.destroy(),this._selectionToolbar.destroy(),this._attachments.destroy(),this._batchAttributeForm.destroy(),this._featureForm.destroy(),this._featureTemplates.destroy(),this._spinner.destroy(),this._sketchToolbar=o(this._sketchToolbar),this._sketchImportAbortController=r(this._sketchImportAbortController)}loadDependencies(){return Promise.all([te({flow:()=>import("@esri/calcite-components/dist/components/calcite-flow"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),list:()=>import("@esri/calcite-components/dist/components/calcite-list")}),P(),j(),V(),x(),O(),z(),q(),Z(),J()])}get _hasInvalidBatchSelection(){return this._hasSelectionFromMultipleLayers||this._selectionCountExceedsMaximum||0===this._selectionList.visibleFeatureCount}get _hasSelectionFromMultipleLayers(){return this._selectionList.visibleLayerCount>1}get _deleteButtonCommonInfo(){return{appearance:"outline",kind:"danger"}}get _selectionCountExceedsMaximum(){const e=this._batchAttributeForm.maximumFeatureCount,{activeLayerItem:t,effectiveCount:i,filterText:s,visibleFeatureCount:o}=this._selectionList;return null!=s&&""!==s?o>e:t?t.total>e:i>e}get _selectionListItemActionConfigs(){const{messages:e}=this;return[{label:e?.batchEditing?.editThisFeature,icon:"edit-attributes",type:"feature",callback:({item:e})=>this._onSelectionListMenuItemSelect(e,"update")},{label:e?.batchEditing.editTheseFeatures,icon:"edit-attributes",type:"layer",callback:({item:e})=>this._onSelectionListMenuItemSelect(e,"update")},{label:e?.batchEditing.mergeTheseFeatures,icon:"merge",type:"layer",callback:({item:e})=>this._onSelectionListMenuItemSelect(e,"merge")}]}get _visibleSelectionCount(){const{activeLayerItem:e,effectiveCount:t,filterText:i,visibleFeatureCount:s}=this._selectionList;return null!=i&&""!==i?s:e?e.total:t}get activeWorkflow(){return this.viewModel.activeWorkflow}get effectiveSelectionManager(){return this.viewModel.effectiveSelectionManager}get hideTemplatesForInactiveLayers(){return this.viewModel.hideTemplatesForInactiveLayers}set hideTemplatesForInactiveLayers(e){this.viewModel.hideTemplatesForInactiveLayers=e}get icon(){return"pencil"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get labelOptions(){return this.viewModel.labelOptions}set labelOptions(e){this.viewModel.labelOptions=e}get layerInfos(){return this.viewModel.layerInfos}set layerInfos(e){this.viewModel.layerInfos=e}get snappingOptions(){return this.viewModel.snappingOptions}set snappingOptions(e){this.viewModel.snappingOptions=e}get tooltipOptions(){return this.viewModel.tooltipOptions}set tooltipOptions(e){this.viewModel.tooltipOptions=e}get valueOptions(){return this.viewModel.valueOptions}set valueOptions(e){this.viewModel.valueOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.viewModel.startCreateFeaturesWorkflowAtFeatureTypeSelection()}startCreateFeaturesWorkflowAtFeatureCreation(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureCreation(e)}startCreateFeaturesWorkflowAtFeatureEdit(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureEdit(e)}startMergeFeaturesWorkflow(e,t={}){return this.viewModel.startMergeFeaturesWorkflow(e,t)}startSplitFeatureWorkflow(e,t={}){return this.viewModel.startSplitFeatureWorkflow(e,t)}async startUpdateFeaturesWorkflow(e){return this.viewModel.startUpdateFeaturesWorkflow(e)}startUpdateWorkflowAtFeatureSelection(){return this.viewModel.startUpdateWorkflowAtFeatureSelection()}startUpdateWorkflowAtMultipleFeatureSelection(e){return this.viewModel.startUpdateWorkflowAtMultipleFeatureSelection(e)}startUpdateWorkflowAtFeatureEdit(e){return this.viewModel.startUpdateWorkflowAtFeatureEdit(e)}startUpdateWorkflowWithActiveSelection(){return this.viewModel.startUpdateWorkflowWithActiveSelection()}deleteFeatureFromWorkflow(){return i(s.getLogger(this),"Editor.deleteFeatureFromWorkflow is deprecated. Use Editor.deleteFeatures instead.",{version:"4.33",replacement:"Editor.deleteFeatures",warnOnce:!0}),this.deleteFeatures()}async deleteFeatures(){await this.viewModel.deleteFeatures()}deleteAssociationFromWorkflow(){return this.viewModel.deleteAssociationFromWorkflow()}cancelWorkflow(e){return this.viewModel.cancelWorkflow(e)}render(){const{visibleElements:e,viewModel:t}=this,i=this.classes(F.base,ie.widget,ie.panel);if(!t)return he("div",{class:i,key:"empty"});const{pageStack:s}=t,o=s.length-1,r=s.map((e,t)=>this._renderPage(e,t===o));return he("div",{class:i,key:"base"},e.flow?he("calcite-flow",{inert:!!this._prompt,key:"flow"},r):r,this._prompt?he(K,{...this._prompt,headingLevel:this.headingLevel}):void 0)}_renderPage(e,t){const i={selected:t};switch(e){case"disabled":break;case"ready":return this._renderReady(i);case"viewing-selection-list":return this._renderSelectionListPage(i);case"awaiting-feature-creation-info":return this._renderAwaitingFeatureCreationInfo(i);case"creating-features-upload-details":return this._renderUploadDetails(i);case"creating-features":return this._renderCreatingFeatures(i);case"editing-existing-feature":case"editing-features":case"editing-attributes":case"choosing-key-feature":return this._renderUpdateFeature(i);case"awaiting-update-feature-candidate":return this._renderFeatureList(i);case"adding-attachment":return this._renderAttachmentAdding(i);case"editing-attachment":return this._renderAttachmentEditing(i);case"viewing-associated-layers":case"viewing-associated-features":return this._renderViewAssociatedLayers(i);case"add-association-select-layer":case"add-association-select-feature":return this._renderSelectFeature(i);case"add-association-create-association":return this._renderAddAssociation(i);case"drawing-splitter-geometry":return this._renderDrawingSplitGeometry(i);case"reviewing-features":return this._renderReviewingSplitFeatures(i)}return he("div",{key:"empty-page"})}_renderAwaitingFeatureCreationInfo(e){const{EditorPanel:t,messages:i}=this;return he(t,{heading:i.selectTemplate,key:"templates-panel",...e},he(N,{key:"feature-templates"},he(H,null,this._renderFeatureTemplates())))}_renderUploadDetails(e){const{EditorPanel:t,activeWorkflow:i,messages:s}=this;if("create-features"!==i?.type)return null;const o=i.data.upload;return o?he(t,{heading:s.createFeatures,key:"upload-details-panel",...e},he(Q,{helpMessage:this._helpMessage,messages:s,upload:o})):null}_renderCreatingFeatures(e){const{EditorPanel:t,activeWorkflow:i,messages:s,messagesCommon:o,headingLevel:r,viewModel:a}=this;if(!i)return null;const n="create-features"===i.type&&i.numPendingFeatures>0||"update"===i.type&&"create-features"===i?.activeWorkflow?.type&&i.activeWorkflow?.numPendingFeatures>0;return he(t,{heading:s.createFeatures,key:"create-features-panel",...e},n?he($,{editorViewModel:a,headingLevel:r,messages:s,messagesCommon:o,renderAttachments:this._renderAttachments,renderBatchAttributeForm:this._renderBatchAttributeForm,renderFeatureForm:this._renderFeatureForm,renderSketchToolbar:this._renderSketch,visibleElements:this.visibleElements,onDelete:this._onDelete,onDeleteAssociation:this._onDeleteAssociation,onSave:this._onSave}):he(I,{helpMessage:this._helpMessage,renderSketchToolbar:this._renderSketch}))}_renderUpdateFeature(e){const{EditorPanel:t,messages:i,messagesCommon:s,headingLevel:o,viewModel:r}=this,a=r.activeFeatureCount>1?i.multiFeature.editPanelTitle:i.singleFeature.editPanelTitle;return he(t,{heading:a,key:"update-feature-panel",...e},he($,{editorViewModel:r,headingLevel:o,messages:i,messagesCommon:s,renderAttachments:this._renderAttachments,renderBatchAttributeForm:this._renderBatchAttributeForm,renderFeatureForm:this._renderFeatureForm,visibleElements:this.visibleElements,onDelete:this._onDelete,onDeleteAssociation:this._onDeleteAssociation,onMerge:this._onMerge,onSave:this._onSave,onSplit:this._onSplit}))}_renderDrawingSplitGeometry(e){const{EditorPanel:t}=this;return he(t,{heading:this.messages.splitFeature,key:"draw-split-geometry-panel",...e},he(I,{helpMessage:this._helpMessage,noticeMessage:this._noticeMessage,renderSketchToolbar:this._renderSketch}))}_renderReviewingSplitFeatures(e){const{EditorPanel:t,messages:i,messagesCommon:s,headingLevel:o,viewModel:r}=this;return he(t,{heading:i.splitFeature,key:"review-split-features-panel",...e},he($,{editorViewModel:r,headingLevel:o,messages:i,messagesCommon:s,renderAttachments:this._renderAttachments,renderBatchAttributeForm:this._renderBatchAttributeForm,renderFeatureForm:this._renderFeatureForm,visibleElements:this.visibleElements,onSave:this._onSave}))}_getAssociationTypeTitle(e){const{messages:t}=this;if(!e)return t.singleFeature.editPanelTitle;if(e.title)return e.title;const{messagesFeature:i}=this;switch(e.type){case"attachment":return i.associationsAttachments;case"connectivity":return i.associationsConnectivity;case"structure":return i.associationsStructure;case"content":return i.associationsContents;case"container":return i.associationsContainer}}_getAddAssociationTypeTitle(e){const{messages:t}=this;if(!e)return t.singleFeature.editPanelTitle;const i=t.associations;switch(e.type){case"attachment":return i.addAttachment;case"connectivity":return i.addConnectivity;case"structure":return i.addStructure;case"content":return i.addContent;case"container":return i.addContainer}}async _initializeAssociationItemList(e){const t=(await import("./FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationItemList.js")).default;this._associationItemList=new t({view:this.view,viewModel:e})}async _initializeAssociationSettings(){const e=new(0,(await import("./FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationSettings.js")).default);return this._associationSettings=e,e}_renderViewAssociatedLayers(e){const{EditorPanel:t,messages:i,messagesCommon:s,headingLevel:o,viewModel:r}=this,a=r.featureFormViewModel?.activeAssociationInput?.activeAssociationType,n=this._getAssociationTypeTitle(a);return he(t,{heading:n,key:"viewing-associated-layers-panel",...e},he($,{editorViewModel:r,headingLevel:o,messages:i,messagesCommon:s,renderAttachments:this._renderAttachments,renderBatchAttributeForm:this._renderBatchAttributeForm,renderFeatureForm:this._renderFeatureForm,renderSketchToolbar:this._renderSketch,visibleElements:this.visibleElements,onDelete:this._onDelete,onDeleteAssociation:this._onDeleteAssociation,onSave:this._onSave}))}_renderSelectFeature(e){const{_associationItemList:t,EditorPanel:i,viewModel:s,messagesCommon:o}=this,r=s.utilityNetworkAssociationAddAssociationViewModel,a=this._getAddAssociationTypeTitle(r?.associationType),n="ready"!==r?.state||this.viewModel.featureFormDisabled;return t?he(i,{heading:a,key:"add-association-select-feature",...e},he(N,{key:"select-feature"},he(H,null,t.render())),he(D,{buttons:[t.filterOptionsVisible?{appearance:"solid",label:o.apply,disabled:n,onClick:()=>t.applyFilterOptions(),type:"button"}:void 0,{appearance:"outline",label:o.cancel,disabled:n,onClick:()=>{"update"===s.activeWorkflow?.type&&(r?.reset(),s.activeWorkflow.cancelActiveWorkflow())},type:"button"}]})):he(i,{heading:a,key:"add-association-select-feature",...e})}async _setUpAssociationSettings(){const{viewModel:e}=this,t=this._associationSettings??await this._updatingHandles.addPromise(this._initializeAssociationSettings()),i=e.utilityNetworkAssociationAddAssociationViewModel,s="update"===e.activeWorkflow?.type?e.activeWorkflow:null,o=s?s.activeWorkflow:null,r="add-association"===o?.type?o.sourceFeatureItem:null,a=i?.selectedFeature,n=i?.association,l=i?.utilityNetwork;r&&a&&n&&l&&(t.sourceFeature=r,t.targetFeature=a,t.association=n,t.utilityNetwork=l)}_renderAddAssociation(e){const{_associationSettings:t,EditorPanel:i,viewModel:s,messagesCommon:o}=this;if(!t)return null;const r=s.utilityNetworkAssociationAddAssociationViewModel,a=this._getAddAssociationTypeTitle(r?.associationType),n="ready"!==r?.state;return he(i,{heading:a,key:"add-association",...e},he(N,{key:"add-association-content"},he(H,null,t.render())),he(D,{buttons:[{label:o.add,disabled:n||!r.canAddAssociation,onClick:()=>this._onSave(),type:"button"},{appearance:"outline",label:o.cancel,disabled:n,onClick:()=>{"update"===s.activeWorkflow?.type&&s.activeWorkflow.cancelActiveWorkflow()},type:"button"}]}))}_renderCustomTemplateGroupContent(e){const{messages:t,viewModel:i}=this,s=a(e.group.items,e=>i.itemHasInvalidFormTemplate(e)?t.formFieldCreateError:void 0);return s?he(B,{kind:"warning",message:s}):null}_renderAttachmentAdding(e){const{EditorPanel:t,_attachments:i,messages:s,messagesCommon:o}=this;return he(t,{heading:s.addAttachment,key:"attachment-adding-panel",...e},he(N,{key:"attachments"},this._renderAttachments()),he(D,{buttons:[{label:i.submitting?o.cancel:o.add,disabled:i.submitting||!i.selectedFile,onClick:this._onAttachmentAdd,type:"button"}]}))}_renderSelectionListPage(e){const{_hasSelectionFromMultipleLayers:i,_hasInvalidBatchSelection:s,_selectionCountExceedsMaximum:o,_selectionList:r,_visibleSelectionCount:a,messages:n,EditorPanel:l}=this,{batchUpdateActions:c}=this.visibleElements,{maxVisibleFeatureCountPerLayer:d}=r;return he(l,{heading:n.widgetLabel,key:"selection-list-panel",...e},this.visibleElements.selectionToolbar&&"3d"!==this.view?.type?he("div",{class:F.selectionToolbarContainer},this._renderSelectionToolbar()):void 0,he(N,{key:"selection-list"},he(H,null,this._renderSelectionList())),he(D,{buttons:[c?{label:t(n.batchEditing.editCount,{count:a}),disabled:s,onClick:()=>this.startUpdateWorkflowWithActiveSelection(),type:"button"}:void 0],notice:c&&i?{text:n.batchEditing.selectOneLayer,icon:"information"}:c&&o?{text:t(this.messages.multiFeature.formFailedToLoadTooManyFeatures,{num:d}),icon:"information"}:void 0}))}_renderAttachmentEditing(e){const{EditorPanel:t,_attachments:i,activeWorkflow:s,messages:o,messagesCommon:r}=this;return s?he(t,{heading:o.editAttachment,key:"attachment-editing-panel",...e},he(N,{key:"attachments"},this._renderAttachments()),s.shouldAllowAttachmentEditing?he(D,{buttons:[{label:r.update,disabled:i.submitting||!i.selectedFile,onClick:this._onAttachmentUpdate,type:"button"},{...this._deleteButtonCommonInfo,onClick:this._onAttachmentDelete,disabled:i.submitting,label:r.delete,type:"button"}]}):void 0):null}_renderReady(e){const{EditorPanel:t,messages:i,viewModel:s,visibleElements:o}=this,r=this._helpMessage;return he(t,{heading:i.widgetLabel,key:"landing-panel",...e},he(N,{key:"landing-content"},s.editorItems.length?[o.editFeaturesSection?he(H,{key:"edit-actions"},this._renderUpdateActions()):null,o.createFeaturesSection&&s.canCreateVisible?he(H,{key:"create-actions"},this._renderCreateActions()):null]:he(G,{key:"no-content"},i.noEditableLayers)),r?he("div",{class:F.helpMessage,key:"footer-actions",slot:"footer"},r):void 0)}get _helpMessage(){return this.getHelpMessageString(this.activeWorkflow?.helpMessage)}get _noticeMessage(){return this.getHelpMessageString(this.activeWorkflow?.noticeMessage)}_renderUpdateActions(){const{messages:e,messagesCommon:t,viewModel:i}=this,s={id:"select",label:t.select};return he("div",{class:F.updateActions,key:"update-actions"},he(oe,{level:se(this.headingLevel)},e.editFeatures),this.visibleElements.selectionToolbar&&"3d"!==this.view?.type?he("div",{class:F.selectionToolbarContainer},this._renderSelectionToolbar()):he("calcite-list",{class:F.updateActionsList,label:e.editFeaturesList,selectionAppearance:"border",selectionMode:"single"},re({disabled:!i.canUpdateVisible,grouped:!1,item:s,selectedItem:"awaiting-feature-to-update"===i.activeWorkflow?.stepId?s:void 0,renderIcon:this._renderSelectIcon,onItemSelect:this._onToggleUpdateWorkflow})))}_renderCreateActions(){return he("div",{key:"create-actions"},he(oe,{level:se(this.headingLevel)},this.messages.createFeatures),he("div",{class:F.featureTemplatesContainer,key:"templates"},this._renderFeatureTemplates()))}_renderFeatureList(e){const{EditorPanel:i,viewModel:s}=this,{activeWorkflow:o}=s;if("update"!==o?.type)return null;const r=o.data.candidates,a=t(this.messages.multipleFeaturesTemplate,{total:r.length});return he(i,{heading:a,key:"feature-list",...e},he(U,{editorItems:s.editorItems,editorMessages:this.messages,filterText:this._filterText,id:this.id,messagesTemplates:this.messagesTemplates,workflow:o,onFilterTextChange:e=>this._filterText=e,onSelectFeature:(e,t)=>s.selectFeature(e,t),onZoomTo:e=>s.zoomTo(e)}))}_showPromptAndWait({title:e,message:t,yesLabel:i,noLabel:s}){const o=n(),{view:r}=this,a=r?.focused;return this._showPrompt({title:e,message:t,context:"danger",actions:{primary:{label:i,action:()=>o.resolve(!0)},secondary:{label:s,action:()=>o.resolve(!1)}}}),o.promise.finally(()=>{this._clearPrompt(),a&&r?.focus()})}async _onSelectionListItemSelect(e){await this.viewModel.onSelectionListItemSelect(e)}async _onSelectionListMenuItemSelect(e,t){await this.viewModel.onSelectionListMenuItemSelect(e,t)}async _setupSketch(){if(!!!this.visibleElements.sketch)return this._sketchImportAbortController=r(this._sketchImportAbortController),this._sketchToolbar=o(this._sketchToolbar),void this.removeHandles(ue);if(this._sketchImportAbortController)return;const e=new AbortController;this._sketchImportAbortController=e;const t=await import("./Sketch.js");if(!e.signal.aborted)try{this._sketchToolbar=new t.default({toolbarKind:"docked",contextualToolLocation:"inline-end",scale:"s",visibleElements:new ee({deleteButton:!1,settingsMenu:!1,directionModePicker:!1,selectionCountLabel:!1,duplicateButton:!1,createTools:new X({freehandPolygon:!0,freehandPolyline:!0}),selectionTools:new Y({"lasso-selection":!1,"rectangle-selection":!1})})}),this.addHandles([l(()=>{const e=this.viewModel.activeLeafWorkflow;return e&&"availableCreateTools"in e?e.availableCreateTools:null},e=>{this._sketchToolbar&&(this._sketchToolbar.availableCreateTools=e)},h),l(()=>this.visibleElements.undoRedoButtons,e=>{this._sketchToolbar&&(this._sketchToolbar.visibleElements.undoRedoMenu=e)},h),d(()=>this.viewModel?.sketchViewModel,e=>{this._sketchToolbar&&(this._sketchToolbar.viewModel=e)},h)],ue)}finally{this._sketchImportAbortController=null}}getHelpMessageString(e){const{messages:t,view:i}=this;return e?t["3d"===i?.type?"helpMessages3d":"helpMessages2d"]?.[e]:void 0}get test(){return{sketch:this._sketchToolbar,showPrompt:this._showPromptAndWait.bind(this)}}};e([m()],ge.prototype,"_batchAttributeForm",void 0),e([m()],ge.prototype,"_featureForm",void 0),e([m()],ge.prototype,"_sketchToolbar",void 0),e([m()],ge.prototype,"_attachments",void 0),e([m()],ge.prototype,"_associationItemList",void 0),e([m()],ge.prototype,"_associationSettings",void 0),e([m()],ge.prototype,"_featureTemplates",void 0),e([m()],ge.prototype,"_filterText",void 0),e([m()],ge.prototype,"_hasInvalidBatchSelection",null),e([m()],ge.prototype,"_hasSelectionFromMultipleLayers",null),e([m()],ge.prototype,"_prompt",void 0),e([m()],ge.prototype,"_spinner",void 0),e([m()],ge.prototype,"_deleteButtonCommonInfo",null),e([m()],ge.prototype,"_loading",void 0),e([m()],ge.prototype,"_selectionCountExceedsMaximum",null),e([m()],ge.prototype,"_selectionList",void 0),e([m()],ge.prototype,"_selectionListItemActionConfigs",null),e([m()],ge.prototype,"_selectionToolbar",void 0),e([m()],ge.prototype,"_visibleSelectionCount",null),e([m({readOnly:!0})],ge.prototype,"activeWorkflow",null),e([m()],ge.prototype,"effectiveSelectionManager",null),e([m()],ge.prototype,"headingLevel",void 0),e([m()],ge.prototype,"hideTemplatesForInactiveLayers",null),e([m()],ge.prototype,"icon",null),e([m()],ge.prototype,"label",null),e([m()],ge.prototype,"labelOptions",null),e([m()],ge.prototype,"layerInfos",null),e([m(),ce("esri/widgets/Editor/t9n/Editor")],ge.prototype,"messages",void 0),e([m(),ce("esri/t9n/common")],ge.prototype,"messagesCommon",void 0),e([m(),ce("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],ge.prototype,"messagesTemplates",void 0),e([m(),ce("esri/widgets/Feature/t9n/Feature")],ge.prototype,"messagesFeature",void 0),e([m()],ge.prototype,"snappingOptions",null),e([m()],ge.prototype,"tooltipOptions",null),e([m()],ge.prototype,"supportingWidgetDefaults",void 0),e([m({type:g,nonNullable:!0})],ge.prototype,"valueOptions",null),e([m()],ge.prototype,"view",null),e([m(),de(["sketch-create","sketch-delete","sketch-update","workflow-cancel","workflow-commit"])],ge.prototype,"viewModel",void 0),e([m({type:T,nonNullable:!0})],ge.prototype,"visibleElements",void 0),e([m()],ge.prototype,"_helpMessage",null),e([m()],ge.prototype,"_noticeMessage",null),ge=e([p("esri.widgets.Editor")],ge);const we=ge;export{we 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/5.0/esri/copyright.txt for details.
4
4
  */
5
- import has from"../../../core/has.js";import e from"../../../core/Logger.js";import{replace as t}from"../../../core/string.js";import{convertDateFormatToIntlOptions as n,formatDate as r}from"../../../intl/date.js";import{convertNumberFieldFormatToIntlOptions as i,convertNumberFormatToIntlOptions as o,formatNumber as a}from"../../../intl/number.js";import{isRasterPixelValueField as l,featureHasFields as u,isTimeOnlyField as s}from"../../../layers/support/fieldUtils.js";import{supportsFieldConfiguration as f,getEffectiveLayerCapabilities as d}from"../../../layers/support/layerUtils.js";import{formatAnyDate as c,isAnyDateField as p}from"../../../smartMapping/support/utils.js";import{loadArcade as y}from"../../../support/loadArcade.js";import{getTimeZoneFormattingOptions as m}from"../../../time/timeZoneUtils.js";const g="esri.widgets.Feature.support.featureUtils",I=()=>e.getLogger(g),b=/href=(""|'')/gi,h=/(\{([^{\r\n]+)\})/g,F=/'/g,w=/^\s*expression\//i,T=/(\n)/gi,N=/[\u00A0-\u9999<>&]/gim,j=/href\s*=\s*(?:"([^"]+)"|'([^']+)')/gi,C=/^(?:mailto:|tel:)/,Z="relationships/",v=n("short-date-short-time");function L(e){if(null!=e)return(e.sourceLayer||e.layer)??void 0}async function x({type:e,value:t,event:n}){try{return"function"==typeof t?t(n):await t}catch(r){return void I().error("error",`An error occurred when calling the "${e}" function`,{error:r,graphic:n.graphic,value:t})}}function q(e=""){if(e)return!C.test(e.trim().toLowerCase())}function A(e){return!!e&&w.test(e)}function E(e,t){if(!t||!A(t)||!e)return;const n=t.replace(w,"").toLowerCase();return e.find(({name:e})=>e.toLowerCase()===n)}function U({fieldInfo:e,graphic:t}){return!(!e?.fieldName||A(e.fieldName)||be(e.fieldName)||t?.isAggregate||t?.popupTemplate)}function M({expressionInfos:e,fieldInfo:t,graphic:n,isContentFieldInfos:r,layer:i}){if(!t?.fieldName)return null;const o=E(e,t.fieldName);if(o)return o.title||null;if(f(i)&&U({fieldInfo:t,graphic:n})){const e=i.getFieldAlias(t.fieldName);return r?t.label||e||t.fieldName:e||t.fieldName}return t.label||t.fieldName}function k({fieldInfo:e,isContentFieldInfos:t,layer:n}){if(!e?.fieldName)return null;if(f(n)){const r=n?.getFieldConfiguration?.(e.fieldName)?.fieldFormat;return t&&e.fieldFormat||r}return null}function R(e,t){const n=t.get(e.toLowerCase());return`{${n?.fieldName||e}}`}function $(e){return e.replaceAll(b,"")}function D(e,t){const n=O(t,e);return n?n.name:e}function z(e,t){return e&&e.map(e=>D(e,t))}function O(e,t){return e&&"function"==typeof e.getField&&t?e.getField(t)??null:null}function S(e){return`${e}`.trim()}function G({attributes:e,globalAttributes:t,layer:n,text:r,expressionAttributes:i,fieldInfoMap:o}){return r?Q({formattedAttributes:t,template:B(r,{...t,...i,...e},n),fieldInfoMap:o}):""}function Q({formattedAttributes:e,template:n,fieldInfoMap:r}){return S($(t(t(n,e=>R(e,r)),e)))}function P(e,t,n=!1){const r=t[e];if("string"==typeof r){const i="%27",o=(n?encodeURIComponent(r):r).replaceAll(F,i);t[e]=o}}function _(e,t=!1){const n={...e};return Object.keys(n).forEach(e=>P(e,n,t)),n}function H(e,n,r){const i=(n=S(n))&&!n.startsWith("{");return t(e,_(r,i||!1))}function W(e,t){return e.replaceAll(h,(e,n,r)=>{const i=O(t,r);return i?`{${i.name}}`:n})}function B(e,t,n){const r=W(e,n);return r?r.replaceAll(j,(e,n,r)=>H(e,n||r,t)):r}function J(e,t){const n="number"===t?.fieldFormat?.type||t?.format&&null==t.format.dateFormat&&(null!=t.format.places||null!=t.format.digitSeparator);if("string"==typeof e&&n){const t=Number(e);if(!isNaN(t))return t}return e}function K(e){return null!=e&&"object"==typeof e&&"fieldsIndex"in e&&"geometryType"in e&&"getField"in e&&"load"in e&&"loaded"in e&&"objectIdField"in e&&"spatialReference"in e&&"type"in e&&("feature"===e.type||"scene"===e.type||"subtype-group"===e.type||"subtype-sublayer"===e.type||"sublayer"===e.type)&&"when"in e}function V(e){return null!=e&&"object"==typeof e&&"createQuery"in e&&"queryFeatureCount"in e&&"queryObjectIds"in e&&"queryRelatedFeatures"in e&&"queryRelatedFeaturesCount"in e&&"relationships"in e}function X(e){return K(e)&&V(e)}function Y(e){return!(!(e&&"object"==typeof e&&"createQuery"in e&&"getField"in e&&"queryFeatureCount"in e&&"queryFeatures"in e&&"queryObjectIds"in e&&"capabilities"in e&&"fields"in e&&"fieldsIndex"in e&&"type"in e)||"feature"!==e.type&&"subtype-group"!==e.type&&"subtype-sublayer"!==e.type&&"sublayer"!==e.type||!("when"in e))&&("subtype-sublayer"===e.type&&"parent"in e&&e.parent&&"object"==typeof e.parent?"globalIdField"in e.parent:"globalIdField"in e)}function ee(e){return!!e&&"object"==typeof e&&"sourceLayer"in e&&X(e.sourceLayer)}function te(e,t){const{fieldInfos:n,fieldName:r,graphic:u,isContentFieldInfos:s,layer:d,preventPlacesFormatting:p,timeZone:y}=t,m=ie(n,r),g=O(d,r),I=f(d)&&U({fieldInfo:m,graphic:u}),b=I?null:m?.format,h=I?k({fieldInfo:m,layer:d,isContentFieldInfos:s}):null,F="number"===h?.type;if(m&&!l(r)){const t=g?.type,n="date-time"===h?.type,r=m.format?.dateFormat;if("date"===t||"date-only"===t||"time-only"===t||"timestamp-offset"===t||n||r)return c(e,{format:n?void 0:r,fieldFormat:n?h:void 0,fieldType:t,timeZoneOptions:{layerTimeZone:d&&"preferredTimeZone"in d?d.preferredTimeZone:null,viewTimeZone:y,datesInUnknownTimezone:!(!d||!("datesInUnknownTimezone"in d))&&!!d.datesInUnknownTimezone}})}if("string"==typeof e&&l(r)&&b)return ne(e,b);if("string"==typeof(e=J(e,{format:F?void 0:b,fieldFormat:F?h:void 0}))||null==e||null==b&&null==h)return de(e);const w=F?i(h):b?o(b):void 0;return a(e,p?{...w,minimumFractionDigits:0,maximumFractionDigits:20}:w)}function ne(e,t){return e=e.trim(),/\d{2}-\d{2}/.test(e)?e:e.includes(",")?re(e,",",", ",t):e.includes(";")?re(e,";","; ",t):e.includes(" ")?re(e," "," ",t):a(Number(e),o(t))}function re(e,t,n,r){return e.trim().split(t).map(e=>a(Number(e),o(r))).join(n)}function ie(e,t){if(e?.length&&t)return e.find(e=>e.fieldName?.toLowerCase()===t.toLowerCase())}function oe({fieldName:e,graphic:t,layer:n}){if(be(e))return null;if(!n||"function"!=typeof n.getFeatureType)return null;const{typeIdField:r}=n;if(!r||e!==r)return null;const i=n.getFeatureType(t);return i?i.name:null}function ae({fieldName:e,value:t,graphic:n,layer:r}){if(be(e))return null;if(!r||"function"!=typeof r.getFieldDomain)return null;const i=n&&r.getFieldDomain(e,{feature:n,excludeImpliedDomains:has("esri-widget-legacy-field-domain-calculation")});return i&&"coded-value"===i.type?i.getName(t):null}function le(e,t,n,i){const{creatorField:o,creationDateField:a,editorField:l,editDateField:u}=e;if(!t)return;const s=m(i&&"preferredTimeZone"in i?i.preferredTimeZone:null,!(!i||!("datesInUnknownTimezone"in i))&&!!i.datesInUnknownTimezone,n,v,"date"),f={...v,...s},d=t[u];if("number"==typeof d){const e=t[l];return{type:"edit",date:r(d,f),user:e}}const c=t[a];if("number"==typeof c){const e=t[o];return{type:"create",date:r(c,f),user:e}}return null}function ue(e,t){const n=new Map;if(!e)return n;for(const r of e){if(!r.fieldName)continue;const e=D(r.fieldName,t);r.fieldName=e,n.set(e.toLowerCase(),r)}return n}function se(e){const t=[];if(!e)return t;const{fieldInfos:n,content:r}=e;return n&&t.push(...n),r&&Array.isArray(r)?(r.forEach(e=>{if("fields"===e.type){const n=e?.fieldInfos;n&&t.push(...n)}}),t):t}function fe(e){return e.replaceAll(N,e=>`&#${e.charCodeAt(0)};`)}function de(e){return"string"==typeof e?e.replaceAll(T,'<br class="esri-text-new-line" />'):e}function ce(e){const{fieldInfoMap:t,fieldInfos:n,fieldName:r,graphic:i,isContentFieldInfos:o,layer:a,timeZone:l,value:u}=e;if(null==u)return"";const f=ae({fieldName:r,value:u,graphic:i,layer:a});if(f)return f;const d=oe({fieldName:r,graphic:i,layer:a});if(d)return d;if(t.get(r.toLowerCase()))return te(u,{fieldInfos:n||Array.from(t.values()),fieldName:r,graphic:i,isContentFieldInfos:o,layer:a,timeZone:l});const y=a?.fieldsIndex?.get(r);return y&&(p(y)||s(y))?c(u,{fieldType:y.type,timeZoneOptions:{layerTimeZone:a&&"preferredTimeZone"in a?a.preferredTimeZone:null,viewTimeZone:l,datesInUnknownTimezone:!(!a||!("datesInUnknownTimezone"in a))&&!!a.datesInUnknownTimezone}}):de(u)}function pe({attributes:e,fieldInfoMap:t,fieldInfos:n,graphic:r,isContentFieldInfos:i,layer:o,relatedInfos:a,timeZone:l}){const u={};return a?.forEach(e=>we({attributes:u,relatedInfo:e,fieldInfoMap:t,fieldInfos:n,layer:o,timeZone:l})),e&&Object.keys(e).forEach(a=>{const s=e[a];u[a]=ce({fieldInfoMap:t,fieldInfos:n,fieldName:a,graphic:r,isContentFieldInfos:i,layer:o,timeZone:l,value:s})}),u}async function ye(e,t){const{layer:n,graphic:r,outFields:i,objectIds:o,returnGeometry:a,spatialReference:l}=e,u=o[0];if("number"!=typeof u&&"string"!=typeof u){const e="Could not query required fields for the specified feature. The feature's ID is invalid.",t={layer:n,graphic:r,objectId:u,requiredFields:i};return I().warn(e,t),null}if(!d(n)?.operations?.supportsQuery){const e="The specified layer cannot be queried. The following fields will not be available.",t={layer:n,graphic:r,requiredFields:i,returnGeometry:a};return I().warn(e,t),null}const s=n.createQuery();s.objectIds=o,s.outFields=i?.length?i:[n.objectIdField],s.returnGeometry=!!a,s.returnZ=!!a,s.returnM=!!a,s.outSpatialReference=l;return(await n.queryFeatures(s,t)).features[0]}async function me(e){if(!e.expressionInfos?.length)return!1;const t=await y(),{arcadeUtils:{hasGeometryFunctions:n}}=t;return n(e)}async function ge(e){if(!e.expressionInfos?.length)return!1;const t=await y(),{arcadeUtils:{requiresTrack:n}}=t;return n(e)}async function Ie({graphic:e,popupTemplate:t,layer:n,spatialReference:r},i){if(!n||!t)return;if("function"==typeof n.load&&await n.load(i),!e.attributes)return;const o=n.objectIdField,a=e.attributes[o];if(null==a)return;const l=[a],s=new Set(await t.getRequiredFields(n.fieldsIndex));null==n.timeInfo?.trackIdField||s.has(n.timeInfo.trackIdField)||await ge(t)&&s.add(n.timeInfo.trackIdField);const f=u(e,s),d=f?[]:s.has(o)?[...s]:[...s,o],c=t.returnGeometry||await me(t);if(f&&!c)return;const p=await ye({layer:n,graphic:e,outFields:d,objectIds:l,returnGeometry:c,spatialReference:r},i);p&&(p.geometry&&(e.geometry=p.geometry),p.attributes&&(e.attributes={...e.attributes,...p.attributes}))}function be(e=""){return!!e&&e.includes(Z)}function he(e){return e?`${Z}${e.layerId}/${e.fieldName}`:""}function Fe({attributes:e,graphic:t,relatedInfo:n,fieldInfos:r,fieldInfoMap:i,layer:o,timeZone:a}){e&&t&&n&&Object.keys(t.attributes).forEach(l=>{const u=he({layerId:n.relation.id.toString(),fieldName:l}),s=t.attributes[l];e[u]=ce({fieldName:u,fieldInfos:r,fieldInfoMap:i,layer:o,value:s,graphic:t,timeZone:a})})}function we({attributes:e,relatedInfo:t,fieldInfoMap:n,fieldInfos:r,layer:i,timeZone:o}){e&&t&&(t.relatedFeatures?.forEach(a=>Fe({attributes:e,graphic:a,relatedInfo:t,fieldInfoMap:n,fieldInfos:r,layer:i,timeZone:o})),t.relatedStatsFeatures?.forEach(a=>Fe({attributes:e,graphic:a,relatedInfo:t,fieldInfoMap:n,fieldInfos:r,layer:i,timeZone:o})))}const Te=e=>{if(!e)return!1;const t=e.toUpperCase();return t.includes("CURRENT_TIMESTAMP")||t.includes("CURRENT_DATE")||t.includes("CURRENT_TIME")},Ne=({layer:e,method:t,query:n,definitionExpression:r})=>{if(!e.capabilities?.query?.supportsCacheHint||"attachments"===t)return;const i=null!=n.where?n.where:null,o=null!=n.geometry?n.geometry:null;Te(r)||Te(i)||"extent"===o?.type||"tile"===n.resultType||(n.cacheHint=!0)},je=({query:e,layer:t,method:n})=>{Ne({layer:t,method:n,query:e,definitionExpression:`${t.definitionExpression} ${t.serviceDefinitionExpression??""}`})},Ce=({queryPayload:e,layer:t,method:n})=>{Ne({layer:t,method:n,query:e,definitionExpression:`${t.definitionExpression} ${t.serviceDefinitionExpression??""}`})};function Ze(e,t,n){return e&&t&&n?"sublayer"===t.type?xe({layers:t.layer?.allSublayers,map:e,relatedLayer:t,relationship:n})||xe({layers:t.layer?.subtables,map:e,relatedLayer:t,relationship:n}):xe({layers:e.allLayers,map:e,relatedLayer:t,relationship:n})||xe({layers:e.allTables,map:e,relatedLayer:t,relationship:n}):null}function ve(e,t){return e&&"utilityNetworks"in e&&t?e.utilityNetworks?.find(e=>e.isUtilityLayer(t)):null}function Le(e,t){return e?.allTables.find(e=>"feature"===e.type&&e.layerId===t.id&&e.url===t.layer?.url)}function xe({map:e,relationship:t,relationship:{relatedTableId:n},relatedLayer:r,layers:i}){if(!i)return null;for(const o of i){if("map-image"===o.type){const n=xe({layers:o.sublayers,map:e,relatedLayer:r,relationship:t})||xe({layers:o.subtables,map:e,relatedLayer:r,relationship:t});if(n)return n;continue}if(!X(o))continue;if("sublayer"===r.type){if(o!==r&&o.id===n)return o.isTable?Le(e,o):o;continue}const i="scene"===r.type&&r.associatedLayer?r.associatedLayer.url:r.url;if(!i)return null;if("sublayer"!==o.type){if(o!==r&&o.url===i&&o.layerId===n)return o}else if(o!==r&&o.layer?.url===i&&o.id===n)return o.isTable?Le(e,o):o}return null}export{de as applyTextFormattingHTML,ue as createFieldInfoMap,Ze as findRelatedLayer,ve as findUtilityNetwork,W as fixTokens,pe as formatAttributes,le as formatEditInfo,te as formatValueToFieldInfo,se as getAllFieldInfos,k as getFieldFormat,ie as getFieldInfo,M as getFieldInfoLabel,D as getFixedFieldName,z as getFixedFieldNames,L as getSourceLayer,x as graphicCallback,fe as htmlEntities,Y as isAssociatedFeatureSupportedLayer,A as isExpressionField,K as isFeatureSupportedLayer,ee as isGraphicForRelatableFeatureSupportedLayer,X as isRelatableFeatureSupportedLayer,V as isRelatableLayer,be as isRelatedField,U as isSupportedContext,je as preLayerQueryCallback,Ce as preRequestCallback,ye as querySourceLayer,Ie as queryUpdatedFeature,q as shouldOpenInNewTab,Q as substituteAttributes,G as substituteFieldsInLinksAndAttributes};
5
+ import has from"../../../core/has.js";import e from"../../../core/Logger.js";import{replace as t}from"../../../core/string.js";import{convertDateFormatToIntlOptions as n,formatDate as r}from"../../../intl/date.js";import{convertNumberFieldFormatToIntlOptions as i,convertNumberFormatToIntlOptions as o,formatNumber as a}from"../../../intl/number.js";import{fieldFormatFromFieldInfo as l}from"../../../layers/support/fieldFormatUtils.js";import{isRasterPixelValueField as u,featureHasFields as s,isTimeOnlyField as f}from"../../../layers/support/fieldUtils.js";import{supportsFieldConfiguration as d,getEffectiveLayerCapabilities as c}from"../../../layers/support/layerUtils.js";import{formatAnyDate as p,isAnyDateField as y}from"../../../smartMapping/support/utils.js";import{loadArcade as m}from"../../../support/loadArcade.js";import{getTimeZoneFormattingOptions as g}from"../../../time/timeZoneUtils.js";const I="esri.widgets.Feature.support.featureUtils",b=()=>e.getLogger(I),h=/href=(""|'')/gi,F=/(\{([^{\r\n]+)\})/g,w=/'/g,T=/^\s*expression\//i,N=/(\n)/gi,j=/[\u00A0-\u9999<>&]/gim,C=/href\s*=\s*(?:"([^"]+)"|'([^']+)')/gi,Z=/^(?:mailto:|tel:)/,v="relationships/",L=n("short-date-short-time");function x(e){if(null!=e)return(e.sourceLayer||e.layer)??void 0}async function q({type:e,value:t,event:n}){try{return"function"==typeof t?t(n):await t}catch(r){return void b().error("error",`An error occurred when calling the "${e}" function`,{error:r,graphic:n.graphic,value:t})}}function A(e=""){if(e)return!Z.test(e.trim().toLowerCase())}function U(e){return!!e&&T.test(e)}function E(e,t){if(!t||!U(t)||!e)return;const n=t.replace(T,"").toLowerCase();return e.find(({name:e})=>e.toLowerCase()===n)}function M({fieldInfo:e,graphic:t}){return!(!e?.fieldName||U(e.fieldName)||he(e.fieldName)||t?.isAggregate||t?.popupTemplate)}function k({expressionInfos:e,fieldInfo:t,graphic:n,isContentFieldInfos:r,layer:i}){if(!t?.fieldName)return null;const o=E(e,t.fieldName);if(o)return o.title||null;if(d(i)&&M({fieldInfo:t,graphic:n})){const e=i.getFieldAlias(t.fieldName);return r?t.label||e||t.fieldName:e||t.fieldName}return t.label||t.fieldName}function R({fieldInfo:e,isContentFieldInfos:t,layer:n}){if(!e?.fieldName)return null;if(d(n)){const r=n.popupTemplate||n.fieldConfigurations?n.getFieldConfiguration(e.fieldName)?.fieldFormat:l(e,n.getField(e.fieldName));return t&&e.fieldFormat||r}return null}function $(e,t){const n=t.get(e.toLowerCase());return`{${n?.fieldName||e}}`}function D(e){return e.replaceAll(h,"")}function z(e,t){const n=S(t,e);return n?n.name:e}function O(e,t){return e&&e.map(e=>z(e,t))}function S(e,t){return e&&"function"==typeof e.getField&&t?e.getField(t)??null:null}function G(e){return`${e}`.trim()}function Q({attributes:e,globalAttributes:t,layer:n,text:r,expressionAttributes:i,fieldInfoMap:o}){return r?P({formattedAttributes:t,template:J(r,{...t,...i,...e},n),fieldInfoMap:o}):""}function P({formattedAttributes:e,template:n,fieldInfoMap:r}){return G(D(t(t(n,e=>$(e,r)),e)))}function _(e,t,n=!1){const r=t[e];if("string"==typeof r){const i="%27",o=(n?encodeURIComponent(r):r).replaceAll(w,i);t[e]=o}}function H(e,t=!1){const n={...e};return Object.keys(n).forEach(e=>_(e,n,t)),n}function W(e,n,r){const i=(n=G(n))&&!n.startsWith("{");return t(e,H(r,i||!1))}function B(e,t){return e.replaceAll(F,(e,n,r)=>{const i=S(t,r);return i?`{${i.name}}`:n})}function J(e,t,n){const r=B(e,n);return r?r.replaceAll(C,(e,n,r)=>W(e,n||r,t)):r}function K(e,t){const n="number"===t?.fieldFormat?.type||t?.format&&null==t.format.dateFormat&&(null!=t.format.places||null!=t.format.digitSeparator);if("string"==typeof e&&n){const t=Number(e);if(!isNaN(t))return t}return e}function V(e){return null!=e&&"object"==typeof e&&"fieldsIndex"in e&&"geometryType"in e&&"getField"in e&&"load"in e&&"loaded"in e&&"objectIdField"in e&&"spatialReference"in e&&"type"in e&&("feature"===e.type||"scene"===e.type||"subtype-group"===e.type||"subtype-sublayer"===e.type||"sublayer"===e.type)&&"when"in e}function X(e){return null!=e&&"object"==typeof e&&"createQuery"in e&&"queryFeatureCount"in e&&"queryObjectIds"in e&&"queryRelatedFeatures"in e&&"queryRelatedFeaturesCount"in e&&"relationships"in e}function Y(e){return V(e)&&X(e)}function ee(e){return!(!(e&&"object"==typeof e&&"createQuery"in e&&"getField"in e&&"queryFeatureCount"in e&&"queryFeatures"in e&&"queryObjectIds"in e&&"capabilities"in e&&"fields"in e&&"fieldsIndex"in e&&"type"in e)||"feature"!==e.type&&"subtype-group"!==e.type&&"subtype-sublayer"!==e.type&&"sublayer"!==e.type||!("when"in e))&&("subtype-sublayer"===e.type&&"parent"in e&&e.parent&&"object"==typeof e.parent?"globalIdField"in e.parent:"globalIdField"in e)}function te(e){return!!e&&"object"==typeof e&&"sourceLayer"in e&&Y(e.sourceLayer)}function ne(e,t){const{fieldInfos:n,fieldName:r,graphic:l,isContentFieldInfos:s,layer:f,preventPlacesFormatting:c,timeZone:y}=t,m=oe(n,r),g=S(f,r),I=d(f)&&M({fieldInfo:m,graphic:l}),b=I?null:m?.format,h=I?R({fieldInfo:m,layer:f,isContentFieldInfos:s}):null,F="number"===h?.type;if(m&&!u(r)){const t=g?.type,n="date-time"===h?.type,r=b?.dateFormat;if("date"===t||"date-only"===t||"time-only"===t||"timestamp-offset"===t||n||r)return p(e,{format:n?void 0:r,fieldFormat:n?h:void 0,fieldType:t,timeZoneOptions:{layerTimeZone:f&&"preferredTimeZone"in f?f.preferredTimeZone:null,viewTimeZone:y,datesInUnknownTimezone:!(!f||!("datesInUnknownTimezone"in f))&&!!f.datesInUnknownTimezone}})}if("string"==typeof e&&u(r)&&b)return re(e,b);if("string"==typeof(e=K(e,{format:F?void 0:b,fieldFormat:F?h:void 0}))||null==e||null==b&&null==h)return ce(e);const w=F?i(h):b?o(b):void 0;return a(e,c?{...w,minimumFractionDigits:0,maximumFractionDigits:20}:w)}function re(e,t){return e=e.trim(),/\d{2}-\d{2}/.test(e)?e:e.includes(",")?ie(e,",",", ",t):e.includes(";")?ie(e,";","; ",t):e.includes(" ")?ie(e," "," ",t):a(Number(e),o(t))}function ie(e,t,n,r){return e.trim().split(t).map(e=>a(Number(e),o(r))).join(n)}function oe(e,t){if(e?.length&&t)return e.find(e=>e.fieldName?.toLowerCase()===t.toLowerCase())}function ae({fieldName:e,graphic:t,layer:n}){if(he(e))return null;if(!n||"function"!=typeof n.getFeatureType)return null;const{typeIdField:r}=n;if(!r||e!==r)return null;const i=n.getFeatureType(t);return i?i.name:null}function le({fieldName:e,value:t,graphic:n,layer:r}){if(he(e))return null;if(!r||"function"!=typeof r.getFieldDomain)return null;const i=n&&r.getFieldDomain(e,{feature:n,excludeImpliedDomains:has("esri-widget-legacy-field-domain-calculation")});return i&&"coded-value"===i.type?i.getName(t):null}function ue(e,t,n,i){const{creatorField:o,creationDateField:a,editorField:l,editDateField:u}=e;if(!t)return;const s=g(i&&"preferredTimeZone"in i?i.preferredTimeZone:null,!(!i||!("datesInUnknownTimezone"in i))&&!!i.datesInUnknownTimezone,n,L,"date"),f={...L,...s},d=t[u];if("number"==typeof d){const e=t[l];return{type:"edit",date:r(d,f),user:e}}const c=t[a];if("number"==typeof c){const e=t[o];return{type:"create",date:r(c,f),user:e}}return null}function se(e,t){const n=new Map;if(!e)return n;for(const r of e){if(!r.fieldName)continue;const e=z(r.fieldName,t);r.fieldName=e,n.set(e.toLowerCase(),r)}return n}function fe(e){const t=[];if(!e)return t;const{fieldInfos:n,content:r}=e;return n&&t.push(...n),r&&Array.isArray(r)?(r.forEach(e=>{if("fields"===e.type){const n=e?.fieldInfos;n&&t.push(...n)}}),t):t}function de(e){return e.replaceAll(j,e=>`&#${e.charCodeAt(0)};`)}function ce(e){return"string"==typeof e?e.replaceAll(N,'<br class="esri-text-new-line" />'):e}function pe(e){const{fieldInfoMap:t,fieldInfos:n,fieldName:r,graphic:i,isContentFieldInfos:o,layer:a,timeZone:l,value:u}=e;if(null==u)return"";const s=le({fieldName:r,value:u,graphic:i,layer:a});if(s)return s;const d=ae({fieldName:r,graphic:i,layer:a});if(d)return d;if(t.get(r.toLowerCase()))return ne(u,{fieldInfos:n||Array.from(t.values()),fieldName:r,graphic:i,isContentFieldInfos:o,layer:a,timeZone:l});const c=a?.fieldsIndex?.get(r);return c&&(y(c)||f(c))?p(u,{fieldType:c.type,timeZoneOptions:{layerTimeZone:a&&"preferredTimeZone"in a?a.preferredTimeZone:null,viewTimeZone:l,datesInUnknownTimezone:!(!a||!("datesInUnknownTimezone"in a))&&!!a.datesInUnknownTimezone}}):ce(u)}function ye({attributes:e,fieldInfoMap:t,fieldInfos:n,graphic:r,isContentFieldInfos:i,layer:o,relatedInfos:a,timeZone:l}){const u={};return a?.forEach(e=>Te({attributes:u,relatedInfo:e,fieldInfoMap:t,fieldInfos:n,layer:o,timeZone:l})),e&&Object.keys(e).forEach(a=>{const s=e[a];u[a]=pe({fieldInfoMap:t,fieldInfos:n,fieldName:a,graphic:r,isContentFieldInfos:i,layer:o,timeZone:l,value:s})}),u}async function me(e,t){const{layer:n,graphic:r,outFields:i,objectIds:o,returnGeometry:a,spatialReference:l}=e,u=o[0];if("number"!=typeof u&&"string"!=typeof u){const e="Could not query required fields for the specified feature. The feature's ID is invalid.",t={layer:n,graphic:r,objectId:u,requiredFields:i};return b().warn(e,t),null}if(!c(n)?.operations?.supportsQuery){const e="The specified layer cannot be queried. The following fields will not be available.",t={layer:n,graphic:r,requiredFields:i,returnGeometry:a};return b().warn(e,t),null}const s=n.createQuery();s.objectIds=o,s.outFields=i?.length?i:[n.objectIdField],s.returnGeometry=!!a,s.returnZ=!!a,s.returnM=!!a,s.outSpatialReference=l;return(await n.queryFeatures(s,t)).features[0]}async function ge(e){if(!e.expressionInfos?.length)return!1;const t=await m(),{arcadeUtils:{hasGeometryFunctions:n}}=t;return n(e)}async function Ie(e){if(!e.expressionInfos?.length)return!1;const t=await m(),{arcadeUtils:{requiresTrack:n}}=t;return n(e)}async function be({graphic:e,popupTemplate:t,layer:n,spatialReference:r},i){if(!n||!t)return;if("function"==typeof n.load&&await n.load(i),!e.attributes)return;const o=n.objectIdField,a=e.attributes[o];if(null==a)return;const l=[a],u=new Set(await t.getRequiredFields(n.fieldsIndex));null==n.timeInfo?.trackIdField||u.has(n.timeInfo.trackIdField)||await Ie(t)&&u.add(n.timeInfo.trackIdField);const f=s(e,u),d=f?[]:u.has(o)?[...u]:[...u,o],c=t.returnGeometry||await ge(t);if(f&&!c)return;const p=await me({layer:n,graphic:e,outFields:d,objectIds:l,returnGeometry:c,spatialReference:r},i);p&&(p.geometry&&(e.geometry=p.geometry),p.attributes&&(e.attributes={...e.attributes,...p.attributes}))}function he(e=""){return!!e&&e.includes(v)}function Fe(e){return e?`${v}${e.layerId}/${e.fieldName}`:""}function we({attributes:e,graphic:t,relatedInfo:n,fieldInfos:r,fieldInfoMap:i,layer:o,timeZone:a}){e&&t&&n&&Object.keys(t.attributes).forEach(l=>{const u=Fe({layerId:n.relation.id.toString(),fieldName:l}),s=t.attributes[l];e[u]=pe({fieldName:u,fieldInfos:r,fieldInfoMap:i,layer:o,value:s,graphic:t,timeZone:a})})}function Te({attributes:e,relatedInfo:t,fieldInfoMap:n,fieldInfos:r,layer:i,timeZone:o}){e&&t&&(t.relatedFeatures?.forEach(a=>we({attributes:e,graphic:a,relatedInfo:t,fieldInfoMap:n,fieldInfos:r,layer:i,timeZone:o})),t.relatedStatsFeatures?.forEach(a=>we({attributes:e,graphic:a,relatedInfo:t,fieldInfoMap:n,fieldInfos:r,layer:i,timeZone:o})))}const Ne=e=>{if(!e)return!1;const t=e.toUpperCase();return t.includes("CURRENT_TIMESTAMP")||t.includes("CURRENT_DATE")||t.includes("CURRENT_TIME")},je=({layer:e,method:t,query:n,definitionExpression:r})=>{if(!e.capabilities?.query?.supportsCacheHint||"attachments"===t)return;const i=null!=n.where?n.where:null,o=null!=n.geometry?n.geometry:null;Ne(r)||Ne(i)||"extent"===o?.type||"tile"===n.resultType||(n.cacheHint=!0)},Ce=({query:e,layer:t,method:n})=>{je({layer:t,method:n,query:e,definitionExpression:`${t.definitionExpression} ${t.serviceDefinitionExpression??""}`})},Ze=({queryPayload:e,layer:t,method:n})=>{je({layer:t,method:n,query:e,definitionExpression:`${t.definitionExpression} ${t.serviceDefinitionExpression??""}`})};function ve(e,t,n){return e&&t&&n?"sublayer"===t.type?qe({layers:t.layer?.allSublayers,map:e,relatedLayer:t,relationship:n})||qe({layers:t.layer?.subtables,map:e,relatedLayer:t,relationship:n}):qe({layers:e.allLayers,map:e,relatedLayer:t,relationship:n})||qe({layers:e.allTables,map:e,relatedLayer:t,relationship:n}):null}function Le(e,t){return e&&"utilityNetworks"in e&&t?e.utilityNetworks?.find(e=>e.isUtilityLayer(t)):null}function xe(e,t){return e?.allTables.find(e=>"feature"===e.type&&e.layerId===t.id&&e.url===t.layer?.url)}function qe({map:e,relationship:t,relationship:{relatedTableId:n},relatedLayer:r,layers:i}){if(!i)return null;for(const o of i){if("map-image"===o.type){const n=qe({layers:o.sublayers,map:e,relatedLayer:r,relationship:t})||qe({layers:o.subtables,map:e,relatedLayer:r,relationship:t});if(n)return n;continue}if(!Y(o))continue;if("sublayer"===r.type){if(o!==r&&o.id===n)return o.isTable?xe(e,o):o;continue}const i="scene"===r.type&&r.associatedLayer?r.associatedLayer.url:r.url;if(!i)return null;if("sublayer"!==o.type){if(o!==r&&o.url===i&&o.layerId===n)return o}else if(o!==r&&o.layer?.url===i&&o.id===n)return o.isTable?xe(e,o):o}return null}export{ce as applyTextFormattingHTML,se as createFieldInfoMap,ve as findRelatedLayer,Le as findUtilityNetwork,B as fixTokens,ye as formatAttributes,ue as formatEditInfo,ne as formatValueToFieldInfo,fe as getAllFieldInfos,R as getFieldFormat,oe as getFieldInfo,k as getFieldInfoLabel,z as getFixedFieldName,O as getFixedFieldNames,x as getSourceLayer,q as graphicCallback,de as htmlEntities,ee as isAssociatedFeatureSupportedLayer,U as isExpressionField,V as isFeatureSupportedLayer,te as isGraphicForRelatableFeatureSupportedLayer,Y as isRelatableFeatureSupportedLayer,X as isRelatableLayer,he as isRelatedField,M as isSupportedContext,Ce as preLayerQueryCallback,Ze as preRequestCallback,me as querySourceLayer,be as queryUpdatedFeature,A as shouldOpenInNewTab,P as substituteAttributes,Q as substituteFieldsInLinksAndAttributes};