@arcgis/core 5.2.0-next.22 → 5.2.0-next.24

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 (152) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/04070767356c12026369.js +1 -0
  3. package/assets/esri/core/workers/chunks/10112bf4b385f1955a3d.js +1 -0
  4. package/assets/esri/core/workers/chunks/{b0b3c67b7d37bd854d95.js → 1040bce57ea63a6dbca4.js} +2 -2
  5. package/assets/esri/core/workers/chunks/{3b74749db78bcba2bc16.js → 126a8c26618425790804.js} +1 -1
  6. package/assets/esri/core/workers/chunks/{d4e0346209fabc58f929.js → 15fd30908d5db7f7136e.js} +3 -3
  7. package/assets/esri/core/workers/chunks/{1a4bec464daa9662ab2a.js → 1a7c0a1dc6ecc93ea03a.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{73b0edabddbb72fe1104.js → 1b5001bdfeecf78c33ce.js} +1 -1
  9. package/assets/esri/core/workers/chunks/{57e04b7ec238f7b24274.js → 1f03e34520746e432719.js} +1 -1
  10. package/assets/esri/core/workers/chunks/218e2d8d6cd147c769ce.js +1 -0
  11. package/assets/esri/core/workers/chunks/{2c4f10eaf02ef090ee8f.js → 23f81f4a3d7a983eef23.js} +1 -1
  12. package/assets/esri/core/workers/chunks/{a856ae928273f9d6792f.js → 268ee59800e64baa9682.js} +1 -1
  13. package/assets/esri/core/workers/chunks/26a2d4b95cda0a41d980.js +1 -0
  14. package/assets/esri/core/workers/chunks/{f02a9408ba3893484c6c.js → 2d6d01913096f7cb5ff8.js} +1 -1
  15. package/assets/esri/core/workers/chunks/2e7b83c8ba78cb06d611.js +1 -0
  16. package/assets/esri/core/workers/chunks/{7fc8516111bd869256fc.js → 30298f84bd414f9dea64.js} +1 -1
  17. package/assets/esri/core/workers/chunks/316a3d5c7842b445e29e.js +1 -0
  18. package/assets/esri/core/workers/chunks/{84a0bb53fcbd99b5aa0c.js → 33e86dd1a54e447fa0e3.js} +1 -1
  19. package/assets/esri/core/workers/chunks/{5fab14c5f1febebb75f1.js → 34eb22ee13df24271532.js} +1 -1
  20. package/assets/esri/core/workers/chunks/353c67da4b25c29360db.js +2 -0
  21. package/assets/esri/core/workers/chunks/{3d83ac791212b81c9d11.js → 36b904912cea1744d1c6.js} +1 -1
  22. package/assets/esri/core/workers/chunks/{f8cfd0045d06aa24beec.js → 3b7060d264888bf298b1.js} +1 -1
  23. package/assets/esri/core/workers/chunks/{f9b44ff9bb4f7a88ab56.js → 3d1021f7ea9617a76ccf.js} +1 -1
  24. package/assets/esri/core/workers/chunks/{60d4a3f770bb1e01cd10.js → 3e4b379a6a197b9c4e6b.js} +1 -1
  25. package/assets/esri/core/workers/chunks/{4f51963815b0d53ffbd9.js → 3e94ed4d57ee7d870cba.js} +1 -1
  26. package/assets/esri/core/workers/chunks/{7d220f574ebf2740c208.js → 41aca863324387576cf8.js} +1 -1
  27. package/assets/esri/core/workers/chunks/{a54773c9bbc751619b3f.js → 47948c72bc01bd173c20.js} +2 -2
  28. package/assets/esri/core/workers/chunks/{cbe8adc100582e746a8c.js → 4adfe7f8a8efe2cd8e80.js} +1 -1
  29. package/assets/esri/core/workers/chunks/{e29c8c10331edfa83277.js → 502464c4eab7667f6566.js} +1 -1
  30. package/assets/esri/core/workers/chunks/{e9acc05b0cf9e05f31a8.js → 50b34e246f8eef2f6e07.js} +1 -1
  31. package/assets/esri/core/workers/chunks/52993a9dc0c56e9bda19.js +1 -0
  32. package/assets/esri/core/workers/chunks/5b654e0dc901a7f06a9f.js +1 -0
  33. package/assets/esri/core/workers/chunks/{dd795c95cdc3812b5b49.js → 6adc17e6e287a365ad8d.js} +1 -1
  34. package/assets/esri/core/workers/chunks/{40df6ffeb61fea80aae3.js → 7849cf0352c0a604e164.js} +1 -1
  35. package/assets/esri/core/workers/chunks/{6c0c77de1934f35dc45f.js → 7c34eb94e2c74602aeab.js} +1 -1
  36. package/assets/esri/core/workers/chunks/{8579eba21f40630d073d.js → 7dbaa089c7472825b80c.js} +1 -1
  37. package/assets/esri/core/workers/chunks/{66c2cfe11161d5dc989a.js → 7dec8c453fdee1968d12.js} +1 -1
  38. package/assets/esri/core/workers/chunks/7e4093f42795ba2f8cfd.js +1 -0
  39. package/assets/esri/core/workers/chunks/856cf872d29eeaf11a71.js +1 -0
  40. package/assets/esri/core/workers/chunks/88b08b386926ec889573.js +1 -0
  41. package/assets/esri/core/workers/chunks/{1b0765403b06294b3e1d.js → 89dd1b1acb0d69264c93.js} +1 -1
  42. package/assets/esri/core/workers/chunks/{5d710b3e50f2211a765d.js → 8b526ca2dd6fc6a7e921.js} +1 -1
  43. package/assets/esri/core/workers/chunks/{50345dfc00380b158c96.js → 8ba3e0462a9bdaae5f40.js} +1 -1
  44. package/assets/esri/core/workers/chunks/{c86d388d216adbb15a05.js → 8bd4c43c34aacf3b07da.js} +1 -1
  45. package/assets/esri/core/workers/chunks/{69e98de578f467a35054.js → a0b78cbeb0e53107d819.js} +1 -1
  46. package/assets/esri/core/workers/chunks/{fee50ab6c92ef0327255.js → a454df829a72ab02c860.js} +1 -1
  47. package/assets/esri/core/workers/chunks/{5481af25fd46914498df.js → a6dc01847f39413f78b8.js} +1 -1
  48. package/assets/esri/core/workers/chunks/{44e32ed3a570593a7245.js → a8310f55de4749f973d0.js} +1 -1
  49. package/assets/esri/core/workers/chunks/{5dd441db1e74dc9b56e9.js → acc733b4881c3e4e503e.js} +1 -1
  50. package/assets/esri/core/workers/chunks/{0b45d34938fa7862f746.js → affc972757798b6db002.js} +1 -1
  51. package/assets/esri/core/workers/chunks/{9f93c29af2a18f7cb160.js → b45e91249a8ea1559a2b.js} +1 -1
  52. package/assets/esri/core/workers/chunks/{f955b35337a08f9f747d.js → c610ccbfdb1c5b06c217.js} +1 -1
  53. package/assets/esri/core/workers/chunks/{fb9f8b6cc2b4ae5b60df.js → c9ce408675dae6a0edd1.js} +1 -1
  54. package/assets/esri/core/workers/chunks/cd88e6f02bc2e5b67abf.js +1 -0
  55. package/assets/esri/core/workers/chunks/d374cb2d17a2d11c500f.js +1 -0
  56. package/assets/esri/core/workers/chunks/{5b42f8aa0247adc2d065.js → d41eed41916ed0422059.js} +1 -1
  57. package/assets/esri/core/workers/chunks/{8eda85fc01a71aedd9e4.js → dadf85890961bcc205eb.js} +1 -1
  58. package/assets/esri/core/workers/chunks/{2255a21c7b959f04d941.js → db90fb8ac96579259566.js} +1 -1
  59. package/assets/esri/core/workers/chunks/{ef94d25d1cceb25ea9fe.js → dd0acd0f8b96839b4f24.js} +2 -2
  60. package/assets/esri/core/workers/chunks/e3623e557ab463580fd2.js +1 -0
  61. package/assets/esri/core/workers/chunks/{d523af1db620b5381c99.js → e8e7cd26c43f231cdea2.js} +1 -1
  62. package/assets/esri/core/workers/chunks/{162dada6a199d1efdf86.js → f859c53432f258af77e3.js} +2 -2
  63. package/chunks/OITBlendEmission.glsl.js +5 -2
  64. package/config.d.ts +9 -2
  65. package/config.js +1 -1
  66. package/form/elements/AttachmentElement.d.ts +4 -4
  67. package/kernel.js +1 -1
  68. package/layers/OrientedImageryLayer.d.ts +20 -2
  69. package/layers/orientedImagery/types.d.ts +4 -1
  70. package/layers/save/featureLayerUtils.js +1 -1
  71. package/layers/save/utils.js +1 -1
  72. package/layers/support/fetchService.js +1 -1
  73. package/package.json +3 -3
  74. package/portal/support/portalItemUtils.js +1 -1
  75. package/support/revision.js +1 -1
  76. package/symbols/CIMSymbol.d.ts +2 -3
  77. package/symbols/cim/types.d.ts +58 -2
  78. package/views/2d/engine/webgl/shaderGraph/graph/ShaderGraphContext.js +1 -1
  79. package/views/2d/engine/webgl/shaderGraph/graph/glsl.js +1 -1
  80. package/views/2d/engine/webgl/shaderGraph/techniques/pieChart/PieChartMeshWriter.js +1 -1
  81. package/views/2d/engine/webgl/shaderGraph/techniques/pieChart/PieChartShader.js +1 -1
  82. package/views/2d/engine/webgl/shaderGraph/techniques/pieChart/PieChartTechnique.js +1 -1
  83. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  84. package/views/2d/layers/features/schema/processor/symbols/SymbolSchema.js +1 -1
  85. package/views/3d/analysis/Viewshed/ViewshedComputedData.js +1 -1
  86. package/views/3d/analysis/Viewshed/ViewshedEditTool.js +1 -1
  87. package/views/3d/analysis/Viewshed/ViewshedSnappingController.js +1 -1
  88. package/views/3d/analysis/Viewshed/ViewshedSubTool.js +1 -1
  89. package/views/3d/layers/GaussianSplatLayerView3D.js +1 -1
  90. package/views/3d/state/controllers/PinchAndPanControllerGlobal.js +1 -1
  91. package/views/3d/state/utils/navigationUtils.js +1 -1
  92. package/views/3d/support/gaussianSplatting/GaussianSplatTextureAtlas.js +1 -1
  93. package/views/3d/support/pointsOfInterest/Focus.js +1 -1
  94. package/views/3d/webgl/RenderCamera.js +1 -1
  95. package/views/3d/webgl-engine/core/shaderLibrary/util/EmissionDimming.glsl.js +1 -1
  96. package/views/3d/webgl-engine/materials/renderers/MergedBuffer.js +1 -1
  97. package/views/3d/webgl-engine/shaders/OutputColorHighlightOLID.glsl.js +4 -4
  98. package/views/PopupView.d.ts +3 -0
  99. package/widgets/BatchAttributeForm/templates/support/createBatchFormTemplate.js +1 -1
  100. package/widgets/BatchAttributeForm/types.d.ts +0 -7
  101. package/widgets/BatchAttributeForm.d.ts +7 -9
  102. package/widgets/BatchAttributeForm.js +1 -1
  103. package/widgets/Editor/EditorViewModel.d.ts +12 -2
  104. package/widgets/Editor/EditorViewModel.js +1 -1
  105. package/widgets/Editor/compatibilityAdapters.js +2 -0
  106. package/widgets/Editor/components/PendingFeatureList.js +1 -1
  107. package/widgets/Editor/components/UpdateFeaturePanelContent.js +1 -1
  108. package/widgets/Editor/legacy/AddAssociationWorkflow.js +2 -0
  109. package/widgets/Editor/legacy/AddAssociationWorkflowData.js +2 -0
  110. package/widgets/Editor/legacy/CreateFeaturesWorkflow.js +2 -0
  111. package/widgets/Editor/legacy/CreateFeaturesWorkflowData.js +2 -0
  112. package/widgets/Editor/legacy/MergeFeaturesWorkflow.js +2 -0
  113. package/widgets/Editor/legacy/MergeFeaturesWorkflowData.js +2 -0
  114. package/widgets/Editor/legacy/SplitFeatureWorkflow.js +2 -0
  115. package/widgets/Editor/legacy/SplitFeatureWorkflowData.js +2 -0
  116. package/widgets/Editor/legacy/UpdateFeatureWorkflow.js +2 -0
  117. package/widgets/Editor/legacy/UpdateFeatureWorkflowData.js +2 -0
  118. package/widgets/Editor/legacy/UpdateFeaturesWorkflow.js +2 -0
  119. package/widgets/Editor/legacy/UpdateFeaturesWorkflowData.js +2 -0
  120. package/widgets/Editor/legacy/UpdateRecordWorkflow.js +2 -0
  121. package/widgets/Editor/legacy/UpdateRecordWorkflowData.js +2 -0
  122. package/widgets/Editor/legacy/UpdateWorkflow.js +2 -0
  123. package/widgets/Editor/legacy/UpdateWorkflowData.js +2 -0
  124. package/widgets/Editor/legacy/Workflow.js +2 -0
  125. package/widgets/Editor/legacy/workflowUtils.js +2 -0
  126. package/widgets/Editor/workflowUtils.js +1 -1
  127. package/widgets/Editor.js +1 -1
  128. package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
  129. package/widgets/FeatureTable/FeatureTableViewModel.d.ts +2 -1
  130. package/widgets/FeatureTable/Grid/GridViewModel.d.ts +3 -0
  131. package/widgets/Sketch/SketchViewModel.d.ts +8 -1
  132. package/widgets/Sketch/types.d.ts +12 -0
  133. package/assets/esri/core/workers/chunks/0eb0ce43b4813cae968f.js +0 -2
  134. package/assets/esri/core/workers/chunks/0fb685f385e91d0f0601.js +0 -1
  135. package/assets/esri/core/workers/chunks/277718031c903da2b3b9.js +0 -1
  136. package/assets/esri/core/workers/chunks/47d630561f3fce5c63c4.js +0 -1
  137. package/assets/esri/core/workers/chunks/58c79e15ca95238a4b43.js +0 -1
  138. package/assets/esri/core/workers/chunks/5b238f9c345f10c5c2fa.js +0 -1
  139. package/assets/esri/core/workers/chunks/9ad36947bb42ed7f97d3.js +0 -1
  140. package/assets/esri/core/workers/chunks/9e0ea6c34940b1acf3c6.js +0 -1
  141. package/assets/esri/core/workers/chunks/aec46ec486912dca549d.js +0 -1
  142. package/assets/esri/core/workers/chunks/be4275a4b8977ec3eb61.js +0 -1
  143. package/assets/esri/core/workers/chunks/d6bb8db22ba85ad05fd7.js +0 -1
  144. package/assets/esri/core/workers/chunks/d8329c2000c0cc597adc.js +0 -1
  145. package/assets/esri/core/workers/chunks/dee339774131d7274137.js +0 -1
  146. package/assets/esri/core/workers/chunks/f3fe865506fd7428eb6d.js +0 -1
  147. package/assets/esri/core/workers/chunks/fccc34b86454c56f27ab.js +0 -1
  148. /package/assets/esri/core/workers/chunks/{b0b3c67b7d37bd854d95.js.LICENSE.txt → 1040bce57ea63a6dbca4.js.LICENSE.txt} +0 -0
  149. /package/assets/esri/core/workers/chunks/{0eb0ce43b4813cae968f.js.LICENSE.txt → 353c67da4b25c29360db.js.LICENSE.txt} +0 -0
  150. /package/assets/esri/core/workers/chunks/{a54773c9bbc751619b3f.js.LICENSE.txt → 47948c72bc01bd173c20.js.LICENSE.txt} +0 -0
  151. /package/assets/esri/core/workers/chunks/{ef94d25d1cceb25ea9fe.js.LICENSE.txt → dd0acd0f8b96839b4f24.js.LICENSE.txt} +0 -0
  152. /package/assets/esri/core/workers/chunks/{162dada6a199d1efdf86.js.LICENSE.txt → f859c53432f258af77e3.js.LICENSE.txt} +0 -0
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{substitute as t}from"../../../intl.js";import{property as r,subclass as o}from"../../../core/accessorSupport/decorators.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 l}from"./workflowAdapters/pendingFeatureList/CreateFeaturesWorkflowPendingFeatureListAdapter.js";import{SplitFeatureWorkflowPendingFeatureListAdapter as c}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,l=await h(s,n,{ariaLabel:a}).catch(()=>(k(o,!1),null));if(null==l)return;o.appendChild(l)}})}),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",{icon:"zoom-to-object",slot:"actions-end",text:this.messages.zoomTo,title:this.messages.zoomTo,onblur:()=>t.clearHighlights(),onclick:()=>t.zoomToFeature(e),onfocus:()=>t.highlightFeature(e)}):void 0,i=t.allowCancel?g("calcite-action",{icon:"trash",slot:"actions-end",text:r.createFeaturesSelectionList.discard,title:r.createFeaturesSelectionList.discard,onblur:()=>t.clearHighlights(),onclick:()=>t.cancelFeature(e),onfocus:()=>t.highlightFeature(e)}):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 l({workflow:e}):n(e)?new c({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
+ import{__decorate as e}from"tslib";import{substitute as t}from"../../../intl.js";import{property as r,subclass as i}from"../../../core/accessorSupport/decorators.js";import o from"../../Widget.js";import{isNextOrLegacySplitFeatureWorkflow as s,isNextOrLegacyCreateFeaturesWorkflow as n}from"../compatibilityAdapters.js";import{css as a}from"../css.js";import{CreateFeaturesWorkflowPendingFeatureListAdapter as l}from"./workflowAdapters/pendingFeatureList/CreateFeaturesWorkflowPendingFeatureListAdapter.js";import{SplitFeatureWorkflowPendingFeatureListAdapter as c}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 o{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 i=e.target;if(I(i))return void r.unobserve(i);const o=v(i),{graphic:s}=o,n=s.sourceLayer??this.workflowAdapter?.layer;if(!n||!s)return;k(i,!0);const a=o.id?t(this.messages.previewTemplateAriaLabel,{label:o.id}):this.messagesCommon.preview,l=await h(s,n,{ariaLabel:a}).catch(()=>(k(i,!1),null));if(null==l)return;i.appendChild(l)}})}),this.messages=null,this.messagesCommon=null,this._renderActionEnd=({graphic:e})=>{const{workflowAdapter:t,messages:r}=this;if(!t)return;const i=e.geometry?g("calcite-action",{icon:"zoom-to-object",slot:"actions-end",text:this.messages.zoomTo,title:this.messages.zoomTo,onblur:()=>t.clearHighlights(),onclick:()=>t.zoomToFeature(e),onfocus:()=>t.highlightFeature(e)}):void 0,o=t.allowCancel?g("calcite-action",{icon:"trash",slot:"actions-end",text:r.createFeaturesSelectionList.discard,title:r.createFeaturesSelectionList.discard,onblur:()=>t.clearHighlights(),onclick:()=>t.cancelFeature(e),onfocus:()=>t.highlightFeature(e)}):void 0;return g(w,null,i,o)},this._renderItemContentEnd=({graphic:e})=>{const{workflowAdapter:t}=this,r=t?.isSubmittable(e);return[r?void 0:g("calcite-icon",{class:a.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,i)=>{const o=e.isSubmittable(r),s=o?t.createFeaturesSelectionList.featureReadyToSubmit:t.createFeaturesSelectionList.featureNotReadyToSubmit;return{disabled:!1,id:`${e.getFeatureTitle(r)??i}`,graphic:r,label:s,submittable:o}}),i=s(this.workflow)?t.result:t.createFeaturesSelectionList.heading;return g("div",null,g(m,{level:p(this.headingLevel)},i),g("calcite-list",{label:i},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 l({workflow:e}):s(e)?new c({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([i("esri.widgets.Editor.components.PendingFeatureList")],b);const F=b;export{F as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- 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,isUpdateFeatureWorkflow as s,isUpdateFeaturesWorkflow as a}from"../workflowUtils.js";import{loadFooterActionsComponents as l,FooterActions as r}from"./FooterActions.js";import c from"./MergeFeaturesList.js";import{loadNoticesComponents as u,Notices as p}from"./Notices.js";import{loadPanelContentComponents as m,PanelContentSection as d,PanelContentSectionGroup as f,PanelContent as g}from"./PanelContent.js";import k from"./PendingFeatureList.js";import{loadCalciteComponents as b}from"../../support/componentsUtils.js";import{tsx as w,tsxFragment as v}from"../../support/widget.js";import{classes as y}from"../../support/widgetUtils.js";const h=()=>Promise.all([b({"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar"),action:()=>import("@esri/calcite-components/dist/components/calcite-action")}),l(),u(),m()]);function F(e){const{editorViewModel:s,formWidget:a,headingLevel:l,messages:u,renderSketchToolbar:m}=e,{activeFeatureCount:b,activeLeafWorkflow:y,activeWorkflow:h,formViewModel:F}=s;if(!y||!h||!F)return null;const j=o(y)&&!y.data.selectedPendingFeature||i(y)&&!y.activeFeature,L=n(y),A=F.activeForm.inputs,S=o(y)&&A.every(e=>!e.visible),B=null!=s.formViewModel?.activeAssociationsInput,T=!j&&!S&&!B,V=S||o(y)&&!T&&!B,z=S?w(d,null,w(k,{headingLevel:l,key:"pending-feature-list",workflow:y})):w(v,null,w(p,{activeFeatureCount:b,messages:u,workflow:h}),L?w(d,{class:t.mergeFeaturesListSection,key:"panel-section-merge"},w(c,{headingLevel:l,key:"merge-features-list",workflow:y})):void 0,w(d,{key:"panel-content-section-main"},w(f,null,j?w(k,{headingLevel:l,key:"pending-feature-list",workflow:y}):a.render())));return w(v,null,T?C(y,e):void 0,V?m?.():void 0,w(g,{key:"attribute-panel-content"},z),w(r,{buttons:M(e)}))}function C(e,o){const i=[],n="3d"===o.editorViewModel.view?.type,{visibleElements:l}=o,r="s";if(l.zoomToButton&&o.editorViewModel.canZoomTo&&i.push(w("calcite-action",{alignment:"center",icon:"zoom-to-object",key:"zoom-to-button",scale:r,text:o.messages.zoomTo,title:o.messages.zoomTo,onclick:()=>o.editorViewModel.zoomTo()})),l.splitButton&&s(e)&&e.supportsSplitFeatureWorkflow&&!n&&o.onSplit){const{onSplit:e,messages:t}=o;i.push(w("calcite-action",{icon:"split-geometry",key:"split-button",scale:r,text:t.split,title:t.split,onclick:e}))}if(l.mergeButton&&a(e)&&e.supportsMergeFeaturesWorkflow&&!n&&o.onMerge){const{onMerge:e,messages:t}=o;i.push(w("calcite-action",{icon:"merge",key:"merge-button",scale:r,text:t.mergeFeatures,title:t.mergeFeatures,onclick:e}))}return i.length>0?w("calcite-action-bar",{class:y(t.sketchContainer,t.updateActionBar),"data-testid":"update-feature-panel-action-bar",expandDisabled:!0,layout:"horizontal",scale:r},i):void 0}function M({editorViewModel:t,formWidget:o,messages:i,messagesCommon:n,onDelete:s,onDeleteAssociation:a,onSave:l}){const{activeFeatureCount:r,activeLeafWorkflow:c,syncing:u}=t;if(!c)return[];const{page:p}=t;if("viewing-associated-features"===p||"viewing-associated-layers"===p)return[{appearance:"outline",onClick:()=>{c.formViewModel?.goBack()},disabled:u,label:n.cancel,type:"button"}];const m=t.formViewModel,d=o.footerButtonInfos;if(m&&"default"!==m.page)return d.map(({appearance:e,disabled:t,form:o,icon:i,kind:n,label:s,onclick:a})=>({appearance:e,disabled:t,form:o,icon:i,kind:n,label:s,onClick:a,type:"button"}));const f=[],g=r>1?i.multiFeature:i.singleFeature,k=!c.allowSave||u,b=e(g[c.saveActionLabel],{count:r});f.push({appearance:"solid",onClick:l,disabled:k,kind:"brand",label:b,type:"button"});const w={appearance:"outline",disabled:u,kind:"danger",label:e(g.delete,{count:r}),type:"button"};return t.shouldShowDeleteButton&&!t.formHasAssociation&&s&&f.push({...w,onClick:s}),t.formHasAssociation&&!t.shouldShowDeleteButton&&a&&f.push({...w,onClick:a,label:i.deleteAssociationTitle}),t.formHasAssociation&&t.shouldShowDeleteButton&&a&&s&&f.push({...w,primaryLabel:n.delete,primaryText:n.delete,onClick:s,dropdownItems:[{onClick:a,label:i.deleteAssociationTitle}],type:"split-button"}),f}export{F as UpdateFeaturePanelContent,h as loadUpdateFeaturePanelContentComponents};
2
+ import{substitute as e}from"../../../intl/substitute.js";import{isNextOrLegacyCreateFeaturesWorkflow as t,isNextOrLegacySplitFeatureWorkflow as o,isNextOrLegacyMergeFeaturesWorkflow as i,isLegacyFeatureFormViewModel as n,isNextOrLegacyUpdateFeatureWorkflow as s,isNextOrLegacyUpdateFeaturesWorkflow as a}from"../compatibilityAdapters.js";import{css as l}from"../css.js";import{isBatchAttributeFormViewModel as r}from"../workflowUtils.js";import{loadFooterActionsComponents as c,FooterActions as u}from"./FooterActions.js";import p from"./MergeFeaturesList.js";import{loadNoticesComponents as m,Notices as d}from"./Notices.js";import{loadPanelContentComponents as f,PanelContentSection as g,PanelContentSectionGroup as k,PanelContent as b}from"./PanelContent.js";import w from"./PendingFeatureList.js";import{loadCalciteComponents as v}from"../../support/componentsUtils.js";import{Heading as h,incrementHeadingLevel as y}from"../../support/Heading.js";import{tsx as F,tsxFragment as j}from"../../support/widget.js";import{classes as A}from"../../support/widgetUtils.js";const C=()=>Promise.all([v({"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar"),action:()=>import("@esri/calcite-components/dist/components/calcite-action")}),c(),m(),f()]);function M(e){const{editorViewModel:s,headingLevel:a,messages:c,renderAttachments:m,renderFeatureForm:f,formWidget:v,renderSketchToolbar:A}=e,{activeFeatureCount:C,activeLeafWorkflow:M,activeWorkflow:B,formViewModel:T}=s;if(!M||!B||!T)return null;const V=r(T),z=t(M)&&!M.data.selectedPendingFeature||o(M)&&!M.activeFeature,I=i(M),W=M.shouldShowAttachments&&!V&&!T.activeRelationshipInput&&!T.activeAssociationInput,x=V?T.activeForm.inputs:T.inputs,D=t(M)&&x.every(e=>!e.visible)&&!W,H=null!=s.featureFormViewModel?.activeAssociationInput,P=!z&&!D&&!H,U=D||t(M)&&!W&&!P&&!H,E=n(T)?f:v?.render.bind(v),N=D?F(g,null,F(w,{headingLevel:a,key:"pending-feature-list",workflow:M})):F(j,null,F(d,{activeFeatureCount:C,messages:c,workflow:B}),I?F(g,{class:l.mergeFeaturesListSection,key:"panel-section-merge"},F(p,{headingLevel:a,key:"merge-features-list",workflow:M})):void 0,F(g,{key:"panel-content-section-main"},F(k,null,z?F(w,{headingLevel:a,key:"pending-feature-list",workflow:M}):E?.(),W?F("div",{key:"attachments"},F(h,{level:y(a)},c.attachments),m()):null)));return F(j,null,P?L(M,e):void 0,U?A?.():void 0,F(b,{key:"attribute-panel-content"},N),F(u,{buttons:S(e)}))}function L(e,t){const o=[],i="3d"===t.editorViewModel.view?.type,{visibleElements:n}=t,r="s";if(n.zoomToButton&&t.editorViewModel.canZoomTo&&o.push(F("calcite-action",{alignment:"center",icon:"zoom-to-object",key:"zoom-to-button",scale:r,text:t.messages.zoomTo,title:t.messages.zoomTo,onclick:()=>t.editorViewModel.zoomTo()})),n.splitButton&&s(e)&&e.supportsSplitFeatureWorkflow&&!i&&t.onSplit){const{onSplit:e,messages:i}=t;o.push(F("calcite-action",{icon:"split-geometry",key:"split-button",scale:r,text:i.split,title:i.split,onclick:e}))}if(n.mergeButton&&a(e)&&e.supportsMergeFeaturesWorkflow&&!i&&t.onMerge){const{onMerge:e,messages:i}=t;o.push(F("calcite-action",{icon:"merge",key:"merge-button",scale:r,text:i.mergeFeatures,title:i.mergeFeatures,onclick:e}))}return o.length>0?F("calcite-action-bar",{class:A(l.sketchContainer,l.updateActionBar),"data-testid":"update-feature-panel-action-bar",expandDisabled:!0,layout:"horizontal",scale:r},o):void 0}function S({editorViewModel:t,formWidget:o,messages:i,messagesCommon:s,onDelete:a,onDeleteAssociation:l,onSave:r}){const{activeFeatureCount:c,activeLeafWorkflow:u,syncing:p}=t;if(!u)return[];const{page:m}=t;if("viewing-associated-features"===m||"viewing-associated-layers"===m)return[{appearance:"outline",onClick:()=>{const e=u.formViewModel;n(e)?null!=e.associationId&&(e.associationId=null):e?.goBack()},disabled:p,label:s.cancel,type:"button"}];const d=t.formViewModel,f=o?.footerButtonInfos??[];if(d&&!n(d)&&"default"!==d.page)return f.map(({appearance:e,disabled:t,form:o,icon:i,kind:n,label:s,onclick:a})=>({appearance:e,disabled:t,form:o,icon:i,kind:n,label:s,onClick:a,type:"button"}));const g=[],k=c>1?i.multiFeature:i.singleFeature,b=!u.allowSave||p,w=e(k[u.saveActionLabel],{count:c});g.push({appearance:"solid",onClick:r,disabled:b,kind:"brand",label:w,type:"button"});const v={appearance:"outline",disabled:p,kind:"danger",label:e(k.delete,{count:c}),type:"button"};return t.shouldShowDeleteButton&&!t.formHasAssociation&&a&&g.push({...v,onClick:a}),t.formHasAssociation&&!t.shouldShowDeleteButton&&l&&g.push({...v,onClick:l,label:i.deleteAssociationTitle}),t.formHasAssociation&&t.shouldShowDeleteButton&&l&&a&&g.push({...v,primaryLabel:s.delete,primaryText:s.delete,onClick:a,dropdownItems:[{onClick:l,label:i.deleteAssociationTitle}],type:"split-button"}),g}export{M as UpdateFeaturePanelContent,C as loadUpdateFeaturePanelContentComponents};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import{__decorate as t}from"tslib";import e from"../../../core/Error.js";import{makeHandle as i,abortHandle as o}from"../../../core/handleUtils.js";import{isAborted as s}from"../../../core/promiseUtils.js";import{watch as a}from"../../../core/reactiveUtils.js";import{property as r,subclass as l}from"../../../core/accessorSupport/decorators.js";import{isSubtypeSublayer as n}from"../../../layers/support/layerUtils.js";import{createFeatureServices as d}from"../../../rest/featureService/utils.js";import c from"../../../views/draw/support/HighlightHelper.js";import{temporaryHighlightName as u}from"../../../views/support/HighlightDefaults.js";import{fetchFullFeatures as p}from"../workflowUtils.js";import w from"./AddAssociationWorkflowData.js";import h from"./Workflow.js";import y from"../../FeatureForm/UtilityNetworkAssociationAddAssociationViewModel.js";import{getFeatureTitle as m}from"../../support/UtilityNetworkAssociations/utils/getFeatureTitle.js";var A;const f={exit:Symbol()};let g=class extends h{static{A=this}constructor(t){super(t),this._utilityNetworkAssociationAddAssociationViewModel=new y,this._highlightHelper=null,this.sourceFeatureItem=null,this.type="add-association"}initialize(){const{data:t}=this,{view:e}=t.viewModel;e&&(this._highlightHelper=new c({view:e,highlightName:u}),this.addHandles(i(()=>this._highlightHelper?.removeAll())));const s=new AbortController;this.addHandles(o(s)),this._updatingHandles.consumePromise(this._setup(s))}get editorItem(){return this.data.editorItem}get formViewModel(){return this._formViewModel}get utilityNetworkAssociationAddAssociationViewModel(){return this._utilityNetworkAssociationAddAssociationViewModel}get hasPendingEdits(){return!!this._utilityNetworkAssociationAddAssociationViewModel.selectedFeature}get layer(){return this.data.editorItem.layer}get parent(){return this.data.parent}get reliesOnOwnerAdminPrivileges(){return this.editorItem.capabilities.create.reliesOnOwnerAdminPrivileges}async enter(){this._addHandles()}exit(){this.removeHandles(f.exit)}async start(){return await super.start(),null}async _setup(t){const{data:i}=this,{feature:o}=i;try{const[e]=await p([o],o.sourceLayer,i.viewModel.view.spatialReference,t.signal);if(s(t))return;const a=e.sourceLayer&&"getFeatureTitle"in e.sourceLayer&&await e.sourceLayer.getFeatureTitle(e)||m(e);if(s(t))return;this.sourceFeatureItem={feature:o,label:a},this._initializeUtilityNetworkAssociationAddAssociationViewModel()}catch(a){await this.cancel({force:!0,error:new e("editor:failed-to-fetch-full-feature","Failed to retrieve all information for this feature. The update cannot proceed.",{detail:{error:a}})})}}_initializeUtilityNetworkAssociationAddAssociationViewModel(){const{viewModel:{view:t},utilityNetwork:e,associationType:i}=this.data,o=this._utilityNetworkAssociationAddAssociationViewModel;o.graphic=this.sourceFeatureItem.feature,o.map=t?.map,o.utilityNetwork=e,o.layer=this.layer,o.associationType=i,o.highlightHelper=this._highlightHelper,e.networkSystemLayers.loadAssociationsTable()}_addHandles(){const t=this._utilityNetworkAssociationAddAssociationViewModel;this.addHandles([a(()=>t.selectedLayer,t=>{t&&this.go("add-association-select-feature")}),a(()=>t.selectedFeature,t=>{t&&this.go("add-association-create-association")})],f.exit)}static async create(t){const e=new A({data:await w.create(t),onCommit:this._onCommitFactory(t.applyEditsFeatureService)});return e._set("steps",this._createWorkflowSteps(e)),e}static _createWorkflowSteps(t){return[{id:"add-association-select-layer",async setUp(){const{utilityNetworkAssociationAddAssociationViewModel:e}=t.data.viewModel;e&&(e.selectedLayer=null,e.selectedFeature=null,e.association=null)},async tearDown(){}},{id:"add-association-select-feature",async setUp(){const{utilityNetworkAssociationAddAssociationViewModel:e}=t.data.viewModel;e&&(e.selectedFeature=null,e.association=null)},async tearDown(){}},{id:"add-association-create-association",async setUp(){},async tearDown(){}}]}static{this._onCommitFactory=t=>async i=>{const{feature:o,utilityNetwork:s,associationsInput:a}=i,{utilityNetworkAssociationAddAssociationViewModel:r}=i.viewModel,{association:l}=r;await s.networkSystemLayers.loadAssociationsTable();const c=s?.generateAddAssociations([l]);if(!c)throw new e("editor:failed-to-add-association","Could not create payload needed to add association");const u=o.sourceLayer,p=n(u)&&u.parent?u.parent:u,w=d([p]),h=w.values().next().value?.featureService;if(!h)throw new e("editor:failed-to-delete-association","Could not retrieve feature service needed to delete association");await(h?.load());const y=s?.gdbVersion??void 0;await t(h,[c],{gdbVersion:y}),await a.refresh()}}};t([r()],g.prototype,"_utilityNetworkAssociationAddAssociationViewModel",void 0),t([r()],g.prototype,"_formViewModel",void 0),t([r()],g.prototype,"editorItem",null),t([r()],g.prototype,"formViewModel",null),t([r()],g.prototype,"utilityNetworkAssociationAddAssociationViewModel",null),t([r()],g.prototype,"sourceFeatureItem",void 0),t([r()],g.prototype,"hasPendingEdits",null),t([r()],g.prototype,"layer",null),t([r()],g.prototype,"parent",null),t([r()],g.prototype,"reliesOnOwnerAdminPrivileges",null),g=A=t([l("esri.widgets.Editor.legacy.AddAssociationWorkflow")],g);export{g as AddAssociationWorkflow};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import{__decorate as t}from"tslib";import o from"../../../core/Accessor.js";import{property as e,subclass as i}from"../../../core/accessorSupport/decorators.js";import{findEditorItemForLayerOrThrow as r}from"../workflowUtils.js";var s;let a=s=class extends o{constructor(t){super(t),this.editorItem=null,this.feature=null,this.utilityNetwork=null,this.associationType=null,this.parent=null,this.associationsInput=null,this.viewModel=null}static async create(t){const{feature:o,parent:e,viewModel:i,utilityNetwork:a,associationType:n,associationsInput:p}=t,l=r(i.editorItems,o.sourceLayer);return new s({editorItem:l,feature:o,parent:e,viewModel:i,utilityNetwork:a,associationType:n,associationsInput:p})}};t([e({constructOnly:!0})],a.prototype,"editorItem",void 0),t([e()],a.prototype,"feature",void 0),t([e({constructOnly:!0})],a.prototype,"utilityNetwork",void 0),t([e({constructOnly:!0})],a.prototype,"associationType",void 0),t([e()],a.prototype,"parent",void 0),t([e()],a.prototype,"associationsInput",void 0),t([e()],a.prototype,"viewModel",void 0),a=s=t([i("esri.widgets.Editor.legacy.AddAssociationWorkflowData")],a);export{a as default};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import{__decorate as e}from"tslib";import t from"../../../Graphic.js";import a from"../../../core/Error.js";import{makeHandle as i,handlesGroup as r,abortHandle as s}from"../../../core/handleUtils.js";import"../../../core/has.js";import o from"../../../core/Logger.js";import{removeMaybe as n,destroyMaybe as l}from"../../../core/maybe.js";import{isPromiseLike as d,debounce as c}from"../../../core/promiseUtils.js";import{watch as u,initial as p,sync as h,whenOnce as m,syncAndInitial as f}from"../../../core/reactiveUtils.js";import{generateBracedUUID as g}from"../../../core/uuid.js";import{property as w,subclass as y}from"../../../core/accessorSupport/decorators.js";import{isSharedTemplateOrMetadata as v,isSharedTemplate as F,getCreationAttributes as _,isStandardFeatureTemplate as b}from"../../../editing/templateUtils.js";import{getFullTemplate as M}from"../../../editing/sharedTemplates/templateLoader.js";import I from"../../../layers/GraphicsLayer.js";import{isSceneLayer as V,isTable as k}from"../../../layers/support/layerUtils.js";import{isNumber as S}from"../../../support/guards.js";import{getDisplayedSymbol as T}from"../../../symbols/support/symbolUtils.js";import{updateGraphicSymbolWhenRequired as A}from"../../../views/draw/support/editingSessionUtils.js";import{getDrawHelpMessage as P}from"../../../views/draw/support/helpMessageUtils.js";import E from"../../../views/draw/support/HighlightHelper.js";import U from"../../../views/interactive/sketch/SketchOptions.js";import C from"../../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{temporaryHighlightName as H}from"../../../views/support/HighlightDefaults.js";import{isModelUpload as L,handleModelUpload as j}from"../modelUploadUtils.js";import{activeSketchToolDrawsUnsupportedCurve as O,createToolFromGeometryType as x,containsUnsupportedCurve as D,findEditorItemForLayer as z,getServiceEditsFromWorkflowData as R,getServiceInfoForLayer as W,orderEditsByRelationshipDependencies as G,getServiceLayersById as N,startCreatingNewFeature as K,syncUpdateOptions as Z,findLayerInfo as q,isTerminalUpdateEventType as B,getVisualVariableAttributes as J,startUpdatingFeatureGeometry as Q,createWorkflowSteps as X,avoidFeatureTemplateSelectionWithOnlyOneItem as Y,setUpSketchCreateWatchers as $,setRelationshipFields as ee,showProgressCursor as te,setVisualVariablesAndElevationInfoForUpdate as ae,visualVariableInteractiveUpdate as ie}from"../workflowUtils.js";import re from"./CreateFeaturesWorkflowData.js";import se from"./Workflow.js";import{prepareAttachmentsForCreateFeaturesWorkflow as oe}from"./workflowUtils.js";import ne from"../../FeatureForm/FeatureFormViewModel.js";import le from"../../Sketch/SketchViewModel.js";var de;const ce=Symbol(),ue=Symbol(),pe=Symbol(),he=Symbol(),me={point:["point"],multipoint:["multipoint"],polygon:["polygon","freehandPolygon","rectangle","circle"],polyline:["polyline","freehandPolyline"],mesh:[],multipatch:[]};let fe=de=class extends se{constructor(e){super(e),this.type="create-features",this.createFeatureState="create-new",this.data=void 0,this.isNested=!1,this._getDrawMeshHelpMessage=void 0,this._featureFormHandle=null,this._visualVariableAttributes={rotation:null,size:null},this._formViewModel=new ne,this._sketchLayer=null,this._sketchViewModel=null,this._attachmentFileInfos=new Map,this._isActive=!0}initialize(){this.isNested&&(this._isActive=!1),this._initializeSketchViewModel()}destroy(){this._sketchViewModel.destroy()}get allowSave(){return!this.updating}get curveResizeDisabled(){return this.data.curveResizeDisabled}get curveUpdatesDisabled(){return this.data.curveUpdatesDisabled}get formViewModel(){return this._formViewModel}get hasInvalidFormTemplate(){return!!this.data.editorItem?.hasInvalidFormTemplate}get hasPendingEdits(){if(this.pendingFeatures.some(e=>!!this.data.getEditsForPendingFeature(e)?.modified))return!0;const{creationInfo:e,upload:t}=this.data,{activeComponent:a,createGraphic:i}=this._sketchViewModel,r=i?.geometry?.type;return!("polyline"!==r&&"polygon"!==r&&"multipoint"!==r||"draw-2d"!==a?.type&&"draw-3d"!==a?.type)&&a.drawOperation.committedVertices.length>0||(!(!t||"pending"!==t.state&&"success"!==t.state)||!!e?.geometryToPlace)}get hasPreviousStep(){return this._stepIndex>0||"update-pending"===this.createFeatureState&&!!this.data.selectedPendingFeature&&!this.parent&&!L(this.data.creationInfo)}get helpMessage(){const{creationInfo:e,viewModel:t}=this.data;if("creating-features"!==this.stepId||!e)return;const{_sketchViewModel:a}=this,{drawTool:i,isUsingLegacyCreateTools:r}=a;if(!r)return i?.helpMessageKey??"noTool";const s=e.layer.geometryType,o=a.createGraphic;if("mesh"===s){this._getDrawMeshHelpMessage||import("../../../views/draw/support/helpMessageUtils3d.js").then(e=>{this._getDrawMeshHelpMessage=e.getDrawMeshHelpMessage});const{view:e}=t;return"3d"===e?.type?this._getDrawMeshHelpMessage?.(o,e):void 0}const{activeCreateToolDrawMode:n,activeTool:l}=a;return P("rectangle"===l||"circle"===l?l:s,o?.geometry,n)}get noticeMessage(){if(O(this._sketchViewModel,this.data.editorItem))return"curveToolDensifyWarning"}get layer(){return this.data.creationInfo?.layer}get numPendingFeatures(){return this.pendingFeatures.length}get numPendingFeaturesExcludingHidden(){return this.pendingFeatures.filter(e=>this.data.isDisplayable(e)).length}get parent(){return this.data.parent}get pendingFeatures(){return this.data.pendingFeatures}get keyboardCancellationEnabled(){return 0===this.numPendingFeatures}get reliesOnOwnerAdminPrivileges(){return this.data.editorItem?.capabilities.create.reliesOnOwnerAdminPrivileges??!1}get saveActionLabel(){return"create"}get shouldShowAttachments(){return(this.data.selectedPendingFeature&&this.data.editorItem?.capabilities.create.attachments.enabled)??!1}get shouldAllowAttachmentEditing(){return this.shouldShowAttachments}get sketchUpdateOptions(){const{editorItem:e}=this.data;return{enableScaling:!this.curveResizeDisabled,multipleSelectionEnabled:!1,reshapeOptions:{enableCreateCurveFromStraightEdge:!V(e?.layer)&&!!e?.capabilities.supportsTrueCurve}}}get sketchViewModel(){return this._sketchViewModel}get test(){}get availableCreateTools(){const e=this.data.creationInfo?.layer.geometryType,t=this.data.viewModel.view;if(!e)return[];if(this.data.creationInfo?.maxFeatures&&this.data.creationInfo.maxFeatures<=this.numPendingFeatures)return[];if(v(this.data.fullTemplate)){const{tool:t}=x(e,this.data.fullTemplate);return[t]}return"2d"!==t?.type&&"multipoint"===e?[]:[...me[e]]}get _attachmentsActive(){const e=this.data.viewModel.attachmentsViewModel.mode,t=this.stepId;return this.shouldShowAttachments&&("add"===e||"edit"===e||"adding-attachment"===t||"editing-attachment"===t)}getUpdating(){return!!this._sketchViewModel?.updating}async enter(){this._isActive=!0,"awaiting-feature-creation-info"!==this.stepId&&await this._updatingHandles.addPromise(this._setUpCreatingFeaturesStep())}exit(){this._isActive=!1,this.removeHandles([pe])}async updatePendingFeature(e){if(e!==this.data.selectedPendingFeature)return this._sketchViewModel.cancel(),this._startUpdating({feature:e})}async start(){return await super.start(),k(this.data.creationInfo?.layer)?null:{enter:async()=>{},exit:async()=>{},viewModel:this._sketchViewModel}}async save(e){const{formViewModel:t}=this;if(t.pendingSubtypeChoice)return;t.submit(),this._stashValidationState();const a=this.data.selectedPendingFeature,i=this._hasValidationErrors(a)?a:this.data.pendingFeatures.find(e=>this._hasValidationErrors(e));if(i)return await this._startUpdating({feature:i}),void t?.submit();const{pendingFeatures:r,editorItem:s}=this.data;if(s&&e&&D(r.toArray(),s)){if(!await e("curveEditingDensifyPrompt"))return this.reset()}return super.save()}back(e){return"update-pending"!==this.createFeatureState||!this.data.selectedPendingFeature||L(this.data.creationInfo)||this._attachmentsActive||this.parent?super.back(e):this._clearSelectedFeature()}previous(e){return"update-pending"!==this.createFeatureState||!this.data.selectedPendingFeature||L(this.data.creationInfo)||this._attachmentsActive?super.previous(e):this._clearSelectedFeature()}cancelFeature(e){this.data.isSharedTemplateWorkflow?o.getLogger(this).warn("Cannot cancel individual features created by shared templates."):(this.data.removePendingFeature(e),this.sketchViewModel.removeGraphic(e))}static create(e){const{addAttachmentsCallback:t,applyEdits:a,applyEditsFeatureService:i,isNested:r,creationInfo:s,parent:o,snappingManager:n,startAt:l,viewModel:d}=e,c=e.sketchOptions??new U,u=s?.layer,p=u?z(d.editorItems,u):void 0,h=new de({data:new re({creationInfo:s,editorItem:p,parent:o,sketchOptions:c,snappingManager:n,viewModel:d}),isNested:r,onCommit:async e=>{const{creationInfo:r}=e;if(!r)return;h._sketchViewModel.cancel();const s=e.pendingFeatures.toArray(),{layer:o}=r,n=o.capabilities?.editing.supportsGlobalId&&"globalIdField"in o,l=h._attachmentFileInfos,{fullTemplate:c}=e,u=R(h.data),p=F(c)&&u;if(n){if(ve(s),p){let t=_e(u,l);const a=await(W(o,d.view)?.load());a&&(t=G({edits:t,serviceInfo:a,view:d.view,findOriginalFeature:t=>e.getEditsForPendingFeature(t)?.initialFeature??t})),await i(c.featureService,t,{globalIdUsed:!0,honorSequenceOfEdits:!0,gdbVersion:c.layer.gdbVersion??void 0})}else{const e=Fe(s,l);await a(o,e,{globalIdUsed:!0})}return}const m=p?await i(c.featureService,u,{gdbVersion:c.layer.gdbVersion??void 0}):[await a(o,{addFeatures:s})];m&&l.size>0&&await Promise.all(m.map(e=>{if(e?.addFeatureResults)return t(o,ye(s,e.addFeatureResults,o,l))}))}});return h._set("steps",this._createWorkflowSteps(h,l)),h}_fadeExistingFeatures(e){if("effect"in e){const t=e.effect;return e.effect="saturate(0.6) opacity(0.8)",i(()=>e.effect=t)}const t=e.opacity;return e.opacity=.7,i(()=>e.opacity=t)}async _initializeFullTemplateAndExecutorInfo(e){const{creationInfo:t}=e,{view:a}=e.viewModel;if(!t||!a)return null;const i=await M(a,t.template);if(e.fullTemplate=i,i&&F(i)){const{createTemplateExecutor:r}=await import("../../../editing/sharedTemplates/executor/createTemplateExecutor.js"),s={completionResults:[],executor:await r(i),serviceLayersById:N(t.layer,a)};e.templateExecutorInfo=s}return i}async _startCreating(){this.removeHandles(ue);const{data:e}=this;if(!e.creationInfo)return;const t=this.data.creationInfo?.maxFeatures;if(t&&this.numPendingFeatures>=t)return this.sketchViewModel.cancel(),void(this.numPendingFeatures&&await this._startUpdating({feature:this.pendingFeatures.at(-1)}));this.createFeatureState="create-new",await K(this._sketchViewModel,this._sketchLayer,e)}async _clearSelectedFeature(){const e=this._formViewModel.pendingSubtypeChoice;e&&(e.resolve("undo"),await e.promise),this._stashValidationState(),this.sketchViewModel.cancel(),this.data.selectedPendingFeature=null,this._featureFormHandle=n(this._featureFormHandle),this._formViewModel.feature=null;const t=this.data.viewModel.attachmentsViewModel;"add"!==t.mode&&"edit"!==t.mode||await(this.data.viewModel.activeWorkflow?.previous())}_stashValidationState(){const e=this._formViewModel.feature,t=e&&this.data.getEditsForPendingFeature(e);t&&(t.submittable=this._formViewModel.submittable)}async _selectFeatureForUpdate({feature:e,initialFeature:t=e}){this._stashValidationState();const{data:a,pendingFeatures:i}=this;i.includes(e)||a.addPendingFeature(e,t),a.selectedPendingFeature=e;const{_formViewModel:s,_sketchViewModel:o,sketchUpdateOptions:l}=this,{creationInfo:d,viewModel:c}=a,{attachmentsViewModel:p,layerInfos:h,view:m}=c;if(!m||!d)return;Z(o,l),n(this._featureFormHandle);const f=e.sourceLayer,g=q(h,f),w=g?.formTemplate,y=m.spatialReference;s.set({editType:"INSERT",feature:e,formTemplate:w,spatialReference:y,map:m.map}),"add"!==p.mode&&"edit"!==p.mode||await(c.activeWorkflow?.previous()),p.graphic=e,p.fileInfos.removeAll(),p.mode="view";(this._attachmentFileInfos.get(e)||[]).forEach(({file:e,form:t})=>p.addFile(e,t)),await A(e,"2d"===m.type?m.scale:null);const v=a.getEditsForPendingFeature(e);this._featureFormHandle=r([s.on("value-change",async({fieldName:t,value:a})=>{if(v?.updateAttributes(s.getValues()),S(a)){const e=this._visualVariableAttributes;e.size&&!e.size.isUpdatingInteractively&&t===e.size.field&&e.size.setInitialValue(a),e.rotation&&!e.rotation.isUpdatingInteractively&&t===e.rotation.field&&e.rotation.setInitialValue(a)}await A(e,"2d"===m.type?m.scale:null)}),o.on(["update","undo","redo"],e=>{("undo"===e.type||"redo"===e.type||"update"===e.type&&null!=e.toolEventInfo&&B(e.toolEventInfo.type))&&s.notifyFeatureGeometryChanged()}),u(()=>s.feature?.sourceLayer,t=>e.sourceLayer=t),u(()=>[s.feature,s.submittable],()=>this._stashValidationState())]),this.createFeatureState="update-pending"}async _startUpdating({feature:e,initialFeature:t=e}){await this._selectFeatureForUpdate({feature:e,initialFeature:t});const{_sketchLayer:a,_sketchViewModel:i,data:r}=this,{creationInfo:s,viewModel:o}=r,{view:n}=o;if(!n||!s)return;const l=e.sourceLayer??s.layer;return k(l)?void 0:(this._visualVariableAttributes=J(e),Q({graphic:e,sketchLayer:a,sketchViewModel:i,sourceLayer:l,updateOptions:this.sketchUpdateOptions,visualVariables:this._visualVariableAttributes}))}static _createWorkflowSteps(e,t="awaiting-feature-creation-info"){const{data:a}=e,i=X(["awaiting-feature-creation-info","creating-features","adding-attachment","editing-attachment"],t,{"awaiting-feature-creation-info":()=>({id:"awaiting-feature-creation-info",async setUp(){const{creationInfo:t,viewModel:i}=a,{view:r}=i;r&&(L(t)?e.addHandles(await j({view:r,data:a,next:()=>e.next(),cancel:()=>i.cancelWorkflow({warnIfNoWorkflow:!1})}),this.id):(a.parent&&t&&e.addHandles(i.restrictFeatureTemplatesViewModelToLayer(t.layer),this.id),e.addHandles(i.featureTemplatesViewModel.on("select",({item:t})=>{t&&(a.creationInfo={...a.creationInfo,layer:t.layer,template:t.template},e.next())}),this.id)))},async tearDown(){e.removeHandles(this.id)}}),"creating-features":()=>({id:"creating-features",async setUp(){e._isActive&&await e._setUpCreatingFeaturesStep()},async tearDown(t){const{viewModel:i}=a;t.canceled&&(e.removeHandles([pe,ce,ue,he]),i.attachmentsViewModel.fileInfos.removeAll(),e._attachmentFileInfos.clear())}}),"adding-attachment":()=>({id:"adding-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=a.viewModel,{graphic:i,fileInfos:r}=t;e._attachmentFileInfos.set(i,r.toArray()),t.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=a.viewModel,{graphic:i,fileInfos:r}=t;e._attachmentFileInfos.set(i,r.toArray()),t.mode="view"}})});return Y(a,i)}static _configureSketchViewModel(e){const{data:t,_sketchLayer:a,_sketchViewModel:s}=e,{creationInfo:o,viewModel:n}=t,{view:l}=n,d=[];if(!l)return i();if("2d"===l.type){o&&d.push(e._fadeExistingFeatures(o.layer));const t=c((e,t)=>Promise.all(e.map(e=>A(e,t))));d.push(u(()=>l.scale,e=>t(a.graphics,e)))}const p=_(t.fullTemplate,o?.attributeOverrides,o?.layer),h=u(()=>s.createGraphic&&s.activeComponent,()=>{s.createGraphic&&s.activeComponent&&!e.hasHandles(ue)&&e._updatingHandles.consumePromise($({creationAttributes:p,data:t,sketchViewModel:s,view:l}).then(t=>e.addHandles(t,ue)))}),m=async t=>{if("cancel"!==t.state&&"complete"!==t.state||e.removeHandles(ue),"cancel"===t.state&&null!==l.activeTool&&l.activeTool!==e.sketchViewModel.activeComponent&&(await e._waitForActiveToolCleared(),await e._startCreating()),"complete"===t.state&&t.graphic){const a=await e._processEdits(t.graphic,{scale:"2d"===l.type?l.scale:null,useSourceLayer:!0});a&&(await e._waitForActiveToolCleared(),await e._startUpdating({feature:a}))}},f=async i=>{const{attachmentsViewModel:r}=n,{_formViewModel:d}=e;if(i.graphics.length>1)return void await e._clearSelectedFeature();const c=i.graphics[0];if("complete"===i.state){const{submittable:t}=d;if(e.numPendingFeatures!==o?.maxFeatures&&t||d.submit(),await e._clearSelectedFeature(),"add"!==r.mode&&"edit"!==r.mode||await(n.activeWorkflow?.previous()),null==e.data.selectedPendingFeature&&(null==l.activeTool||l.activeTool===e.sketchViewModel.activeComponent)&&(await e.sketchViewModel.wait(),"ready"===e.sketchViewModel.state&&"mesh"!==e.data.creationInfo?.layer.geometryType))return e._startCreating()}else{if("start"===i.state)return c.sourceLayer??=t.creationInfo?.layer,await ae({graphic:c,sketchLayer:a,sketchViewModel:s,visualVariables:e._visualVariableAttributes,sourceLayer:c.sourceLayer}),e._selectFeatureForUpdate({feature:c});if("active"===i.state){await e.updatePendingFeature(c);const t=e._visualVariableAttributes;ie(l,c,i,t)&&await A(c,"2d"===l.type?l.scale:null);const a=c.attributes,{rotation:r,size:s}=t;if(null!=r){const{field:e}=r;d.setValue(e,a[e])}if(null!=s){const{field:e}=s;d.setValue(e,a[e])}}}},g=async a=>{if(a.graphics.forEach(e=>{t.removePendingFeature(e)}),!L(t.creationInfo))return e._startCreating()},w=async()=>{if(L(t.creationInfo))try{await e.data.viewModel.back()}catch{}return e._startCreating()};d.push(h,s.on("create",t=>e._updatingHandles.addPromise(m(t))),s.on("update",t=>e._updatingHandles.addPromise(f(t))),s.on("delete",t=>e._updatingHandles.addPromise(g(t))),e._updatingHandles.addWhen(()=>!e.numPendingFeatures,()=>e._updatingHandles.addPromise(w())),i(()=>{s.cancel()}),ge(s,a,t),...we(t));const y=r(d);return s.addHandles(y),y}_initializeSketchViewModel(){const{data:e}=this,{view:t}=e.viewModel,a=new I({elevationInfo:e.creationInfo?.layer.elevationInfo,internal:!0,listMode:"hide",title:"createFeaturesWorkflow-internal"}),r=new le({layer:a,creationMode:"single",sketchOptions:e.sketchOptions,snappingManager:e.snappingManager,useLegacyCreateTools:e.viewModel.useLegacyCreateTools,updateOnGraphicClick:!1,defaultUpdateOptions:this.sketchUpdateOptions,view:t});this._sketchLayer=a,this._sketchViewModel=r,t?.map.add(a),this.addHandles([i(()=>{t?.destroyed||t?.map.remove(a),l(a)}),u(()=>this.numPendingFeatures>0,e=>this._sketchViewModel.updateOnGraphicClick=e,p),u(()=>this.sketchUpdateOptions,e=>{r.defaultUpdateOptions=e,Z(r,e)},h)])}_hasValidationErrors(e){return!!e&&(!this.data.isSubmittable(e)||!!this._formViewModel.validateContingencyConstraints(e.attributes,{includeIncompleteViolations:!0})?.length)}async _processEdits(e,t){const{data:a,_formViewModel:i,_sketchLayer:r}=this,{layerInfos:s,view:o}=a.viewModel;i.editType="INSERT",i.map=o?.map,i.spatialReference=o?.spatialReference;const{templateExecutorInfo:n}=a;if(!n){const t=e.clone();return t.geometry=null,await this._addAndInitializeEdits(e,t),e}r.remove(e);const{executor:l}=n,c=l(e.geometry,"completion"),u=d(c)?await c:c;n.completionResults.push(u),ee(u.relationships),i.editType="INSERT",i.map=o?.map,i.spatialReference=o?.spatialReference,u.primary&&a.creationInfo?.attributeOverrides&&(u.primary.graphic.attributes={...u.primary.graphic.attributes,...a.creationInfo.attributeOverrides});for(const d of u.edits){let e=null;if(d.addFeatures)for(const a of d.addFeatures){const i=a.clone();i.geometry=null,null!=a.geometry&&(a.symbol=await T(a,t),r.add(a)),a.sourceLayer!==e?.layer&&(e=q(s,a.sourceLayer));const o=!!u.associationGraphics?.has(a);await this._addAndInitializeEdits(a,i,e,o)}}i.feature=null,await m(()=>!i.updating);return u.edits.reduce((e,t)=>e+(t.addFeatures?.length??0),0)>1?null:u.primary?.graphic}async _addAndInitializeEdits(e,t,a,i=!1){const{data:r,_formViewModel:s}=this,{layerInfos:o}=r.viewModel,n=r.addPendingFeature(e,t,{isAssociation:i});a??=q(o,e.sourceLayer),s.feature=e,s.formTemplate=a?.formTemplate,await m(()=>!s.updating),n.updateAttributes(s.getValues()),n.submittable=s.submittable}async _setUpCreatingFeaturesStep(){if(this.hasHandles(pe))return;const{data:e,sketchViewModel:s}=this,{creationInfo:o,viewModel:l}=e,{attachmentsViewModel:d,view:c}=l;if(!c||!o?.layer)throw new a("missing-parameters","CreateFeaturesWorkflow requires a view and creationInfo.");const{initialFeature:h,layer:m}=o,f=[],g=[];this._featureFormHandle=n(this._featureFormHandle),this._visualVariableAttributes={rotation:null,size:null},e.editorItem=z(l.editorItems,o.layer),o.template&&(null==e.fullTemplate&&await this._initializeFullTemplateAndExecutorInfo(e),g.push(i(()=>{e.templateExecutorInfo&&(e.templateExecutorInfo.completionResults=[])}))),s.allowDeleteKey=!e.isSharedTemplateWorkflow,oe(d),f.push(u(()=>d.mode,e=>{switch(e){case"add":this.go("adding-attachment");break;case"edit":this.go("editing-attachment")}}));const w=te(c);f.push(w);const y=k(o.layer),{template:F}=o,M=!F||b(F)||v(F)&&"feature"===F.type,I=y&&M;try{if(I){const a=h??new t({attributes:_(e.fullTemplate,o.attributeOverrides,m),sourceLayer:m}),i=await this._processEdits(a);i&&await this._startUpdating({feature:i})}else f.push(de._configureSketchViewModel(this)),h?(L(o)&&o.geometryToPlace&&(h.attributes=_(e.fullTemplate,o.attributeOverrides,m)),s.addGraphic(h),await this._startUpdating({feature:h})):await this._startCreating()}finally{w.remove()}const V=i(()=>{for(const t of e.pendingFeatures)s.removeGraphic(t),e.removePendingFeature(t)}),S=u(()=>c?.timeZone,e=>{this._formViewModel.timeZone=e,this.data.timeZone=e},p),T=i(()=>{L(o)&&l.cancelWorkflow({warnIfNoWorkflow:!1})});this._featureFormHandle&&f.push(this._featureFormHandle),this.addHandles(f,this._handleKeys.beforeCommit),this.addHandles(g,this._handleKeys.afterCommit),this.addHandles([i(()=>d.fileInfos.removeAll()),r(f),r(g),T,V,S],pe)}async _waitForActiveToolCleared(){const e=this.data.viewModel.view;if(null==e?.activeTool)return;const t=new AbortController;this.addHandles(s(t),he),await m(()=>null==e?.activeTool,t.signal),t.abort()}};function ge(e,t,a){let s=null;const o=()=>e.snappingOptions.featureSources,n=()=>(s=new C({layer:t}),o().add(s),s),d=()=>{null!=s&&(o().remove(s),s=l(s))};return r([u(()=>{const e=a.creationInfo?.layer,t=o().find(t=>t.layer===e);return{hasFeatureLayerSource:!!t,enabled:t?.enabled??!1}},({hasFeatureLayerSource:e,enabled:t})=>{if(!e)return d();s??=n(),s.enabled=t},f),i(d)])}function we(e){const t=e.viewModel.view;if(!t)return[];const a=[];if("3d"===t.type){const r=new E({view:t});a.push(u(()=>e.selectedPendingFeature,(e,t)=>{r.remove(e),r.add(t)}),i(()=>r.destroy()))}const r=new E({view:t,highlightName:H});return a.push(u(()=>e.temporaryHighlightFeature,e=>{r.removeAll(),r.add(e)}),i(()=>r.destroy())),a}function ye(e,t,a,i){const r=[];return t.forEach((t,s)=>{if(!t.error){const o=e[s],n=i.get(o)||[];o.attributes[a.objectIdField]=t.objectId,n.forEach(({form:e})=>r.push({feature:o,attachment:e}))}}),r}function ve(e){for(const t of e){const{sourceLayer:e}=t;e&&"globalIdField"in e&&null!=e.globalIdField&&(t.attributes[e.globalIdField]??=g())}}function Fe(e,t){const a=[];if(!t||0===t.size)return{addFeatures:e};for(const[i,r]of t)for(const{file:e}of r)a.push({feature:i,attachment:{globalId:g(),data:e}});return a.length?{addFeatures:e,addAttachments:a}:{addFeatures:e}}function _e(e,t){return e.map(e=>{const{addFeatures:a}=e;if(!a||0===a.length)return e;const i=[];for(const r of a){const e=t.get(r);if(e)for(const{file:t}of e)i.push({feature:r,attachment:{globalId:g(),data:t}})}return i.length?{...e,addAttachments:i}:e})}e([w()],fe.prototype,"allowSave",null),e([w()],fe.prototype,"createFeatureState",void 0),e([w()],fe.prototype,"curveResizeDisabled",null),e([w()],fe.prototype,"curveUpdatesDisabled",null),e([w()],fe.prototype,"data",void 0),e([w({constructOnly:!0})],fe.prototype,"isNested",void 0),e([w()],fe.prototype,"formViewModel",null),e([w()],fe.prototype,"hasInvalidFormTemplate",null),e([w()],fe.prototype,"hasPendingEdits",null),e([w()],fe.prototype,"hasPreviousStep",null),e([w()],fe.prototype,"_getDrawMeshHelpMessage",void 0),e([w()],fe.prototype,"helpMessage",null),e([w()],fe.prototype,"noticeMessage",null),e([w()],fe.prototype,"layer",null),e([w()],fe.prototype,"parent",null),e([w()],fe.prototype,"keyboardCancellationEnabled",null),e([w()],fe.prototype,"reliesOnOwnerAdminPrivileges",null),e([w()],fe.prototype,"saveActionLabel",null),e([w()],fe.prototype,"shouldShowAttachments",null),e([w()],fe.prototype,"shouldAllowAttachmentEditing",null),e([w()],fe.prototype,"sketchUpdateOptions",null),e([w()],fe.prototype,"sketchViewModel",null),e([w()],fe.prototype,"availableCreateTools",null),e([w()],fe.prototype,"_attachmentsActive",null),fe=de=e([y("esri.widgets.Editor.legacy.CreateFeaturesWorkflow")],fe);const be=fe;export{be as default};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import i from"../../../core/Collection.js";import r from"../../../core/Logger.js";import s from"../../../core/ReactiveMap.js";import{property as o,subclass as n}from"../../../core/accessorSupport/decorators.js";import{isSharedTemplateOrMetadata as a}from"../../../editing/templateUtils.js";import{hasCircularArc as l,isCurvedGeometry as p}from"../../../geometry/support/curves/curveUtils.js";import u from"../Edits.js";const d=()=>r.getLogger("esri.widgets.Editor.CreateFeaturesWorkflowData");let g=class extends t{constructor(e){super(e),this.creationInfo=null,this.editorItem=null,this.fullTemplate=null,this.parent=null,this.temporaryHighlightFeature=null,this.sketchOptions=null,this.snappingManager=null,this.templateExecutorInfo=null,this.viewModel=null,this.upload=null,this._pendingEdits=new s}get attachmentsModified(){return[...this._pendingEdits.values()].some(e=>e.attachmentsModified)}get curveResizeDisabled(){return this.hasCurves&&l(this.selectedPendingFeature?.geometry)&&!this.editorItem?.supportedCurveTypes.includes("elliptic-arc")}get curveUpdatesDisabled(){return this.hasCurves&&!1===this.editorItem?.capabilities.supportsTrueCurveUpdate}get hasCurves(){const e=this.selectedPendingFeature;return!(!e?.geometry||!p(e.geometry))}get isSharedTemplateWorkflow(){return!!this.fullTemplate&&a(this.fullTemplate)}get pendingFeatures(){return new i([...this._pendingEdits.keys()])}set selectedPendingFeature(e){this._set("selectedPendingFeature",e),this.temporaryHighlightFeature=null}set timeZone(e){this._set("timeZone",e),this._pendingEdits.forEach(t=>{t.timeZone=e})}isSubmittable(e){const t=this._pendingEdits.get(e);return!!t?.submittable||!!t?.isAssociation}isDisplayable(e){return!this._pendingEdits.get(e)?.isAssociation}addPendingFeature(e,t=e,i={isAssociation:!1}){this.temporaryHighlightFeature=null;const{_pendingEdits:r}=this;if(r.has(e))return r.get(e);e.sourceLayer||d().warn("source-layer-not-set","A feature added to `pendingFeatures` did not have `sourceLayer` set. This may cause problems throughout `CreateFeaturesWorkflow`.");const s=new u({feature:e,isAssociation:i.isAssociation});return s.trackChanges(t),r.set(e,s),s}getEditsForPendingFeature(e){return this._pendingEdits.get(e)}removePendingFeature(e){this.temporaryHighlightFeature=null;const{_pendingEdits:t}=this,i=t.get(e);i&&(i.destroy(),t.delete(e)),this.selectedPendingFeature===e&&(this.selectedPendingFeature=null)}getFeatureTitle(e){return this._pendingEdits.get(e)?.displayTitle}};e([o()],g.prototype,"attachmentsModified",null),e([o()],g.prototype,"creationInfo",void 0),e([o()],g.prototype,"curveResizeDisabled",null),e([o()],g.prototype,"curveUpdatesDisabled",null),e([o()],g.prototype,"editorItem",void 0),e([o()],g.prototype,"fullTemplate",void 0),e([o()],g.prototype,"hasCurves",null),e([o()],g.prototype,"isSharedTemplateWorkflow",null),e([o()],g.prototype,"parent",void 0),e([o()],g.prototype,"pendingFeatures",null),e([o()],g.prototype,"selectedPendingFeature",null),e([o()],g.prototype,"temporaryHighlightFeature",void 0),e([o({constructOnly:!0})],g.prototype,"sketchOptions",void 0),e([o()],g.prototype,"snappingManager",void 0),e([o()],g.prototype,"templateExecutorInfo",void 0),e([o()],g.prototype,"viewModel",void 0),e([o()],g.prototype,"upload",void 0),e([o()],g.prototype,"timeZone",null),g=e([n("esri.widgets.Editor.legacy.CreateFeaturesWorkflowData")],g);const h=g;export{h as default};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ 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{destroyMaybe as o}from"../../../core/maybe.js";import{on as s,whenOnce as n,watch as l,initial as d}from"../../../core/reactiveUtils.js";import{property as h,subclass as m}from"../../../core/accessorSupport/decorators.js";import u from"../../../layers/GraphicsLayer.js";import{updateGraphicSymbolWhenRequired as p}from"../../../views/draw/support/editingSessionUtils.js";import c from"../../../views/draw/support/HighlightHelper.js";import{temporaryHighlightName as w}from"../../../views/support/HighlightDefaults.js";import f from"../Edits.js";import{makeMinimalAttributes as g}from"../workflowUtils.js";import y from"./MergeFeaturesWorkflowData.js";import F from"./Workflow.js";import{assertViewNot3D as v,assertMergeWorkflowCapabilities as _,assertMinimumFeatureCount as M,assertFeaturesAreFromSameLayer as k,InvalidKeyFeatureError as V}from"../support/errors.js";import{mergeFeatures as j}from"../support/mergeFeaturesUtils.js";import H from"../../FeatureForm/FeatureFormViewModel.js";var I;const b=Symbol();let A=I=class extends F{constructor(e){super(e),this.type="merge-features",this._formViewModel=null,this._graphicsLayer=null,this._highlightHelper=null}initialize(){const e=this.data.viewModel.view;this._highlightHelper=e?new c({view:e}):null,this._initializeFeatureFormViewModel(),this._initializeGraphicsLayer(),this._createAndInitializeEdits(this.data.keyFeature)}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._highlightHelper?.destroy()}get formViewModel(){return this._formViewModel}get hasPendingEdits(){return!1}get layer(){return this.data.editorItem.layer}get parent(){return this.data.parent}get shouldShowAttachments(){return this.data.editorItem.capabilities.attachments.enabled}static async create(e){const{applyEdits:t,applyEditsFeatureService:i,...r}=e,{editorItem:a,features:o}=r;if(v(r.viewModel,"merge-features"),_(a),M(o,2),k(o),r.keyFeature&&!o.includes(r.keyFeature))throw new V;const s=await j(o),n=new I({data:new y({...r,mergedGeometry:s}),onCommit:L(t)});return n._set("steps",S()),n}async enter(){this._configureAttachmentsViewModel()}exit(){}isKeyFeature(e){return this.data.keyFeature===e}isTemporaryHighlightFeature(e){return this.data.temporaryHighlightFeature===e}async setKeyFeature(e){const{data:t}=this;if(e!==t.keyFeature){if(!t.features.includes(e))throw new V;t.keyFeature=e,await this._createAndInitializeEdits(e)}}async start(){return await super.start(),this._makeSketchController()}getFeatureTitle(e){return this.data.getFeatureTitle(e)}async _createAndInitializeEdits(e){const{data:t}=this,i=e.clone();i.geometry=t.mergedGeometry;const r=new f({feature:i});t.edits=r;const a=t.getInitialFeature(e)||e;r.trackChanges(a),await this._setFeatureOnFormViewModel(i,a),this._setFeatureOnAttachmentsViewModel(e)}_initializeFeatureFormViewModel(){const{data:e}=this,t=e.viewModel.view,i=new H({disabled:!0,editType:"UPDATE",formTemplate:e.editorItem.formTemplate,highlightHelper:this._highlightHelper,map:t?.map,spatialReference:t?.spatialReference,timeZone:e.timeZone});this._formViewModel=i,this.addHandles(s(()=>i,"value-change",({feature:i,fieldName:r,value:a})=>{const o=e.edits;i&&o&&(o.setAttribute(r,a),p(i,t?.scale))}))}_initializeGraphicsLayer(){const{data:e}=this,{view:t}=e.viewModel,i=new u({elevationInfo:e.editorItem.layer.elevationInfo,internal:!0,listMode:"hide",title:"mergeFeaturesWorkflow-internal"});this._graphicsLayer=i,t?.map.add(i)}_makeSketchController(){return{enter:async()=>{this.addHandles(z(this.data),b)},exit:()=>{this.removeHandles(b)}}}async _setFeatureOnFormViewModel(e,t){const i=this._formViewModel;i.feature=e,i.overrideInitialFeature(t),await n(()=>!i.updating)}_configureAttachmentsViewModel(){const{data:e}=this,{keyFeature:t,viewModel:i}=e,{attachmentsViewModel:r}=i;r.set({capabilities:{editing:!1},graphic:t,filesEnabled:!1,mode:"view"})}_setFeatureOnAttachmentsViewModel(e){this.data.viewModel.attachmentsViewModel.graphic=e}};e([h()],A.prototype,"formViewModel",null),e([h()],A.prototype,"hasPendingEdits",null),e([h()],A.prototype,"layer",null),e([h()],A.prototype,"parent",null),e([h()],A.prototype,"shouldShowAttachments",null),e([h()],A.prototype,"type",void 0),e([h()],A.prototype,"_formViewModel",void 0),e([h()],A.prototype,"_graphicsLayer",void 0),e([h()],A.prototype,"_highlightHelper",void 0),A=I=e([m("esri.widgets.Editor.legacy.MergeFeaturesWorkflow")],A);const E=A;function S(){return[{id:"choosing-key-feature",async setUp(){},async tearDown(){}}]}function L(e){return async i=>{const{edits:r,keyFeature:a}=i,o=r?.feature?.cloneShallow(),s=i.editorItem.layer;if(!r||!o)throw new t("editing:missing-feature","Workflow data has no edits to submit.");r.attributesModified||(o.attributes=g(o,i.editorItem.layer));const n=[];for(const e of i.features){if(e===a)continue;const t=e.cloneShallow();t.attributes=g(t,s),t.geometry=null,n.push(t)}await e(s,{updateFeatures:[o],deleteFeatures:n})}}function z(e){const t=e.viewModel.view;if(!t)return i();const o=new c({view:t});for(const i of e.features)o.add(i);const s=new c({view:t,highlightName:w}),n=l(()=>e.keyFeature,e=>{s.removeAll(),s.add(e)},d),h=new c({view:t,highlightName:w}),m=l(()=>e.temporaryHighlightFeature,e=>{h.removeAll(),e&&h.add(e)});return r([a(o),n,a(s),m,a(h)])}export{E as default};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import i from"../../../core/ReactiveMap.js";import{property as r,subclass as o}from"../../../core/accessorSupport/decorators.js";let a=class extends t{constructor(e){super(e),this._featureTitleMap=null,this.editorItem=null,this.features=[],this.initialFeatures=[],this.keyFeature=null,this.edits=null,this.mergedGeometry=null,this.parent=null,this.temporaryHighlightFeature=null,this.viewModel=null}async initialize(){const{features:e,timeZone:t}=this,{layer:r}=this.editorItem;if(this.keyFeature??=e[0],0===this.initialFeatures.length&&(this.initialFeatures=e.slice()),!("getFeatureTitle"in r))return;const o=await Promise.all(e.map(async e=>[e,await r.getFeatureTitle(e,{fetchMissingFields:!1,timeZone:t})]));this._featureTitleMap=new i(o)}get _initialFeatureMap(){const e=new Map(this.initialFeatures.map(e=>[e.getObjectId(),e])),t=new Map(this.features.map(e=>[e.getObjectId(),e])),i=new Map;for(const[r,o]of t){const t=e.get(r);r&&t&&i.set(o,t)}return i}get timeZone(){return this.viewModel.view?.timeZone}set timeZone(e){null==e?this._clearOverride("timeZone"):this._override("timeZone",e)}getFeatureTitle(e){return this._featureTitleMap?.get(e)}getInitialFeature(e){return this._initialFeatureMap.get(e)}};e([r()],a.prototype,"_featureTitleMap",void 0),e([r()],a.prototype,"_initialFeatureMap",null),e([r({constructOnly:!0})],a.prototype,"editorItem",void 0),e([r({constructOnly:!0})],a.prototype,"features",void 0),e([r()],a.prototype,"initialFeatures",void 0),e([r()],a.prototype,"keyFeature",void 0),e([r()],a.prototype,"edits",void 0),e([r()],a.prototype,"mergedGeometry",void 0),e([r()],a.prototype,"parent",void 0),e([r()],a.prototype,"temporaryHighlightFeature",void 0),e([r()],a.prototype,"timeZone",null),e([r()],a.prototype,"viewModel",void 0),a=e([o("esri.widgets.Editor.legacy.MergeFeaturesWorkflowData")],a);const s=a;export{s as default};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ 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 n,on as l,whenOnce as p,initial as d}from"../../../core/reactiveUtils.js";import{property as u,subclass as c}from"../../../core/accessorSupport/decorators.js";import h from"../../../layers/GraphicsLayer.js";import{swapForEditingSession as m,updateGraphicSymbolWhenRequired as y}from"../../../views/draw/support/editingSessionUtils.js";import{getDrawHelpMessage as w}from"../../../views/draw/support/helpMessageUtils.js";import g from"../../../views/draw/support/HighlightHelper.js";import f from"../../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{temporaryHighlightName as v}from"../../../views/support/HighlightDefaults.js";import _ from"../Edits.js";import{activeSketchToolDrawsUnsupportedCurve as F,containsUnsupportedCurve as M,createWorkflowSteps as S,makeMinimalAttributes as b}from"../workflowUtils.js";import k from"./SplitFeatureWorkflowData.js";import T from"./Workflow.js";import{assertViewNot3D as I,assertSplitWorkflowCapabilities as V}from"../support/errors.js";import{getCompatibleSpitterGeometryType as E,ensureSplittableGeometry as G,makeNewFeatureAttributes as H,splitGeometry as j,canSplitByPoint as x,isSplitterGeometry as C}from"../support/splitFeatureUtils.js";import U from"../../FeatureForm/FeatureFormViewModel.js";import L from"../../Sketch/SketchViewModel.js";import{getDrawToolGeometryTypeFromCreateTool as W}from"../../Sketch/support/sketchUtils.js";var O;const P=Symbol(),z=Symbol();let A=O=class extends T{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}initialize(){const e=this.data.viewModel.view;this._highlightHelper=e?new g({view:e,highlightName:v}):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,drawTool:r,isUsingLegacyCreateTools:a}=this._sketchViewModel;if(!a)return r?.helpMessageKey??"noTool";const o=W(t);return"mesh"!==o?w(o,i?.geometry,e):void 0}get layer(){return this.data.editorItem.layer}get parent(){return this.data.parent}get sketchUpdateOptions(){return{enableScaling:!this.curveResizeDisabled,multipleSelectionEnabled:!1}}get updating(){return this._updatingHandles.updating||this._formViewModel.updating||this._sketchViewModel.updating}get noticeMessage(){return this._splittingMayIntroduceCurves&&F(this._sketchViewModel,this.data.editorItem)?"curveToolDensifyWarning":this._lastSplitterGeometryWasInvalid?"invalidSplitterGeometry":void 0}get _splittingMayIntroduceCurves(){return"polygon"===this.data.editorItem.layer.geometryType}async back(e){if(this.activeFeature)return await this.setActiveFeature(null);await super.back(e)}static create(e){const{applyEdits:i,applyEditsFeatureService:r,defaultSplitterGeometryType:a,startAt:o,...s}=e;if(I(e.viewModel,"split-feature"),V(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=E(G(s.feature.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.feature.geometry?.type}'.`)}const n=new O({data:new k(s),defaultSplitterGeometryType:a,onCommit:R(e.applyEdits)});return n._set("steps",O._createWorkflowSteps(n,o)),n}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 commit(e){const{newFeatureEdits:t,existingFeatureEdits:i,editorItem:r}=this.data,a=[i?.feature,t?.feature].filter(e=>!!e);if(e&&M(a,r)){if(!await e("curveEditingDensifyPrompt"))return this.reset()}return super.commit()}async start(){return await super.start(),this._makeSketchController()}async _createAndInitializeEdits({newPart:e,remainingPart:t}){const{data:i}=this,r=i.feature,a=this._formViewModel,o=r.clone();o.geometry=t;const s=new _({feature:o});i.existingFeatureEdits=s,s.trackChanges(i.initialFeature),await this._setFeatureOnFormViewModel(o,"existing"),s.submittable=a.submittable;const n=r.clone();n.geometry=e,n.attributes=H(r.attributes,i.editorItem.layer);const l=new _({feature:n});return i.newFeatureEdits=l,l.trackChanges(),await this._setFeatureOnFormViewModel(n,"new"),l.submittable=a.submittable,{featureToCreate:n,featureToUpdate:o}}static _createWorkflowSteps(e,i="drawing-splitter-geometry"){const{data:r}=e;return S(["drawing-splitter-geometry","reviewing-features"],i,{"drawing-splitter-geometry":()=>({id:"drawing-splitter-geometry",async setUp(){const i=G(r.feature.geometry),a=E(i,e.defaultSplitterGeometryType),{snappingManager:o}=r;x(i)&&o&&e.addHandles(N(o,e.layer));const s=e._sketchViewModel;e.addHandles([l(()=>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(!C(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)}}}),n(()=>s.activeTool,(t,i)=>{"point"===t&&!e.hasHandles(P)&&o?e.addHandles(Z(o,e.layer),P):"point"===i&&e.removeHandles(P)})],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),n=await e._displayFeatureGraphics(s,o);e.addHandles(n,this.id)},async tearDown(){e.removeHandles(this.id)}})})}async _displayFeatureGraphics(e,t){const{data:a,_graphicsLayer:o}=this,l=a.viewModel.view,p=[];if(!e||!t||!l)return i();const d=s(i=>Promise.all([y(e,i),y(t,i)]));return await d("2d"===l.type?l.scale:null),"2d"===l.type&&p.push(n(()=>l.scale,e=>d(e))),o.add(t),p.push(i(()=>o.remove(t))),p.push(await m(o,l,a.feature,e)),r(p)}async _executeSplit(e){const{data:i}=this,{feature: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 j(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}=this,t=e.viewModel.view,i=new U({formTemplate:e.editorItem.formTemplate,highlightHelper:this._highlightHelper,map:t?.map,spatialReference:t?.spatialReference,timeZone:e.timeZone});this._formViewModel=i,this.addHandles(l(()=>i,"value-change",({feature:i,fieldName:r,value:a})=>{i&&(e.getEditsForFeature(i)?.setAttribute(r,a),y(i,t?.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 L({layer:e,creationMode:"single",sketchOptions:t.sketchOptions,snappingManager:t.snappingManager,useLegacyCreateTools:t.viewModel.useLegacyCreateTools,updateOnGraphicClick:!1,defaultUpdateOptions:this.sketchUpdateOptions,view:i})}_makeSketchController(){return{enter:async()=>this.addHandles($(this)),exit:()=>this.removeHandles(z),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.initialFeature)):r.editType="INSERT",await p(()=>!r.updating)}get test(){}};e([u()],A.prototype,"activeFeature",null),e([u()],A.prototype,"allowSave",null),e([u()],A.prototype,"availableCreateTools",null),e([u()],A.prototype,"defaultSplitterGeometryType",void 0),e([u()],A.prototype,"formViewModel",null),e([u()],A.prototype,"hasInvalidFormTemplate",null),e([u()],A.prototype,"hasPreviousStep",null),e([u()],A.prototype,"helpMessage",null),e([u()],A.prototype,"layer",null),e([u()],A.prototype,"parent",null),e([u()],A.prototype,"sketchUpdateOptions",null),e([u()],A.prototype,"type",void 0),e([u()],A.prototype,"updating",null),e([u()],A.prototype,"noticeMessage",null),e([u()],A.prototype,"_activeFeature",void 0),e([u()],A.prototype,"_formViewModel",void 0),e([u()],A.prototype,"_graphicsLayer",void 0),e([u()],A.prototype,"_highlightHelper",void 0),e([u()],A.prototype,"_lastSplitterGeometryWasInvalid",void 0),e([u()],A.prototype,"_sketchViewModel",void 0),e([u()],A.prototype,"_splittingMayIntroduceCurves",null),A=O=e([c("esri.widgets.Editor.legacy.SplitFeatureWorkflow")],A);const D=A;function R(e){return async i=>{const{existingFeatureEdits:r,newFeatureEdits:a}=i,o=r?.feature?.cloneShallow(),s=a?.feature?.cloneShallow(),n=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(n,{addFeatures:[s],updateFeatures:[o]})}}function N(e,t){if(e.options.featureSources.some(e=>e.layer===t))return i();const r=new f({enabled:!1,layer:t});return e.options.featureSources.add(r),i(()=>{e.options.featureSources.remove(r),r.destroy()})}function Z(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 n=new Map;for(const i of r.featureSources)n.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 n)e.enabled=t})}function $(e){const t=e.data,{feature:o,viewModel:s}=t,{view:l}=s;if(!l)return i();const p=new g({view:l}),u=n(()=>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 g({view:l,highlightName:v}),h=n(()=>t.temporaryHighlightFeature,(t,i)=>{i&&i!==e.activeFeature&&c.remove(i),t&&c.add(t)}),m=n(()=>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{D as default};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import{__decorate as t}from"tslib";import e from"../../../core/Accessor.js";import{property as i,subclass as r}from"../../../core/accessorSupport/decorators.js";import o from"../../../views/interactive/sketch/SketchOptions.js";let s=class extends e{constructor(t){super(t),this.editorItem=null,this.newFeatureEdits=null,this.existingFeatureEdits=null,this.feature=null,this.initialFeature=null,this.sketchOptions=new o,this.snappingManager=null,this.splitResult=null,this.splitterGeometry=null,this.temporaryHighlightFeature=null,this.viewModel=null}initialize(){this.initialFeature||(this.initialFeature=this.feature)}get timeZone(){return this.viewModel.view?.timeZone}set timeZone(t){null==t?this._clearOverride("timeZone"):this._override("timeZone",t)}getEditsForFeature(t){const{existingFeatureEdits:e,newFeatureEdits:i}=this;return e?.feature===t?e:i?.feature===t?i:null}getRoleForFeature(t){const{existingFeatureEdits:e,newFeatureEdits:i}=this;return e?.feature===t?"existing":i?.feature===t?"new":null}};t([i({constructOnly:!0})],s.prototype,"editorItem",void 0),t([i()],s.prototype,"newFeatureEdits",void 0),t([i()],s.prototype,"existingFeatureEdits",void 0),t([i()],s.prototype,"feature",void 0),t([i()],s.prototype,"initialFeature",void 0),t([i()],s.prototype,"parent",void 0),t([i({constructOnly:!0})],s.prototype,"sketchOptions",void 0),t([i()],s.prototype,"snappingManager",void 0),t([i()],s.prototype,"splitResult",void 0),t([i()],s.prototype,"splitterGeometry",void 0),t([i()],s.prototype,"temporaryHighlightFeature",void 0),t([i()],s.prototype,"timeZone",null),t([i()],s.prototype,"viewModel",void 0),s=t([r("esri.widgets.Editor.legacy.SplitFeatureWorkflowData")],s);const n=s;export{n as default};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import{makeHandle as i}from"../../../core/handleUtils.js";import"../../../core/has.js";import{destroyMaybe as s}from"../../../core/maybe.js";import{watch as a,sync as r}from"../../../core/reactiveUtils.js";import{property as o,subclass as l}from"../../../core/accessorSupport/decorators.js";import d from"../../../layers/GraphicsLayer.js";import{isSceneLayer as n}from"../../../layers/support/layerUtils.js";import{updateGraphicSymbolWhenRequired as h,swapForEditingSession as c}from"../../../views/draw/support/editingSessionUtils.js";import{highlightsSupported as p}from"../../../views/support/layerViewUtils.js";import{getVisualVariableAttributes as u,setUpGeometryUpdate as w,isTerminalUpdateEventType as m,syncUpdateOptions as y,cloneGraphicExceptMesh as k,canCreateInteractiveEditSession as f}from"../workflowUtils.js";import g from"./UpdateFeatureWorkflowData.js";import{UpdateRecordWorkflow as _,handleKeys as v}from"./UpdateRecordWorkflow.js";import V from"../../Sketch/SketchViewModel.js";var M;const S={...v,highlights:Symbol(),sketchGraphics:Symbol(),sketchViewModel:Symbol()};let b=M=class extends _{constructor(e){super(e),this.type="update-feature",this._layerViewEditSession=null,this._sketchGraphicClone=null,this._sketchLayer=null,this._sketchViewModel=null}destroy(){this._layerViewEditSession?.rollback()}get curveResizeDisabled(){return this.data.curveResizeDisabled}get curveUpdatesDisabled(){return this.data.curveUpdatesDisabled}get sketchUpdateOptions(){const{capabilities:e,layer:t}=this.data.editorItem;return{enableScaling:!this.curveResizeDisabled,multipleSelectionEnabled:!1,reshapeOptions:{enableCreateCurveFromStraightEdge:!n(t)&&e.supportsTrueCurve}}}get supportsSplitFeatureWorkflow(){return this.data.supportsSplitFeatureWorkflow}get viewGraphic(){return this._sketchViewModel?this._sketchGraphicClone:this.data.edits.feature??this.fullFeature}getUpdating(){return!!this._sketchViewModel?.updating}async commit(){this.removeHandles(S.sketchGraphics);try{const e=this.data.edits.stagedForDelete;await super.commit();const t=this._layerViewEditSession;e?t?.rollback():t?.commit()}catch(e){throw await this._configureSketchViewModel(),new t("editor-workflow:failed-to-commit","An error occurred when sending the updates to the service",{error:e})}}async start(){return await super.start(),await this._initializeSketchViewModel()}_initializeFormViewModel(){super._initializeFormViewModel(),this.addHandles([this._formViewModel.on("value-change",e=>{this._layerViewEditSession?.setAttribute(e.fieldName,e.value)}),a(()=>this._formViewModel.feature?.sourceLayer,e=>this._sketchGraphicClone.sourceLayer=e)])}_configureHighlight(){const{edits:e,layerView:t}=this.data;p(t)&&this.addHandles(t.highlight(e.feature),S.highlights)}async _configureSketchViewModel(){const{_sketchLayer:e,_sketchViewModel:t}=this;if(!t||!e)return;const{data:i,_formViewModel:s,_sketchGraphicClone:a}=this,{edits:r,viewModel:o}=i,l=r.feature,{view:d}=o,n=u(l),h=await w({feature:l,featureClone:a,visualVariableAttributes:n,sketchLayer:e,sketchViewModel:t,getUpdateOptions:()=>this.sketchUpdateOptions,view:d,onUpdate:({geometry:e,attributes:t},i)=>{if(r.updateAttributes(t),r.updateGeometry(e),s.feature&&(s.feature.geometry=e),null!=n.rotation){const{field:e}=n.rotation;s.setValue(e,t[e])}if(null!=n.size){const{field:e}=n.size;s.setValue(e,t[e])}("undo"===i.type||"redo"===i.type||"update"===i.type&&null!=i.toolEventInfo&&m(i.toolEventInfo.type))&&s.notifyFeatureGeometryChanged()},addUpdatingPromise:e=>{this._updatingHandles.consumePromise(e)},addHandle:e=>{this.addHandles(e,S.sketchGraphics)}});this.addHandles(h,S.sketchGraphics),t.addHandles(h)}async _initializeSketchViewModel(){const{data:e,_sketchGraphicClone:t}=this,{readOnly:o}=e,l=e.edits.feature,{capabilities:n,layer:p}=e.editorItem,u=e.viewModel.view;if(this.removeHandles([S.highlights,S.sketchGraphics,S.sketchViewModel]),!n.update.geometry||o||this.curveUpdatesDisabled)return{enter:async()=>{this.hasHandles(S.highlights)||this._configureHighlight()},exit:()=>this.removeHandles([S.highlights])};const w=new d({elevationInfo:p.elevationInfo,internal:!0,listMode:"hide",title:"updateFeaturesWorkflow-internal"}),m=new V({allowDeleteKey:!1,layer:w,sketchOptions:e.sketchOptions,snappingManager:e.snappingManager,useLegacyCreateTools:e.viewModel.useLegacyCreateTools,updateOnGraphicClick:!1,cancelUpdateOnClickAway:!1,defaultUpdateOptions:this.sketchUpdateOptions,view:u});return this._sketchLayer=w,this._sketchViewModel=m,u?.map.add(w),await(u?.whenLayerView(w)),this.addHandles([i(()=>{u?.destroyed||u?.map.remove(w),w.destroyed||w.destroy(),this._sketchViewModel=s(m)}),a(()=>this.sketchUpdateOptions,e=>{m.defaultUpdateOptions=e,y(m,e)},r)],S.sketchViewModel),await h(t,"2d"===u?.type?u.scale:null),this.addHandles([await c(w,u,l,t)]),{enter:async()=>{this.hasHandles(S.sketchGraphics)||await this._updatingHandles.addPromise(this._configureSketchViewModel())},exit:()=>this.removeHandles([S.sketchGraphics]),viewModel:m}}_onFullFeatureLoaded(e){super._onFullFeatureLoaded(e);const t=this._sketchGraphicClone=k(e),{edits:i,layerView:s}=this.data;i.updateGeometry(e.geometry),i.trackChanges(),f(s)&&(this._layerViewEditSession=s.createInteractiveEditSession(t))}static async create(e){const t=new M({data:await g.create(e),onCommit:this._onCommitFactory(e.applyEdits)});return t._set("steps",this._createWorkflowSteps(t)),t}get test(){}};e([o()],b.prototype,"curveResizeDisabled",null),e([o()],b.prototype,"curveUpdatesDisabled",null),e([o()],b.prototype,"sketchUpdateOptions",null),e([o()],b.prototype,"supportsSplitFeatureWorkflow",null),e([o()],b.prototype,"_layerViewEditSession",void 0),e([o()],b.prototype,"_sketchGraphicClone",void 0),e([o()],b.prototype,"_sketchLayer",void 0),e([o()],b.prototype,"_sketchViewModel",void 0),b=M=e([l("esri.widgets.Editor.legacy.UpdateFeatureWorkflow")],b);export{b as UpdateFeatureWorkflow,S as handleKeys};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import{property as r,subclass as o}from"../../../core/accessorSupport/decorators.js";import{hasCircularArc as s,isCurvedGeometry as i}from"../../../geometry/support/curves/curveUtils.js";import a from"../../../views/interactive/sketch/SketchOptions.js";import{whenEditorLayerView as p}from"../workflowUtils.js";import u from"./UpdateRecordWorkflowData.js";var n;let l=n=class extends u{constructor(e){super(e),this.sketchOptions=null,this.snappingManager=null}get curveResizeDisabled(){return this.hasCurves&&s(this.edits.feature?.geometry)&&!this.editorItem.supportedCurveTypes.includes("elliptic-arc")}get curveUpdatesDisabled(){return this.hasCurves&&!this.editorItem.capabilities.supportsTrueCurveUpdate}get hasCurves(){const e=this.edits.feature;return!(!e?.geometry||!i(e.geometry))}get supportsSplitFeatureWorkflow(){const e=this.edits.feature,t=this.editorItem;return!(!e?.geometry||!t)&&(!(i(e.geometry)&&!t.capabilities.supportsTrueCurveUpdate)&&t.supportsSplitFeatureWorkflow)}static async create(e){const{feature:r,snappingManager:o,viewModel:s}=e,i=e.sketchOptions??new a,{view:u}=s;if(!u)throw new t("editor:cannot-create-workflow-data","The provided EditorViewModel does not have an associated view");const l=await p(u,r.layer??r.sourceLayer);return new n({...n._makeConstructorProps(e),layerView:l,sketchOptions:i,snappingManager:o})}};e([r()],l.prototype,"curveResizeDisabled",null),e([r()],l.prototype,"curveUpdatesDisabled",null),e([r()],l.prototype,"hasCurves",null),e([r()],l.prototype,"layerView",void 0),e([r({constructOnly:!0})],l.prototype,"sketchOptions",void 0),e([r()],l.prototype,"snappingManager",void 0),e([r()],l.prototype,"supportsSplitFeatureWorkflow",null),l=n=e([o("esri.widgets.Editor.legacy.UpdateFeatureWorkflowData")],l);const c=l;export{c as default};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import{__decorate as e}from"tslib";import t from"../../../core/Collection.js";import r from"../../../core/Error.js";import o from"../../../core/Logger.js";import{destroyMaybe as i}from"../../../core/maybe.js";import{whenOnce as s}from"../../../core/reactiveUtils.js";import{property as a,subclass as n}from"../../../core/accessorSupport/decorators.js";import{isSceneLayer as l,isTable as d}from"../../../layers/support/layerUtils.js";import u from"../../BatchAttributeForm/BatchAttributeFormViewModel.js";import{handleFormValuesChangeEvent as p,whenEditorLayerView as c,findEditorItemForLayer as h}from"../workflowUtils.js";import f from"./UpdateFeaturesWorkflowData.js";import m from"./Workflow.js";import{MultipleSourceLayersError as g}from"../support/errors.js";import{SketchController as y}from"../support/SketchController.js";var w;const F=()=>o.getLogger("esri.widgets.Editor.UpdateFeaturesWorkflow"),v=Symbol();let b=w=class extends m{constructor(e){super(e),this.type="update-features",this._formViewModel=null,this._sketchController=null}async initialize(){this._initializeFormViewModel();try{await this._updatingHandles.addPromise((async()=>{const{fullFeatures:e}=await this.data.when();this._formViewModel.features=new t(e),this._initializeVisuals(e)})())}catch(e){this.cancel({force:!0,error:new r("update-features-workflow:initialize","Failed to initialize the workflow data.",e)})}}destroy(){this._sketchController=i(this._sketchController),this._formViewModel.destroy()}get curveUpdatesDisabled(){return this.data.curveUpdatesDisabled}get features(){return this.data.features}get featureInfos(){return this.data.featureInfos}get formViewModel(){return this._formViewModel}get hasInvalidFormTemplate(){return this.data.editorItems.some(e=>e.hasInvalidFormTemplate)}get hasPendingEdits(){const{data:e}=this;return e.fullFeatures.some(t=>!!e.getPendingEditsForFeature(t)?.modified)}get parent(){return this.data.parent}get saveActionLabel(){return"update"}get selectedFeature(){return this.data.selectedFeature}get sketchUpdateOptions(){const{data:e}=this,t=e.fullFeatures,r=_(e),o=e.getEditorItemForLayer(r),i=!this.selectedFeature||t.length>1;return{multipleSelectionEnabled:!1,reshapeOptions:{enableCreateCurveFromStraightEdge:!l(r)&&!!o?.capabilities.supportsTrueCurve},tool:i?"move":void 0}}get sketchViewModel(){return this._sketchController?.viewModel}get supportsMergeFeaturesWorkflow(){const e=this.data,{fullFeatures:t,layers:r}=e;return!(1!==r.length||t.length<2)&&(!this.curveUpdatesDisabled&&!!e.getEditorItemForLayer(r[0])?.supportsMergeFeaturesWorkflow)}getUpdating(){return!!this._sketchController?.updating}get viewGraphics(){return this._sketchController?.sketchGraphics??this.data.fullFeatures}static create(e){const{applyEdits:t,applyEditsFeatureService:r,...o}=e,{features:i,featureInfos:s,viewModel:a}=o,n=new Set;function l(e){const t=h(a.editorItems,e);t&&n.add(t)}s?.length?s.forEach(({layer:e})=>l(e)):i?.length&&(F().warn("editor:update-features-workflow-data-features","UpdateFeaturesWorkflow: 'features' is deprecrated, use 'featureInfos'"),i.forEach(e=>l(e.sourceLayer??e.layer)));const d=Array.from(n),u=new w({data:new f({...o,editorItems:d}),onCommit:E(e.applyEdits)});return u._set("steps",M()),u}async deleteAndCommit(){return this.data.stageDelete(),this.commit()}async enter(){}exit(e){}async reset(){}async save(){const{formViewModel:e}=this;await e.submit(),e.valid&&await super.save()}async start(){await super.start(),await s(()=>!this.updating);const e=this._sketchController;if(e)return e;const{data:t}=this,{view:r}=t.viewModel,o=_(t);return!r||d(o)?{enter:async()=>{},exit:()=>{}}:{enter:()=>this._initializeHighlights(t.fullFeatures,o,r),exit:()=>this.removeHandles(v)}}_initializeFormViewModel(){const{data:e}=this,t=e.viewModel.view,r=e.getEditorItemForLayer(_(e)),o=r?.layerInfo?[r.layerInfo]:null,i=new u({editType:"UPDATE",map:t?.map,readOnly:!1===r?.capabilities.update.attributes,spatialReference:t?.spatialReference,timeZone:e.timeZone,layerInfos:o});this._formViewModel=i,this.addHandles(i.on("values-change",p({forEachFeature:(t,r)=>{const o=e.getPendingEditsForFeature(t);if(o){for(const{fieldName:e,value:t}of r)o.setAttribute(e,t);this._sketchController?.notifyAttributesChanged(t,r)}}})));const s=t=>{e.getPendingEditsForFeature(t.feature)?.setAttachmentEdits(t.attachmentEdits)};this.addHandles(i.on("attachments-change",s))}async _initializeHighlights(e,t,r){const o=await c(r,t);this.addHandles(o.highlight(e),v)}_initializeSketchController(e,t,r){const{data:o}=this,i=new y({defaultUpdateOptions:this.sketchUpdateOptions,sourceLayer:t,view:r,features:e,useLegacyCreateTools:o.viewModel.useLegacyCreateTools,onGeometriesUpdated:e=>{const t=[];for(const{feature:r,geometry:i}of e)o.getPendingEditsForFeature(r)?.updateGeometry(i),t.push(r);this._formViewModel.notifyGeometriesChanged(t)},onVisualVariableAttributesUpdated:()=>{F().warnOnce("editor:batch-update-visual-variables","UpdateFeaturesWorkflow does not currently support modifying visual variables through the scale and rotate tools.")}});this._sketchController=i}_initializeVisuals(e){const{data:t}=this,{view:r}=t.viewModel;if(!r)return;const o=_(t);if(d(o))return;const i=t.getEditorItemForLayer(o);i?.capabilities.update.geometry&&!this.curveUpdatesDisabled&&this._initializeSketchController(e,o,r)}};e([a()],b.prototype,"curveUpdatesDisabled",null),e([a()],b.prototype,"features",null),e([a()],b.prototype,"featureInfos",null),e([a()],b.prototype,"formViewModel",null),e([a()],b.prototype,"hasInvalidFormTemplate",null),e([a()],b.prototype,"hasPendingEdits",null),e([a()],b.prototype,"parent",null),e([a()],b.prototype,"saveActionLabel",null),e([a()],b.prototype,"selectedFeature",null),e([a()],b.prototype,"sketchUpdateOptions",null),e([a()],b.prototype,"sketchViewModel",null),e([a()],b.prototype,"supportsMergeFeaturesWorkflow",null),e([a()],b.prototype,"type",void 0),e([a()],b.prototype,"viewGraphics",null),e([a()],b.prototype,"_formViewModel",void 0),e([a()],b.prototype,"_sketchController",void 0),b=w=e([n("esri.widgets.Editor.legacy.UpdateFeaturesWorkflow")],b);const k=b;function M(){return[{id:"editing-features",async setUp(){},async tearDown(){}}]}function E(e){return async t=>{const r=_(t),o=[],i=[];for(const e of t.fullFeatures){const r=t.getPendingEditsForFeature(e),s=r?.stagedForDelete;if(!r?.modified&&!s)continue;const a=e.clone();if(!r?.attributesModified||s){const t=e.sourceLayer;if(!t){F().warn("Feature has no sourceLayer. It will not be included in any applyEdits payload.");continue}const r=t.objectIdField;if(a.attributes={[r]:e.getAttribute(r)},"scene"===t.type&&null!=t.infoFor3D){const r=t.associatedLayer?.globalIdField;null!=r&&a.setAttribute(r,e.getAttribute(r))}}r?.geometryModified&&!s||(a.geometry=null),s?i.push(a):(r?.attributesModified||r?.geometryModified)&&o.push(a)}if(0===o.length&&0===i.length)return void F().warn("No edits to apply. Workflow will finish without sending an applyEdits request.");const s={};o.length&&(s.updateFeatures=o),i.length&&(s.deleteFeatures=i),await e(r,s)}}function _(e){if(e.layers.length>1)throw new g;return e.layers[0]}export{k as default};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import{__decorate as e}from"tslib";import{isSome as t,unique as r}from"../../../core/arrayUtils.js";import s from"../../../core/Error.js";import{abortHandle as i}from"../../../core/handleUtils.js";import{getOrCreateMapValue as o}from"../../../core/MapUtils.js";import{EsriPromise as a}from"../../../core/Promise.js";import{throwIfAborted as l,isAbortError as n}from"../../../core/promiseUtils.js";import u from"../../../core/ReactiveMap.js";import{property as p,subclass as f}from"../../../core/accessorSupport/decorators.js";import{isCurvedGeometry as d}from"../../../geometry/support/curves/curveUtils.js";import{isSubtypeSublayer as c}from"../../../layers/support/layerUtils.js";import{fetchFullFeaturesByObjectId as m}from"../../../views/draw/support/editingSessionUtils.js";import h from"../Edits.js";let y=class extends a{constructor(e){super(e),this.editorItems=[],this.featureInfos=null,this.parent=null,this.selectedFeature=null,this.sketchOptions=null,this.snappingManager=null,this.viewModel=null,this._editorItemsByLayer=new u,this._fullFeatures=new u,this._pendingEdits=new u}initialize(){const e=new AbortController;this.addResolvingPromise(this._initializeFullFeatures(e.signal).then(t=>{l(e.signal),this._initializeEdits(t)}).catch(e=>{if(n(e))throw new s("update-features-workflow:full-features-aborted","Fetching of full features was aborted.");throw e})),this.addHandles(i(e)),this._initializeEditorItemsByLayer()}get curveUpdatesDisabled(){return this.hasCurves&&this.editorItems.some(e=>!e.capabilities.supportsTrueCurveUpdate)}get features(){return this.fullFeatures}get fullFeatures(){return Array.from(this._fullFeatures.values())}get hasCurves(){return this.fullFeatures.some(e=>e.geometry&&d(e.geometry))}get initialFeatures(){return Array.from(this._pendingEdits.values()).map(e=>e.initialFeature).filter(t)}get layers(){const{featureInfos:e,features:s}=this;return e?.length?e.map(e=>e.layer):s.length?r(s.map(e=>e.sourceLayer).filter(t)):[]}set timeZone(e){this._set("timeZone",e),this._pendingEdits.forEach(t=>{t.timeZone=e})}getEditorItemForLayer(e){return this._editorItemsByLayer.get(e)}getFeatureTitle(e){return this._pendingEdits.get(e)?.displayTitle}getPendingEditsForFeature(e){const t=e.getObjectId();if(null!=t)return this._pendingEdits.get(this._fullFeatures.get(t)??e)}isSubmittable(e){const t=this._pendingEdits.get(e);return!!t&&(t.submittable||t.isAssociation)}stageDelete(){for(const e of this._pendingEdits.values())e.stageDelete()}_initializeEditorItemsByLayer(){for(const e of this.editorItems)this._editorItemsByLayer.set(e.layer,e)}_initializeEdits(e){const{timeZone:t}=this;for(const r of e){const e=new h({feature:r,timeZone:t});e.trackChanges(),this._pendingEdits.set(r,e)}}async _initializeFullFeatures(e){const{_fullFeatures:t,featureInfos:r,features:i,viewModel:a}=this,{spatialReference:l}=a.view,n=new Map;if(r?.length)for(const{layer:s,objectIds:o}of r)n.set(c(s)?s.parent:s,o);else if(i.length)for(const s of i){const e=s.getObjectId();if(null!=e){const t=s.sourceLayer??s.layer,r=c(t)?t.parent:t;o(n,r,()=>[]).push(e)}}const u=Array.from(n.entries()).map(async([r,i])=>{const o=await m(i,r,l,e);if(o.length!==i.length)throw new s("editor:update-features-workflow:fetch-full-features-incomplete","Failed to fetch full features for one or more of the provided features.");const a=r.objectIdField,n=(e,t)=>e.attributes[a]>t.attributes[a]?1:-1,u=i.sort((e,t)=>e-t),p=o.sort(n);for(let e=0;e<u.length;e++)t.set(u[e],p[e]);return o});return(await Promise.all(u)).flat()}};e([p()],y.prototype,"curveUpdatesDisabled",null),e([p({constructOnly:!0})],y.prototype,"editorItems",void 0),e([p({constructOnly:!0})],y.prototype,"featureInfos",void 0),e([p()],y.prototype,"features",null),e([p()],y.prototype,"fullFeatures",null),e([p()],y.prototype,"hasCurves",null),e([p()],y.prototype,"initialFeatures",null),e([p()],y.prototype,"layers",null),e([p()],y.prototype,"parent",void 0),e([p()],y.prototype,"selectedFeature",void 0),e([p({constructOnly:!0})],y.prototype,"sketchOptions",void 0),e([p()],y.prototype,"snappingManager",void 0),e([p()],y.prototype,"timeZone",null),e([p()],y.prototype,"viewModel",void 0),e([p()],y.prototype,"_fullFeatures",void 0),y=e([f("esri.widgets.Editor.legacy.UpdateFeaturesWorkflowData")],y);const g=y;export{g as default};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import{makeHandle as i,abortHandle as a}from"../../../core/handleUtils.js";import r from"../../../core/Logger.js";import{isAborted as o}from"../../../core/promiseUtils.js";import{watch as s}from"../../../core/reactiveUtils.js";import{property as l,subclass as n}from"../../../core/accessorSupport/decorators.js";import d from"../../../views/draw/support/HighlightHelper.js";import{temporaryHighlightName as c}from"../../../views/support/HighlightDefaults.js";import{fetchFullFeatures as h}from"../workflowUtils.js";import u from"./UpdateRecordWorkflowData.js";import m from"./Workflow.js";import p from"../../FeatureForm/FeatureFormViewModel.js";var g;const f={exit:Symbol()};let w=class extends m{static{g=this}constructor(e){super(e),this._highlightHelper=null,this.fullFeature=null,this.type="update-table-record"}initialize(){const{data:e}=this,{edits:s}=e,{view:l}=e.viewModel,n=s.feature;l&&(this._highlightHelper=new d({view:l,highlightName:c}),this.addHandles(i(()=>this._highlightHelper?.removeAll())));const u=new AbortController;this.addHandles(a(u)),this._updatingHandles.consumePromise(h([n],n.sourceLayer,e.viewModel.view.spatialReference,u.signal).then(([e])=>{o(u)||(this._onFullFeatureLoaded(e),this._initializeFormViewModel())},e=>(r.getLogger(this).error("initialize()","Failed to fetch full feature for update workflow.",e),this.cancel({force:!0,error:new t("editor:failed-to-fetch-full-feature","Failed to retrieve all information for this feature. The update cannot proceed.",{detail:{error:e}})}))))}get allowSave(){return!this.data.readOnly&&this.hasPendingEdits&&!this.updating}get editorItem(){return this.data.editorItem}get formViewModel(){return this._formViewModel}get hasInvalidFormTemplate(){return this.data.editorItem.hasInvalidFormTemplate}get hasPendingEdits(){return this.data.edits.modified&&!this.data.readOnly}get layer(){return this.data.editorItem.layer}get parent(){return this.data.parent}get saveActionLabel(){return"update"}get shouldShowAttachments(){return this.editorItem.capabilities.attachments.enabled}get shouldAllowAttachmentEditing(){return this.editorItem.capabilities.update.attachments.enabled}get reliesOnOwnerAdminPrivileges(){const e=this.editorItem.capabilities;return e.update.reliesOnOwnerAdminPrivileges||e.delete.reliesOnOwnerAdminPrivileges}async enter(){this._configureAttachmentsViewModel()}exit(e){this.removeHandles(f.exit)}async start(){return await super.start(),null}_configureAttachmentsViewModel(){const{data:e,fullFeature:t}=this,{attachmentsCapabilities:a,viewModel:r}=e,{attachmentsViewModel:o}=r,l=e.readOnly?{editing:!1}:a;o.set({capabilities:l,graphic:t,filesEnabled:!1,mode:"view"}),this.addHandles([i(()=>o.fileInfos.removeAll()),s(()=>o.mode,e=>{switch(e){case"add":this.go("adding-attachment");break;case"edit":this.go("editing-attachment")}})],f.exit)}_initializeFormViewModel(){const{association:e,edits:t,formTemplate:i,viewModel:{view:a},readOnly:r}=this.data,o=this._formViewModel=new p({activeAssociation:e,editType:"UPDATE",feature:this.fullFeature,formTemplate:i,highlightHelper:this._highlightHelper,map:a?.map,spatialReference:a.spatialReference,timeZone:a?.timeZone,disabled:r});o.callbacks={...this.data.featureFormCallbacks,showAllRelatedRecords:e=>o.relationshipId=e.relationshipId,viewAssociatedLayers:e=>o.associationId=e.associationId,viewAssociatedFeatures:e=>o.associatedLayer=e.associatedLayer};const{initialFeature:l}=t;l&&o.overrideInitialFeature(l),this.addHandles([o.on("value-change",()=>{t.updateAttributes(o.getValues()),this.fullFeature.attributes=t.feature.attributes}),s(()=>a?.timeZone,e=>o.timeZone=e)])}_onFullFeatureLoaded(e){this.fullFeature=e;const{edits:t}=this.data;t.updateAttributes(e.attributes),t.trackChanges()}static async create(e){const t=new g({data:await u.create(e),onCommit:this._onCommitFactory(e.applyEdits)});return t._set("steps",this._createWorkflowSteps(t)),t}static _createWorkflowSteps(e){const{attachmentsViewModel:t}=e.data.viewModel;return[{id:"editing-attributes",async setUp(){},async tearDown(){}},{id:"adding-attachment",async setUp(){},async tearDown(){t.mode="view"}},{id:"editing-attachment",async setUp(){},async tearDown(){t.mode="view"}}]}static{this._onCommitFactory=e=>async t=>{const{edits:i}=t,{feature:a}=i;if(!a)return;const r=a.sourceLayer,o=a.clone();if(!i.attributesModified||i.stagedForDelete){const e=r.objectIdField;if(o.attributes={[e]:a.getAttribute(e)},"scene"===r.type&&null!=r.infoFor3D){const e=r.associatedLayer?.globalIdField;null!=e&&o.setAttribute(e,a.getAttribute(e))}}i.geometryModified&&!i.stagedForDelete||(o.geometry=null);const s=i.stagedForDelete?"deleteFeatures":"updateFeatures";await e(r,{[s]:[o]})}}};e([l()],w.prototype,"_formViewModel",void 0),e([l()],w.prototype,"allowSave",null),e([l()],w.prototype,"editorItem",null),e([l()],w.prototype,"formViewModel",null),e([l()],w.prototype,"fullFeature",void 0),e([l()],w.prototype,"hasInvalidFormTemplate",null),e([l()],w.prototype,"hasPendingEdits",null),e([l()],w.prototype,"layer",null),e([l()],w.prototype,"parent",null),e([l()],w.prototype,"saveActionLabel",null),e([l()],w.prototype,"shouldShowAttachments",null),e([l()],w.prototype,"shouldAllowAttachmentEditing",null),e([l()],w.prototype,"reliesOnOwnerAdminPrivileges",null),w=g=e([n("esri.widgets.Editor.legacy.UpdateRecordWorkflow")],w);export{w as UpdateRecordWorkflow,f as handleKeys};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import{__decorate as t}from"tslib";import e from"../../../core/Accessor.js";import o from"../../../core/Error.js";import{property as r,subclass as i}from"../../../core/accessorSupport/decorators.js";import a from"../Edits.js";import{findEditorItemForLayer as s}from"../workflowUtils.js";var l;let d=l=class extends e{constructor(t){super(t),this.association=null,this.editorItem=null,this.edits=null,this.featureFormCallbacks=null,this.parent=null,this.readOnly=!1,this.viewModel=null}get attachmentsCapabilities(){const t=this.editorItem.capabilities.update.attachments.enabled;return{editing:!0,operations:{add:t,update:t,delete:t}}}get formTemplate(){return this.editorItem.formTemplate}static async create(t){const e=l._makeConstructorProps(t);return new l(e)}stageDelete(){this.edits.stageDelete()}static _makeConstructorProps(t){const{association:e,feature:r,parent:i,featureFormCallbacks:l,viewModel:d,readOnly:n}=t,p=s(d.editorItems,r.sourceLayer);if(!p)throw new o("no-editorItem-found","The EditorViewModel provided did not have an EditorItem associated with the specified Graphic's layer");return{association:e,editorItem:p,edits:new a({feature:r}),parent:i,featureFormCallbacks:l,viewModel:d,readOnly:n??!1}}};t([r()],d.prototype,"association",void 0),t([r()],d.prototype,"attachmentsCapabilities",null),t([r({constructOnly:!0})],d.prototype,"editorItem",void 0),t([r()],d.prototype,"edits",void 0),t([r()],d.prototype,"featureFormCallbacks",void 0),t([r()],d.prototype,"formTemplate",null),t([r()],d.prototype,"parent",void 0),t([r()],d.prototype,"readOnly",void 0),t([r()],d.prototype,"viewModel",void 0),d=l=t([i("esri.widgets.Editor.legacy.UpdateRecordWorkflowData")],d);const n=d;export{n as default};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ 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{onAbort as n,createAbortError as l,throwIfAborted as d,debounce as c}from"../../../core/promiseUtils.js";import p from"../../../core/Queue.js";import{whenOnce as u,watch as w,sync as h,on as f,when as g}from"../../../core/reactiveUtils.js";import{last as v}from"../../../core/SetUtils.js";import{property as k,subclass as m}from"../../../core/accessorSupport/decorators.js";import{getGraphicLayer as y}from"../../../graphic/graphicOriginUtils.js";import{isEditableLayer as W}from"../../../layers/support/editableLayers.js";import{isFeatureLayer as A,isSubtypeSublayer as _,isSubtypeGroupLayer as b,isTable as S}from"../../../layers/support/layerUtils.js";import{findUtilityNetwork as C,isGraphicForRelatableFeatureSupportedLayer as M}from"../../../popup/support/featureUtils.js";import{createFeatureServices as F}from"../../../rest/featureService/utils.js";import U from"../../../views/draw/support/HighlightHelper.js";import{ViewEventPriorities as R}from"../../../views/input/InputManager.js";import{temporaryHighlightName as E}from"../../../views/support/HighlightDefaults.js";import{isLegacyFeatureFormViewModel as I}from"../compatibilityAdapters.js";import{findEditorItemForLayer as j,findEditorItemForLayerOrThrow as V,createWorkflowSteps as P,fetchCandidates as L,toFeatureInfos as N}from"../workflowUtils.js";import O from"./CreateFeaturesWorkflow.js";import T from"./MergeFeaturesWorkflow.js";import x from"./SplitFeatureWorkflow.js";import D from"./UpdateFeaturesWorkflow.js";import{UpdateFeatureWorkflow as H}from"./UpdateFeatureWorkflow.js";import{UpdateRecordWorkflow as z}from"./UpdateRecordWorkflow.js";import q from"./UpdateWorkflowData.js";import G from"./Workflow.js";import{isSplitFeatureWorkflow as Q,workflowInfluencesOutcomeOfParent as $,isAnyUpdateLeafWorkflow as B,isUpdateRecordWorkflow as J,isParentWorkflow as K,isUpdateFeaturesWorkflowOptions as X,isMergeWorkflowOptions as Y,isSplitWorkflowOptions as Z}from"./workflowUtils.js";import{assertFeaturesAreFromSameLayer as ee}from"../support/errors.js";var te;let ie=te=class extends G{constructor(e){super(e),this._workflowStack=new p(v),this._sketchStack=new p(v),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||!I(e))return!1;const{activeAssociation:t,feature:i}=e;return!(!t||!i?.sourceLayer||!A(i?.sourceLayer)&&!_(i?.sourceLayer))}get activeWorkflow(){return this._workflowStack.last()}getUpdating(){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||I(e)&&(null!=e.relationshipId||null!=e.associationId||null!=e.associatedLayer)}get hasUpdatableCandidates(){const{candidates:e,viewModel:t}=this.data;return e.some(({layer:e})=>j(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}get curveResizeDisabled(){return this.activeWorkflow?.curveResizeDisabled??!1}get curveUpdatesDisabled(){return this.activeWorkflow?.curveUpdatesDisabled??!1}async back(e=()=>Promise.resolve(!0)){const{activeWorkflow:t}=this,i=t?.formViewModel;if(I(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(Q(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 te({data:new q({applyEditsCallback:i,applyEditsFeatureServiceCallback:o,...a}),onCommit:async()=>{}});return r._set("steps",this._createWorkflowSteps(r,t)),r}async save(e){const{formViewModel:t}=this;if(t){await t.submit();if(!(I(t)?t.submittable:t.valid)||I(t)&&ae(t))return}if(this.nestedWorkflowCount<2)return await this.commit();const{activeWorkflow:i}=this;if(await(i?.commit(e)),!$(i))return void await this._popWorkflowAndReconcile();this._popWorkflow();const o=this._workflowStack.peek();if(o&&o===i?.parent&&(await o.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=B(e);if(t){e.data.stageDelete();const t=J(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(!I(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=_(s)&&s.parent?s.parent:s,l=F([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=C(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(!I(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(!W(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=K(this.activeWorkflow)?this.activeWorkflow:void 0;return O.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(!W(i)||b(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=S(e.sourceLayer)?z:H,{applyEditsCallback:o,applyEditsFeatureServiceCallback:a,sketchOptions:r,snappingManager:s,viewModel:n}=this.data,l=K(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 u(()=>!d.updating),d}async _createNestedUpdateFeaturesWorkflow(e,t={}){const{applyEditsCallback:i,applyEditsFeatureServiceCallback:o,viewModel:a}=this.data,r=D.create({applyEdits:i,applyEditsFeatureService:o,featureInfos:e,viewModel:a,...t});return await u(()=>!r.updating),r}async _createNestedAddAssociationWorkflow(e,t,i){const{AddAssociationWorkflow:a}=await import("./AddAssociationWorkflow.js"),{applyEditsCallback:r,applyEditsFeatureServiceCallback:s,viewModel:n}=this.data,l=K(this.activeWorkflow)?this.activeWorkflow:void 0,{formViewModel:d}=this,c=I(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,associationsInput:c,applyEdits:r,applyEditsFeatureService:s});return await u(()=>!p.updating),p}async _createNestedMergeFeaturesWorkflow(e,t){const{applyEditsCallback:i,applyEditsFeatureServiceCallback:o,viewModel:a}=this.data;ee(e);const r=V(this.data.viewModel.editorItems,y(e[0])),s=K(this.activeWorkflow)?this.activeWorkflow:void 0,n=await T.create({applyEdits:i,applyEditsFeatureService:o,editorItem:r,features:e,parent:s,viewModel:a,...t});return await u(()=>!n.updating),n}async _createNestedSplitFeatureWorkflow(e,t){const{applyEditsCallback:i,applyEditsFeatureServiceCallback:o,sketchOptions:a,snappingManager:r,viewModel:s}=this.data,n=K(this.activeWorkflow)?this.activeWorkflow:void 0,l=V(s.editorItems,e.sourceLayer),d=x.create({applyEdits:i,applyEditsFeatureService:o,editorItem:l,feature:e,parent:n,sketchOptions:a,snappingManager:r,viewModel:s,...t});return await u(()=>!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.consumePromise(t),i.push(t)}await Promise.all(i),this._workflowStack.clear(),this._sketchStack.clear()}_makeUpdatingResolver(){const e=Promise.withResolvers();return this._updatingHandles.consumePromise(e.promise),e}_makeRelatedRecordAttributes(e){const{parentFeature:t,relatedLayer:i,relationshipId:o}=e;if(!M(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=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,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&&!S(e.data.creationInfo?.layer)}static _createWorkflowSteps(e,t="awaiting-feature-to-update"){const{data:i}=e;return P(["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 c=o.on("immediate-click",async a=>{const s=Promise.withResolvers();e._updatingHandles.consumePromise(s.promise);try{t.location=a.mapPoint,t.visible=!0,r?.abort();const{editorItems:s}=i.viewModel;r=new AbortController;const c=await a.defer(()=>new Promise((e,t)=>{n(r?.signal,()=>t(l())),e(L(s,o,a,r?.signal))}));if(d(r),i.candidates=c.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()}},R.TOOL),p=g(()=>null!=o.activeTool,()=>e.cancel({force:!0}),{once:!0});o.focus(),e.addHandles([c,p],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 U({view:t,highlightName:E});e.addHandles([f(()=>i.rootFeatures,"change",({added:e,removed:t})=>{t.forEach(e=>o.remove(e)),e.forEach(e=>o.add(e))},h),a(()=>o.removeAll())],this.id)},async tearDown(){e.removeHandles(this.id)}}),"editing-existing-feature":()=>({id:"editing-existing-feature",async setUp(){await re(e);const{data:t}=e;t.viewModel.spinnerViewModel.visible=!1;const i=c(async()=>{await u(()=>!e.updating),e.previous()});e.addHandles([w(()=>e.nestedWorkflowCount,(e,t)=>{0===e&&0!==t&&i()},h)],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 ae(e){if(e.pendingSubtypeChoice)return!0;const t=e.getValues();return e.validateContingencyConstraints(t,{includeIncompleteViolations:!0}).length>0}async function re(e){const{data:t}=e,{rootWorkflowOptions:i}=t;if(X(i)){const{rootFeatureInfos:a}=t,r=a.length>0?a:N(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");Y(i)?await e.startMergingFeatures(a.toArray(),i.props):Z(i)?await e.startSplittingFeature(r,i.props):await e.startUpdatingSingle(r)}e([k()],ie.prototype,"formViewModel",null),e([k()],ie.prototype,"activeUtilityNetworkAssociationAddAssociationViewModel",null),e([k()],ie.prototype,"activeSketchViewModel",null),e([k()],ie.prototype,"canDeleteAssociation",null),e([k()],ie.prototype,"activeWorkflow",null),e([k()],ie.prototype,"data",void 0),e([k()],ie.prototype,"hasPreviousStep",null),e([k()],ie.prototype,"hasUpdatableCandidates",null),e([k()],ie.prototype,"nestedWorkflowCount",null),e([k()],ie.prototype,"shouldShowAttachments",null),e([k()],ie.prototype,"shouldAllowAttachmentEditing",null),e([k()],ie.prototype,"hasPendingEdits",null),e([k()],ie.prototype,"helpMessage",null),e([k()],ie.prototype,"noticeMessage",null),e([k()],ie.prototype,"reliesOnOwnerAdminPrivileges",null),e([k()],ie.prototype,"hasInvalidFormTemplate",null),e([k()],ie.prototype,"curveResizeDisabled",null),e([k()],ie.prototype,"curveUpdatesDisabled",null),ie=te=e([m("esri.widgets.Editor.legacy.UpdateWorkflow")],ie);const se=ie;export{se as default};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import{__decorate as t}from"tslib";import o from"../../../core/Accessor.js";import e from"../../../core/Collection.js";import{property as s,subclass as r}from"../../../core/accessorSupport/decorators.js";import a from"../../../views/interactive/sketch/SketchOptions.js";let i=class extends o{constructor(t){super(t),this.addAttachmentsCallback=null,this.applyEditsCallback=null,this.applyEditsFeatureServiceCallback=null,this.applyAttachmentEditsCallback=null,this.candidates=[],this.rootFeatures=new e,this.rootFeatureInfos=[],this.rootWorkflowOptions={type:"update-single"},this.sketchOptions=new a,this.snappingManager=null,this.viewModel=null}};t([s()],i.prototype,"addAttachmentsCallback",void 0),t([s()],i.prototype,"applyEditsCallback",void 0),t([s()],i.prototype,"applyEditsFeatureServiceCallback",void 0),t([s()],i.prototype,"applyAttachmentEditsCallback",void 0),t([s()],i.prototype,"candidates",void 0),t([s()],i.prototype,"rootFeatures",void 0),t([s()],i.prototype,"rootFeatureInfos",void 0),t([s()],i.prototype,"rootWorkflowOptions",void 0),t([s({constructOnly:!0})],i.prototype,"sketchOptions",void 0),t([s()],i.prototype,"snappingManager",void 0),t([s()],i.prototype,"viewModel",void 0),i=t([r("esri.widgets.Editor.legacy.UpdateWorkflowData")],i);const p=i;export{p as default};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import{__decorate as t}from"tslib";import e from"../../../core/Error.js";import{EventedAccessor as s}from"../../../core/Evented.js";import{throwIfNotAbortError as i}from"../../../core/promiseUtils.js";import{property as n,subclass as o}from"../../../core/accessorSupport/decorators.js";import{UpdatingHandles as r}from"../../../core/support/UpdatingHandles.js";let a=class extends s{constructor(t){super(t),this._indexHistory=[],this._lastStepIndex=-1,this._stepIndex=-1,this._updatingHandles=new r,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 curveResizeDisabled(){return!1}get curveUpdatesDisabled(){return!1}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 sketchUpdateOptions(){return{}}get updating(){return this._updatingHandles.updating||!!this.formViewModel?.updating||this.getUpdating()}getUpdating(){return!1}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(t){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=Promise.withResolvers(),i=(e??Promise.resolve()).then(()=>s.promise);this._pendingOperation=i,this._updatingHandles.consumePromise(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([n()],a.prototype,"curveResizeDisabled",null),t([n()],a.prototype,"curveUpdatesDisabled",null),t([n()],a.prototype,"data",void 0),t([n()],a.prototype,"formViewModel",null),t([n()],a.prototype,"hasNextStep",null),t([n()],a.prototype,"hasPreviousStep",null),t([n()],a.prototype,"onCommit",void 0),t([n()],a.prototype,"reliesOnOwnerAdminPrivileges",null),t([n()],a.prototype,"hasInvalidFormTemplate",null),t([n()],a.prototype,"shouldShowAttachments",null),t([n()],a.prototype,"shouldAllowAttachmentEditing",null),t([n()],a.prototype,"started",void 0),t([n({readOnly:!0})],a.prototype,"stepId",null),t([n()],a.prototype,"steps",void 0),t([n({readOnly:!0})],a.prototype,"type",void 0),t([n()],a.prototype,"allowSave",null),t([n()],a.prototype,"helpMessage",null),t([n()],a.prototype,"noticeMessage",null),t([n()],a.prototype,"hasPendingEdits",null),t([n()],a.prototype,"keyboardCancellationEnabled",null),t([n()],a.prototype,"sketchUpdateOptions",null),t([n()],a.prototype,"updating",null),a=t([o("esri.widgets.Editor.legacy.Workflow")],a);const p=a;export{p as default};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ function e(e){return null!=e&&"update-features"===e.type}function t(e){return null!=e&&e.type.includes("update-")&&"fullFeature"in e}function n(e){return null!=e&&"update"===e.type}function u(e){return null!=e&&"merge-features"===e.type}function r(e){return null!=e&&"split-feature"===e.type}function i(e){const t=e?.type;return"update-feature"===t||"update-table-record"===t||"update-features"===t||"split-feature"===t}function p(n){return t(n)||e(n)}function l(e){return"merge"===e?.type}function a(e){return"split"===e?.type}function f(e){return u(e)||r(e)}function o(e){return"update-multiple"===e?.type}function c(e){e.filesEnabled=!0,e.mode="view",e.capabilities={editing:!0,operations:{add:!0,update:!0,delete:!0}}}export{p as isAnyUpdateLeafWorkflow,u as isMergeFeaturesWorkflow,l as isMergeWorkflowOptions,i as isParentWorkflow,r as isSplitFeatureWorkflow,a as isSplitWorkflowOptions,e as isUpdateFeaturesWorkflow,o as isUpdateFeaturesWorkflowOptions,t as isUpdateRecordWorkflow,n as isUpdateWorkflow,c as prepareAttachmentsForCreateFeaturesWorkflow,f as workflowInfluencesOutcomeOfParent};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import e from"../../Color.js";import t from"../../Graphic.js";import{isSome as r,equals as n,addMany as o}from"../../core/arrayUtils.js";import i from"../../core/Error.js";import{handlesGroup as a,makeHandle as s,abortHandle as l}from"../../core/handleUtils.js";import{clone as c}from"../../core/lang.js";import u from"../../core/Logger.js";import{getOrCreateMapValue as p}from"../../core/MapUtils.js";import{debounce as d,isPromiseLike as f,whenOrAbort as y}from"../../core/promiseUtils.js";import{watch as m,on as h,whenOnce as g,when as b}from"../../core/reactiveUtils.js";import{px2pt as w}from"../../core/screenUtils.js";import{addMany as I}from"../../core/SetUtils.js";import{isSharedTemplateOrMetadata as v,isSharedGroupTemplate as T,getCreationAttributes as F,isSharedPresetTemplate as j}from"../../editing/templateUtils.js";import{isCurvedGeometry as k,hasUnsupportedCurve as S}from"../../geometry/support/curves/curveUtils.js";import A from"../../layers/GraphicsLayer.js";import{featureHasFields as O,fixFields as U,getDisplayFieldName as L}from"../../layers/support/fieldUtils.js";import{isSubtypeSublayer as V}from"../../layers/support/layerUtils.js";import{calculateTolerance as M}from"../../renderers/support/clickToleranceUtils.js";import{meterIn as x}from"../../renderers/support/lengthUtils.js";import{isRenderer as q}from"../../renderers/support/typeUtils.js";import{getTransformationType as z}from"../../renderers/visualVariables/support/sizeVariableUtils.js";import{isGraphic as E}from"../../support/graphicInstanceUtils.js";import P from"../../symbols/SimpleFillSymbol.js";import R from"../../symbols/SimpleLineSymbol.js";import C from"../../symbols/SimpleMarkerSymbol.js";import{to3D as D}from"../../symbols/support/symbolConversion.js";import{getDisplayedSymbol as G}from"../../symbols/support/symbolUtils.js";import{getServices as B}from"../../undoredo/support/Services.js";import{defaultDrawingMode as N}from"../../views/draw/drawingModes.js";import{updateGraphicSymbolWhenRequired as Z,fetchFullFeaturesByObjectId as W}from"../../views/draw/support/editingSessionUtils.js";import{createQueryGeometry as $}from"../../views/support/drapedUtils.js";import{filterGraphicHits as Q,hitTestSelectSimilarDistance as H}from"../../views/support/hitTestSelectUtils.js";import{dependencySort as J}from"./support/dependencySort.js";import{isDrawGraphicTool as K,isDrawTool as X}from"../Sketch/support/sketchUtils.js";const Y=()=>u.getLogger("esri.widgets.Editor.workflowUtils");function _(e){return ie(e)||ne(e)}function ee(e){return!!e&&"features"in e}function te(e){return null!=e&&"create-features"===e.type}function re(e){return!!e&&"feature"in e}function ne(e){return null!=e&&"update-features"===e.type}function oe(e){return null!=e&&"update-feature"===e.type}function ie(e){return null!=e&&e.type.includes("update-")&&"fullFeature"in e}function ae(e){return null!=e&&"update"===e.type}function se(e){return null!=e&&"merge-features"===e.type}function le(e){return null!=e&&"split-feature"===e.type}function ce(e){const t=e?.type;return"update-feature"===t||"update-table-record"===t||"update-features"===t||"split-feature"===t}function ue(e){return"merge"===e?.type}function pe(e){return"split"===e?.type}function de(e){return se(e)||le(e)}function fe(e){return"update-multiple"===e?.type}function ye(e){const t=e&&"renderer"in e?e.renderer:null;if(!ve(t))return{rotation:null,size:null};const r=t.getVisualVariablesForType("rotation").filter(e=>(!e.axis||"heading"===e.axis)&&e.field&&!e.valueExpression),n=t.getVisualVariablesForType("size").filter(e=>e.field&&!e.useSymbolValue&&!e.valueExpression&&"real-world-size"===z(e));return{rotation:1===r.length?r[0]:null,size:1===n.length?n[0]:null}}function me(e){const t=e.sourceLayer;if(!(t&&"renderer"in t&&ve(t.renderer)))return{rotation:null,size:null};const{rotation:r,size:n}=ye(t);let o=null,i=null;if(r){const e=t.fields?.filter(e=>e.name===r.field),n=1===e?.length?e[0]:null;o=he(r,n)}if(n){const e=t.fields?.filter(e=>e.name===n.field),r=1===e?.length?e[0]:null;i=we(n,r)}return{rotation:o,size:i}}function he(e,t){const r="heading"===(e.axis||"heading")&&"arithmetic"===e.rotationType?-1:1,n=t?.type??"double",o={initial:0,current:0};return{field:e.field,fieldType:n,getDefaultValue:()=>Promise.resolve(0),getValue:e=>(o.current=o.initial-r*e,Ie((o.current+360)%360,n)),setInitialValue:e=>{o.initial=e,o.current=0},isUpdatingInteractively:!1,rotationType:e.rotationType??"geographic"}}function ge(e,t){switch(t){case"width":return e[0];case"depth":return e[1];case"height":return e[2];default:return e[2]||e[1]||e[0]}}async function be(e,t,r){if(null==t)return 0;const{symbol:n}=D(t);if(null==n||"web-style"===n.type||"cim"===n.type)return 0;const o=n.symbolLayers.at(0);if(!o)return 0;switch(o.type){case"icon":{const{computeIconLayerResourceSize:e}=await import("../../symbols/support/symbolLayerUtils.js");return Math.min(ot.icon,(await e(o,ot.icon))[0])||ot.icon}case"text":return ot.text;case"line":return ot.line;case"object":{const{computeObjectLayerResourceSize:t}=await import("../../symbols/support/symbolLayerUtils.js");return ge(await t(o,e.scale/ot.viewScaleSizeFactor),r)}case"path":case"extrude":return e.scale/ot.viewScaleSizeFactor;default:return 0}}function we(e,t){const r=e.axis,n=t?.type??"double",o={initial:0,current:0},i=x[e.valueUnit]??1;let a;return a="area"===e.valueRepresentation?e=>(e*i/2)**2*Math.PI:"radius"===e.valueRepresentation||"distance"===e.valueRepresentation?e=>e*i/2:e=>e*i,{field:e.field,fieldType:n,getDefaultValue:async(e,t)=>Ie(a(await be(t,e,r)),n),getValue:(e,t)=>(o.initial||(o.initial=t.pixelSizeAt(t.center)),o.current=o.initial*e,Ie(o.current,n)),setInitialValue:e=>{o.initial=e,o.current=0},isUpdatingInteractively:!1,displayUnit:st(e.valueUnit),axis:e.axis}}function Ie(e,t){switch(t){case"small-integer":case"integer":case"long":return Math.round(e);case"double":case"single":return e;default:return 0}}function ve(e){if(!q(e))return!1;switch(e?.type){case"class-breaks":case"simple":case"unique-value":case"dot-density":case"dictionary":case"pie-chart":return!0;default:return!1}}function Te(e,t){if(!e||!t)throw new Error("no geometry type");if("multipatch"===e)return{tool:"mesh",createOptions:{mode:"hybrid"}};const r=new Map;r.set("circle",{mode:"freehand"}),r.set("rectangle",{mode:"freehand"});const n={mode:N,optionsPerTool:r};if(v(t)){const o=t.defaultTool,i=T(t)?t.definition?.inputGeometryType??e:e;switch(o){case"freehand":case"stream-line":return{tool:"polyline"===i?"freehandPolyline":"freehandPolygon",createOptions:n};case"autocomplete-freehand-polygons":case"stream-polygon":return{tool:"freehandPolygon",createOptions:n};case"autocomplete-polygons":case"difference-polygon":case"create-structures":case"polygon":case"trace":return{tool:"polygon"===i?"polygon":"polyline",createOptions:n};case"circle":return r.get("circle").preserveAspectRatio=!0,{tool:"circle",createOptions:n};case"ellipse":return r.get("circle").preserveAspectRatio=!1,{tool:"circle",createOptions:n};case"create-points-along-line":case"multipoint":return{tool:"multipoint",createOptions:n};case"line":case"radial-line":case"right-angle-line":case"split":case"two-point-line":return{tool:"polyline",createOptions:n};case"rectangle":case"regular-polygon":case"right-angle-polygon":return{tool:"rectangle",createOptions:n};case"elevation-point-from-contour":case"elevation-point-from-dem":case"parcel-seed":case"point":case"point-and-rotation":case"point-at-end-of-line":return{tool:"point",createOptions:n}}}else{const o=t.drawingTool;if("circle"===o||"ellipse"===o)return r.get("circle").preserveAspectRatio="circle"===o,{tool:"circle",createOptions:n};if("rectangle"===o)return{tool:"rectangle",createOptions:n};if("freehand"===o)return{tool:"polygon"===e?"freehandPolygon":"freehandPolyline",createOptions:n}}return{tool:e,createOptions:n}}async function Fe(e,t,r){const{creationInfo:n,fullTemplate:o}=r;if(!n)throw new i("featureworkflow","No creation info provided.");const a=n.layer,s=F(o,n.attributeOverrides,n.layer),{view:l}=e,c="2d"===l?.type;T(o)||j(o)||await Ge(e,a,s,c?l.scale:null);const{capabilities:u}=a;t.elevationInfo=a.elevationInfo;const p=Te(a.geometryType,o);e.defaultCreateOptions={graphicProperties:{attributes:s,sourceLayer:a},mode:p.createOptions.mode,optionsPerTool:p.createOptions.optionsPerTool,preserveAspectRatio:p.createOptions.preserveAspectRatio,hasZ:u.data.supportsZ,defaultZ:(c?u.editing.zDefault:null)??e.defaultCreateOptions.defaultZ},null==n.geometryToPlace?await e.create(p.tool):await e.place(n.geometryToPlace,{graphicProperties:{attributes:s,sourceLayer:a}})}async function je(e){return a([ke(e),Se(e)])}function ke({creationAttributes:e,data:t,sketchViewModel:r,view:n}){const{creationInfo:o}=t,{fullTemplate:i}=t;if(!o||"2d"!==n?.type||T(i)||j(i))return null;const a=d(t=>Ge(r,o.layer,e,t));return m(()=>n.scale,e=>a(e))}function Se({data:t,sketchViewModel:r,view:n}){const{templateExecutorInfo:o}=t;if(!o)return null;const l=r.activeComponent;if(!n||!K(l)&&!X(l))return Y().error(new i("featureworkflow","Failed to set up template feedback.")),null;const c=new A({effect:"saturate(0.6) opacity(0.8)",listMode:"hide",title:"Shared Template Feedback Graphics"});n.map?.add(c);const{executor:u,serviceLayersById:p}=o,d=n.theme?.accentColor??new e([255,165,0,1]);return a([h(()=>l,["cursor-update","vertex-add"],()=>{c.removeAll();const e=K(l)?l.graphic?.geometry:l.unprocessedGeometry;if(!e||!Ae(e))return;const t=u(e,"digitizing");if(!f(t))for(const r of t.edits){const e=p.get(r.id);if(e&&r.addFeatures&&0!==r.addFeatures.length)for(const t of e)if(!t.isTable)for(const e of r.addFeatures){const t=Oe(e,d);t&&c.add(t)}}}),s(()=>{n.map.remove(c),c.destroy()})])}function Ae(e){switch(e.type){case"point":case"multipoint":return!0;case"polyline":{if(k(e))return e.curvePaths[0].length>1;const t=e.paths[0];return!!t&&t.length>1}case"polygon":{if(k(e))return e.curveRings[0].length>2;const t=e.rings[0];return!!t&&(n(t.at(0),t.at(-1))?t.length>2:t.length>1)}default:return!1}}function Oe(e,r){let n=null;switch(e.geometry?.type){case"point":case"multipoint":n=new C({angle:0,color:r,outline:new R({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:1}),path:"undefined",size:8,style:"circle",xoffset:0,yoffset:0});break;case"polygon":n=new P({color:r,outline:new R({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:3}),style:"none"});break;case"polyline":n=new R({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:2});break;default:return null}return new t({geometry:e.geometry,symbol:n,attributes:{...e.attributes}})}function Ue(e,t){const r=B(t),n=V(e)?e.parent:e;return r.tablesAndLayersLookup.get(n)}function Le(e,t){const r=Ue(e,t);if(!r)return new Map;const n=new Map;for(const o of r.layersAndTables)p(n,o.layerId,()=>[]).push(o);return n}function Ve(e){const t=e.objectIdField,r=e.globalIdField??"";return{id:e.layerId,identifierFields:{objectIdField:t,globalIdField:r},addFeatures:[],deleteAttachments:[],addAttachments:[],deleteFeatures:[],updateFeatures:[]}}function Me(e){const{edits:t,serviceInfo:n,view:o,findOriginalFeature:i}=e,a=xe(n.layersAndTables),s=n.layersAndTables.toArray(),{allEditData:l,editDataByLayerIdMap:c,editDataByIdMap:u}=ze(t,a,i),p=Ee(l,qe(s,c),c);if(o&&Ce(l,p,o),0===p.length)return t;const d=J(p,{continueOnCircularDependency:!0}).map(e=>u.get(e)).filter(r),f=new Map;for(const r of d)f.set(r.uniqueId,r);const y=[];for(const r of l)f.has(r.uniqueId)||y.push(r);const m=[];let h=null;for(const r of d){const{layer:e}=r;switch(null==h?h=Ve(e):h.id!==e.layerId&&(m.push(h),h=Ve(e)),r.operationType){case"add":case"modify":h.addFeatures.push(r.after);break;case"delete":h.deleteFeatures.push(r.before)}}null!==h&&m.push(h);for(const r of y){const e=r.layer.layerId,t=m.find(t=>t.id===e)??Ve(r.layer);switch(m.includes(t)||m.push(t),r.operationType){case"add":t.addFeatures.push(r.after);break;case"modify":t.updateFeatures.push(r.after);break;case"delete":t.deleteFeatures.push(r.before);break;case"deleteAttachment":t.deleteAttachments.push(r.attachmentId);break;case"addAttachment":t.addAttachments.push(r.attachment)}}for(const r of m)void 0!==r.deleteAttachments&&0===r.deleteAttachments.length&&delete r.deleteAttachments,void 0!==r.addAttachments&&0===r.addAttachments.length&&delete r.addAttachments;return m}function xe(e){const t=new Map;for(const r of e)t.set(r.layerId,r);return t}function qe(e,t){const r=new Map;for(const n of e)for(const e of n.relationships??[])if(r.set(Pe(n,e),""),t.has(e.relatedTableId)){const o=t.get(e.relatedTableId);if(o.length>0)for(const t of o[0].layer.relationships??[])if(t.id===e.id){r.set(Pe(n,e),t.keyField);break}}return r}function ze(e,t,r){const n=new Map,o=[],a=new Map;let s=1;for(const l of e){const e=[],c=t.get(l.id);if(!c)throw new i("featureworkflow",`Failed to prepare applyEdits payload. Layer with id ${l.id} not found.`);for(const t of l.addFeatures??[])e.push({uniqueId:"T"+s++,operationType:"add",layer:c,after:t});for(const t of l.deleteFeatures??[])e.push({uniqueId:"T"+s++,operationType:"delete",before:t,layer:c});for(const t of l.deleteAttachments??[])e.push({uniqueId:"T"+s++,operationType:"deleteAttachment",attachmentId:t,layer:c});for(const t of l.addAttachments??[])e.push({uniqueId:"T"+s++,operationType:"addAttachment",attachment:t,layer:c});for(const t of l.updateFeatures??[])e.push({uniqueId:"T"+s++,operationType:"modify",before:r(t),after:t,layer:c});n.set(c.layerId,e);for(const t of e)o.push(t),a.set(t.uniqueId,t)}return{allEditData:o,editDataByIdMap:a,editDataByLayerIdMap:n}}function Ee(e,t,r){const n=[];for(const o of e){const e=o.layer.relationships??[],{uniqueId:i}=o;for(const a of e){const e=a.keyField;if("origin"===a.role){const s=r.get(a.relatedTableId);if(!s||0===s.length)continue;const l=Pe(o.layer,a),c=t.get(l);if(void 0===c||""===c)continue;switch(o.operationType){case"add":for(const t of s)t!==o&&("add"!==t.operationType&&"modify"!==t.operationType||t.after.attributes[c]===o.after.attributes[e]&&n.push([i,t.uniqueId]));break;case"modify":if(o.before.attributes[e]!==o.after.attributes[e])for(const t of s){const r=t.uniqueId;t!==o&&("delete"===t.operationType?t.before.attributes[c]===o.before.attributes[e]?n.push([r,i]):t.before.attributes[c]===o.after.attributes[e]&&n.push([i,r]):"add"===t.operationType?t.after.attributes[c]===o.after.attributes[e]?n.push([i,r]):t.after.attributes[c]===o.before.attributes[e]&&n.push([r,i]):"modify"===t.operationType&&(t.before.attributes[c]!==t.after.attributes[c]?t.after.attributes[c]===o.after.attributes[e]?n.push([i,r]):n.push([r,i]):n.push([i,r])))}break;case"delete":for(const t of s)t!==o&&("delete"!==t.operationType&&"modify"!==t.operationType||t.before.attributes[c]===o.before.attributes[e]&&n.push([t.uniqueId,i]))}}}}return n}function Pe(e,t){return`${e.layerId}:${t.id}`}function Re(e,t){return!!(t?.map&&"utilityNetworks"in t.map&&t.map.utilityNetworks?.length&&t.map.utilityNetworks.some(t=>!(!t.loaded||!e.url?.startsWith(t.featureServiceUrl)||e.layerId!==t.networkSystemLayers.associationsTableId)))}function Ce(e,t,r){const n=[];for(const i of e)Re(i.layer,r)&&n.push(i);if(0===n.length)return;let o=[];for(const i of n){const r=i.layer;switch(i.operationType){case"delete":o=[...De(i.before.attributes[r.fieldsIndex.get("fromglobalid").name],e),...De(i.before.attributes[r.fieldsIndex.get("toglobalid").name],e)];for(const e of o)t.push([i.uniqueId,e.uniqueId]);break;case"add":o=[...De(i.after.attributes[r.fieldsIndex.get("fromglobalid").name],e),...De(i.after.attributes[r.fieldsIndex.get("toglobalid").name],e)];for(const e of o)t.push([e.uniqueId,i.uniqueId])}}}function De(e,t){const r=[],n=t.filter(({layer:e})=>""!==e.globalIdField&&null!=e.globalIdField);for(const o of n){const t=o.layer.globalIdField;("before"in o&&o.before?.attributes[t]===e||"after"in o&&o.after?.attributes[t]===e)&&r.push(o)}return r}async function Ge(e,r,n,o){const i=new t({sourceLayer:r,attributes:n}),{rotation:a,size:s}=me(i);let l=await G(i,{useSourceLayer:!0,scale:o}),c=!1;for(const t of[s,a]){if(null==t)continue;null==n[t.field]&&(n[t.field]=await t.getDefaultValue(l,e.view),c=!0)}switch(c&&(l=await G(i,{useSourceLayer:!0,scale:o})),l?.type){case"simple-fill":case"polygon-3d":e.polygonSymbol=l;break;case"simple-line":case"line-3d":e.polylineSymbol=l;break;case"simple-marker":case"picture-marker":case"point-3d":case"cim":e.pointSymbol=l;break;case"mesh-3d":e.meshSymbol=l}Be(e.tooltipOptions,s,a)}function Be(e,t,r){e.visualVariables=null!=t||null!=r?{size:null!=t?{unit:t.displayUnit,axis:t.axis,valueType:t.fieldType}:null,rotation:null!=r?{valueType:r.fieldType,rotationType:r.rotationType??"geographic"}:null}:null}function Ne(e,t){return e.find(e=>e.layer===t)}function Ze(e,t){const r=Ne(e,t);if(null==r)throw new i("no-editorItem-found","The EditorViewModel provided did not have an EditorItem associated with the specified layer");return r}function We(e,t){return e?.find(e=>e.layer===t)}async function $e(e,t,r,n){switch(t.type){case"3d":return Qe(e,t,r,n);case"2d":return He(e,t,r,n)}}async function Qe(e,t,r,n){if(0===e.length)return[];const{updatable:i,graphicsByLayer:a}=await r.defer(async()=>{const{results:o}=await y(H(t,r),n),i=new Map,a=e=>{const t=e.layer,r=i.get(t);if(!r){const e=new Array;return i.set(t,e),e}return r};Q(o).forEach(({graphic:e})=>a(e).push(e));const s=e.filter(({capabilities:e,layer:t})=>e.update.enabled&&i.has(t));return 0!==s.length&&r.stopPropagation(),{updatable:s,graphicsByLayer:i}});return y(Promise.allSettled(i.map(async({layer:e})=>{const t=a.get(e),r=Je(e);if(t.every(e=>O(e,r)))return t;const i=[];for(const n of t){i.push(n.getObjectId());const e=Object.keys(n.attributes);o(r,e)}const s=e.createQuery();return s.returnGeometry=!1,s.objectIds=i,s.outFields=U(e.fieldsIndex,r),e.queryFeatures(s,{signal:n}).then(({features:e})=>e)})),n)}async function He(e,t,r,n){if(0===e.length)return[];const{mapPoint:o}=r;if(null==o)return[];let i=null;const a=await r.defer(async()=>{const{results:o}=await y(t.hitTest(r),n);if(0===o.length)return[];const a=new Set;i=Q(o),i.forEach(({graphic:e})=>e&&a.add(e.layer));const s=e.filter(e=>a.has(e.layer)&&e.supportsUpdateWorkflow);return s.length>0&&r.stopPropagation(),s});return y(Promise.allSettled(a.map(async({layer:e})=>{const a=e.createQuery();a.returnGeometry=!0,a.outFields=Je(e);const s="renderer"in e?M({renderer:e.renderer,pointerType:r.pointerType}):0;a.geometry=$(o,s,t),a.outSpatialReference=t.spatialReference;const{features:l}=await e.queryFeatures(a,{signal:n});return i?.forEach(({graphic:t})=>{t.layer!==e||l.some(e=>e.getObjectId()===t.getObjectId())||l.push(t)}),l})),n)}function Je(e){return U(e.fieldsIndex,[e.objectIdField,L({displayField:"displayField"in e?e.displayField:null,fields:e.fields})])}async function Ke(e,t,n,o){const i=e.map(e=>e.getObjectId()??e.attributes[t.objectIdField]).filter(r);return await W(i,t,n,o)}async function Xe(e){const{graphic:t,sketchViewModel:r,sourceLayer:n,updateOptions:o,visualVariables:i}=e;await _e(e);const a={multipleSelectionEnabled:!1,...o};return"point"===n.geometryType&&(a.enableRotation=null!=i.rotation,a.enableScaling=null!=i.size),r.update(t,a)}function Ye(e,t){const{activeUpdateOptions:r}=e;r&&(e.activeUpdateOptions={...r,...t,reshapeOptions:{...r.reshapeOptions,...t.reshapeOptions},highlightOptions:{...r.highlightOptions,...t.highlightOptions}})}async function _e(e){const{graphic:t,sketchLayer:r,sketchViewModel:n,sourceLayer:o,visualVariables:i}=e;let a=!1;const{rotation:s,size:l}=i;for(const c of[s,l]){if(null==c)continue;const e=t.getAttribute(c.field);if(null!=e)c.setInitialValue(e);else{const e=await c.getDefaultValue(t.symbol,n.view);c.setInitialValue(e),t.setAttribute(c.field,e),a=!0}}if(a){const e="2d"===n.view?.type?n.view.scale:null;await Z(t,e)}Be(n.tooltipOptions,l,s),r.elevationInfo=o.elevationInfo}function et(e){return null==e||"rotate-start"!==e.type&&"rotate"!==e.type&&"rotate-stop"!==e.type?null:e}function tt(e){return null==e||"scale-start"!==e.type&&"scale"!==e.type&&"scale-stop"!==e.type?null:e}function rt(e,t,r,n){if(null==t.geometry||"point"!==t.geometry?.type)return!1;const o=t.attributes;let i=!1;const a=n.rotation,s=et(r.toolEventInfo);if(null!=a&&null!=s){const{field:r,getValue:n}=a;if("rotate-stop"===s.type)a.isUpdatingInteractively=!1,a.setInitialValue(t.getAttribute(r));else{a.isUpdatingInteractively=!0;const l=n(s.angle,e);l!==o[r]&&t.setAttribute(r,l),i=!0}}const l=n.size,c=tt(r.toolEventInfo);if(null!=l&&null!=c){const{field:r,getValue:n}=l;if("scale-stop"===c.type)l.isUpdatingInteractively=!1,l.setInitialValue(t.getAttribute(r));else{l.isUpdatingInteractively=!0;const a=n(c.xScale,e);a!==o[r]&&t.setAttribute(r,a),i=!0}}return i}async function nt({feature:e,featureClone:t,sketchLayer:r,sketchViewModel:n,getUpdateOptions:o,view:i,visualVariableAttributes:c,addHandle:u,addUpdatingPromise:p,onUpdate:f}){await Z(t,"2d"===i.type?i.scale:null);let y=null;if("2d"===n?.view?.type){const e=d(e=>Z(t,e));y=m(()=>n?.view?.scale,t=>e(t))}const h=t.sourceLayer,w=ct(i,h);await Xe({graphic:t,sketchLayer:r,sketchViewModel:n,sourceLayer:h,updateOptions:o(),visualVariables:c});let I=null;w.then(e=>I=e).catch(()=>{});const v=c.size,T=c.rotation,F=m(()=>e.attributes,async e=>{let r=!1;for(const n in e){const o=e[n];o!==t.getAttribute(n)&&(t.setAttribute(n,o),null==v||v.isUpdatingInteractively||v.field!==n||v.setInitialValue(o),null==T||T.isUpdatingInteractively||T.field!==n||T.setInitialValue(o),(null==I||I.requiredFields.includes(n))&&(r=!0))}r&&await Z(t,"2d"===i.type?i.scale:null)}),j=n.on("update",async e=>{const t=e.graphics[0],a={graphic:t,sketchLayer:r,sketchViewModel:n,sourceLayer:h,updateOptions:o(),visualVariables:c};if("complete"===e.state){const e=new AbortController,t=l(e);return u(t),p(g(()=>null===i.activeTool,e.signal).then(async()=>{if(!e.signal.aborted)return e.abort(),Xe(a)}))}rt(i,t,e,c)&&await Z(t,"2d"===i.type?i.scale:null),f(pt(t),e)}),k=b(()=>null!=i.activeTool&&i.activeTool!==n.activeComponent,()=>n.cancel()),S=n.on(["undo","redo"],e=>{f(pt(e.graphics[0]),e)});return a([S,j,k,s(()=>n.cancel()),F,y])}const ot={icon:w(24),text:w(12),line:w(1),viewScaleSizeFactor:100};function it(e,t,r){let n=!1;return e.filter(e=>!!n||(n=e===t,n)).map(e=>r[e]())}function at(e,t){e.viewModel.syncFeatureTemplates();const r=e.creationInfo;if("awaiting-feature-creation-info"===t[0].id&&r){const n=r.layer,o=e.viewModel.getTemplatesForLayer(n);1===o.length&&"scene"!==n.type&&(r.template=o[0],t.shift())}return t}function st(e){return"unknown"===e?null:e}const lt=e=>e.includes("-stop")||e.includes("vertex-"),ct=(e,t)=>{const r="subtype-sublayer"===t.type?t.parent:t;return e.whenLayerView(r)};function ut(e){return"createInteractiveEditSession"in e}function pt(e){const t=e.geometry;if("mesh"===t?.type){const r=e.cloneShallow();return r.attributes=c(e.attributes),r.geometry=t.cloneShallow(),r.geometry.transform=t.transform?.clone()??null,r}return e.clone()}function dt(e){return e.acquireCursor("progress")}function ft(e){for(const t of e){const{destinationGraphic:e,destinationField:r,sourceGraphic:n,sourceField:o}=t;e.setAttribute(r,n.getAttribute(o))}}function yt(e){const t=e.templateExecutorInfo?.completionResults;return t?.length?(t.forEach(e=>ft(e.relationships)),t.flatMap(e=>e.edits)):null}function mt(e){const t=ae(e)?e.activeWorkflow:e;if(null==t)return[];if(ne(t))return t.data.layers;const r=t.layer;return r?[r]:[]}function ht({attributes:e},t){const r=new Set;r.add(t.objectIdField),"uniqueIdFields"in t&&t.uniqueIdFields&&t.uniqueIdFields.length>0&&I(r,t.uniqueIdFields);const n={};for(const o of r)null!=e[o]&&(n[o]=e[o]);if("scene"===t.type&&null!=t.infoFor3D){const r=t.associatedLayer?.globalIdField;null!=r&&(e[r]=e[r])}return n}function gt(e){if(!bt(e))return e;const t=new Map;for(const r of e){const e=r.getObjectId();if(null!=e){const n=r.sourceLayer??r.layer;p(t,n,()=>[]).push(e)}}return Array.from(t.entries()).map(([e,t])=>({layer:e,objectIds:t}))}function bt(e){return 0===e.length||E(e[0])}function wt({drawTool:e},t){const r=e?.mostDownstreamPlugin?.configuration?.curveTypes;if(!t||!r||0===r.length)return!1;const n=new Set(t.capabilities.supportedCurveTypes);return r.some(e=>!n.has(e))}function It(e,t){const r=new Set(t.capabilities.supportedCurveTypes);return e.some(({geometry:e})=>e&&k(e)&&S(e,r))}function vt({filter:e,forEachFeature:t,forEachValueChange:r}){return n=>{for(const{feature:o,changes:i}of n.data)if(!e||e(o)){for(const{fieldName:e,value:t}of i)r?.(e,t,o);t?.(o,i)}}}export{wt as activeSketchToolDrawsUnsupportedCurve,Ce as appendAllUtilityNetworkAssociationRelationships,at as avoidFeatureTemplateSelectionWithOnlyOneItem,ut as canCreateInteractiveEditSession,pt as cloneGraphicExceptMesh,It as containsUnsupportedCurve,xe as createLayerIdMap,qe as createRelationshipKeyMap,Te as createToolFromGeometryType,it as createWorkflowSteps,$e as fetchCandidates,Ke as fetchFullFeatures,Ee as findAllDependencies,De as findChangesByGlobalId,Ne as findEditorItemForLayer,Ze as findEditorItemForLayerOrThrow,We as findLayerInfo,Pe as generateHashForRelationship,mt as getLayersFromWorkflow,he as getRotationVariableAttribute,yt as getServiceEditsFromWorkflowData,Ue as getServiceInfoForLayer,Le as getServiceLayersById,we as getSizeVariableAttribute,me as getVisualVariableAttributes,ye as getVisualVariablesForLayer,vt as handleFormValuesChangeEvent,_ as isAnyUpdateLeafWorkflow,ee as isBatchAttributeFormViewModel,te as isCreateFeaturesWorkflow,re as isFeatureFormViewModel,bt as isGraphicsArray,se as isMergeFeaturesWorkflow,ue as isMergeWorkflowOptions,ce as isParentWorkflow,le as isSplitFeatureWorkflow,pe as isSplitWorkflowOptions,lt as isTerminalUpdateEventType,oe as isUpdateFeatureWorkflow,ne as isUpdateFeaturesWorkflow,fe as isUpdateFeaturesWorkflowOptions,ie as isUpdateRecordWorkflow,ae as isUpdateWorkflow,Re as isUtilityNetworkAssociationsTable,ht as makeMinimalAttributes,Me as orderEditsByRelationshipDependencies,ft as setRelationshipFields,nt as setUpGeometryUpdate,je as setUpSketchCreateWatchers,_e as setVisualVariablesAndElevationInfoForUpdate,dt as showProgressCursor,ot as sizeDefaults,st as sizeVariableUnitToLengthUnit,Fe as startCreatingNewFeature,Xe as startUpdatingFeatureGeometry,Ye as syncUpdateOptions,gt as toFeatureInfos,rt as visualVariableInteractiveUpdate,ct as whenEditorLayerView,de as workflowInfluencesOutcomeOfParent};
2
+ import e from"../../Color.js";import t from"../../Graphic.js";import{isSome as r,equals as n,addMany as o}from"../../core/arrayUtils.js";import i from"../../core/Error.js";import{handlesGroup as a,makeHandle as s,abortHandle as l}from"../../core/handleUtils.js";import{clone as c}from"../../core/lang.js";import u from"../../core/Logger.js";import{getOrCreateMapValue as p}from"../../core/MapUtils.js";import{debounce as d,isPromiseLike as f,whenOrAbort as y}from"../../core/promiseUtils.js";import{watch as m,on as h,whenOnce as g,when as b}from"../../core/reactiveUtils.js";import{px2pt as w}from"../../core/screenUtils.js";import{addMany as I}from"../../core/SetUtils.js";import{isSharedTemplateOrMetadata as v,isSharedGroupTemplate as T,getCreationAttributes as F,isSharedPresetTemplate as j}from"../../editing/templateUtils.js";import{isCurvedGeometry as k,hasUnsupportedCurve as A}from"../../geometry/support/curves/curveUtils.js";import S from"../../layers/GraphicsLayer.js";import{featureHasFields as O,fixFields as U,getDisplayFieldName as L}from"../../layers/support/fieldUtils.js";import{isSubtypeSublayer as V}from"../../layers/support/layerUtils.js";import{calculateTolerance as M}from"../../renderers/support/clickToleranceUtils.js";import{meterIn as x}from"../../renderers/support/lengthUtils.js";import{isRenderer as q}from"../../renderers/support/typeUtils.js";import{getTransformationType as z}from"../../renderers/visualVariables/support/sizeVariableUtils.js";import{isGraphic as E}from"../../support/graphicInstanceUtils.js";import P from"../../symbols/SimpleFillSymbol.js";import R from"../../symbols/SimpleLineSymbol.js";import C from"../../symbols/SimpleMarkerSymbol.js";import{to3D as D}from"../../symbols/support/symbolConversion.js";import{getDisplayedSymbol as G}from"../../symbols/support/symbolUtils.js";import{getServices as B}from"../../undoredo/support/Services.js";import{defaultDrawingMode as N}from"../../views/draw/drawingModes.js";import{updateGraphicSymbolWhenRequired as Z,fetchFullFeaturesByObjectId as W}from"../../views/draw/support/editingSessionUtils.js";import{createQueryGeometry as $}from"../../views/support/drapedUtils.js";import{filterGraphicHits as Q,hitTestSelectSimilarDistance as H}from"../../views/support/hitTestSelectUtils.js";import{isNextOrLegacyUpdateWorkflow as J,isNextOrLegacyUpdateFeaturesWorkflow as K}from"./compatibilityAdapters.js";import{dependencySort as X}from"./support/dependencySort.js";import{isDrawGraphicTool as Y,isDrawTool as _}from"../Sketch/support/sketchUtils.js";const ee=()=>u.getLogger("esri.widgets.Editor.workflowUtils");function te(e){return ae(e)||oe(e)}function re(e){return!!e&&"features"in e}function ne(e){return null!=e&&"create-features"===e.type}function oe(e){return null!=e&&"update-features"===e.type}function ie(e){return null!=e&&"update-feature"===e.type}function ae(e){return null!=e&&e.type.includes("update-")&&"fullFeature"in e}function se(e){return null!=e&&"update"===e.type}function le(e){return null!=e&&"merge-features"===e.type}function ce(e){return null!=e&&"split-feature"===e.type}function ue(e){const t=e?.type;return"update-feature"===t||"update-table-record"===t||"update-features"===t||"split-feature"===t}function pe(e){return"merge"===e?.type}function de(e){return"split"===e?.type}function fe(e){return le(e)||ce(e)}function ye(e){return"update-multiple"===e?.type}function me(e){const t=e&&"renderer"in e?e.renderer:null;if(!Te(t))return{rotation:null,size:null};const r=t.getVisualVariablesForType("rotation").filter(e=>(!e.axis||"heading"===e.axis)&&e.field&&!e.valueExpression),n=t.getVisualVariablesForType("size").filter(e=>e.field&&!e.useSymbolValue&&!e.valueExpression&&"real-world-size"===z(e));return{rotation:1===r.length?r[0]:null,size:1===n.length?n[0]:null}}function he(e){const t=e.sourceLayer;if(!(t&&"renderer"in t&&Te(t.renderer)))return{rotation:null,size:null};const{rotation:r,size:n}=me(t);let o=null,i=null;if(r){const e=t.fields?.filter(e=>e.name===r.field),n=1===e?.length?e[0]:null;o=ge(r,n)}if(n){const e=t.fields?.filter(e=>e.name===n.field),r=1===e?.length?e[0]:null;i=Ie(n,r)}return{rotation:o,size:i}}function ge(e,t){const r="heading"===(e.axis||"heading")&&"arithmetic"===e.rotationType?-1:1,n=t?.type??"double",o={initial:0,current:0};return{field:e.field,fieldType:n,getDefaultValue:()=>Promise.resolve(0),getValue:e=>(o.current=o.initial-r*e,ve((o.current+360)%360,n)),setInitialValue:e=>{o.initial=e,o.current=0},isUpdatingInteractively:!1,rotationType:e.rotationType??"geographic"}}function be(e,t){switch(t){case"width":return e[0];case"depth":return e[1];case"height":return e[2];default:return e[2]||e[1]||e[0]}}async function we(e,t,r){if(null==t)return 0;const{symbol:n}=D(t);if(null==n||"web-style"===n.type||"cim"===n.type)return 0;const o=n.symbolLayers.at(0);if(!o)return 0;switch(o.type){case"icon":{const{computeIconLayerResourceSize:e}=await import("../../symbols/support/symbolLayerUtils.js");return Math.min(it.icon,(await e(o,it.icon))[0])||it.icon}case"text":return it.text;case"line":return it.line;case"object":{const{computeObjectLayerResourceSize:t}=await import("../../symbols/support/symbolLayerUtils.js");return be(await t(o,e.scale/it.viewScaleSizeFactor),r)}case"path":case"extrude":return e.scale/it.viewScaleSizeFactor;default:return 0}}function Ie(e,t){const r=e.axis,n=t?.type??"double",o={initial:0,current:0},i=x[e.valueUnit]??1;let a;return a="area"===e.valueRepresentation?e=>(e*i/2)**2*Math.PI:"radius"===e.valueRepresentation||"distance"===e.valueRepresentation?e=>e*i/2:e=>e*i,{field:e.field,fieldType:n,getDefaultValue:async(e,t)=>ve(a(await we(t,e,r)),n),getValue:(e,t)=>(o.initial||(o.initial=t.pixelSizeAt(t.center)),o.current=o.initial*e,ve(o.current,n)),setInitialValue:e=>{o.initial=e,o.current=0},isUpdatingInteractively:!1,displayUnit:lt(e.valueUnit),axis:e.axis}}function ve(e,t){switch(t){case"small-integer":case"integer":case"long":return Math.round(e);case"double":case"single":return e;default:return 0}}function Te(e){if(!q(e))return!1;switch(e?.type){case"class-breaks":case"simple":case"unique-value":case"dot-density":case"dictionary":case"pie-chart":return!0;default:return!1}}function Fe(e,t){if(!e||!t)throw new Error("no geometry type");if("multipatch"===e)return{tool:"mesh",createOptions:{mode:"hybrid"}};const r=new Map;r.set("circle",{mode:"freehand"}),r.set("rectangle",{mode:"freehand"});const n={mode:N,optionsPerTool:r};if(v(t)){const o=t.defaultTool,i=T(t)?t.definition?.inputGeometryType??e:e;switch(o){case"freehand":case"stream-line":return{tool:"polyline"===i?"freehandPolyline":"freehandPolygon",createOptions:n};case"autocomplete-freehand-polygons":case"stream-polygon":return{tool:"freehandPolygon",createOptions:n};case"autocomplete-polygons":case"difference-polygon":case"create-structures":case"polygon":case"trace":return{tool:"polygon"===i?"polygon":"polyline",createOptions:n};case"circle":return r.get("circle").preserveAspectRatio=!0,{tool:"circle",createOptions:n};case"ellipse":return r.get("circle").preserveAspectRatio=!1,{tool:"circle",createOptions:n};case"create-points-along-line":case"multipoint":return{tool:"multipoint",createOptions:n};case"line":case"radial-line":case"right-angle-line":case"split":case"two-point-line":return{tool:"polyline",createOptions:n};case"rectangle":case"regular-polygon":case"right-angle-polygon":return{tool:"rectangle",createOptions:n};case"elevation-point-from-contour":case"elevation-point-from-dem":case"parcel-seed":case"point":case"point-and-rotation":case"point-at-end-of-line":return{tool:"point",createOptions:n}}}else{const o=t.drawingTool;if("circle"===o||"ellipse"===o)return r.get("circle").preserveAspectRatio="circle"===o,{tool:"circle",createOptions:n};if("rectangle"===o)return{tool:"rectangle",createOptions:n};if("freehand"===o)return{tool:"polygon"===e?"freehandPolygon":"freehandPolyline",createOptions:n}}return{tool:e,createOptions:n}}async function je(e,t,r){const{creationInfo:n,fullTemplate:o}=r;if(!n)throw new i("featureworkflow","No creation info provided.");const a=n.layer,s=F(o,n.attributeOverrides,n.layer),{view:l}=e,c="2d"===l?.type;T(o)||j(o)||await Be(e,a,s,c?l.scale:null);const{capabilities:u}=a;t.elevationInfo=a.elevationInfo;const p=Fe(a.geometryType,o);e.defaultCreateOptions={graphicProperties:{attributes:s,sourceLayer:a},mode:p.createOptions.mode,optionsPerTool:p.createOptions.optionsPerTool,preserveAspectRatio:p.createOptions.preserveAspectRatio,hasZ:u.data.supportsZ,defaultZ:(c?u.editing.zDefault:null)??e.defaultCreateOptions.defaultZ},null==n.geometryToPlace?await e.create(p.tool):await e.place(n.geometryToPlace,{graphicProperties:{attributes:s,sourceLayer:a}})}async function ke(e){return a([Ae(e),Se(e)])}function Ae({creationAttributes:e,data:t,sketchViewModel:r,view:n}){const{creationInfo:o}=t,{fullTemplate:i}=t;if(!o||"2d"!==n?.type||T(i)||j(i))return null;const a=d(t=>Be(r,o.layer,e,t));return m(()=>n.scale,e=>a(e))}function Se({data:t,sketchViewModel:r,view:n}){const{templateExecutorInfo:o}=t;if(!o)return null;const l=r.activeComponent;if(!n||!Y(l)&&!_(l))return ee().error(new i("featureworkflow","Failed to set up template feedback.")),null;const c=new S({effect:"saturate(0.6) opacity(0.8)",listMode:"hide",title:"Shared Template Feedback Graphics"});n.map?.add(c);const{executor:u,serviceLayersById:p}=o,d=n.theme?.accentColor??new e([255,165,0,1]);return a([h(()=>l,["cursor-update","vertex-add"],()=>{c.removeAll();const e=Y(l)?l.graphic?.geometry:l.unprocessedGeometry;if(!e||!Oe(e))return;const t=u(e,"digitizing");if(!f(t))for(const r of t.edits){const e=p.get(r.id);if(e&&r.addFeatures&&0!==r.addFeatures.length)for(const t of e)if(!t.isTable)for(const e of r.addFeatures){const t=Ue(e,d);t&&c.add(t)}}}),s(()=>{n.map.remove(c),c.destroy()})])}function Oe(e){switch(e.type){case"point":case"multipoint":return!0;case"polyline":{if(k(e))return e.curvePaths[0].length>1;const t=e.paths[0];return!!t&&t.length>1}case"polygon":{if(k(e))return e.curveRings[0].length>2;const t=e.rings[0];return!!t&&(n(t.at(0),t.at(-1))?t.length>2:t.length>1)}default:return!1}}function Ue(e,r){let n=null;switch(e.geometry?.type){case"point":case"multipoint":n=new C({angle:0,color:r,outline:new R({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:1}),path:"undefined",size:8,style:"circle",xoffset:0,yoffset:0});break;case"polygon":n=new P({color:r,outline:new R({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:3}),style:"none"});break;case"polyline":n=new R({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:2});break;default:return null}return new t({geometry:e.geometry,symbol:n,attributes:{...e.attributes}})}function Le(e,t){const r=B(t),n=V(e)?e.parent:e;return r.tablesAndLayersLookup.get(n)}function Ve(e,t){const r=Le(e,t);if(!r)return new Map;const n=new Map;for(const o of r.layersAndTables)p(n,o.layerId,()=>[]).push(o);return n}function Me(e){const t=e.objectIdField,r=e.globalIdField??"";return{id:e.layerId,identifierFields:{objectIdField:t,globalIdField:r},addFeatures:[],deleteAttachments:[],addAttachments:[],deleteFeatures:[],updateFeatures:[]}}function xe(e){const{edits:t,serviceInfo:n,view:o,findOriginalFeature:i}=e,a=qe(n.layersAndTables),s=n.layersAndTables.toArray(),{allEditData:l,editDataByLayerIdMap:c,editDataByIdMap:u}=Ee(t,a,i),p=Pe(l,ze(s,c),c);if(o&&De(l,p,o),0===p.length)return t;const d=X(p,{continueOnCircularDependency:!0}).map(e=>u.get(e)).filter(r),f=new Map;for(const r of d)f.set(r.uniqueId,r);const y=[];for(const r of l)f.has(r.uniqueId)||y.push(r);const m=[];let h=null;for(const r of d){const{layer:e}=r;switch(null==h?h=Me(e):h.id!==e.layerId&&(m.push(h),h=Me(e)),r.operationType){case"add":case"modify":h.addFeatures.push(r.after);break;case"delete":h.deleteFeatures.push(r.before)}}null!==h&&m.push(h);for(const r of y){const e=r.layer.layerId,t=m.find(t=>t.id===e)??Me(r.layer);switch(m.includes(t)||m.push(t),r.operationType){case"add":t.addFeatures.push(r.after);break;case"modify":t.updateFeatures.push(r.after);break;case"delete":t.deleteFeatures.push(r.before);break;case"deleteAttachment":t.deleteAttachments.push(r.attachmentId);break;case"addAttachment":t.addAttachments.push(r.attachment)}}for(const r of m)void 0!==r.deleteAttachments&&0===r.deleteAttachments.length&&delete r.deleteAttachments,void 0!==r.addAttachments&&0===r.addAttachments.length&&delete r.addAttachments;return m}function qe(e){const t=new Map;for(const r of e)t.set(r.layerId,r);return t}function ze(e,t){const r=new Map;for(const n of e)for(const e of n.relationships??[])if(r.set(Re(n,e),""),t.has(e.relatedTableId)){const o=t.get(e.relatedTableId);if(o.length>0)for(const t of o[0].layer.relationships??[])if(t.id===e.id){r.set(Re(n,e),t.keyField);break}}return r}function Ee(e,t,r){const n=new Map,o=[],a=new Map;let s=1;for(const l of e){const e=[],c=t.get(l.id);if(!c)throw new i("featureworkflow",`Failed to prepare applyEdits payload. Layer with id ${l.id} not found.`);for(const t of l.addFeatures??[])e.push({uniqueId:"T"+s++,operationType:"add",layer:c,after:t});for(const t of l.deleteFeatures??[])e.push({uniqueId:"T"+s++,operationType:"delete",before:t,layer:c});for(const t of l.deleteAttachments??[])e.push({uniqueId:"T"+s++,operationType:"deleteAttachment",attachmentId:t,layer:c});for(const t of l.addAttachments??[])e.push({uniqueId:"T"+s++,operationType:"addAttachment",attachment:t,layer:c});for(const t of l.updateFeatures??[])e.push({uniqueId:"T"+s++,operationType:"modify",before:r(t),after:t,layer:c});n.set(c.layerId,e);for(const t of e)o.push(t),a.set(t.uniqueId,t)}return{allEditData:o,editDataByIdMap:a,editDataByLayerIdMap:n}}function Pe(e,t,r){const n=[];for(const o of e){const e=o.layer.relationships??[],{uniqueId:i}=o;for(const a of e){const e=a.keyField;if("origin"===a.role){const s=r.get(a.relatedTableId);if(!s||0===s.length)continue;const l=Re(o.layer,a),c=t.get(l);if(void 0===c||""===c)continue;switch(o.operationType){case"add":for(const t of s)t!==o&&("add"!==t.operationType&&"modify"!==t.operationType||t.after.attributes[c]===o.after.attributes[e]&&n.push([i,t.uniqueId]));break;case"modify":if(o.before.attributes[e]!==o.after.attributes[e])for(const t of s){const r=t.uniqueId;t!==o&&("delete"===t.operationType?t.before.attributes[c]===o.before.attributes[e]?n.push([r,i]):t.before.attributes[c]===o.after.attributes[e]&&n.push([i,r]):"add"===t.operationType?t.after.attributes[c]===o.after.attributes[e]?n.push([i,r]):t.after.attributes[c]===o.before.attributes[e]&&n.push([r,i]):"modify"===t.operationType&&(t.before.attributes[c]!==t.after.attributes[c]?t.after.attributes[c]===o.after.attributes[e]?n.push([i,r]):n.push([r,i]):n.push([i,r])))}break;case"delete":for(const t of s)t!==o&&("delete"!==t.operationType&&"modify"!==t.operationType||t.before.attributes[c]===o.before.attributes[e]&&n.push([t.uniqueId,i]))}}}}return n}function Re(e,t){return`${e.layerId}:${t.id}`}function Ce(e,t){return!!(t?.map&&"utilityNetworks"in t.map&&t.map.utilityNetworks?.length&&t.map.utilityNetworks.some(t=>!(!t.loaded||!e.url?.startsWith(t.featureServiceUrl)||e.layerId!==t.networkSystemLayers.associationsTableId)))}function De(e,t,r){const n=[];for(const i of e)Ce(i.layer,r)&&n.push(i);if(0===n.length)return;let o=[];for(const i of n){const r=i.layer;switch(i.operationType){case"delete":o=[...Ge(i.before.attributes[r.fieldsIndex.get("fromglobalid").name],e),...Ge(i.before.attributes[r.fieldsIndex.get("toglobalid").name],e)];for(const e of o)t.push([i.uniqueId,e.uniqueId]);break;case"add":o=[...Ge(i.after.attributes[r.fieldsIndex.get("fromglobalid").name],e),...Ge(i.after.attributes[r.fieldsIndex.get("toglobalid").name],e)];for(const e of o)t.push([e.uniqueId,i.uniqueId])}}}function Ge(e,t){const r=[],n=t.filter(({layer:e})=>""!==e.globalIdField&&null!=e.globalIdField);for(const o of n){const t=o.layer.globalIdField;("before"in o&&o.before?.attributes[t]===e||"after"in o&&o.after?.attributes[t]===e)&&r.push(o)}return r}async function Be(e,r,n,o){const i=new t({sourceLayer:r,attributes:n}),{rotation:a,size:s}=he(i);let l=await G(i,{useSourceLayer:!0,scale:o}),c=!1;for(const t of[s,a]){if(null==t)continue;null==n[t.field]&&(n[t.field]=await t.getDefaultValue(l,e.view),c=!0)}switch(c&&(l=await G(i,{useSourceLayer:!0,scale:o})),l?.type){case"simple-fill":case"polygon-3d":e.polygonSymbol=l;break;case"simple-line":case"line-3d":e.polylineSymbol=l;break;case"simple-marker":case"picture-marker":case"point-3d":case"cim":e.pointSymbol=l;break;case"mesh-3d":e.meshSymbol=l}Ne(e.tooltipOptions,s,a)}function Ne(e,t,r){e.visualVariables=null!=t||null!=r?{size:null!=t?{unit:t.displayUnit,axis:t.axis,valueType:t.fieldType}:null,rotation:null!=r?{valueType:r.fieldType,rotationType:r.rotationType??"geographic"}:null}:null}function Ze(e,t){return e.find(e=>e.layer===t)}function We(e,t){const r=Ze(e,t);if(null==r)throw new i("no-editorItem-found","The EditorViewModel provided did not have an EditorItem associated with the specified layer");return r}function $e(e,t){return e?.find(e=>e.layer===t)}async function Qe(e,t,r,n){switch(t.type){case"3d":return He(e,t,r,n);case"2d":return Je(e,t,r,n)}}async function He(e,t,r,n){if(0===e.length)return[];const{updatable:i,graphicsByLayer:a}=await r.defer(async()=>{const{results:o}=await y(H(t,r),n),i=new Map,a=e=>{const t=e.layer,r=i.get(t);if(!r){const e=new Array;return i.set(t,e),e}return r};Q(o).forEach(({graphic:e})=>a(e).push(e));const s=e.filter(({capabilities:e,layer:t})=>e.update.enabled&&i.has(t));return 0!==s.length&&r.stopPropagation(),{updatable:s,graphicsByLayer:i}});return y(Promise.allSettled(i.map(async({layer:e})=>{const t=a.get(e),r=Ke(e);if(t.every(e=>O(e,r)))return t;const i=[];for(const n of t){i.push(n.getObjectId());const e=Object.keys(n.attributes);o(r,e)}const s=e.createQuery();return s.returnGeometry=!1,s.objectIds=i,s.outFields=U(e.fieldsIndex,r),e.queryFeatures(s,{signal:n}).then(({features:e})=>e)})),n)}async function Je(e,t,r,n){if(0===e.length)return[];const{mapPoint:o}=r;if(null==o)return[];let i=null;const a=await r.defer(async()=>{const{results:o}=await y(t.hitTest(r),n);if(0===o.length)return[];const a=new Set;i=Q(o),i.forEach(({graphic:e})=>e&&a.add(e.layer));const s=e.filter(e=>a.has(e.layer)&&e.supportsUpdateWorkflow);return s.length>0&&r.stopPropagation(),s});return y(Promise.allSettled(a.map(async({layer:e})=>{const a=e.createQuery();a.returnGeometry=!0,a.outFields=Ke(e);const s="renderer"in e?M({renderer:e.renderer,pointerType:r.pointerType}):0;a.geometry=$(o,s,t),a.outSpatialReference=t.spatialReference;const{features:l}=await e.queryFeatures(a,{signal:n});return i?.forEach(({graphic:t})=>{t.layer!==e||l.some(e=>e.getObjectId()===t.getObjectId())||l.push(t)}),l})),n)}function Ke(e){return U(e.fieldsIndex,[e.objectIdField,L({displayField:"displayField"in e?e.displayField:null,fields:e.fields})])}async function Xe(e,t,n,o){const i=e.map(e=>e.getObjectId()??e.attributes[t.objectIdField]).filter(r);return await W(i,t,n,o)}async function Ye(e){const{graphic:t,sketchViewModel:r,sourceLayer:n,updateOptions:o,visualVariables:i}=e;await et(e);const a={multipleSelectionEnabled:!1,...o};return"point"===n.geometryType&&(a.enableRotation=null!=i.rotation,a.enableScaling=null!=i.size),r.update(t,a)}function _e(e,t){const{activeUpdateOptions:r}=e;r&&(e.activeUpdateOptions={...r,...t,reshapeOptions:{...r.reshapeOptions,...t.reshapeOptions},highlightOptions:{...r.highlightOptions,...t.highlightOptions}})}async function et(e){const{graphic:t,sketchLayer:r,sketchViewModel:n,sourceLayer:o,visualVariables:i}=e;let a=!1;const{rotation:s,size:l}=i;for(const c of[s,l]){if(null==c)continue;const e=t.getAttribute(c.field);if(null!=e)c.setInitialValue(e);else{const e=await c.getDefaultValue(t.symbol,n.view);c.setInitialValue(e),t.setAttribute(c.field,e),a=!0}}if(a){const e="2d"===n.view?.type?n.view.scale:null;await Z(t,e)}Ne(n.tooltipOptions,l,s),r.elevationInfo=o.elevationInfo}function tt(e){return null==e||"rotate-start"!==e.type&&"rotate"!==e.type&&"rotate-stop"!==e.type?null:e}function rt(e){return null==e||"scale-start"!==e.type&&"scale"!==e.type&&"scale-stop"!==e.type?null:e}function nt(e,t,r,n){if(null==t.geometry||"point"!==t.geometry?.type)return!1;const o=t.attributes;let i=!1;const a=n.rotation,s=tt(r.toolEventInfo);if(null!=a&&null!=s){const{field:r,getValue:n}=a;if("rotate-stop"===s.type)a.isUpdatingInteractively=!1,a.setInitialValue(t.getAttribute(r));else{a.isUpdatingInteractively=!0;const l=n(s.angle,e);l!==o[r]&&t.setAttribute(r,l),i=!0}}const l=n.size,c=rt(r.toolEventInfo);if(null!=l&&null!=c){const{field:r,getValue:n}=l;if("scale-stop"===c.type)l.isUpdatingInteractively=!1,l.setInitialValue(t.getAttribute(r));else{l.isUpdatingInteractively=!0;const a=n(c.xScale,e);a!==o[r]&&t.setAttribute(r,a),i=!0}}return i}async function ot({feature:e,featureClone:t,sketchLayer:r,sketchViewModel:n,getUpdateOptions:o,view:i,visualVariableAttributes:c,addHandle:u,addUpdatingPromise:p,onUpdate:f}){await Z(t,"2d"===i.type?i.scale:null);let y=null;if("2d"===n?.view?.type){const e=d(e=>Z(t,e));y=m(()=>n?.view?.scale,t=>e(t))}const h=t.sourceLayer,w=ut(i,h);await Ye({graphic:t,sketchLayer:r,sketchViewModel:n,sourceLayer:h,updateOptions:o(),visualVariables:c});let I=null;w.then(e=>I=e).catch(()=>{});const v=c.size,T=c.rotation,F=m(()=>e.attributes,async e=>{let r=!1;for(const n in e){const o=e[n];o!==t.getAttribute(n)&&(t.setAttribute(n,o),null==v||v.isUpdatingInteractively||v.field!==n||v.setInitialValue(o),null==T||T.isUpdatingInteractively||T.field!==n||T.setInitialValue(o),(null==I||I.requiredFields.includes(n))&&(r=!0))}r&&await Z(t,"2d"===i.type?i.scale:null)}),j=n.on("update",async e=>{const t=e.graphics[0],a={graphic:t,sketchLayer:r,sketchViewModel:n,sourceLayer:h,updateOptions:o(),visualVariables:c};if("complete"===e.state){const e=new AbortController,t=l(e);return u(t),p(g(()=>null===i.activeTool,e.signal).then(async()=>{if(!e.signal.aborted)return e.abort(),Ye(a)}))}nt(i,t,e,c)&&await Z(t,"2d"===i.type?i.scale:null),f(dt(t),e)}),k=b(()=>null!=i.activeTool&&i.activeTool!==n.activeComponent,()=>n.cancel()),A=n.on(["undo","redo"],e=>{f(dt(e.graphics[0]),e)});return a([A,j,k,s(()=>n.cancel()),F,y])}const it={icon:w(24),text:w(12),line:w(1),viewScaleSizeFactor:100};function at(e,t,r){let n=!1;return e.filter(e=>!!n||(n=e===t,n)).map(e=>r[e]())}function st(e,t){e.viewModel.syncFeatureTemplates();const r=e.creationInfo;if("awaiting-feature-creation-info"===t[0].id&&r){const n=r.layer,o=e.viewModel.getTemplatesForLayer(n);1===o.length&&"scene"!==n.type&&(r.template=o[0],t.shift())}return t}function lt(e){return"unknown"===e?null:e}const ct=e=>e.includes("-stop")||e.includes("vertex-"),ut=(e,t)=>{const r="subtype-sublayer"===t.type?t.parent:t;return e.whenLayerView(r)};function pt(e){return"createInteractiveEditSession"in e}function dt(e){const t=e.geometry;if("mesh"===t?.type){const r=e.cloneShallow();return r.attributes=c(e.attributes),r.geometry=t.cloneShallow(),r.geometry.transform=t.transform?.clone()??null,r}return e.clone()}function ft(e){return e.acquireCursor("progress")}function yt(e){for(const t of e){const{destinationGraphic:e,destinationField:r,sourceGraphic:n,sourceField:o}=t;e.setAttribute(r,n.getAttribute(o))}}function mt(e){const t=e.templateExecutorInfo?.completionResults;return t?.length?(t.forEach(e=>yt(e.relationships)),t.flatMap(e=>e.edits)):null}function ht(e){const t=J(e)?e.activeWorkflow:e;if(null==t)return[];if(K(t))return t.data.layers;const r=t.layer;return r?[r]:[]}function gt({attributes:e},t){const r=new Set;r.add(t.objectIdField),"uniqueIdFields"in t&&t.uniqueIdFields&&t.uniqueIdFields.length>0&&I(r,t.uniqueIdFields);const n={};for(const o of r)null!=e[o]&&(n[o]=e[o]);if("scene"===t.type&&null!=t.infoFor3D){const r=t.associatedLayer?.globalIdField;null!=r&&(e[r]=e[r])}return n}function bt(e){if(!wt(e))return e;const t=new Map;for(const r of e){const e=r.getObjectId();if(null!=e){const n=r.sourceLayer??r.layer;p(t,n,()=>[]).push(e)}}return Array.from(t.entries()).map(([e,t])=>({layer:e,objectIds:t}))}function wt(e){return 0===e.length||E(e[0])}function It({drawTool:e},t){const r=e?.mostDownstreamPlugin?.configuration?.curveTypes;if(!t||!r||0===r.length)return!1;const n=new Set(t.capabilities.supportedCurveTypes);return r.some(e=>!n.has(e))}function vt(e,t){const r=new Set(t.capabilities.supportedCurveTypes);return e.some(({geometry:e})=>e&&k(e)&&A(e,r))}function Tt({filter:e,forEachFeature:t,forEachValueChange:r}){return n=>{for(const{feature:o,changes:i}of n.data)if(!e||e(o)){for(const{fieldName:e,value:t}of i)r?.(e,t,o);t?.(o,i)}}}export{It as activeSketchToolDrawsUnsupportedCurve,De as appendAllUtilityNetworkAssociationRelationships,st as avoidFeatureTemplateSelectionWithOnlyOneItem,pt as canCreateInteractiveEditSession,dt as cloneGraphicExceptMesh,vt as containsUnsupportedCurve,qe as createLayerIdMap,ze as createRelationshipKeyMap,Fe as createToolFromGeometryType,at as createWorkflowSteps,Qe as fetchCandidates,Xe as fetchFullFeatures,Pe as findAllDependencies,Ge as findChangesByGlobalId,Ze as findEditorItemForLayer,We as findEditorItemForLayerOrThrow,$e as findLayerInfo,Re as generateHashForRelationship,ht as getLayersFromWorkflow,ge as getRotationVariableAttribute,mt as getServiceEditsFromWorkflowData,Le as getServiceInfoForLayer,Ve as getServiceLayersById,Ie as getSizeVariableAttribute,he as getVisualVariableAttributes,me as getVisualVariablesForLayer,Tt as handleFormValuesChangeEvent,te as isAnyUpdateLeafWorkflow,re as isBatchAttributeFormViewModel,ne as isCreateFeaturesWorkflow,wt as isGraphicsArray,le as isMergeFeaturesWorkflow,pe as isMergeWorkflowOptions,ue as isParentWorkflow,ce as isSplitFeatureWorkflow,de as isSplitWorkflowOptions,ct as isTerminalUpdateEventType,ie as isUpdateFeatureWorkflow,oe as isUpdateFeaturesWorkflow,ye as isUpdateFeaturesWorkflowOptions,ae as isUpdateRecordWorkflow,se as isUpdateWorkflow,Ce as isUtilityNetworkAssociationsTable,gt as makeMinimalAttributes,xe as orderEditsByRelationshipDependencies,yt as setRelationshipFields,ot as setUpGeometryUpdate,ke as setUpSketchCreateWatchers,et as setVisualVariablesAndElevationInfoForUpdate,ft as showProgressCursor,it as sizeDefaults,lt as sizeVariableUnitToLengthUnit,je as startCreatingNewFeature,Ye as startUpdatingFeatureGeometry,_e as syncUpdateOptions,bt as toFeatureInfos,nt as visualVariableInteractiveUpdate,ut as whenEditorLayerView,fe as workflowInfluencesOutcomeOfParent};