@arcgis/core 5.2.0-next.140 → 5.2.0-next.142

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 (95) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/{498d6dfd3bb0d3490548.js → 14a3808427deaaa85bf2.js} +1 -1
  3. package/assets/esri/core/workers/chunks/25e6013e2c095629b236.js +1 -0
  4. package/assets/esri/core/workers/chunks/347bf269c2b1583d2dca.js +1 -0
  5. package/assets/esri/core/workers/chunks/{5e90c1b49f2b7e21d05a.js → 55766692b578e60dd70e.js} +22 -22
  6. package/assets/esri/core/workers/chunks/{40fb1910f780e78c128c.js → 8b54589f173259c1ba55.js} +1 -1
  7. package/assets/esri/core/workers/chunks/{61ad8306ab79aca79505.js → 8ba32d3a0df4a206ef1c.js} +1 -1
  8. package/assets/esri/core/workers/chunks/d4926545193414cf2f16.js +1 -0
  9. package/assets/esri/core/workers/chunks/e32b96c08cb272a59851.js +1 -0
  10. package/assets/esri/core/workers/chunks/{4310c8d2b40ae69c3681.js → fccbb902fe08448f91de.js} +1 -1
  11. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.ar.json +1 -1
  12. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.bg.json +1 -1
  13. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.bs.json +1 -1
  14. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.ca.json +1 -1
  15. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.cs.json +1 -1
  16. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.da.json +1 -1
  17. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.de.json +1 -1
  18. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.el.json +1 -1
  19. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.es.json +1 -1
  20. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.et.json +1 -1
  21. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.fi.json +1 -1
  22. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.fr.json +1 -1
  23. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.he.json +1 -1
  24. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.hr.json +1 -1
  25. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.hu.json +1 -1
  26. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.id.json +1 -1
  27. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.it.json +1 -1
  28. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.ja.json +1 -1
  29. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.ko.json +1 -1
  30. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.lt.json +1 -1
  31. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.lv.json +1 -1
  32. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.nl.json +1 -1
  33. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.no.json +1 -1
  34. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.pl.json +1 -1
  35. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.pt-BR.json +1 -1
  36. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.pt-PT.json +1 -1
  37. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.ro.json +1 -1
  38. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.ru.json +1 -1
  39. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.sk.json +1 -1
  40. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.sl.json +1 -1
  41. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.sr.json +1 -1
  42. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.sv.json +1 -1
  43. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.th.json +1 -1
  44. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.tr.json +1 -1
  45. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.uk.json +1 -1
  46. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.vi.json +1 -1
  47. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.zh-CN.json +1 -1
  48. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.zh-HK.json +1 -1
  49. package/assets/esri/widgets/BatchAttributeForm/t9n/messages.zh-TW.json +1 -1
  50. package/chunks/RibbonLine.glsl.js +9 -11
  51. package/config.js +1 -1
  52. package/kernel.js +1 -1
  53. package/layers/GeospatialPDFLayer.d.ts +2 -5
  54. package/layers/GeospatialPDFLayer.js +1 -1
  55. package/layers/ParquetLayer.d.ts +8 -1
  56. package/layers/ParquetLayer.js +1 -1
  57. package/layers/geospatialPDF/renderExtentUtils.js +1 -1
  58. package/package.json +2 -2
  59. package/views/2d/analysis/AreaMeasurement/AreaMeasurementTool.js +1 -1
  60. package/views/2d/analysis/AreaMeasurementAnalysisView2D.d.ts +2 -0
  61. package/views/2d/analysis/AreaMeasurementAnalysisView2D.js +1 -1
  62. package/views/2d/analysis/DistanceMeasurement/DistanceMeasurementTool.js +1 -1
  63. package/views/2d/analysis/DistanceMeasurementAnalysisView2D.d.ts +2 -0
  64. package/views/2d/analysis/DistanceMeasurementAnalysisView2D.js +1 -1
  65. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/LineShader.js +1 -1
  66. package/views/3d/analysis/LineOfSight/LineOfSightItemManipulatedObject3D.js +1 -1
  67. package/views/3d/analysis/LineOfSight/LineOfSightPlacementController.js +1 -1
  68. package/views/3d/analysis/LineOfSight/lineOfSightPlacementUtils.js +1 -1
  69. package/views/3d/analysis/Viewshed/ViewshedPlacementController.js +1 -1
  70. package/views/3d/analysis/Viewshed/ViewshedPlacementPointPlugin.js +1 -1
  71. package/views/3d/analysis/Viewshed/placementUtils.js +1 -1
  72. package/views/3d/interactive/SnappingVisualizer3D.js +1 -1
  73. package/views/3d/interactive/visualElements/ExtendedLineVisualElement.js +1 -1
  74. package/views/3d/interactive/visualElements/ParallelLineVisualElement.js +1 -1
  75. package/views/3d/interactive/visualElements/RightAngleQuadVisualElement.js +1 -1
  76. package/views/3d/layers/GaussianSplatLayerView3D.js +1 -1
  77. package/views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateSceneLighting.glsl.js +3 -3
  78. package/views/3d/webgl-engine/core/shaderLibrary/shading/LineStipple.glsl.js +23 -9
  79. package/views/DOMContainer.d.ts +1 -0
  80. package/views/draw/support/PluginContext.js +1 -1
  81. package/views/draw/support/managers/TooltipManager.js +1 -1
  82. package/views/interactive/snapping/SnappingVisualizer.js +1 -1
  83. package/views/interactive/tooltip/infos/DynamicTooltipInfo.js +1 -1
  84. package/views/layers/FeatureLikeLayerView.d.ts +1 -0
  85. package/views/layers/GraphicsLayerView.d.ts +1 -0
  86. package/views/layers/ImageryLayerView.d.ts +1 -0
  87. package/widgets/BatchAttributeForm.js +1 -1
  88. package/widgets/Directions.js +1 -1
  89. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  90. package/widgets/OrientedImageryViewer/types.d.ts +20 -0
  91. package/widgets/OrientedImageryViewer.d.ts +9 -1
  92. package/assets/esri/core/workers/chunks/1f3148cebee1961249a4.js +0 -1
  93. package/assets/esri/core/workers/chunks/6c5738012ba8b69bc596.js +0 -1
  94. package/assets/esri/core/workers/chunks/ae2181805d8ba130babc.js +0 -1
  95. package/assets/esri/core/workers/chunks/d6d5a9e73ee43d6066d3.js +0 -1
@@ -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 n}from"../core/deprecate.js";import r from"../core/Logger.js";import{getOrCreateMapValue as i}from"../core/MapUtils.js";import{destroyMaybe as a}from"../core/maybe.js";import o from"../core/ReactiveMap.js";import{watch as s,when as c,on as l,sync as u}from"../core/reactiveUtils.js";import{formatFileSize as d}from"../core/unitFormatUtils.js";import{property as f,subclass as p}from"../core/accessorSupport/decorators.js";import{formatDate as m}from"../intl/date.js";import{isIntegerField as h}from"../layers/support/fieldUtils.js";import{isString as g}from"../support/guards.js";import ee from"./Widget.js";import{getAttachmentTypeCategory as te,getCalciteIconForAttachment as _}from"./Attachments/support/attachmentUtils.js";import{getAttachmentKey as v,isImageAttachment as y,getAttachmentFilenameParts as b}from"./BatchAttributeForm/attachmentUtils.js";import{getHiddenFieldsValidationErrorMessage as ne,getMessageString as x,isElementTemplateWithInputType as S,subtypeChangeShouldPrompt as re,flattenInputs as ie}from"./BatchAttributeForm/batchAttributeFormUtils.js";import C from"./BatchAttributeForm/BatchAttributeFormViewModel.js";import{css as w}from"./BatchAttributeForm/css.js";import{makeViewingEditedAttachmentFooterButtons as ae,makeViewingAttachmentFooterButtons as oe,makeCancelFooterButton as T,makeDefaultFooterButtons as E}from"./BatchAttributeForm/interfaceUtils.js";import D from"./BatchAttributeForm/VisibleElements.js";import{isDynamicChoiceController as O,isMultipleChoiceController as k}from"./BatchAttributeForm/inputs/support/controllerUtils.js";import{isGroupInput as A,isFieldInput as j,isTextElementInput as se,isRelationshipElementInput as ce,isAttachmentElementInput as le,isUtilityNetworkAssociationsElementInput as M,differentValuesString as N,getNormalizedFieldName as P,isGroupedInput as F}from"./BatchAttributeForm/inputs/support/inputUtils.js";import{clearMultipleChoiceOtherChoiceStateForViewModel as I,otherChoiceCheckedPlaceholderValue as L,canRestoreMultipleChoiceOtherChoiceDraftValue as R}from"./BatchAttributeForm/inputs/support/multipleChoiceInputUtils.js";import{loadRelationshipDetailsComponents as z,RelationshipDetails as B}from"./BatchAttributeForm/rendered-content/RelationshipDetails.js";import{Prompt as V}from"./Editor/components/Prompt.js";import{downloadAttachmentInfo as H}from"./FeatureTable/support/exportUtils.js";import{loadCalciteComponents as U}from"./support/componentsUtils.js";import{getLabelForDateFieldValue as ue,getIntlOptionsForField as de,prepareISOFieldValueForDateComponents as W,prepareUnixFieldValueForDateComponents as G,normalizeTimeOnlyString as K,getISOFieldValueFromDateComponents as fe,getUnixFieldValueFromDateComponents as pe}from"./support/dateUtils.js";import{globalCss as q}from"./support/globalCss.js";import{Heading as me}from"./support/Heading.js";import{calciteListFilterProps as he}from"./support/listUtils.js";import{messageBundle as J,vmEvent as ge,tsx as Y}from"./support/widget.js";import{setFocus as _e}from"./support/widgetUtils.js";import{isEmptyValue as X}from"./support/forms/formUtils.js";const Z=`data-element-id`,Q=`data-field-name`;let $=class extends ee{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 C,this.visibleElements=new D,this.groupDisplay=`all`,this._associationsList=null,this._associationsWidgetsMap=new o,this._attemptFocusOnNextRender=!1,this._dateComponentMap=new Map,this._dynamicChoiceItemSelections=new WeakSet,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=()=>{let 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=()=>{let e=this.selectedAttachmentDetails;if(!e?.attachment)return;let t=e.input.getAttachmentEditState(e.attachment).initialName;if(t==null)return;let n=e.input.template.elementId,r=v(e.attachment);this.viewModel.stageRenameAttachment(n,r,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._afterDateComponentCreateOrUpdate=this._afterDateComponentCreateOrUpdate.bind(this),this._afterRadioGroupCreateOrUpdate=this._afterRadioGroupCreateOrUpdate.bind(this),e?.suppressDeprecationWarning||(this.announceDeprecation=()=>{n(r.getLogger(this),`Editor`,`arcgis-editor`,{version:`5.0`})})}normalizeCtorArgs(e={}){let{suppressDeprecationWarning:t,...n}=e;return n}initialize(){this.addHandles([s(()=>this.features.toArray(),()=>{this._dateComponentMap.clear(),I(this.viewModel,{includeDraftValues:!0})}),s(()=>this.viewModel.activeForm,()=>{this._batchSwitchInputInitialValues.clear(),this._resetTransientFormState(),I(this.viewModel),this._setFocusableInput()}),s(()=>this.viewModel.selectedAttachmentAddElementId,()=>{this.hideAttachmentDialog()}),c(()=>!this.selectedAttachmentDetails,()=>this.hideAttachmentDialog()),s(()=>this.viewModel.selectedAttachmentListElementId,()=>{this._attachmentListFilterText=``}),s(()=>[this.viewModel.activeRelationshipInput,this._listObserverNode],()=>this._onObserverChange()),l(()=>this.viewModel,`submit`,()=>{this.valid||this.goToFirstError()}),s(()=>[this._associationsEnabled,this.viewModel.activeForm.allUtilityNetworkAssociationsElementInputs],()=>this._setUpAssociationsWidgets(),u),s(()=>this.viewModel.activeAssociationsInput,e=>this._onActiveAssociationsInputChange(e)),s(()=>this.groupDisplay,()=>this._syncGroupInputStates())])}loadDependencies(){return Promise.all([U({action:()=>import(`@esri/calcite-components/dist/components/calcite-action`),autocomplete:()=>import(`@esri/calcite-components/dist/components/calcite-autocomplete`),"autocomplete-item":()=>import(`@esri/calcite-components/dist/components/calcite-autocomplete-item`),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`)}),z()])}destroy(){this._destroyAssociationsWidgets(),this._associationsList=a(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(){let{features:e,messages:t,page:n}=this;return t?n===`replacing-attachment`?t.titles.replaceAttachment:n===`viewing-attachment-details`?t.titles.editAttachment:n===`adding-attachments`?t.titles.addAttachments:n===`viewing-attachments`?t.titles.attachments:e.length===1||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[];let{messages:e,messagesCommon:t,page:n}=this,r=this.effectiveDisabled;if(n===`adding-attachments`||n===`replacing-attachment`)return[];if(n===`viewing-attachment-details`){let t=this.selectedAttachmentDetails,n=t?.input?.getAttachmentEditState(t.attachment);return!t?.input||!n?[]:n.isRenamed||n.isReplaced?ae({doneOnclick:()=>this._setSelectedAttachment(null),messages:e.footerButtons,resetOnclick:()=>this._resetSelectedAttachmentChanges(),resetDisabled:this._disableAttachmentModification(t.input)}):oe({deleteDisabled:this._disableAttachmentModification(t.input),deleteOnclick:()=>this._deleteSelectedAttachment(),doneOnclick:()=>this._setSelectedAttachment(null),messages:e.footerButtons})}return n===`viewing-associated-features`?T({messages:t,purpose:`cancel-viewing-associated-features`,onclick:()=>this.goBack()}):n===`viewing-associated-layers`?T({messages:t,purpose:`cancel-viewing-associated-layers`,onclick:()=>this.goBack()}):n===`viewing-attachments`||n===`viewing-related-records`?[]:E({disabled:r||!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 this.viewModel.mode===`batch`||!this.viewModel.activeFeature?!1:!!(this.viewModel.formDescription||this.viewModel.formTitle)}get _associationsEnabled(){let{callbacks:e}=this;return!!(e?.addAssociation||e?.editAssociatedFeature)}get _formId(){return`${this.id}-form`}get _relatedRecordsEnabled(){let{callbacks:e}=this;return!!(e&&(e.addRelatedRecord||e.editRelatedRecord))}async goBack(){return this.viewModel.goBack()}async goHome(){return this.viewModel.goHome()}goToFirstError(){let e=this.viewModel.getFirstVisibleInvalidFieldInput();if(!e)return;let{groupInput:t}=e;t&&(t.open||=!0),this._setFocusableInput(e.input),this.scheduleRender()}render(){return Y(`div`,{class:this.classes(w.base,q.widget,q.panel),ondragover:this._handleDragAndDrop,ondrop:this._handleDragAndDrop},this._renderContent(),this._renderAttachmentDialog(),this._prompt?Y(V,{...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){let{datePart:t,elementId:n}=e.dataset,r=i(this._dateComponentMap,`${n}`,()=>({}));switch(t){case`date`:r.date=e;break;case`time`:r.time=e;break;case`timeZone`:r.timeZone=e}}_renderContent(){let{messages:e,viewModel:n}=this,{status:r}=n;if(r===`failed`)return n.hasTooManyComplexFeatures?this._renderErrorNotice(t(e.formFailedToLoadTooManyComplexFeatures,{num:n.maximumFeatureCountWithComplexForms})):n.hasTooManyFeatures?this._renderErrorNotice(t(e.formFailedToLoadTooManyFeatures,{num:n.maximumFeatureCount})):e.formFailedToLoad;if(n.hasLayersWithContingentValues&&this.viewModel.features.length>1)return this._renderErrorNotice(e.unsupportedContingentValues);if(r===`loading`&&this.visibleElements.loadingIndicator)return Y(`calcite-loader`,{key:`loader`,label:this.messagesCommon?.loading});if(this.features.length!==0)return this._renderForm()}_renderErrorNotice(e,t=`warning`){return Y(`calcite-notice`,{class:w.noticeError,icon:!0,kind:t,open:!0},Y(`div`,{slot:`message`},e))}_renderForm(){return Y(`form`,{class:w.form,id:this._formId,inert:!!this._prompt,onsubmit:this._onFormSubmit},this.viewModel.expressionEvaluationFailed&&this.visibleElements.expressionsErrorNotice&&this._renderErrorNotice(this.messages.expressionEvaluationFailed),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(){let{viewModel:e}=this,{hasNonActiveInvalidFeatures:t,activeForm:n}=e,r;if(!e.submitHasBeenAttempted)return null;if(n.invalidHiddenInputs.length>0){if(r=ne(n,e.mode,this.messages),this.viewModel.mode===`batch`){let e=n.invalidHiddenInputs.filter(e=>e.effectiveVisibilityCode===`hidden:group-visibility-expression:all-features`||e.visibilityCode===`hidden:visibility-expression:all-features`);e.length>0?r+=` (${e.map(e=>e.label).join(`, `)})`:r=null}else r=null}else if(t)return null;return r?this._renderErrorNotice(r,`danger`):null}_renderDefaultPage(){return[this._renderReadOnlyNotice(),this._renderFormHeader(),this._renderFormContent()]}_renderReadOnlyNotice(){if((this.disabled||this.readOnly)&&this.visibleElements.readOnlyNotice)return Y(`calcite-notice`,{class:w.disabledNotice,"data-testid":`read-only-notice`,icon:`read-only-non-editable`,kind:`brand`,open:!0,scale:`s`,width:`full`},Y(`div`,{slot:`message`},this.featureFormMessages.disabledForm))}_renderFormHeader(){let{formTitle:e,formDescription:t}=this.viewModel;if(!this._formHeaderVisible)return;let n=e?Y(me,{key:`title`,level:this.headingLevel},e):void 0,r=t?Y(`p`,{class:w.description,key:`description`},t):void 0;return Y(`div`,{class:w.formHeader},n,r)}_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){if(A(e))return this._renderGroupInput(e);if(j(e))return this._renderLabeledField(e);if(se(e))return this._renderTextComponent(e);if(ce(e))return this._renderRelationshipElementInput(e);if(le(e))return this._renderAttachmentElementInput(e);if(M(e))return this._renderUtilityNetworkAssociationsElementInput(e)}_renderGroupInput(e){let{inputs:t,template:n,open:r}=e,i=t.filter(e=>e.visible),a=e.label??``,o=this._focusedFieldInput?.group===e,s=this.groupDisplay===`sequential`;return Y(`calcite-block`,{class:this.classes(w.group,s?w.groupSequential:null,o?w.groupActive:null,this.disabled?w.inputDisabled:null),collapsible:!0,description:e.description??void 0,expanded:r,heading:a,headingLevel:this.headingLevel,key:`{${n.elementId}-key}`,label:a,onCalciteBlockClose:()=>{e.open=!1},onCalciteBlockOpen:()=>{e.open=!0},onCalciteBlockToggle:({currentTarget:t})=>this._onGroupToggle(t,e)},i.map(e=>this._renderInput(e)))}_renderLabeledField(e){let{elementId:n}=e.template,{label:r,required:i,dataType:a}=e,o=i?t(this.messages.requiredFieldLabel,{name:r}):r;return Y(`calcite-label`,{"aria-label":o,class:w.label,key:`field--${n}`},Y(`div`,{class:w.labelTextContent,key:`labelTextContainer`},r,i?Y(`span`,{"aria-hidden":`true`,title:this.messagesCommon.required},`*`):void 0),a===`unsupported`?this._renderReadOnlyComponent(e):this._renderFieldInput(e),this._renderAuxiliaryText(e))}_renderFieldInput(e){let t=this.getCommonInputProps(e),{dataType:n}=e;return O(e.inputController)?this._renderDynamicChoiceComponent({input:e,props:t,controller:e.inputController}):e.domain?.type===`coded-value`?this._renderCodedInputs({input:e,props:t}):k(e.inputController)?this._renderMultipleChoiceComponent({input:e,props:t}):n===`date`?this._renderDateComponents(e,t):(t.disabled=this.disabled,t.readOnly=t.readOnly||this.viewModel.updating,n===`number`?this._renderNumberComponent(e,t):this._renderStringComponent(e,t))}_renderAuxiliaryText(e){let{description:t}=e,n=x(e,e.validationMessage,this.messages);return n?Y(`calcite-input-message`,{icon:!0,status:e.status},n):t?Y(`calcite-input-message`,{class:w.description,icon:!1,status:e.status},t):null}_renderCodedInputs({input:e,props:t}){let n=e.input?.type??null,r=e.codedValueOptions;switch(n){case`switch`:return this._renderSwitchField({input:e,props:t});case`radio-buttons`:return this._renderRadioButtonGroupComponent({input:e,options:r,props:t});default:return this._renderComboBoxComponent({options:r,props:t,input:e})}}_renderDynamicChoiceComponent({input:e,props:t,controller:n}){let r=n.filteredChoices,i=e.showNoValueLabel||this.messages.empty,a=n.evaluated&&!n.evaluating&&!n.choices.length&&Y(`calcite-notice`,{appearance:`transparent`,kind:`info`,open:!0,scale:`s`,slot:`content-top`,width:`full`},Y(`div`,{slot:`message`},this.messages.noDynamicChoices)),o=t=>{this._saveInput(e,t)},s=(e,t)=>{this._dynamicChoiceItemSelections.delete(n);let r=e.closest(`calcite-autocomplete`);if(r){let e=t==null?``:n.getLabel(t);n.filterValue=``,r.inputValue=e}o(t)},c=({currentTarget:t})=>{let r=t.inputValue??``;n.filterValue=r,!r&&e.value!=null&&o(null)},l=e.showNoValueOptionEnabled?Y(`calcite-autocomplete-item`,{heading:i,key:`dynamic-choice-empty`,selected:e.value==null,value:``,onCalciteAutocompleteItemSelect:({currentTarget:e})=>s(e,null),onpointerdown:()=>{this._dynamicChoiceItemSelections.add(n)}}):null,u=t=>{t.inputValue=e.value===N?this.messages.differentValuesPlaceholder:e.value==null?``:n.inputValue};return Y(`calcite-autocomplete`,{...t,afterCreate:u,disabled:t.readOnly||t.disabled,loading:n.evaluating,placeholder:e.value==null?i:t.placeholder,value:String(t.value),onblur:e=>this._onDynamicChoiceBlur(e,n),onCalciteAutocompleteBeforeOpen:()=>n.beginInteraction(),onCalciteAutocompleteTextInput:c},a,l,r.map(t=>Y(`calcite-autocomplete-item`,{heading:t.name,key:`dynamic-choice-${t.code}`,selected:t.code===e.value,value:String(t.code),onCalciteAutocompleteItemSelect:({currentTarget:e})=>s(e,t.code),onpointerdown:()=>{this._dynamicChoiceItemSelections.add(n)}})))}_renderMultipleChoiceComponent({input:e,props:t}){let{messages:n}=this,r=this._getMultipleChoiceController(e);if(!r)return null;let{input:i}=r,a=i.includeSelectAllChoices===!0,{checkboxStatesByValue:o,selectAllState:s}=r.selectionState,c=s.checked?n.deselectAllLabel:n.selectAllLabel,l=r.otherChoiceRenderState;return Y(`div`,{class:w.multipleChoiceInput,key:`${t.key}-multiple-choice-group`},a?this._renderMultipleChoiceSelectAllCheckbox({props:t,selectAllState:s,selectAllLabel:c,handleSelectAllCheckboxChange:t=>{this._saveValueFromMultipleChoiceCheckbox({input:e,checkbox:t,isSelectAllCheckbox:!0})}}):null,this._renderMultipleChoiceChoiceCheckboxes({input:e,props:t,checkboxStatesByValue:o,handleChoiceCheckboxChange:t=>{this._saveValueFromMultipleChoiceCheckbox({input:e,checkbox:t})}}),l.shouldShow?this._renderMultipleChoiceOtherChoice({props:t,includeSelectAllChoices:a,otherChoiceRenderState:l,handleOtherChoiceCheckboxChange:t=>{let{fieldName:n}=l;n&&this._saveOtherChoiceCheckboxValue({input:e,isChecked:t.checked,otherChoiceFieldName:n})},handleOtherChoiceInputChange:t=>{this._saveValueFromMultipleChoiceTextInput({input:e,textInput:t,otherChoiceFieldName:l.fieldName??void 0})},differentValuesPlaceholder:n.differentValuesPlaceholder}):null)}_renderMultipleChoiceSelectAllCheckbox({props:e,selectAllState:t,selectAllLabel:n,handleSelectAllCheckboxChange:r}){return Y(`calcite-checkbox`,{afterCreate:e.afterCreate,afterUpdate:e.afterUpdate,"aria-invalid":e[`aria-invalid`],checked:t.checked,class:w.multipleChoiceSelectAll,"data-element-id":e[Z],disabled:e.readOnly||e.disabled,indeterminate:t.indeterminate,key:`${e.key}-select-all`,label:n,labelText:n,value:`esri_BatchAttributeForm_select_all`,onblur:e.onblur,onCalciteCheckboxChange:({currentTarget:e})=>r(e),onfocus:e.onfocus})}_renderMultipleChoiceChoiceCheckboxes({input:e,props:t,checkboxStatesByValue:n,handleChoiceCheckboxChange:r}){let i=this._getMultipleChoiceController(e);if(!i)return[];let{choices:a}=i;return a.map(e=>{let i=n.get(e.value)??{checked:!1,indeterminate:!1};return Y(`calcite-checkbox`,{afterCreate:t.afterCreate,afterUpdate:t.afterUpdate,"aria-invalid":t[`aria-invalid`],checked:i.checked,class:t.class,"data-element-id":t[Z],disabled:t.readOnly||t.disabled,indeterminate:i.indeterminate,key:`${t.key}-${e.value}`,label:e.label,labelText:e.label,value:e.value,onblur:t.onblur,onCalciteCheckboxChange:({currentTarget:e})=>r(e),onfocus:t.onfocus})})}_renderMultipleChoiceOtherChoice({props:e,includeSelectAllChoices:t,otherChoiceRenderState:n,handleOtherChoiceCheckboxChange:r,handleOtherChoiceInputChange:i,differentValuesPlaceholder:a}){let o=n.label??this.messages.otherOptionLabel;return Y(`div`,{class:this.classes(w.multipleChoiceOtherChoice,t?w.multipleChoiceOtherChoiceWithSelectAll:null),key:`${e.key}-other-choice`},Y(`calcite-checkbox`,{afterCreate:e.afterCreate,afterUpdate:e.afterUpdate,"aria-invalid":e[`aria-invalid`],checked:n.checkboxState.checked,class:e.class,"data-element-id":e[Z],disabled:e.readOnly||e.disabled,indeterminate:n.checkboxState.indeterminate,key:`${e.key}-other-choice-checkbox`,label:o,labelText:o,value:`esri_BatchAttributeForm_other_choice`,onblur:e.onblur,onCalciteCheckboxChange:({currentTarget:e})=>r(e),onfocus:e.onfocus}),n.checkboxState.checked?Y(`calcite-input`,{afterCreate:e.afterCreate,afterUpdate:e.afterUpdate,"aria-invalid":e[`aria-invalid`],"aria-label":o,class:w.textElementInput,"data-element-id":e[Z],disabled:e.readOnly||e.disabled,key:`${e.key}-other-choice-input`,maxLength:n.maxLength,placeholder:n.value===N?a:n.hint,status:n.status,type:`text`,value:n.normalizedValue===N?``:n.normalizedValue?String(n.normalizedValue):``,onblur:e.onblur,onCalciteInputInput:({currentTarget:e})=>i(e),onfocus:e.onfocus}):null)}async _saveValueFromMultipleChoiceCheckbox({input:e,checkbox:t,isSelectAllCheckbox:n=!1}){e.touch();let r=this._getMultipleChoiceController(e);if(!r)return;if(r.input&&!n&&this.viewModel.mode===`batch`){await this._saveMultipleChoiceCheckboxValueByFeature({input:e,checkbox:t});return}let i=e.value,a=this._parseValue(t,e,n);a!==i&&await this.viewModel.setValue(e.template.elementId,a)}async _saveValueFromMultipleChoiceTextInput({input:e,textInput:t,otherChoiceFieldName:n}){if(!n)return;let r=t.value,i=r==null||r===``?null:r,a=this._getMultipleChoiceController(e);if(!a)return;a.initializeExplicitOtherChoiceCheckedState(),a.stashOtherChoiceDraftValueForFeatures(e.features,i);let o=P(e,n);o&&await this.viewModel.setValueForFieldName(o,i,Array.from(e.features,e=>e.source))}async _saveOtherChoiceCheckboxValue({input:e,isChecked:t,otherChoiceFieldName:n}){let r=this._getMultipleChoiceController(e);if(!r)return;r.setExplicitOtherChoiceCheckedState(t),e.touch(),t||r.setOtherChoiceDraftValuesFromFeatures(e.features.toArray());let i=P(e,n);if(!i)return;let a=new Map;for(let i of e.features){let e=i.getAttribute(n);if(t){if(!X(e))continue;let t=r.getOtherChoiceDraftValue(i),n=R(t)?t:L;a.set(i,n);continue}e!=null&&a.set(i,null)}a.size!==0&&await this.viewModel.setValuePerFeatureForFieldName(i,new Map(Array.from(a,([e,t])=>[e.source,t])))}async _saveMultipleChoiceCheckboxValueByFeature({input:e,checkbox:t}){let n=this._getMultipleChoiceController(e);if(!n)return;let r=new Map(e.features.map(r=>[r,n.getUpdatedValueForFeature({choiceValue:t.value,currentValue:r.getAttribute(e.fieldName),isChecked:t.checked})]));r.size!==0&&await this.viewModel.setFieldInputValuePerFeature(e,r)}_renderSwitchField({input:e,props:t}){if((this._batchSwitchInputInitialValues.get(e)===N||e.value===N)&&this.viewModel.mode===`batch`){let n={dropdown:{afterCreate:this._afterComponentCreateOrUpdate,afterUpdate:this._afterComponentCreateOrUpdate,disabled:t.readOnly,open:!1,onblur:t.onblur,onfocus:t.onfocus,[Z]:t[Z]},trigger:{appearance:`transparent`,iconEnd:`chevron-down`,kind:`neutral`,slot:`trigger`,label:t.label},group:{mode:`single`}};return this._renderDropdownComponent({buttonValue:e.value,dropdownProps:n,options:[{name:this.messages.differentValuesPlaceholder,value:N,disabled:!0},...e.codedValueDomainOptions]})}return this._renderSwitchComponent({input:e,props:t})}_renderSwitchComponent({input:e,props:t}){return Y(`calcite-switch`,{...t,checked:S(e.template,`switch`)?e.value===e.template.input.onValue:!1,class:w.inputSwitch,disabled:t.readOnly||t.disabled,onCalciteSwitchChange:({currentTarget:e})=>this._saveInputFromElement(e)})}_renderDropdownComponent({buttonValue:e,options:t,dropdownProps:n}){let{trigger:r,dropdown:i,group:a}=n;return Y(`calcite-dropdown`,{...i,topLayerDisabled:this.topLayerDisabled,onCalciteDropdownSelect:({currentTarget:e})=>this._saveInputFromElement(e)},Y(`calcite-button`,{...r},e===N?this.messages.differentValuesPlaceholder:e),Y(`calcite-dropdown-group`,{selectionMode:a.mode},t.map(t=>Y(`calcite-dropdown-item`,{disabled:t.disabled,label:String(t.name),selected:e===t.value},t.name))))}_renderComboBoxComponent({input:e,options:t,props:n}){let r=this.viewModel.editType===`INSERT`&&e.showNoValueOptionEnabled&&!e.touched?()=>{}:n.onblur,i={...n,onblur:r};return Y(`calcite-combobox`,{...i,clearDisabled:e.isSubtypeField,selectionMode:`single`,topLayerDisabled:this.topLayerDisabled,value:n.placeholder===this.messages.differentValuesPlaceholder?N:String(n.value),onCalciteComboboxChange:({currentTarget:t})=>{t.value!==N&&(e.isSubtypeField&&t.selectedItems.length===0?t.value=`${e.value}`:this._saveInputFromElement(t))}},this.renderComboboxOptionsList({input:e,options:t,props:n}))}renderComboboxOptionsList({input:e,options:t,props:n}){let r=e=>e.map(e=>{let{value:t}=e,r=X(e.value)?this.messages.empty:e.name;return Y(`calcite-combobox-item`,{heading:r,key:`#${t}`,selected:n.value===t,value:`${t}`})}),i=[],{messages:a}=this;t.other.length>0&&i.push(Y(`calcite-combobox-item-group`,{key:`other`,label:a.other},r(t.other))),t.unsupported.length>0&&i.push(Y(`calcite-combobox-item-group`,{key:`unsupported`,label:a.unsupported},r(t.unsupported)));let o=r(t.recommended);i.length>0?i.unshift(Y(`calcite-combobox-item-group`,{key:`recommended`,label:a.recommended},o)):i=o;let s=n.placeholder===this.messages.differentValuesPlaceholder,c=!s&&X(n.value);return e.showNoValueOptionEnabled&&!t.containsEmptyOption&&i.unshift(Y(`calcite-combobox-item`,{heading:e.showNoValueLabel||this.messages.empty,key:`empty-option`,selected:c,value:``})),s&&i.unshift(Y(`calcite-combobox-item`,{heading:this.messages.differentValuesPlaceholder,key:N,selected:!0,value:N})),i}_renderRadioButtonGroupComponent({input:e,options:t,props:n}){let r=[...t.recommended,...t.other,...t.unsupported].map(({name:t,value:r})=>this._renderRadioButtons({label:t,value:r,selected:r===e.value,props:n}));if(e.showNoValueOptionEnabled&&!t.containsEmptyOption){let t=e.showNoValueLabel||this.messages.empty,i=X(e.value);r.unshift(this._renderRadioButtons({label:t,value:``,selected:i,props:n}))}return Y(`calcite-radio-button-group`,{afterCreate:this._afterRadioGroupCreateOrUpdate,afterUpdate:this._afterRadioGroupCreateOrUpdate,class:w.inputRadioGroup,"data-field-name":n[Q],disabled:n.readOnly||n.disabled,key:`${n.key}-radio-group`,layout:`vertical`,name:`${n.name}-${this.id}`,required:n.required},r,n.placeholder===this.messages.differentValuesPlaceholder?Y(`calcite-label`,{class:w.placeholderRadio,key:n.label,layout:`inline`},Y(`calcite-radio-button`,{checked:!0,class:w.inputRadio,disabled:!0,value:n.placeholder}),n.placeholder):null)}_renderRadioButtons({value:e,selected:t,label:n,props:r}){return Y(`calcite-label`,{class:w.inputRadioLabel,key:r.label,layout:`inline`},Y(`calcite-radio-button`,{...r,afterCreate:void 0,afterUpdate:void 0,checked:t,class:w.inputRadio,disabled:r.readOnly||r.disabled,name:void 0,value:e,onCalciteRadioButtonChange:({currentTarget:e})=>{e.checked&&this._saveInputFromElement(e)}}),n)}_renderStringComponent(e,t){let{template:n}=e;return!n.field.editable||this.readOnly?this._renderReadOnlyComponent(e):n.input?.type===`text-area`?Y(`calcite-text-area`,{...t,class:this.classes(w.individualElement),resize:`vertical`,value:t.value?String(t.value):``,onblur:n=>{t.onblur(n),e.userHasChangedValue&&this._saveInputFromElement(n.currentTarget)},onCalciteTextAreaInput:t=>{e.userHasChangedValue=!0,t.currentTarget.value===``&&this._saveInputFromElement(t.currentTarget)}}):Y(`calcite-input`,{...t,class:this.classes(w.individualElement),type:`text`,value:t.value?String(t.value):``,onblur:n=>{t.onblur(n),e.userHasChangedValue&&this._saveInputFromElement(n.currentTarget)},onCalciteInputInput:t=>{e.userHasChangedValue=!0,t.currentTarget.value===``&&this._saveInputFromElement(t.currentTarget)}})}_renderNumberComponent(e,t){let n=h(e.field);return Y(`calcite-input-number`,{...t,integer:n,step:n?1:`any`,type:`number`,value:n&&t.value!==``?Math.round(parseFloat(String(t.value))).toString():String(t.value),onblur:n=>{t.onblur(n),e.userHasChangedValue&&this._saveInputFromElement(n.currentTarget)},onCalciteInputNumberInput:t=>{e.userHasChangedValue=!0,t.currentTarget.value===``&&this._saveInputFromElement(t.currentTarget)}})}_renderReadOnlyComponent(e,t){let n=this.getCommonInputProps(e);return Y(`calcite-input`,{...n,class:this.classes(w.fieldInput,w.inputDisabled,w.individualElement),readOnly:!0,type:`text`,value:String(t??n.value??``)})}_renderDateComponents(e,t){let{field:n}=e,r;switch(n.type){case`date`:r=this._renderDateFieldComponents(e,t);break;case`date-only`:r=this._renderDateOnlyFieldComponent(e,t);break;case`time-only`:r=this._renderTimeOnlyFieldComponent(e,t);break;case`timestamp-offset`:r=this._renderTimestampOffsetFieldComponents(e,t);break;default:r=this._renderReadOnlyComponent(e,ue(n,t.value,{timeZone:e.effectiveTimeZone,...de(e.template.field)}))}return e.value===N?[r,Y(`calcite-input-message`,{icon:`information`,key:`diff-values-message`,status:`idle`},this.messages.differentValues)]:r}_renderDateOnlyFieldComponent(e,t){let{class:n,disabled:r,key:i,readOnly:a}=t,{rawMax:o,rawMin:s}=e.range;return Y(`calcite-input-date-picker`,{afterCreate:this._afterDateComponentCreateOrUpdate,afterUpdate:this._afterDateComponentCreateOrUpdate,class:n,"data-date-part":`date`,"data-element-id":t[Z],"data-field-name":t[Q],disabled:r,key:`${i}-date-input`,max:g(o)?o:void 0,min:g(s)?s:void 0,overlayPositioning:`fixed`,readOnly:a,topLayerDisabled:this.topLayerDisabled,value:e.value===N?``:e.value?String(e.value):``,onblur:t.onblur,onCalciteInputDatePickerChange:t=>this._saveValueFromDateComponent(e,t.currentTarget),onfocus:t.onfocus})}_renderTimeOnlyFieldComponent(e,t){let{class:n,disabled:r,key:i,readOnly:a}=t;return Y(`calcite-input-time-picker`,{afterCreate:this._afterDateComponentCreateOrUpdate,afterUpdate:this._afterDateComponentCreateOrUpdate,class:n,"data-date-part":`time`,"data-element-id":t[Z],"data-field-name":t[Q],disabled:r,key:`${i}-time-input`,overlayPositioning:`fixed`,readOnly:a,step:e.timeStep,value:e.value===N?``:e.value?String(e.value):``,onblur:t.onblur,onCalciteInputTimePickerChange:t=>this._saveValueFromDateComponent(e,t.currentTarget),onfocus:t.onfocus})}_renderTimestampOffsetFieldComponents(e,t){let{class:n,disabled:r,key:i,readOnly:a,onblur:o,onfocus:s}=t,{rawMax:c,rawMin:l}=e.range,u=e.effectiveTimeZone,d=W(c,u),f=W(l,u),p=W(e.value===N?``:e.value,u),m=e.includeTimeOffset,h={afterCreate:this._afterDateComponentCreateOrUpdate,afterUpdate:this._afterDateComponentCreateOrUpdate,disabled:r,[Z]:t[Z],[Q]:t[Q],onblur:o,onfocus:s,overlayPositioning:`fixed`,readOnly:a};return Y(`div`,{class:w.dateInputContainer,key:`${i}-date-time-container`},Y(`calcite-input-date-picker`,{...h,class:n,"data-date-part":`date`,key:`${i}-date-input`,max:d?.date??void 0,min:f?.date??void 0,topLayerDisabled:this.topLayerDisabled,value:p.date??``,onCalciteInputDatePickerChange:t=>this._saveValueFromDateComponent(e,t.target)}),Y(`calcite-input-time-picker`,{...h,class:n,"data-date-part":`time`,key:`${i}-time-input`,step:e.timeStep,value:p.time??``,onCalciteInputTimePickerChange:t=>this._saveValueFromDateComponent(e,t.target)}),m?Y(`calcite-input-time-zone`,{...h,class:n,clearable:e.value===N||e.value==null,"data-date-part":`timeZone`,key:`${i}-timezone-input`,value:p.timeZoneOffset||``,onCalciteInputTimeZoneChange:t=>this._saveValueFromDateComponent(e,t.target)}):null)}_renderDateFieldComponents(e,t){let{class:n,disabled:r,key:i,readOnly:a,min:o,max:s}=t,c=e.effectiveTimeZone,l=G(e.value===N?``:e.value,c),u=G(s,c),d=G(o,c),f=e.includeTime,p={afterCreate:this._afterDateComponentCreateOrUpdate,afterUpdate:this._afterDateComponentCreateOrUpdate,disabled:r,[Z]:t[Z],[Q]:t[Q],onblur:t.onblur,onfocus:t.onfocus,overlayPositioning:`fixed`,readOnly:a};return Y(`div`,{class:w.dateInputContainer,key:`${i}-date-time-container`},Y(`calcite-input-date-picker`,{...p,class:n,"data-date-part":`date`,key:`${i}-date-input`,max:u?.date??void 0,min:d?.date??void 0,topLayerDisabled:this.topLayerDisabled,value:l.date??``,onCalciteInputDatePickerChange:t=>this._saveValueFromDateComponent(e,t.target)}),f?Y(`calcite-input-time-picker`,{...p,"data-date-part":`time`,key:`${i}-time-input`,step:1,value:l.time??``,onCalciteInputTimePickerChange:t=>{this._saveValueFromDateComponent(e,t.target)}}):null)}_renderRelationshipElementInput(e){return this._relatedRecordsEnabled?Y(B,{afterObserverCreated:this._afterListObserverCreated,afterObserverRemoved:this._afterListObserverRemoved,input:e,messages:this.messages,messagesCommon:this.messagesCommon,viewModel:this.viewModel}):null}_renderRelationshipListPage(){let{activeRelationshipInput:e}=this.viewModel;if(e)return this._renderRelationshipElementInput(e)}_renderAttachmentElementInput(e){if(!this.attachmentsEnabled)return;let{allAttachmentsVisibleOnDefaultPage:t,attachments:n,defaultPageAttachments:r,template:{description:i,elementId:a,label:o}}=e,s=t?n:r;return Y(`div`,{class:w.attachmentElementInput,"data-testid":`attachment-element-${a}`,key:`attachment-element-${a}`},o?Y(`div`,{class:w.attachmentElementLabel,key:`attachment-element-label-${a}`},o):null,i?Y(`div`,{class:w.description,key:`attachment-element-description-${a}`},i):null,n.length?this._renderAttachmentList(e,s,{label:o||this.messagesCommon.details,viewAllCount:t?null:n.length}):Y(`div`,{class:w.attachmentElementEmptyState,key:`attachment-element-empty-state-${a}`},this.messages.attachments.noAttachments),this._renderAttachmentAddAction(e))}_renderAttachmentListPage(){let e=this.viewModel.selectedAttachmentListInput;if(e)return Y(`div`,{class:w.attachmentElementAllPanel,key:`attachment-element-all-panel-${e.template.elementId}`},this._renderAttachmentList(e,e.attachments,{filterEnabled:!0,label:this.messages.titles.attachments}))}_renderAttachmentList(e,t,n){let{filterEnabled:r,label:i,viewAllCount:a}=n;return Y(`calcite-list`,{class:w.attachmentElementList,filterEnabled:r,filterPlaceholder:r?this.messages.attachments.searchAttachments:void 0,filterProps:r?he:void 0,filterText:r?this._attachmentListFilterText:void 0,label:i,selectionAppearance:`border`,selectionMode:`none`,onCalciteListFilter:r?e=>{this._attachmentListFilterText=e.currentTarget.filterText??``}:void 0},this._renderAttachmentListItems(e,t),a==null?null:this._renderViewAllAttachmentsItem(e,a))}_renderAttachmentListItems(e,t){let{elementId:n}=e.template;return t.map((t,r)=>{let i=this._formatAttachmentSize(t.size),a=this._getAttachmentLabel(t,r,i,e.displayFilename),o=a===i?void 0:i,s=v(t),c=e.isStagedAttachmentAddition(t),l=e.getAttachmentEditState(t),u=l.isDeleted,d=!u&&(c||l.isRenamed||l.isReplaced);return Y(`calcite-list-item`,{class:w.attachmentElementListItem,description:o,key:`attachment-item-${s}`,label:a,onCalciteListItemSelect:c||u?void 0:()=>this._setSelectedAttachment({attachmentKey:s,elementId:n})},Y(`div`,{class:w.attachmentElementListItemStart,slot:`content-start`},this._renderAttachmentPreviewThumbnail(t,a,e)),d?Y(`span`,{class:w.attachmentElementListItemStagedIndicator,slot:`content-end`}):null,c?[Y(`calcite-action`,{disabled:this._disableAttachmentModification(e),icon:`x`,scale:`s`,slot:`actions-end`,text:this.messagesCommon.delete,title:this.messagesCommon.delete,onclick:()=>this.viewModel.stageDeleteAttachment(n,v(t))})]:u?Y(`calcite-chip`,{label:this.messages.attachments.deleted,scale:`s`,slot:`content-end`},this.messages.attachments.deleted):Y(`calcite-icon`,{flipRtl:!0,icon:`chevron-right`,scale:`s`,slot:`content-end`}))})}_renderViewAllAttachmentsItem(e,n){let{elementId:r}=e.template,{viewAll:i}=this.messages.attachments;return Y(`calcite-list-item`,{class:w.attachmentElementListItem,description:t(this.messages.attachments.count,{count:n}),key:`attachment-item-view-all-${r}`,label:i,onCalciteListItemSelect:()=>this._setAttachmentListElementId(r)},Y(`calcite-icon`,{flipRtl:!0,icon:`chevron-right`,scale:`s`,slot:`content-end`}))}_renderAttachmentAddAction(e){let{elementId:t}=e.template,n=this.effectiveDisabled||e.addDisabled,r=this._renderAttachmentCountLimitsLabel(e),i=this._getAttachmentNoticeMessage(e),a=e.hasMinimumAttachmentCountNotMet||e.hasExceededAttachmentLimit?`danger`:`info`,o=e.canUploadFiles,s=e.isCaptureOnly&&!this.effectiveDisabled&&!i;return Y(`div`,{class:w.attachmentElementAddActions,key:`attachment-element-add-actions-${t}`},o?Y(`calcite-button`,{appearance:`outline`,disabled:n,iconStart:`attachment`,kind:`neutral`,round:!0,scale:`s`,onclick:()=>this._setAttachmentAddElementId(t)},this.messages.attachments.attach):null,this._renderAttachmentCaptureButton(e),s?this._renderAttachmentCaptureDisabledNotice(t):null,r?Y(`div`,{class:w.attachmentElementEmptyActionHint},r):null,!this.effectiveDisabled&&i?Y(`calcite-notice`,{closable:!1,icon:a===`danger`?`exclamation-mark-circle`:`lightbulb`,kind:a,open:!0,scale:`s`,width:`full`},Y(`div`,{slot:`message`},i)):null)}_renderAttachmentCaptureButton(e){if(!e.hasCaptureInputs)return null;let t=e.captureMediaType;return Y(`calcite-button`,{appearance:`outline`,disabled:!0,iconStart:ve(t),kind:`neutral`,round:!0,scale:`s`},this._getCaptureButtonLabel(t))}_getAttachmentNoticeMessage(e){let 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||e.touched}_getCaptureButtonLabel(e){let{capture:t,recordAudio:n,takePhoto:r,takeVideo:i}=this.messages.attachments;switch(e){case`image`:return r||t;case`video`:return i||t;case`audio`:return n||t;default:return t}}_renderAttachmentAddPage(){let e=this.viewModel.selectedAttachmentAddInput;return e?this._renderAttachmentAddPanel(e):null}_renderAttachmentAddPanel(e){let{maxAttachmentCount:t}=e,{elementId:n}=e.template;if(e.isCaptureOnly)return this._renderAttachmentCaptureDisabledNotice(n);let r=t==null||t-e.attachments.length>1,i=this.effectiveDisabled||e.addDisabled,a=this.messages.attachments,o=a.dragAndDropFile,s=e=>{this._attachmentFileInputMap.set(n,e)};return Y(`div`,{class:w.attachmentElementAddPanel,key:`attachment-element-add-panel-${n}`},Y(`input`,{accept:e.accept,afterCreate:s,afterRemoved:()=>{this._attachmentFileInputMap.delete(n)},afterUpdate:s,class:w.attachmentElementFileInput,"data-element-id":n,disabled:i,multiple:r,type:`file`,onchange:e=>{let t=e.currentTarget,r=t.files?Array.from(t.files):[];this._stageAttachmentFiles(n,r),t.value=``}}),Y(`div`,{class:w.attachmentElementAddDropzone,"data-disabled":i?`true`:`false`,ondragover:e=>{e.stopPropagation(),e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=`copy`)},ondrop:e=>{if(e.preventDefault(),e.stopPropagation(),i)return;let t=e.dataTransfer?.files?Array.from(e.dataTransfer.files):[];this._stageAttachmentFiles(n,t)}},Y(`calcite-icon`,{class:w.attachmentElementAddDropzoneIcon,icon:`upload`,scale:`l`}),Y(`div`,{class:w.attachmentElementAddDropzoneHeading},a.addFile),Y(`div`,{class:w.attachmentElementAddDropzoneDetail,title:o},o),Y(`calcite-button`,{appearance:`transparent`,disabled:i,iconStart:`folder-open`,kind:`brand`,scale:`s`,type:`button`,onclick:e=>{e.stopPropagation(),this._openAttachmentFilePicker(n,i)}},a.selectFile)),this._renderAttachmentValidationCriteria(e,{includeCountCriteria:!0}))}_renderAttachmentCaptureDisabledNotice(e){return Y(`calcite-notice`,{class:w.attachmentElementCaptureNotice,icon:!0,key:`attachment-element-capture-disabled-notice-${e}`,kind:`warning`,open:!0,scale:`s`},Y(`div`,{slot:`message`},this.messages.attachments.captureMethodNotSupported))}async _stageAttachmentFiles(e,t){if(t.length===0)return;let n=this.viewModel.selectedAttachmentAddInput,r=!0;try{r=(await this.viewModel.stageAddAttachments(e,t)).length>0&&!n?.hasInvalidValidationCriteria&&!n?.hasUnsupportedFileTypeValidationError}finally{r&&this.viewModel.setSelectedAttachmentAddElementId(null)}}_openAttachmentFilePicker(e,t){t||this._attachmentFileInputMap.get(e)?.click()}_renderAttachmentDetailPage(){let e=this.selectedAttachmentDetails;if(!e)return;if(this.page===`replacing-attachment`)return this._renderAttachmentReplacePanel(e);let{attachment:t,input:n}=e,r=v(t),i=!!n.getAttachmentPreviewUrl(t),a=!this._disableAttachmentModification(n)&&n.canUploadFiles,o=n.getAttachmentEditState(t);return Y(`div`,{class:w.attachmentElementDetail,key:`attachment-detail-panel-${n.template.elementId}-${r}`},Y(`div`,{class:w.attachmentElementDetailPreview},this._renderAttachmentPreviewImageForInput(t,n)),Y(`div`,{class:w.attachmentElementDetailActions},y(t)?Y(`calcite-button`,{appearance:`outline`,disabled:!i,iconStart:`expand`,kind:`neutral`,label:this.messages.attachments.maximize,scale:`m`,title:this.messages.attachments.maximize,onclick:this._maximizeSelectedAttachment}):null,Y(`calcite-button`,{appearance:`outline`,disabled:!i||o.isReplaced,iconStart:`download`,kind:`neutral`,label:this.messages.attachments.download,scale:`m`,title:this.messages.attachments.download,onclick:()=>{this._downloadAttachment(t)}}),Y(`calcite-button`,{appearance:`outline`,disabled:!a,iconStart:`upload-to`,kind:`neutral`,label:this.messages.attachments.replace,scale:`m`,title:this.messages.attachments.replace,onclick:this._enterAttachmentReplaceView})),Y(`div`,{class:w.attachmentElementDetailMetadata},Y(`div`,{class:w.attachmentElementDetailMetadataGroup},Y(`span`,{class:w.attachmentElementDetailMetadataLabel},this.messages.attachments.fileName),this._renderFileNameContent(t,n)),Y(`div`,{class:w.attachmentElementDetailMetadataGroup},Y(`span`,{class:w.attachmentElementDetailMetadataLabel},this.messages.attachments.size),Y(`span`,{class:w.attachmentElementDetailMetadataValue},this._formatAttachmentSize(t.size))),Y(`div`,{class:w.attachmentElementDetailMetadataGroup},Y(`span`,{class:w.attachmentElementDetailMetadataLabel},this.messages.attachments.type),Y(`span`,{class:w.attachmentElementDetailMetadataValue},this._getLabelForAttachmentType(t)))))}_renderFileNameContent(e,t){if(!t.allowUserRename)return Y(`span`,{class:w.attachmentElementDetailMetadataValue},e.name);let n=t.getAttachmentEditState(e),{baseName:r,extension:i}=b(e.name),a=this._disableAttachmentModification(t),o=!a&&e.name.trim().length===0;return[Y(`div`,{class:w.attachmentElementDetailFileNameRow,key:`file-name-row`},Y(`calcite-input`,{class:w.attachmentElementDetailFileNameInput,disabled:a,scale:`m`,status:o?`invalid`:`idle`,suffixText:i,value:r,onCalciteInputInput:({currentTarget:e})=>this._renameSelectedAttachment(e.value)}),Y(`calcite-button`,{appearance:`transparent`,disabled:a||n.initialName==null||!n.isRenamed,iconStart:`reset`,kind:`neutral`,label:this.messages.footerButtons.reset,scale:`m`,title:this.messages.footerButtons.reset,onclick:this._resetSelectedAttachmentName})),o?Y(`calcite-input-message`,{icon:!0,key:`file-name-message`,status:`invalid`},this.messages.validationErrors.cannotBeNull):null]}_renderAttachmentReplacePanel(e){let{attachment:t,input:n}=e,r=this._disableAttachmentModification(n)||!n.canUploadFiles,i=n.template.elementId;return Y(`div`,{class:w.attachmentElementAddPanel,key:`attachment-replace-panel-${i}-${v(t)}`},Y(`input`,{accept:n.accept,afterCreate:this._setSelectedAttachmentReplaceFileInput,afterRemoved:()=>{this._selectedAttachmentReplaceFileInput=null},afterUpdate:this._setSelectedAttachmentReplaceFileInput,class:w.attachmentElementFileInput,disabled:r,type:`file`,onchange:e=>{let t=e.currentTarget,n=t.files?.[0];n&&this._stageSelectedAttachmentReplacement(n),t.value=``}}),Y(`div`,{class:w.attachmentElementAddDropzone,"data-disabled":r?`true`:`false`,ondragover:e=>{e.preventDefault(),e.stopPropagation(),e.dataTransfer&&(e.dataTransfer.dropEffect=`copy`)},ondrop:e=>{if(e.preventDefault(),e.stopPropagation(),r)return;let t=e.dataTransfer?.files?.[0];t&&this._stageSelectedAttachmentReplacement(t)}},Y(`calcite-icon`,{class:w.attachmentElementAddDropzoneIcon,icon:`refresh`,scale:`l`}),Y(`div`,{class:w.attachmentElementAddDropzoneHeading},this.messages.attachments.replace),Y(`div`,{class:w.attachmentElementAddDropzoneDetail,title:this.messages.attachments.dragAndDropFile},this.messages.attachments.dragAndDropFile),Y(`calcite-button`,{appearance:`transparent`,disabled:r,iconStart:`folder-open`,kind:`brand`,scale:`s`,onclick:e=>{e.stopPropagation(),this._openSelectedAttachmentReplaceFilePicker()}},this.messages.attachments.selectFile)),this._renderAttachmentValidationCriteria(n,{includeCountCriteria:!1}),Y(`div`,{class:w.attachmentElementDetailMetadata},Y(`div`,{class:w.attachmentElementDetailMetadataGroup},Y(`span`,{class:w.attachmentElementDetailMetadataLabel},this.messages.attachments.fileToBeReplaced),Y(`span`,{class:w.attachmentElementDetailMetadataValue},t.name))))}_renderAttachmentDialog(){let e=this._attachmentDialogInfo;if(!e)return null;let{attachment:t,input:n}=e;return Y(`calcite-dialog`,{heading:t.name||this.messagesCommon.details,key:`attachment-preview-dialog`,modal:!0,open:!0,placement:`cover`,width:`l`,onCalciteDialogClose:this._closeAttachmentDialog},Y(`div`,{class:w.attachmentElementDialogPreview},this._renderAttachmentPreviewImageForInput(t,n)))}_setSelectedAttachment(e,t){t?.touch(),this.viewModel.setSelectedAttachment(e),e||this.hideAttachmentDialog()}_setAttachmentAddElementId(e){let{viewModel:t}=this;t.setSelectedAttachmentAddElementId(e),t.selectedAttachmentAddInput?.touch(),t.selectedAttachmentAddInput?.clearValidationCriteriaState(),this.hideAttachmentDialog()}_setAttachmentListElementId(e){let{viewModel:t}=this;t.setSelectedAttachmentListElementId(e),t.selectedAttachmentListInput?.touch(),this.hideAttachmentDialog()}_getAttachmentLabel(e,n,r,i){return i!==!1&&g(e.name)&&e.name.length>0?e.name:r===this.messagesCommon.notApplicable?t(this.messages.attachments.attachmentNumberedLabel,{index:n+1}):r}_renderAttachmentCountLimitsLabel(e){let t=this.messages.attachments,n=e.minAttachmentCount!=null&&e.minAttachmentCount>0?this._renderAttachmentCountLimitLabel(t.minAttachmentsShort,e.minAttachmentCount,`min`):null,r=e.maxAttachmentCount==null?null:this._renderAttachmentCountLimitLabel(t.maxAttachmentsShort,e.maxAttachmentCount,`max`);return!n&&!r?null:[n,n&&r?Y(`span`,{key:`attachment-count-limits-separator`},`, `):null,r]}_renderAttachmentCountLimitLabel(e,n,r){let i=`__count__`,[a,o]=t(e,{count:i}).split(i);return Y(`span`,{key:r},a,Y(`span`,{class:w.attachmentElementEmptyActionHintValue},n),o)}_renderAttachmentValidationCriteria(e,{includeCountCriteria:t}){let n=this._getAttachmentValidationCriteria(e,{includeCountCriteria:t}),r=`attachment-validation-criteria-${e.template.elementId}`;return n.length===0?null:Y(`div`,{class:w.attachmentElementValidationCriteria,key:r},n.map(({key:e,message:t,state:n})=>Y(`calcite-notice`,{appearance:n===`danger`?`outline-fill`:`transparent`,closable:!1,icon:!0,key:e,kind:n,open:!0,scale:`s`,width:`full`},Y(`div`,{slot:`message`},t))))}_getAttachmentValidationCriteria(e,{includeCountCriteria:n}){let r=[],i=e.validationCriterionStates,a=this.messages.attachments,o=this._getNestableAttachmentInputs(e.input);e.hasUnsupportedFileTypeValidationError&&r.push({key:`unsupported-file-type`,message:this._getUnsupportedFileTypeMessage(),state:`danger`});for(let e of o)e.type===`document`&&e.maxFileSize!=null&&r.push({key:`maximum-file-size`,message:t(a.maximumFileSize,{maxSize:this._formatAttachmentSizeLimitInMegabytes(e.maxFileSize)}),state:i.get(`maximum-file-size`)??`info`}),e.type===`audio`&&e.maxDuration!=null&&r.push({key:`maximum-audio-length`,message:t(a.maximumAudioLength,{maxDuration:this._formatAttachmentDurationLimit(e.maxDuration)}),state:i.get(`maximum-audio-length`)??`info`}),e.type===`video`&&e.maxDuration!=null&&r.push({key:`maximum-video-length`,message:t(a.maximumVideoLength,{maxDuration:this._formatAttachmentDurationLimit(e.maxDuration)}),state:i.get(`maximum-video-length`)??`info`}),e.type===`image`&&e.maxImageSize!=null&&r.push({key:`maximum-image-size`,message:t(a.attachmentMustBeSmallerThan,{maxSize:`${e.maxImageSize}px`}),state:i.get(`maximum-image-size`)??`info`});return n&&e.minAttachmentCount!=null&&e.minAttachmentCount>0&&r.push({key:`minimum-number-of-files`,message:t(a.minimumNumberOfFiles,{count:e.minAttachmentCount}),state:i.get(`minimum-number-of-files`)??`info`}),n&&e.maxAttachmentCount!=null&&r.push({key:`maximum-number-of-files`,message:t(a.maximumNumberOfFiles,{count:e.maxAttachmentCount}),state:i.get(`maximum-number-of-files`)??`info`}),r}_getNestableAttachmentInputs(e){return e==null?[]:e.type===`attachment`?e.inputTypes?.slice()??[]:[e]}_getUnsupportedFileTypeMessage(){return this.featureTableMessages.errorFileUnsupported}_formatAttachmentSize(e){return e==null||Number.isNaN(e)?this.messagesCommon.notApplicable:d(this.messagesUnits,e)}_formatAttachmentSizeLimitInMegabytes(e){return d(this.messagesUnits,e*1048576)}_formatAttachmentDurationLimit(e){return m(Math.round(e)*1e3,{...e>=3600?{hour:`2-digit`,hourCycle:`h23`}:{},minute:`2-digit`,second:`2-digit`,timeZone:`UTC`})}_getLabelForAttachmentType({contentType:e}){if(!e)return this.messagesCommon.notApplicable;let t=this.messages.attachments.attachmentTypes,n=te(e);return t?.[n]||e}_renderAttachmentPreviewThumbnail(e,t,n){let r=n.getAttachmentPreviewUrl(e,64);return r&&y(e)?Y(`img`,{alt:t,class:w.attachmentElementListItemThumb,src:r}):Y(`calcite-icon`,{class:w.attachmentElementListItemIcon,icon:_(e.contentType),scale:`s`})}_renderAttachmentPreviewImageForInput(e,t){let n=t.getAttachmentPreviewUrl(e),r=e.name||this.messagesCommon.details;return n&&y(e)?Y(`img`,{alt:r,class:w.attachmentElementDetailPreviewImage,src:n,title:r}):[Y(`calcite-icon`,{class:w.attachmentElementDetailPreviewIcon,icon:_(e.contentType),scale:`l`,textLabel:r,title:r}),this.messages.attachments.noPreviewAvailable]}async _downloadAttachment(e){await H(e)}_canReplaceSelectedAttachment(){return!this.effectiveDisabled&&!!this.selectedAttachmentDetails?.input.canUploadFiles}_exitAttachmentReplaceView(){this.viewModel.setShowingSelectedAttachmentReplacePage(!1),this._selectedAttachmentReplaceFileInput=null}async _stageSelectedAttachmentReplacement(e){let t=this.selectedAttachmentDetails;if(!t?.attachment)return;let n=t.input.template.elementId,r=v(t.attachment),i=!1;try{i=await this.viewModel.stageReplaceAttachment(n,r,e)}finally{i&&this._exitAttachmentReplaceView()}}_renameSelectedAttachment(e){let t=this.selectedAttachmentDetails;if(!t?.attachment)return;let n=t.input.template.elementId,r=v(t.attachment);this.viewModel.stageRenameAttachment(n,r,e)}_resetSelectedAttachmentChanges(){let e=this.selectedAttachmentDetails;e?.attachment&&this.viewModel.resetAttachmentChanges(e.input.template.elementId,v(e.attachment))}_deleteSelectedAttachment(){let e=this.selectedAttachmentDetails;if(!e?.attachment||this._disableAttachmentModification(e.input))return;let t=e.input.template.elementId,n=v(e.attachment);this.viewModel.stageDeleteAttachment(t,n),this._setSelectedAttachment(null)}_disableAttachmentModification(e){return this.disabledOrReadOnly||!e.editable}hideAttachmentDialog(){this._attachmentDialogInfo=null}_renderTextComponent(e){let{elementId:t}=e.template;return Y(`div`,{class:w.textElementInput,"data-testid":`text-element-${t}`,innerHTML:e.text,key:`text-element-${t}`})}_renderUtilityNetworkAssociationsElementInput(e){if(!this._associationsEnabled)return;let{elementId:t}=e.template;return Y(`div`,{class:w.utilityNetworkAssociationsElementInput,"data-testid":t,key:t},this._associationsWidgetsMap.get(e)?.render())}getCommonInputProps(e){let{template:t,valid:n,value:r,minLength:i,maxLength:a,required:o,fieldName:s,editable:c,status:l,range:{max:u,min:d}}=e,f=!c||this.readOnly,p=this.disabled||this.viewModel.updating,m=t.hint??void 0,h=!1;return r===N&&(m=this.messages.differentValuesPlaceholder,h=!0),{afterCreate:this._afterComponentCreateOrUpdate,afterUpdate:this._afterComponentCreateOrUpdate,"aria-invalid":n?`false`:`true`,class:this.classes(w.fieldInput,f?w.inputDisabled:null),status:l,maxLength:a&&a>-1?a:void 0,minLength:i&&i>-1?i:void 0,key:t.elementId,label:s,name:s,max:u??void 0,min:d??void 0,disabled:p,readOnly:f,onblur:this._onComponentBlur,required:o,placeholder:m,value:h?``:r??``,[Z]:t.elementId,[Q]:s,onfocus:this._onComponentFocus}}_onObserverChange(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode);let e=this.viewModel.activeRelationshipInput;e&&this._listObserverNode&&e.showAllEnabled&&this._listObserver.observe(this._listObserverNode)}_onFormSubmit(e){e.preventDefault()}_handleDragAndDrop(e){e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=`none`)}_getFieldInputFromHTMLElement(e){return this.viewModel.findFieldInput(e.getAttribute(Z))}_afterRadioGroupCreateOrUpdate(e){let t=e.selectedItem,n=e.querySelector(`calcite-radio-button`),r=t||n;r&&this._afterComponentCreateOrUpdate(r)}_onComponentFocus(e){let t=e.target,n=this._getFieldInputFromHTMLElement(t);this._focusedFieldInput=n}_isMultipleChoiceCheckbox(e,t){let n=this._getMultipleChoiceController(t);return e.tagName===`CALCITE-CHECKBOX`&&n?.input!=null}_afterComponentCreateOrUpdate(e){let t=this._getFieldInputFromHTMLElement(e),n=this._focusedFieldInput;this._attemptFocusOnNextRender&&n===t&&(this._attemptFocusOnNextRender=!1,_e(e))}_onComponentBlur(e){let t=e.target,n=this._getFieldInputFromHTMLElement(t);this._isMultipleChoiceCheckbox(t,n)||n.touch(),this._focusedFieldInput=null}_onDynamicChoiceBlur(e,t){let n=e.currentTarget;if(this._dynamicChoiceItemSelections.delete(t))return;let r=e.relatedTarget;r instanceof Node&&n.contains(r)||(t.endInteraction(),n.inputValue=t.inputValue,this._onComponentBlur(e))}_resetTransientFormState(){this._attemptFocusOnNextRender=!1,this._focusedFieldInput=null,this._attachmentDialogInfo=null,this._selectedAttachmentReplaceFileInput=null,this._attachmentListFilterText=``,this._attachmentFileInputMap.clear()}_parseValue(e,t,n=!1){let r=this._getMultipleChoiceController(t);if(r){let{input:t,values:i}=r;if(t&&i){let t=e;return r.getValueFromCheckboxChange({choiceValue:t.value,isChecked:t.checked,isSelectAllCheckbox:n})}}if(S(t.template,`switch`)){if(e.localName===`calcite-dropdown`&&t.domain){for(let n of t.domain.codedValues)if(n.name===e.selectedItems[0].textContent)return n.code}return e.checked?t.template.input.onValue:t.template.input.offValue}let i=e.value;return i==null||i===``?null:t.dataType===`number`?i===`-0`||i===`-0.`||i===`-0,`?i:parseFloat(i):t.field.type===`date`?parseFloat(i):i}_getMultipleChoiceController(e){return k(e.inputController)?e.inputController:null}_saveInputFromElement(e){let t=this._getFieldInputFromHTMLElement(e);if(!t)return;let n=this._parseValue(e,t);this._saveInput(t,n)}_saveInput(e,t){let{elementId:n}=e.template,r=e?.value,{viewModel:a}=this;if(S(e.template,`switch`)&&a.mode!==`single`){let t=i(this._batchSwitchInputInitialValues,e,()=>e.value);this._batchSwitchInputInitialValues.set(e,t===null?r:t)}t!==r&&(e.touch(),!e.isSubtypeField||a.mode===`batch`||!re(a.activeLayer,r,t)?a.setValue(n,t):this._pendingSubtypeChoice||=this._handleSubtypeChoice(e,t))}async _handleSubtypeChoice(e,n){let{value:r,template:i}=e,{elementId:a}=i,{messages:o,viewModel:s,messagesCommon:c}=this,{subtypes:l,activeFeatureIndex:u}=s;if(await s.setValue(a,n),!l?.length)return;let d=l.find(e=>e.code===n),f=l.find(e=>e.code===r)?.name??`${r}`;if(!d)return;let p=Promise.withResolvers();s.pendingSubtypeChoice=p;let m=`update-fields`,h=[{label:o.subtypes.useDefaultValuesOption,value:`update-fields`},{label:o.subtypes.keepCurrentValuesOption,value:`keep-existing`}],g={context:`info`,title:o.subtypes.changeWarningTitle,message:t(o.subtypes.changeWarning,{originalType:f,newType:d.name}),radios:h,defaultRadioSelection:`update-fields`,onRadioSelection:e=>{m=e},actions:{primary:{label:c.apply,action:()=>p.resolve(m),type:`positive`},secondary:{label:c.cancel,type:`neutral`,action:()=>p.resolve(`undo`)}},cancel:()=>p.reject()};try{switch(this.showPrompt(g),await p.promise){case`update-fields`:await s.applySubtypeDefaults(d),await s.handleSubtypeChanged(u);break;case`keep-existing`:await s.handleSubtypeChanged(u);break;case`undo`:await this.viewModel.setValue(a,r)}}finally{s.pendingSubtypeChoice=null,this.clearPrompt(),this._pendingSubtypeChoice=null}}_afterDateComponentCreateOrUpdate(e){this._setDateTimeTimeZoneMap(e),this._afterComponentCreateOrUpdate(e)}_saveValueFromDateComponent(e,t){let{elementId:n}=e.template,r=e.field.type,i=this._dateComponentMap.get(`${n}`);if(!i)return;let a=e.effectiveTimeZone,o=e.value===N?void 0:e.value,s=null;r===`date-only`?s=Array.isArray(t.value)?t.value[0]:t.value:r===`time-only`?(o=K(o),s=K(t.value)):s=r===`timestamp-offset`?t.value==null?null:fe({dateComponent:i.date,timeComponent:i.time,oldValue:o,timeZoneComponent:i.timeZone,defaultTimeZone:a}):t.value==null?null:pe({oldValue:o,dateComponent:i.date,timeZone:a,timeComponent:i.time?.value===N?void 0:i.time}),o!==s&&(e.touch(),s===null||!t.value?this.viewModel.setValue(n,null):this.viewModel.setValue(n,s))}_renderViewingAssociationsPage(){return this._associationsList?.render()}_onActiveAssociationsInputChange(e){let t=this._associationsList;t&&(e?(t.associationInput=e,t.viewModel=e.viewModel):t.associationInput=null)}async _setUpAssociationsWidgets(){let e=this.viewModel.activeForm.allUtilityNetworkAssociationsElementInputs;if(this._associationsEnabled&&e.length!==0){await this._setUpUtilityNetworkAssociationList();for(let t of e)this._associationsWidgetsMap.set(t,await this._createAssociationsWidget(t))}}async _setUpUtilityNetworkAssociationList(){if(this._associationsList)return;let 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)});let t=this.viewModel.activeAssociationsInput;t&&(this._associationsList.associationInput=t,this._associationsList.viewModel=t.viewModel)}async _createAssociationsWidget(e){let t=(await import(`./Feature/FeatureUtilityNetworkAssociations.js`)).default;return new t({viewModel:e.viewModel,onSelectAssociationType:t=>this._onSelectAssociationType(e,t)})}_destroyAssociationsWidgets(){this._associationsWidgetsMap.forEach(e=>a(e)),this._associationsWidgetsMap.clear()}_onSelectAssociationType(e,{listType:t}){this.setActiveAssociationsInput(e),this.setActiveAssociationType(t)}_onSelectAssociatedLayer({layer:e}){this.setActiveAssociationsLayer(e)}async _onEditAssociatedFeature(e){let t=this.callbacks?.editAssociatedFeature,n=this.viewModel.activeAssociationsInput;if(!t||!n?.feature)return;let{association:r,feature:i}=e;await t({parentFeature:n.feature.plainGraphic,association:r,feature:i})}_onAddAssociation(e){let t=this.callbacks?.addAssociation,n=this.viewModel.activeAssociationsInput;if(!t||!n?.feature)return;let{associationType:r,utilityNetwork:i}=e;t({feature:n.feature.plainGraphic,associationType:r,utilityNetwork:i})}_setFocusableInput(e){let t=e&&j(e)?e:this._findFocusableInput(e);this._syncGroupInputStates(),this._focusedFieldInput=t,this._attemptFocusOnNextRender=!0}_findFocusableInput(e){let t=this.viewModel.activeForm.inputs;if(!t.length)return;let n=ie(t),r;if(!e)r=0;else if(A(e)){let t=e.inputs.find(e=>e.visible);r=t?n.indexOf(t):0}else{let i;i=F(e)&&!e.group.open?e.group.inputs.filter(j)[t.length-1]:e,r=n.indexOf(i)+1}for(let e=r;e<n.length;e++){let t=n[e];if(t.visible&&j(t)){if(this.disabledOrReadOnly&&(t?.inputType===`switch`||t?.inputType===`radio-buttons`))continue;return t}}return null}_onGroupToggle(e,t){e.expanded?(t.open=!0,this._setFocusableInput(t),this.groupDisplay===`sequential`&&this.viewModel.activeForm.allGroupInputs.forEach(e=>{e!==t&&(e.open=!1)})):t.open=!1,this.scheduleRender()}_syncGroupInputStates(){if(this.groupDisplay!==`sequential`)return;let e=this.viewModel.activeForm?.allGroupInputs;if(!e.length)return;let t=e.filter(e=>e.open);t.length===0?e[0].open=!0:t.length>1&&t.slice(1).forEach(e=>e.open=!1)}};e([f()],$.prototype,`activeFeatureIndex`,null),e([f()],$.prototype,`attachmentsEnabled`,null),e([f()],$.prototype,`callbacks`,null),e([f()],$.prototype,`disabled`,null),e([f()],$.prototype,`effectiveTitle`,null),e([f()],$.prototype,`effectiveDisabled`,null),e([f()],$.prototype,`disabledOrReadOnly`,null),e([f()],$.prototype,`features`,null),e([f()],$.prototype,`footerButtonInfos`,null),e([f()],$.prototype,`map`,null),e([f()],$.prototype,`maximumFeatureCount`,null),e([f()],$.prototype,`maximumFeatureCountWithComplexForms`,null),e([f()],$.prototype,`spatialReference`,null),e([f()],$.prototype,`layerInfos`,null),e([f()],$.prototype,`timeZone`,null),e([f()],$.prototype,`headingLevel`,void 0),e([f()],$.prototype,`icon`,null),e([f(),J(`esri/t9n/common`)],$.prototype,`messagesCommon`,void 0),e([f(),J(`esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm`)],$.prototype,`messages`,void 0),e([f(),J(`esri/widgets/FeatureForm/t9n/FeatureForm`)],$.prototype,`featureFormMessages`,void 0),e([f(),J(`esri/widgets/FeatureTable/t9n/FeatureTable`)],$.prototype,`featureTableMessages`,void 0),e([f(),J(`esri/core/t9n/Units`)],$.prototype,`messagesUnits`,void 0),e([f()],$.prototype,`page`,null),e([f()],$.prototype,`readOnly`,null),e([f()],$.prototype,`showPrompt`,null),e([f()],$.prototype,`clearPrompt`,null),e([f()],$.prototype,`selectedAttachment`,null),e([f()],$.prototype,`selectedAttachmentDetails`,null),e([f()],$.prototype,`valid`,null),e([f({type:C}),ge([`attachments-change`,`value-change`,`values-change`,`submit`])],$.prototype,`viewModel`,void 0),e([f({type:D,nonNullable:!0})],$.prototype,`visibleElements`,void 0),e([f()],$.prototype,`groupDisplay`,void 0),e([f()],$.prototype,`_formHeaderVisible`,null),e([f()],$.prototype,`_associationsEnabled`,null),e([f()],$.prototype,`_associationsList`,void 0),e([f()],$.prototype,`_attemptFocusOnNextRender`,void 0),e([f()],$.prototype,`_formId`,null),e([f()],$.prototype,`_focusedFieldInput`,void 0),e([f()],$.prototype,`_pendingSubtypeChoice`,void 0),e([f()],$.prototype,`_relatedRecordsEnabled`,null),e([f()],$.prototype,`_listObserverNode`,void 0),e([f()],$.prototype,`_attachmentDialogInfo`,void 0),e([f()],$.prototype,`_attachmentListFilterText`,void 0),e([f()],$.prototype,`_prompt`,void 0),e([f()],$.prototype,`test`,null),$=e([p(`esri.widgets.BatchAttributeForm`)],$);function ve(e){switch(e){case`audio`:return _(`audio/mpeg`);case`video`:return _(`video/mp4`);case`image`:return _(`image/png`);default:return`camera`}}const ye=$;export{ye as default};
2
+ import{__decorate as e}from"tslib";import{substitute as t}from"../intl.js";import{deprecateWidget as n}from"../core/deprecate.js";import r from"../core/Logger.js";import{getOrCreateMapValue as i}from"../core/MapUtils.js";import{destroyMaybe as a}from"../core/maybe.js";import o from"../core/ReactiveMap.js";import{watch as s,when as c,on as l,sync as u}from"../core/reactiveUtils.js";import{formatFileSize as d}from"../core/unitFormatUtils.js";import{property as f,subclass as p}from"../core/accessorSupport/decorators.js";import{formatDate as m}from"../intl/date.js";import{isIntegerField as h}from"../layers/support/fieldUtils.js";import{isString as g}from"../support/guards.js";import ee from"./Widget.js";import{getAttachmentTypeCategory as te,getCalciteIconForAttachment as _}from"./Attachments/support/attachmentUtils.js";import{getAttachmentKey as v,isImageAttachment as y,getAttachmentFilenameParts as b}from"./BatchAttributeForm/attachmentUtils.js";import{getHiddenFieldsValidationErrorMessage as ne,getMessageString as x,isElementTemplateWithInputType as S,subtypeChangeShouldPrompt as re,flattenInputs as ie}from"./BatchAttributeForm/batchAttributeFormUtils.js";import C from"./BatchAttributeForm/BatchAttributeFormViewModel.js";import{css as w}from"./BatchAttributeForm/css.js";import{makeViewingEditedAttachmentFooterButtons as ae,makeViewingAttachmentFooterButtons as oe,makeCancelFooterButton as T,makeDefaultFooterButtons as E}from"./BatchAttributeForm/interfaceUtils.js";import D from"./BatchAttributeForm/VisibleElements.js";import{isDynamicChoiceController as O,isMultipleChoiceController as k}from"./BatchAttributeForm/inputs/support/controllerUtils.js";import{isGroupInput as A,isFieldInput as j,isTextElementInput as se,isRelationshipElementInput as ce,isAttachmentElementInput as le,isUtilityNetworkAssociationsElementInput as M,differentValuesString as N,getNormalizedFieldName as P,isGroupedInput as F}from"./BatchAttributeForm/inputs/support/inputUtils.js";import{clearMultipleChoiceOtherChoiceStateForViewModel as I,otherChoiceCheckedPlaceholderValue as L,canRestoreMultipleChoiceOtherChoiceDraftValue as R}from"./BatchAttributeForm/inputs/support/multipleChoiceInputUtils.js";import{loadRelationshipDetailsComponents as z,RelationshipDetails as B}from"./BatchAttributeForm/rendered-content/RelationshipDetails.js";import{Prompt as V}from"./Editor/components/Prompt.js";import{downloadAttachmentInfo as H}from"./FeatureTable/support/exportUtils.js";import{loadCalciteComponents as U}from"./support/componentsUtils.js";import{getLabelForDateFieldValue as ue,getIntlOptionsForField as de,prepareISOFieldValueForDateComponents as W,prepareUnixFieldValueForDateComponents as G,normalizeTimeOnlyString as K,getISOFieldValueFromDateComponents as fe,getUnixFieldValueFromDateComponents as pe}from"./support/dateUtils.js";import{globalCss as q}from"./support/globalCss.js";import{Heading as me}from"./support/Heading.js";import{calciteListFilterProps as he}from"./support/listUtils.js";import{messageBundle as J,vmEvent as ge,tsx as Y}from"./support/widget.js";import{setFocus as _e}from"./support/widgetUtils.js";import{isEmptyValue as X}from"./support/forms/formUtils.js";const Z=`data-element-id`,Q=`data-field-name`;let $=class extends ee{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 C,this.visibleElements=new D,this.groupDisplay=`all`,this._associationsList=null,this._associationsWidgetsMap=new o,this._attemptFocusOnNextRender=!1,this._dateComponentMap=new Map,this._dynamicChoiceItemSelections=new WeakSet,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=()=>{let 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=()=>{let e=this.selectedAttachmentDetails;if(!e?.attachment)return;let t=e.input.getAttachmentEditState(e.attachment).initialName;if(t==null)return;let n=e.input.template.elementId,r=v(e.attachment);this.viewModel.stageRenameAttachment(n,r,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._afterDateComponentCreateOrUpdate=this._afterDateComponentCreateOrUpdate.bind(this),this._afterRadioGroupCreateOrUpdate=this._afterRadioGroupCreateOrUpdate.bind(this),e?.suppressDeprecationWarning||(this.announceDeprecation=()=>{n(r.getLogger(this),`Editor`,`arcgis-editor`,{version:`5.0`})})}normalizeCtorArgs(e={}){let{suppressDeprecationWarning:t,...n}=e;return n}initialize(){this.addHandles([s(()=>this.features.toArray(),()=>{this._dateComponentMap.clear(),I(this.viewModel,{includeDraftValues:!0})}),s(()=>this.viewModel.activeForm,()=>{this._batchSwitchInputInitialValues.clear(),this._resetTransientFormState(),I(this.viewModel),this._setFocusableInput()}),s(()=>this.viewModel.selectedAttachmentAddElementId,()=>{this.hideAttachmentDialog()}),c(()=>!this.selectedAttachmentDetails,()=>this.hideAttachmentDialog()),s(()=>this.viewModel.selectedAttachmentListElementId,()=>{this._attachmentListFilterText=``}),s(()=>[this.viewModel.activeRelationshipInput,this._listObserverNode],()=>this._onObserverChange()),l(()=>this.viewModel,`submit`,()=>{this.valid||this.goToFirstError()}),s(()=>[this._associationsEnabled,this.viewModel.activeForm.allUtilityNetworkAssociationsElementInputs],()=>this._setUpAssociationsWidgets(),u),s(()=>this.viewModel.activeAssociationsInput,e=>this._onActiveAssociationsInputChange(e)),s(()=>this.groupDisplay,()=>this._syncGroupInputStates())])}loadDependencies(){return Promise.all([U({action:()=>import(`@esri/calcite-components/dist/components/calcite-action`),autocomplete:()=>import(`@esri/calcite-components/dist/components/calcite-autocomplete`),"autocomplete-item":()=>import(`@esri/calcite-components/dist/components/calcite-autocomplete-item`),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`)}),z()])}destroy(){this._destroyAssociationsWidgets(),this._associationsList=a(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(){let{features:e,messages:t,page:n}=this;return t?n===`replacing-attachment`?t.titles.replaceAttachment:n===`viewing-attachment-details`?t.titles.editAttachment:n===`adding-attachments`?t.titles.addAttachments:n===`viewing-attachments`?t.titles.attachments:e.length===1||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[];let{messages:e,messagesCommon:t,page:n}=this,r=this.effectiveDisabled;if(n===`adding-attachments`||n===`replacing-attachment`)return[];if(n===`viewing-attachment-details`){let t=this.selectedAttachmentDetails,n=t?.input?.getAttachmentEditState(t.attachment);return!t?.input||!n?[]:n.isRenamed||n.isReplaced?ae({doneOnclick:()=>this._setSelectedAttachment(null),messages:e.footerButtons,resetOnclick:()=>this._resetSelectedAttachmentChanges(),resetDisabled:this._disableAttachmentModification(t.input)}):oe({deleteDisabled:this._disableAttachmentModification(t.input),deleteOnclick:()=>this._deleteSelectedAttachment(),doneOnclick:()=>this._setSelectedAttachment(null),messages:e.footerButtons})}return n===`viewing-associated-features`?T({messages:t,purpose:`cancel-viewing-associated-features`,onclick:()=>this.goBack()}):n===`viewing-associated-layers`?T({messages:t,purpose:`cancel-viewing-associated-layers`,onclick:()=>this.goBack()}):n===`viewing-attachments`||n===`viewing-related-records`?[]:E({disabled:r||!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 this.viewModel.mode===`batch`||!this.viewModel.activeFeature?!1:!!(this.viewModel.formDescription||this.viewModel.formTitle)}get _associationsEnabled(){let{callbacks:e}=this;return!!(e?.addAssociation||e?.editAssociatedFeature)}get _formId(){return`${this.id}-form`}get _relatedRecordsEnabled(){let{callbacks:e}=this;return!!(e&&(e.addRelatedRecord||e.editRelatedRecord))}async goBack(){return this.viewModel.goBack()}async goHome(){return this.viewModel.goHome()}goToFirstError(){let e=this.viewModel.getFirstVisibleInvalidFieldInput();if(!e)return;let{groupInput:t}=e;t&&(t.open||=!0),this._setFocusableInput(e.input),this.scheduleRender()}render(){return Y(`div`,{class:this.classes(w.base,q.widget,q.panel),ondragover:this._handleDragAndDrop,ondrop:this._handleDragAndDrop},this._renderContent(),this._renderAttachmentDialog(),this._prompt?Y(V,{...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){let{datePart:t,elementId:n}=e.dataset,r=i(this._dateComponentMap,`${n}`,()=>({}));switch(t){case`date`:r.date=e;break;case`time`:r.time=e;break;case`timeZone`:r.timeZone=e}}_renderContent(){let{messages:e,viewModel:n}=this,{status:r}=n;if(r===`failed`)return n.hasTooManyComplexFeatures?this._renderErrorNotice(t(e.formFailedToLoadTooManyComplexFeatures,{num:n.maximumFeatureCountWithComplexForms})):n.hasTooManyFeatures?this._renderErrorNotice(t(e.formFailedToLoadTooManyFeatures,{num:n.maximumFeatureCount})):e.formFailedToLoad;if(n.hasLayersWithContingentValues&&this.viewModel.features.length>1)return this._renderErrorNotice(e.unsupportedContingentValues);if(r===`loading`&&this.visibleElements.loadingIndicator)return Y(`calcite-loader`,{key:`loader`,label:this.messagesCommon?.loading});if(this.features.length!==0)return this._renderForm()}_renderErrorNotice(e,t=`warning`){return Y(`calcite-notice`,{class:w.noticeError,icon:!0,kind:t,open:!0},Y(`div`,{slot:`message`},e))}_renderForm(){return Y(`form`,{class:w.form,id:this._formId,inert:!!this._prompt,onsubmit:this._onFormSubmit},this.viewModel.expressionEvaluationFailed&&this.visibleElements.expressionsErrorNotice&&this._renderErrorNotice(this.messages.expressionEvaluationFailed),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(){let{viewModel:e}=this,{hasNonActiveInvalidFeatures:t,activeForm:n}=e,r;if(!e.submitHasBeenAttempted)return null;if(n.invalidHiddenInputs.length>0){if(r=ne(n,e.mode,this.messages),this.viewModel.mode===`batch`){let e=n.invalidHiddenInputs.filter(e=>e.effectiveVisibilityCode===`hidden:group-visibility-expression:all-features`||e.visibilityCode===`hidden:visibility-expression:all-features`);e.length>0?r+=` (${e.map(e=>e.label).join(`, `)})`:r=null}else r=null}else if(t)return null;return r?this._renderErrorNotice(r,`danger`):null}_renderDefaultPage(){return[this._renderReadOnlyNotice(),this._renderFormHeader(),this._renderFormContent()]}_renderReadOnlyNotice(){if((this.disabled||this.readOnly)&&this.visibleElements.readOnlyNotice)return Y(`calcite-notice`,{class:w.disabledNotice,"data-testid":`read-only-notice`,icon:`read-only-non-editable`,kind:`brand`,open:!0,scale:`s`,width:`full`},Y(`div`,{slot:`message`},this.featureFormMessages.disabledForm))}_renderFormHeader(){let{formTitle:e,formDescription:t}=this.viewModel;if(!this._formHeaderVisible)return;let n=e?Y(me,{key:`title`,level:this.headingLevel},e):void 0,r=t?Y(`p`,{class:w.description,key:`description`},t):void 0;return Y(`div`,{class:w.formHeader},n,r)}_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){if(A(e))return this._renderGroupInput(e);if(j(e))return this._renderLabeledField(e);if(se(e))return this._renderTextComponent(e);if(ce(e))return this._renderRelationshipElementInput(e);if(le(e))return this._renderAttachmentElementInput(e);if(M(e))return this._renderUtilityNetworkAssociationsElementInput(e)}_renderGroupInput(e){let{inputs:t,template:n,open:r}=e,i=t.filter(e=>e.visible),a=e.label??``,o=this._focusedFieldInput?.group===e,s=this.groupDisplay===`sequential`;return Y(`calcite-block`,{class:this.classes(w.group,s?w.groupSequential:null,o?w.groupActive:null,this.disabled?w.inputDisabled:null),collapsible:!0,description:e.description??void 0,expanded:r,heading:a,headingLevel:this.headingLevel,key:`{${n.elementId}-key}`,label:a,onCalciteBlockClose:()=>{e.open=!1},onCalciteBlockOpen:()=>{e.open=!0},onCalciteBlockToggle:({currentTarget:t})=>this._onGroupToggle(t,e)},i.map(e=>this._renderInput(e)))}_renderLabeledField(e){let{elementId:n}=e.template,{label:r,required:i,dataType:a}=e,o=i?t(this.messages.requiredFieldLabel,{name:r}):r;return Y(`calcite-label`,{"aria-label":o,class:w.label,key:`field--${n}`},Y(`div`,{class:w.labelTextContent,key:`labelTextContainer`},r,i?Y(`span`,{"aria-hidden":`true`,title:this.messagesCommon.required},`*`):void 0),a===`unsupported`?this._renderReadOnlyComponent(e):this._renderFieldInput(e),this._renderAuxiliaryText(e))}_renderFieldInput(e){let t=this.getCommonInputProps(e),{dataType:n}=e;return O(e.inputController)?this._renderDynamicChoiceComponent({input:e,props:t,controller:e.inputController}):e.domain?.type===`coded-value`?this._renderCodedInputs({input:e,props:t}):k(e.inputController)?this._renderMultipleChoiceComponent({input:e,props:t}):n===`date`?this._renderDateComponents(e,t):(t.disabled=this.disabled,t.readOnly=t.readOnly||this.viewModel.updating,n===`number`?this._renderNumberComponent(e,t):this._renderStringComponent(e,t))}_renderAuxiliaryText(e){let{description:t}=e,n=x(e,e.validationMessage,this.messages);return n?Y(`calcite-input-message`,{icon:!0,status:e.status},n):t?Y(`calcite-input-message`,{class:w.description,icon:!1,status:e.status},t):null}_renderCodedInputs({input:e,props:t}){let n=e.input?.type??null,r=e.codedValueOptions;switch(n){case`switch`:return this._renderSwitchField({input:e,props:t});case`radio-buttons`:return this._renderRadioButtonGroupComponent({input:e,options:r,props:t});default:return this._renderComboBoxComponent({options:r,props:t,input:e})}}_renderDynamicChoiceComponent({input:e,props:t,controller:n}){let r=n.filteredChoices,i=e.showNoValueLabel||this.messages.empty,a=n.evaluated&&!n.evaluating&&!n.choices.length&&Y(`calcite-notice`,{appearance:`transparent`,kind:`neutral`,open:!0,scale:`s`,slot:`content-bottom`,width:`full`},Y(`div`,{slot:`message`},e.showNoValueOptionEnabled?this.messages.noDynamicChoicesWithNoValue:this.messages.noDynamicChoices)),o=t=>{this._saveInput(e,t)},s=(e,t)=>{this._dynamicChoiceItemSelections.delete(n);let r=e.closest(`calcite-autocomplete`);if(r){let e=t==null?``:n.getLabel(t);n.filterValue=``,r.inputValue=e}o(t)},c=({currentTarget:t})=>{let r=t.inputValue??``;n.filterValue=r,!r&&e.value!=null&&o(null)},l=e.showNoValueOptionEnabled?Y(`calcite-autocomplete-item`,{heading:i,key:`dynamic-choice-empty`,selected:e.value==null,value:``,onCalciteAutocompleteItemSelect:({currentTarget:e})=>s(e,null),onpointerdown:()=>{this._dynamicChoiceItemSelections.add(n)}}):null,u=t=>{t.inputValue=e.value===N?this.messages.differentValuesPlaceholder:e.value==null?``:n.inputValue};return Y(`calcite-autocomplete`,{...t,afterCreate:u,disabled:t.readOnly||t.disabled,placeholder:e.value==null?i:t.placeholder,value:String(t.value),onblur:e=>this._onDynamicChoiceBlur(e,n),onCalciteAutocompleteBeforeOpen:()=>n.beginInteraction(),onCalciteAutocompleteTextInput:c},n.evaluating?Y(`calcite-loader`,{key:`dynamic-choice-loader`,label:this.messagesCommon.loading,scale:`s`,slot:`content-top`}):[a,l,...r.map(t=>Y(`calcite-autocomplete-item`,{heading:t.name,key:`dynamic-choice-${t.code}`,selected:t.code===e.value,value:String(t.code),onCalciteAutocompleteItemSelect:({currentTarget:e})=>s(e,t.code),onpointerdown:()=>{this._dynamicChoiceItemSelections.add(n)}}))])}_renderMultipleChoiceComponent({input:e,props:t}){let{messages:n}=this,r=this._getMultipleChoiceController(e);if(!r)return null;let{input:i}=r,a=i.includeSelectAllChoices===!0,{checkboxStatesByValue:o,selectAllState:s}=r.selectionState,c=s.checked?n.deselectAllLabel:n.selectAllLabel,l=r.otherChoiceRenderState;return Y(`div`,{class:w.multipleChoiceInput,key:`${t.key}-multiple-choice-group`},a?this._renderMultipleChoiceSelectAllCheckbox({props:t,selectAllState:s,selectAllLabel:c,handleSelectAllCheckboxChange:t=>{this._saveValueFromMultipleChoiceCheckbox({input:e,checkbox:t,isSelectAllCheckbox:!0})}}):null,this._renderMultipleChoiceChoiceCheckboxes({input:e,props:t,checkboxStatesByValue:o,handleChoiceCheckboxChange:t=>{this._saveValueFromMultipleChoiceCheckbox({input:e,checkbox:t})}}),l.shouldShow?this._renderMultipleChoiceOtherChoice({props:t,includeSelectAllChoices:a,otherChoiceRenderState:l,handleOtherChoiceCheckboxChange:t=>{let{fieldName:n}=l;n&&this._saveOtherChoiceCheckboxValue({input:e,isChecked:t.checked,otherChoiceFieldName:n})},handleOtherChoiceInputChange:t=>{this._saveValueFromMultipleChoiceTextInput({input:e,textInput:t,otherChoiceFieldName:l.fieldName??void 0})},differentValuesPlaceholder:n.differentValuesPlaceholder}):null)}_renderMultipleChoiceSelectAllCheckbox({props:e,selectAllState:t,selectAllLabel:n,handleSelectAllCheckboxChange:r}){return Y(`calcite-checkbox`,{afterCreate:e.afterCreate,afterUpdate:e.afterUpdate,"aria-invalid":e[`aria-invalid`],checked:t.checked,class:w.multipleChoiceSelectAll,"data-element-id":e[Z],disabled:e.readOnly||e.disabled,indeterminate:t.indeterminate,key:`${e.key}-select-all`,label:n,labelText:n,value:`esri_BatchAttributeForm_select_all`,onblur:e.onblur,onCalciteCheckboxChange:({currentTarget:e})=>r(e),onfocus:e.onfocus})}_renderMultipleChoiceChoiceCheckboxes({input:e,props:t,checkboxStatesByValue:n,handleChoiceCheckboxChange:r}){let i=this._getMultipleChoiceController(e);if(!i)return[];let{choices:a}=i;return a.map(e=>{let i=n.get(e.value)??{checked:!1,indeterminate:!1};return Y(`calcite-checkbox`,{afterCreate:t.afterCreate,afterUpdate:t.afterUpdate,"aria-invalid":t[`aria-invalid`],checked:i.checked,class:t.class,"data-element-id":t[Z],disabled:t.readOnly||t.disabled,indeterminate:i.indeterminate,key:`${t.key}-${e.value}`,label:e.label,labelText:e.label,value:e.value,onblur:t.onblur,onCalciteCheckboxChange:({currentTarget:e})=>r(e),onfocus:t.onfocus})})}_renderMultipleChoiceOtherChoice({props:e,includeSelectAllChoices:t,otherChoiceRenderState:n,handleOtherChoiceCheckboxChange:r,handleOtherChoiceInputChange:i,differentValuesPlaceholder:a}){let o=n.label??this.messages.otherOptionLabel;return Y(`div`,{class:this.classes(w.multipleChoiceOtherChoice,t?w.multipleChoiceOtherChoiceWithSelectAll:null),key:`${e.key}-other-choice`},Y(`calcite-checkbox`,{afterCreate:e.afterCreate,afterUpdate:e.afterUpdate,"aria-invalid":e[`aria-invalid`],checked:n.checkboxState.checked,class:e.class,"data-element-id":e[Z],disabled:e.readOnly||e.disabled,indeterminate:n.checkboxState.indeterminate,key:`${e.key}-other-choice-checkbox`,label:o,labelText:o,value:`esri_BatchAttributeForm_other_choice`,onblur:e.onblur,onCalciteCheckboxChange:({currentTarget:e})=>r(e),onfocus:e.onfocus}),n.checkboxState.checked?Y(`calcite-input`,{afterCreate:e.afterCreate,afterUpdate:e.afterUpdate,"aria-invalid":e[`aria-invalid`],"aria-label":o,class:w.textElementInput,"data-element-id":e[Z],disabled:e.readOnly||e.disabled,key:`${e.key}-other-choice-input`,maxLength:n.maxLength,placeholder:n.value===N?a:n.hint,status:n.status,type:`text`,value:n.normalizedValue===N?``:n.normalizedValue?String(n.normalizedValue):``,onblur:e.onblur,onCalciteInputInput:({currentTarget:e})=>i(e),onfocus:e.onfocus}):null)}async _saveValueFromMultipleChoiceCheckbox({input:e,checkbox:t,isSelectAllCheckbox:n=!1}){e.touch();let r=this._getMultipleChoiceController(e);if(!r)return;if(r.input&&!n&&this.viewModel.mode===`batch`){await this._saveMultipleChoiceCheckboxValueByFeature({input:e,checkbox:t});return}let i=e.value,a=this._parseValue(t,e,n);a!==i&&await this.viewModel.setValue(e.template.elementId,a)}async _saveValueFromMultipleChoiceTextInput({input:e,textInput:t,otherChoiceFieldName:n}){if(!n)return;let r=t.value,i=r==null||r===``?null:r,a=this._getMultipleChoiceController(e);if(!a)return;a.initializeExplicitOtherChoiceCheckedState(),a.stashOtherChoiceDraftValueForFeatures(e.features,i);let o=P(e,n);o&&await this.viewModel.setValueForFieldName(o,i,Array.from(e.features,e=>e.source))}async _saveOtherChoiceCheckboxValue({input:e,isChecked:t,otherChoiceFieldName:n}){let r=this._getMultipleChoiceController(e);if(!r)return;r.setExplicitOtherChoiceCheckedState(t),e.touch(),t||r.setOtherChoiceDraftValuesFromFeatures(e.features.toArray());let i=P(e,n);if(!i)return;let a=new Map;for(let i of e.features){let e=i.getAttribute(n);if(t){if(!X(e))continue;let t=r.getOtherChoiceDraftValue(i),n=R(t)?t:L;a.set(i,n);continue}e!=null&&a.set(i,null)}a.size!==0&&await this.viewModel.setValuePerFeatureForFieldName(i,new Map(Array.from(a,([e,t])=>[e.source,t])))}async _saveMultipleChoiceCheckboxValueByFeature({input:e,checkbox:t}){let n=this._getMultipleChoiceController(e);if(!n)return;let r=new Map(e.features.map(r=>[r,n.getUpdatedValueForFeature({choiceValue:t.value,currentValue:r.getAttribute(e.fieldName),isChecked:t.checked})]));r.size!==0&&await this.viewModel.setFieldInputValuePerFeature(e,r)}_renderSwitchField({input:e,props:t}){if((this._batchSwitchInputInitialValues.get(e)===N||e.value===N)&&this.viewModel.mode===`batch`){let n={dropdown:{afterCreate:this._afterComponentCreateOrUpdate,afterUpdate:this._afterComponentCreateOrUpdate,disabled:t.readOnly,open:!1,onblur:t.onblur,onfocus:t.onfocus,[Z]:t[Z]},trigger:{appearance:`transparent`,iconEnd:`chevron-down`,kind:`neutral`,slot:`trigger`,label:t.label},group:{mode:`single`}};return this._renderDropdownComponent({buttonValue:e.value,dropdownProps:n,options:[{name:this.messages.differentValuesPlaceholder,value:N,disabled:!0},...e.codedValueDomainOptions]})}return this._renderSwitchComponent({input:e,props:t})}_renderSwitchComponent({input:e,props:t}){return Y(`calcite-switch`,{...t,checked:S(e.template,`switch`)?e.value===e.template.input.onValue:!1,class:w.inputSwitch,disabled:t.readOnly||t.disabled,onCalciteSwitchChange:({currentTarget:e})=>this._saveInputFromElement(e)})}_renderDropdownComponent({buttonValue:e,options:t,dropdownProps:n}){let{trigger:r,dropdown:i,group:a}=n;return Y(`calcite-dropdown`,{...i,topLayerDisabled:this.topLayerDisabled,onCalciteDropdownSelect:({currentTarget:e})=>this._saveInputFromElement(e)},Y(`calcite-button`,{...r},e===N?this.messages.differentValuesPlaceholder:e),Y(`calcite-dropdown-group`,{selectionMode:a.mode},t.map(t=>Y(`calcite-dropdown-item`,{disabled:t.disabled,label:String(t.name),selected:e===t.value},t.name))))}_renderComboBoxComponent({input:e,options:t,props:n}){let r=this.viewModel.editType===`INSERT`&&e.showNoValueOptionEnabled&&!e.touched?()=>{}:n.onblur,i={...n,onblur:r};return Y(`calcite-combobox`,{...i,clearDisabled:e.isSubtypeField,selectionMode:`single`,topLayerDisabled:this.topLayerDisabled,value:n.placeholder===this.messages.differentValuesPlaceholder?N:String(n.value),onCalciteComboboxChange:({currentTarget:t})=>{t.value!==N&&(e.isSubtypeField&&t.selectedItems.length===0?t.value=`${e.value}`:this._saveInputFromElement(t))}},this.renderComboboxOptionsList({input:e,options:t,props:n}))}renderComboboxOptionsList({input:e,options:t,props:n}){let r=e=>e.map(e=>{let{value:t}=e,r=X(e.value)?this.messages.empty:e.name;return Y(`calcite-combobox-item`,{heading:r,key:`#${t}`,selected:n.value===t,value:`${t}`})}),i=[],{messages:a}=this;t.other.length>0&&i.push(Y(`calcite-combobox-item-group`,{key:`other`,label:a.other},r(t.other))),t.unsupported.length>0&&i.push(Y(`calcite-combobox-item-group`,{key:`unsupported`,label:a.unsupported},r(t.unsupported)));let o=r(t.recommended);i.length>0?i.unshift(Y(`calcite-combobox-item-group`,{key:`recommended`,label:a.recommended},o)):i=o;let s=n.placeholder===this.messages.differentValuesPlaceholder,c=!s&&X(n.value);return e.showNoValueOptionEnabled&&!t.containsEmptyOption&&i.unshift(Y(`calcite-combobox-item`,{heading:e.showNoValueLabel||this.messages.empty,key:`empty-option`,selected:c,value:``})),s&&i.unshift(Y(`calcite-combobox-item`,{heading:this.messages.differentValuesPlaceholder,key:N,selected:!0,value:N})),i}_renderRadioButtonGroupComponent({input:e,options:t,props:n}){let r=[...t.recommended,...t.other,...t.unsupported].map(({name:t,value:r})=>this._renderRadioButtons({label:t,value:r,selected:r===e.value,props:n}));if(e.showNoValueOptionEnabled&&!t.containsEmptyOption){let t=e.showNoValueLabel||this.messages.empty,i=X(e.value);r.unshift(this._renderRadioButtons({label:t,value:``,selected:i,props:n}))}return Y(`calcite-radio-button-group`,{afterCreate:this._afterRadioGroupCreateOrUpdate,afterUpdate:this._afterRadioGroupCreateOrUpdate,class:w.inputRadioGroup,"data-field-name":n[Q],disabled:n.readOnly||n.disabled,key:`${n.key}-radio-group`,layout:`vertical`,name:`${n.name}-${this.id}`,required:n.required},r,n.placeholder===this.messages.differentValuesPlaceholder?Y(`calcite-label`,{class:w.placeholderRadio,key:n.label,layout:`inline`},Y(`calcite-radio-button`,{checked:!0,class:w.inputRadio,disabled:!0,value:n.placeholder}),n.placeholder):null)}_renderRadioButtons({value:e,selected:t,label:n,props:r}){return Y(`calcite-label`,{class:w.inputRadioLabel,key:r.label,layout:`inline`},Y(`calcite-radio-button`,{...r,afterCreate:void 0,afterUpdate:void 0,checked:t,class:w.inputRadio,disabled:r.readOnly||r.disabled,name:void 0,value:e,onCalciteRadioButtonChange:({currentTarget:e})=>{e.checked&&this._saveInputFromElement(e)}}),n)}_renderStringComponent(e,t){let{template:n}=e;return!n.field.editable||this.readOnly?this._renderReadOnlyComponent(e):n.input?.type===`text-area`?Y(`calcite-text-area`,{...t,class:this.classes(w.individualElement),resize:`vertical`,value:t.value?String(t.value):``,onblur:n=>{t.onblur(n),e.userHasChangedValue&&this._saveInputFromElement(n.currentTarget)},onCalciteTextAreaInput:t=>{e.userHasChangedValue=!0,t.currentTarget.value===``&&this._saveInputFromElement(t.currentTarget)}}):Y(`calcite-input`,{...t,class:this.classes(w.individualElement),type:`text`,value:t.value?String(t.value):``,onblur:n=>{t.onblur(n),e.userHasChangedValue&&this._saveInputFromElement(n.currentTarget)},onCalciteInputInput:t=>{e.userHasChangedValue=!0,t.currentTarget.value===``&&this._saveInputFromElement(t.currentTarget)}})}_renderNumberComponent(e,t){let n=h(e.field);return Y(`calcite-input-number`,{...t,integer:n,step:n?1:`any`,type:`number`,value:n&&t.value!==``?Math.round(parseFloat(String(t.value))).toString():String(t.value),onblur:n=>{t.onblur(n),e.userHasChangedValue&&this._saveInputFromElement(n.currentTarget)},onCalciteInputNumberInput:t=>{e.userHasChangedValue=!0,t.currentTarget.value===``&&this._saveInputFromElement(t.currentTarget)}})}_renderReadOnlyComponent(e,t){let n=this.getCommonInputProps(e);return Y(`calcite-input`,{...n,class:this.classes(w.fieldInput,w.inputDisabled,w.individualElement),readOnly:!0,type:`text`,value:String(t??n.value??``)})}_renderDateComponents(e,t){let{field:n}=e,r;switch(n.type){case`date`:r=this._renderDateFieldComponents(e,t);break;case`date-only`:r=this._renderDateOnlyFieldComponent(e,t);break;case`time-only`:r=this._renderTimeOnlyFieldComponent(e,t);break;case`timestamp-offset`:r=this._renderTimestampOffsetFieldComponents(e,t);break;default:r=this._renderReadOnlyComponent(e,ue(n,t.value,{timeZone:e.effectiveTimeZone,...de(e.template.field)}))}return e.value===N?[r,Y(`calcite-input-message`,{icon:`information`,key:`diff-values-message`,status:`idle`},this.messages.differentValues)]:r}_renderDateOnlyFieldComponent(e,t){let{class:n,disabled:r,key:i,readOnly:a}=t,{rawMax:o,rawMin:s}=e.range;return Y(`calcite-input-date-picker`,{afterCreate:this._afterDateComponentCreateOrUpdate,afterUpdate:this._afterDateComponentCreateOrUpdate,class:n,"data-date-part":`date`,"data-element-id":t[Z],"data-field-name":t[Q],disabled:r,key:`${i}-date-input`,max:g(o)?o:void 0,min:g(s)?s:void 0,overlayPositioning:`fixed`,readOnly:a,topLayerDisabled:this.topLayerDisabled,value:e.value===N?``:e.value?String(e.value):``,onblur:t.onblur,onCalciteInputDatePickerChange:t=>this._saveValueFromDateComponent(e,t.currentTarget),onfocus:t.onfocus})}_renderTimeOnlyFieldComponent(e,t){let{class:n,disabled:r,key:i,readOnly:a}=t;return Y(`calcite-input-time-picker`,{afterCreate:this._afterDateComponentCreateOrUpdate,afterUpdate:this._afterDateComponentCreateOrUpdate,class:n,"data-date-part":`time`,"data-element-id":t[Z],"data-field-name":t[Q],disabled:r,key:`${i}-time-input`,overlayPositioning:`fixed`,readOnly:a,step:e.timeStep,value:e.value===N?``:e.value?String(e.value):``,onblur:t.onblur,onCalciteInputTimePickerChange:t=>this._saveValueFromDateComponent(e,t.currentTarget),onfocus:t.onfocus})}_renderTimestampOffsetFieldComponents(e,t){let{class:n,disabled:r,key:i,readOnly:a,onblur:o,onfocus:s}=t,{rawMax:c,rawMin:l}=e.range,u=e.effectiveTimeZone,d=W(c,u),f=W(l,u),p=W(e.value===N?``:e.value,u),m=e.includeTimeOffset,h={afterCreate:this._afterDateComponentCreateOrUpdate,afterUpdate:this._afterDateComponentCreateOrUpdate,disabled:r,[Z]:t[Z],[Q]:t[Q],onblur:o,onfocus:s,overlayPositioning:`fixed`,readOnly:a};return Y(`div`,{class:w.dateInputContainer,key:`${i}-date-time-container`},Y(`calcite-input-date-picker`,{...h,class:n,"data-date-part":`date`,key:`${i}-date-input`,max:d?.date??void 0,min:f?.date??void 0,topLayerDisabled:this.topLayerDisabled,value:p.date??``,onCalciteInputDatePickerChange:t=>this._saveValueFromDateComponent(e,t.target)}),Y(`calcite-input-time-picker`,{...h,class:n,"data-date-part":`time`,key:`${i}-time-input`,step:e.timeStep,value:p.time??``,onCalciteInputTimePickerChange:t=>this._saveValueFromDateComponent(e,t.target)}),m?Y(`calcite-input-time-zone`,{...h,class:n,clearable:e.value===N||e.value==null,"data-date-part":`timeZone`,key:`${i}-timezone-input`,value:p.timeZoneOffset||``,onCalciteInputTimeZoneChange:t=>this._saveValueFromDateComponent(e,t.target)}):null)}_renderDateFieldComponents(e,t){let{class:n,disabled:r,key:i,readOnly:a,min:o,max:s}=t,c=e.effectiveTimeZone,l=G(e.value===N?``:e.value,c),u=G(s,c),d=G(o,c),f=e.includeTime,p={afterCreate:this._afterDateComponentCreateOrUpdate,afterUpdate:this._afterDateComponentCreateOrUpdate,disabled:r,[Z]:t[Z],[Q]:t[Q],onblur:t.onblur,onfocus:t.onfocus,overlayPositioning:`fixed`,readOnly:a};return Y(`div`,{class:w.dateInputContainer,key:`${i}-date-time-container`},Y(`calcite-input-date-picker`,{...p,class:n,"data-date-part":`date`,key:`${i}-date-input`,max:u?.date??void 0,min:d?.date??void 0,topLayerDisabled:this.topLayerDisabled,value:l.date??``,onCalciteInputDatePickerChange:t=>this._saveValueFromDateComponent(e,t.target)}),f?Y(`calcite-input-time-picker`,{...p,"data-date-part":`time`,key:`${i}-time-input`,step:1,value:l.time??``,onCalciteInputTimePickerChange:t=>{this._saveValueFromDateComponent(e,t.target)}}):null)}_renderRelationshipElementInput(e){return this._relatedRecordsEnabled?Y(B,{afterObserverCreated:this._afterListObserverCreated,afterObserverRemoved:this._afterListObserverRemoved,input:e,messages:this.messages,messagesCommon:this.messagesCommon,viewModel:this.viewModel}):null}_renderRelationshipListPage(){let{activeRelationshipInput:e}=this.viewModel;if(e)return this._renderRelationshipElementInput(e)}_renderAttachmentElementInput(e){if(!this.attachmentsEnabled)return;let{allAttachmentsVisibleOnDefaultPage:t,attachments:n,defaultPageAttachments:r,template:{description:i,elementId:a,label:o}}=e,s=t?n:r;return Y(`div`,{class:w.attachmentElementInput,"data-testid":`attachment-element-${a}`,key:`attachment-element-${a}`},o?Y(`div`,{class:w.attachmentElementLabel,key:`attachment-element-label-${a}`},o):null,i?Y(`div`,{class:w.description,key:`attachment-element-description-${a}`},i):null,n.length?this._renderAttachmentList(e,s,{label:o||this.messagesCommon.details,viewAllCount:t?null:n.length}):Y(`div`,{class:w.attachmentElementEmptyState,key:`attachment-element-empty-state-${a}`},this.messages.attachments.noAttachments),this._renderAttachmentAddAction(e))}_renderAttachmentListPage(){let e=this.viewModel.selectedAttachmentListInput;if(e)return Y(`div`,{class:w.attachmentElementAllPanel,key:`attachment-element-all-panel-${e.template.elementId}`},this._renderAttachmentList(e,e.attachments,{filterEnabled:!0,label:this.messages.titles.attachments}))}_renderAttachmentList(e,t,n){let{filterEnabled:r,label:i,viewAllCount:a}=n;return Y(`calcite-list`,{class:w.attachmentElementList,filterEnabled:r,filterPlaceholder:r?this.messages.attachments.searchAttachments:void 0,filterProps:r?he:void 0,filterText:r?this._attachmentListFilterText:void 0,label:i,selectionAppearance:`border`,selectionMode:`none`,onCalciteListFilter:r?e=>{this._attachmentListFilterText=e.currentTarget.filterText??``}:void 0},this._renderAttachmentListItems(e,t),a==null?null:this._renderViewAllAttachmentsItem(e,a))}_renderAttachmentListItems(e,t){let{elementId:n}=e.template;return t.map((t,r)=>{let i=this._formatAttachmentSize(t.size),a=this._getAttachmentLabel(t,r,i,e.displayFilename),o=a===i?void 0:i,s=v(t),c=e.isStagedAttachmentAddition(t),l=e.getAttachmentEditState(t),u=l.isDeleted,d=!u&&(c||l.isRenamed||l.isReplaced);return Y(`calcite-list-item`,{class:w.attachmentElementListItem,description:o,key:`attachment-item-${s}`,label:a,onCalciteListItemSelect:c||u?void 0:()=>this._setSelectedAttachment({attachmentKey:s,elementId:n})},Y(`div`,{class:w.attachmentElementListItemStart,slot:`content-start`},this._renderAttachmentPreviewThumbnail(t,a,e)),d?Y(`span`,{class:w.attachmentElementListItemStagedIndicator,slot:`content-end`}):null,c?[Y(`calcite-action`,{disabled:this._disableAttachmentModification(e),icon:`x`,scale:`s`,slot:`actions-end`,text:this.messagesCommon.delete,title:this.messagesCommon.delete,onclick:()=>this.viewModel.stageDeleteAttachment(n,v(t))})]:u?Y(`calcite-chip`,{label:this.messages.attachments.deleted,scale:`s`,slot:`content-end`},this.messages.attachments.deleted):Y(`calcite-icon`,{flipRtl:!0,icon:`chevron-right`,scale:`s`,slot:`content-end`}))})}_renderViewAllAttachmentsItem(e,n){let{elementId:r}=e.template,{viewAll:i}=this.messages.attachments;return Y(`calcite-list-item`,{class:w.attachmentElementListItem,description:t(this.messages.attachments.count,{count:n}),key:`attachment-item-view-all-${r}`,label:i,onCalciteListItemSelect:()=>this._setAttachmentListElementId(r)},Y(`calcite-icon`,{flipRtl:!0,icon:`chevron-right`,scale:`s`,slot:`content-end`}))}_renderAttachmentAddAction(e){let{elementId:t}=e.template,n=this.effectiveDisabled||e.addDisabled,r=this._renderAttachmentCountLimitsLabel(e),i=this._getAttachmentNoticeMessage(e),a=e.hasMinimumAttachmentCountNotMet||e.hasExceededAttachmentLimit?`danger`:`info`,o=e.canUploadFiles,s=e.isCaptureOnly&&!this.effectiveDisabled&&!i;return Y(`div`,{class:w.attachmentElementAddActions,key:`attachment-element-add-actions-${t}`},o?Y(`calcite-button`,{appearance:`outline`,disabled:n,iconStart:`attachment`,kind:`neutral`,round:!0,scale:`s`,onclick:()=>this._setAttachmentAddElementId(t)},this.messages.attachments.attach):null,this._renderAttachmentCaptureButton(e),s?this._renderAttachmentCaptureDisabledNotice(t):null,r?Y(`div`,{class:w.attachmentElementEmptyActionHint},r):null,!this.effectiveDisabled&&i?Y(`calcite-notice`,{closable:!1,icon:a===`danger`?`exclamation-mark-circle`:`lightbulb`,kind:a,open:!0,scale:`s`,width:`full`},Y(`div`,{slot:`message`},i)):null)}_renderAttachmentCaptureButton(e){if(!e.hasCaptureInputs)return null;let t=e.captureMediaType;return Y(`calcite-button`,{appearance:`outline`,disabled:!0,iconStart:ve(t),kind:`neutral`,round:!0,scale:`s`},this._getCaptureButtonLabel(t))}_getAttachmentNoticeMessage(e){let 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||e.touched}_getCaptureButtonLabel(e){let{capture:t,recordAudio:n,takePhoto:r,takeVideo:i}=this.messages.attachments;switch(e){case`image`:return r||t;case`video`:return i||t;case`audio`:return n||t;default:return t}}_renderAttachmentAddPage(){let e=this.viewModel.selectedAttachmentAddInput;return e?this._renderAttachmentAddPanel(e):null}_renderAttachmentAddPanel(e){let{maxAttachmentCount:t}=e,{elementId:n}=e.template;if(e.isCaptureOnly)return this._renderAttachmentCaptureDisabledNotice(n);let r=t==null||t-e.attachments.length>1,i=this.effectiveDisabled||e.addDisabled,a=this.messages.attachments,o=a.dragAndDropFile,s=e=>{this._attachmentFileInputMap.set(n,e)};return Y(`div`,{class:w.attachmentElementAddPanel,key:`attachment-element-add-panel-${n}`},Y(`input`,{accept:e.accept,afterCreate:s,afterRemoved:()=>{this._attachmentFileInputMap.delete(n)},afterUpdate:s,class:w.attachmentElementFileInput,"data-element-id":n,disabled:i,multiple:r,type:`file`,onchange:e=>{let t=e.currentTarget,r=t.files?Array.from(t.files):[];this._stageAttachmentFiles(n,r),t.value=``}}),Y(`div`,{class:w.attachmentElementAddDropzone,"data-disabled":i?`true`:`false`,ondragover:e=>{e.stopPropagation(),e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=`copy`)},ondrop:e=>{if(e.preventDefault(),e.stopPropagation(),i)return;let t=e.dataTransfer?.files?Array.from(e.dataTransfer.files):[];this._stageAttachmentFiles(n,t)}},Y(`calcite-icon`,{class:w.attachmentElementAddDropzoneIcon,icon:`upload`,scale:`l`}),Y(`div`,{class:w.attachmentElementAddDropzoneHeading},a.addFile),Y(`div`,{class:w.attachmentElementAddDropzoneDetail,title:o},o),Y(`calcite-button`,{appearance:`transparent`,disabled:i,iconStart:`folder-open`,kind:`brand`,scale:`s`,type:`button`,onclick:e=>{e.stopPropagation(),this._openAttachmentFilePicker(n,i)}},a.selectFile)),this._renderAttachmentValidationCriteria(e,{includeCountCriteria:!0}))}_renderAttachmentCaptureDisabledNotice(e){return Y(`calcite-notice`,{class:w.attachmentElementCaptureNotice,icon:!0,key:`attachment-element-capture-disabled-notice-${e}`,kind:`warning`,open:!0,scale:`s`},Y(`div`,{slot:`message`},this.messages.attachments.captureMethodNotSupported))}async _stageAttachmentFiles(e,t){if(t.length===0)return;let n=this.viewModel.selectedAttachmentAddInput,r=!0;try{r=(await this.viewModel.stageAddAttachments(e,t)).length>0&&!n?.hasInvalidValidationCriteria&&!n?.hasUnsupportedFileTypeValidationError}finally{r&&this.viewModel.setSelectedAttachmentAddElementId(null)}}_openAttachmentFilePicker(e,t){t||this._attachmentFileInputMap.get(e)?.click()}_renderAttachmentDetailPage(){let e=this.selectedAttachmentDetails;if(!e)return;if(this.page===`replacing-attachment`)return this._renderAttachmentReplacePanel(e);let{attachment:t,input:n}=e,r=v(t),i=!!n.getAttachmentPreviewUrl(t),a=!this._disableAttachmentModification(n)&&n.canUploadFiles,o=n.getAttachmentEditState(t);return Y(`div`,{class:w.attachmentElementDetail,key:`attachment-detail-panel-${n.template.elementId}-${r}`},Y(`div`,{class:w.attachmentElementDetailPreview},this._renderAttachmentPreviewImageForInput(t,n)),Y(`div`,{class:w.attachmentElementDetailActions},y(t)?Y(`calcite-button`,{appearance:`outline`,disabled:!i,iconStart:`expand`,kind:`neutral`,label:this.messages.attachments.maximize,scale:`m`,title:this.messages.attachments.maximize,onclick:this._maximizeSelectedAttachment}):null,Y(`calcite-button`,{appearance:`outline`,disabled:!i||o.isReplaced,iconStart:`download`,kind:`neutral`,label:this.messages.attachments.download,scale:`m`,title:this.messages.attachments.download,onclick:()=>{this._downloadAttachment(t)}}),Y(`calcite-button`,{appearance:`outline`,disabled:!a,iconStart:`upload-to`,kind:`neutral`,label:this.messages.attachments.replace,scale:`m`,title:this.messages.attachments.replace,onclick:this._enterAttachmentReplaceView})),Y(`div`,{class:w.attachmentElementDetailMetadata},Y(`div`,{class:w.attachmentElementDetailMetadataGroup},Y(`span`,{class:w.attachmentElementDetailMetadataLabel},this.messages.attachments.fileName),this._renderFileNameContent(t,n)),Y(`div`,{class:w.attachmentElementDetailMetadataGroup},Y(`span`,{class:w.attachmentElementDetailMetadataLabel},this.messages.attachments.size),Y(`span`,{class:w.attachmentElementDetailMetadataValue},this._formatAttachmentSize(t.size))),Y(`div`,{class:w.attachmentElementDetailMetadataGroup},Y(`span`,{class:w.attachmentElementDetailMetadataLabel},this.messages.attachments.type),Y(`span`,{class:w.attachmentElementDetailMetadataValue},this._getLabelForAttachmentType(t)))))}_renderFileNameContent(e,t){if(!t.allowUserRename)return Y(`span`,{class:w.attachmentElementDetailMetadataValue},e.name);let n=t.getAttachmentEditState(e),{baseName:r,extension:i}=b(e.name),a=this._disableAttachmentModification(t),o=!a&&e.name.trim().length===0;return[Y(`div`,{class:w.attachmentElementDetailFileNameRow,key:`file-name-row`},Y(`calcite-input`,{class:w.attachmentElementDetailFileNameInput,disabled:a,scale:`m`,status:o?`invalid`:`idle`,suffixText:i,value:r,onCalciteInputInput:({currentTarget:e})=>this._renameSelectedAttachment(e.value)}),Y(`calcite-button`,{appearance:`transparent`,disabled:a||n.initialName==null||!n.isRenamed,iconStart:`reset`,kind:`neutral`,label:this.messages.footerButtons.reset,scale:`m`,title:this.messages.footerButtons.reset,onclick:this._resetSelectedAttachmentName})),o?Y(`calcite-input-message`,{icon:!0,key:`file-name-message`,status:`invalid`},this.messages.validationErrors.cannotBeNull):null]}_renderAttachmentReplacePanel(e){let{attachment:t,input:n}=e,r=this._disableAttachmentModification(n)||!n.canUploadFiles,i=n.template.elementId;return Y(`div`,{class:w.attachmentElementAddPanel,key:`attachment-replace-panel-${i}-${v(t)}`},Y(`input`,{accept:n.accept,afterCreate:this._setSelectedAttachmentReplaceFileInput,afterRemoved:()=>{this._selectedAttachmentReplaceFileInput=null},afterUpdate:this._setSelectedAttachmentReplaceFileInput,class:w.attachmentElementFileInput,disabled:r,type:`file`,onchange:e=>{let t=e.currentTarget,n=t.files?.[0];n&&this._stageSelectedAttachmentReplacement(n),t.value=``}}),Y(`div`,{class:w.attachmentElementAddDropzone,"data-disabled":r?`true`:`false`,ondragover:e=>{e.preventDefault(),e.stopPropagation(),e.dataTransfer&&(e.dataTransfer.dropEffect=`copy`)},ondrop:e=>{if(e.preventDefault(),e.stopPropagation(),r)return;let t=e.dataTransfer?.files?.[0];t&&this._stageSelectedAttachmentReplacement(t)}},Y(`calcite-icon`,{class:w.attachmentElementAddDropzoneIcon,icon:`refresh`,scale:`l`}),Y(`div`,{class:w.attachmentElementAddDropzoneHeading},this.messages.attachments.replace),Y(`div`,{class:w.attachmentElementAddDropzoneDetail,title:this.messages.attachments.dragAndDropFile},this.messages.attachments.dragAndDropFile),Y(`calcite-button`,{appearance:`transparent`,disabled:r,iconStart:`folder-open`,kind:`brand`,scale:`s`,onclick:e=>{e.stopPropagation(),this._openSelectedAttachmentReplaceFilePicker()}},this.messages.attachments.selectFile)),this._renderAttachmentValidationCriteria(n,{includeCountCriteria:!1}),Y(`div`,{class:w.attachmentElementDetailMetadata},Y(`div`,{class:w.attachmentElementDetailMetadataGroup},Y(`span`,{class:w.attachmentElementDetailMetadataLabel},this.messages.attachments.fileToBeReplaced),Y(`span`,{class:w.attachmentElementDetailMetadataValue},t.name))))}_renderAttachmentDialog(){let e=this._attachmentDialogInfo;if(!e)return null;let{attachment:t,input:n}=e;return Y(`calcite-dialog`,{heading:t.name||this.messagesCommon.details,key:`attachment-preview-dialog`,modal:!0,open:!0,placement:`cover`,width:`l`,onCalciteDialogClose:this._closeAttachmentDialog},Y(`div`,{class:w.attachmentElementDialogPreview},this._renderAttachmentPreviewImageForInput(t,n)))}_setSelectedAttachment(e,t){t?.touch(),this.viewModel.setSelectedAttachment(e),e||this.hideAttachmentDialog()}_setAttachmentAddElementId(e){let{viewModel:t}=this;t.setSelectedAttachmentAddElementId(e),t.selectedAttachmentAddInput?.touch(),t.selectedAttachmentAddInput?.clearValidationCriteriaState(),this.hideAttachmentDialog()}_setAttachmentListElementId(e){let{viewModel:t}=this;t.setSelectedAttachmentListElementId(e),t.selectedAttachmentListInput?.touch(),this.hideAttachmentDialog()}_getAttachmentLabel(e,n,r,i){return i!==!1&&g(e.name)&&e.name.length>0?e.name:r===this.messagesCommon.notApplicable?t(this.messages.attachments.attachmentNumberedLabel,{index:n+1}):r}_renderAttachmentCountLimitsLabel(e){let t=this.messages.attachments,n=e.minAttachmentCount!=null&&e.minAttachmentCount>0?this._renderAttachmentCountLimitLabel(t.minAttachmentsShort,e.minAttachmentCount,`min`):null,r=e.maxAttachmentCount==null?null:this._renderAttachmentCountLimitLabel(t.maxAttachmentsShort,e.maxAttachmentCount,`max`);return!n&&!r?null:[n,n&&r?Y(`span`,{key:`attachment-count-limits-separator`},`, `):null,r]}_renderAttachmentCountLimitLabel(e,n,r){let i=`__count__`,[a,o]=t(e,{count:i}).split(i);return Y(`span`,{key:r},a,Y(`span`,{class:w.attachmentElementEmptyActionHintValue},n),o)}_renderAttachmentValidationCriteria(e,{includeCountCriteria:t}){let n=this._getAttachmentValidationCriteria(e,{includeCountCriteria:t}),r=`attachment-validation-criteria-${e.template.elementId}`;return n.length===0?null:Y(`div`,{class:w.attachmentElementValidationCriteria,key:r},n.map(({key:e,message:t,state:n})=>Y(`calcite-notice`,{appearance:n===`danger`?`outline-fill`:`transparent`,closable:!1,icon:!0,key:e,kind:n,open:!0,scale:`s`,width:`full`},Y(`div`,{slot:`message`},t))))}_getAttachmentValidationCriteria(e,{includeCountCriteria:n}){let r=[],i=e.validationCriterionStates,a=this.messages.attachments,o=this._getNestableAttachmentInputs(e.input);e.hasUnsupportedFileTypeValidationError&&r.push({key:`unsupported-file-type`,message:this._getUnsupportedFileTypeMessage(),state:`danger`});for(let e of o)e.type===`document`&&e.maxFileSize!=null&&r.push({key:`maximum-file-size`,message:t(a.maximumFileSize,{maxSize:this._formatAttachmentSizeLimitInMegabytes(e.maxFileSize)}),state:i.get(`maximum-file-size`)??`info`}),e.type===`audio`&&e.maxDuration!=null&&r.push({key:`maximum-audio-length`,message:t(a.maximumAudioLength,{maxDuration:this._formatAttachmentDurationLimit(e.maxDuration)}),state:i.get(`maximum-audio-length`)??`info`}),e.type===`video`&&e.maxDuration!=null&&r.push({key:`maximum-video-length`,message:t(a.maximumVideoLength,{maxDuration:this._formatAttachmentDurationLimit(e.maxDuration)}),state:i.get(`maximum-video-length`)??`info`}),e.type===`image`&&e.maxImageSize!=null&&r.push({key:`maximum-image-size`,message:t(a.attachmentMustBeSmallerThan,{maxSize:`${e.maxImageSize}px`}),state:i.get(`maximum-image-size`)??`info`});return n&&e.minAttachmentCount!=null&&e.minAttachmentCount>0&&r.push({key:`minimum-number-of-files`,message:t(a.minimumNumberOfFiles,{count:e.minAttachmentCount}),state:i.get(`minimum-number-of-files`)??`info`}),n&&e.maxAttachmentCount!=null&&r.push({key:`maximum-number-of-files`,message:t(a.maximumNumberOfFiles,{count:e.maxAttachmentCount}),state:i.get(`maximum-number-of-files`)??`info`}),r}_getNestableAttachmentInputs(e){return e==null?[]:e.type===`attachment`?e.inputTypes?.slice()??[]:[e]}_getUnsupportedFileTypeMessage(){return this.featureTableMessages.errorFileUnsupported}_formatAttachmentSize(e){return e==null||Number.isNaN(e)?this.messagesCommon.notApplicable:d(this.messagesUnits,e)}_formatAttachmentSizeLimitInMegabytes(e){return d(this.messagesUnits,e*1048576)}_formatAttachmentDurationLimit(e){return m(Math.round(e)*1e3,{...e>=3600?{hour:`2-digit`,hourCycle:`h23`}:{},minute:`2-digit`,second:`2-digit`,timeZone:`UTC`})}_getLabelForAttachmentType({contentType:e}){if(!e)return this.messagesCommon.notApplicable;let t=this.messages.attachments.attachmentTypes,n=te(e);return t?.[n]||e}_renderAttachmentPreviewThumbnail(e,t,n){let r=n.getAttachmentPreviewUrl(e,64);return r&&y(e)?Y(`img`,{alt:t,class:w.attachmentElementListItemThumb,src:r}):Y(`calcite-icon`,{class:w.attachmentElementListItemIcon,icon:_(e.contentType),scale:`s`})}_renderAttachmentPreviewImageForInput(e,t){let n=t.getAttachmentPreviewUrl(e),r=e.name||this.messagesCommon.details;return n&&y(e)?Y(`img`,{alt:r,class:w.attachmentElementDetailPreviewImage,src:n,title:r}):[Y(`calcite-icon`,{class:w.attachmentElementDetailPreviewIcon,icon:_(e.contentType),scale:`l`,textLabel:r,title:r}),this.messages.attachments.noPreviewAvailable]}async _downloadAttachment(e){await H(e)}_canReplaceSelectedAttachment(){return!this.effectiveDisabled&&!!this.selectedAttachmentDetails?.input.canUploadFiles}_exitAttachmentReplaceView(){this.viewModel.setShowingSelectedAttachmentReplacePage(!1),this._selectedAttachmentReplaceFileInput=null}async _stageSelectedAttachmentReplacement(e){let t=this.selectedAttachmentDetails;if(!t?.attachment)return;let n=t.input.template.elementId,r=v(t.attachment),i=!1;try{i=await this.viewModel.stageReplaceAttachment(n,r,e)}finally{i&&this._exitAttachmentReplaceView()}}_renameSelectedAttachment(e){let t=this.selectedAttachmentDetails;if(!t?.attachment)return;let n=t.input.template.elementId,r=v(t.attachment);this.viewModel.stageRenameAttachment(n,r,e)}_resetSelectedAttachmentChanges(){let e=this.selectedAttachmentDetails;e?.attachment&&this.viewModel.resetAttachmentChanges(e.input.template.elementId,v(e.attachment))}_deleteSelectedAttachment(){let e=this.selectedAttachmentDetails;if(!e?.attachment||this._disableAttachmentModification(e.input))return;let t=e.input.template.elementId,n=v(e.attachment);this.viewModel.stageDeleteAttachment(t,n),this._setSelectedAttachment(null)}_disableAttachmentModification(e){return this.disabledOrReadOnly||!e.editable}hideAttachmentDialog(){this._attachmentDialogInfo=null}_renderTextComponent(e){let{elementId:t}=e.template;return Y(`div`,{class:w.textElementInput,"data-testid":`text-element-${t}`,innerHTML:e.text,key:`text-element-${t}`})}_renderUtilityNetworkAssociationsElementInput(e){if(!this._associationsEnabled)return;let{elementId:t}=e.template;return Y(`div`,{class:w.utilityNetworkAssociationsElementInput,"data-testid":t,key:t},this._associationsWidgetsMap.get(e)?.render())}getCommonInputProps(e){let{template:t,valid:n,value:r,minLength:i,maxLength:a,required:o,fieldName:s,editable:c,status:l,range:{max:u,min:d}}=e,f=!c||this.readOnly,p=this.disabled||this.viewModel.updating,m=t.hint??void 0,h=!1;return r===N&&(m=this.messages.differentValuesPlaceholder,h=!0),{afterCreate:this._afterComponentCreateOrUpdate,afterUpdate:this._afterComponentCreateOrUpdate,"aria-invalid":n?`false`:`true`,class:this.classes(w.fieldInput,f?w.inputDisabled:null),status:l,maxLength:a&&a>-1?a:void 0,minLength:i&&i>-1?i:void 0,key:t.elementId,label:s,name:s,max:u??void 0,min:d??void 0,disabled:p,readOnly:f,onblur:this._onComponentBlur,required:o,placeholder:m,value:h?``:r??``,[Z]:t.elementId,[Q]:s,onfocus:this._onComponentFocus}}_onObserverChange(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode);let e=this.viewModel.activeRelationshipInput;e&&this._listObserverNode&&e.showAllEnabled&&this._listObserver.observe(this._listObserverNode)}_onFormSubmit(e){e.preventDefault()}_handleDragAndDrop(e){e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=`none`)}_getFieldInputFromHTMLElement(e){return this.viewModel.findFieldInput(e.getAttribute(Z))}_afterRadioGroupCreateOrUpdate(e){let t=e.selectedItem,n=e.querySelector(`calcite-radio-button`),r=t||n;r&&this._afterComponentCreateOrUpdate(r)}_onComponentFocus(e){let t=e.target,n=this._getFieldInputFromHTMLElement(t);this._focusedFieldInput=n}_isMultipleChoiceCheckbox(e,t){let n=this._getMultipleChoiceController(t);return e.tagName===`CALCITE-CHECKBOX`&&n?.input!=null}_afterComponentCreateOrUpdate(e){let t=this._getFieldInputFromHTMLElement(e),n=this._focusedFieldInput;this._attemptFocusOnNextRender&&n===t&&(this._attemptFocusOnNextRender=!1,_e(e))}_onComponentBlur(e){let t=e.target,n=this._getFieldInputFromHTMLElement(t);this._isMultipleChoiceCheckbox(t,n)||n.touch(),this._focusedFieldInput=null}_onDynamicChoiceBlur(e,t){let n=e.currentTarget;if(this._dynamicChoiceItemSelections.delete(t))return;let r=e.relatedTarget;r instanceof Node&&n.contains(r)||(t.endInteraction(),n.inputValue=t.inputValue,this._onComponentBlur(e))}_resetTransientFormState(){this._attemptFocusOnNextRender=!1,this._focusedFieldInput=null,this._attachmentDialogInfo=null,this._selectedAttachmentReplaceFileInput=null,this._attachmentListFilterText=``,this._attachmentFileInputMap.clear()}_parseValue(e,t,n=!1){let r=this._getMultipleChoiceController(t);if(r){let{input:t,values:i}=r;if(t&&i){let t=e;return r.getValueFromCheckboxChange({choiceValue:t.value,isChecked:t.checked,isSelectAllCheckbox:n})}}if(S(t.template,`switch`)){if(e.localName===`calcite-dropdown`&&t.domain){for(let n of t.domain.codedValues)if(n.name===e.selectedItems[0].textContent)return n.code}return e.checked?t.template.input.onValue:t.template.input.offValue}let i=e.value;return i==null||i===``?null:t.dataType===`number`?i===`-0`||i===`-0.`||i===`-0,`?i:parseFloat(i):t.field.type===`date`?parseFloat(i):i}_getMultipleChoiceController(e){return k(e.inputController)?e.inputController:null}_saveInputFromElement(e){let t=this._getFieldInputFromHTMLElement(e);if(!t)return;let n=this._parseValue(e,t);this._saveInput(t,n)}_saveInput(e,t){let{elementId:n}=e.template,r=e?.value,{viewModel:a}=this;if(S(e.template,`switch`)&&a.mode!==`single`){let t=i(this._batchSwitchInputInitialValues,e,()=>e.value);this._batchSwitchInputInitialValues.set(e,t===null?r:t)}t!==r&&(e.touch(),!e.isSubtypeField||a.mode===`batch`||!re(a.activeLayer,r,t)?a.setValue(n,t):this._pendingSubtypeChoice||=this._handleSubtypeChoice(e,t))}async _handleSubtypeChoice(e,n){let{value:r,template:i}=e,{elementId:a}=i,{messages:o,viewModel:s,messagesCommon:c}=this,{subtypes:l,activeFeatureIndex:u}=s;if(await s.setValue(a,n),!l?.length)return;let d=l.find(e=>e.code===n),f=l.find(e=>e.code===r)?.name??`${r}`;if(!d)return;let p=Promise.withResolvers();s.pendingSubtypeChoice=p;let m=`update-fields`,h=[{label:o.subtypes.useDefaultValuesOption,value:`update-fields`},{label:o.subtypes.keepCurrentValuesOption,value:`keep-existing`}],g={context:`info`,title:o.subtypes.changeWarningTitle,message:t(o.subtypes.changeWarning,{originalType:f,newType:d.name}),radios:h,defaultRadioSelection:`update-fields`,onRadioSelection:e=>{m=e},actions:{primary:{label:c.apply,action:()=>p.resolve(m),type:`positive`},secondary:{label:c.cancel,type:`neutral`,action:()=>p.resolve(`undo`)}},cancel:()=>p.reject()};try{switch(this.showPrompt(g),await p.promise){case`update-fields`:await s.applySubtypeDefaults(d),await s.handleSubtypeChanged(u);break;case`keep-existing`:await s.handleSubtypeChanged(u);break;case`undo`:await this.viewModel.setValue(a,r)}}finally{s.pendingSubtypeChoice=null,this.clearPrompt(),this._pendingSubtypeChoice=null}}_afterDateComponentCreateOrUpdate(e){this._setDateTimeTimeZoneMap(e),this._afterComponentCreateOrUpdate(e)}_saveValueFromDateComponent(e,t){let{elementId:n}=e.template,r=e.field.type,i=this._dateComponentMap.get(`${n}`);if(!i)return;let a=e.effectiveTimeZone,o=e.value===N?void 0:e.value,s=null;r===`date-only`?s=Array.isArray(t.value)?t.value[0]:t.value:r===`time-only`?(o=K(o),s=K(t.value)):s=r===`timestamp-offset`?t.value==null?null:fe({dateComponent:i.date,timeComponent:i.time,oldValue:o,timeZoneComponent:i.timeZone,defaultTimeZone:a}):t.value==null?null:pe({oldValue:o,dateComponent:i.date,timeZone:a,timeComponent:i.time?.value===N?void 0:i.time}),o!==s&&(e.touch(),s===null||!t.value?this.viewModel.setValue(n,null):this.viewModel.setValue(n,s))}_renderViewingAssociationsPage(){return this._associationsList?.render()}_onActiveAssociationsInputChange(e){let t=this._associationsList;t&&(e?(t.associationInput=e,t.viewModel=e.viewModel):t.associationInput=null)}async _setUpAssociationsWidgets(){let e=this.viewModel.activeForm.allUtilityNetworkAssociationsElementInputs;if(this._associationsEnabled&&e.length!==0){await this._setUpUtilityNetworkAssociationList();for(let t of e)this._associationsWidgetsMap.set(t,await this._createAssociationsWidget(t))}}async _setUpUtilityNetworkAssociationList(){if(this._associationsList)return;let 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)});let t=this.viewModel.activeAssociationsInput;t&&(this._associationsList.associationInput=t,this._associationsList.viewModel=t.viewModel)}async _createAssociationsWidget(e){let t=(await import(`./Feature/FeatureUtilityNetworkAssociations.js`)).default;return new t({viewModel:e.viewModel,onSelectAssociationType:t=>this._onSelectAssociationType(e,t)})}_destroyAssociationsWidgets(){this._associationsWidgetsMap.forEach(e=>a(e)),this._associationsWidgetsMap.clear()}_onSelectAssociationType(e,{listType:t}){this.setActiveAssociationsInput(e),this.setActiveAssociationType(t)}_onSelectAssociatedLayer({layer:e}){this.setActiveAssociationsLayer(e)}async _onEditAssociatedFeature(e){let t=this.callbacks?.editAssociatedFeature,n=this.viewModel.activeAssociationsInput;if(!t||!n?.feature)return;let{association:r,feature:i}=e;await t({parentFeature:n.feature.plainGraphic,association:r,feature:i})}_onAddAssociation(e){let t=this.callbacks?.addAssociation,n=this.viewModel.activeAssociationsInput;if(!t||!n?.feature)return;let{associationType:r,utilityNetwork:i}=e;t({feature:n.feature.plainGraphic,associationType:r,utilityNetwork:i})}_setFocusableInput(e){let t=e&&j(e)?e:this._findFocusableInput(e);this._syncGroupInputStates(),this._focusedFieldInput=t,this._attemptFocusOnNextRender=!0}_findFocusableInput(e){let t=this.viewModel.activeForm.inputs;if(!t.length)return;let n=ie(t),r;if(!e)r=0;else if(A(e)){let t=e.inputs.find(e=>e.visible);r=t?n.indexOf(t):0}else{let i;i=F(e)&&!e.group.open?e.group.inputs.filter(j)[t.length-1]:e,r=n.indexOf(i)+1}for(let e=r;e<n.length;e++){let t=n[e];if(t.visible&&j(t)){if(this.disabledOrReadOnly&&(t?.inputType===`switch`||t?.inputType===`radio-buttons`))continue;return t}}return null}_onGroupToggle(e,t){e.expanded?(t.open=!0,this._setFocusableInput(t),this.groupDisplay===`sequential`&&this.viewModel.activeForm.allGroupInputs.forEach(e=>{e!==t&&(e.open=!1)})):t.open=!1,this.scheduleRender()}_syncGroupInputStates(){if(this.groupDisplay!==`sequential`)return;let e=this.viewModel.activeForm?.allGroupInputs;if(!e.length)return;let t=e.filter(e=>e.open);t.length===0?e[0].open=!0:t.length>1&&t.slice(1).forEach(e=>e.open=!1)}};e([f()],$.prototype,`activeFeatureIndex`,null),e([f()],$.prototype,`attachmentsEnabled`,null),e([f()],$.prototype,`callbacks`,null),e([f()],$.prototype,`disabled`,null),e([f()],$.prototype,`effectiveTitle`,null),e([f()],$.prototype,`effectiveDisabled`,null),e([f()],$.prototype,`disabledOrReadOnly`,null),e([f()],$.prototype,`features`,null),e([f()],$.prototype,`footerButtonInfos`,null),e([f()],$.prototype,`map`,null),e([f()],$.prototype,`maximumFeatureCount`,null),e([f()],$.prototype,`maximumFeatureCountWithComplexForms`,null),e([f()],$.prototype,`spatialReference`,null),e([f()],$.prototype,`layerInfos`,null),e([f()],$.prototype,`timeZone`,null),e([f()],$.prototype,`headingLevel`,void 0),e([f()],$.prototype,`icon`,null),e([f(),J(`esri/t9n/common`)],$.prototype,`messagesCommon`,void 0),e([f(),J(`esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm`)],$.prototype,`messages`,void 0),e([f(),J(`esri/widgets/FeatureForm/t9n/FeatureForm`)],$.prototype,`featureFormMessages`,void 0),e([f(),J(`esri/widgets/FeatureTable/t9n/FeatureTable`)],$.prototype,`featureTableMessages`,void 0),e([f(),J(`esri/core/t9n/Units`)],$.prototype,`messagesUnits`,void 0),e([f()],$.prototype,`page`,null),e([f()],$.prototype,`readOnly`,null),e([f()],$.prototype,`showPrompt`,null),e([f()],$.prototype,`clearPrompt`,null),e([f()],$.prototype,`selectedAttachment`,null),e([f()],$.prototype,`selectedAttachmentDetails`,null),e([f()],$.prototype,`valid`,null),e([f({type:C}),ge([`attachments-change`,`value-change`,`values-change`,`submit`])],$.prototype,`viewModel`,void 0),e([f({type:D,nonNullable:!0})],$.prototype,`visibleElements`,void 0),e([f()],$.prototype,`groupDisplay`,void 0),e([f()],$.prototype,`_formHeaderVisible`,null),e([f()],$.prototype,`_associationsEnabled`,null),e([f()],$.prototype,`_associationsList`,void 0),e([f()],$.prototype,`_attemptFocusOnNextRender`,void 0),e([f()],$.prototype,`_formId`,null),e([f()],$.prototype,`_focusedFieldInput`,void 0),e([f()],$.prototype,`_pendingSubtypeChoice`,void 0),e([f()],$.prototype,`_relatedRecordsEnabled`,null),e([f()],$.prototype,`_listObserverNode`,void 0),e([f()],$.prototype,`_attachmentDialogInfo`,void 0),e([f()],$.prototype,`_attachmentListFilterText`,void 0),e([f()],$.prototype,`_prompt`,void 0),e([f()],$.prototype,`test`,null),$=e([p(`esri.widgets.BatchAttributeForm`)],$);function ve(e){switch(e){case`audio`:return _(`audio/mpeg`);case`video`:return _(`video/mp4`);case`image`:return _(`image/png`);default:return`camera`}}const ye=$;export{ye 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{isSome as t}from"../core/arrayUtils.js";import n from"../core/Collection.js";import{deprecateWidget as r}from"../core/deprecate.js";import{addEventListener as i}from"../core/events.js";import{makeHandle as a}from"../core/handleUtils.js";import o from"../core/Logger.js";import{destroyMaybe as s}from"../core/maybe.js";import{debounce as c,isAbortError as l}from"../core/promiseUtils.js";import{watch as u,initial as d,on as f}from"../core/reactiveUtils.js";import{escapeRegExpString as p}from"../core/string.js";import{property as m,subclass as h}from"../core/accessorSupport/decorators.js";import{onLocaleChange as g,getLocaleLanguage as _}from"../intl/locale.js";import v from"../portal/Portal.js";import{defaultUnitPropertyMetadata as y}from"../properties/defaultUnit.js";import b from"../rest/support/Stop.js";import x from"../symbols/SimpleMarkerSymbol.js";import S from"./Search.js";import C from"./Widget.js";import{css as w}from"./Directions/css.js";import{DirectionsSearchTool as T}from"./Directions/DirectionsSearchTool.js";import E from"./Directions/DirectionsViewModel.js";import D from"./Directions/DirectionsVisibleElements.js";import{formatDistance as O,formatDuration as k,DepartureTimeOption as A,getIconName as j}from"./Directions/support/directionsUtils.js";import{isArcGISWorldGeocoder as M,meteredArcGISLocatorUrl as N}from"./Search/support/locatorUtils.js";import{loadCalciteComponents as P}from"./support/componentsUtils.js";import{globalCss as F}from"./support/globalCss.js";import{messageBundle as I,tsx as L}from"./support/widget.js";function R(e){let{branchName:n,displayText:r,exitName:i,intersectingName:a,name:o,towardName:s}=e;if(r==null)return null;let c=[n,i,a,o,s].filter(t).sort((e,t)=>t.length-e.length).map(e=>p(e));if(!c.length)return r;let l=new RegExp(c.join(`|`),`g`),u=r.matchAll(l),d=0,f=[];for(let{0:e,index:t}of u)f.push(r.slice(d,t),L(`span`,{class:w.labelEmphasize,key:`maneuver-${t}`},e)),d=t+e.length;return f.push(r.slice(d)),L(`span`,null,f)}const z=`print-preview-closed`;let B=class extends C{constructor(e,t){super(e,t),this._activeManeuver=null,this._placeholderStops=new n([new b,new b]),this._portalFolderCombobox=null,this._portalFolders=null,this._portalItemNameInput=null,this._portalUserName=null,this._printPreviewDialog=null,this._sections=null,this._stopsToSearches=new Map,this._editNoticeClosed=!1,this._printPreviewDialogOpen=!1,this._currentFlowItem=`primary`,this._parentFlowItem=`primary`,this._saveState=`initialized`,this._searchTool=null,this.headingLevel=2,this.messages=null,this.messagesUnits=null,this.searchProperties={popupEnabled:!1,resultGraphicEnabled:!1},this.viewModel=new E,this.visibleElements=new D,this._solveRouteDebounced=c(()=>this._solveRoute()),this.announceDeprecation=()=>{r(o.getLogger(this),`Directions`,`arcgis-directions`,{version:`5.0`})}}initialize(){this.addHandles([u(()=>this.viewModel.layer,()=>{this.viewModel.load().catch(()=>{})},d),u(()=>this.viewModel.layer?.routeInfo,()=>{this._sections=this._getStopSections()},d),u(()=>this.viewModel.layer?.stops.toArray(),e=>{e&&this.view?.activeTool&&this._searchTool&&this.view.activeTool===this._searchTool&&!e.includes(this._searchTool.stop)&&(this.view.tools.remove(this._searchTool),this._searchTool=null)})])}loadDependencies(){return P({accordion:()=>import(`@esri/calcite-components/dist/components/calcite-accordion`),"accordion-item":()=>import(`@esri/calcite-components/dist/components/calcite-accordion-item`),action:()=>import(`@esri/calcite-components/dist/components/calcite-action`),"action-menu":()=>import(`@esri/calcite-components/dist/components/calcite-action-menu`),"block-section":()=>import(`@esri/calcite-components/dist/components/calcite-block-section`),button:()=>import(`@esri/calcite-components/dist/components/calcite-button`),combobox:()=>import(`@esri/calcite-components/dist/components/calcite-combobox`),"combobox-item":()=>import(`@esri/calcite-components/dist/components/calcite-combobox-item`),flow:()=>import(`@esri/calcite-components/dist/components/calcite-flow`),"flow-item":()=>import(`@esri/calcite-components/dist/components/calcite-flow-item`),icon:()=>import(`@esri/calcite-components/dist/components/calcite-icon`),input:()=>import(`@esri/calcite-components/dist/components/calcite-input`),"input-date-picker":()=>import(`@esri/calcite-components/dist/components/calcite-input-date-picker`),"input-time-picker":()=>import(`@esri/calcite-components/dist/components/calcite-input-time-picker`),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`),panel:()=>import(`@esri/calcite-components/dist/components/calcite-panel`),switch:()=>import(`@esri/calcite-components/dist/components/calcite-switch`)})}destroy(){this._stopsToSearches.forEach(s)}get apiKey(){return this.viewModel.apiKey}set apiKey(e){this.viewModel.apiKey=e}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(e){this.viewModel.goToOverride=e}get displayedStops(){return this.effectiveStops.toArray().filter(({locationType:e})=>e!==`waypoint`)}get effectiveStops(){return this.viewModel.layer?.stops??this._placeholderStops}get icon(){return`right`}set icon(e){this._overrideIfSome(`icon`,e)}get label(){return this.messages?.widgetLabel??``}set label(e){this._overrideIfSome(`label`,e)}get lastRoute(){return this.viewModel.lastRoute}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get maxStops(){return this.viewModel.maxStops}set maxStops(e){this.viewModel.maxStops=e}get unit(){return this.defaultUnit}set unit(e){this._overrideIfSome(`unit`,e)}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}acquireSearch(e){let{view:t}=this.viewModel;if(this._stopsToSearches.has(e)){let n=this._stopsToSearches.get(e);return n.view=t,this._overrideDefaultSources(n),n}let n=new S({icon:``,popupEnabled:!1,resultGraphicEnabled:!1,view:t,suppressDeprecationWarning:!0,...this.searchProperties});return this._normalizeSearchSources(n),this.addHandles([f(()=>n.allSources,`change`,()=>this._normalizeSearchSources(n)),n.on(`search-clear`,()=>{e.geometry=null,e.name=null,this.viewModel.layer?.removeResult()}),n.on(`select-result`,()=>{let t=n.selectedResult;e.geometry=t?.feature.geometry,e.name=t?.name,this._solveRouteDebounced()}),u(()=>n.searchTerm,t=>{e.name=t}),g(()=>this._normalizeSearchSources(n))],n),this._stopsToSearches.set(e,n),n}getDirections(){return this.viewModel.getDirections()}render(){return L(`div`,{class:this.classes(w.base,F.widget,F.panel)},L(`calcite-flow`,null,this._renderPrimaryFlowItem(),this._renderDirectionsFlowItem(),this._renderEditFlowItem(),this._renderSaveFlowItem()),this._renderPrintDocument())}save(){return this.viewModel.save()}saveAs(e,t={}){return this.viewModel.saveAs(e,t)}zoomToRoute(){return this.viewModel.zoomToRoute()}_applyLocatorSourceOverrides({allSources:e}){for(let t of e)`url`in t&&t.url&&(t.language=_(),t.locationType??=`street`,M(t.url)&&this.apiKey&&t.apiKey==null&&(t.apiKey=this.apiKey,t.url=N))}_disposeSearch(e){if(!e||!this._stopsToSearches.has(e))return;let t=this._stopsToSearches.get(e);this.removeHandles(t),t.destroy(),this._stopsToSearches.delete(e)}_getErrorDescription(){switch(this.viewModel.lastError?.name){case`directions-view-model:unable-to-route`:return this.messages.errors.unableToRoute;case`directions-view-model:service-metadata-unavailable`:return this.messages.errors.unableToLoadServiceMetadata;default:return this.messages.errors.unknownError}}_getNetworkFeatureName(e){switch(e.type){case`stop`:switch(e.locationType){case`stop`:default:return this.messages.networkFeatures.stops.stop;case`waypoint`:return this.messages.networkFeatures.stops.waypoint;case`break`:return this.messages.networkFeatures.stops.break}case`point-barrier`:return this.messages.networkFeatures.pointBarrier;case`polyline-barrier`:return this.messages.networkFeatures.polylineBarrier;case`polygon-barrier`:return this.messages.networkFeatures.polygonBarrier}}_getRouteCostSummary(){let e=this.viewModel.layer?.routeInfo;if(!e)return null;let t=e.totalDistance??0,n=e.totalDuration??0,{messagesUnits:r,unit:i}=this;return{distance:O(r,t,i),duration:k(n)}}_getStopCostDescription(e){if(!e.directions.length)return;let{totalDistance:t,totalDuration:n}=e.directions.reduce((e,{lines:t})=>{for(let{distance:n,duration:r}of t)e.totalDistance+=n??0,e.totalDuration+=r??0;return e},{totalDistance:0,totalDuration:0}),{messagesUnits:r,unit:i}=this,a=O(r,t,i);return`${k(n)} (${a})`}_getStopSections(){if(!this.viewModel.layer)return null;let{directionPoints:e,directionLines:t,stops:n}=this.viewModel.layer;if(!e||!t)return null;let r=[],i=null;for(let a of e){let{objectId:e,stopId:o}=a;if(o!=null){let e=n.find(({objectId:e})=>e===o);(!i||i.stop!==e)&&(i={stop:e,directions:[]},r.push(i));continue}if(i==null)continue;let s=t.toArray().filter(({directionPointId:t})=>t===e);s.length!==0&&i.directions.push({directionPoint:a,lines:s})}return r}_handleAddStopClick(){let e=new x;this.viewModel.layer?.stops.add(new b({symbol:e}))}_handleAutoSolveChange({target:e}){this.viewModel.autoSolve=e.checked}_handleCreatePolylineBarrierClick(){this.viewModel.create(`polyline-barrier`)}_handleClearRouteClick(){this._currentFlowItem=`primary`,this.viewModel.reset()}_handleCreateStopClick(){this.viewModel.create(`stop`)}_handleDeleteNetworkFeatureClick(e){this.viewModel.remove(e),this.viewModel.autoSolve&&this._solveRouteDebounced()}_handleDeleteStopClick(e){this.effectiveStops.remove(e),this._disposeSearch(e),this._solveRouteDebounced()}_handleDepartureDateChange({currentTarget:{value:e}}){Array.isArray(e)||(this.viewModel.departureIsoDate=e,this._solveRouteDebounced())}_handleDepartureTimeChange({currentTarget:{value:e}}){this.viewModel.departureIsoTime=e,this._solveRouteDebounced()}_handleDepartureTimeOptionChange({currentTarget:e}){let{selectedItems:t}=e;t.length&&(this.viewModel.departureOption=t[0].value,this._solveRouteDebounced())}_handleDirectionsFlowItemBackClick(e){e.stopPropagation(),this._currentFlowItem=`primary`}_handleDirectionTurnItemSelect(e){this._activeManeuver===e?this.zoomToRoute():(this._activeManeuver=e,this.viewModel.centerAt(e.geometry))}_handleDirectionTurnPointerEnter(e){this.viewModel.highlight(e)}_handleDirectionTurnPointerLeave(){this.viewModel.clearHighlights()}_handleEditFlowItemBackClick(e){e.stopPropagation(),this.viewModel.stopEditing(),this._currentFlowItem=`primary`}_handleEditingDoneClick(){this.viewModel.stopEditing(),this._currentFlowItem=`primary`}_handleEditNoticeClose(){this._editNoticeClosed=!0}_handleEditRouteClick(){this._currentFlowItem=`edit`,this.viewModel.startEditing()}_handleItemDetailsClick(){let e=this.viewModel.layer?.portalItem;e&&window.open(`${e.portal.url}/home/item.html?id=${e.id}`,`_blank`)}_handleLocateStopClick(e){let{view:t}=this;if(!t)return;let n=`directions-search-tool`;this.removeHandles(n),this._searchTool=new T({stop:e,view:t}),this.addHandles([this._searchTool.on(`click`,async t=>{if(t.mapPoint&&this._stopsToSearches.has(e)){let n=this._stopsToSearches.get(e),r=(await n.search(t.mapPoint))?.results?.[0].results?.[0];if(r){let{feature:t,name:i}=r;n.searchTerm=i,e.geometry=t.geometry}}this.removeHandles(n)}),a(()=>{this._searchTool&&=(this.view?.tools.remove(this._searchTool),null)})],n),t.addAndActivateTool(this._searchTool)}_handleOptimizeStopOrderToggle({target:{expanded:e}}){this.viewModel.routeParameters.findBestSequence=e,e&&this._removeWaypoints(),this._solveRouteDebounced()}_handlePanToStopClick(e){this.viewModel.centerAt(e)}_handlePreserveFirstStopChange({target:{checked:e}}){this.viewModel.routeParameters.preserveFirstStop=e,this._solveRouteDebounced()}_handlePreserveLastStopChange({target:{checked:e}}){this.viewModel.routeParameters.preserveLastStop=e,this._solveRouteDebounced()}_handlePrintPreviewDialogAfterCreate(e){document.body.appendChild(e),e.showModal(),this._printPreviewDialog=e,this.removeHandles(z),this.addHandles([i(e,`close`,this._handlePrintPreviewDialogClosed.bind(this)),a(()=>{this._printPreviewDialog&&(document.body.removeChild(this._printPreviewDialog),this._printPreviewDialog=null,this._printPreviewDialogOpen=!1)})],z)}_handlePrintPreviewDialogClick(){this._printPreviewDialogOpen=!0}_handlePrintPreviewDialogCloseClick(){this._printPreviewDialog?.close()}_handlePrintPreviewDialogClosed(){this.removeHandles(z)}_handlePrintPreviewDialogPrintClick(){document.body.classList.add(w.printPreviewMedia),window.print(),document.body.classList.remove(w.printPreviewMedia),this._printPreviewDialog?.close()}_handleResolveRouteClick(){this._solveRouteDebounced()}_handleReverseStopOrderClick(){this._removeWaypoints(),this.effectiveStops.reverse(),this._solveRouteDebounced()}_handleSaveErrorCloseClick(){this._currentFlowItem=this._parentFlowItem}_handleSaveFlowItemBackClick(e){e.stopPropagation(),this._currentFlowItem=this._parentFlowItem}async _handleSaveLayerAs(){let e=v.getDefault();try{await e.signIn()}catch(e){if(l(e)||e.name===`identity-manager:user-aborted`)return;this._parentFlowItem=this._currentFlowItem,this._currentFlowItem=`save`,this._saveState=`connect-to-portal-error`;return}this._saveState=`fetch-portal-information`,this._parentFlowItem=this._currentFlowItem,this._currentFlowItem=`save`,this._portalUserName=e.user?.username;try{this._portalFolders=await e.user?.fetchFolders()}catch{this._saveState=`fetch-portal-information-error`;return}this._saveState=`save-layer`}_handleSaveLayerClick(){this.viewModel.layer?.save()}_handleSaveLayerButtonClick(){this._saveState=`saving`;let{layer:e}=this;if(!e||!this._portalFolders)return;let t=this._portalItemNameInput?.value,n=this._portalFolderCombobox?.value,r=this._portalFolders.find(({id:e})=>e===n);e.saveAs({title:t},{folder:r}).then(()=>{e.title=t,this._currentFlowItem=this._parentFlowItem}).catch(()=>{this._saveState=`saving-error`})}_handleSaveLayerCancelClick(){this._currentFlowItem=this._parentFlowItem}_handleSaveLayerFolderCreate(e){this._portalFolderCombobox=e}_handleSaveLayerNameCreate(e){this._portalItemNameInput=e}_handleSignInClick(){this.viewModel.load().catch(()=>{})}_handleStopListReorder({detail:{dragEl:e,newIndex:t}}){this._removeWaypoints(),this.effectiveStops.reorder(e.value,t),this._solveRouteDebounced()}_handleTravelModeChange({currentTarget:{selectedItems:e}}){e.length&&(this.viewModel.selectedTravelMode=e[0].value,this._solveRouteDebounced())}_handleViewDrivingDirectionsClick(){this._currentFlowItem=`directions`}_normalizeSearchSources(e){this._overrideDefaultSources(e),this._applyLocatorSourceOverrides(e)}_overrideDefaultSources(e){for(let t of e.viewModel.defaultSources)t.autoNavigate=!1}_removeWaypoints(){let e=this.viewModel.layer?.stops;if(e){let t=e.filter(({locationType:e})=>e===`waypoint`);e.removeMany(t)}}_renderClearRouteAction(e){return L(`calcite-action`,{bind:this,icon:`trash`,key:`clear-route`,onclick:this._handleClearRouteClick,...e,text:this.messages.common.clear,textEnabled:!0})}_renderDeleteStopAction(e){return L(`calcite-action`,{icon:`trash`,slot:`actions-end`,text:this.messages.deleteStop,title:this.messages.deleteStop,onclick:this._handleDeleteStopClick.bind(this,e)})}_renderDepartureTime(){let{DEPART_AT:e,NOW:t,UNSPECIFIED:n}=A;return L(`calcite-label`,{class:w.departureTime,key:`departure-time`},this.messages.departureTime,L(`calcite-combobox`,{bind:this,label:this.messages.departureTime,overlayPositioning:`fixed`,selectionMode:`single-persist`,topLayerDisabled:this.topLayerDisabled,onCalciteComboboxChange:this._handleDepartureTimeOptionChange},L(`calcite-combobox-item`,{heading:this.messages.leaveNow,key:t,label:this.messages.leaveNow,selected:this.viewModel.departureOption===t,value:t}),L(`calcite-combobox-item`,{heading:this.messages.departAt,key:e,label:this.messages.departAt,selected:this.viewModel.departureOption===e,value:e}),L(`calcite-combobox-item`,{heading:this.messages.timeUnspecified,key:n,label:this.messages.timeUnspecified,selected:this.viewModel.departureOption===n,value:n})))}_renderDepartureTimeOptions(){return this.viewModel.departureOption===A.DEPART_AT?L(`div`,{class:w.departureTimeOptions},L(`calcite-input-date-picker`,{bind:this,scale:`s`,topLayerDisabled:this.topLayerDisabled,value:this.viewModel.departureIsoDate,onCalciteInputDatePickerChange:this._handleDepartureDateChange}),L(`calcite-input-time-picker`,{bind:this,scale:`s`,value:this.viewModel.departureIsoTime,onCalciteInputTimePickerClose:this._handleDepartureTimeChange})):null}_renderDirectionsFlowItem(){if(this._currentFlowItem!==`directions`)return null;let e=this._getRouteCostSummary();if(!this._sections||!e)return null;let{distance:t,duration:n}=e,{formattedEta:r}=this.viewModel,i=this._sections.at(0)?.stop.name??``,a=this._sections.at(-1)?.stop.name??``;return L(`calcite-flow-item`,{bind:this,key:`directions-flow-item`,overlayPositioning:`fixed`,selected:this._currentFlowItem===`directions`,onCalciteFlowItemBack:this._handleDirectionsFlowItemBackClick},L(`div`,{class:w.directionsHeader,slot:`header-content`},L(`div`,{class:w.headerStops},L(`span`,null,this.messages.from),` `,L(`span`,{class:w.directionsHeaderStopName},i),L(`span`,null,this.messages.to),` `,L(`span`,{class:w.directionsHeaderStopName},a)),L(`div`,{class:w.flexColumn},L(`span`,null,`${n} (${t})`),r?L(`span`,null,r):null)),this._renderRouteLayerActions({slot:`header-menu-actions`}),L(`calcite-accordion`,{class:w.accordion,iconPosition:`start`,selectionMode:`single`},this._sections.map((e,t)=>this._renderDirectionSection(e,t))))}_renderDirectionSection(e,t){let{stop:n,directions:r}=e,{name:i}=n,a=t===0,o=this._getStopCostDescription(e);return L(`calcite-accordion-item`,{description:o,expanded:a,heading:i??``,key:`stop-${t}`},L(`calcite-action`,{icon:`zoom-to-object`,slot:`actions-end`,text:this.messages.panToStop,title:this.messages.panToStop,onclick:this._handlePanToStopClick.bind(this,n)}),this._renderDirectionTurns(r))}_renderDirectionTurns(e){return L(`calcite-list`,{label:this.messages.drivingDirections,selectionMode:`none`},e.map((e,t)=>{let{directionPoint:n,lines:r}=e,i=r[0],{distance:a,duration:o}=i,s=O(this.messagesUnits,a??0,this.unit),c=k(o??0),l=s&&c?`${s} | ${c}`:`${s||c}`,u=R(n),d=j(n.directionPointType);return L(`calcite-list-item`,{class:w.labelNoBottomMargin,key:`driving-direction-${t}`,onCalciteListItemSelect:this._handleDirectionTurnItemSelect.bind(this,i),onpointerenter:this._handleDirectionTurnPointerEnter.bind(this,i),onpointerleave:this._handleDirectionTurnPointerLeave.bind(this)},L(`calcite-icon`,{icon:d,slot:`content-start`}),L(`div`,{slot:`content`},L(`calcite-label`,{layout:`inline`,scale:`s`},u),L(`calcite-label`,{layout:`inline`,scale:`s`},l)))}))}_renderEditNotice(){return this._editNoticeClosed?null:L(`div`,{class:w.editInformationContainer,key:w.editInformationContainer},L(`calcite-notice`,{bind:this,closable:!0,kind:`info`,open:!0,onCalciteNoticeClose:this._handleEditNoticeClose},L(`calcite-label`,{scale:`s`,slot:`message`},this.messages.editInstructions)))}_renderEditFlowItem(){return this._currentFlowItem===`edit`?L(`calcite-flow-item`,{bind:this,heading:this.messages.editRoute,headingLevel:this.headingLevel,key:`edit-flow-item`,loading:this.viewModel.state===`routing`,selected:this._currentFlowItem===`edit`,onCalciteFlowItemBack:this._handleEditFlowItemBackClick},L(`div`,{class:w.flexColumn,key:`edit-container`},this._renderEditNotice(),L(`div`,{class:w.editToolbarContainer},L(`calcite-label`,{layout:`inline`,scale:`s`},this.messages.automaticallySolve,L(`calcite-switch`,{bind:this,checked:this.viewModel.autoSolve,scale:`s`,onCalciteSwitchChange:this._handleAutoSolveChange})),L(`div`,{class:w.editToolbar},L(`calcite-action`,{bind:this,disabled:!this.viewModel.layer||this.viewModel.layer.stops.length>=this.maxStops,icon:`flag`,scale:`s`,text:this.messages.networkFeatures.stops.stop,textEnabled:!0,onclick:this._handleCreateStopClick}),L(`calcite-action`,{bind:this,icon:`line`,scale:`s`,text:this.messages.barrier,textEnabled:!0,onclick:this._handleCreatePolylineBarrierClick}),L(`calcite-action`,{bind:this,class:w.solveRoute,disabled:this.viewModel.autoSolve,icon:`refresh`,scale:`s`,text:this.messages.solve,textEnabled:!0,onclick:this._handleResolveRouteClick}))),L(`div`,{class:w.selectedFeatureContainer},L(`calcite-list`,{label:this.messages.selectedNetworkFeatures,scale:`s`,selectionMode:`none`},this.viewModel.selectedNetworkFeatures?.toArray().map((e,t)=>L(`calcite-list-item`,{description:this._getNetworkFeatureName(e),key:`network-feature-${t}`,label:e.name??e.objectId?.toString()??this.messages.unnamed},L(`calcite-action`,{icon:`trash`,slot:`actions-end`,text:this.messages.common.delete,onclick:this._handleDeleteNetworkFeatureClick.bind(this,e)}))))),L(`div`,{class:w.editFooter},this._renderEditFooterContent()))):null}_renderEditFooterContent(){return this.viewModel.lastError?this._renderErrorNotice():L(`calcite-button`,{appearance:`outline-fill`,bind:this,width:`full`,onclick:this._handleEditingDoneClick},this.messages.common.done)}_renderErrorNotice(){return L(`calcite-notice`,{icon:`exclamation-mark-circle`,kind:`danger`,open:!0},L(`calcite-label`,{class:w.labelNoBottomMargin,slot:`message`},this._getErrorDescription()))}_renderFooter(){if(!this.viewModel.layer)return L(`div`,{class:w.primaryFooter,key:`footer-missing-layer`},L(`calcite-notice`,{icon:`information`,open:!0},L(`calcite-label`,{class:w.labelNoBottomMargin,slot:`message`},this.messages.missingLayer)));if(this.viewModel.state===`unauthenticated`)return L(`div`,{class:w.primaryFooterCentered,key:`footer-sign-in`},L(`calcite-label`,null,this.messages.signInRequired),L(`calcite-button`,{bind:this,onclick:this._handleSignInClick},this.messages.common.auth.signIn));if(this.viewModel.state===`routing`)return L(`div`,{class:this.classes(w.primaryFooter,w.primaryFooterLoader),key:`footer-routing`},L(`calcite-loader`,{label:this.messages.solve,scale:`s`}));if(this.viewModel.state===`error`)return L(`div`,{class:w.primaryFooter,key:`footer-service-error`},this._renderErrorNotice());if(!this.viewModel.layer?.routeInfo)return L(`div`,{class:w.primaryFooter,key:`footer-unsolved-route`},L(`calcite-notice`,{icon:`information`,open:!0},L(`calcite-label`,{class:w.labelNoBottomMargin,slot:`message`},this.messages.directionsPlaceholder)));let e=this._getRouteCostSummary();if(!e||!this.viewModel.layer?.directionPoints)return L(`div`,{class:w.primaryFooter,key:`footer-invalid-route`},L(`calcite-notice`,{icon:`exclamation-mark-triangle`,kind:`danger`,open:!0},L(`calcite-label`,{class:w.labelNoBottomMargin,slot:`message`},this.messages.invalidRoute)));let{distance:t,duration:n}=e,{formattedEta:r}=this.viewModel;return L(`div`,{class:w.routeItem,key:`footer-directions-summary`},L(`button`,{"aria-busy":`false`,"aria-label":this.messages.viewDrivingDirections,"aria-live":`polite`,bind:this,class:w.routeItemButton,title:this.messages.viewDrivingDirections,type:`button`,onclick:this._handleViewDrivingDirectionsClick},L(`div`,{class:w.routeItemButtonContent},L(`span`,{class:w.routeItemLabel},`${n} (${t})`),L(`span`,{class:w.routeItemDescription},r)),L(`calcite-icon`,{flipRtl:!0,icon:`chevron-right`,scale:`s`})),L(`calcite-action-menu`,{label:`test`},L(`calcite-action`,{icon:`ellipsis`,key:`route-actions`,slot:`trigger`,text:`Route actions`}),this._renderRouteLayerActions()))}_renderInteractiveRouteActions(){return L(`div`,{class:w.actionContainer,key:w.actionContainer},L(`calcite-button`,{appearance:`outline`,bind:this,class:w.addStopButton,disabled:this.effectiveStops.length>=this.maxStops,iconStart:`plus`,kind:`neutral`,label:this.messages.addStop,title:this.messages.addStop,width:`half`,onclick:this._handleAddStopClick},this.messages.addStop),this.visibleElements.editRouteButton?L(`calcite-button`,{appearance:`outline`,bind:this,class:w.editRouteButton,disabled:this.viewModel.view?.type!==`2d`,iconStart:`pencil`,kind:`neutral`,label:this.messages.editRoute,title:this.messages.editRoute,width:`half`,onclick:this._handleEditRouteClick},this.messages.editRoute):null)}_renderLocateStopAction(e){if(e.name!=null||e.geometry!=null)return null;let t=this.effectiveStops.indexOf(e),n=!!this.view?.activeTool&&this.view.activeTool===this._searchTool&&this._searchTool.stop===e;return L(`calcite-action`,{active:n,icon:`crosshair`,key:`stop-location-action-${t}`,slot:`actions-end`,text:this.messages.pickALocationOnTheMap,title:this.messages.pickALocationOnTheMap,onclick:this._handleLocateStopClick.bind(this,e)})}_renderOptimizeStopOrder(){let{routeParameters:e}=this.viewModel,{findBestSequence:t,preserveFirstStop:n,preserveLastStop:r}=e;return L(`calcite-block-section`,{bind:this,class:w.optimizeSection,text:this.messages.optimizeOrder,toggleDisplay:`switch`,onCalciteBlockSectionToggle:this._handleOptimizeStopOrderToggle},t?[L(`calcite-label`,{class:w.optimizeSwitches,key:`preserve-first-stop`,layout:`inline-space-between`},this.messages.preserveFirstStop,L(`calcite-switch`,{bind:this,checked:n,scale:`s`,onCalciteSwitchChange:this._handlePreserveFirstStopChange})),L(`calcite-label`,{class:w.optimizeSwitches,key:`preserve-last-stop`,layout:`inline-space-between`},this.messages.preserveLastStop,L(`calcite-switch`,{bind:this,checked:r,scale:`s`,onCalciteSwitchChange:this._handlePreserveLastStopChange}))]:null)}_renderPrimaryFlowItem(){return L(`calcite-flow-item`,{key:`primary-flow-item`,loading:this.viewModel.state===`initializing`,selected:this._currentFlowItem===`primary`},L(`calcite-panel`,{class:w.primaryFlowItem,disabled:!this.viewModel.layer||this.viewModel.state===`unauthenticated`||this.viewModel.state===`error`&&!this.viewModel.serviceDescription},this._renderStops(),this._renderInteractiveRouteActions(),this._renderSeparator(),this._renderRouteSolveOptions()),this._renderFooter())}_renderPrintDocument(){if(!this._printPreviewDialogOpen)return null;let e=this._getRouteCostSummary();if(!this._sections||!e)return null;let{distance:t,duration:n}=e,{formattedEta:r}=this.viewModel,i=this._sections.at(0)?.stop.name??``,a=this._sections.at(-1)?.stop.name??``;return L(`dialog`,{afterCreate:this._handlePrintPreviewDialogAfterCreate,bind:this,class:w.printPreviewDialog},L(`div`,{class:w.printPreviewContent},L(`div`,{class:w.printPreviewHeader},L(`div`,{class:w.printPreviewHeaderLabel},L(`div`,{class:w.headerStops},L(`span`,null,this.messages.from),` `,L(`span`,{class:w.directionsHeaderStopName},i),L(`span`,null,this.messages.to),` `,L(`span`,{class:w.directionsHeaderStopName},a))),L(`div`,{class:this.classes(w.printPreviewHeaderButtons,w.printPreviewHideOnPrint)},L(`calcite-button`,{autofocus:!0,bind:this,class:w.printPreviewDialogPrint,iconStart:`print`,onclick:this._handlePrintPreviewDialogPrintClick},this.messages.common.print),L(`calcite-button`,{appearance:`outline`,bind:this,class:w.printPreviewDialogClose,iconStart:`x-circle`,onclick:this._handlePrintPreviewDialogCloseClick},this.messages.common.close))),L(`div`,{class:w.directionsHeader},L(`span`,null,`${n} (${t})`),r?L(`span`,null,r):null),this._sections.map((e,t)=>this._renderPrintSection(e,t))))}_renderPrintManeuver(e,t){let{directionPoint:n,lines:r}=e,{distance:i,duration:a}=r.at(0)??{},o=O(this.messagesUnits,i??0,this.unit),s=k(a??0),c=o&&s?`${o} | ${s}`:`${o||s}`,l=R(n),u=j(n.directionPointType);return L(`div`,{class:this.classes(w.flexRow,w.printPreviewAvoidPageBreak),key:`direction-${t}`},L(`calcite-icon`,{icon:u,preload:!0}),L(`div`,{class:w.flexColumn},L(`span`,null,l),L(`span`,null,c)))}_renderPrintRouteAction(e){if(!this.visibleElements.printButton)return null;let t=!this.viewModel.layer?.routeInfo;return L(`calcite-action`,{bind:this,disabled:t,icon:`print`,key:`print-route`,onclick:this._handlePrintPreviewDialogClick,...e,text:this.messages.common.print,textEnabled:!0})}_renderPrintSection({stop:e,directions:t},n){return L(`div`,{class:w.printPreviewSection,key:`section-${n}`},L(`span`,{class:w.directionsHeaderStopName},e.name??``),t.map((e,t)=>this._renderPrintManeuver(e,t)))}_renderRouteLayerActions(e){return[this._renderClearRouteAction(e),this._renderSaveLayerAction(e),this._renderSaveLayerAsAction(e),this._renderPrintRouteAction(e),this._renderViewItemDetailsAction(e)]}_renderRouteSolveOptions(){return L(`div`,{class:w.marginInlineMedium,key:`route-solve-options`},this._renderTravelModes(),this._renderDepartureTime(),this._renderDepartureTimeOptions(),this._renderOptimizeStopOrder())}_renderSaveContent(){switch(this._saveState){case`initialized`:return this._renderSaveInitialized();case`connect-to-portal`:return this._renderSaveProcessing(this.messages.identity.lblSigning);case`connect-to-portal-error`:return this._renderSaveError(this.messages.errors.authenticating);case`fetch-portal-information`:return this._renderSaveProcessing(this.messages.processing.fetching);case`fetch-portal-information-error`:return this._renderSaveError(this.messages.errors.fetching);case`save-layer`:return this._renderSaveLayerSettings();case`saving`:return this._renderSaveProcessing(this.messages.processing.saving);case`saving-error`:return this._renderSaveError(this.messages.errors.saving)}}_renderSaveError(e){return L(`calcite-panel`,{class:w.paddingMedium,key:`save-layer-error`},L(`div`,{class:w.saveError},L(`calcite-icon`,{class:w.saveErrorIcon,icon:`exclamation-mark-triangle`,scale:`l`,textLabel:this.messages.common.errorMessage}),L(`calcite-label`,{class:w.saveErrorLabel},e)),L(`calcite-button`,{appearance:`outline`,bind:this,slot:`footer-start`,width:`full`,onclick:this._handleSaveErrorCloseClick},this.messages.common.close))}_renderSaveInitialized(){return L(`calcite-panel`,{class:w.paddingMedium,key:`save-layer-initialized`})}_renderSaveFlowItem(){return this._currentFlowItem===`save`?L(`calcite-flow-item`,{bind:this,heading:this.messages.saveLayer,headingLevel:this.headingLevel,key:`save-layer-flow-item`,selected:this._currentFlowItem===`save`,onCalciteFlowItemBack:this._handleSaveFlowItemBackClick},this._renderSaveContent()):null}_renderSaveLayerAction(e){if(!this.visibleElements.saveButton)return null;let t=this.viewModel.layer,n=t?.routeInfo,r=t?.portalItem?.itemControl,i=!!n&&(r===`admin`||r===`update`);return L(`calcite-action`,{bind:this,disabled:!i,icon:`save`,key:`save-route`,onclick:this._handleSaveLayerClick,...e,text:this.messages.common.save,textEnabled:!0})}_renderSaveLayerAsAction(e){if(!this.visibleElements.saveAsButton)return null;let t=!this.viewModel.layer?.routeInfo;return L(`calcite-action`,{disabled:t,icon:`save-as`,key:`save-as-route`,onclick:()=>{this._handleSaveLayerAs()},...e,text:this.messages.common.saveAs,textEnabled:!0})}_renderSaveLayerSettings(){if(this.layer==null||this._portalFolders==null||this._portalUserName==null)return this._renderSaveInitialized();let{stops:e}=this.layer,t=`${e.at(0).name} - ${e.at(-1).name}`,n=[L(`calcite-combobox-item`,{heading:`${this._portalUserName} (${this.messages.common.home})`,key:w.folderHome,selected:!0,value:w.folderHome}),...this._portalFolders.map(e=>L(`calcite-combobox-item`,{heading:e.title??``,key:`${w.folder}-${e.id}`,value:e.id}))];return L(`calcite-panel`,{key:`save-layer-panel`},L(`div`,{class:w.paddingMedium},L(`calcite-label`,null,this.messages.layerName,L(`calcite-input`,{afterCreate:this._handleSaveLayerNameCreate,bind:this,label:this.messages.layerName,value:t})),L(`calcite-label`,null,this.messages.saveInFolder,L(`calcite-combobox`,{afterCreate:this._handleSaveLayerFolderCreate,bind:this,label:this.messages.saveInFolder,overlayPositioning:`fixed`,selectionMode:`single-persist`,topLayerDisabled:this.topLayerDisabled},n))),L(`calcite-button`,{bind:this,slot:`footer-start`,width:`full`,onclick:this._handleSaveLayerButtonClick},this.messages.common.save),L(`calcite-button`,{appearance:`outline`,bind:this,slot:`footer-start`,width:`full`,onclick:this._handleSaveLayerCancelClick},this.messages.common.cancel))}_renderSaveProcessing(e){return L(`calcite-panel`,{class:w.marginInlineMedium,key:`save-layer-processing`},L(`calcite-loader`,{class:w.saveProcessLoader,label:e,text:e}))}_renderSeparator(){return L(`div`,{class:w.separator})}_renderStop(e){let t=this.acquireSearch(e);e.name!=null&&(t.searchTerm=e.name);let n=this._renderLocateStopAction(e),r=this.effectiveStops.length>2&&this._renderDeleteStopAction(e);return L(`calcite-list-item`,{key:e,value:e},n,r,L(`div`,{class:w.stopItem,slot:`content`},t.render()))}_renderStops(){let e=this.displayedStops;for(let t of this._stopsToSearches.keys())e.includes(t)||this._disposeSearch(t);return L(`div`,{class:w.stopContainer,key:w.stopContainer},L(`calcite-list`,{bind:this,class:w.stopList,dragEnabled:!0,label:this.messages.widgetLabel,scale:`s`,onCalciteListOrderChange:this._handleStopListReorder},e.map(e=>this._renderStop(e))),e.length===2&&L(`calcite-action`,{bind:this,icon:`arrow-up-down`,text:this.messages.reverseStops,title:this.messages.reverseStops,onclick:this._handleReverseStopOrderClick}))}_renderTravelMode(e){let{id:t,name:n}=e;return L(`calcite-combobox-item`,{heading:n,key:t,label:n,selected:this.viewModel.selectedTravelMode?.id===t,value:e})}_renderTravelModes(){return this.viewModel.travelModes.length?L(`calcite-label`,{key:`travel-modes`},this.messages.mode,L(`calcite-combobox`,{bind:this,label:this.messages.mode,overlayPositioning:`fixed`,selectionMode:`single-persist`,topLayerDisabled:this.topLayerDisabled,onCalciteComboboxChange:this._handleTravelModeChange},this.viewModel.travelModes.map(e=>this._renderTravelMode(e)))):null}_renderViewItemDetailsAction(e){return this.visibleElements.layerDetails?L(`calcite-action`,{bind:this,disabled:!this.viewModel.layer?.portalItem,icon:`launch`,key:`open-route-details-link`,onclick:this._handleItemDetailsClick,...e,text:this.messages.viewLayerDetails,textEnabled:!0}):null}async _solveRoute(){if(this.viewModel.updateDepartureTime(),(this.viewModel.layer?.stops.filter(({geometry:e})=>!!e).length??0)<2){this.viewModel.clearResults();return}try{await this.viewModel.getDirections()}catch{}}};e([m()],B.prototype,`_editNoticeClosed`,void 0),e([m()],B.prototype,`_printPreviewDialogOpen`,void 0),e([m()],B.prototype,`_currentFlowItem`,void 0),e([m()],B.prototype,`_saveState`,void 0),e([m()],B.prototype,`_searchTool`,void 0),e([m()],B.prototype,`apiKey`,null),e([m(y)],B.prototype,`defaultUnit`,void 0),e([m()],B.prototype,`goToOverride`,null),e([m()],B.prototype,`headingLevel`,void 0),e([m()],B.prototype,`displayedStops`,null),e([m()],B.prototype,`effectiveStops`,null),e([m()],B.prototype,`icon`,null),e([m()],B.prototype,`label`,null),e([m({readOnly:!0})],B.prototype,`lastRoute`,null),e([m()],B.prototype,`layer`,null),e([m()],B.prototype,`maxStops`,null),e([m(),I(`esri/widgets/Directions/t9n/Directions`)],B.prototype,`messages`,void 0),e([m(),I(`esri/core/t9n/Units`)],B.prototype,`messagesUnits`,void 0),e([m()],B.prototype,`searchProperties`,void 0),e([m()],B.prototype,`unit`,null),e([m()],B.prototype,`view`,null),e([m({type:E})],B.prototype,`viewModel`,void 0),e([m({type:D,nonNullable:!0})],B.prototype,`visibleElements`,void 0),B=e([h(`esri.widgets.Directions`)],B);const V=B;export{V as default};
2
+ import{__decorate as e}from"tslib";import{isSome as t}from"../core/arrayUtils.js";import n from"../core/Collection.js";import{deprecateWidget as r}from"../core/deprecate.js";import{addEventListener as i}from"../core/events.js";import{makeHandle as a}from"../core/handleUtils.js";import o from"../core/Logger.js";import{destroyMaybe as s}from"../core/maybe.js";import{debounce as c,isAbortError as l}from"../core/promiseUtils.js";import{watch as u,initial as d,on as f}from"../core/reactiveUtils.js";import{escapeRegExpString as p}from"../core/string.js";import{property as m,subclass as h}from"../core/accessorSupport/decorators.js";import{onLocaleChange as g,getLocaleLanguage as _}from"../intl/locale.js";import v from"../portal/Portal.js";import{defaultUnitPropertyMetadata as y}from"../properties/defaultUnit.js";import b from"../rest/support/Stop.js";import x from"../symbols/SimpleMarkerSymbol.js";import S from"./Search.js";import C from"./Widget.js";import{css as w}from"./Directions/css.js";import{DirectionsSearchTool as T}from"./Directions/DirectionsSearchTool.js";import E from"./Directions/DirectionsViewModel.js";import D from"./Directions/DirectionsVisibleElements.js";import{formatDistance as O,formatDuration as k,DepartureTimeOption as A,getIconName as j}from"./Directions/support/directionsUtils.js";import{isArcGISWorldGeocoder as M,meteredArcGISLocatorUrl as N}from"./Search/support/locatorUtils.js";import{loadCalciteComponents as P}from"./support/componentsUtils.js";import{globalCss as F}from"./support/globalCss.js";import{messageBundle as I,tsx as L}from"./support/widget.js";function R(e){let{branchName:n,displayText:r,exitName:i,intersectingName:a,name:o,towardName:s}=e;if(r==null)return null;let c=[n,i,a,o,s].filter(t).sort((e,t)=>t.length-e.length).map(e=>p(e));if(!c.length)return r;let l=new RegExp(c.join(`|`),`g`),u=r.matchAll(l),d=0,f=[];for(let{0:e,index:t}of u)f.push(r.slice(d,t),L(`span`,{class:w.labelEmphasize,key:`maneuver-${t}`},e)),d=t+e.length;return f.push(r.slice(d)),L(`span`,null,f)}const z=`print-preview-closed`;let B=class extends C{constructor(e,t){super(e,t),this._activeManeuver=null,this._placeholderStops=new n([new b,new b]),this._portalFolderCombobox=null,this._portalFolders=null,this._portalItemNameInput=null,this._portalUserName=null,this._printPreviewDialog=null,this._sections=null,this._stopsToSearches=new Map,this._editNoticeClosed=!1,this._printPreviewDialogOpen=!1,this._currentFlowItem=`primary`,this._parentFlowItem=`primary`,this._saveState=`initialized`,this._searchTool=null,this.headingLevel=2,this.messages=null,this.messagesUnits=null,this.searchProperties={popupEnabled:!1,resultGraphicEnabled:!1},this.viewModel=new E,this.visibleElements=new D,this._solveRouteDebounced=c(()=>this._solveRoute()),this.announceDeprecation=()=>{r(o.getLogger(this),`Directions`,`arcgis-directions`,{version:`5.0`})}}initialize(){this.addHandles([u(()=>this.viewModel.layer,()=>{this.viewModel.load().catch(()=>{})},d),u(()=>this.viewModel.layer?.routeInfo,()=>{this._sections=this._getStopSections()},d),u(()=>this.viewModel.layer?.stops.toArray(),e=>{e&&this.view?.activeTool&&this._searchTool&&this.view.activeTool===this._searchTool&&!e.includes(this._searchTool.stop)&&(this.view.tools.remove(this._searchTool),this._searchTool=null)})])}loadDependencies(){return P({accordion:()=>import(`@esri/calcite-components/dist/components/calcite-accordion`),"accordion-item":()=>import(`@esri/calcite-components/dist/components/calcite-accordion-item`),action:()=>import(`@esri/calcite-components/dist/components/calcite-action`),"action-menu":()=>import(`@esri/calcite-components/dist/components/calcite-action-menu`),"block-section":()=>import(`@esri/calcite-components/dist/components/calcite-block-section`),button:()=>import(`@esri/calcite-components/dist/components/calcite-button`),combobox:()=>import(`@esri/calcite-components/dist/components/calcite-combobox`),"combobox-item":()=>import(`@esri/calcite-components/dist/components/calcite-combobox-item`),flow:()=>import(`@esri/calcite-components/dist/components/calcite-flow`),"flow-item":()=>import(`@esri/calcite-components/dist/components/calcite-flow-item`),icon:()=>import(`@esri/calcite-components/dist/components/calcite-icon`),input:()=>import(`@esri/calcite-components/dist/components/calcite-input`),"input-date-picker":()=>import(`@esri/calcite-components/dist/components/calcite-input-date-picker`),"input-time-picker":()=>import(`@esri/calcite-components/dist/components/calcite-input-time-picker`),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`),panel:()=>import(`@esri/calcite-components/dist/components/calcite-panel`),switch:()=>import(`@esri/calcite-components/dist/components/calcite-switch`)})}destroy(){this._stopsToSearches.forEach(s)}get apiKey(){return this.viewModel.apiKey}set apiKey(e){this.viewModel.apiKey=e}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(e){this.viewModel.goToOverride=e}get displayedStops(){return this.effectiveStops.toArray().filter(({locationType:e})=>e!==`waypoint`)}get effectiveStops(){return this.viewModel.layer?.stops??this._placeholderStops}get icon(){return`right`}set icon(e){this._overrideIfSome(`icon`,e)}get label(){return this.messages?.widgetLabel??``}set label(e){this._overrideIfSome(`label`,e)}get lastRoute(){return this.viewModel.lastRoute}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get maxStops(){return this.viewModel.maxStops}set maxStops(e){this.viewModel.maxStops=e}get unit(){return this.defaultUnit}set unit(e){this._overrideIfSome(`unit`,e)}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}acquireSearch(e){let{view:t}=this.viewModel;if(this._stopsToSearches.has(e)){let n=this._stopsToSearches.get(e);return n.view=t,this._overrideDefaultSources(n),n}let n=new S({icon:``,popupEnabled:!1,resultGraphicEnabled:!1,view:t,suppressDeprecationWarning:!0,...this.searchProperties});return this._normalizeSearchSources(n),this.addHandles([f(()=>n.allSources,`change`,()=>this._normalizeSearchSources(n)),n.on(`search-clear`,()=>{e.geometry=null,e.name=null,this.viewModel.layer?.removeResult()}),n.on(`select-result`,()=>{let t=n.selectedResult;e.geometry=t?.feature.geometry,e.name=t?.name,this._solveRouteDebounced()}),u(()=>n.searchTerm,t=>{e.name=t}),g(()=>this._normalizeSearchSources(n))],n),this._stopsToSearches.set(e,n),n}getDirections(){return this.viewModel.getDirections()}render(){return L(`div`,{class:this.classes(w.base,F.widget,F.panel)},L(`calcite-flow`,null,this._renderPrimaryFlowItem(),this._renderDirectionsFlowItem(),this._renderEditFlowItem(),this._renderSaveFlowItem()),this._renderPrintDocument())}save(){return this.viewModel.save()}saveAs(e,t={}){return this.viewModel.saveAs(e,t)}zoomToRoute(){return this.viewModel.zoomToRoute()}_applyLocatorSourceOverrides({allSources:e}){for(let t of e)`url`in t&&t.url&&(t.language=_(),t.locationType??=`street`,M(t.url)&&this.apiKey&&t.apiKey==null&&(t.apiKey=this.apiKey,t.url=N))}_disposeSearch(e){if(!e||!this._stopsToSearches.has(e))return;let t=this._stopsToSearches.get(e);this.removeHandles(t),t.destroy(),this._stopsToSearches.delete(e)}_getErrorDescription(){switch(this.viewModel.lastError?.name){case`directions-view-model:unable-to-route`:return this.messages.errors.unableToRoute;case`directions-view-model:service-metadata-unavailable`:return this.messages.errors.unableToLoadServiceMetadata;default:return this.messages.errors.unknownError}}_getNetworkFeatureName(e){switch(e.type){case`stop`:switch(e.locationType){case`stop`:default:return this.messages.networkFeatures.stops.stop;case`waypoint`:return this.messages.networkFeatures.stops.waypoint;case`break`:return this.messages.networkFeatures.stops.break}case`point-barrier`:return this.messages.networkFeatures.pointBarrier;case`polyline-barrier`:return this.messages.networkFeatures.polylineBarrier;case`polygon-barrier`:return this.messages.networkFeatures.polygonBarrier}}_getRouteCostSummary(){let e=this.viewModel.layer?.routeInfo;if(!e)return null;let t=e.totalDistance??0,n=e.totalDuration??0,{messagesUnits:r,unit:i}=this;return{distance:O(r,t,i),duration:k(n)}}_getStopCostDescription(e){if(!e.directions.length)return;let{totalDistance:t,totalDuration:n}=e.directions.reduce((e,{lines:t})=>{for(let{distance:n,duration:r}of t)e.totalDistance+=n??0,e.totalDuration+=r??0;return e},{totalDistance:0,totalDuration:0}),{messagesUnits:r,unit:i}=this,a=O(r,t,i);return`${k(n)} (${a})`}_getStopSections(){if(!this.viewModel.layer)return null;let{directionPoints:e,directionLines:t,stops:n}=this.viewModel.layer;if(!e||!t)return null;let r=[],i=null;for(let a of e){let{objectId:e,stopId:o}=a;if(o!=null){let e=n.find(({objectId:e})=>e===o);(!i||i.stop!==e)&&(i={stop:e,directions:[]},r.push(i));continue}if(i==null)continue;let s=t.toArray().filter(({directionPointId:t})=>t===e);s.length!==0&&i.directions.push({directionPoint:a,lines:s})}return r}_handleAddStopClick(){let e=new x;this.viewModel.layer?.stops.add(new b({symbol:e}))}_handleAutoSolveChange({target:e}){this.viewModel.autoSolve=e.checked}_handleCreatePolylineBarrierClick(){this.viewModel.create(`polyline-barrier`)}_handleClearRouteClick(){this._currentFlowItem=`primary`,this.viewModel.reset()}_handleCreateStopClick(){this.viewModel.create(`stop`)}_handleDeleteNetworkFeatureClick(e){this.viewModel.remove(e),this.viewModel.autoSolve&&this._solveRouteDebounced()}_handleDeleteStopClick(e){this.effectiveStops.remove(e),this._disposeSearch(e),this._solveRouteDebounced()}_handleDepartureDateChange({currentTarget:{value:e}}){Array.isArray(e)||(this.viewModel.departureIsoDate=e,this._solveRouteDebounced())}_handleDepartureTimeChange({currentTarget:{value:e}}){this.viewModel.departureIsoTime=e,this._solveRouteDebounced()}_handleDepartureTimeOptionChange({currentTarget:e}){let{selectedItems:t}=e;t.length&&(this.viewModel.departureOption=t[0].value,this._solveRouteDebounced())}_handleDirectionsFlowItemBackClick(e){e.stopPropagation(),this._currentFlowItem=`primary`}_handleDirectionTurnItemSelect(e){this._activeManeuver===e?this.zoomToRoute():(this._activeManeuver=e,this.viewModel.centerAt(e.geometry))}_handleDirectionTurnPointerEnter(e){this.viewModel.highlight(e)}_handleDirectionTurnPointerLeave(){this.viewModel.clearHighlights()}_handleEditFlowItemBackClick(e){e.stopPropagation(),this.viewModel.stopEditing(),this._currentFlowItem=`primary`}_handleEditingDoneClick(){this.viewModel.stopEditing(),this._currentFlowItem=`primary`}_handleEditNoticeClose(){this._editNoticeClosed=!0}_handleEditRouteClick(){this._currentFlowItem=`edit`,this.viewModel.startEditing()}_handleItemDetailsClick(){let e=this.viewModel.layer?.portalItem;e&&window.open(`${e.portal.url}/home/item.html?id=${e.id}`,`_blank`)}_handleLocateStopClick(e){let{view:t}=this;if(!t)return;let n=`directions-search-tool`;this.removeHandles(n),this._searchTool=new T({stop:e,view:t}),this.addHandles([this._searchTool.on(`click`,async t=>{if(t.stopPropagation(),t.mapPoint&&this._stopsToSearches.has(e)){let n=this._stopsToSearches.get(e),r=(await n.search(t.mapPoint))?.results?.[0].results?.[0];if(r){let{feature:t,name:i}=r;n.searchTerm=i,e.geometry=t.geometry}}this.removeHandles(n)}),a(()=>{this._searchTool&&=(this.view?.tools.remove(this._searchTool),null)})],n),t.addAndActivateTool(this._searchTool)}_handleOptimizeStopOrderToggle({target:{expanded:e}}){this.viewModel.routeParameters.findBestSequence=e,e&&this._removeWaypoints(),this._solveRouteDebounced()}_handlePanToStopClick(e){this.viewModel.centerAt(e)}_handlePreserveFirstStopChange({target:{checked:e}}){this.viewModel.routeParameters.preserveFirstStop=e,this._solveRouteDebounced()}_handlePreserveLastStopChange({target:{checked:e}}){this.viewModel.routeParameters.preserveLastStop=e,this._solveRouteDebounced()}_handlePrintPreviewDialogAfterCreate(e){document.body.appendChild(e),e.showModal(),this._printPreviewDialog=e,this.removeHandles(z),this.addHandles([i(e,`close`,this._handlePrintPreviewDialogClosed.bind(this)),a(()=>{this._printPreviewDialog&&(document.body.removeChild(this._printPreviewDialog),this._printPreviewDialog=null,this._printPreviewDialogOpen=!1)})],z)}_handlePrintPreviewDialogClick(){this._printPreviewDialogOpen=!0}_handlePrintPreviewDialogCloseClick(){this._printPreviewDialog?.close()}_handlePrintPreviewDialogClosed(){this.removeHandles(z)}_handlePrintPreviewDialogPrintClick(){document.body.classList.add(w.printPreviewMedia),window.print(),document.body.classList.remove(w.printPreviewMedia),this._printPreviewDialog?.close()}_handleResolveRouteClick(){this._solveRouteDebounced()}_handleReverseStopOrderClick(){this._removeWaypoints(),this.effectiveStops.reverse(),this._solveRouteDebounced()}_handleSaveErrorCloseClick(){this._currentFlowItem=this._parentFlowItem}_handleSaveFlowItemBackClick(e){e.stopPropagation(),this._currentFlowItem=this._parentFlowItem}async _handleSaveLayerAs(){let e=v.getDefault();try{await e.signIn()}catch(e){if(l(e)||e.name===`identity-manager:user-aborted`)return;this._parentFlowItem=this._currentFlowItem,this._currentFlowItem=`save`,this._saveState=`connect-to-portal-error`;return}this._saveState=`fetch-portal-information`,this._parentFlowItem=this._currentFlowItem,this._currentFlowItem=`save`,this._portalUserName=e.user?.username;try{this._portalFolders=await e.user?.fetchFolders()}catch{this._saveState=`fetch-portal-information-error`;return}this._saveState=`save-layer`}_handleSaveLayerClick(){this.viewModel.layer?.save()}_handleSaveLayerButtonClick(){this._saveState=`saving`;let{layer:e}=this;if(!e||!this._portalFolders)return;let t=this._portalItemNameInput?.value,n=this._portalFolderCombobox?.value,r=this._portalFolders.find(({id:e})=>e===n);e.saveAs({title:t},{folder:r}).then(()=>{e.title=t,this._currentFlowItem=this._parentFlowItem}).catch(()=>{this._saveState=`saving-error`})}_handleSaveLayerCancelClick(){this._currentFlowItem=this._parentFlowItem}_handleSaveLayerFolderCreate(e){this._portalFolderCombobox=e}_handleSaveLayerNameCreate(e){this._portalItemNameInput=e}_handleSignInClick(){this.viewModel.load().catch(()=>{})}_handleStopListReorder({detail:{dragEl:e,newIndex:t}}){this._removeWaypoints(),this.effectiveStops.reorder(e.value,t),this._solveRouteDebounced()}_handleTravelModeChange({currentTarget:{selectedItems:e}}){e.length&&(this.viewModel.selectedTravelMode=e[0].value,this._solveRouteDebounced())}_handleViewDrivingDirectionsClick(){this._currentFlowItem=`directions`}_normalizeSearchSources(e){this._overrideDefaultSources(e),this._applyLocatorSourceOverrides(e)}_overrideDefaultSources(e){for(let t of e.viewModel.defaultSources)t.autoNavigate=!1}_removeWaypoints(){let e=this.viewModel.layer?.stops;if(e){let t=e.filter(({locationType:e})=>e===`waypoint`);e.removeMany(t)}}_renderClearRouteAction(e){return L(`calcite-action`,{bind:this,icon:`trash`,key:`clear-route`,onclick:this._handleClearRouteClick,...e,text:this.messages.common.clear,textEnabled:!0})}_renderDeleteStopAction(e){return L(`calcite-action`,{icon:`trash`,slot:`actions-end`,text:this.messages.deleteStop,title:this.messages.deleteStop,onclick:this._handleDeleteStopClick.bind(this,e)})}_renderDepartureTime(){let{DEPART_AT:e,NOW:t,UNSPECIFIED:n}=A;return L(`calcite-label`,{class:w.departureTime,key:`departure-time`},this.messages.departureTime,L(`calcite-combobox`,{bind:this,label:this.messages.departureTime,overlayPositioning:`fixed`,selectionMode:`single-persist`,topLayerDisabled:this.topLayerDisabled,onCalciteComboboxChange:this._handleDepartureTimeOptionChange},L(`calcite-combobox-item`,{heading:this.messages.leaveNow,key:t,label:this.messages.leaveNow,selected:this.viewModel.departureOption===t,value:t}),L(`calcite-combobox-item`,{heading:this.messages.departAt,key:e,label:this.messages.departAt,selected:this.viewModel.departureOption===e,value:e}),L(`calcite-combobox-item`,{heading:this.messages.timeUnspecified,key:n,label:this.messages.timeUnspecified,selected:this.viewModel.departureOption===n,value:n})))}_renderDepartureTimeOptions(){return this.viewModel.departureOption===A.DEPART_AT?L(`div`,{class:w.departureTimeOptions},L(`calcite-input-date-picker`,{bind:this,scale:`s`,topLayerDisabled:this.topLayerDisabled,value:this.viewModel.departureIsoDate,onCalciteInputDatePickerChange:this._handleDepartureDateChange}),L(`calcite-input-time-picker`,{bind:this,scale:`s`,value:this.viewModel.departureIsoTime,onCalciteInputTimePickerClose:this._handleDepartureTimeChange})):null}_renderDirectionsFlowItem(){if(this._currentFlowItem!==`directions`)return null;let e=this._getRouteCostSummary();if(!this._sections||!e)return null;let{distance:t,duration:n}=e,{formattedEta:r}=this.viewModel,i=this._sections.at(0)?.stop.name??``,a=this._sections.at(-1)?.stop.name??``;return L(`calcite-flow-item`,{bind:this,key:`directions-flow-item`,overlayPositioning:`fixed`,selected:this._currentFlowItem===`directions`,onCalciteFlowItemBack:this._handleDirectionsFlowItemBackClick},L(`div`,{class:w.directionsHeader,slot:`header-content`},L(`div`,{class:w.headerStops},L(`span`,null,this.messages.from),` `,L(`span`,{class:w.directionsHeaderStopName},i),L(`span`,null,this.messages.to),` `,L(`span`,{class:w.directionsHeaderStopName},a)),L(`div`,{class:w.flexColumn},L(`span`,null,`${n} (${t})`),r?L(`span`,null,r):null)),this._renderRouteLayerActions({slot:`header-menu-actions`}),L(`calcite-accordion`,{class:w.accordion,iconPosition:`start`,selectionMode:`single`},this._sections.map((e,t)=>this._renderDirectionSection(e,t))))}_renderDirectionSection(e,t){let{stop:n,directions:r}=e,{name:i}=n,a=t===0,o=this._getStopCostDescription(e);return L(`calcite-accordion-item`,{description:o,expanded:a,heading:i??``,key:`stop-${t}`},L(`calcite-action`,{icon:`zoom-to-object`,slot:`actions-end`,text:this.messages.panToStop,title:this.messages.panToStop,onclick:this._handlePanToStopClick.bind(this,n)}),this._renderDirectionTurns(r))}_renderDirectionTurns(e){return L(`calcite-list`,{label:this.messages.drivingDirections,selectionMode:`none`},e.map((e,t)=>{let{directionPoint:n,lines:r}=e,i=r[0],{distance:a,duration:o}=i,s=O(this.messagesUnits,a??0,this.unit),c=k(o??0),l=s&&c?`${s} | ${c}`:`${s||c}`,u=R(n),d=j(n.directionPointType);return L(`calcite-list-item`,{class:w.labelNoBottomMargin,key:`driving-direction-${t}`,onCalciteListItemSelect:this._handleDirectionTurnItemSelect.bind(this,i),onpointerenter:this._handleDirectionTurnPointerEnter.bind(this,i),onpointerleave:this._handleDirectionTurnPointerLeave.bind(this)},L(`calcite-icon`,{icon:d,slot:`content-start`}),L(`div`,{slot:`content`},L(`calcite-label`,{layout:`inline`,scale:`s`},u),L(`calcite-label`,{layout:`inline`,scale:`s`},l)))}))}_renderEditNotice(){return this._editNoticeClosed?null:L(`div`,{class:w.editInformationContainer,key:w.editInformationContainer},L(`calcite-notice`,{bind:this,closable:!0,kind:`info`,open:!0,onCalciteNoticeClose:this._handleEditNoticeClose},L(`calcite-label`,{scale:`s`,slot:`message`},this.messages.editInstructions)))}_renderEditFlowItem(){return this._currentFlowItem===`edit`?L(`calcite-flow-item`,{bind:this,heading:this.messages.editRoute,headingLevel:this.headingLevel,key:`edit-flow-item`,loading:this.viewModel.state===`routing`,selected:this._currentFlowItem===`edit`,onCalciteFlowItemBack:this._handleEditFlowItemBackClick},L(`div`,{class:w.flexColumn,key:`edit-container`},this._renderEditNotice(),L(`div`,{class:w.editToolbarContainer},L(`calcite-label`,{layout:`inline`,scale:`s`},this.messages.automaticallySolve,L(`calcite-switch`,{bind:this,checked:this.viewModel.autoSolve,scale:`s`,onCalciteSwitchChange:this._handleAutoSolveChange})),L(`div`,{class:w.editToolbar},L(`calcite-action`,{bind:this,disabled:!this.viewModel.layer||this.viewModel.layer.stops.length>=this.maxStops,icon:`flag`,scale:`s`,text:this.messages.networkFeatures.stops.stop,textEnabled:!0,onclick:this._handleCreateStopClick}),L(`calcite-action`,{bind:this,icon:`line`,scale:`s`,text:this.messages.barrier,textEnabled:!0,onclick:this._handleCreatePolylineBarrierClick}),L(`calcite-action`,{bind:this,class:w.solveRoute,disabled:this.viewModel.autoSolve,icon:`refresh`,scale:`s`,text:this.messages.solve,textEnabled:!0,onclick:this._handleResolveRouteClick}))),L(`div`,{class:w.selectedFeatureContainer},L(`calcite-list`,{label:this.messages.selectedNetworkFeatures,scale:`s`,selectionMode:`none`},this.viewModel.selectedNetworkFeatures?.toArray().map((e,t)=>L(`calcite-list-item`,{description:this._getNetworkFeatureName(e),key:`network-feature-${t}`,label:e.name??e.objectId?.toString()??this.messages.unnamed},L(`calcite-action`,{icon:`trash`,slot:`actions-end`,text:this.messages.common.delete,onclick:this._handleDeleteNetworkFeatureClick.bind(this,e)}))))),L(`div`,{class:w.editFooter},this._renderEditFooterContent()))):null}_renderEditFooterContent(){return this.viewModel.lastError?this._renderErrorNotice():L(`calcite-button`,{appearance:`outline-fill`,bind:this,width:`full`,onclick:this._handleEditingDoneClick},this.messages.common.done)}_renderErrorNotice(){return L(`calcite-notice`,{icon:`exclamation-mark-circle`,kind:`danger`,open:!0},L(`calcite-label`,{class:w.labelNoBottomMargin,slot:`message`},this._getErrorDescription()))}_renderFooter(){if(!this.viewModel.layer)return L(`div`,{class:w.primaryFooter,key:`footer-missing-layer`},L(`calcite-notice`,{icon:`information`,open:!0},L(`calcite-label`,{class:w.labelNoBottomMargin,slot:`message`},this.messages.missingLayer)));if(this.viewModel.state===`unauthenticated`)return L(`div`,{class:w.primaryFooterCentered,key:`footer-sign-in`},L(`calcite-label`,null,this.messages.signInRequired),L(`calcite-button`,{bind:this,onclick:this._handleSignInClick},this.messages.common.auth.signIn));if(this.viewModel.state===`routing`)return L(`div`,{class:this.classes(w.primaryFooter,w.primaryFooterLoader),key:`footer-routing`},L(`calcite-loader`,{label:this.messages.solve,scale:`s`}));if(this.viewModel.state===`error`)return L(`div`,{class:w.primaryFooter,key:`footer-service-error`},this._renderErrorNotice());if(!this.viewModel.layer?.routeInfo)return L(`div`,{class:w.primaryFooter,key:`footer-unsolved-route`},L(`calcite-notice`,{icon:`information`,open:!0},L(`calcite-label`,{class:w.labelNoBottomMargin,slot:`message`},this.messages.directionsPlaceholder)));let e=this._getRouteCostSummary();if(!e||!this.viewModel.layer?.directionPoints)return L(`div`,{class:w.primaryFooter,key:`footer-invalid-route`},L(`calcite-notice`,{icon:`exclamation-mark-triangle`,kind:`danger`,open:!0},L(`calcite-label`,{class:w.labelNoBottomMargin,slot:`message`},this.messages.invalidRoute)));let{distance:t,duration:n}=e,{formattedEta:r}=this.viewModel;return L(`div`,{class:w.routeItem,key:`footer-directions-summary`},L(`button`,{"aria-busy":`false`,"aria-label":this.messages.viewDrivingDirections,"aria-live":`polite`,bind:this,class:w.routeItemButton,title:this.messages.viewDrivingDirections,type:`button`,onclick:this._handleViewDrivingDirectionsClick},L(`div`,{class:w.routeItemButtonContent},L(`span`,{class:w.routeItemLabel},`${n} (${t})`),L(`span`,{class:w.routeItemDescription},r)),L(`calcite-icon`,{flipRtl:!0,icon:`chevron-right`,scale:`s`})),L(`calcite-action-menu`,{label:`test`},L(`calcite-action`,{icon:`ellipsis`,key:`route-actions`,slot:`trigger`,text:`Route actions`}),this._renderRouteLayerActions()))}_renderInteractiveRouteActions(){return L(`div`,{class:w.actionContainer,key:w.actionContainer},L(`calcite-button`,{appearance:`outline`,bind:this,class:w.addStopButton,disabled:this.effectiveStops.length>=this.maxStops,iconStart:`plus`,kind:`neutral`,label:this.messages.addStop,title:this.messages.addStop,width:`half`,onclick:this._handleAddStopClick},this.messages.addStop),this.visibleElements.editRouteButton?L(`calcite-button`,{appearance:`outline`,bind:this,class:w.editRouteButton,disabled:this.viewModel.view?.type!==`2d`,iconStart:`pencil`,kind:`neutral`,label:this.messages.editRoute,title:this.messages.editRoute,width:`half`,onclick:this._handleEditRouteClick},this.messages.editRoute):null)}_renderLocateStopAction(e){if(e.name!=null||e.geometry!=null)return null;let t=this.effectiveStops.indexOf(e),n=!!this.view?.activeTool&&this.view.activeTool===this._searchTool&&this._searchTool.stop===e;return L(`calcite-action`,{active:n,icon:`crosshair`,key:`stop-location-action-${t}`,slot:`actions-end`,text:this.messages.pickALocationOnTheMap,title:this.messages.pickALocationOnTheMap,onclick:this._handleLocateStopClick.bind(this,e)})}_renderOptimizeStopOrder(){let{routeParameters:e}=this.viewModel,{findBestSequence:t,preserveFirstStop:n,preserveLastStop:r}=e;return L(`calcite-block-section`,{bind:this,class:w.optimizeSection,text:this.messages.optimizeOrder,toggleDisplay:`switch`,onCalciteBlockSectionToggle:this._handleOptimizeStopOrderToggle},t?[L(`calcite-label`,{class:w.optimizeSwitches,key:`preserve-first-stop`,layout:`inline-space-between`},this.messages.preserveFirstStop,L(`calcite-switch`,{bind:this,checked:n,scale:`s`,onCalciteSwitchChange:this._handlePreserveFirstStopChange})),L(`calcite-label`,{class:w.optimizeSwitches,key:`preserve-last-stop`,layout:`inline-space-between`},this.messages.preserveLastStop,L(`calcite-switch`,{bind:this,checked:r,scale:`s`,onCalciteSwitchChange:this._handlePreserveLastStopChange}))]:null)}_renderPrimaryFlowItem(){return L(`calcite-flow-item`,{key:`primary-flow-item`,loading:this.viewModel.state===`initializing`,selected:this._currentFlowItem===`primary`},L(`calcite-panel`,{class:w.primaryFlowItem,disabled:!this.viewModel.layer||this.viewModel.state===`unauthenticated`||this.viewModel.state===`error`&&!this.viewModel.serviceDescription},this._renderStops(),this._renderInteractiveRouteActions(),this._renderSeparator(),this._renderRouteSolveOptions()),this._renderFooter())}_renderPrintDocument(){if(!this._printPreviewDialogOpen)return null;let e=this._getRouteCostSummary();if(!this._sections||!e)return null;let{distance:t,duration:n}=e,{formattedEta:r}=this.viewModel,i=this._sections.at(0)?.stop.name??``,a=this._sections.at(-1)?.stop.name??``;return L(`dialog`,{afterCreate:this._handlePrintPreviewDialogAfterCreate,bind:this,class:w.printPreviewDialog},L(`div`,{class:w.printPreviewContent},L(`div`,{class:w.printPreviewHeader},L(`div`,{class:w.printPreviewHeaderLabel},L(`div`,{class:w.headerStops},L(`span`,null,this.messages.from),` `,L(`span`,{class:w.directionsHeaderStopName},i),L(`span`,null,this.messages.to),` `,L(`span`,{class:w.directionsHeaderStopName},a))),L(`div`,{class:this.classes(w.printPreviewHeaderButtons,w.printPreviewHideOnPrint)},L(`calcite-button`,{autofocus:!0,bind:this,class:w.printPreviewDialogPrint,iconStart:`print`,onclick:this._handlePrintPreviewDialogPrintClick},this.messages.common.print),L(`calcite-button`,{appearance:`outline`,bind:this,class:w.printPreviewDialogClose,iconStart:`x-circle`,onclick:this._handlePrintPreviewDialogCloseClick},this.messages.common.close))),L(`div`,{class:w.directionsHeader},L(`span`,null,`${n} (${t})`),r?L(`span`,null,r):null),this._sections.map((e,t)=>this._renderPrintSection(e,t))))}_renderPrintManeuver(e,t){let{directionPoint:n,lines:r}=e,{distance:i,duration:a}=r.at(0)??{},o=O(this.messagesUnits,i??0,this.unit),s=k(a??0),c=o&&s?`${o} | ${s}`:`${o||s}`,l=R(n),u=j(n.directionPointType);return L(`div`,{class:this.classes(w.flexRow,w.printPreviewAvoidPageBreak),key:`direction-${t}`},L(`calcite-icon`,{icon:u,preload:!0}),L(`div`,{class:w.flexColumn},L(`span`,null,l),L(`span`,null,c)))}_renderPrintRouteAction(e){if(!this.visibleElements.printButton)return null;let t=!this.viewModel.layer?.routeInfo;return L(`calcite-action`,{bind:this,disabled:t,icon:`print`,key:`print-route`,onclick:this._handlePrintPreviewDialogClick,...e,text:this.messages.common.print,textEnabled:!0})}_renderPrintSection({stop:e,directions:t},n){return L(`div`,{class:w.printPreviewSection,key:`section-${n}`},L(`span`,{class:w.directionsHeaderStopName},e.name??``),t.map((e,t)=>this._renderPrintManeuver(e,t)))}_renderRouteLayerActions(e){return[this._renderClearRouteAction(e),this._renderSaveLayerAction(e),this._renderSaveLayerAsAction(e),this._renderPrintRouteAction(e),this._renderViewItemDetailsAction(e)]}_renderRouteSolveOptions(){return L(`div`,{class:w.marginInlineMedium,key:`route-solve-options`},this._renderTravelModes(),this._renderDepartureTime(),this._renderDepartureTimeOptions(),this._renderOptimizeStopOrder())}_renderSaveContent(){switch(this._saveState){case`initialized`:return this._renderSaveInitialized();case`connect-to-portal`:return this._renderSaveProcessing(this.messages.identity.lblSigning);case`connect-to-portal-error`:return this._renderSaveError(this.messages.errors.authenticating);case`fetch-portal-information`:return this._renderSaveProcessing(this.messages.processing.fetching);case`fetch-portal-information-error`:return this._renderSaveError(this.messages.errors.fetching);case`save-layer`:return this._renderSaveLayerSettings();case`saving`:return this._renderSaveProcessing(this.messages.processing.saving);case`saving-error`:return this._renderSaveError(this.messages.errors.saving)}}_renderSaveError(e){return L(`calcite-panel`,{class:w.paddingMedium,key:`save-layer-error`},L(`div`,{class:w.saveError},L(`calcite-icon`,{class:w.saveErrorIcon,icon:`exclamation-mark-triangle`,scale:`l`,textLabel:this.messages.common.errorMessage}),L(`calcite-label`,{class:w.saveErrorLabel},e)),L(`calcite-button`,{appearance:`outline`,bind:this,slot:`footer-start`,width:`full`,onclick:this._handleSaveErrorCloseClick},this.messages.common.close))}_renderSaveInitialized(){return L(`calcite-panel`,{class:w.paddingMedium,key:`save-layer-initialized`})}_renderSaveFlowItem(){return this._currentFlowItem===`save`?L(`calcite-flow-item`,{bind:this,heading:this.messages.saveLayer,headingLevel:this.headingLevel,key:`save-layer-flow-item`,selected:this._currentFlowItem===`save`,onCalciteFlowItemBack:this._handleSaveFlowItemBackClick},this._renderSaveContent()):null}_renderSaveLayerAction(e){if(!this.visibleElements.saveButton)return null;let t=this.viewModel.layer,n=t?.routeInfo,r=t?.portalItem?.itemControl,i=!!n&&(r===`admin`||r===`update`);return L(`calcite-action`,{bind:this,disabled:!i,icon:`save`,key:`save-route`,onclick:this._handleSaveLayerClick,...e,text:this.messages.common.save,textEnabled:!0})}_renderSaveLayerAsAction(e){if(!this.visibleElements.saveAsButton)return null;let t=!this.viewModel.layer?.routeInfo;return L(`calcite-action`,{disabled:t,icon:`save-as`,key:`save-as-route`,onclick:()=>{this._handleSaveLayerAs()},...e,text:this.messages.common.saveAs,textEnabled:!0})}_renderSaveLayerSettings(){if(this.layer==null||this._portalFolders==null||this._portalUserName==null)return this._renderSaveInitialized();let{stops:e}=this.layer,t=`${e.at(0).name} - ${e.at(-1).name}`,n=[L(`calcite-combobox-item`,{heading:`${this._portalUserName} (${this.messages.common.home})`,key:w.folderHome,selected:!0,value:w.folderHome}),...this._portalFolders.map(e=>L(`calcite-combobox-item`,{heading:e.title??``,key:`${w.folder}-${e.id}`,value:e.id}))];return L(`calcite-panel`,{key:`save-layer-panel`},L(`div`,{class:w.paddingMedium},L(`calcite-label`,null,this.messages.layerName,L(`calcite-input`,{afterCreate:this._handleSaveLayerNameCreate,bind:this,label:this.messages.layerName,value:t})),L(`calcite-label`,null,this.messages.saveInFolder,L(`calcite-combobox`,{afterCreate:this._handleSaveLayerFolderCreate,bind:this,label:this.messages.saveInFolder,overlayPositioning:`fixed`,selectionMode:`single-persist`,topLayerDisabled:this.topLayerDisabled},n))),L(`calcite-button`,{bind:this,slot:`footer-start`,width:`full`,onclick:this._handleSaveLayerButtonClick},this.messages.common.save),L(`calcite-button`,{appearance:`outline`,bind:this,slot:`footer-start`,width:`full`,onclick:this._handleSaveLayerCancelClick},this.messages.common.cancel))}_renderSaveProcessing(e){return L(`calcite-panel`,{class:w.marginInlineMedium,key:`save-layer-processing`},L(`calcite-loader`,{class:w.saveProcessLoader,label:e,text:e}))}_renderSeparator(){return L(`div`,{class:w.separator})}_renderStop(e){let t=this.acquireSearch(e);e.name!=null&&(t.searchTerm=e.name);let n=this._renderLocateStopAction(e),r=this.effectiveStops.length>2&&this._renderDeleteStopAction(e);return L(`calcite-list-item`,{key:e,value:e},n,r,L(`div`,{class:w.stopItem,slot:`content`},t.render()))}_renderStops(){let e=this.displayedStops;for(let t of this._stopsToSearches.keys())e.includes(t)||this._disposeSearch(t);return L(`div`,{class:w.stopContainer,key:w.stopContainer},L(`calcite-list`,{bind:this,class:w.stopList,dragEnabled:!0,label:this.messages.widgetLabel,scale:`s`,onCalciteListOrderChange:this._handleStopListReorder},e.map(e=>this._renderStop(e))),e.length===2&&L(`calcite-action`,{bind:this,icon:`arrow-up-down`,text:this.messages.reverseStops,title:this.messages.reverseStops,onclick:this._handleReverseStopOrderClick}))}_renderTravelMode(e){let{id:t,name:n}=e;return L(`calcite-combobox-item`,{heading:n,key:t,label:n,selected:this.viewModel.selectedTravelMode?.id===t,value:e})}_renderTravelModes(){return this.viewModel.travelModes.length?L(`calcite-label`,{key:`travel-modes`},this.messages.mode,L(`calcite-combobox`,{bind:this,label:this.messages.mode,overlayPositioning:`fixed`,selectionMode:`single-persist`,topLayerDisabled:this.topLayerDisabled,onCalciteComboboxChange:this._handleTravelModeChange},this.viewModel.travelModes.map(e=>this._renderTravelMode(e)))):null}_renderViewItemDetailsAction(e){return this.visibleElements.layerDetails?L(`calcite-action`,{bind:this,disabled:!this.viewModel.layer?.portalItem,icon:`launch`,key:`open-route-details-link`,onclick:this._handleItemDetailsClick,...e,text:this.messages.viewLayerDetails,textEnabled:!0}):null}async _solveRoute(){if(this.viewModel.updateDepartureTime(),(this.viewModel.layer?.stops.filter(({geometry:e})=>!!e).length??0)<2){this.viewModel.clearResults();return}try{await this.viewModel.getDirections()}catch{}}};e([m()],B.prototype,`_editNoticeClosed`,void 0),e([m()],B.prototype,`_printPreviewDialogOpen`,void 0),e([m()],B.prototype,`_currentFlowItem`,void 0),e([m()],B.prototype,`_saveState`,void 0),e([m()],B.prototype,`_searchTool`,void 0),e([m()],B.prototype,`apiKey`,null),e([m(y)],B.prototype,`defaultUnit`,void 0),e([m()],B.prototype,`goToOverride`,null),e([m()],B.prototype,`headingLevel`,void 0),e([m()],B.prototype,`displayedStops`,null),e([m()],B.prototype,`effectiveStops`,null),e([m()],B.prototype,`icon`,null),e([m()],B.prototype,`label`,null),e([m({readOnly:!0})],B.prototype,`lastRoute`,null),e([m()],B.prototype,`layer`,null),e([m()],B.prototype,`maxStops`,null),e([m(),I(`esri/widgets/Directions/t9n/Directions`)],B.prototype,`messages`,void 0),e([m(),I(`esri/core/t9n/Units`)],B.prototype,`messagesUnits`,void 0),e([m()],B.prototype,`searchProperties`,void 0),e([m()],B.prototype,`unit`,null),e([m()],B.prototype,`view`,null),e([m({type:E})],B.prototype,`viewModel`,void 0),e([m({type:D,nonNullable:!0})],B.prototype,`visibleElements`,void 0),B=e([h(`esri.widgets.Directions`)],B);const V=B;export{V as default};