@arcgis/core 5.2.0-next.21 → 5.2.0-next.23

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 (214) hide show
  1. package/Graphic.d.ts +1 -0
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/{eccbddaec4be44c86f79.js → 1040bce57ea63a6dbca4.js} +2 -2
  4. package/assets/esri/core/workers/chunks/1a7c0a1dc6ecc93ea03a.js +1 -0
  5. package/assets/esri/core/workers/chunks/292498a9c7d462d215c6.js +1 -0
  6. package/assets/esri/core/workers/chunks/2d6d01913096f7cb5ff8.js +1 -0
  7. package/assets/esri/core/workers/chunks/30298f84bd414f9dea64.js +1 -0
  8. package/assets/esri/core/workers/chunks/353c67da4b25c29360db.js +2 -0
  9. package/assets/esri/core/workers/chunks/3b4fc67f6cb7393fbd97.js +1 -0
  10. package/assets/esri/core/workers/chunks/47948c72bc01bd173c20.js +2 -0
  11. package/assets/esri/core/workers/chunks/{f0519b06987471456b69.js → 502464c4eab7667f6566.js} +1 -1
  12. package/assets/esri/core/workers/chunks/{d7acbc2ddff4cee8a465.js → 5ee887fc6e1e0e70e02f.js} +1 -1
  13. package/assets/esri/core/workers/chunks/6c0c77de1934f35dc45f.js +1 -0
  14. package/assets/esri/core/workers/chunks/{f7f820483e45c05ab9e4.js → 75df436e6e9773bdcfc2.js} +1 -1
  15. package/assets/esri/core/workers/chunks/780519b60aa674a61a74.js +1 -0
  16. package/assets/esri/core/workers/chunks/7dbaa089c7472825b80c.js +1 -0
  17. package/assets/esri/core/workers/chunks/7dec8c453fdee1968d12.js +1 -0
  18. package/assets/esri/core/workers/chunks/{a2247f4c3116efb16c4f.js → 7e23de8d9b2d938808f6.js} +1 -1
  19. package/assets/esri/core/workers/chunks/7e4093f42795ba2f8cfd.js +1 -0
  20. package/assets/esri/core/workers/chunks/{6649acaceab00ad30e7f.js → 8ba3e0462a9bdaae5f40.js} +1 -1
  21. package/assets/esri/core/workers/chunks/928b18e13e015330d44b.js +1 -0
  22. package/assets/esri/core/workers/chunks/9434c76ad39c936dba90.js +1 -0
  23. package/assets/esri/core/workers/chunks/{909e67dee8c30e391d69.js → a8310f55de4749f973d0.js} +1 -1
  24. package/assets/esri/core/workers/chunks/{ac16016964be3b684e98.js → aded4e704e09a28edc8f.js} +1 -1
  25. package/assets/esri/core/workers/chunks/{7175f0c6a6e56b685d20.js → b419fd36337e76e2d4a3.js} +6 -6
  26. package/assets/esri/core/workers/chunks/{05d597dd117766beadd8.js → b91a15522692781560b4.js} +1 -1
  27. package/assets/esri/core/workers/chunks/c86d388d216adbb15a05.js +1 -0
  28. package/assets/esri/core/workers/chunks/{f1ff33584680d8718400.js → c9ce408675dae6a0edd1.js} +1 -1
  29. package/assets/esri/core/workers/chunks/{0b522e05668bef729b1b.js → ceb5bd9f2afaa2ea0808.js} +1 -1
  30. package/assets/esri/core/workers/chunks/d07068c44d560e4ce02e.js +1 -0
  31. package/assets/esri/core/workers/chunks/{da47fdffb5969694a2ae.js → d41eed41916ed0422059.js} +1 -1
  32. package/assets/esri/core/workers/chunks/{19493c9c7e1d2ac0f80f.js → d4e0346209fabc58f929.js} +1 -1
  33. package/assets/esri/core/workers/chunks/{b375abfb2a2d9c63e20a.js → db90fb8ac96579259566.js} +1 -1
  34. package/assets/esri/core/workers/chunks/{44b30bce8e9a75b9e1b3.js → dd0acd0f8b96839b4f24.js} +2 -2
  35. package/assets/esri/core/workers/chunks/{5809e70a8e57e9b05959.js → dd795c95cdc3812b5b49.js} +1 -1
  36. package/assets/esri/core/workers/chunks/f7344d855f1092383abe.js +1 -0
  37. package/assets/esri/core/workers/chunks/{2dbd88566abac030e965.js → f859c53432f258af77e3.js} +2 -2
  38. package/assets/esri/core/workers/chunks/{ecbf84a1f42e6188faab.js → fd629872b5c07853f695.js} +1 -1
  39. package/assets/esri/libs/parquet/pkg/bundle_bg.wasm +0 -0
  40. package/assets/esri/themes/base/widgets/_BatchAttributeForm.scss +5 -1
  41. package/assets/esri/themes/dark/main.css +1 -1
  42. package/assets/esri/themes/light/main.css +1 -1
  43. package/assets/esri/themes/light/view.css +1 -1
  44. package/chunks/GaussianSplat.glsl.js +4 -4
  45. package/chunks/GaussianSplatShadow.glsl.js +1 -1
  46. package/config.d.ts +9 -2
  47. package/config.js +1 -1
  48. package/core/date.js +1 -1
  49. package/form/FormTemplate.d.ts +15 -20
  50. package/form/elements/AttachmentElement.d.ts +38 -11
  51. package/form/elements/Element.d.ts +9 -6
  52. package/form/elements/FieldElement.d.ts +0 -1
  53. package/form/elements/GroupElement.d.ts +4 -6
  54. package/form/elements/RelationshipElement.d.ts +8 -8
  55. package/form/elements/inputs/attachments/AttachmentInput.d.ts +34 -18
  56. package/form/elements/inputs/attachments/AudioInput.d.ts +4 -3
  57. package/form/elements/inputs/attachments/DocumentInput.d.ts +2 -6
  58. package/form/elements/inputs/attachments/ImageInput.d.ts +4 -3
  59. package/form/elements/inputs/attachments/Input.d.ts +6 -3
  60. package/form/elements/inputs/attachments/SignatureInput.d.ts +3 -3
  61. package/form/elements/inputs/attachments/VideoInput.d.ts +4 -3
  62. package/form/elements.d.ts +6 -12
  63. package/form/types.d.ts +0 -4
  64. package/kernel.js +1 -1
  65. package/layers/AnnotationFeatureLayer.d.ts +2 -1
  66. package/layers/DimensionFeatureLayer.d.ts +2 -1
  67. package/layers/OrientedImageryLayer.d.ts +20 -2
  68. package/layers/OrientedImageryLayer.js +1 -1
  69. package/layers/ParquetLayer.js +1 -1
  70. package/layers/graphics/sources/ParquetSource.js +1 -1
  71. package/layers/graphics/sources/geojson/GeoJSONSourceWorker.js +1 -1
  72. package/layers/graphics/sources/geojson/geojson.js +1 -1
  73. package/layers/graphics/sources/parquet/FileProvider.js +1 -1
  74. package/layers/graphics/sources/parquet/PortalParquetLayerFileProvider.js +1 -1
  75. package/layers/graphics/sources/parquet/fileProviderChangedError.js +2 -0
  76. package/layers/graphics/sources/support/ParquetSourceWorker.js +1 -1
  77. package/layers/mixins/EditBusLayer.js +1 -1
  78. package/layers/orientedImagery/core/utils.js +1 -1
  79. package/layers/orientedImagery/types.d.ts +4 -1
  80. package/layers/support/RasterBandInfo.js +1 -1
  81. package/layers/types.d.ts +1 -0
  82. package/package.json +3 -3
  83. package/rest/support/AttachmentQuery.d.ts +13 -1
  84. package/rest/support/AttachmentQuery.js +1 -1
  85. package/rest/support/OutDistance.d.ts +5 -1
  86. package/rest/support/PrintParameters.d.ts +2 -1
  87. package/rest/support/Query.d.ts +2 -0
  88. package/support/basemapUtils.js +1 -1
  89. package/support/revision.js +1 -1
  90. package/symbols/SimpleMarkerSymbol.d.ts +2 -2
  91. package/views/2d/engine/AFeatureContainer.js +1 -1
  92. package/views/2d/engine/webgl/AttributeStoreView.js +1 -1
  93. package/views/2d/engine/webgl/mesh/templates/shapingUtils.js +1 -1
  94. package/views/2d/engine/webgl/shaderGraph/graph/ShaderGraphContext.js +1 -1
  95. package/views/2d/engine/webgl/shaderGraph/graph/glsl.js +1 -1
  96. package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedMarkerMeshWriter.js +1 -1
  97. package/views/2d/engine/webgl/shaderGraph/techniques/pieChart/PieChartMeshWriter.js +1 -1
  98. package/views/2d/engine/webgl/shaderGraph/techniques/pieChart/PieChartShader.js +1 -1
  99. package/views/2d/engine/webgl/shaderGraph/techniques/pieChart/PieChartTechnique.js +1 -1
  100. package/views/2d/engine/webgl/shaderGraph/techniques/text/TextShader.js +1 -1
  101. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  102. package/views/2d/layers/features/FeatureContainer.js +1 -1
  103. package/views/2d/layers/features/schema/processor/symbols/SymbolSchema.js +1 -1
  104. package/views/2d/layers/features/sources/strategies/ParquetTileLoadStrategy.js +1 -1
  105. package/views/2d/layers/support/annodime/DimensionInfo.js +1 -1
  106. package/views/2d/layers/support/annodime/cimAnnotations.js +1 -1
  107. package/views/3d/analysis/LineOfSight/LineOfSightReshapeTool3D.js +1 -1
  108. package/views/3d/analysis/LineOfSight/LineOfSightTool2.js +1 -1
  109. package/views/3d/analysis/ShadowCastAnalysisView3D.js +1 -1
  110. package/views/3d/analysis/Viewshed/ViewshedComputedData.js +1 -1
  111. package/views/3d/analysis/Viewshed/ViewshedSnappingController.js +1 -1
  112. package/views/3d/analysis/Viewshed/ViewshedSubTool.js +1 -1
  113. package/views/3d/interactive/editingTools/reshape/ReshapeOperation.js +1 -1
  114. package/views/3d/interactive/editingTools/reshape/ReshapeTool3D.js +1 -1
  115. package/views/3d/layers/GaussianSplatLayerView3D.js +1 -1
  116. package/views/3d/layers/GaussianSplatLayerViewPerformanceInfo.js +1 -1
  117. package/views/3d/layers/graphics/tessellationUtils.js +1 -1
  118. package/views/3d/state/controllers/PinchAndPanControllerGlobal.js +1 -1
  119. package/views/3d/state/controllers/PinchAndPanControllerLocal.js +1 -1
  120. package/views/3d/state/utils/navigationUtils.js +1 -1
  121. package/views/3d/support/gaussianSplatting/GaussianSplatAtlasPages.js +1 -1
  122. package/views/3d/support/gaussianSplatting/GaussianSplatDataStore.js +1 -1
  123. package/views/3d/support/gaussianSplatting/GaussianSplatHeaderTexture.js +2 -0
  124. package/views/3d/support/gaussianSplatting/GaussianSplatTextureAtlas.js +1 -1
  125. package/views/3d/webgl-engine/core/shaderLibrary/output/Emissions.glsl.js +4 -4
  126. package/views/3d/webgl-engine/core/shaderLibrary/util/GaussianSplatTextureFetch.glsl.js +13 -12
  127. package/views/3d/webgl-engine/effects/glow/Glow.js +1 -1
  128. package/views/3d/webgl-engine/lib/GaussianSplatRenderNode.js +1 -1
  129. package/views/3d/webgl-engine/lib/GaussianSplatShadowRenderNode.js +1 -1
  130. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  131. package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
  132. package/views/3d/webgl-engine/shaders/OutputColorHighlightOLID.glsl.js +1 -1
  133. package/views/PopupView.d.ts +3 -0
  134. package/views/View2D.d.ts +2 -2
  135. package/views/layers/AnnotationFeatureLayerView.d.ts +9 -1
  136. package/views/layers/DimensionFeatureLayerView.d.ts +9 -1
  137. package/views/layers/FeatureLikeLayerView.js +1 -1
  138. package/widgets/BasemapGallery.js +1 -1
  139. package/widgets/BatchAttributeForm/attachmentUtils.js +1 -1
  140. package/widgets/BatchAttributeForm/batchAttributeFormUtils.js +1 -1
  141. package/widgets/BatchAttributeForm/css.js +1 -1
  142. package/widgets/BatchAttributeForm/inputs/AttachmentElementInput.js +1 -1
  143. package/widgets/BatchAttributeForm/templates/support/createBatchFormTemplate.js +1 -1
  144. package/widgets/BatchAttributeForm/types.d.ts +0 -7
  145. package/widgets/BatchAttributeForm.d.ts +7 -9
  146. package/widgets/BatchAttributeForm.js +1 -1
  147. package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
  148. package/widgets/Editor/EditorViewModel.d.ts +12 -2
  149. package/widgets/Editor/EditorViewModel.js +1 -1
  150. package/widgets/Editor/UpdateRecordWorkflow.js +1 -1
  151. package/widgets/Editor/UpdateWorkflow.js +1 -1
  152. package/widgets/Editor/compatibilityAdapters.js +2 -0
  153. package/widgets/Editor/components/PendingFeatureList.js +1 -1
  154. package/widgets/Editor/components/UpdateFeaturePanelContent.js +1 -1
  155. package/widgets/Editor/legacy/AddAssociationWorkflow.js +2 -0
  156. package/widgets/Editor/legacy/AddAssociationWorkflowData.js +2 -0
  157. package/widgets/Editor/legacy/CreateFeaturesWorkflow.js +2 -0
  158. package/widgets/Editor/legacy/CreateFeaturesWorkflowData.js +2 -0
  159. package/widgets/Editor/legacy/MergeFeaturesWorkflow.js +2 -0
  160. package/widgets/Editor/legacy/MergeFeaturesWorkflowData.js +2 -0
  161. package/widgets/Editor/legacy/SplitFeatureWorkflow.js +2 -0
  162. package/widgets/Editor/legacy/SplitFeatureWorkflowData.js +2 -0
  163. package/widgets/Editor/legacy/UpdateFeatureWorkflow.js +2 -0
  164. package/widgets/Editor/legacy/UpdateFeatureWorkflowData.js +2 -0
  165. package/widgets/Editor/legacy/UpdateFeaturesWorkflow.js +2 -0
  166. package/widgets/Editor/legacy/UpdateFeaturesWorkflowData.js +2 -0
  167. package/widgets/Editor/legacy/UpdateRecordWorkflow.js +2 -0
  168. package/widgets/Editor/legacy/UpdateRecordWorkflowData.js +2 -0
  169. package/widgets/Editor/legacy/UpdateWorkflow.js +2 -0
  170. package/widgets/Editor/legacy/UpdateWorkflowData.js +2 -0
  171. package/widgets/Editor/legacy/Workflow.js +2 -0
  172. package/widgets/Editor/legacy/workflowUtils.js +2 -0
  173. package/widgets/Editor/types.d.ts +12 -0
  174. package/widgets/Editor/workflowUtils.js +1 -1
  175. package/widgets/Editor.js +1 -1
  176. package/widgets/FeatureForm/FeatureFormViewModel.d.ts +16 -12
  177. package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
  178. package/widgets/FeatureForm.d.ts +14 -16
  179. package/widgets/FeatureTable/FeatureTableViewModel.d.ts +2 -1
  180. package/widgets/FeatureTable/Grid/Grid.js +1 -1
  181. package/widgets/FeatureTable/Grid/GridViewModel.d.ts +3 -0
  182. package/widgets/FeatureTable/Grid/GridViewModel.js +1 -1
  183. package/widgets/FeatureTable/Grid/types.d.ts +20 -0
  184. package/widgets/FeatureTable.d.ts +14 -2
  185. package/widgets/FeatureTable.js +1 -1
  186. package/widgets/OrientedImageryViewer/components/ImageLocationWidget.js +1 -1
  187. package/widgets/OrientedImageryViewer/components/ImageViewerViewModel.js +1 -1
  188. package/widgets/OrientedImageryViewer/navigation/queries.js +1 -1
  189. package/widgets/OrientedImageryViewer/navigation/utils.js +1 -1
  190. package/widgets/OrientedImageryViewer/support/panConstraint.js +1 -1
  191. package/widgets/OrientedImageryViewer.js +1 -1
  192. package/widgets/ShadowCast/ShadowCastViewModel.js +1 -1
  193. package/assets/esri/core/workers/chunks/057d288d795b853295f1.js +0 -2
  194. package/assets/esri/core/workers/chunks/26aa8190ac439f634c5b.js +0 -1
  195. package/assets/esri/core/workers/chunks/3192586ec7fc73ed1165.js +0 -1
  196. package/assets/esri/core/workers/chunks/33866e6e6de1bab64599.js +0 -1
  197. package/assets/esri/core/workers/chunks/360fd810d70d21c092d9.js +0 -1
  198. package/assets/esri/core/workers/chunks/3e89f487c5851c954d8b.js +0 -1
  199. package/assets/esri/core/workers/chunks/5aa375b0c6a205134703.js +0 -1
  200. package/assets/esri/core/workers/chunks/5f0bc019add4aff3130c.js +0 -1
  201. package/assets/esri/core/workers/chunks/630ad47857de3cf726d1.js +0 -1
  202. package/assets/esri/core/workers/chunks/754f7ed62afc4e0a1972.js +0 -2
  203. package/assets/esri/core/workers/chunks/7ee76504e7fea389a1c9.js +0 -1
  204. package/assets/esri/core/workers/chunks/8331e04ebe0a54b04ab6.js +0 -1
  205. package/assets/esri/core/workers/chunks/8c64c6b8d7376a9d1c91.js +0 -1
  206. package/assets/esri/core/workers/chunks/c30ca771dd3f7198142b.js +0 -1
  207. package/assets/esri/core/workers/chunks/e5fcd8e7a4a660ef6ad6.js +0 -1
  208. package/assets/esri/core/workers/chunks/f47319d36f1527277923.js +0 -1
  209. package/assets/esri/core/workers/chunks/ff00ac01f0baaecaa890.js +0 -1
  210. /package/assets/esri/core/workers/chunks/{eccbddaec4be44c86f79.js.LICENSE.txt → 1040bce57ea63a6dbca4.js.LICENSE.txt} +0 -0
  211. /package/assets/esri/core/workers/chunks/{057d288d795b853295f1.js.LICENSE.txt → 353c67da4b25c29360db.js.LICENSE.txt} +0 -0
  212. /package/assets/esri/core/workers/chunks/{44b30bce8e9a75b9e1b3.js.LICENSE.txt → 47948c72bc01bd173c20.js.LICENSE.txt} +0 -0
  213. /package/assets/esri/core/workers/chunks/{754f7ed62afc4e0a1972.js.LICENSE.txt → dd0acd0f8b96839b4f24.js.LICENSE.txt} +0 -0
  214. /package/assets/esri/core/workers/chunks/{2dbd88566abac030e965.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{deprecateWidget as i}from"../core/deprecate.js";import a from"../core/Logger.js";import{getOrCreateMapValue as n}from"../core/MapUtils.js";import{destroyMaybe as s}from"../core/maybe.js";import l from"../core/ReactiveMap.js";import{watch as o,when as r,on as c,sync as d}from"../core/reactiveUtils.js";import{formatFileSize as m}from"../core/unitFormatUtils.js";import{property as h,subclass as u}from"../core/accessorSupport/decorators.js";import{formatDate as p}from"../intl/date.js";import{isIntegerField as g}from"../layers/support/fieldUtils.js";import{isString as v}from"../support/guards.js";import b from"./Widget.js";import{getAttachmentTypeCategory as f,getCalciteIconForAttachment as _}from"./Attachments/support/attachmentUtils.js";import{getAttachmentKey as C,isImageAttachment as A,getAttachmentFilenameParts as y}from"./BatchAttributeForm/attachmentUtils.js";import{getHiddenFieldsValidationErrorMessage as w,getVisibleFieldInputValidationErrorMessage as I,isElementTemplateWithInputType as F,subtypeChangeShouldPrompt as k,flattenInputs as M}from"./BatchAttributeForm/batchAttributeFormUtils.js";import x from"./BatchAttributeForm/BatchAttributeFormViewModel.js";import{css as D}from"./BatchAttributeForm/css.js";import{makeViewingEditedAttachmentFooterButtons as S,makeViewingAttachmentFooterButtons as E,makeCancelFooterButton as L,makeDefaultFooterButtons as O}from"./BatchAttributeForm/interfaceUtils.js";import T from"./BatchAttributeForm/VisibleElements.js";import{isGroupInput as V,isFieldInput as R,isTextElementInput as N,isRelationshipElementInput as P,isAttachmentElementInput as U,isUtilityNetworkAssociationsElementInput as B,differentValuesString as $,getNormalizedFieldName as z,isGroupedInput as j}from"./BatchAttributeForm/inputs/support/inputUtils.js";import{clearMultipleChoiceOtherChoiceStateForViewModel as H,getMultipleChoiceCheckboxState as W,otherChoiceCheckedPlaceholderValue as Z,getUpdatedMultipleChoiceValueForFeature as G,getMultipleChoiceSelectAllState as q,splitMultipleChoiceValue as K,canRestoreMultipleChoiceOtherChoiceDraftValue as X}from"./BatchAttributeForm/inputs/support/multipleChoiceInputUtils.js";import{loadRelationshipDetailsComponents as J,RelationshipDetails as Q}from"./BatchAttributeForm/rendered-content/RelationshipDetails.js";import{Prompt as Y}from"./Editor/components/Prompt.js";import{downloadAttachmentInfo as ee}from"./FeatureTable/support/exportUtils.js";import{loadCalciteComponents as te}from"./support/componentsUtils.js";import{getLabelForDateFieldValue as ie,getIntlOptionsForField as ae,prepareISOFieldValueForDateComponents as ne,prepareUnixFieldValueForDateComponents as se,normalizeTimeOnlyString as le,getISOFieldValueFromDateComponents as oe,getUnixFieldValueFromDateComponents as re}from"./support/dateUtils.js";import{globalCss as ce}from"./support/globalCss.js";import{Heading as de}from"./support/Heading.js";import{calciteListFilterProps as me}from"./support/listUtils.js";import{messageBundle as he,vmEvent as ue,tsx as pe}from"./support/widget.js";import{setFocus as ge}from"./support/widgetUtils.js";import{isEmptyValue as ve}from"./support/forms/formUtils.js";const be="data-element-id",fe="data-field-name",_e="esri_BatchAttributeForm_select_all",Ce="esri_BatchAttributeForm_other_choice";let Ae=class extends b{constructor(e,t){super(e,t),this.headingLevel=2,this.messagesCommon=null,this.messages=null,this.featureFormMessages=null,this.featureTableMessages=null,this.messagesUnits=null,this.viewModel=new x,this.visibleElements=new T,this.groupDisplay="all",this._associationsList=null,this._associationsWidgetsMap=new l,this._attemptFocusOnNextRender=!1,this._dateComponentMap=new Map,this._touchedInputs=new Set,this._focusedFieldInput=null,this._pendingSubtypeChoice=null,this._batchSwitchInputInitialValues=new Map,this._listObserverNode=null,this._listObserver=new IntersectionObserver(e=>{e.length&&e[0].isIntersecting&&this.viewModel.activeRelationshipInput?.incrementPage()},{root:window.document}),this._attachmentDialogInfo=null,this._attachmentListFilterText="",this._attachmentFileInputMap=new Map,this._prompt=null,this._selectedAttachmentReplaceFileInput=null,this._afterListObserverCreated=e=>{this.viewModel.activeRelationshipInput&&(this._listObserverNode=e)},this._afterListObserverRemoved=()=>{this._listObserverNode=null},this._maximizeSelectedAttachment=()=>{this._attachmentDialogInfo=this.selectedAttachmentDetails},this._enterAttachmentReplaceView=()=>{const e=this.selectedAttachmentDetails;this._canReplaceSelectedAttachment()&&e&&(e.input.clearValidationCriteriaState(),this.viewModel.setShowingSelectedAttachmentReplacePage(!0))},this._setSelectedAttachmentReplaceFileInput=e=>{this._selectedAttachmentReplaceFileInput=e},this._openSelectedAttachmentReplaceFilePicker=()=>{this._canReplaceSelectedAttachment()&&this._selectedAttachmentReplaceFileInput?.click()},this._resetSelectedAttachmentName=()=>{const e=this.selectedAttachmentDetails;if(!e?.attachment)return;const t=e.input.getAttachmentEditState(e.attachment).initialName;if(null==t)return;const i=e.input.template.elementId,a=C(e.attachment);this.viewModel.stageRenameAttachment(i,a,t)},this._resetSelectedAttachmentChanges=()=>{const e=this.selectedAttachmentDetails;e?.attachment&&this.viewModel.resetAttachmentChanges(e.input.template.elementId,C(e.attachment))},this._deleteSelectedAttachment=()=>{const e=this.selectedAttachmentDetails;if(!e?.attachment||this._isSelectedAttachmentDeleteDisabled())return;const t=e.input.template.elementId,i=C(e.attachment);this.viewModel.stageDeleteAttachment(t,i),this._setSelectedAttachment(null)},this._closeAttachmentDialog=()=>{this.hideAttachmentDialog()},this._saveInputFromElement=this._saveInputFromElement.bind(this),this._onFormSubmit=this._onFormSubmit.bind(this),this._onComponentFocus=this._onComponentFocus.bind(this),this._onComponentBlur=this._onComponentBlur.bind(this),this._afterComponentCreateOrUpdate=this._afterComponentCreateOrUpdate.bind(this),this._afterDateComponentCreate=this._afterDateComponentCreate.bind(this),this._afterRadioGroupCreateOrUpdate=this._afterRadioGroupCreateOrUpdate.bind(this),e?.suppressDeprecationWarning||(this.announceDeprecation=()=>{i(a.getLogger(this),"Editor","arcgis-editor",{version:"5.0"})})}normalizeCtorArgs(e={}){const{suppressDeprecationWarning:t,...i}=e;return i}initialize(){this.addHandles([o(()=>this.features,()=>{this._dateComponentMap.clear(),H(this.viewModel,{includeDraftValues:!0})}),o(()=>this.viewModel.activeForm,()=>{this._batchSwitchInputInitialValues.clear(),this._resetTransientFormState(),H(this.viewModel),this._setFocusableInput()}),o(()=>this.viewModel.selectedAttachmentAddElementId,()=>{this.hideAttachmentDialog()}),r(()=>!this.selectedAttachmentDetails,()=>this.hideAttachmentDialog()),o(()=>this.viewModel.selectedAttachmentListElementId,()=>{this._attachmentListFilterText=""}),o(()=>[this.viewModel.activeRelationshipInput,this._listObserverNode],()=>this._onObserverChange()),c(()=>this.viewModel,"submit",()=>{this.valid||this.goToFirstError()}),o(()=>[this._associationsEnabled,this.viewModel.activeForm.allUtilityNetworkAssociationsElementInputs],()=>this._setUpAssociationsWidgets(),d),o(()=>this.viewModel.activeAssociationsInput,e=>this._onActiveAssociationsInputChange(e))])}loadDependencies(){return Promise.all([te({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),block:()=>import("@esri/calcite-components/dist/components/calcite-block"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),checkbox:()=>import("@esri/calcite-components/dist/components/calcite-checkbox"),chip:()=>import("@esri/calcite-components/dist/components/calcite-chip"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item"),"combobox-item-group":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item-group"),dialog:()=>import("@esri/calcite-components/dist/components/calcite-dialog"),dropdown:()=>import("@esri/calcite-components/dist/components/calcite-dropdown"),"dropdown-group":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-group"),"dropdown-item":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-item"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),input:()=>import("@esri/calcite-components/dist/components/calcite-input"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker"),"input-message":()=>import("@esri/calcite-components/dist/components/calcite-input-message"),"input-number":()=>import("@esri/calcite-components/dist/components/calcite-input-number"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker"),"input-time-zone":()=>import("@esri/calcite-components/dist/components/calcite-input-time-zone"),label:()=>import("@esri/calcite-components/dist/components/calcite-label"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch"),"text-area":()=>import("@esri/calcite-components/dist/components/calcite-text-area"),"radio-button":()=>import("@esri/calcite-components/dist/components/calcite-radio-button"),"radio-button-group":()=>import("@esri/calcite-components/dist/components/calcite-radio-button-group")}),J()])}destroy(){this._destroyAssociationsWidgets(),this._associationsList=s(this._associationsList),this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode)}get activeFeatureIndex(){return this.viewModel.activeFeatureIndex}set activeFeatureIndex(e){this.viewModel.activeFeatureIndex=e}get attachmentsEnabled(){return this.viewModel.attachmentsEnabled}set attachmentsEnabled(e){this.viewModel.attachmentsEnabled=e}get callbacks(){return this.viewModel.callbacks}set callbacks(e){this.viewModel.callbacks=e}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}get effectiveTitle(){const{features:e,messages:t,page:i}=this;return t?"replacing-attachment"===i?t.titles.replaceAttachment:"viewing-attachment-details"===i?t.titles.editAttachment:"adding-attachments"===i?t.titles.addAttachments:"viewing-attachments"===i?t.titles.attachments:1===e.length||this.activeFeatureIndex>-1?t.titles.editFeature:e.length>1?t.titles.editFeatures:"":""}get effectiveDisabled(){return this.disabled||this.readOnly||this.viewModel.updating}get features(){return this.viewModel.features}set features(e){this.viewModel.features=e}get footerButtonInfos(){if(!this.features.length||!this.messages||!this.messagesCommon)return[];const{messages:e,messagesCommon:t,page:i}=this,a=this.effectiveDisabled;if("adding-attachments"===i||"replacing-attachment"===i)return[];const n=this._getSelectedAttachmentEditState();if("viewing-attachment-details"===i){return!!n?.isRenamed||!!n?.isReplaced?S({doneOnclick:()=>this._setSelectedAttachment(null),messages:e.footerButtons,resetOnclick:this._resetSelectedAttachmentChanges}):E({deleteDisabled:this._isSelectedAttachmentDeleteDisabled(),deleteOnclick:this._deleteSelectedAttachment,doneOnclick:()=>this._setSelectedAttachment(null),messages:e.footerButtons})}return"viewing-associated-features"===i?L({messages:t,purpose:"cancel-viewing-associated-features",onclick:this.goBack}):"viewing-associated-layers"===i?L({messages:t,purpose:"cancel-viewing-associated-layers",onclick:this.goBack}):"viewing-attachments"===i||"viewing-related-records"===i?[]:O({disabled:a||!this.valid,formId:this._formId,messages:e,callback:this.submit})}get footerNoticeInfos(){if(!this.features.length||!this.messages)return[];const{messages:{footerNotices:e}}=this;return this._isSelectedAttachmentDeleteDisabled()?[{icon:"information",message:e.deleteDisabledMinimumAttachments}]:[]}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get maximumFeatureCount(){return this.viewModel.maximumFeatureCount}set maximumFeatureCount(e){this.viewModel.maximumFeatureCount=e}get maximumFeatureCountWithComplexForms(){return this.viewModel.maximumFeatureCountWithComplexForms}set maximumFeatureCountWithComplexForms(e){this.viewModel.maximumFeatureCountWithComplexForms=e}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=e}get layerInfos(){return this.viewModel.layerInfos}set layerInfos(e){this.viewModel.layerInfos=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get icon(){return"edit-attributes"}set icon(e){this._overrideIfSome("icon",e)}get page(){return this.viewModel.page}get readOnly(){return this.viewModel.readOnly}set readOnly(e){this.viewModel.readOnly=e}get showPrompt(){return e=>{this._prompt?.cancel?.(),this._prompt=e}}set showPrompt(e){this._overrideIfSome("showPrompt",e)}get clearPrompt(){return()=>this._prompt=null}set clearPrompt(e){this._overrideIfSome("clearPrompt",e)}get selectedAttachment(){return this.viewModel.selectedAttachment}get selectedAttachmentDetails(){return this.viewModel.selectedAttachmentDetails}get valid(){return this.viewModel.valid}get _formHeaderVisible(){return!("batch"===this.viewModel.mode||!this.viewModel.activeFeature)&&!(!this.viewModel.formDescription&&!this.viewModel.formTitle)}get _associationsEnabled(){const{callbacks:e}=this;return!(!e?.addAssociation&&!e?.editAssociatedFeature)}get _formId(){return`${this.id}-form`}get _relatedRecordsEnabled(){const{callbacks:e}=this;return!(!e||!e.addRelatedRecord&&!e.editRelatedRecord)}async goBack(){return this.viewModel.goBack()}async goHome(){return this.viewModel.goHome()}goToFirstError(){const e=this.viewModel.getFirstVisibleInvalidFieldInput();if(!e)return;const{groupInput:t}=e;t&&(t.open||(t.open=!0)),this._setFocusableInput(e.input),this.scheduleRender()}render(){return pe("div",{class:this.classes(D.base,ce.widget,ce.panel)},this._renderContent(),this._renderAttachmentDialog(),this._prompt?pe(Y,{...this._prompt,headingLevel:this.headingLevel}):void 0)}setActiveAssociationsInput(e){this.viewModel.setActiveAssociationsInput(e)}setActiveAssociationsLayer(e){this.viewModel.setActiveAssociationsLayer(e)}setActiveAssociationType(e){this.viewModel.setActiveAssociationType(e)}submit(){return this.viewModel.submit()}get test(){return{saveInput:this._saveInput.bind(this),pendingSubtypeChoice:this._pendingSubtypeChoice}}_setDateTimeTimeZoneMap(e){const{datePart:t,elementId:i}=e.dataset,a=n(this._dateComponentMap,`${i}`,()=>({}));switch(t){case"date":a.date=e;break;case"time":a.time=e;break;case"timeZone":a.timeZone=e}}_renderContent(){const{messages:e,viewModel:i}=this,{status:a}=i;return"failed"===a?i.hasTooManyComplexFeatures?this._renderErrorNotice(t(e.formFailedToLoadTooManyComplexFeatures,{num:i.maximumFeatureCountWithComplexForms})):i.hasTooManyFeatures?this._renderErrorNotice(t(e.formFailedToLoadTooManyFeatures,{num:i.maximumFeatureCount})):e.formFailedToLoad:i.expressionEvaluationFailed?this._renderErrorNotice(e.expressionEvaluationFailed):i.hasLayersWithContingentValues&&this.viewModel.features.length>1?this._renderErrorNotice(e.unsupportedContingentValues):"loading"===a&&this.visibleElements.loadingIndicator?pe("calcite-loader",{key:"loader",label:this.messagesCommon?.loading}):0!==this.features.length?this._renderForm():void 0}_renderErrorNotice(e,t="warning"){return pe("calcite-notice",{class:D.noticeError,icon:!0,kind:t,open:!0},pe("div",{slot:"message"},e))}_renderForm(){return pe("form",{class:D.form,id:this._formId,inert:!!this._prompt,onsubmit:this._onFormSubmit},this._renderInvisibleFieldsError(),this._renderPage())}_renderPage(){switch(this.page){case"adding-attachments":return this._renderAttachmentAddPage();case"viewing-attachment-details":case"replacing-attachment":return this._renderAttachmentDetailPage();case"viewing-attachments":return this._renderAttachmentListPage();case"viewing-associated-layers":case"viewing-associated-features":return this._renderViewingAssociationsPage();case"viewing-related-categories":case"viewing-related-records":return this._renderRelationshipListPage();default:return this._renderDefaultPage()}}_renderInvisibleFieldsError(){const{viewModel:e}=this,{hasNonActiveInvalidFeatures:t,activeForm:i}=e;let a;if(!e.submitHasBeenAttempted)return null;if(i.invalidHiddenInputs.length>0)if(a=w(i,e.mode,this.messages),"batch"===this.viewModel.mode){const e=i.invalidHiddenInputs.filter(e=>"hidden:group-visibility-expression:all-features"===e.effectiveVisibilityCode||"hidden:visibility-expression:all-features"===e.visibilityCode);e.length>0?a+=` (${e.map(e=>e.label).join(", ")})`:a=null}else a+=` (${i.invalidHiddenInputs.map(e=>e.label).join(", ")})`;else if(t)return null;return a?this._renderErrorNotice(a,"danger"):null}_renderDefaultPage(){return[this._renderReadOnlyNotice(),this._renderFormHeader(),this._renderFormContent()]}_renderReadOnlyNotice(){if((this.disabled||this.readOnly)&&this.visibleElements.readOnlyNotice)return pe("calcite-notice",{class:D.disabledNotice,icon:"read-only-non-editable",kind:"brand",open:!0,scale:"s",width:"full"},pe("div",{slot:"message"},this.featureFormMessages.disabledForm))}_renderFormHeader(){const{formTitle:e,formDescription:t}=this.viewModel;if(!this._formHeaderVisible)return;const i=e?pe(de,{key:"title",level:this.headingLevel},e):void 0,a=t?pe("p",{class:D.description,key:"description"},t):void 0;return pe("div",{class:D.formHeader},i,a)}_renderFormContent(){return this.viewModel.hasVisibleInputs?this.viewModel.activeForm.inputs.filter(e=>e.visible).map(e=>this._renderInput(e)):this._renderErrorNotice(this.messages.noVisibleFields[this.viewModel.noVisibleElementsReason])}_renderInput(e){return V(e)?this._renderGroupInput(e):R(e)?this._renderLabeledField(e):N(e)?this._renderTextComponent(e):P(e)?this._renderRelationshipElementInput(e):U(e)?this._renderAttachmentElementInput(e):B(e)?this._renderUtilityNetworkAssociationsElementInput(e):void 0}_renderGroupInput(e){const{inputs:t,template:i,open:a}=e,n=t.filter(e=>e.visible),s=e.label??"";return pe("calcite-block",{class:this.classes(D.group,"sequential"===this.groupDisplay?D.groupSequential:null,this.disabled?D.inputDisabled:null),collapsible:!0,description:e.description??void 0,disabled:this.effectiveDisabled,expanded:a,heading:s,headingLevel:this.headingLevel,key:`{${i.elementId}-key}`,label:s,onCalciteBlockClose:()=>{e.open=!1},onCalciteBlockOpen:()=>{e.open=!0},onCalciteBlockToggle:({currentTarget:t})=>this._onGroupToggle(t,e)},n.map(e=>this._renderInput(e)))}_renderLabeledField(e){const{elementId:i}=e.template,{label:a,required:n,dataType:s}=e,l=n?t(this.messages.requiredFieldLabel,{name:a}):a;return pe("calcite-label",{"aria-label":l,class:D.label,key:`field--${i}`},pe("div",{class:D.labelTextContent,key:"labelTextContainer"},a,n?pe("span",{"aria-hidden":"true",title:this.messagesCommon.required},"*"):void 0),"unsupported"!==s?this._renderFieldInput(e):this._renderReadOnlyComponent(e),this._renderAuxiliaryText(e))}_renderFieldInput(e){const t=this.getCommonInputProps(e),{dataType:i}=e;return"date"===i?this._renderDateComponents(e,t):"coded-value"===e.domain?.type?this._renderCodedInputs({input:e,props:t}):null!==e.multipleChoiceChoices?this._renderMultipleChoiceComponent({input:e,props:t}):"number"===i?this._renderNumberComponent(e,t):this._renderStringComponent(e,t)}_renderAuxiliaryText(e){const{description:t}=e,i=this._getErrorToDisplay(e),a=i?I(e,i,this.messages):null;return a?pe("calcite-input-message",{icon:!0,status:"invalid"},a):t?pe("calcite-input-message",{class:D.description,icon:!1,status:"idle"},t):null}_renderCodedInputs({input:e,props:t}){const i=e.input?.type??null,a=e.codedValueOptions;switch(i){case"switch":return this._renderSwitchField({input:e,props:t});case"radio-buttons":return this._renderRadioButtonGroupComponent({input:e,options:a,props:t});default:return this._renderComboBoxComponent({options:a,props:t,input:e})}}_renderMultipleChoiceComponent({input:e,props:t}){const{messages:i}=this,{multipleChoiceChoices:a,multipleChoiceInput:n,multipleChoiceValues:s}=e;if(!n||!a||!s)return null;const l=!0===n.includeSelectAllChoices,o=new Map;let r=s.length>0,c=!1;for(const b of s){const t=W({input:e,choiceValue:b});o.set(b,t),(t.checked||t.indeterminate)&&(c=!0),t.checked||(r=!1)}const d={checked:r,indeterminate:!r&&c},m=d.checked?i.deselectAllLabel:i.selectAllLabel,h=e.getMultipleChoiceOtherChoiceRenderState(this.messages.otherOptionLabel),u=t=>{this._saveValueFromMultipleChoiceCheckbox({input:e,checkbox:t,isSelectAllCheckbox:!0})},p=t=>{this._saveValueFromMultipleChoiceCheckbox({input:e,checkbox:t})},g=t=>{const{fieldName:i}=h;i&&this._saveOtherChoiceCheckboxValue({input:e,isChecked:t.checked,otherChoiceFieldName:i})},v=t=>{this._saveValueFromMultipleChoiceTextInput({input:e,textInput:t,otherChoiceFieldName:h.fieldName})};return pe("div",{class:D.multipleChoiceInput,key:`${t.key}-multiple-choice-group`},l?this._renderMultipleChoiceSelectAllCheckbox({props:t,selectAllState:d,selectAllLabel:m,handleSelectAllCheckboxChange:u}):null,this._renderMultipleChoiceChoiceCheckboxes({input:e,props:t,checkboxStatesByValue:o,handleChoiceCheckboxChange:p}),h.shouldShow?this._renderMultipleChoiceOtherChoice({props:t,includeSelectAllChoices:l,otherChoiceRenderState:h,handleOtherChoiceCheckboxChange:g,handleOtherChoiceInputChange:v,differentValuesPlaceholder:i.differentValuesPlaceholder}):null)}_renderMultipleChoiceSelectAllCheckbox({props:e,selectAllState:t,selectAllLabel:i,handleSelectAllCheckboxChange:a}){return pe("calcite-checkbox",{afterCreate:e.afterCreate,afterUpdate:e.afterUpdate,"aria-invalid":e["aria-invalid"],checked:t.checked,class:D.multipleChoiceSelectAll,"data-element-id":e[be],disabled:e.readOnly||e.disabled,indeterminate:t.indeterminate,key:`${e.key}-select-all`,label:i,labelText:i,value:_e,onblur:e.onblur,onCalciteCheckboxChange:({currentTarget:e})=>a(e),onfocus:e.onfocus})}_renderMultipleChoiceChoiceCheckboxes({input:e,props:t,checkboxStatesByValue:i,handleChoiceCheckboxChange:a}){const{multipleChoiceChoices:n}=e;return n?n.map(e=>{const n=i.get(e.value)??{checked:!1,indeterminate:!1};return pe("calcite-checkbox",{afterCreate:t.afterCreate,afterUpdate:t.afterUpdate,"aria-invalid":t["aria-invalid"],checked:n.checked,class:t.class,"data-element-id":t[be],disabled:t.readOnly||t.disabled,indeterminate:n.indeterminate,key:`${t.key}-${e.value}`,label:e.label,labelText:e.label,value:e.value,onblur:t.onblur,onCalciteCheckboxChange:({currentTarget:e})=>a(e),onfocus:t.onfocus})}):[]}_renderMultipleChoiceOtherChoice({props:e,includeSelectAllChoices:t,otherChoiceRenderState:i,handleOtherChoiceCheckboxChange:a,handleOtherChoiceInputChange:n,differentValuesPlaceholder:s}){return pe("div",{class:this.classes(D.multipleChoiceOtherChoice,t?D.multipleChoiceOtherChoiceWithSelectAll:null),key:`${e.key}-other-choice`},pe("calcite-checkbox",{afterCreate:e.afterCreate,afterUpdate:e.afterUpdate,"aria-invalid":e["aria-invalid"],checked:i.checkboxState.checked,class:e.class,"data-element-id":e[be],disabled:e.readOnly||e.disabled,indeterminate:i.checkboxState.indeterminate,key:`${e.key}-other-choice-checkbox`,label:i.label,labelText:i.label,value:Ce,onblur:e.onblur,onCalciteCheckboxChange:({currentTarget:e})=>a(e),onfocus:e.onfocus}),i.checkboxState.checked?pe("calcite-input",{afterCreate:e.afterCreate,afterUpdate:e.afterUpdate,"aria-invalid":e["aria-invalid"],"aria-label":i.label,class:D.textElementInput,"data-element-id":e[be],disabled:e.readOnly||e.disabled,key:`${e.key}-other-choice-input`,maxLength:i.maxLength,placeholder:i.value===$?s:i.hint,type:"text",value:i.normalizedValue===$?"":i.normalizedValue?String(i.normalizedValue):"",onblur:e.onblur,onCalciteInputInput:({currentTarget:e})=>n(e),onfocus:e.onfocus}):null)}async _saveValueFromMultipleChoiceCheckbox({input:e,checkbox:t,isSelectAllCheckbox:i=!1}){if(this._markFieldInputTouched(e),e.multipleChoiceInput&&!i&&"batch"===this.viewModel.mode)return void await this._saveMultipleChoiceCheckboxValueByFeature({input:e,checkbox:t});const a=e.value,n=this._parseValue(t,e,i);n!==a&&await this.viewModel.setValue(e.template.elementId,n)}async _saveValueFromMultipleChoiceTextInput({input:e,textInput:t,otherChoiceFieldName:i}){if(!i)return;const a=t.value,n=null==a||""===a?null:a;e.initializeExplicitMultipleChoiceOtherChoiceCheckedState(),e.stashMultipleChoiceOtherChoiceDraftValueForFeatures(e.features,n);const s=z(e,i);s&&await this.viewModel.setValueForFieldName(s,n,Array.from(e.features,e=>e.source))}async _saveOtherChoiceCheckboxValue({input:e,isChecked:t,otherChoiceFieldName:i}){e.setExplicitMultipleChoiceOtherChoiceCheckedState(t),this._markFieldInputTouched(e),t||e.setMultipleChoiceOtherChoiceDraftValuesFromFeatures(e.features.toArray());const a=z(e,i);if(!a)return;const n=new Map;for(const s of e.features){const a=s.getAttribute(i);if(t){if(!ve(a))continue;const t=e.getMultipleChoiceOtherChoiceDraftValue(s),i=X(t)?t:Z;n.set(s,i);continue}null!=a&&n.set(s,null)}0!==n.size&&await this.viewModel.setValuePerFeatureForFieldName(a,new Map(Array.from(n,([e,t])=>[e.source,t])))}async _saveMultipleChoiceCheckboxValueByFeature({input:e,checkbox:t}){if(!e.multipleChoiceInput||!e.multipleChoiceValues)return;const i=new Map(e.features.map(i=>[i,G({input:e,choiceValue:t.value,currentValue:i.getAttribute(e.fieldName),isChecked:t.checked})]));0!==i.size&&await this.viewModel.setFieldInputValuePerFeature(e,i)}_renderSwitchField({input:e,props:t}){if((this._batchSwitchInputInitialValues.get(e)===$||e.value===$)&&"batch"===this.viewModel.mode){const i={dropdown:{afterCreate:this._afterComponentCreateOrUpdate,afterUpdate:this._afterComponentCreateOrUpdate,disabled:t.readOnly,open:!1,[be]:t[be]},trigger:{appearance:"transparent",iconEnd:"chevron-down",kind:"neutral",slot:"trigger",label:t.label},group:{mode:"single"}};return this._renderDropdownComponent({buttonValue:e.value,dropdownProps:i,options:[{name:this.messages.differentValuesPlaceholder,value:$,disabled:!0},...e.codedValueDomainOptions]})}return this._renderSwitchComponent({input:e,props:t})}_renderSwitchComponent({input:e,props:t}){return pe("calcite-switch",{...t,checked:!!F(e.template,"switch")&&e.value===e.template.input.onValue,class:D.inputSwitch,disabled:t.readOnly,onblur:()=>{this._focusedFieldInput=null},onCalciteSwitchChange:({currentTarget:e})=>this._saveInputFromElement(e)})}_renderDropdownComponent({buttonValue:e,options:t,dropdownProps:i}){const{trigger:a,dropdown:n,group:s}=i;return pe("calcite-dropdown",{...n,topLayerDisabled:this.topLayerDisabled,onblur:()=>{this._focusedFieldInput=null},onCalciteDropdownSelect:({currentTarget:e})=>this._saveInputFromElement(e),onfocus:this._onComponentFocus},pe("calcite-button",{...a},e===$?this.messages.differentValuesPlaceholder:e),pe("calcite-dropdown-group",{selectionMode:s.mode},t.map(t=>pe("calcite-dropdown-item",{disabled:t.disabled,label:String(t.name),selected:e===t.value},t.name))))}_renderComboBoxComponent({input:e,options:t,props:i}){const a="INSERT"===this.viewModel.editType,n=this._touchedInputs.has(e?.template?.elementId),s=a&&e.showNoValueOptionEnabled&&!n?()=>{}:i.onblur,l={...i,onblur:s};return pe("calcite-combobox",{...l,clearDisabled:e.isSubtypeField,selectionMode:"single",topLayerDisabled:this.topLayerDisabled,value:i.placeholder===this.messages.differentValuesPlaceholder?$:String(i.value),onCalciteComboboxChange:({currentTarget:t})=>{t.value!==$&&(e.isSubtypeField&&0===t.selectedItems.length?t.value=`${e.value}`:this._saveInputFromElement(t))}},this.renderComboboxOptionsList({input:e,options:t,props:i}))}renderComboboxOptionsList({input:e,options:t,props:i}){const a=e=>e.map(e=>{const{value:t}=e,a=ve(e.value)?this.messages.empty:e.name;return pe("calcite-combobox-item",{heading:a,key:`#${t}`,selected:i.value===t,value:`${t}`})});let n=[];const{messages:s}=this;t.other.length>0&&n.push(pe("calcite-combobox-item-group",{key:"other",label:s.other},a(t.other))),t.unsupported.length>0&&n.push(pe("calcite-combobox-item-group",{key:"unsupported",label:s.unsupported},a(t.unsupported)));const l=a(t.recommended);n.length>0?n.unshift(pe("calcite-combobox-item-group",{key:"recommended",label:s.recommended},l)):n=l;const o=i.placeholder===this.messages.differentValuesPlaceholder,r=!o&&ve(i.value);return e.showNoValueOptionEnabled&&!t.containsEmptyOption&&n.unshift(pe("calcite-combobox-item",{heading:e.showNoValueLabel||this.messages.empty,key:"empty-option",selected:r,value:""})),o&&n.unshift(pe("calcite-combobox-item",{heading:this.messages.differentValuesPlaceholder,key:$,selected:!0,value:$})),n}_renderRadioButtonGroupComponent({input:e,options:t,props:i}){const a=[...t.recommended,...t.other,...t.unsupported].map(({name:t,value:a})=>this._renderRadioButtons({label:t,value:a,selected:a===e.value,props:i}));if(e.showNoValueOptionEnabled&&!t.containsEmptyOption){const t="",n=e.showNoValueLabel||this.messages.empty,s=ve(e.value);a.unshift(this._renderRadioButtons({label:n,value:t,selected:s,props:i}))}return pe("calcite-radio-button-group",{afterCreate:this._afterRadioGroupCreateOrUpdate,afterUpdate:this._afterRadioGroupCreateOrUpdate,class:D.inputRadioGroup,"data-field-name":i[fe],disabled:i.readOnly||i.disabled,key:`${i.key}-radio-group`,layout:"vertical",name:i.name,required:i.required},a,i.placeholder===this.messages.differentValuesPlaceholder?pe("calcite-label",{class:D.placeholderRadio,key:i.label,layout:"inline"},pe("calcite-radio-button",{checked:!0,class:D.inputRadio,disabled:!0,name:i.placeholder,value:i.placeholder}),i.placeholder):null)}_renderRadioButtons({value:e,selected:t,label:i,props:a}){return pe("calcite-label",{class:D.inputRadioLabel,key:a.label,layout:"inline"},pe("calcite-radio-button",{...a,afterCreate:void 0,afterUpdate:void 0,checked:t,class:D.inputRadio,disabled:a.readOnly||a.disabled,name:a.label,value:e,onblur:()=>{this._focusedFieldInput=null},onCalciteRadioButtonChange:({currentTarget:e})=>{e.checked&&this._saveInputFromElement(e)}}),i)}_renderStringComponent(e,t){const{template:i}=e;return!i.field.editable||this.readOnly?this._renderReadOnlyComponent(e):"text-area"===i.input?.type?pe("calcite-text-area",{...t,class:this.classes(D.individualElement),resize:"vertical",value:t.value?String(t.value):"",onCalciteTextAreaInput:({currentTarget:e})=>this._saveInputFromElement(e)}):pe("calcite-input",{...t,class:this.classes(D.individualElement),type:"text",value:t.value?String(t.value):"",onCalciteInputInput:({currentTarget:e})=>this._saveInputFromElement(e)})}_renderNumberComponent(e,t){const i=g(e.field);return pe("calcite-input-number",{...t,integer:i,type:"number",value:i&&""!==t.value?Math.round(parseFloat(String(t.value))).toString():String(t.value),onCalciteInputNumberInput:({currentTarget:e})=>this._saveInputFromElement(e)})}_renderReadOnlyComponent(e,t){const i=this.getCommonInputProps(e);return pe("calcite-input",{...i,class:this.classes(D.fieldInput,D.inputDisabled,D.individualElement),readOnly:!0,type:"text",value:String(t??i.value??"")})}_renderDateComponents(e,t){const{field:i}=e;let a;switch(i.type){case"date":a=this._renderDateFieldComponents(e,t);break;case"date-only":a=this._renderDateOnlyFieldComponent(e,t);break;case"time-only":a=this._renderTimeOnlyFieldComponent(e,t);break;case"timestamp-offset":a=this._renderTimestampOffsetFieldComponents(e,t);break;default:a=this._renderReadOnlyComponent(e,ie(i,t.value,{timeZone:e.effectiveTimeZone,...ae(e.template.field)}))}return e.value===$?[a,pe("calcite-input-message",{icon:"information",key:"diff-values-message",status:"idle"},this.messages.differentValues)]:a}_renderDateOnlyFieldComponent(e,t){const{class:i,disabled:a,key:n,readOnly:s}=t,{rawMax:l,rawMin:o}=e.range;return pe("calcite-input-date-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,class:i,"data-date-part":"date","data-element-id":t[be],"data-field-name":t[fe],key:`${n}-date-input`,max:v(l)?l:void 0,min:v(o)?o:void 0,overlayPositioning:"fixed",readOnly:s||a,topLayerDisabled:this.topLayerDisabled,value:e.value===$?"":e.value?String(e.value):"",onblur:()=>{this._focusedFieldInput=null},onCalciteInputDatePickerChange:t=>this._saveValueFromDateComponent(e,t.currentTarget),onfocus:this._onComponentFocus})}_renderTimeOnlyFieldComponent(e,t){const{class:i,disabled:a,key:n,readOnly:s}=t;return pe("calcite-input-time-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,class:i,"data-date-part":"time","data-element-id":t[be],"data-field-name":t[fe],key:`${n}-time-input`,overlayPositioning:"fixed",readOnly:s||a,value:e.value===$?"":e.value?String(e.value):"",onblur:()=>{this._focusedFieldInput=null},onCalciteInputTimePickerChange:t=>this._saveValueFromDateComponent(e,t.currentTarget),onfocus:this._onComponentFocus})}_renderTimestampOffsetFieldComponents(e,t){const{class:i,disabled:a,key:n,readOnly:s}=t,{rawMax:l,rawMin:o}=e.range,r=ne(l),c=ne(o),d=ne(e.value===$?"":e.value),m=e.includeTimeOffset,h={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,overlayPositioning:"fixed",readOnly:s||a,[be]:t[be],[fe]:t[fe],onfocus:this._onComponentFocus};return pe("div",{class:D.dateInputContainer,key:`${n}-date-time-container`},pe("calcite-input-date-picker",{...h,class:i,"data-date-part":"date",key:`${n}-date-input`,max:r?.date??void 0,min:c?.date??void 0,topLayerDisabled:this.topLayerDisabled,value:d.date??"",onblur:()=>{this._focusedFieldInput=null},onCalciteInputDatePickerChange:t=>this._saveValueFromDateComponent(e,t.target)}),pe("calcite-input-time-picker",{...h,class:i,"data-date-part":"time",key:`${n}-time-input`,value:d.time??"",onblur:()=>{this._focusedFieldInput=null},onCalciteInputTimePickerChange:t=>this._saveValueFromDateComponent(e,t.target)}),m?pe("calcite-input-time-zone",{...h,class:i,clearable:e.value===$||null==e.value,"data-date-part":"timeZone",key:`${n}-timezone-input`,value:d.timeZoneOffset||"",onblur:()=>{this._focusedFieldInput=null},onCalciteInputTimeZoneChange:t=>this._saveValueFromDateComponent(e,t.target)}):null)}_renderDateFieldComponents(e,t){const{class:i,disabled:a,key:n,readOnly:s,min:l,max:o}=t,r=e.effectiveTimeZone,c=se(e.value===$?"":e.value,r),d=se(o,r),m=se(l,r),h=e.includeTime,u={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,overlayPositioning:"fixed",readOnly:s||a,[be]:t[be],[fe]:t[fe],onfocus:this._onComponentFocus};return pe("div",{class:D.dateInputContainer,key:`${n}-date-time-container`},pe("calcite-input-date-picker",{...u,class:i,"data-date-part":"date",key:`${n}-date-input`,max:d?.date??void 0,min:m?.date??void 0,topLayerDisabled:this.topLayerDisabled,value:c.date??"",onblur:()=>{this._focusedFieldInput=null},onCalciteInputDatePickerChange:t=>this._saveValueFromDateComponent(e,t.target)}),h?pe("calcite-input-time-picker",{...u,"data-date-part":"time",key:`${n}-time-input`,step:1,value:c.time??"",onblur:()=>{this._focusedFieldInput=null},onCalciteInputTimePickerChange:t=>{this._saveValueFromDateComponent(e,t.target)}}):null)}_renderRelationshipElementInput(e){return this._relatedRecordsEnabled?pe(Q,{afterObserverCreated:this._afterListObserverCreated,afterObserverRemoved:this._afterListObserverRemoved,input:e,messages:this.messages,messagesCommon:this.messagesCommon,viewModel:this.viewModel}):null}_renderRelationshipListPage(){const{activeRelationshipInput:e}=this.viewModel;if(e)return this._renderRelationshipElementInput(e)}_renderAttachmentElementInput(e){if(!this.attachmentsEnabled)return;const{allAttachmentsVisibleOnDefaultPage:t,attachments:i,defaultPageAttachments:a,template:{description:n,elementId:s,label:l}}=e,o=t?i:a;return pe("div",{class:D.attachmentElementInput,"data-testid":`attachment-element-${s}`,key:`attachment-element-${s}`},l?pe("div",{class:D.attachmentElementLabel,key:`attachment-element-label-${s}`},l):null,n?pe("div",{class:D.description,key:`attachment-element-description-${s}`},n):null,i.length?this._renderAttachmentList(e,o,{label:l||this.messagesCommon.details,viewAllCount:t?null:i.length}):pe("div",{class:D.attachmentElementEmptyState,key:`attachment-element-empty-state-${s}`},this.messages.attachments.noAttachments),this._renderAttachmentAddAction(e))}_renderAttachmentListPage(){const e=this.viewModel.selectedAttachmentListInput;if(e)return pe("div",{class:D.attachmentElementAllPanel,key:`attachment-element-all-panel-${e.template.elementId}`},this._renderAttachmentList(e,e.attachments,{filterEnabled:!0,label:this.messages.titles.attachments}))}_renderAttachmentList(e,t,i){const{filterEnabled:a,label:n,viewAllCount:s}=i;return pe("calcite-list",{class:D.attachmentElementList,filterEnabled:a,filterPlaceholder:a?this.messages.attachments.searchAttachments:void 0,filterProps:a?me:void 0,filterText:a?this._attachmentListFilterText:void 0,label:n,selectionAppearance:"border",selectionMode:"none",onCalciteListFilter:a?e=>{this._attachmentListFilterText=e.currentTarget.filterText??""}:void 0},this._renderAttachmentListItems(e,t),null!=s?this._renderViewAllAttachmentsItem(e,s):null)}_renderAttachmentListItems(e,t){const{elementId:i}=e.template;return t.map((t,a)=>{const n=this._formatAttachmentSize(t.size),s=this._getAttachmentLabel(t,a,n,e.displayFilename),l=s===n?void 0:n,o=C(t),r=e.isStagedAttachmentAddition(t),c=e.getAttachmentEditState(t),d=c.isDeleted,m=!d&&(r||c.isRenamed||c.isReplaced);return pe("calcite-list-item",{class:D.attachmentElementListItem,description:l,key:`attachment-item-${o}`,label:s,onCalciteListItemSelect:r||d?void 0:()=>this._setSelectedAttachment({attachmentKey:o,elementId:i})},pe("div",{class:D.attachmentElementListItemStart,slot:"content-start"},this._renderAttachmentPreviewThumbnail(t,s,e)),m?pe("span",{class:D.attachmentElementListItemStagedIndicator,slot:"content-end"}):null,r?[pe("calcite-action",{disabled:this.effectiveDisabled,icon:"x",scale:"s",slot:"actions-end",text:this.messagesCommon.delete,title:this.messagesCommon.delete,onclick:()=>this.viewModel.stageDeleteAttachment(i,C(t))})]:d?pe("calcite-chip",{label:this.messages.attachments.deleted,scale:"s",slot:"content-end"},this.messages.attachments.deleted):pe("calcite-icon",{flipRtl:!0,icon:"chevron-right",scale:"s",slot:"content-end"}))})}_renderViewAllAttachmentsItem(e,i){const{elementId:a}=e.template,{viewAll:n}=this.messages.attachments;return pe("calcite-list-item",{class:D.attachmentElementListItem,description:t(this.messages.attachments.count,{count:i}),key:`attachment-item-view-all-${a}`,label:n,onCalciteListItemSelect:()=>this._setAttachmentListElementId(a)},pe("calcite-icon",{flipRtl:!0,icon:"chevron-right",scale:"s",slot:"content-end"}))}_renderAttachmentAddAction(e){const{elementId:t}=e.template,i=this.effectiveDisabled||e.addDisabled,a=this._renderAttachmentCountLimitsLabel(e),n=this._getAttachmentNoticeMessage(e),s=e.hasMinimumAttachmentCountNotMet||e.hasExceededAttachmentLimit?"danger":"info",l=e.canUploadFiles,o=e.isCaptureOnly&&!this.effectiveDisabled&&!n;return pe("div",{class:D.attachmentElementAddActions,key:`attachment-element-add-actions-${t}`},l?pe("calcite-button",{appearance:"outline",disabled:i,iconStart:"attachment",kind:"neutral",round:!0,scale:"s",onclick:()=>this._setAttachmentAddElementId(t)},this.messages.attachments.attach):null,this._renderAttachmentCaptureButton(e),o?this._renderAttachmentCaptureDisabledNotice(t):null,a?pe("div",{class:D.attachmentElementEmptyActionHint},a):null,!this.effectiveDisabled&&n?pe("calcite-notice",{closable:!1,icon:"danger"===s?"exclamation-mark-circle":"lightbulb",kind:s,open:!0,scale:"s",width:"full"},pe("div",{slot:"message"},n)):null)}_renderAttachmentCaptureButton(e){if(!e.hasCaptureInputs)return null;const t=e.captureMediaType;return pe("calcite-button",{appearance:"outline",disabled:!0,iconStart:ye(t),kind:"neutral",round:!0,scale:"s"},this._getCaptureButtonLabel(t))}_getAttachmentNoticeMessage(e){const t=this.messages.attachments;return e.hasUnsupportedFileTypeValidationError?this._getUnsupportedFileTypeMessage():e.hasMinimumAttachmentCountNotMet&&this._shouldShowMinimumAttachmentNotice(e)?t.minimumNotMet:e.hasExceededAttachmentLimit?t.attachmentLimitExceeded:e.hasReachedAttachmentLimit?t.attachmentLimitReached:null}_shouldShowMinimumAttachmentNotice(e){return e.hasAttachmentChanges||this.viewModel.submitHasBeenAttempted||this._touchedInputs.has(e.template.elementId)}_getCaptureButtonLabel(e){const{capture:t,recordAudio:i,takePhoto:a,takeVideo:n}=this.messages.attachments;switch(e){case"image":return a||t;case"video":return n||t;case"audio":return i||t;default:return t}}_renderAttachmentAddPage(){const e=this.viewModel.selectedAttachmentAddInput;return e?this._renderAttachmentAddPanel(e):null}_renderAttachmentAddPanel(e){const{maxAttachmentCount:t}=e,{elementId:i}=e.template;if(e.isCaptureOnly)return this._renderAttachmentCaptureDisabledNotice(i);const a=null==t||t-e.attachments.length>1,n=this.effectiveDisabled||e.addDisabled,s=this.messages.attachments,l=s.dragAndDropFile,o="upload",r=e=>{this._attachmentFileInputMap.set(i,e)};return pe("div",{class:D.attachmentElementAddPanel,key:`attachment-element-add-panel-${i}`},pe("input",{accept:e.accept,afterCreate:r,afterRemoved:()=>{this._attachmentFileInputMap.delete(i)},afterUpdate:r,class:D.attachmentElementFileInput,"data-element-id":i,disabled:n,multiple:a,type:"file",onchange:e=>{const t=e.currentTarget,a=t.files?Array.from(t.files):[];this._stageAttachmentFiles(i,a),t.value=""}}),pe("div",{class:D.attachmentElementAddDropzone,"data-disabled":n?"true":"false",ondragover:e=>{e.preventDefault()},ondrop:e=>{if(e.preventDefault(),n)return;const t=e.dataTransfer?.files?Array.from(e.dataTransfer.files):[];this._stageAttachmentFiles(i,t)}},pe("calcite-icon",{class:D.attachmentElementAddDropzoneIcon,icon:o,scale:"l"}),pe("div",{class:D.attachmentElementAddDropzoneHeading},s.addFile),pe("div",{class:D.attachmentElementAddDropzoneDetail,title:l},l),pe("calcite-button",{appearance:"transparent",disabled:n,iconStart:"folder-open",kind:"brand",scale:"s",type:"button",onclick:e=>{e.stopPropagation(),this._openAttachmentFilePicker(i,n)}},s.selectFile)),this._renderAttachmentValidationCriteria(e,{includeCountCriteria:!0}))}_renderAttachmentCaptureDisabledNotice(e){return pe("calcite-notice",{class:D.attachmentElementCaptureNotice,icon:!0,key:`attachment-element-capture-disabled-notice-${e}`,kind:"warning",open:!0,scale:"s"},pe("div",{slot:"message"},this.messages.attachments.captureMethodNotSupported))}async _stageAttachmentFiles(e,t){if(0===t.length)return;const i=this.viewModel.selectedAttachmentAddInput;let a=!0;try{a=(await this.viewModel.stageAddAttachments(e,t)).length>0&&!i?.hasInvalidValidationCriteria&&!i?.hasUnsupportedFileTypeValidationError}finally{a&&this.viewModel.setSelectedAttachmentAddElementId(null)}}_openAttachmentFilePicker(e,t){t||this._attachmentFileInputMap.get(e)?.click()}_renderAttachmentDetailPage(){const e=this.selectedAttachmentDetails;if(!e)return;if("replacing-attachment"===this.page)return this._renderAttachmentReplacePanel(e);const{attachment:t,input:i}=e,a=C(t),n=!!i.getAttachmentPreviewUrl(t),s=!this.effectiveDisabled&&i.canUploadFiles;return pe("div",{class:D.attachmentElementDetail,key:`attachment-detail-panel-${i.template.elementId}-${a}`},pe("div",{class:D.attachmentElementDetailPreview},this._renderAttachmentPreviewImageForInput(t,i)),pe("div",{class:D.attachmentElementDetailActions},A(t)?pe("calcite-button",{appearance:"outline",disabled:!n,iconStart:"expand",kind:"neutral",label:this.messages.attachments.maximize,scale:"m",title:this.messages.attachments.maximize,onclick:this._maximizeSelectedAttachment}):null,pe("calcite-button",{appearance:"outline",disabled:!n,iconStart:"download",kind:"neutral",label:this.messages.attachments.download,scale:"m",title:this.messages.attachments.download,onclick:()=>{this._downloadAttachment(t)}}),pe("calcite-button",{appearance:"outline",disabled:!s,iconStart:"upload-to",kind:"neutral",label:this.messages.attachments.replace,scale:"m",title:this.messages.attachments.replace,onclick:this._enterAttachmentReplaceView})),pe("div",{class:D.attachmentElementDetailMetadata},pe("div",{class:D.attachmentElementDetailMetadataGroup},pe("span",{class:D.attachmentElementDetailMetadataLabel},this.messages.attachments.fileName),this._renderFileNameContent(t,i)),pe("div",{class:D.attachmentElementDetailMetadataGroup},pe("span",{class:D.attachmentElementDetailMetadataLabel},this.messages.attachments.size),pe("span",{class:D.attachmentElementDetailMetadataValue},this._formatAttachmentSize(t.size))),pe("div",{class:D.attachmentElementDetailMetadataGroup},pe("span",{class:D.attachmentElementDetailMetadataLabel},this.messages.attachments.type),pe("span",{class:D.attachmentElementDetailMetadataValue},this._getLabelForAttachmentType(t)))))}_renderFileNameContent(e,t){if(!t.allowUserRename)return pe("span",{class:D.attachmentElementDetailMetadataValue},e.name);const i=t.getAttachmentEditState(e),{baseName:a,extension:n}=y(e.name),s=this.disabled||this.readOnly,l=!s&&0===e.name.trim().length;return[pe("div",{class:D.attachmentElementDetailFileNameRow,key:"file-name-row"},pe("calcite-input",{class:D.attachmentElementDetailFileNameInput,disabled:s,scale:"m",status:l?"invalid":"idle",suffixText:n,value:a,onCalciteInputInput:({currentTarget:e})=>this._renameSelectedAttachment(e.value)}),pe("calcite-button",{appearance:"transparent",disabled:s||null==i.initialName||!i.isRenamed,iconStart:"reset",kind:"neutral",scale:"m",title:this.messages.footerButtons.reset,onclick:this._resetSelectedAttachmentName})),l?pe("calcite-input-message",{icon:!0,key:"file-name-message",status:"invalid"},this.messages.validationErrors.cannotBeNull):null]}_renderAttachmentReplacePanel(e){const{attachment:t,input:i}=e,a=this.effectiveDisabled||!i.canUploadFiles,n=i.template.elementId;return pe("div",{class:D.attachmentElementAddPanel,key:`attachment-replace-panel-${n}-${C(t)}`},pe("input",{accept:i.accept,afterCreate:this._setSelectedAttachmentReplaceFileInput,afterRemoved:()=>{this._selectedAttachmentReplaceFileInput=null},afterUpdate:this._setSelectedAttachmentReplaceFileInput,class:D.attachmentElementFileInput,disabled:a,type:"file",onchange:e=>{const t=e.currentTarget,i=t.files?.[0];i&&this._stageSelectedAttachmentReplacement(i),t.value=""}}),pe("div",{class:D.attachmentElementAddDropzone,"data-disabled":a?"true":"false",ondragover:e=>{e.preventDefault()},ondrop:e=>{if(e.preventDefault(),a)return;const t=e.dataTransfer?.files?.[0];t&&this._stageSelectedAttachmentReplacement(t)}},pe("calcite-icon",{class:D.attachmentElementAddDropzoneIcon,icon:"refresh",scale:"l"}),pe("div",{class:D.attachmentElementAddDropzoneHeading},this.messages.attachments.replace),pe("div",{class:D.attachmentElementAddDropzoneDetail,title:this.messages.attachments.dragAndDropFile},this.messages.attachments.dragAndDropFile),pe("calcite-button",{appearance:"transparent",disabled:a,iconStart:"folder-open",kind:"brand",scale:"s",onclick:e=>{e.stopPropagation(),this._openSelectedAttachmentReplaceFilePicker()}},this.messages.attachments.selectFile)),this._renderAttachmentValidationCriteria(i,{includeCountCriteria:!1}),pe("div",{class:D.attachmentElementDetailMetadata},pe("div",{class:D.attachmentElementDetailMetadataGroup},pe("span",{class:D.attachmentElementDetailMetadataLabel},this.messages.attachments.fileToBeReplaced),pe("span",{class:D.attachmentElementDetailMetadataValue},t.name))))}_renderAttachmentDialog(){const e=this._attachmentDialogInfo;if(!e)return null;const{attachment:t,input:i}=e;return pe("calcite-dialog",{heading:t.name||this.messagesCommon.details,key:"attachment-preview-dialog",modal:!0,open:!0,placement:"cover",width:"l",onCalciteDialogClose:this._closeAttachmentDialog},pe("div",{class:D.attachmentElementDetailPreview},this._renderAttachmentPreviewImageForInput(t,i)))}_setSelectedAttachment(e){e?.elementId&&this._touchedInputs.add(e.elementId),this.viewModel.setSelectedAttachment(e),e||this.hideAttachmentDialog()}_setAttachmentAddElementId(e){e&&this._touchedInputs.add(e),this.viewModel.setSelectedAttachmentAddElementId(e),this.viewModel.selectedAttachmentAddInput?.clearValidationCriteriaState(),this.hideAttachmentDialog()}_setAttachmentListElementId(e){e&&this._touchedInputs.add(e),this.viewModel.setSelectedAttachmentListElementId(e),this.hideAttachmentDialog()}_getAttachmentLabel(e,i,a,n){return!1!==n&&v(e.name)&&e.name.length>0?e.name:a!==this.messagesCommon.notApplicable?a:t(this.messages.attachments.attachmentNumberedLabel,{index:i+1})}_renderAttachmentCountLimitsLabel(e){const t=this.messages.attachments,i=null!=e.minAttachmentCount&&e.minAttachmentCount>0?this._renderAttachmentCountLimitLabel(t.minAttachmentsShort,e.minAttachmentCount,"min"):null,a=null!=e.maxAttachmentCount?this._renderAttachmentCountLimitLabel(t.maxAttachmentsShort,e.maxAttachmentCount,"max"):null;return i||a?[i,i&&a?pe("span",{key:"attachment-count-limits-separator"},", "):null,a]:null}_renderAttachmentCountLimitLabel(e,i,a){const n="__count__",[s,l]=t(e,{count:n}).split(n);return pe("span",{key:a},s,pe("span",{class:D.attachmentElementEmptyActionHintValue},i),l)}_renderAttachmentValidationCriteria(e,{includeCountCriteria:t}){const i=this._getAttachmentValidationCriteria(e,{includeCountCriteria:t}),a=`attachment-validation-criteria-${e.template.elementId}`;return 0===i.length?null:pe("div",{class:D.attachmentElementValidationCriteria,key:a},i.map(({key:e,message:t,state:i})=>pe("calcite-notice",{appearance:"danger"===i?"outline-fill":"transparent",closable:!1,icon:!0,key:e,kind:i,open:!0,scale:"s",width:"full"},pe("div",{slot:"message"},t))))}_getAttachmentValidationCriteria(e,{includeCountCriteria:i}){const a=[],n=e.validationCriterionStates,s=this.messages.attachments,l=this._getNestableAttachmentInputs(e.input);e.hasUnsupportedFileTypeValidationError&&a.push({key:"unsupported-file-type",message:this._getUnsupportedFileTypeMessage(),state:"danger"});for(const o of l)"document"===o.type&&null!=o.maxFileSize&&a.push({key:"maximum-file-size",message:t(s.maximumFileSize,{maxSize:this._formatAttachmentSizeLimitInMegabytes(o.maxFileSize)}),state:n.get("maximum-file-size")??"info"}),"audio"===o.type&&null!=o.maxDuration&&a.push({key:"maximum-audio-length",message:t(s.maximumAudioLength,{maxDuration:this._formatAttachmentDurationLimit(o.maxDuration)}),state:n.get("maximum-audio-length")??"info"}),"video"===o.type&&null!=o.maxDuration&&a.push({key:"maximum-video-length",message:t(s.maximumVideoLength,{maxDuration:this._formatAttachmentDurationLimit(o.maxDuration)}),state:n.get("maximum-video-length")??"info"}),"image"===o.type&&null!=o.maxImageSize&&a.push({key:"maximum-image-size",message:t(s.attachmentMustBeSmallerThan,{maxSize:`${o.maxImageSize}px`}),state:n.get("maximum-image-size")??"info"});return i&&null!=e.minAttachmentCount&&e.minAttachmentCount>0&&a.push({key:"minimum-number-of-files",message:t(s.minimumNumberOfFiles,{count:e.minAttachmentCount}),state:n.get("minimum-number-of-files")??"info"}),i&&null!=e.maxAttachmentCount&&a.push({key:"maximum-number-of-files",message:t(s.maximumNumberOfFiles,{count:e.maxAttachmentCount}),state:n.get("maximum-number-of-files")??"info"}),a}_getNestableAttachmentInputs(e){return null==e?[]:"attachment"===e.type?e.inputTypes?.slice()??[]:[e]}_getUnsupportedFileTypeMessage(){return this.featureTableMessages.errorFileUnsupported}_formatAttachmentSize(e){return null==e||Number.isNaN(e)?this.messagesCommon.notApplicable:m(this.messagesUnits,e)}_formatAttachmentSizeLimitInMegabytes(e){return m(this.messagesUnits,1048576*e)}_formatAttachmentDurationLimit(e){return p(1e3*Math.round(e),{...e>=3600?{hour:"2-digit",hourCycle:"h23"}:{},minute:"2-digit",second:"2-digit",timeZone:"UTC"})}_getLabelForAttachmentType({contentType:e}){if(!e)return this.messagesCommon.notApplicable;const t=this.messages.attachments.attachmentTypes,i=f(e);return t?.[i]||e}_renderAttachmentPreviewThumbnail(e,t,i){const a=i.getAttachmentPreviewUrl(e,64);return a&&A(e)?pe("img",{alt:t,class:D.attachmentElementListItemThumb,src:a}):pe("calcite-icon",{class:D.attachmentElementListItemIcon,icon:_(e.contentType),scale:"s"})}_renderAttachmentPreviewImageForInput(e,t){const i=t.getAttachmentPreviewUrl(e),a=e.name||this.messagesCommon.details;return i&&A(e)?pe("img",{alt:a,class:D.attachmentElementDetailPreviewImage,src:i,title:a}):[pe("calcite-icon",{class:D.attachmentElementDetailPreviewIcon,icon:_(e.contentType),scale:"l",textLabel:a,title:a}),this.messages.attachments.noPreviewAvailable]}async _downloadAttachment(e){await ee(e)}_canReplaceSelectedAttachment(){return!this.effectiveDisabled&&!!this.selectedAttachmentDetails?.input.canUploadFiles}_exitAttachmentReplaceView(){this.viewModel.setShowingSelectedAttachmentReplacePage(!1),this._selectedAttachmentReplaceFileInput=null}async _stageSelectedAttachmentReplacement(e){const t=this.selectedAttachmentDetails;if(!t?.attachment)return;const i=t.input.template.elementId,a=C(t.attachment);let n=!1;try{n=await this.viewModel.stageReplaceAttachment(i,a,e)}finally{n&&this._exitAttachmentReplaceView()}}_renameSelectedAttachment(e){const t=this.selectedAttachmentDetails;if(!t?.attachment)return;const i=t.input.template.elementId,a=C(t.attachment);this.viewModel.stageRenameAttachment(i,a,e)}_isSelectedAttachmentDeleteDisabled(){const e=this.selectedAttachmentDetails;if(!e)return!1;if(this.effectiveDisabled)return!0;const t=e.input.minAttachmentCount;return null!=t&&e.input.attachments.length<=t}hideAttachmentDialog(){this._attachmentDialogInfo=null}_renderTextComponent(e){const{elementId:t}=e.template;return pe("div",{class:D.textElementInput,"data-testid":`text-element-${t}`,innerHTML:e.text,key:`text-element-${t}`})}_renderUtilityNetworkAssociationsElementInput(e){if(!this._associationsEnabled)return;const{elementId:t}=e.template;return pe("div",{class:D.utilityNetworkAssociationsElementInput,"data-testid":t,key:t},this._associationsWidgetsMap.get(e)?.render())}getCommonInputProps(e){const{template:t,valid:i,value:a,minLength:n,maxLength:s,required:l,fieldName:o,editable:r,userHasChangedValue:c,range:{max:d,min:m}}=e,h=!r||this.readOnly,u=!h&&(this.disabled||this.viewModel.updating);let p=t.hint??void 0,g=!1;return a===$&&(p=this.messages.differentValuesPlaceholder,g=!0),{afterCreate:this._afterComponentCreateOrUpdate,afterUpdate:this._afterComponentCreateOrUpdate,"aria-invalid":i?"false":"true",class:this.classes(D.fieldInput,h?D.inputDisabled:null),status:!c&&!this.viewModel.submitHasBeenAttempted||i?"idle":"invalid",maxLength:s&&s>-1?s:void 0,minLength:n&&n>-1?n:void 0,key:t.elementId,label:o,name:o,max:null!=d?d:void 0,min:null!=m?m:void 0,disabled:u,readOnly:h,onblur:this._onComponentBlur,required:l,placeholder:p,value:g?"":a??"",[be]:t.elementId,[fe]:o,onfocus:this._onComponentFocus}}_onObserverChange(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode);const e=this.viewModel.activeRelationshipInput;e&&this._listObserverNode&&e.showAllEnabled&&this._listObserver.observe(this._listObserverNode)}_onFormSubmit(e){e.preventDefault()}_getFieldInputFromHTMLElement(e){return this.viewModel.findFieldInput(e.getAttribute(be))}_afterRadioGroupCreateOrUpdate(e){const t=e.selectedItem,i=e.querySelector("calcite-radio-button"),a=t||i;a&&this._afterComponentCreateOrUpdate(a)}_onComponentFocus(e){const t=e.target,i=this._getFieldInputFromHTMLElement(t);this._isMultipleChoiceCheckbox(t,i)||this._markFieldInputTouched(i),this._focusedFieldInput=i}_markFieldInputTouched(e){this._touchedInputs.add(e.template.elementId)}_isMultipleChoiceCheckbox(e,t){return"CALCITE-CHECKBOX"===e.tagName&&null!=t.multipleChoiceInput}_afterComponentCreateOrUpdate(e){const t=this._getFieldInputFromHTMLElement(e),i=this._focusedFieldInput;this._attemptFocusOnNextRender&&i===t&&(this._attemptFocusOnNextRender=!1,ge(e))}_onComponentBlur(){this._focusedFieldInput=null}_resetTransientFormState(){this._attemptFocusOnNextRender=!1,this._focusedFieldInput=null,this._attachmentDialogInfo=null,this._selectedAttachmentReplaceFileInput=null,this._attachmentListFilterText="",this._attachmentFileInputMap.clear()}_parseValue(e,t,i=!1){const a=t.multipleChoiceInput,n=t.multipleChoiceValues;if(a&&n){const s=a.choiceDelimiter,l=e;if(i){return q({input:t}).checked?null:n.length>0?n.join(s):null}const o=K(t.value,s).filter(e=>e!==$),r=new Set(o);l.checked?r.add(l.value):r.delete(l.value);const c=n.filter(e=>r.has(e));return c.length?c.join(s):null}if(F(t.template,"switch")){if("calcite-dropdown"===e.localName&&t.domain)for(const i of t.domain.codedValues)if(i.name===e.selectedItems[0].textContent)return i.code;return e.checked?t.template.input.onValue:t.template.input.offValue}const s=e.value;return null==s||""===s?null:"number"===t.dataType?"-0"===s||"-0."===s||"-0,"===s?s:parseFloat(s):"date"===t.field.type?parseFloat(s):s}_saveInputFromElement(e){const t=this._getFieldInputFromHTMLElement(e);if(!t)return;const i=this._parseValue(e,t);this._saveInput(t,i)}_saveInput(e,t){const{elementId:i}=e.template,a=e?.value,{viewModel:s}=this;if(F(e.template,"switch")&&"single"!==s.mode){const t=n(this._batchSwitchInputInitialValues,e,()=>e.value);this._batchSwitchInputInitialValues.set(e,null===t?a:t)}t!==a&&(e.isSubtypeField&&"batch"!==s.mode&&k(s.activeLayer,a,t)?this._pendingSubtypeChoice||(this._pendingSubtypeChoice=this._handleSubtypeChoice(e,t)):s.setValue(i,t))}async _handleSubtypeChoice(e,i){const{value:a,template:n}=e,{elementId:s}=n,{messages:l,viewModel:o,messagesCommon:r}=this,{subtypes:c,activeFeatureIndex:d}=o;if(await o.setValue(s,i),!c?.length)return;const m=c.find(e=>e.code===i),h=c.find(e=>e.code===a)?.name??`${a}`;if(!m)return;const u=Promise.withResolvers();o.pendingSubtypeChoice=u;let p="update-fields";const g=[{label:l.subtypes.useDefaultValuesOption,value:"update-fields"},{label:l.subtypes.keepCurrentValuesOption,value:"keep-existing"}],v={context:"info",title:l.subtypes.changeWarningTitle,message:t(l.subtypes.changeWarning,{originalType:h,newType:m.name}),radios:g,defaultRadioSelection:"update-fields",onRadioSelection:e=>{p=e},actions:{primary:{label:r.apply,action:()=>u.resolve(p),type:"positive"},secondary:{label:r.cancel,type:"neutral",action:()=>u.resolve("undo")}},cancel:()=>u.reject()};try{this.showPrompt(v);switch(await u.promise){case"update-fields":await o.applySubtypeDefaults(m),await o.handleSubtypeChanged(d);break;case"keep-existing":await o.handleSubtypeChanged(d);break;case"undo":await this.viewModel.setValue(s,a)}}finally{o.pendingSubtypeChoice=null,this.clearPrompt(),this._pendingSubtypeChoice=null}}_afterDateComponentCreate(e){this._setDateTimeTimeZoneMap(e),this._afterComponentCreateOrUpdate(e)}_saveValueFromDateComponent(e,t){const{elementId:i}=e.template,a=e.field.type,n=this._dateComponentMap.get(`${i}`);if(!n)return;const s=e.effectiveTimeZone;let l=e.value===$?void 0:e.value,o=null;"date-only"===a?o=Array.isArray(t.value)?t.value[0]:t.value:"time-only"===a?(l=le(l),o=le(t.value)):o="timestamp-offset"===a?null!=t.value?oe({dateComponent:n.date,timeComponent:n.time,oldValue:l,timeZoneComponent:n.timeZone,defaultTimeZone:s}):null:null!=t.value?re({oldValue:l,dateComponent:n.date,timeZone:s,timeComponent:n.time?.value===$?void 0:n.time}):null,l!==o&&(null!==o&&t.value?this.viewModel.setValue(`${i}`,o):this.viewModel.setValue(`${i}`,null))}_getErrorToDisplay(e){const t=e.compositeError;return e.valid||!t?null:"contingent-values-validation-error::contingency-violation-error"===t||"contingent-values-validation-error::contingency-violation-warning"===t||this._touchedInputs.has(e.template.elementId)||this.viewModel.submitHasBeenAttempted?t:null}_renderViewingAssociationsPage(){return this._associationsList?.render()}_onActiveAssociationsInputChange(e){const t=this._associationsList;t&&(e?(t.associationInput=e,t.viewModel=e.viewModel):t.associationInput=null)}async _setUpAssociationsWidgets(){const e=this.viewModel.activeForm.allUtilityNetworkAssociationsElementInputs;if(this._associationsEnabled&&0!==e.length){await this._setUpUtilityNetworkAssociationList();for(const t of e)this._associationsWidgetsMap.set(t,await this._createAssociationsWidget(t))}}async _setUpUtilityNetworkAssociationList(){if(this._associationsList)return;const e=(await import("./FeatureForm/FeatureFormUtilityNetworkAssociations/FeatureFormUtilityNetworkAssociationList.js")).default;this._associationsList=new e({onSelectLayer:this._onSelectAssociatedLayer.bind(this),onSelectFeature:this._onEditAssociatedFeature.bind(this),onAddAssociation:this._onAddAssociation.bind(this)});const t=this.viewModel.activeAssociationsInput;t&&(this._associationsList.associationInput=t,this._associationsList.viewModel=t.viewModel)}async _createAssociationsWidget(e){return new(0,(await import("./Feature/FeatureUtilityNetworkAssociations.js")).default)({viewModel:e.viewModel,onSelectAssociationType:t=>this._onSelectAssociationType(e,t)})}_destroyAssociationsWidgets(){this._associationsWidgetsMap.forEach(e=>s(e)),this._associationsWidgetsMap.clear()}_onSelectAssociationType(e,{listType:t}){this.setActiveAssociationsInput(e),this.setActiveAssociationType(t)}_onSelectAssociatedLayer({layer:e}){this.setActiveAssociationsLayer(e)}async _onEditAssociatedFeature(e){const t=this.callbacks?.editAssociatedFeature,i=this.viewModel.activeAssociationsInput;if(!t||!i?.feature)return;const{association:a,feature:n}=e;await t({parentFeature:i.feature.plainGraphic,association:a,feature:n})}_onAddAssociation(e){const t=this.callbacks?.addAssociation,i=this.viewModel.activeAssociationsInput;if(!t||!i?.feature)return;const{associationType:a,utilityNetwork:n}=e;t({feature:i.feature.plainGraphic,associationType:a,utilityNetwork:n})}_getSelectedAttachmentEditState(){const e=this.selectedAttachmentDetails;if(e)return e.input.getAttachmentEditState(e.attachment)}_setFocusableInput(e){const t=e&&R(e)?e:this._findFocusableInput(e);this._focusedFieldInput=t,this._attemptFocusOnNextRender=!0}_findFocusableInput(e){const t=this.viewModel.activeForm.inputs;if(!t.length)return;const i=M(t);let a;if(e)if(V(e)){const t=e.inputs.find(e=>e.visible);a=t?i.indexOf(t):0}else{let n;if(j(e)&&!e.group.open){n=e.group.inputs.filter(R)[t.length-1]}else n=e;a=i.indexOf(n)+1}else a=0;for(let n=a;n<i.length;n++){const e=i[n];if(e.visible&&R(e))return this.disabled||this.readOnly,e}return null}_onGroupToggle(e,t){e.expanded?(t.open=!0,this._setFocusableInput(t)):t.open=!1,this.scheduleRender()}};function ye(e){switch(e){case"audio":return _("audio/mpeg");case"video":return _("video/mp4");case"image":return _("image/png");default:return"camera"}}e([h()],Ae.prototype,"activeFeatureIndex",null),e([h()],Ae.prototype,"attachmentsEnabled",null),e([h()],Ae.prototype,"callbacks",null),e([h()],Ae.prototype,"disabled",null),e([h()],Ae.prototype,"effectiveTitle",null),e([h()],Ae.prototype,"effectiveDisabled",null),e([h()],Ae.prototype,"features",null),e([h()],Ae.prototype,"footerButtonInfos",null),e([h()],Ae.prototype,"footerNoticeInfos",null),e([h()],Ae.prototype,"map",null),e([h()],Ae.prototype,"maximumFeatureCount",null),e([h()],Ae.prototype,"maximumFeatureCountWithComplexForms",null),e([h()],Ae.prototype,"spatialReference",null),e([h()],Ae.prototype,"layerInfos",null),e([h()],Ae.prototype,"timeZone",null),e([h()],Ae.prototype,"headingLevel",void 0),e([h()],Ae.prototype,"icon",null),e([h(),he("esri/t9n/common")],Ae.prototype,"messagesCommon",void 0),e([h(),he("esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm")],Ae.prototype,"messages",void 0),e([h(),he("esri/widgets/FeatureForm/t9n/FeatureForm")],Ae.prototype,"featureFormMessages",void 0),e([h(),he("esri/widgets/FeatureTable/t9n/FeatureTable")],Ae.prototype,"featureTableMessages",void 0),e([h(),he("esri/core/t9n/Units")],Ae.prototype,"messagesUnits",void 0),e([h()],Ae.prototype,"page",null),e([h()],Ae.prototype,"readOnly",null),e([h()],Ae.prototype,"showPrompt",null),e([h()],Ae.prototype,"clearPrompt",null),e([h()],Ae.prototype,"selectedAttachment",null),e([h()],Ae.prototype,"selectedAttachmentDetails",null),e([h()],Ae.prototype,"valid",null),e([h({type:x}),ue(["attachments-change","value-change","values-change","submit"])],Ae.prototype,"viewModel",void 0),e([h({type:T,nonNullable:!0})],Ae.prototype,"visibleElements",void 0),e([h()],Ae.prototype,"groupDisplay",void 0),e([h()],Ae.prototype,"_formHeaderVisible",null),e([h()],Ae.prototype,"_associationsEnabled",null),e([h()],Ae.prototype,"_associationsList",void 0),e([h()],Ae.prototype,"_attemptFocusOnNextRender",void 0),e([h()],Ae.prototype,"_formId",null),e([h()],Ae.prototype,"_focusedFieldInput",void 0),e([h()],Ae.prototype,"_pendingSubtypeChoice",void 0),e([h()],Ae.prototype,"_relatedRecordsEnabled",null),e([h()],Ae.prototype,"_listObserverNode",void 0),e([h()],Ae.prototype,"_attachmentDialogInfo",void 0),e([h()],Ae.prototype,"_attachmentListFilterText",void 0),e([h()],Ae.prototype,"_prompt",void 0),e([h()],Ae.prototype,"test",null),Ae=e([u("esri.widgets.BatchAttributeForm")],Ae);const we=Ae;export{we as default};
2
+ import{__decorate as e}from"tslib";import{substitute as t}from"../intl.js";import{deprecateWidget as i}from"../core/deprecate.js";import a from"../core/Logger.js";import{getOrCreateMapValue as n}from"../core/MapUtils.js";import{destroyMaybe as s}from"../core/maybe.js";import l from"../core/ReactiveMap.js";import{watch as o,when as r,on as c,sync as d}from"../core/reactiveUtils.js";import{formatFileSize as m}from"../core/unitFormatUtils.js";import{property as u,subclass as h}from"../core/accessorSupport/decorators.js";import{formatDate as p}from"../intl/date.js";import{isIntegerField as g}from"../layers/support/fieldUtils.js";import{isString as v}from"../support/guards.js";import b from"./Widget.js";import{getAttachmentTypeCategory as f,getCalciteIconForAttachment as _}from"./Attachments/support/attachmentUtils.js";import{getAttachmentKey as C,isImageAttachment as y,getAttachmentFilenameParts as A}from"./BatchAttributeForm/attachmentUtils.js";import{getHiddenFieldsValidationErrorMessage as w,getVisibleFieldInputValidationErrorMessage as I,isElementTemplateWithInputType as F,subtypeChangeShouldPrompt as k,flattenInputs as M}from"./BatchAttributeForm/batchAttributeFormUtils.js";import x from"./BatchAttributeForm/BatchAttributeFormViewModel.js";import{css as D}from"./BatchAttributeForm/css.js";import{makeViewingEditedAttachmentFooterButtons as S,makeViewingAttachmentFooterButtons as E,makeCancelFooterButton as O,makeDefaultFooterButtons as L}from"./BatchAttributeForm/interfaceUtils.js";import T from"./BatchAttributeForm/VisibleElements.js";import{isGroupInput as V,isFieldInput as R,isTextElementInput as N,isRelationshipElementInput as P,isAttachmentElementInput as U,isUtilityNetworkAssociationsElementInput as B,differentValuesString as $,getNormalizedFieldName as z,isGroupedInput as j}from"./BatchAttributeForm/inputs/support/inputUtils.js";import{clearMultipleChoiceOtherChoiceStateForViewModel as H,getMultipleChoiceCheckboxState as W,otherChoiceCheckedPlaceholderValue as G,getUpdatedMultipleChoiceValueForFeature as Z,getMultipleChoiceSelectAllState as q,splitMultipleChoiceValue as K,canRestoreMultipleChoiceOtherChoiceDraftValue as X}from"./BatchAttributeForm/inputs/support/multipleChoiceInputUtils.js";import{loadRelationshipDetailsComponents as J,RelationshipDetails as Q}from"./BatchAttributeForm/rendered-content/RelationshipDetails.js";import{Prompt as Y}from"./Editor/components/Prompt.js";import{downloadAttachmentInfo as ee}from"./FeatureTable/support/exportUtils.js";import{loadCalciteComponents as te}from"./support/componentsUtils.js";import{getLabelForDateFieldValue as ie,getIntlOptionsForField as ae,prepareISOFieldValueForDateComponents as ne,prepareUnixFieldValueForDateComponents as se,normalizeTimeOnlyString as le,getISOFieldValueFromDateComponents as oe,getUnixFieldValueFromDateComponents as re}from"./support/dateUtils.js";import{globalCss as ce}from"./support/globalCss.js";import{Heading as de}from"./support/Heading.js";import{calciteListFilterProps as me}from"./support/listUtils.js";import{messageBundle as ue,vmEvent as he,tsx as pe}from"./support/widget.js";import{setFocus as ge}from"./support/widgetUtils.js";import{isEmptyValue as ve}from"./support/forms/formUtils.js";const be="data-element-id",fe="data-field-name",_e="esri_BatchAttributeForm_select_all",Ce="esri_BatchAttributeForm_other_choice";let ye=class extends b{constructor(e,t){super(e,t),this.headingLevel=2,this.messagesCommon=null,this.messages=null,this.featureFormMessages=null,this.featureTableMessages=null,this.messagesUnits=null,this.viewModel=new x,this.visibleElements=new T,this.groupDisplay="all",this._associationsList=null,this._associationsWidgetsMap=new l,this._attemptFocusOnNextRender=!1,this._dateComponentMap=new Map,this._touchedInputs=new Set,this._focusedFieldInput=null,this._pendingSubtypeChoice=null,this._batchSwitchInputInitialValues=new Map,this._listObserverNode=null,this._listObserver=new IntersectionObserver(e=>{e.length&&e[0].isIntersecting&&this.viewModel.activeRelationshipInput?.incrementPage()},{root:window.document}),this._attachmentDialogInfo=null,this._attachmentListFilterText="",this._attachmentFileInputMap=new Map,this._prompt=null,this._selectedAttachmentReplaceFileInput=null,this._afterListObserverCreated=e=>{this.viewModel.activeRelationshipInput&&(this._listObserverNode=e)},this._afterListObserverRemoved=()=>{this._listObserverNode=null},this._maximizeSelectedAttachment=()=>{this._attachmentDialogInfo=this.selectedAttachmentDetails},this._enterAttachmentReplaceView=()=>{const e=this.selectedAttachmentDetails;this._canReplaceSelectedAttachment()&&e&&(e.input.clearValidationCriteriaState(),this.viewModel.setShowingSelectedAttachmentReplacePage(!0))},this._setSelectedAttachmentReplaceFileInput=e=>{this._selectedAttachmentReplaceFileInput=e},this._openSelectedAttachmentReplaceFilePicker=()=>{this._canReplaceSelectedAttachment()&&this._selectedAttachmentReplaceFileInput?.click()},this._resetSelectedAttachmentName=()=>{const e=this.selectedAttachmentDetails;if(!e?.attachment)return;const t=e.input.getAttachmentEditState(e.attachment).initialName;if(null==t)return;const i=e.input.template.elementId,a=C(e.attachment);this.viewModel.stageRenameAttachment(i,a,t)},this._closeAttachmentDialog=()=>{this.hideAttachmentDialog()},this._saveInputFromElement=this._saveInputFromElement.bind(this),this._onFormSubmit=this._onFormSubmit.bind(this),this._onComponentFocus=this._onComponentFocus.bind(this),this._onComponentBlur=this._onComponentBlur.bind(this),this._afterComponentCreateOrUpdate=this._afterComponentCreateOrUpdate.bind(this),this._afterDateComponentCreate=this._afterDateComponentCreate.bind(this),this._afterRadioGroupCreateOrUpdate=this._afterRadioGroupCreateOrUpdate.bind(this),e?.suppressDeprecationWarning||(this.announceDeprecation=()=>{i(a.getLogger(this),"Editor","arcgis-editor",{version:"5.0"})})}normalizeCtorArgs(e={}){const{suppressDeprecationWarning:t,...i}=e;return i}initialize(){this.addHandles([o(()=>this.features,()=>{this._dateComponentMap.clear(),H(this.viewModel,{includeDraftValues:!0})}),o(()=>this.viewModel.activeForm,()=>{this._batchSwitchInputInitialValues.clear(),this._resetTransientFormState(),H(this.viewModel),this._setFocusableInput()}),o(()=>this.viewModel.selectedAttachmentAddElementId,()=>{this.hideAttachmentDialog()}),r(()=>!this.selectedAttachmentDetails,()=>this.hideAttachmentDialog()),o(()=>this.viewModel.selectedAttachmentListElementId,()=>{this._attachmentListFilterText=""}),o(()=>[this.viewModel.activeRelationshipInput,this._listObserverNode],()=>this._onObserverChange()),c(()=>this.viewModel,"submit",()=>{this.valid||this.goToFirstError()}),o(()=>[this._associationsEnabled,this.viewModel.activeForm.allUtilityNetworkAssociationsElementInputs],()=>this._setUpAssociationsWidgets(),d),o(()=>this.viewModel.activeAssociationsInput,e=>this._onActiveAssociationsInputChange(e)),o(()=>this.groupDisplay,()=>this._syncGroupInputStates())])}loadDependencies(){return Promise.all([te({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),block:()=>import("@esri/calcite-components/dist/components/calcite-block"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),checkbox:()=>import("@esri/calcite-components/dist/components/calcite-checkbox"),chip:()=>import("@esri/calcite-components/dist/components/calcite-chip"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item"),"combobox-item-group":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item-group"),dialog:()=>import("@esri/calcite-components/dist/components/calcite-dialog"),dropdown:()=>import("@esri/calcite-components/dist/components/calcite-dropdown"),"dropdown-group":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-group"),"dropdown-item":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-item"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),input:()=>import("@esri/calcite-components/dist/components/calcite-input"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker"),"input-message":()=>import("@esri/calcite-components/dist/components/calcite-input-message"),"input-number":()=>import("@esri/calcite-components/dist/components/calcite-input-number"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker"),"input-time-zone":()=>import("@esri/calcite-components/dist/components/calcite-input-time-zone"),label:()=>import("@esri/calcite-components/dist/components/calcite-label"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch"),"text-area":()=>import("@esri/calcite-components/dist/components/calcite-text-area"),"radio-button":()=>import("@esri/calcite-components/dist/components/calcite-radio-button"),"radio-button-group":()=>import("@esri/calcite-components/dist/components/calcite-radio-button-group")}),J()])}destroy(){this._destroyAssociationsWidgets(),this._associationsList=s(this._associationsList),this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode)}get activeFeatureIndex(){return this.viewModel.activeFeatureIndex}set activeFeatureIndex(e){this.viewModel.activeFeatureIndex=e}get attachmentsEnabled(){return this.viewModel.attachmentsEnabled}set attachmentsEnabled(e){this.viewModel.attachmentsEnabled=e}get callbacks(){return this.viewModel.callbacks}set callbacks(e){this.viewModel.callbacks=e}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}get effectiveTitle(){const{features:e,messages:t,page:i}=this;return t?"replacing-attachment"===i?t.titles.replaceAttachment:"viewing-attachment-details"===i?t.titles.editAttachment:"adding-attachments"===i?t.titles.addAttachments:"viewing-attachments"===i?t.titles.attachments:1===e.length||this.activeFeatureIndex>-1?t.titles.editFeature:e.length>1?t.titles.editFeatures:"":""}get effectiveDisabled(){return this.disabledOrReadOnly||this.viewModel.updating}get disabledOrReadOnly(){return this.disabled||this.readOnly}get features(){return this.viewModel.features}set features(e){this.viewModel.features=e}get footerButtonInfos(){if(!this.features.length||!this.messages||!this.messagesCommon)return[];const{messages:e,messagesCommon:t,page:i}=this,a=this.effectiveDisabled;if("adding-attachments"===i||"replacing-attachment"===i)return[];const n=this._getSelectedAttachmentEditState();if("viewing-attachment-details"===i){return!!n?.isRenamed||!!n?.isReplaced?S({doneOnclick:()=>this._setSelectedAttachment(null),messages:e.footerButtons,resetOnclick:()=>this._resetSelectedAttachmentChanges()}):E({deleteDisabled:this._isSelectedAttachmentDeleteDisabled(),deleteOnclick:()=>this._deleteSelectedAttachment(),doneOnclick:()=>this._setSelectedAttachment(null),messages:e.footerButtons})}return"viewing-associated-features"===i?O({messages:t,purpose:"cancel-viewing-associated-features",onclick:()=>this.goBack()}):"viewing-associated-layers"===i?O({messages:t,purpose:"cancel-viewing-associated-layers",onclick:()=>this.goBack()}):"viewing-attachments"===i||"viewing-related-records"===i?[]:L({disabled:a||!this.valid,formId:this._formId,messages:e,callback:()=>this.submit()})}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get maximumFeatureCount(){return this.viewModel.maximumFeatureCount}set maximumFeatureCount(e){this.viewModel.maximumFeatureCount=e}get maximumFeatureCountWithComplexForms(){return this.viewModel.maximumFeatureCountWithComplexForms}set maximumFeatureCountWithComplexForms(e){this.viewModel.maximumFeatureCountWithComplexForms=e}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=e}get layerInfos(){return this.viewModel.layerInfos}set layerInfos(e){this.viewModel.layerInfos=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get icon(){return"edit-attributes"}set icon(e){this._overrideIfSome("icon",e)}get page(){return this.viewModel.page}get readOnly(){return this.viewModel.readOnly}set readOnly(e){this.viewModel.readOnly=e}get showPrompt(){return e=>{this._prompt?.cancel?.(),this._prompt=e}}set showPrompt(e){this._overrideIfSome("showPrompt",e)}get clearPrompt(){return()=>this._prompt=null}set clearPrompt(e){this._overrideIfSome("clearPrompt",e)}get selectedAttachment(){return this.viewModel.selectedAttachment}get selectedAttachmentDetails(){return this.viewModel.selectedAttachmentDetails}get valid(){return this.viewModel.valid}get _formHeaderVisible(){return!("batch"===this.viewModel.mode||!this.viewModel.activeFeature)&&!(!this.viewModel.formDescription&&!this.viewModel.formTitle)}get _associationsEnabled(){const{callbacks:e}=this;return!(!e?.addAssociation&&!e?.editAssociatedFeature)}get _formId(){return`${this.id}-form`}get _relatedRecordsEnabled(){const{callbacks:e}=this;return!(!e||!e.addRelatedRecord&&!e.editRelatedRecord)}async goBack(){return this.viewModel.goBack()}async goHome(){return this.viewModel.goHome()}goToFirstError(){const e=this.viewModel.getFirstVisibleInvalidFieldInput();if(!e)return;const{groupInput:t}=e;t&&(t.open||(t.open=!0)),this._setFocusableInput(e.input),this.scheduleRender()}render(){return pe("div",{class:this.classes(D.base,ce.widget,ce.panel)},this._renderContent(),this._renderAttachmentDialog(),this._prompt?pe(Y,{...this._prompt,headingLevel:this.headingLevel}):void 0)}setActiveAssociationsInput(e){this.viewModel.setActiveAssociationsInput(e)}setActiveAssociationsLayer(e){this.viewModel.setActiveAssociationsLayer(e)}setActiveAssociationType(e){this.viewModel.setActiveAssociationType(e)}submit(){return this.viewModel.submit()}get test(){return{saveInput:this._saveInput.bind(this),pendingSubtypeChoice:this._pendingSubtypeChoice}}_setDateTimeTimeZoneMap(e){const{datePart:t,elementId:i}=e.dataset,a=n(this._dateComponentMap,`${i}`,()=>({}));switch(t){case"date":a.date=e;break;case"time":a.time=e;break;case"timeZone":a.timeZone=e}}_renderContent(){const{messages:e,viewModel:i}=this,{status:a}=i;return"failed"===a?i.hasTooManyComplexFeatures?this._renderErrorNotice(t(e.formFailedToLoadTooManyComplexFeatures,{num:i.maximumFeatureCountWithComplexForms})):i.hasTooManyFeatures?this._renderErrorNotice(t(e.formFailedToLoadTooManyFeatures,{num:i.maximumFeatureCount})):e.formFailedToLoad:i.expressionEvaluationFailed?this._renderErrorNotice(e.expressionEvaluationFailed):i.hasLayersWithContingentValues&&this.viewModel.features.length>1?this._renderErrorNotice(e.unsupportedContingentValues):"loading"===a&&this.visibleElements.loadingIndicator?pe("calcite-loader",{key:"loader",label:this.messagesCommon?.loading}):0!==this.features.length?this._renderForm():void 0}_renderErrorNotice(e,t="warning"){return pe("calcite-notice",{class:D.noticeError,icon:!0,kind:t,open:!0},pe("div",{slot:"message"},e))}_renderForm(){return pe("form",{class:D.form,id:this._formId,inert:!!this._prompt,onsubmit:this._onFormSubmit},this._renderInvisibleFieldsError(),this._renderPage())}_renderPage(){switch(this.page){case"adding-attachments":return this._renderAttachmentAddPage();case"viewing-attachment-details":case"replacing-attachment":return this._renderAttachmentDetailPage();case"viewing-attachments":return this._renderAttachmentListPage();case"viewing-associated-layers":case"viewing-associated-features":return this._renderViewingAssociationsPage();case"viewing-related-categories":case"viewing-related-records":return this._renderRelationshipListPage();default:return this._renderDefaultPage()}}_renderInvisibleFieldsError(){const{viewModel:e}=this,{hasNonActiveInvalidFeatures:t,activeForm:i}=e;let a;if(!e.submitHasBeenAttempted)return null;if(i.invalidHiddenInputs.length>0)if(a=w(i,e.mode,this.messages),"batch"===this.viewModel.mode){const e=i.invalidHiddenInputs.filter(e=>"hidden:group-visibility-expression:all-features"===e.effectiveVisibilityCode||"hidden:visibility-expression:all-features"===e.visibilityCode);e.length>0?a+=` (${e.map(e=>e.label).join(", ")})`:a=null}else a+=` (${i.invalidHiddenInputs.map(e=>e.label).join(", ")})`;else if(t)return null;return a?this._renderErrorNotice(a,"danger"):null}_renderDefaultPage(){return[this._renderReadOnlyNotice(),this._renderFormHeader(),this._renderFormContent()]}_renderReadOnlyNotice(){if((this.disabled||this.readOnly)&&this.visibleElements.readOnlyNotice)return pe("calcite-notice",{class:D.disabledNotice,icon:"read-only-non-editable",kind:"brand",open:!0,scale:"s",width:"full"},pe("div",{slot:"message"},this.featureFormMessages.disabledForm))}_renderFormHeader(){const{formTitle:e,formDescription:t}=this.viewModel;if(!this._formHeaderVisible)return;const i=e?pe(de,{key:"title",level:this.headingLevel},e):void 0,a=t?pe("p",{class:D.description,key:"description"},t):void 0;return pe("div",{class:D.formHeader},i,a)}_renderFormContent(){return this.viewModel.hasVisibleInputs?this.viewModel.activeForm.inputs.filter(e=>e.visible).map(e=>this._renderInput(e)):this._renderErrorNotice(this.messages.noVisibleFields[this.viewModel.noVisibleElementsReason])}_renderInput(e){return V(e)?this._renderGroupInput(e):R(e)?this._renderLabeledField(e):N(e)?this._renderTextComponent(e):P(e)?this._renderRelationshipElementInput(e):U(e)?this._renderAttachmentElementInput(e):B(e)?this._renderUtilityNetworkAssociationsElementInput(e):void 0}_renderGroupInput(e){const{inputs:t,template:i,open:a}=e,n=t.filter(e=>e.visible),s=e.label??"",l=this._focusedFieldInput?.group===e,o="sequential"===this.groupDisplay;return pe("calcite-block",{class:this.classes(D.group,o?D.groupSequential:null,l?D.groupActive:null,this.disabled?D.inputDisabled:null),collapsible:!0,description:e.description??void 0,disabled:this.effectiveDisabled,expanded:a,heading:s,headingLevel:this.headingLevel,key:`{${i.elementId}-key}`,label:s,onCalciteBlockClose:()=>{e.open=!1},onCalciteBlockOpen:()=>{e.open=!0},onCalciteBlockToggle:({currentTarget:t})=>this._onGroupToggle(t,e)},n.map(e=>this._renderInput(e)))}_renderLabeledField(e){const{elementId:i}=e.template,{label:a,required:n,dataType:s}=e,l=n?t(this.messages.requiredFieldLabel,{name:a}):a;return pe("calcite-label",{"aria-label":l,class:D.label,key:`field--${i}`},pe("div",{class:D.labelTextContent,key:"labelTextContainer"},a,n?pe("span",{"aria-hidden":"true",title:this.messagesCommon.required},"*"):void 0),"unsupported"!==s?this._renderFieldInput(e):this._renderReadOnlyComponent(e),this._renderAuxiliaryText(e))}_renderFieldInput(e){const t=this.getCommonInputProps(e),{dataType:i}=e;return"coded-value"===e.domain?.type?this._renderCodedInputs({input:e,props:t}):null!==e.multipleChoiceChoices?this._renderMultipleChoiceComponent({input:e,props:t}):"date"===i?this._renderDateComponents(e,t):"number"===i?this._renderNumberComponent(e,t):this._renderStringComponent(e,t)}_renderAuxiliaryText(e){const{description:t}=e,i=this._getErrorToDisplay(e),a=i?I(e,i,this.messages):null;return a?pe("calcite-input-message",{icon:!0,status:"invalid"},a):t?pe("calcite-input-message",{class:D.description,icon:!1,status:"idle"},t):null}_renderCodedInputs({input:e,props:t}){const i=e.input?.type??null,a=e.codedValueOptions;switch(i){case"switch":return this._renderSwitchField({input:e,props:t});case"radio-buttons":return this._renderRadioButtonGroupComponent({input:e,options:a,props:t});default:return this._renderComboBoxComponent({options:a,props:t,input:e})}}_renderMultipleChoiceComponent({input:e,props:t}){const{messages:i}=this,{multipleChoiceChoices:a,multipleChoiceInput:n,multipleChoiceValues:s}=e;if(!n||!a||!s)return null;const l=!0===n.includeSelectAllChoices,o=new Map;let r=s.length>0,c=!1;for(const b of s){const t=W({input:e,choiceValue:b});o.set(b,t),(t.checked||t.indeterminate)&&(c=!0),t.checked||(r=!1)}const d={checked:r,indeterminate:!r&&c},m=d.checked?i.deselectAllLabel:i.selectAllLabel,u=e.getMultipleChoiceOtherChoiceRenderState(this.messages.otherOptionLabel),h=t=>{this._saveValueFromMultipleChoiceCheckbox({input:e,checkbox:t,isSelectAllCheckbox:!0})},p=t=>{this._saveValueFromMultipleChoiceCheckbox({input:e,checkbox:t})},g=t=>{const{fieldName:i}=u;i&&this._saveOtherChoiceCheckboxValue({input:e,isChecked:t.checked,otherChoiceFieldName:i})},v=t=>{this._saveValueFromMultipleChoiceTextInput({input:e,textInput:t,otherChoiceFieldName:u.fieldName})};return pe("div",{class:D.multipleChoiceInput,key:`${t.key}-multiple-choice-group`},l?this._renderMultipleChoiceSelectAllCheckbox({props:t,selectAllState:d,selectAllLabel:m,handleSelectAllCheckboxChange:h}):null,this._renderMultipleChoiceChoiceCheckboxes({input:e,props:t,checkboxStatesByValue:o,handleChoiceCheckboxChange:p}),u.shouldShow?this._renderMultipleChoiceOtherChoice({props:t,includeSelectAllChoices:l,otherChoiceRenderState:u,handleOtherChoiceCheckboxChange:g,handleOtherChoiceInputChange:v,differentValuesPlaceholder:i.differentValuesPlaceholder}):null)}_renderMultipleChoiceSelectAllCheckbox({props:e,selectAllState:t,selectAllLabel:i,handleSelectAllCheckboxChange:a}){return pe("calcite-checkbox",{afterCreate:e.afterCreate,afterUpdate:e.afterUpdate,"aria-invalid":e["aria-invalid"],checked:t.checked,class:D.multipleChoiceSelectAll,"data-element-id":e[be],disabled:e.readOnly||e.disabled,indeterminate:t.indeterminate,key:`${e.key}-select-all`,label:i,labelText:i,value:_e,onblur:e.onblur,onCalciteCheckboxChange:({currentTarget:e})=>a(e),onfocus:e.onfocus})}_renderMultipleChoiceChoiceCheckboxes({input:e,props:t,checkboxStatesByValue:i,handleChoiceCheckboxChange:a}){const{multipleChoiceChoices:n}=e;return n?n.map(e=>{const n=i.get(e.value)??{checked:!1,indeterminate:!1};return pe("calcite-checkbox",{afterCreate:t.afterCreate,afterUpdate:t.afterUpdate,"aria-invalid":t["aria-invalid"],checked:n.checked,class:t.class,"data-element-id":t[be],disabled:t.readOnly||t.disabled,indeterminate:n.indeterminate,key:`${t.key}-${e.value}`,label:e.label,labelText:e.label,value:e.value,onblur:t.onblur,onCalciteCheckboxChange:({currentTarget:e})=>a(e),onfocus:t.onfocus})}):[]}_renderMultipleChoiceOtherChoice({props:e,includeSelectAllChoices:t,otherChoiceRenderState:i,handleOtherChoiceCheckboxChange:a,handleOtherChoiceInputChange:n,differentValuesPlaceholder:s}){return pe("div",{class:this.classes(D.multipleChoiceOtherChoice,t?D.multipleChoiceOtherChoiceWithSelectAll:null),key:`${e.key}-other-choice`},pe("calcite-checkbox",{afterCreate:e.afterCreate,afterUpdate:e.afterUpdate,"aria-invalid":e["aria-invalid"],checked:i.checkboxState.checked,class:e.class,"data-element-id":e[be],disabled:e.readOnly||e.disabled,indeterminate:i.checkboxState.indeterminate,key:`${e.key}-other-choice-checkbox`,label:i.label,labelText:i.label,value:Ce,onblur:e.onblur,onCalciteCheckboxChange:({currentTarget:e})=>a(e),onfocus:e.onfocus}),i.checkboxState.checked?pe("calcite-input",{afterCreate:e.afterCreate,afterUpdate:e.afterUpdate,"aria-invalid":e["aria-invalid"],"aria-label":i.label,class:D.textElementInput,"data-element-id":e[be],disabled:e.readOnly||e.disabled,key:`${e.key}-other-choice-input`,maxLength:i.maxLength,placeholder:i.value===$?s:i.hint,type:"text",value:i.normalizedValue===$?"":i.normalizedValue?String(i.normalizedValue):"",onblur:e.onblur,onCalciteInputInput:({currentTarget:e})=>n(e),onfocus:e.onfocus}):null)}async _saveValueFromMultipleChoiceCheckbox({input:e,checkbox:t,isSelectAllCheckbox:i=!1}){if(this._markFieldInputTouched(e),e.multipleChoiceInput&&!i&&"batch"===this.viewModel.mode)return void await this._saveMultipleChoiceCheckboxValueByFeature({input:e,checkbox:t});const a=e.value,n=this._parseValue(t,e,i);n!==a&&await this.viewModel.setValue(e.template.elementId,n)}async _saveValueFromMultipleChoiceTextInput({input:e,textInput:t,otherChoiceFieldName:i}){if(!i)return;const a=t.value,n=null==a||""===a?null:a;e.initializeExplicitMultipleChoiceOtherChoiceCheckedState(),e.stashMultipleChoiceOtherChoiceDraftValueForFeatures(e.features,n);const s=z(e,i);s&&await this.viewModel.setValueForFieldName(s,n,Array.from(e.features,e=>e.source))}async _saveOtherChoiceCheckboxValue({input:e,isChecked:t,otherChoiceFieldName:i}){e.setExplicitMultipleChoiceOtherChoiceCheckedState(t),this._markFieldInputTouched(e),t||e.setMultipleChoiceOtherChoiceDraftValuesFromFeatures(e.features.toArray());const a=z(e,i);if(!a)return;const n=new Map;for(const s of e.features){const a=s.getAttribute(i);if(t){if(!ve(a))continue;const t=e.getMultipleChoiceOtherChoiceDraftValue(s),i=X(t)?t:G;n.set(s,i);continue}null!=a&&n.set(s,null)}0!==n.size&&await this.viewModel.setValuePerFeatureForFieldName(a,new Map(Array.from(n,([e,t])=>[e.source,t])))}async _saveMultipleChoiceCheckboxValueByFeature({input:e,checkbox:t}){if(!e.multipleChoiceInput||!e.multipleChoiceValues)return;const i=new Map(e.features.map(i=>[i,Z({input:e,choiceValue:t.value,currentValue:i.getAttribute(e.fieldName),isChecked:t.checked})]));0!==i.size&&await this.viewModel.setFieldInputValuePerFeature(e,i)}_renderSwitchField({input:e,props:t}){if((this._batchSwitchInputInitialValues.get(e)===$||e.value===$)&&"batch"===this.viewModel.mode){const i={dropdown:{afterCreate:this._afterComponentCreateOrUpdate,afterUpdate:this._afterComponentCreateOrUpdate,disabled:t.readOnly,open:!1,[be]:t[be]},trigger:{appearance:"transparent",iconEnd:"chevron-down",kind:"neutral",slot:"trigger",label:t.label},group:{mode:"single"}};return this._renderDropdownComponent({buttonValue:e.value,dropdownProps:i,options:[{name:this.messages.differentValuesPlaceholder,value:$,disabled:!0},...e.codedValueDomainOptions]})}return this._renderSwitchComponent({input:e,props:t})}_renderSwitchComponent({input:e,props:t}){return pe("calcite-switch",{...t,checked:!!F(e.template,"switch")&&e.value===e.template.input.onValue,class:D.inputSwitch,disabled:t.readOnly,onblur:()=>{this._focusedFieldInput=null},onCalciteSwitchChange:({currentTarget:e})=>this._saveInputFromElement(e)})}_renderDropdownComponent({buttonValue:e,options:t,dropdownProps:i}){const{trigger:a,dropdown:n,group:s}=i;return pe("calcite-dropdown",{...n,topLayerDisabled:this.topLayerDisabled,onblur:()=>{this._focusedFieldInput=null},onCalciteDropdownSelect:({currentTarget:e})=>this._saveInputFromElement(e),onfocus:this._onComponentFocus},pe("calcite-button",{...a},e===$?this.messages.differentValuesPlaceholder:e),pe("calcite-dropdown-group",{selectionMode:s.mode},t.map(t=>pe("calcite-dropdown-item",{disabled:t.disabled,label:String(t.name),selected:e===t.value},t.name))))}_renderComboBoxComponent({input:e,options:t,props:i}){const a="INSERT"===this.viewModel.editType,n=this._touchedInputs.has(e?.template?.elementId),s=a&&e.showNoValueOptionEnabled&&!n?()=>{}:i.onblur,l={...i,onblur:s};return pe("calcite-combobox",{...l,clearDisabled:e.isSubtypeField,selectionMode:"single",topLayerDisabled:this.topLayerDisabled,value:i.placeholder===this.messages.differentValuesPlaceholder?$:String(i.value),onCalciteComboboxChange:({currentTarget:t})=>{t.value!==$&&(e.isSubtypeField&&0===t.selectedItems.length?t.value=`${e.value}`:this._saveInputFromElement(t))}},this.renderComboboxOptionsList({input:e,options:t,props:i}))}renderComboboxOptionsList({input:e,options:t,props:i}){const a=e=>e.map(e=>{const{value:t}=e,a=ve(e.value)?this.messages.empty:e.name;return pe("calcite-combobox-item",{heading:a,key:`#${t}`,selected:i.value===t,value:`${t}`})});let n=[];const{messages:s}=this;t.other.length>0&&n.push(pe("calcite-combobox-item-group",{key:"other",label:s.other},a(t.other))),t.unsupported.length>0&&n.push(pe("calcite-combobox-item-group",{key:"unsupported",label:s.unsupported},a(t.unsupported)));const l=a(t.recommended);n.length>0?n.unshift(pe("calcite-combobox-item-group",{key:"recommended",label:s.recommended},l)):n=l;const o=i.placeholder===this.messages.differentValuesPlaceholder,r=!o&&ve(i.value);return e.showNoValueOptionEnabled&&!t.containsEmptyOption&&n.unshift(pe("calcite-combobox-item",{heading:e.showNoValueLabel||this.messages.empty,key:"empty-option",selected:r,value:""})),o&&n.unshift(pe("calcite-combobox-item",{heading:this.messages.differentValuesPlaceholder,key:$,selected:!0,value:$})),n}_renderRadioButtonGroupComponent({input:e,options:t,props:i}){const a=[...t.recommended,...t.other,...t.unsupported].map(({name:t,value:a})=>this._renderRadioButtons({label:t,value:a,selected:a===e.value,props:i}));if(e.showNoValueOptionEnabled&&!t.containsEmptyOption){const t="",n=e.showNoValueLabel||this.messages.empty,s=ve(e.value);a.unshift(this._renderRadioButtons({label:n,value:t,selected:s,props:i}))}return pe("calcite-radio-button-group",{afterCreate:this._afterRadioGroupCreateOrUpdate,afterUpdate:this._afterRadioGroupCreateOrUpdate,class:D.inputRadioGroup,"data-field-name":i[fe],disabled:i.readOnly||i.disabled,key:`${i.key}-radio-group`,layout:"vertical",name:i.name,required:i.required},a,i.placeholder===this.messages.differentValuesPlaceholder?pe("calcite-label",{class:D.placeholderRadio,key:i.label,layout:"inline"},pe("calcite-radio-button",{checked:!0,class:D.inputRadio,disabled:!0,name:i.placeholder,value:i.placeholder}),i.placeholder):null)}_renderRadioButtons({value:e,selected:t,label:i,props:a}){return pe("calcite-label",{class:D.inputRadioLabel,key:a.label,layout:"inline"},pe("calcite-radio-button",{...a,afterCreate:void 0,afterUpdate:void 0,checked:t,class:D.inputRadio,disabled:a.readOnly||a.disabled,name:a.label,value:e,onblur:()=>{this._focusedFieldInput=null},onCalciteRadioButtonChange:({currentTarget:e})=>{e.checked&&this._saveInputFromElement(e)}}),i)}_renderStringComponent(e,t){const{template:i}=e;return!i.field.editable||this.readOnly?this._renderReadOnlyComponent(e):"text-area"===i.input?.type?pe("calcite-text-area",{...t,class:this.classes(D.individualElement),resize:"vertical",value:t.value?String(t.value):"",onCalciteTextAreaInput:({currentTarget:e})=>this._saveInputFromElement(e)}):pe("calcite-input",{...t,class:this.classes(D.individualElement),type:"text",value:t.value?String(t.value):"",onCalciteInputInput:({currentTarget:e})=>this._saveInputFromElement(e)})}_renderNumberComponent(e,t){const i=g(e.field);return pe("calcite-input-number",{...t,integer:i,type:"number",value:i&&""!==t.value?Math.round(parseFloat(String(t.value))).toString():String(t.value),onCalciteInputNumberInput:({currentTarget:e})=>this._saveInputFromElement(e)})}_renderReadOnlyComponent(e,t){const i=this.getCommonInputProps(e);return pe("calcite-input",{...i,class:this.classes(D.fieldInput,D.inputDisabled,D.individualElement),readOnly:!0,type:"text",value:String(t??i.value??"")})}_renderDateComponents(e,t){const{field:i}=e;let a;switch(i.type){case"date":a=this._renderDateFieldComponents(e,t);break;case"date-only":a=this._renderDateOnlyFieldComponent(e,t);break;case"time-only":a=this._renderTimeOnlyFieldComponent(e,t);break;case"timestamp-offset":a=this._renderTimestampOffsetFieldComponents(e,t);break;default:a=this._renderReadOnlyComponent(e,ie(i,t.value,{timeZone:e.effectiveTimeZone,...ae(e.template.field)}))}return e.value===$?[a,pe("calcite-input-message",{icon:"information",key:"diff-values-message",status:"idle"},this.messages.differentValues)]:a}_renderDateOnlyFieldComponent(e,t){const{class:i,disabled:a,key:n,readOnly:s}=t,{rawMax:l,rawMin:o}=e.range;return pe("calcite-input-date-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,class:i,"data-date-part":"date","data-element-id":t[be],"data-field-name":t[fe],key:`${n}-date-input`,max:v(l)?l:void 0,min:v(o)?o:void 0,overlayPositioning:"fixed",readOnly:s||a,topLayerDisabled:this.topLayerDisabled,value:e.value===$?"":e.value?String(e.value):"",onblur:()=>{this._focusedFieldInput=null},onCalciteInputDatePickerChange:t=>this._saveValueFromDateComponent(e,t.currentTarget),onfocus:this._onComponentFocus})}_renderTimeOnlyFieldComponent(e,t){const{class:i,disabled:a,key:n,readOnly:s}=t;return pe("calcite-input-time-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,class:i,"data-date-part":"time","data-element-id":t[be],"data-field-name":t[fe],key:`${n}-time-input`,overlayPositioning:"fixed",readOnly:s||a,value:e.value===$?"":e.value?String(e.value):"",onblur:()=>{this._focusedFieldInput=null},onCalciteInputTimePickerChange:t=>this._saveValueFromDateComponent(e,t.currentTarget),onfocus:this._onComponentFocus})}_renderTimestampOffsetFieldComponents(e,t){const{class:i,disabled:a,key:n,readOnly:s}=t,{rawMax:l,rawMin:o}=e.range,r=e.effectiveTimeZone,c=ne(l,r),d=ne(o,r),m=ne(e.value===$?"":e.value,r),u=e.includeTimeOffset,h={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,overlayPositioning:"fixed",readOnly:s||a,[be]:t[be],[fe]:t[fe],onfocus:this._onComponentFocus};return pe("div",{class:D.dateInputContainer,key:`${n}-date-time-container`},pe("calcite-input-date-picker",{...h,class:i,"data-date-part":"date",key:`${n}-date-input`,max:c?.date??void 0,min:d?.date??void 0,topLayerDisabled:this.topLayerDisabled,value:m.date??"",onblur:()=>{this._focusedFieldInput=null},onCalciteInputDatePickerChange:t=>this._saveValueFromDateComponent(e,t.target)}),pe("calcite-input-time-picker",{...h,class:i,"data-date-part":"time",key:`${n}-time-input`,value:m.time??"",onblur:()=>{this._focusedFieldInput=null},onCalciteInputTimePickerChange:t=>this._saveValueFromDateComponent(e,t.target)}),u?pe("calcite-input-time-zone",{...h,class:i,clearable:e.value===$||null==e.value,"data-date-part":"timeZone",key:`${n}-timezone-input`,value:m.timeZoneOffset||"",onblur:()=>{this._focusedFieldInput=null},onCalciteInputTimeZoneChange:t=>this._saveValueFromDateComponent(e,t.target)}):null)}_renderDateFieldComponents(e,t){const{class:i,disabled:a,key:n,readOnly:s,min:l,max:o}=t,r=e.effectiveTimeZone,c=se(e.value===$?"":e.value,r),d=se(o,r),m=se(l,r),u=e.includeTime,h={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,overlayPositioning:"fixed",readOnly:s||a,[be]:t[be],[fe]:t[fe],onfocus:this._onComponentFocus};return pe("div",{class:D.dateInputContainer,key:`${n}-date-time-container`},pe("calcite-input-date-picker",{...h,class:i,"data-date-part":"date",key:`${n}-date-input`,max:d?.date??void 0,min:m?.date??void 0,topLayerDisabled:this.topLayerDisabled,value:c.date??"",onblur:()=>{this._focusedFieldInput=null},onCalciteInputDatePickerChange:t=>this._saveValueFromDateComponent(e,t.target)}),u?pe("calcite-input-time-picker",{...h,"data-date-part":"time",key:`${n}-time-input`,step:1,value:c.time??"",onblur:()=>{this._focusedFieldInput=null},onCalciteInputTimePickerChange:t=>{this._saveValueFromDateComponent(e,t.target)}}):null)}_renderRelationshipElementInput(e){return this._relatedRecordsEnabled?pe(Q,{afterObserverCreated:this._afterListObserverCreated,afterObserverRemoved:this._afterListObserverRemoved,input:e,messages:this.messages,messagesCommon:this.messagesCommon,viewModel:this.viewModel}):null}_renderRelationshipListPage(){const{activeRelationshipInput:e}=this.viewModel;if(e)return this._renderRelationshipElementInput(e)}_renderAttachmentElementInput(e){if(!this.attachmentsEnabled)return;const{allAttachmentsVisibleOnDefaultPage:t,attachments:i,defaultPageAttachments:a,template:{description:n,elementId:s,label:l}}=e,o=t?i:a;return pe("div",{class:D.attachmentElementInput,"data-testid":`attachment-element-${s}`,key:`attachment-element-${s}`},l?pe("div",{class:D.attachmentElementLabel,key:`attachment-element-label-${s}`},l):null,n?pe("div",{class:D.description,key:`attachment-element-description-${s}`},n):null,i.length?this._renderAttachmentList(e,o,{label:l||this.messagesCommon.details,viewAllCount:t?null:i.length}):pe("div",{class:D.attachmentElementEmptyState,key:`attachment-element-empty-state-${s}`},this.messages.attachments.noAttachments),this._renderAttachmentAddAction(e))}_renderAttachmentListPage(){const e=this.viewModel.selectedAttachmentListInput;if(e)return pe("div",{class:D.attachmentElementAllPanel,key:`attachment-element-all-panel-${e.template.elementId}`},this._renderAttachmentList(e,e.attachments,{filterEnabled:!0,label:this.messages.titles.attachments}))}_renderAttachmentList(e,t,i){const{filterEnabled:a,label:n,viewAllCount:s}=i;return pe("calcite-list",{class:D.attachmentElementList,filterEnabled:a,filterPlaceholder:a?this.messages.attachments.searchAttachments:void 0,filterProps:a?me:void 0,filterText:a?this._attachmentListFilterText:void 0,label:n,selectionAppearance:"border",selectionMode:"none",onCalciteListFilter:a?e=>{this._attachmentListFilterText=e.currentTarget.filterText??""}:void 0},this._renderAttachmentListItems(e,t),null!=s?this._renderViewAllAttachmentsItem(e,s):null)}_renderAttachmentListItems(e,t){const{elementId:i}=e.template;return t.map((t,a)=>{const n=this._formatAttachmentSize(t.size),s=this._getAttachmentLabel(t,a,n,e.displayFilename),l=s===n?void 0:n,o=C(t),r=e.isStagedAttachmentAddition(t),c=e.getAttachmentEditState(t),d=c.isDeleted,m=!d&&(r||c.isRenamed||c.isReplaced);return pe("calcite-list-item",{class:D.attachmentElementListItem,description:l,key:`attachment-item-${o}`,label:s,onCalciteListItemSelect:r||d?void 0:()=>this._setSelectedAttachment({attachmentKey:o,elementId:i})},pe("div",{class:D.attachmentElementListItemStart,slot:"content-start"},this._renderAttachmentPreviewThumbnail(t,s,e)),m?pe("span",{class:D.attachmentElementListItemStagedIndicator,slot:"content-end"}):null,r?[pe("calcite-action",{disabled:this.effectiveDisabled,icon:"x",scale:"s",slot:"actions-end",text:this.messagesCommon.delete,title:this.messagesCommon.delete,onclick:()=>this.viewModel.stageDeleteAttachment(i,C(t))})]:d?pe("calcite-chip",{label:this.messages.attachments.deleted,scale:"s",slot:"content-end"},this.messages.attachments.deleted):pe("calcite-icon",{flipRtl:!0,icon:"chevron-right",scale:"s",slot:"content-end"}))})}_renderViewAllAttachmentsItem(e,i){const{elementId:a}=e.template,{viewAll:n}=this.messages.attachments;return pe("calcite-list-item",{class:D.attachmentElementListItem,description:t(this.messages.attachments.count,{count:i}),key:`attachment-item-view-all-${a}`,label:n,onCalciteListItemSelect:()=>this._setAttachmentListElementId(a)},pe("calcite-icon",{flipRtl:!0,icon:"chevron-right",scale:"s",slot:"content-end"}))}_renderAttachmentAddAction(e){const{elementId:t}=e.template,i=this.effectiveDisabled||e.addDisabled,a=this._renderAttachmentCountLimitsLabel(e),n=this._getAttachmentNoticeMessage(e),s=e.hasMinimumAttachmentCountNotMet||e.hasExceededAttachmentLimit?"danger":"info",l=e.canUploadFiles,o=e.isCaptureOnly&&!this.effectiveDisabled&&!n;return pe("div",{class:D.attachmentElementAddActions,key:`attachment-element-add-actions-${t}`},l?pe("calcite-button",{appearance:"outline",disabled:i,iconStart:"attachment",kind:"neutral",round:!0,scale:"s",onclick:()=>this._setAttachmentAddElementId(t)},this.messages.attachments.attach):null,this._renderAttachmentCaptureButton(e),o?this._renderAttachmentCaptureDisabledNotice(t):null,a?pe("div",{class:D.attachmentElementEmptyActionHint},a):null,!this.effectiveDisabled&&n?pe("calcite-notice",{closable:!1,icon:"danger"===s?"exclamation-mark-circle":"lightbulb",kind:s,open:!0,scale:"s",width:"full"},pe("div",{slot:"message"},n)):null)}_renderAttachmentCaptureButton(e){if(!e.hasCaptureInputs)return null;const t=e.captureMediaType;return pe("calcite-button",{appearance:"outline",disabled:!0,iconStart:Ae(t),kind:"neutral",round:!0,scale:"s"},this._getCaptureButtonLabel(t))}_getAttachmentNoticeMessage(e){const t=this.messages.attachments;return e.hasUnsupportedFileTypeValidationError?this._getUnsupportedFileTypeMessage():e.hasMinimumAttachmentCountNotMet&&this._shouldShowMinimumAttachmentNotice(e)?t.minimumNotMet:e.hasExceededAttachmentLimit?t.attachmentLimitExceeded:e.hasReachedAttachmentLimit?t.attachmentLimitReached:null}_shouldShowMinimumAttachmentNotice(e){return e.hasAttachmentChanges||this.viewModel.submitHasBeenAttempted||this._touchedInputs.has(e.template.elementId)}_getCaptureButtonLabel(e){const{capture:t,recordAudio:i,takePhoto:a,takeVideo:n}=this.messages.attachments;switch(e){case"image":return a||t;case"video":return n||t;case"audio":return i||t;default:return t}}_renderAttachmentAddPage(){const e=this.viewModel.selectedAttachmentAddInput;return e?this._renderAttachmentAddPanel(e):null}_renderAttachmentAddPanel(e){const{maxAttachmentCount:t}=e,{elementId:i}=e.template;if(e.isCaptureOnly)return this._renderAttachmentCaptureDisabledNotice(i);const a=null==t||t-e.attachments.length>1,n=this.effectiveDisabled||e.addDisabled,s=this.messages.attachments,l=s.dragAndDropFile,o="upload",r=e=>{this._attachmentFileInputMap.set(i,e)};return pe("div",{class:D.attachmentElementAddPanel,key:`attachment-element-add-panel-${i}`},pe("input",{accept:e.accept,afterCreate:r,afterRemoved:()=>{this._attachmentFileInputMap.delete(i)},afterUpdate:r,class:D.attachmentElementFileInput,"data-element-id":i,disabled:n,multiple:a,type:"file",onchange:e=>{const t=e.currentTarget,a=t.files?Array.from(t.files):[];this._stageAttachmentFiles(i,a),t.value=""}}),pe("div",{class:D.attachmentElementAddDropzone,"data-disabled":n?"true":"false",ondragover:e=>{e.preventDefault()},ondrop:e=>{if(e.preventDefault(),n)return;const t=e.dataTransfer?.files?Array.from(e.dataTransfer.files):[];this._stageAttachmentFiles(i,t)}},pe("calcite-icon",{class:D.attachmentElementAddDropzoneIcon,icon:o,scale:"l"}),pe("div",{class:D.attachmentElementAddDropzoneHeading},s.addFile),pe("div",{class:D.attachmentElementAddDropzoneDetail,title:l},l),pe("calcite-button",{appearance:"transparent",disabled:n,iconStart:"folder-open",kind:"brand",scale:"s",type:"button",onclick:e=>{e.stopPropagation(),this._openAttachmentFilePicker(i,n)}},s.selectFile)),this._renderAttachmentValidationCriteria(e,{includeCountCriteria:!0}))}_renderAttachmentCaptureDisabledNotice(e){return pe("calcite-notice",{class:D.attachmentElementCaptureNotice,icon:!0,key:`attachment-element-capture-disabled-notice-${e}`,kind:"warning",open:!0,scale:"s"},pe("div",{slot:"message"},this.messages.attachments.captureMethodNotSupported))}async _stageAttachmentFiles(e,t){if(0===t.length)return;const i=this.viewModel.selectedAttachmentAddInput;let a=!0;try{a=(await this.viewModel.stageAddAttachments(e,t)).length>0&&!i?.hasInvalidValidationCriteria&&!i?.hasUnsupportedFileTypeValidationError}finally{a&&this.viewModel.setSelectedAttachmentAddElementId(null)}}_openAttachmentFilePicker(e,t){t||this._attachmentFileInputMap.get(e)?.click()}_renderAttachmentDetailPage(){const e=this.selectedAttachmentDetails;if(!e)return;if("replacing-attachment"===this.page)return this._renderAttachmentReplacePanel(e);const{attachment:t,input:i}=e,a=C(t),n=!!i.getAttachmentPreviewUrl(t),s=!this.effectiveDisabled&&i.canUploadFiles;return pe("div",{class:D.attachmentElementDetail,key:`attachment-detail-panel-${i.template.elementId}-${a}`},pe("div",{class:D.attachmentElementDetailPreview},this._renderAttachmentPreviewImageForInput(t,i)),pe("div",{class:D.attachmentElementDetailActions},y(t)?pe("calcite-button",{appearance:"outline",disabled:!n,iconStart:"expand",kind:"neutral",label:this.messages.attachments.maximize,scale:"m",title:this.messages.attachments.maximize,onclick:this._maximizeSelectedAttachment}):null,pe("calcite-button",{appearance:"outline",disabled:!n,iconStart:"download",kind:"neutral",label:this.messages.attachments.download,scale:"m",title:this.messages.attachments.download,onclick:()=>{this._downloadAttachment(t)}}),pe("calcite-button",{appearance:"outline",disabled:!s,iconStart:"upload-to",kind:"neutral",label:this.messages.attachments.replace,scale:"m",title:this.messages.attachments.replace,onclick:this._enterAttachmentReplaceView})),pe("div",{class:D.attachmentElementDetailMetadata},pe("div",{class:D.attachmentElementDetailMetadataGroup},pe("span",{class:D.attachmentElementDetailMetadataLabel},this.messages.attachments.fileName),this._renderFileNameContent(t,i)),pe("div",{class:D.attachmentElementDetailMetadataGroup},pe("span",{class:D.attachmentElementDetailMetadataLabel},this.messages.attachments.size),pe("span",{class:D.attachmentElementDetailMetadataValue},this._formatAttachmentSize(t.size))),pe("div",{class:D.attachmentElementDetailMetadataGroup},pe("span",{class:D.attachmentElementDetailMetadataLabel},this.messages.attachments.type),pe("span",{class:D.attachmentElementDetailMetadataValue},this._getLabelForAttachmentType(t)))))}_renderFileNameContent(e,t){if(!t.allowUserRename)return pe("span",{class:D.attachmentElementDetailMetadataValue},e.name);const i=t.getAttachmentEditState(e),{baseName:a,extension:n}=A(e.name),s=this.disabledOrReadOnly,l=!s&&0===e.name.trim().length;return[pe("div",{class:D.attachmentElementDetailFileNameRow,key:"file-name-row"},pe("calcite-input",{class:D.attachmentElementDetailFileNameInput,disabled:s,scale:"m",status:l?"invalid":"idle",suffixText:n,value:a,onCalciteInputInput:({currentTarget:e})=>this._renameSelectedAttachment(e.value)}),pe("calcite-button",{appearance:"transparent",disabled:s||null==i.initialName||!i.isRenamed,iconStart:"reset",kind:"neutral",scale:"m",title:this.messages.footerButtons.reset,onclick:this._resetSelectedAttachmentName})),l?pe("calcite-input-message",{icon:!0,key:"file-name-message",status:"invalid"},this.messages.validationErrors.cannotBeNull):null]}_renderAttachmentReplacePanel(e){const{attachment:t,input:i}=e,a=this.effectiveDisabled||!i.canUploadFiles,n=i.template.elementId;return pe("div",{class:D.attachmentElementAddPanel,key:`attachment-replace-panel-${n}-${C(t)}`},pe("input",{accept:i.accept,afterCreate:this._setSelectedAttachmentReplaceFileInput,afterRemoved:()=>{this._selectedAttachmentReplaceFileInput=null},afterUpdate:this._setSelectedAttachmentReplaceFileInput,class:D.attachmentElementFileInput,disabled:a,type:"file",onchange:e=>{const t=e.currentTarget,i=t.files?.[0];i&&this._stageSelectedAttachmentReplacement(i),t.value=""}}),pe("div",{class:D.attachmentElementAddDropzone,"data-disabled":a?"true":"false",ondragover:e=>{e.preventDefault()},ondrop:e=>{if(e.preventDefault(),a)return;const t=e.dataTransfer?.files?.[0];t&&this._stageSelectedAttachmentReplacement(t)}},pe("calcite-icon",{class:D.attachmentElementAddDropzoneIcon,icon:"refresh",scale:"l"}),pe("div",{class:D.attachmentElementAddDropzoneHeading},this.messages.attachments.replace),pe("div",{class:D.attachmentElementAddDropzoneDetail,title:this.messages.attachments.dragAndDropFile},this.messages.attachments.dragAndDropFile),pe("calcite-button",{appearance:"transparent",disabled:a,iconStart:"folder-open",kind:"brand",scale:"s",onclick:e=>{e.stopPropagation(),this._openSelectedAttachmentReplaceFilePicker()}},this.messages.attachments.selectFile)),this._renderAttachmentValidationCriteria(i,{includeCountCriteria:!1}),pe("div",{class:D.attachmentElementDetailMetadata},pe("div",{class:D.attachmentElementDetailMetadataGroup},pe("span",{class:D.attachmentElementDetailMetadataLabel},this.messages.attachments.fileToBeReplaced),pe("span",{class:D.attachmentElementDetailMetadataValue},t.name))))}_renderAttachmentDialog(){const e=this._attachmentDialogInfo;if(!e)return null;const{attachment:t,input:i}=e;return pe("calcite-dialog",{heading:t.name||this.messagesCommon.details,key:"attachment-preview-dialog",modal:!0,open:!0,placement:"cover",width:"l",onCalciteDialogClose:this._closeAttachmentDialog},pe("div",{class:D.attachmentElementDetailPreview},this._renderAttachmentPreviewImageForInput(t,i)))}_setSelectedAttachment(e){e?.elementId&&this._touchedInputs.add(e.elementId),this.viewModel.setSelectedAttachment(e),e||this.hideAttachmentDialog()}_setAttachmentAddElementId(e){e&&this._touchedInputs.add(e),this.viewModel.setSelectedAttachmentAddElementId(e),this.viewModel.selectedAttachmentAddInput?.clearValidationCriteriaState(),this.hideAttachmentDialog()}_setAttachmentListElementId(e){e&&this._touchedInputs.add(e),this.viewModel.setSelectedAttachmentListElementId(e),this.hideAttachmentDialog()}_getAttachmentLabel(e,i,a,n){return!1!==n&&v(e.name)&&e.name.length>0?e.name:a!==this.messagesCommon.notApplicable?a:t(this.messages.attachments.attachmentNumberedLabel,{index:i+1})}_renderAttachmentCountLimitsLabel(e){const t=this.messages.attachments,i=null!=e.minAttachmentCount&&e.minAttachmentCount>0?this._renderAttachmentCountLimitLabel(t.minAttachmentsShort,e.minAttachmentCount,"min"):null,a=null!=e.maxAttachmentCount?this._renderAttachmentCountLimitLabel(t.maxAttachmentsShort,e.maxAttachmentCount,"max"):null;return i||a?[i,i&&a?pe("span",{key:"attachment-count-limits-separator"},", "):null,a]:null}_renderAttachmentCountLimitLabel(e,i,a){const n="__count__",[s,l]=t(e,{count:n}).split(n);return pe("span",{key:a},s,pe("span",{class:D.attachmentElementEmptyActionHintValue},i),l)}_renderAttachmentValidationCriteria(e,{includeCountCriteria:t}){const i=this._getAttachmentValidationCriteria(e,{includeCountCriteria:t}),a=`attachment-validation-criteria-${e.template.elementId}`;return 0===i.length?null:pe("div",{class:D.attachmentElementValidationCriteria,key:a},i.map(({key:e,message:t,state:i})=>pe("calcite-notice",{appearance:"danger"===i?"outline-fill":"transparent",closable:!1,icon:!0,key:e,kind:i,open:!0,scale:"s",width:"full"},pe("div",{slot:"message"},t))))}_getAttachmentValidationCriteria(e,{includeCountCriteria:i}){const a=[],n=e.validationCriterionStates,s=this.messages.attachments,l=this._getNestableAttachmentInputs(e.input);e.hasUnsupportedFileTypeValidationError&&a.push({key:"unsupported-file-type",message:this._getUnsupportedFileTypeMessage(),state:"danger"});for(const o of l)"document"===o.type&&null!=o.maxFileSize&&a.push({key:"maximum-file-size",message:t(s.maximumFileSize,{maxSize:this._formatAttachmentSizeLimitInMegabytes(o.maxFileSize)}),state:n.get("maximum-file-size")??"info"}),"audio"===o.type&&null!=o.maxDuration&&a.push({key:"maximum-audio-length",message:t(s.maximumAudioLength,{maxDuration:this._formatAttachmentDurationLimit(o.maxDuration)}),state:n.get("maximum-audio-length")??"info"}),"video"===o.type&&null!=o.maxDuration&&a.push({key:"maximum-video-length",message:t(s.maximumVideoLength,{maxDuration:this._formatAttachmentDurationLimit(o.maxDuration)}),state:n.get("maximum-video-length")??"info"}),"image"===o.type&&null!=o.maxImageSize&&a.push({key:"maximum-image-size",message:t(s.attachmentMustBeSmallerThan,{maxSize:`${o.maxImageSize}px`}),state:n.get("maximum-image-size")??"info"});return i&&null!=e.minAttachmentCount&&e.minAttachmentCount>0&&a.push({key:"minimum-number-of-files",message:t(s.minimumNumberOfFiles,{count:e.minAttachmentCount}),state:n.get("minimum-number-of-files")??"info"}),i&&null!=e.maxAttachmentCount&&a.push({key:"maximum-number-of-files",message:t(s.maximumNumberOfFiles,{count:e.maxAttachmentCount}),state:n.get("maximum-number-of-files")??"info"}),a}_getNestableAttachmentInputs(e){return null==e?[]:"attachment"===e.type?e.inputTypes?.slice()??[]:[e]}_getUnsupportedFileTypeMessage(){return this.featureTableMessages.errorFileUnsupported}_formatAttachmentSize(e){return null==e||Number.isNaN(e)?this.messagesCommon.notApplicable:m(this.messagesUnits,e)}_formatAttachmentSizeLimitInMegabytes(e){return m(this.messagesUnits,1048576*e)}_formatAttachmentDurationLimit(e){return p(1e3*Math.round(e),{...e>=3600?{hour:"2-digit",hourCycle:"h23"}:{},minute:"2-digit",second:"2-digit",timeZone:"UTC"})}_getLabelForAttachmentType({contentType:e}){if(!e)return this.messagesCommon.notApplicable;const t=this.messages.attachments.attachmentTypes,i=f(e);return t?.[i]||e}_renderAttachmentPreviewThumbnail(e,t,i){const a=i.getAttachmentPreviewUrl(e,64);return a&&y(e)?pe("img",{alt:t,class:D.attachmentElementListItemThumb,src:a}):pe("calcite-icon",{class:D.attachmentElementListItemIcon,icon:_(e.contentType),scale:"s"})}_renderAttachmentPreviewImageForInput(e,t){const i=t.getAttachmentPreviewUrl(e),a=e.name||this.messagesCommon.details;return i&&y(e)?pe("img",{alt:a,class:D.attachmentElementDetailPreviewImage,src:i,title:a}):[pe("calcite-icon",{class:D.attachmentElementDetailPreviewIcon,icon:_(e.contentType),scale:"l",textLabel:a,title:a}),this.messages.attachments.noPreviewAvailable]}async _downloadAttachment(e){await ee(e)}_canReplaceSelectedAttachment(){return!this.effectiveDisabled&&!!this.selectedAttachmentDetails?.input.canUploadFiles}_exitAttachmentReplaceView(){this.viewModel.setShowingSelectedAttachmentReplacePage(!1),this._selectedAttachmentReplaceFileInput=null}async _stageSelectedAttachmentReplacement(e){const t=this.selectedAttachmentDetails;if(!t?.attachment)return;const i=t.input.template.elementId,a=C(t.attachment);let n=!1;try{n=await this.viewModel.stageReplaceAttachment(i,a,e)}finally{n&&this._exitAttachmentReplaceView()}}_renameSelectedAttachment(e){const t=this.selectedAttachmentDetails;if(!t?.attachment)return;const i=t.input.template.elementId,a=C(t.attachment);this.viewModel.stageRenameAttachment(i,a,e)}_resetSelectedAttachmentChanges(){const e=this.selectedAttachmentDetails;e?.attachment&&this.viewModel.resetAttachmentChanges(e.input.template.elementId,C(e.attachment))}_deleteSelectedAttachment(){const e=this.selectedAttachmentDetails;if(!e?.attachment||this._isSelectedAttachmentDeleteDisabled())return;const t=e.input.template.elementId,i=C(e.attachment);this.viewModel.stageDeleteAttachment(t,i),this._setSelectedAttachment(null)}_isSelectedAttachmentDeleteDisabled(){return this.disabledOrReadOnly}hideAttachmentDialog(){this._attachmentDialogInfo=null}_renderTextComponent(e){const{elementId:t}=e.template;return pe("div",{class:D.textElementInput,"data-testid":`text-element-${t}`,innerHTML:e.text,key:`text-element-${t}`})}_renderUtilityNetworkAssociationsElementInput(e){if(!this._associationsEnabled)return;const{elementId:t}=e.template;return pe("div",{class:D.utilityNetworkAssociationsElementInput,"data-testid":t,key:t},this._associationsWidgetsMap.get(e)?.render())}getCommonInputProps(e){const{template:t,valid:i,value:a,minLength:n,maxLength:s,required:l,fieldName:o,editable:r,userHasChangedValue:c,range:{max:d,min:m}}=e,u=!r||this.readOnly,h=!u&&(this.disabled||this.viewModel.updating);let p=t.hint??void 0,g=!1;return a===$&&(p=this.messages.differentValuesPlaceholder,g=!0),{afterCreate:this._afterComponentCreateOrUpdate,afterUpdate:this._afterComponentCreateOrUpdate,"aria-invalid":i?"false":"true",class:this.classes(D.fieldInput,u?D.inputDisabled:null),status:!c&&!this.viewModel.submitHasBeenAttempted||i?"idle":"invalid",maxLength:s&&s>-1?s:void 0,minLength:n&&n>-1?n:void 0,key:t.elementId,label:o,name:o,max:null!=d?d:void 0,min:null!=m?m:void 0,disabled:h,readOnly:u,onblur:this._onComponentBlur,required:l,placeholder:p,value:g?"":a??"",[be]:t.elementId,[fe]:o,onfocus:this._onComponentFocus}}_onObserverChange(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode);const e=this.viewModel.activeRelationshipInput;e&&this._listObserverNode&&e.showAllEnabled&&this._listObserver.observe(this._listObserverNode)}_onFormSubmit(e){e.preventDefault()}_getFieldInputFromHTMLElement(e){return this.viewModel.findFieldInput(e.getAttribute(be))}_afterRadioGroupCreateOrUpdate(e){const t=e.selectedItem,i=e.querySelector("calcite-radio-button"),a=t||i;a&&this._afterComponentCreateOrUpdate(a)}_onComponentFocus(e){const t=e.target,i=this._getFieldInputFromHTMLElement(t);this._isMultipleChoiceCheckbox(t,i)||this._markFieldInputTouched(i),this._focusedFieldInput=i}_markFieldInputTouched(e){this._touchedInputs.add(e.template.elementId)}_isMultipleChoiceCheckbox(e,t){return"CALCITE-CHECKBOX"===e.tagName&&null!=t.multipleChoiceInput}_afterComponentCreateOrUpdate(e){const t=this._getFieldInputFromHTMLElement(e),i=this._focusedFieldInput;this._attemptFocusOnNextRender&&i===t&&(this._attemptFocusOnNextRender=!1,ge(e))}_onComponentBlur(){this._focusedFieldInput=null}_resetTransientFormState(){this._attemptFocusOnNextRender=!1,this._focusedFieldInput=null,this._attachmentDialogInfo=null,this._selectedAttachmentReplaceFileInput=null,this._attachmentListFilterText="",this._attachmentFileInputMap.clear(),this._touchedInputs.clear()}_parseValue(e,t,i=!1){const a=t.multipleChoiceInput,n=t.multipleChoiceValues;if(a&&n){const s=a.choiceDelimiter,l=e;if(i){return q({input:t}).checked?null:n.length>0?n.join(s):null}const o=K(t.value,s).filter(e=>e!==$),r=new Set(o);l.checked?r.add(l.value):r.delete(l.value);const c=n.filter(e=>r.has(e));return c.length?c.join(s):null}if(F(t.template,"switch")){if("calcite-dropdown"===e.localName&&t.domain)for(const i of t.domain.codedValues)if(i.name===e.selectedItems[0].textContent)return i.code;return e.checked?t.template.input.onValue:t.template.input.offValue}const s=e.value;return null==s||""===s?null:"number"===t.dataType?"-0"===s||"-0."===s||"-0,"===s?s:parseFloat(s):"date"===t.field.type?parseFloat(s):s}_saveInputFromElement(e){const t=this._getFieldInputFromHTMLElement(e);if(!t)return;const i=this._parseValue(e,t);this._saveInput(t,i)}_saveInput(e,t){const{elementId:i}=e.template,a=e?.value,{viewModel:s}=this;if(F(e.template,"switch")&&"single"!==s.mode){const t=n(this._batchSwitchInputInitialValues,e,()=>e.value);this._batchSwitchInputInitialValues.set(e,null===t?a:t)}t!==a&&(e.isSubtypeField&&"batch"!==s.mode&&k(s.activeLayer,a,t)?this._pendingSubtypeChoice||(this._pendingSubtypeChoice=this._handleSubtypeChoice(e,t)):s.setValue(i,t))}async _handleSubtypeChoice(e,i){const{value:a,template:n}=e,{elementId:s}=n,{messages:l,viewModel:o,messagesCommon:r}=this,{subtypes:c,activeFeatureIndex:d}=o;if(await o.setValue(s,i),!c?.length)return;const m=c.find(e=>e.code===i),u=c.find(e=>e.code===a)?.name??`${a}`;if(!m)return;const h=Promise.withResolvers();o.pendingSubtypeChoice=h;let p="update-fields";const g=[{label:l.subtypes.useDefaultValuesOption,value:"update-fields"},{label:l.subtypes.keepCurrentValuesOption,value:"keep-existing"}],v={context:"info",title:l.subtypes.changeWarningTitle,message:t(l.subtypes.changeWarning,{originalType:u,newType:m.name}),radios:g,defaultRadioSelection:"update-fields",onRadioSelection:e=>{p=e},actions:{primary:{label:r.apply,action:()=>h.resolve(p),type:"positive"},secondary:{label:r.cancel,type:"neutral",action:()=>h.resolve("undo")}},cancel:()=>h.reject()};try{this.showPrompt(v);switch(await h.promise){case"update-fields":await o.applySubtypeDefaults(m),await o.handleSubtypeChanged(d);break;case"keep-existing":await o.handleSubtypeChanged(d);break;case"undo":await this.viewModel.setValue(s,a)}}finally{o.pendingSubtypeChoice=null,this.clearPrompt(),this._pendingSubtypeChoice=null}}_afterDateComponentCreate(e){this._setDateTimeTimeZoneMap(e),this._afterComponentCreateOrUpdate(e)}_saveValueFromDateComponent(e,t){const{elementId:i}=e.template,a=e.field.type,n=this._dateComponentMap.get(`${i}`);if(!n)return;const s=e.effectiveTimeZone;let l=e.value===$?void 0:e.value,o=null;"date-only"===a?o=Array.isArray(t.value)?t.value[0]:t.value:"time-only"===a?(l=le(l),o=le(t.value)):o="timestamp-offset"===a?null!=t.value?oe({dateComponent:n.date,timeComponent:n.time,oldValue:l,timeZoneComponent:n.timeZone,defaultTimeZone:s}):null:null!=t.value?re({oldValue:l,dateComponent:n.date,timeZone:s,timeComponent:n.time?.value===$?void 0:n.time}):null,l!==o&&(null!==o&&t.value?this.viewModel.setValue(`${i}`,o):this.viewModel.setValue(`${i}`,null))}_getErrorToDisplay(e){const t=e.compositeError;return e.valid||!t?null:"contingent-values-validation-error::contingency-violation-error"===t||"contingent-values-validation-error::contingency-violation-warning"===t||this._touchedInputs.has(e.template.elementId)||this.viewModel.submitHasBeenAttempted?t:null}_renderViewingAssociationsPage(){return this._associationsList?.render()}_onActiveAssociationsInputChange(e){const t=this._associationsList;t&&(e?(t.associationInput=e,t.viewModel=e.viewModel):t.associationInput=null)}async _setUpAssociationsWidgets(){const e=this.viewModel.activeForm.allUtilityNetworkAssociationsElementInputs;if(this._associationsEnabled&&0!==e.length){await this._setUpUtilityNetworkAssociationList();for(const t of e)this._associationsWidgetsMap.set(t,await this._createAssociationsWidget(t))}}async _setUpUtilityNetworkAssociationList(){if(this._associationsList)return;const e=(await import("./FeatureForm/FeatureFormUtilityNetworkAssociations/FeatureFormUtilityNetworkAssociationList.js")).default;this._associationsList=new e({onSelectLayer:this._onSelectAssociatedLayer.bind(this),onSelectFeature:this._onEditAssociatedFeature.bind(this),onAddAssociation:this._onAddAssociation.bind(this)});const t=this.viewModel.activeAssociationsInput;t&&(this._associationsList.associationInput=t,this._associationsList.viewModel=t.viewModel)}async _createAssociationsWidget(e){return new(0,(await import("./Feature/FeatureUtilityNetworkAssociations.js")).default)({viewModel:e.viewModel,onSelectAssociationType:t=>this._onSelectAssociationType(e,t)})}_destroyAssociationsWidgets(){this._associationsWidgetsMap.forEach(e=>s(e)),this._associationsWidgetsMap.clear()}_onSelectAssociationType(e,{listType:t}){this.setActiveAssociationsInput(e),this.setActiveAssociationType(t)}_onSelectAssociatedLayer({layer:e}){this.setActiveAssociationsLayer(e)}async _onEditAssociatedFeature(e){const t=this.callbacks?.editAssociatedFeature,i=this.viewModel.activeAssociationsInput;if(!t||!i?.feature)return;const{association:a,feature:n}=e;await t({parentFeature:i.feature.plainGraphic,association:a,feature:n})}_onAddAssociation(e){const t=this.callbacks?.addAssociation,i=this.viewModel.activeAssociationsInput;if(!t||!i?.feature)return;const{associationType:a,utilityNetwork:n}=e;t({feature:i.feature.plainGraphic,associationType:a,utilityNetwork:n})}_getSelectedAttachmentEditState(){const e=this.selectedAttachmentDetails;if(e)return e.input.getAttachmentEditState(e.attachment)}_setFocusableInput(e){const t=e&&R(e)?e:this._findFocusableInput(e);this._syncGroupInputStates(),this._focusedFieldInput=t,this._attemptFocusOnNextRender=!0}_findFocusableInput(e){const t=this.viewModel.activeForm.inputs;if(!t.length)return;const i=M(t);let a;if(e)if(V(e)){const t=e.inputs.find(e=>e.visible);a=t?i.indexOf(t):0}else{let n;if(j(e)&&!e.group.open){n=e.group.inputs.filter(R)[t.length-1]}else n=e;a=i.indexOf(n)+1}else a=0;for(let n=a;n<i.length;n++){const e=i[n];if(e.visible&&R(e)){if(this.disabledOrReadOnly&&("switch"===e?.inputType||"radio-buttons"===e?.inputType))continue;return e}}return null}_onGroupToggle(e,t){e.expanded?(t.open=!0,this._setFocusableInput(t),"sequential"===this.groupDisplay&&this.viewModel.activeForm.allGroupInputs.forEach(e=>{e!==t&&(e.open=!1)})):t.open=!1,this.scheduleRender()}_syncGroupInputStates(){if("sequential"!==this.groupDisplay)return;const e=this.viewModel.activeForm?.allGroupInputs;if(!e.length)return;const t=e.filter(e=>e.open);0===t.length?e[0].open=!0:t.length>1&&t.slice(1).forEach(e=>e.open=!1)}};function Ae(e){switch(e){case"audio":return _("audio/mpeg");case"video":return _("video/mp4");case"image":return _("image/png");default:return"camera"}}e([u()],ye.prototype,"activeFeatureIndex",null),e([u()],ye.prototype,"attachmentsEnabled",null),e([u()],ye.prototype,"callbacks",null),e([u()],ye.prototype,"disabled",null),e([u()],ye.prototype,"effectiveTitle",null),e([u()],ye.prototype,"effectiveDisabled",null),e([u()],ye.prototype,"disabledOrReadOnly",null),e([u()],ye.prototype,"features",null),e([u()],ye.prototype,"footerButtonInfos",null),e([u()],ye.prototype,"map",null),e([u()],ye.prototype,"maximumFeatureCount",null),e([u()],ye.prototype,"maximumFeatureCountWithComplexForms",null),e([u()],ye.prototype,"spatialReference",null),e([u()],ye.prototype,"layerInfos",null),e([u()],ye.prototype,"timeZone",null),e([u()],ye.prototype,"headingLevel",void 0),e([u()],ye.prototype,"icon",null),e([u(),ue("esri/t9n/common")],ye.prototype,"messagesCommon",void 0),e([u(),ue("esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm")],ye.prototype,"messages",void 0),e([u(),ue("esri/widgets/FeatureForm/t9n/FeatureForm")],ye.prototype,"featureFormMessages",void 0),e([u(),ue("esri/widgets/FeatureTable/t9n/FeatureTable")],ye.prototype,"featureTableMessages",void 0),e([u(),ue("esri/core/t9n/Units")],ye.prototype,"messagesUnits",void 0),e([u()],ye.prototype,"page",null),e([u()],ye.prototype,"readOnly",null),e([u()],ye.prototype,"showPrompt",null),e([u()],ye.prototype,"clearPrompt",null),e([u()],ye.prototype,"selectedAttachment",null),e([u()],ye.prototype,"selectedAttachmentDetails",null),e([u()],ye.prototype,"valid",null),e([u({type:x}),he(["attachments-change","value-change","values-change","submit"])],ye.prototype,"viewModel",void 0),e([u({type:T,nonNullable:!0})],ye.prototype,"visibleElements",void 0),e([u()],ye.prototype,"groupDisplay",void 0),e([u()],ye.prototype,"_formHeaderVisible",null),e([u()],ye.prototype,"_associationsEnabled",null),e([u()],ye.prototype,"_associationsList",void 0),e([u()],ye.prototype,"_attemptFocusOnNextRender",void 0),e([u()],ye.prototype,"_formId",null),e([u()],ye.prototype,"_focusedFieldInput",void 0),e([u()],ye.prototype,"_pendingSubtypeChoice",void 0),e([u()],ye.prototype,"_relatedRecordsEnabled",null),e([u()],ye.prototype,"_listObserverNode",void 0),e([u()],ye.prototype,"_attachmentDialogInfo",void 0),e([u()],ye.prototype,"_attachmentListFilterText",void 0),e([u()],ye.prototype,"_prompt",void 0),e([u()],ye.prototype,"test",null),ye=e([h("esri.widgets.BatchAttributeForm")],ye);const we=ye;export{we as default};
@@ -1,2 +1,2 @@
1
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/Collection.js";import i from"../../core/Error.js";import{makeHandle as r,handlesGroup as s,abortHandle as n}from"../../core/handleUtils.js";import"../../core/has.js";import o from"../../core/Logger.js";import{removeMaybe as l,destroyMaybe as d}from"../../core/maybe.js";import{isPromiseLike as c,debounce as u}from"../../core/promiseUtils.js";import{watch as p,initial as h,sync as m,whenOnce as f,syncAndInitial as g}from"../../core/reactiveUtils.js";import{generateBracedUUID as w}from"../../core/uuid.js";import{property as y,subclass as v}from"../../core/accessorSupport/decorators.js";import{isSharedTemplateOrMetadata as F,isSharedTemplate as _,getCreationAttributes as M,isStandardFeatureTemplate as b}from"../../editing/templateUtils.js";import{getFullTemplate as I}from"../../editing/sharedTemplates/templateLoader.js";import V from"../../layers/GraphicsLayer.js";import{isSceneLayer as k,isTable as S}from"../../layers/support/layerUtils.js";import{isNumber as T}from"../../support/guards.js";import{getDisplayedSymbol as P}from"../../symbols/support/symbolUtils.js";import{updateGraphicSymbolWhenRequired as E}from"../../views/draw/support/editingSessionUtils.js";import{getDrawHelpMessage as A}from"../../views/draw/support/helpMessageUtils.js";import U from"../../views/draw/support/HighlightHelper.js";import H from"../../views/interactive/sketch/SketchOptions.js";import C from"../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{temporaryHighlightName as L}from"../../views/support/HighlightDefaults.js";import O from"../BatchAttributeForm/BatchAttributeFormViewModel.js";import j from"./CreateFeaturesWorkflowData.js";import{isModelUpload as x,handleModelUpload as D}from"./modelUploadUtils.js";import z from"./Workflow.js";import{activeSketchToolDrawsUnsupportedCurve as R,createToolFromGeometryType as G,containsUnsupportedCurve as W,findEditorItemForLayer as N,getServiceEditsFromWorkflowData as B,getServiceInfoForLayer as K,orderEditsByRelationshipDependencies as Z,getServiceLayersById as q,startCreatingNewFeature as J,syncUpdateOptions as Q,findLayerInfo as X,handleFormValuesChangeEvent as Y,isTerminalUpdateEventType as $,getVisualVariableAttributes as ee,startUpdatingFeatureGeometry as te,createWorkflowSteps as ae,avoidFeatureTemplateSelectionWithOnlyOneItem as ie,setUpSketchCreateWatchers as re,setRelationshipFields as se,prepareAttachmentsForCreateFeaturesWorkflow as ne,showProgressCursor as oe,setVisualVariablesAndElevationInfoForUpdate as le,visualVariableInteractiveUpdate as de}from"./workflowUtils.js";import{makeServiceEditsWithAttachments as ce,makeEditsWithAttachments as ue,parseEditResultsAndCollectAddAttachmentData as pe}from"./support/attachmentUtils.js";import he from"../Sketch/SketchViewModel.js";var me;const fe=Symbol(),ge=Symbol(),we=Symbol(),ye=Symbol(),ve={point:["point"],multipoint:["multipoint"],polygon:["polygon","freehandPolygon","rectangle","circle"],polyline:["polyline","freehandPolyline"],mesh:[],multipatch:[]};let Fe=me=class extends z{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 O({attachmentsEnabled:!0}),this._sketchLayer=null,this._sketchViewModel=null,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.formViewModel.canGoBack||this._stepIndex>0||"update-pending"===this.createFeatureState&&!!this.data.selectedPendingFeature&&!this.parent&&!x(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,n=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?.(n,e):void 0}const{activeCreateToolDrawMode:o,activeTool:l}=a;return A("rectangle"===l||"circle"===l?l:s,n?.geometry,o)}get noticeMessage(){if(R(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:!k(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(F(this.data.fullTemplate)){const{tool:t}=G(e,this.data.fullTemplate);return[t]}return"2d"!==t?.type&&"multipoint"===e?[]:[...ve[e]]}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([we])}async updatePendingFeature(e){if(e!==this.data.selectedPendingFeature)return this._sketchViewModel.cancel(),this._startUpdating({feature:e})}async start(){return await super.start(),S(this.data.creationInfo?.layer)?null:{enter:async()=>{},exit:async()=>{},viewModel:this._sketchViewModel}}async save(e){const{formViewModel:t}=this;if(t.pendingSubtypeChoice)return;await 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 await(t?.submit());const{pendingFeatures:r,editorItem:s}=this.data;if(s&&e&&W(r.toArray(),s)){if(!await e("curveEditingDensifyPrompt"))return this.reset()}return super.save()}back(e){return this._formViewModel.canGoBack?this._formViewModel.goBack():"update-pending"!==this.createFeatureState||!this.data.selectedPendingFeature||x(this.data.creationInfo)||this.parent?super.back(e):this._clearSelectedFeature()}previous(e){return this._formViewModel.canGoBack?this._formViewModel.goBack():"update-pending"===this.createFeatureState&&this.data.selectedPendingFeature&&!x(this.data.creationInfo)?this._clearSelectedFeature():super.previous(e)}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{applyEdits:t,applyEditsFeatureService:a,addAttachmentsCallback:i,isNested:r,creationInfo:s,parent:n,snappingManager:o,startAt:l,viewModel:d}=e,c=e.sketchOptions??new H,u=s?.layer,p=u?N(d.editorItems,u):void 0,h=new me({data:new j({creationInfo:s,editorItem:p,parent:n,sketchOptions:c,snappingManager:o,viewModel:d}),isNested:r,onCommit:async e=>{const{creationInfo:r}=e;if(!r)return;h._sketchViewModel.cancel();const s=e.pendingFeatures.toArray(),{layer:n}=r,o=n.capabilities?.editing.supportsGlobalId&&"globalIdField"in n,{fullTemplate:l}=e,c=B(h.data),u=_(l)&&c;if(o){if(be(s),u){let t=ce(c,e);const i=await(K(n,d.view)?.load());i&&(t=Z({edits:t,serviceInfo:i,view:d.view,findOriginalFeature:t=>e.getEditsForPendingFeature(t)?.initialFeature??t})),await a(l.featureService,t,{globalIdUsed:!0,honorSequenceOfEdits:!0,gdbVersion:l.layer.gdbVersion??void 0})}else await t(n,ue(s,e),{globalIdUsed:!0});return}const p=u?await a(l.featureService,c,{gdbVersion:l.layer.gdbVersion??void 0}):[await t(n,{addFeatures:s})];p?.length&&e.attachmentsModified&&!o&&await Promise.all(p.map(t=>{if(!t?.addFeatureResults)return;const a=pe(s,t.addFeatureResults,n,e);return i(n,a)}))}});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)",r(()=>e.effect=t)}const t=e.opacity;return e.opacity=.7,r(()=>e.opacity=t)}async _initializeFullTemplateAndExecutorInfo(e){const{creationInfo:t}=e,{view:a}=e.viewModel;if(!t||!a)return null;const i=await I(a,t.template);if(e.fullTemplate=i,i&&_(i)){const{createTemplateExecutor:r}=await import("../../editing/sharedTemplates/executor/createTemplateExecutor.js"),s={completionResults:[],executor:await r(i),serviceLayersById:q(t.layer,a)};e.templateExecutorInfo=s}return i}async _startCreating(){this.removeHandles(ge);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 J(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=l(this._featureFormHandle),this._formViewModel.features=new a,this._formViewModel.activeFeatureIndex=-1;const t=this.data.viewModel.attachmentsViewModel;"add"!==t.mode&&"edit"!==t.mode||await(this.data.viewModel.activeWorkflow?.previous())}_stashValidationState(){const e=this._formViewModel.activeFeature,t=e&&this.data.getEditsForPendingFeature(e);t&&(t.submittable=this._formViewModel.valid)}async _selectFeatureForUpdate({feature:e,initialFeature:t=e}){this._stashValidationState();const{data:i,pendingFeatures:r}=this;r.includes(e)||i.addPendingFeature(e,t),i.selectedPendingFeature=e;const{_formViewModel:n,_sketchViewModel:o,sketchUpdateOptions:d}=this,{creationInfo:c,viewModel:u}=i,{layerInfos:h,view:m}=u;if(!m||!c)return;Q(o,d),l(this._featureFormHandle);const f=e.sourceLayer,g=X(h,f),w=m.spatialReference;n.set({editType:"INSERT",features:new a([e]),activeFeatureIndex:0,layerInfos:g?[g]:null,spatialReference:w,map:m.map}),await E(e,"2d"===m.type?m.scale:null);const y=i.getEditsForPendingFeature(e);y?.attachmentsModified&&n.applyStashedAttachmentEdits(y.attachmentEdits),this._featureFormHandle=s([n.on("values-change",Y({filter:e=>e===y?.feature,forEachValueChange:(e,t)=>{if(T(t)){const a=this._visualVariableAttributes;a.size&&!a.size.isUpdatingInteractively&&e===a.size.field&&a.size.setInitialValue(t),a.rotation&&!a.rotation.isUpdatingInteractively&&e===a.rotation.field&&a.rotation.setInitialValue(t)}},forEachFeature:e=>{y?.updateAttributes(n.getValues(e)),E(e,"2d"===m.type?m.scale:null)}})),n.on("attachments-change",e=>y?.setAttachmentEdits(e.attachmentEdits)),o.on(["update","undo","redo"],t=>{("undo"===t.type||"redo"===t.type||"update"===t.type&&null!=t.toolEventInfo&&$(t.toolEventInfo.type))&&n.notifyGeometriesChanged([e])}),p(()=>n.activeFeature?.sourceLayer,t=>e.sourceLayer=t),p(()=>[n.activeFeature,n.valid],()=>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:n}=r,{view:o}=n;if(!o||!s)return;const l=e.sourceLayer??s.layer;return S(l)?void 0:(this._visualVariableAttributes=ee(e),te({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=ae(["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&&(x(t)?e.addHandles(await D({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){t.canceled&&e.removeHandles([we,fe,ge,ye])}}),"adding-attachment":()=>({id:"adding-attachment",parent:"creating-features",async setUp(){},async tearDown(){}}),"editing-attachment":()=>({id:"editing-attachment",parent:"creating-features",async setUp(){},async tearDown(){}})});return ie(a,i)}static _configureSketchViewModel(e){const{data:t,_sketchLayer:a,_sketchViewModel:i}=e,{creationInfo:n,viewModel:o}=t,{view:l}=o,d=[];if(!l)return r();if("2d"===l.type){n&&d.push(e._fadeExistingFeatures(n.layer));const t=u((e,t)=>Promise.all(e.map(e=>E(e,t))));d.push(p(()=>l.scale,e=>t(a.graphics,e)))}const c=M(t.fullTemplate,n?.attributeOverrides,n?.layer),h=p(()=>i.createGraphic&&i.activeComponent,()=>{i.createGraphic&&i.activeComponent&&!e.hasHandles(ge)&&e._updatingHandles.consumePromise(re({creationAttributes:c,data:t,sketchViewModel:i,view:l}).then(t=>e.addHandles(t,ge)))}),m=async t=>{if("cancel"!==t.state&&"complete"!==t.state||e.removeHandles(ge),"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 r=>{const{attachmentsViewModel:s}=o,{_formViewModel:d}=e;if(r.graphics.length>1)return void await e._clearSelectedFeature();const c=r.graphics[0];if("complete"===r.state){if(e.numPendingFeatures!==n?.maxFeatures&&d.valid||d.submit(),await e._clearSelectedFeature(),"add"!==s.mode&&"edit"!==s.mode||await(o.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"===r.state)return c.sourceLayer??=t.creationInfo?.layer,await le({graphic:c,sketchLayer:a,sketchViewModel:i,visualVariables:e._visualVariableAttributes,sourceLayer:c.sourceLayer}),e._selectFeatureForUpdate({feature:c});if("active"===r.state){await e.updatePendingFeature(c);const t=e._visualVariableAttributes;de(l,c,r,t)&&await E(c,"2d"===l.type?l.scale:null);const a=c.attributes,{rotation:i,size:s}=t;if(null!=i){const{field:t}=i;e._updatingHandles.consumePromise(d.setFieldValue(t,a[t]))}if(null!=s){const{field:t}=s;e._updatingHandles.consumePromise(d.setFieldValue(t,a[t]))}}}},g=async a=>{if(a.graphics.forEach(e=>{t.removePendingFeature(e)}),!x(t.creationInfo))return e._startCreating()},w=async()=>{if(x(t.creationInfo))try{await e.data.viewModel.back()}catch{}return e._startCreating()};d.push(h,i.on("create",t=>e._updatingHandles.addPromise(m(t))),i.on("update",t=>e._updatingHandles.addPromise(f(t))),i.on("delete",t=>e._updatingHandles.addPromise(g(t))),e._updatingHandles.addWhen(()=>!e.numPendingFeatures,()=>e._updatingHandles.addPromise(w())),r(()=>{i.cancel()}),_e(i,a,t),...Me(t));const y=s(d);return i.addHandles(y),y}_initializeSketchViewModel(){const{data:e}=this,{view:t}=e.viewModel,a=new V({elevationInfo:e.creationInfo?.layer.elevationInfo,internal:!0,listMode:"hide",title:"createFeaturesWorkflow-internal"}),i=new he({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=i,t?.map.add(a),this.addHandles([r(()=>{t?.destroyed||t?.map.remove(a),d(a)}),p(()=>this.numPendingFeatures>0,e=>this._sketchViewModel.updateOnGraphicClick=e,h),p(()=>this.sketchUpdateOptions,e=>{i.defaultUpdateOptions=e,Q(i,e)},m)])}_hasValidationErrors(e){return!!e&&!this.data.isSubmittable(e)}async _processEdits(e,t){const{data:i,_formViewModel:r,_sketchLayer:s}=this,{layerInfos:n,view:o}=i.viewModel;r.editType="INSERT",r.map=o?.map,r.spatialReference=o?.spatialReference;const{templateExecutorInfo:l}=i;if(!l){const t=e.clone();return t.geometry=null,await this._addAndInitializeEdits(e,t),e}s.remove(e);const{executor:d}=l,u=d(e.geometry,"completion"),p=c(u)?await u:u;l.completionResults.push(p),se(p.relationships),r.editType="INSERT",r.map=o?.map,r.spatialReference=o?.spatialReference,p.primary&&i.creationInfo?.attributeOverrides&&(p.primary.graphic.attributes={...p.primary.graphic.attributes,...i.creationInfo.attributeOverrides});for(const a of p.edits){let e=null;if(a.addFeatures)for(const i of a.addFeatures){const a=i.clone();a.geometry=null,null!=i.geometry&&(i.symbol=await P(i,t),s.add(i)),i.sourceLayer!==e?.layer&&(e=X(n,i.sourceLayer));const r=!!p.associationGraphics?.has(i);await this._addAndInitializeEdits(i,a,e,r)}}r.features=new a,r.activeFeatureIndex=-1,await f(()=>!r.updating);return p.edits.reduce((e,t)=>e+(t.addFeatures?.length??0),0)>1?null:p.primary?.graphic}async _addAndInitializeEdits(e,t,i,r=!1){const{data:s,_formViewModel:n}=this,{layerInfos:o}=s.viewModel,l=s.addPendingFeature(e,t,{isAssociation:r});i??=X(o,e.sourceLayer),n.features=new a([e]),n.activeFeatureIndex=0,n.layerInfos=i?[i]:null,await f(()=>!n.updating),l.updateAttributes(n.getValues(e)),l.submittable=n.valid}async _setUpCreatingFeaturesStep(){if(this.hasHandles(we))return;const{data:e,sketchViewModel:a}=this,{creationInfo:n,viewModel:o}=e,{attachmentsViewModel:d,view:c}=o;if(!c||!n?.layer)throw new i("missing-parameters","CreateFeaturesWorkflow requires a view and creationInfo.");const{initialFeature:u,layer:m}=n,f=[],g=[];this._featureFormHandle=l(this._featureFormHandle),this._visualVariableAttributes={rotation:null,size:null},e.editorItem=N(o.editorItems,n.layer),n.template&&(null==e.fullTemplate&&await this._initializeFullTemplateAndExecutorInfo(e),g.push(r(()=>{e.templateExecutorInfo&&(e.templateExecutorInfo.completionResults=[])}))),a.allowDeleteKey=!e.isSharedTemplateWorkflow,ne(d),f.push(p(()=>d.mode,e=>{switch(e){case"add":this.go("adding-attachment");break;case"edit":this.go("editing-attachment")}}));const w=oe(c);f.push(w);const y=S(n.layer),{template:v}=n,_=!v||b(v)||F(v)&&"feature"===v.type,I=y&&_;try{if(I){const a=u??new t({attributes:M(e.fullTemplate,n.attributeOverrides,m),sourceLayer:m}),i=await this._processEdits(a);i&&await this._startUpdating({feature:i})}else f.push(me._configureSketchViewModel(this)),u?(x(n)&&n.geometryToPlace&&(u.attributes=M(e.fullTemplate,n.attributeOverrides,m)),a.addGraphic(u),await this._startUpdating({feature:u})):await this._startCreating()}finally{w.remove()}const V=r(()=>{for(const t of e.pendingFeatures)a.removeGraphic(t),e.removePendingFeature(t)}),k=p(()=>c?.timeZone,e=>{this._formViewModel.timeZone=e,this.data.timeZone=e},h),T=r(()=>{x(n)&&o.cancelWorkflow({warnIfNoWorkflow:!1})});this._featureFormHandle&&f.push(this._featureFormHandle),this.addHandles(f,this._handleKeys.beforeCommit),this.addHandles(g,this._handleKeys.afterCommit),this.addHandles([r(()=>d.fileInfos.removeAll()),s(f),s(g),T,V,k],we)}async _waitForActiveToolCleared(){const e=this.data.viewModel.view;if(null==e?.activeTool)return;const t=new AbortController;this.addHandles(n(t),ye),await f(()=>null==e?.activeTool,t.signal),t.abort()}};function _e(e,t,a){let i=null;const n=()=>e.snappingOptions.featureSources,o=()=>(i=new C({layer:t}),n().add(i),i),l=()=>{null!=i&&(n().remove(i),i=d(i))};return s([p(()=>{const e=a.creationInfo?.layer,t=n().find(t=>t.layer===e);return{hasFeatureLayerSource:!!t,enabled:t?.enabled??!1}},({hasFeatureLayerSource:e,enabled:t})=>{if(!e)return l();i??=o(),i.enabled=t},g),r(l)])}function Me(e){const t=e.viewModel.view;if(!t)return[];const a=[];if("3d"===t.type){const i=new U({view:t});a.push(p(()=>e.selectedPendingFeature,(e,t)=>{i.remove(e),i.add(t)}),r(()=>i.destroy()))}const i=new U({view:t,highlightName:L});return a.push(p(()=>e.temporaryHighlightFeature,e=>{i.removeAll(),i.add(e)}),r(()=>i.destroy())),a}function be(e){for(const t of e){const{sourceLayer:e}=t;e&&"globalIdField"in e&&null!=e.globalIdField&&(t.attributes[e.globalIdField]??=w())}}e([y()],Fe.prototype,"allowSave",null),e([y()],Fe.prototype,"createFeatureState",void 0),e([y()],Fe.prototype,"curveResizeDisabled",null),e([y()],Fe.prototype,"curveUpdatesDisabled",null),e([y()],Fe.prototype,"data",void 0),e([y({constructOnly:!0})],Fe.prototype,"isNested",void 0),e([y()],Fe.prototype,"formViewModel",null),e([y()],Fe.prototype,"hasInvalidFormTemplate",null),e([y()],Fe.prototype,"hasPendingEdits",null),e([y()],Fe.prototype,"hasPreviousStep",null),e([y()],Fe.prototype,"_getDrawMeshHelpMessage",void 0),e([y()],Fe.prototype,"helpMessage",null),e([y()],Fe.prototype,"noticeMessage",null),e([y()],Fe.prototype,"layer",null),e([y()],Fe.prototype,"parent",null),e([y()],Fe.prototype,"keyboardCancellationEnabled",null),e([y()],Fe.prototype,"reliesOnOwnerAdminPrivileges",null),e([y()],Fe.prototype,"saveActionLabel",null),e([y()],Fe.prototype,"shouldShowAttachments",null),e([y()],Fe.prototype,"shouldAllowAttachmentEditing",null),e([y()],Fe.prototype,"sketchUpdateOptions",null),e([y()],Fe.prototype,"sketchViewModel",null),e([y()],Fe.prototype,"availableCreateTools",null),Fe=me=e([v("esri.widgets.Editor.CreateFeaturesWorkflow")],Fe);const Ie=Fe;export{Ie as default};
2
+ import{__decorate as e}from"tslib";import t from"../../Graphic.js";import a from"../../core/Collection.js";import i from"../../core/Error.js";import{makeHandle as r,handlesGroup as s,abortHandle as n}from"../../core/handleUtils.js";import"../../core/has.js";import o from"../../core/Logger.js";import{removeMaybe as l,destroyMaybe as d}from"../../core/maybe.js";import{isPromiseLike as c,debounce as u}from"../../core/promiseUtils.js";import{whenOnce as p,watch as h,initial as m,sync as f,syncAndInitial as g}from"../../core/reactiveUtils.js";import{generateBracedUUID as w}from"../../core/uuid.js";import{property as y,subclass as v}from"../../core/accessorSupport/decorators.js";import{isSharedTemplateOrMetadata as F,isSharedTemplate as _,getCreationAttributes as M,isStandardFeatureTemplate as b}from"../../editing/templateUtils.js";import{getFullTemplate as I}from"../../editing/sharedTemplates/templateLoader.js";import V from"../../layers/GraphicsLayer.js";import{isSceneLayer as k,isTable as S}from"../../layers/support/layerUtils.js";import{isNumber as T}from"../../support/guards.js";import{getDisplayedSymbol as P}from"../../symbols/support/symbolUtils.js";import{updateGraphicSymbolWhenRequired as E}from"../../views/draw/support/editingSessionUtils.js";import{getDrawHelpMessage as U}from"../../views/draw/support/helpMessageUtils.js";import A from"../../views/draw/support/HighlightHelper.js";import H from"../../views/interactive/sketch/SketchOptions.js";import C from"../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{temporaryHighlightName as L}from"../../views/support/HighlightDefaults.js";import O from"../BatchAttributeForm/BatchAttributeFormViewModel.js";import j from"./CreateFeaturesWorkflowData.js";import{isModelUpload as x,handleModelUpload as D}from"./modelUploadUtils.js";import z from"./Workflow.js";import{activeSketchToolDrawsUnsupportedCurve as R,createToolFromGeometryType as G,containsUnsupportedCurve as W,findEditorItemForLayer as N,getServiceEditsFromWorkflowData as B,getServiceInfoForLayer as K,orderEditsByRelationshipDependencies as Z,getServiceLayersById as q,startCreatingNewFeature as J,syncUpdateOptions as Q,findLayerInfo as X,handleFormValuesChangeEvent as Y,isTerminalUpdateEventType as $,getVisualVariableAttributes as ee,startUpdatingFeatureGeometry as te,createWorkflowSteps as ae,avoidFeatureTemplateSelectionWithOnlyOneItem as ie,setUpSketchCreateWatchers as re,setRelationshipFields as se,showProgressCursor as ne,setVisualVariablesAndElevationInfoForUpdate as oe,visualVariableInteractiveUpdate as le}from"./workflowUtils.js";import{makeServiceEditsWithAttachments as de,makeEditsWithAttachments as ce,parseEditResultsAndCollectAddAttachmentData as ue}from"./support/attachmentUtils.js";import pe from"../Sketch/SketchViewModel.js";var he;const me=Symbol(),fe=Symbol(),ge=Symbol(),we=Symbol(),ye={point:["point"],multipoint:["multipoint"],polygon:["polygon","freehandPolygon","rectangle","circle"],polyline:["polyline","freehandPolyline"],mesh:[],multipatch:[]};let ve=he=class extends z{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 O({attachmentsEnabled:!0}),this._sketchLayer=null,this._sketchViewModel=null,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.formViewModel.canGoBack||this._stepIndex>0||"update-pending"===this.createFeatureState&&!!this.data.selectedPendingFeature&&!this.parent&&!x(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,n=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?.(n,e):void 0}const{activeCreateToolDrawMode:o,activeTool:l}=a;return U("rectangle"===l||"circle"===l?l:s,n?.geometry,o)}get noticeMessage(){if(R(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:!k(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(F(this.data.fullTemplate)){const{tool:t}=G(e,this.data.fullTemplate);return[t]}return"2d"!==t?.type&&"multipoint"===e?[]:[...ye[e]]}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([ge])}async updatePendingFeature(e){if(e!==this.data.selectedPendingFeature)return this._sketchViewModel.cancel(),this._startUpdating({feature:e})}async start(){return await super.start(),S(this.data.creationInfo?.layer)?null:{enter:async()=>{},exit:async()=>{},viewModel:this._sketchViewModel}}async save(e){const{formViewModel:t}=this;if(t.pendingSubtypeChoice)return;await 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 await(t?.submit());const{pendingFeatures:r,editorItem:s}=this.data;if(s&&e&&W(r.toArray(),s)){if(!await e("curveEditingDensifyPrompt"))return this.reset()}return super.save()}back(e){return this._formViewModel.canGoBack?this._formViewModel.goBack():"update-pending"!==this.createFeatureState||!this.data.selectedPendingFeature||x(this.data.creationInfo)||this.parent?super.back(e):this._clearSelectedFeature()}previous(e){return this._formViewModel.canGoBack?this._formViewModel.goBack():"update-pending"===this.createFeatureState&&this.data.selectedPendingFeature&&!x(this.data.creationInfo)?this._clearSelectedFeature():super.previous(e)}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{applyEdits:t,applyEditsFeatureService:a,addAttachmentsCallback:i,isNested:r,creationInfo:s,parent:n,snappingManager:o,startAt:l,viewModel:d}=e,c=e.sketchOptions??new H,u=s?.layer,p=u?N(d.editorItems,u):void 0,h=new he({data:new j({creationInfo:s,editorItem:p,parent:n,sketchOptions:c,snappingManager:o,viewModel:d}),isNested:r,onCommit:async e=>{const{creationInfo:r}=e;if(!r)return;h._sketchViewModel.cancel();const s=e.pendingFeatures.toArray(),{layer:n}=r,o=n.capabilities?.editing.supportsGlobalId&&"globalIdField"in n,{fullTemplate:l}=e,c=B(h.data),u=_(l)&&c;if(o){if(Me(s),u){let t=de(c,e);const i=await(K(n,d.view)?.load());i&&(t=Z({edits:t,serviceInfo:i,view:d.view,findOriginalFeature:t=>e.getEditsForPendingFeature(t)?.initialFeature??t})),await a(l.featureService,t,{globalIdUsed:!0,honorSequenceOfEdits:!0,gdbVersion:l.layer.gdbVersion??void 0})}else await t(n,ce(s,e),{globalIdUsed:!0});return}const p=u?await a(l.featureService,c,{gdbVersion:l.layer.gdbVersion??void 0}):[await t(n,{addFeatures:s})];p?.length&&e.attachmentsModified&&!o&&await Promise.all(p.map(t=>{if(!t?.addFeatureResults)return;const a=ue(s,t.addFeatureResults,n,e);return i(n,a)}))}});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)",r(()=>e.effect=t)}const t=e.opacity;return e.opacity=.7,r(()=>e.opacity=t)}async _initializeFullTemplateAndExecutorInfo(e){const{creationInfo:t}=e,{view:a}=e.viewModel;if(!t||!a)return null;const i=await I(a,t.template);if(e.fullTemplate=i,i&&_(i)){const{createTemplateExecutor:r}=await import("../../editing/sharedTemplates/executor/createTemplateExecutor.js"),s={completionResults:[],executor:await r(i),serviceLayersById:q(t.layer,a)};e.templateExecutorInfo=s}return i}async _startCreating(){this.removeHandles(fe);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 J(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=l(this._featureFormHandle),this._formViewModel.features=new a,this._formViewModel.activeFeatureIndex=-1}_stashValidationState(){const e=this._formViewModel.activeFeature,t=e&&this.data.getEditsForPendingFeature(e);t&&(t.submittable=this._formViewModel.valid)}async _selectFeatureForUpdate({feature:e,initialFeature:t=e}){this._stashValidationState();const{data:i,pendingFeatures:r}=this;r.includes(e)||i.addPendingFeature(e,t),i.selectedPendingFeature=e;const{_formViewModel:n,_sketchViewModel:o,sketchUpdateOptions:d}=this,{creationInfo:c,viewModel:u}=i,{layerInfos:m,view:f}=u;if(!f||!c)return;Q(o,d),l(this._featureFormHandle);const g=e.sourceLayer,w=X(m,g),y=f.spatialReference;n.set({editType:"INSERT",features:new a([e]),activeFeatureIndex:0,layerInfos:w?[w]:null,spatialReference:y,map:f.map}),await p(()=>!1===n.updating),await E(e,"2d"===f.type?f.scale:null);const v=i.getEditsForPendingFeature(e);v?.attachmentsModified&&n.applyStashedAttachmentEdits(v.attachmentEdits),this._featureFormHandle=s([n.on("values-change",Y({filter:e=>e===v?.feature,forEachValueChange:(e,t)=>{if(T(t)){const a=this._visualVariableAttributes;a.size&&!a.size.isUpdatingInteractively&&e===a.size.field&&a.size.setInitialValue(t),a.rotation&&!a.rotation.isUpdatingInteractively&&e===a.rotation.field&&a.rotation.setInitialValue(t)}},forEachFeature:e=>{v?.updateAttributes(n.getValues(e)),E(e,"2d"===f.type?f.scale:null)}})),n.on("attachments-change",e=>v?.setAttachmentEdits(e.attachmentEdits)),o.on(["update","undo","redo"],t=>{("undo"===t.type||"redo"===t.type||"update"===t.type&&null!=t.toolEventInfo&&$(t.toolEventInfo.type))&&n.notifyGeometriesChanged([e])}),h(()=>n.activeFeature?.sourceLayer,t=>e.sourceLayer=t),h(()=>[n.activeFeature,n.valid],()=>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:n}=r,{view:o}=n;if(!o||!s)return;const l=e.sourceLayer??s.layer;return S(l)?void 0:(this._visualVariableAttributes=ee(e),te({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=ae(["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&&(x(t)?e.addHandles(await D({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){t.canceled&&e.removeHandles([ge,me,fe,we])}}),"adding-attachment":()=>({id:"adding-attachment",parent:"creating-features",async setUp(){},async tearDown(){}}),"editing-attachment":()=>({id:"editing-attachment",parent:"creating-features",async setUp(){},async tearDown(){}})});return ie(a,i)}static _configureSketchViewModel(e){const{data:t,_sketchLayer:a,_sketchViewModel:i}=e,{creationInfo:n,viewModel:o}=t,{view:l}=o,d=[];if(!l)return r();if("2d"===l.type){n&&d.push(e._fadeExistingFeatures(n.layer));const t=u((e,t)=>Promise.all(e.map(e=>E(e,t))));d.push(h(()=>l.scale,e=>t(a.graphics,e)))}const c=M(t.fullTemplate,n?.attributeOverrides,n?.layer),p=h(()=>i.createGraphic&&i.activeComponent,()=>{i.createGraphic&&i.activeComponent&&!e.hasHandles(fe)&&e._updatingHandles.consumePromise(re({creationAttributes:c,data:t,sketchViewModel:i,view:l}).then(t=>e.addHandles(t,fe)))}),m=async t=>{if("cancel"!==t.state&&"complete"!==t.state||e.removeHandles(fe),"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 r=>{const{_formViewModel:s}=e;if(r.graphics.length>1)return void await e._clearSelectedFeature();const o=r.graphics[0];if("complete"===r.state){if(e.numPendingFeatures!==n?.maxFeatures&&s.valid||s.submit(),await e._clearSelectedFeature(),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"===r.state)return o.sourceLayer??=t.creationInfo?.layer,await oe({graphic:o,sketchLayer:a,sketchViewModel:i,visualVariables:e._visualVariableAttributes,sourceLayer:o.sourceLayer}),e._selectFeatureForUpdate({feature:o});if("active"===r.state){await e.updatePendingFeature(o);const t=e._visualVariableAttributes;le(l,o,r,t)&&await E(o,"2d"===l.type?l.scale:null);const a=o.attributes,{rotation:i,size:n}=t;if(null!=i){const{field:t}=i;e._updatingHandles.consumePromise(s.setFieldValue(t,a[t]))}if(null!=n){const{field:t}=n;e._updatingHandles.consumePromise(s.setFieldValue(t,a[t]))}}}},g=async a=>{if(a.graphics.forEach(e=>{t.removePendingFeature(e)}),!x(t.creationInfo))return e._startCreating()},w=async()=>{if(x(t.creationInfo))try{await e.data.viewModel.back()}catch{}return e._startCreating()};d.push(p,i.on("create",t=>e._updatingHandles.addPromise(m(t))),i.on("update",t=>e._updatingHandles.addPromise(f(t))),i.on("delete",t=>e._updatingHandles.addPromise(g(t))),e._updatingHandles.addWhen(()=>!e.numPendingFeatures,()=>e._updatingHandles.addPromise(w())),r(()=>{i.cancel()}),Fe(i,a,t),..._e(t));const y=s(d);return i.addHandles(y),y}_initializeSketchViewModel(){const{data:e}=this,{view:t}=e.viewModel,a=new V({elevationInfo:e.creationInfo?.layer.elevationInfo,internal:!0,listMode:"hide",title:"createFeaturesWorkflow-internal"}),i=new pe({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=i,t?.map.add(a),this.addHandles([r(()=>{t?.destroyed||t?.map.remove(a),d(a)}),h(()=>this.numPendingFeatures>0,e=>this._sketchViewModel.updateOnGraphicClick=e,m),h(()=>this.sketchUpdateOptions,e=>{i.defaultUpdateOptions=e,Q(i,e)},f)])}_hasValidationErrors(e){return!!e&&!this.data.isSubmittable(e)}async _processEdits(e,t){const{data:i,_formViewModel:r,_sketchLayer:s}=this,{layerInfos:n,view:o}=i.viewModel;r.editType="INSERT",r.map=o?.map,r.spatialReference=o?.spatialReference;const{templateExecutorInfo:l}=i;if(!l){const t=e.clone();return t.geometry=null,await this._addAndInitializeEdits(e,t),e}s.remove(e);const{executor:d}=l,u=d(e.geometry,"completion"),h=c(u)?await u:u;l.completionResults.push(h),se(h.relationships),r.editType="INSERT",r.map=o?.map,r.spatialReference=o?.spatialReference,h.primary&&i.creationInfo?.attributeOverrides&&(h.primary.graphic.attributes={...h.primary.graphic.attributes,...i.creationInfo.attributeOverrides});for(const a of h.edits){let e=null;if(a.addFeatures)for(const i of a.addFeatures){const a=i.clone();a.geometry=null,null!=i.geometry&&(i.symbol=await P(i,t),s.add(i)),i.sourceLayer!==e?.layer&&(e=X(n,i.sourceLayer));const r=!!h.associationGraphics?.has(i);await this._addAndInitializeEdits(i,a,e,r)}}r.features=new a,r.activeFeatureIndex=-1,await p(()=>!r.updating);return h.edits.reduce((e,t)=>e+(t.addFeatures?.length??0),0)>1?null:h.primary?.graphic}async _addAndInitializeEdits(e,t,i,r=!1){const{data:s,_formViewModel:n}=this,{layerInfos:o}=s.viewModel,l=s.addPendingFeature(e,t,{isAssociation:r});i??=X(o,e.sourceLayer),n.features=new a([e]),n.activeFeatureIndex=0,n.layerInfos=i?[i]:null,await p(()=>!n.updating),l.updateAttributes(n.getValues(e)),l.submittable=n.valid}async _setUpCreatingFeaturesStep(){if(this.hasHandles(ge))return;const{data:e,sketchViewModel:a}=this,{creationInfo:n,viewModel:o}=e,{view:d}=o;if(!d||!n?.layer)throw new i("missing-parameters","CreateFeaturesWorkflow requires a view and creationInfo.");const{initialFeature:c,layer:u}=n,p=[],f=[];this._featureFormHandle=l(this._featureFormHandle),this._visualVariableAttributes={rotation:null,size:null},e.editorItem=N(o.editorItems,n.layer),n.template&&(null==e.fullTemplate&&await this._initializeFullTemplateAndExecutorInfo(e),f.push(r(()=>{e.templateExecutorInfo&&(e.templateExecutorInfo.completionResults=[])}))),a.allowDeleteKey=!e.isSharedTemplateWorkflow;const g=ne(d);p.push(g);const w=S(n.layer),{template:y}=n,v=!y||b(y)||F(y)&&"feature"===y.type,_=w&&v;try{if(_){const a=c??new t({attributes:M(e.fullTemplate,n.attributeOverrides,u),sourceLayer:u}),i=await this._processEdits(a);i&&await this._startUpdating({feature:i})}else p.push(he._configureSketchViewModel(this)),c?(x(n)&&n.geometryToPlace&&(c.attributes=M(e.fullTemplate,n.attributeOverrides,u)),a.addGraphic(c),await this._startUpdating({feature:c})):await this._startCreating()}finally{g.remove()}const I=r(()=>{for(const t of e.pendingFeatures)a.removeGraphic(t),e.removePendingFeature(t)}),V=h(()=>d?.timeZone,e=>{this._formViewModel.timeZone=e,this.data.timeZone=e},m),k=r(()=>{x(n)&&o.cancelWorkflow({warnIfNoWorkflow:!1})});this._featureFormHandle&&p.push(this._featureFormHandle),this.addHandles(p,this._handleKeys.beforeCommit),this.addHandles(f,this._handleKeys.afterCommit),this.addHandles([s(p),s(f),k,I,V],ge)}async _waitForActiveToolCleared(){const e=this.data.viewModel.view;if(null==e?.activeTool)return;const t=new AbortController;this.addHandles(n(t),we),await p(()=>null==e?.activeTool,t.signal),t.abort()}};function Fe(e,t,a){let i=null;const n=()=>e.snappingOptions.featureSources,o=()=>(i=new C({layer:t}),n().add(i),i),l=()=>{null!=i&&(n().remove(i),i=d(i))};return s([h(()=>{const e=a.creationInfo?.layer,t=n().find(t=>t.layer===e);return{hasFeatureLayerSource:!!t,enabled:t?.enabled??!1}},({hasFeatureLayerSource:e,enabled:t})=>{if(!e)return l();i??=o(),i.enabled=t},g),r(l)])}function _e(e){const t=e.viewModel.view;if(!t)return[];const a=[];if("3d"===t.type){const i=new A({view:t});a.push(h(()=>e.selectedPendingFeature,(e,t)=>{i.remove(e),i.add(t)}),r(()=>i.destroy()))}const i=new A({view:t,highlightName:L});return a.push(h(()=>e.temporaryHighlightFeature,e=>{i.removeAll(),i.add(e)}),r(()=>i.destroy())),a}function Me(e){for(const t of e){const{sourceLayer:e}=t;e&&"globalIdField"in e&&null!=e.globalIdField&&(t.attributes[e.globalIdField]??=w())}}e([y()],ve.prototype,"allowSave",null),e([y()],ve.prototype,"createFeatureState",void 0),e([y()],ve.prototype,"curveResizeDisabled",null),e([y()],ve.prototype,"curveUpdatesDisabled",null),e([y()],ve.prototype,"data",void 0),e([y({constructOnly:!0})],ve.prototype,"isNested",void 0),e([y()],ve.prototype,"formViewModel",null),e([y()],ve.prototype,"hasInvalidFormTemplate",null),e([y()],ve.prototype,"hasPendingEdits",null),e([y()],ve.prototype,"hasPreviousStep",null),e([y()],ve.prototype,"_getDrawMeshHelpMessage",void 0),e([y()],ve.prototype,"helpMessage",null),e([y()],ve.prototype,"noticeMessage",null),e([y()],ve.prototype,"layer",null),e([y()],ve.prototype,"parent",null),e([y()],ve.prototype,"keyboardCancellationEnabled",null),e([y()],ve.prototype,"reliesOnOwnerAdminPrivileges",null),e([y()],ve.prototype,"saveActionLabel",null),e([y()],ve.prototype,"shouldShowAttachments",null),e([y()],ve.prototype,"shouldAllowAttachmentEditing",null),e([y()],ve.prototype,"sketchUpdateOptions",null),e([y()],ve.prototype,"sketchViewModel",null),e([y()],ve.prototype,"availableCreateTools",null),ve=he=e([v("esri.widgets.Editor.CreateFeaturesWorkflow")],ve);const be=ve;export{be as default};
@@ -25,7 +25,7 @@ import type { SnappingOptionsProperties } from "../../views/interactive/snapping
25
25
  import type { SketchTooltipOptionsProperties } from "../../views/interactive/sketch/SketchTooltipOptions.js";
26
26
  import type { SketchValueOptionsProperties } from "../../views/interactive/sketch/SketchValueOptions.js";
27
27
 
28
- export interface EditorViewModelProperties extends Partial<Pick<EditorViewModel, "layerInfos" | "selectionManager" | "syncViewSelection" | "useLegacyCreateTools" | "view">> {
28
+ export interface EditorViewModelProperties extends Partial<Pick<EditorViewModel, "formSystem" | "layerInfos" | "selectionManager" | "syncViewSelection" | "useLegacyCreateTools" | "view">> {
29
29
  /** The [AttachmentsViewModel][AttachmentsViewModel](https://developers.arcgis.com/javascript/latest/references/core/widgets/Attachments/AttachmentsViewModel/) for supporting the editor widget. Attachment editing is enabled by default if the layer has support for it. */
30
30
  attachmentsViewModel?: AttachmentsViewModelProperties;
31
31
  /**
@@ -181,6 +181,16 @@ export default class EditorViewModel extends EventedAccessor {
181
181
  */
182
182
  get featureTemplatesViewModel(): FeatureTemplatesViewModel;
183
183
  set featureTemplatesViewModel(value: FeatureTemplatesViewModelProperties);
184
+ /**
185
+ * Set this property to 'next' to opt-in to support for the latest Editing features,
186
+ * including support for multiple choice inputs and AttachmentElement in
187
+ * feature forms.
188
+ *
189
+ * @deprecated This property, including support for using legacy form APIs, will be removed at 6.0 when 'next' becomes default.
190
+ * @default "legacy"
191
+ * @since 5.1
192
+ */
193
+ accessor formSystem: "legacy" | "next";
184
194
  /**
185
195
  * The form's view model used to support the Editor widget.
186
196
  * This can be either the [BatchAttributeFormViewModel][BatchAttributeFormViewModel](https://developers.arcgis.com/javascript/latest/references/core/widgets/BatchAttributeForm/BatchAttributeFormViewModel/)
@@ -188,7 +198,7 @@ export default class EditorViewModel extends EventedAccessor {
188
198
  *
189
199
  * @since 4.33
190
200
  */
191
- get formViewModel(): BatchAttributeFormViewModel | null | undefined;
201
+ get formViewModel(): BatchAttributeFormViewModel | FeatureFormViewModel | null | undefined;
192
202
  /**
193
203
  * Use this property to determine if the next generation geometry creation
194
204
  * has been disabled. This can happen when