// All material copyright Esri, All Rights Reserved, unless otherwise specified. // See https://js.arcgis.com/4.30/esri/copyright.txt for details. //>>built define("require ../chunks/tslib.es6 ../intl ../core/arrayUtils ../core/has ../core/Logger ../core/promiseUtils ../core/reactiveUtils ../core/accessorSupport/decorators/property ../core/accessorSupport/decorators/subclass ../layers/support/fieldUtils ./Widget ./Editor/components/Prompt ./FeatureForm/css ./FeatureForm/featureFormUtils ./FeatureForm/FeatureFormViewModel ../chunks/componentsUtils ./support/dataUtils ./support/dateUtils ./support/globalCss ./support/Heading ./support/widgetUtils ./support/decorators/messageBundle ./support/decorators/vmEvent ./support/jsxFactory ../intl/substitute".split(" "), function(t,n,l,I,S,J,K,C,p,L,M,N,O,m,x,P,Q,F,w,G,H,T,D,R,f,E){l=class extends N{constructor(a,b){super(a,b);this._attemptFocusOnNextRender=!1;this._dateComponentMap=new Map;this._inputsWithChanges=new Set;this._listObserverNode=this._pendingSubtypeChoice=this._focusedFieldName=null;this._listObserver=new IntersectionObserver(c=>{c.length&&c[0].isIntersecting&&this._incrementRelatedRecordPage()},{root:window.document});this._prompt=null;this.groupDisplay="all";this.headingLevel=2;this.messagesTemplates= this.messagesFeature=this.messagesCommon=this.messages=null;this.viewModel=new P;this._onShowAllRelatedRecordsClick=c=>{const {feature:d,relatedRecordCallbacks:e}=this;d&&e?.showAllRelatedRecords&&e.showAllRelatedRecords({parentFeature:d,relationshipId:c})};this._onAddRelatedRecordsClick=(c,d)=>{const {feature:e,relatedRecordCallbacks:g}=this;e&&g?.addRelatedRecord&&g.addRelatedRecord({parentFeature:e,relatedLayer:d,relationshipId:c})};this._onFormKeyDown=this._onFormKeyDown.bind(this);this._onFormSubmit= this._onFormSubmit.bind(this);this._onGroupToggle=this._onGroupToggle.bind(this);this._onComponentBlur=this._onComponentBlur.bind(this);this._onComponentFocus=this._onComponentFocus.bind(this);this._onComponentKeyDown=this._onComponentKeyDown.bind(this);this._afterComponentCreate=this._afterComponentCreate.bind(this);this._afterComponentCreateOrUpdate=this._afterComponentCreateOrUpdate.bind(this);this._afterDateComponentCreate=this._afterDateComponentCreate.bind(this);this._afterDateComponentCreateOrUpdate= this._afterDateComponentCreateOrUpdate.bind(this);this._afterRadioGroupCreateOrUpdate=this._afterRadioGroupCreateOrUpdate.bind(this)}initialize(){this.addHandles([C.watch(()=>this.feature,()=>{this._inputsWithChanges.clear();this._dateComponentMap.clear();C.whenOnce(()=>!this.viewModel.updating).then(()=>{const a=this._getFocusableInput("forward");this._syncGroupInputStates();this._focusedFieldName=a?.name||null;this._attemptFocusOnNextRender=!0})}),C.watch(()=>this.groupDisplay,()=>this._syncGroupInputStates()), this.on("submit",a=>{if(0this._inputsWithChanges.add(c));this._focusedFieldName=b;this._attemptFocusOnNextRender=!0;this.scheduleRender()}}),C.watch(()=>[this.viewModel.activeRelationshipInput,this._listObserverNode],()=>this._onObserverChange())])}loadDependencies(){return Q.loadCalciteComponents({block:()=>new Promise((a,b)=>t(["../chunks/calcite-block"],a,b)),button:()=>new Promise((a,b)=>t(["../chunks/calcite-button"],a,b)),combobox:()=> new Promise((a,b)=>t(["../chunks/calcite-combobox"],a,b)),"combobox-item":()=>new Promise((a,b)=>t(["../chunks/calcite-combobox-item"],a,b)),"combobox-item-group":()=>new Promise((a,b)=>t(["../chunks/calcite-combobox-item-group"],a,b)),icon:()=>new Promise((a,b)=>t(["../chunks/calcite-icon"],a,b)),input:()=>new Promise((a,b)=>t(["../chunks/calcite-input"],a,b)),"input-date-picker":()=>new Promise((a,b)=>t(["../chunks/calcite-input-date-picker"],a,b)),"input-message":()=>new Promise((a,b)=>t(["../chunks/calcite-input-message"], a,b)),"input-number":()=>new Promise((a,b)=>t(["../chunks/calcite-input-number"],a,b)),"input-time-picker":()=>new Promise((a,b)=>t(["../chunks/calcite-input-time-picker"],a,b)),"input-time-zone":()=>new Promise((a,b)=>t(["../chunks/calcite-input-time-zone"],a,b)),label:()=>new Promise((a,b)=>t(["../chunks/calcite-label"],a,b)),list:()=>new Promise((a,b)=>t(["../chunks/calcite-list"],a,b)),"list-item":()=>new Promise((a,b)=>t(["../chunks/calcite-list-item"],a,b)),loader:()=>new Promise((a,b)=>t(["../chunks/calcite-loader"], a,b)),notice:()=>new Promise((a,b)=>t(["../chunks/calcite-notice"],a,b)),"radio-button":()=>new Promise((a,b)=>t(["../chunks/calcite-radio-button"],a,b)),"radio-button-group":()=>new Promise((a,b)=>t(["../chunks/calcite-radio-button-group"],a,b)),switch:()=>new Promise((a,b)=>t(["../chunks/calcite-switch"],a,b)),"text-area":()=>new Promise((a,b)=>t(["../chunks/calcite-text-area"],a,b))})}destroy(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode)}get _relatedRecordsEnabled(){const a= this.relatedRecordCallbacks;return!(!a||!(a.addRelatedRecord||a.editRelatedRecord||a.showAllRelatedRecords))}get disabled(){return this.viewModel.disabled}set disabled(a){this.viewModel.disabled=a}get feature(){return this.viewModel.feature}set feature(a){this.viewModel.feature=a}get formTemplate(){return this.viewModel.formTemplate}set formTemplate(a){this.viewModel.formTemplate=a}get icon(){return"form-field"}set icon(a){this._overrideIfSome("icon",a)}get label(){return this.messages?.widgetLabel?? ""}set label(a){this._overrideIfSome("label",a)}get layer(){return this.viewModel.layer}set layer(a){this.viewModel.layer=a}get map(){return this.viewModel.map}set map(a){this.viewModel.map=a}get relatedRecordCallbacks(){return this.viewModel.relatedRecordCallbacks}set relatedRecordCallbacks(a){this.viewModel.relatedRecordCallbacks=a}get relationshipId(){return this.viewModel.relationshipId}set relationshipId(a){this.viewModel.relationshipId=a}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(a){this.viewModel.spatialReference= a}get strict(){return this.viewModel.strict}set strict(a){this.viewModel.strict=a}get timeZone(){return this.viewModel.timeZone}set timeZone(a){this.viewModel.timeZone=a}get showPrompt(){return a=>{this._prompt?.cancel?.();this._prompt=a}}set showPrompt(a){this._overrideIfSome("showPrompt",a)}get clearPrompt(){return()=>this._prompt=null}set clearPrompt(a){this._overrideIfSome("clearPrompt",a)}getValues(){return this.viewModel.getValues()}submit(){return this.viewModel.submit()}render(){const {state:a}= this.viewModel;return f.tsx("div",{class:this.classes(m.css.base,G.globalCss.widget,G.globalCss.panel)},"ready"===a?this._renderForm():null)}_renderForm(){return f.tsx("div",null,f.tsx("form",{class:m.css.form,novalidate:!0,onkeydown:this._onFormKeyDown,onsubmit:this._onFormSubmit},this._renderHeader(),this._renderContent()),this._prompt?f.tsx(O.Prompt,{...this._prompt,headingLevel:this.headingLevel}):void 0)}_renderHeader(){var a=this.viewModel;if(a.formHeaderVisible){var b=null!=a.formTitle&&f.tsx(H.Heading, {key:"title",level:this.headingLevel},a.formTitle);a=null!=a.formDescription&&f.tsx("p",{class:m.css.description,key:"description"},a.formDescription);return f.tsx("div",{class:m.css.formHeader},b,a)}}_renderContent(){const {viewModel:a}=this;return a.activeRelationshipInput?this._renderRelationshipInput(a.activeRelationshipInput):a.inputs.filter(I.isSome).filter(b=>b.visible).map(b=>this._renderInput(b))}_renderInput(a){if(x.isGroupInput(a))return this._renderGroup(a);if(x.isFieldInput(a))return this._renderLabeledField(a); if(x.isRelationshipInput(a))return this._renderRelationshipInput(a);if(x.isTextElementInput(a))return this._renderTextElementInput(a)}_renderDescriptionOrEmpty(a,b){return null==a?null:f.tsx("div",{class:this.classes(m.css.description),id:b},a)}_renderGroup(a){const {disabled:b,formTemplate:c,headingLevel:d}=this,{description:e,id:g,inputs:k,label:h,open:r}=a,v=k.filter(u=>u.visible),q=this.viewModel.findField(this._focusedFieldName);return f.tsx("calcite-block",{class:this.classes(m.css.group,"sequential"=== this.groupDisplay?m.css.groupSequential:null,q?.group===a?m.css.groupActive:null,b?m.css.inputDisabled:null),collapsible:!0,"data-group":a,description:e||void 0,disabled:b,heading:`${h}`,headingLevel:c?.title?H.incrementHeadingLevel(d):d,id:g,key:g,open:r,onCalciteBlockToggle:({target:u})=>this._onGroupToggle(u,a)},v.map(u=>this._renderInput(u)))}_getFocusableInput(a,b){const c=x.flattenInputs(this.viewModel.inputs);"backward"===a&&c.reverse();b?x.isGroupInput(b)?a=(a=b.inputs.find(d=>d.visible))? c.indexOf(a):0:(x.isInputInGroupInput(b)&&!b.group.open?(b=b.group.inputs.filter(x.isFieldInput),a="forward"===a?b[b.length-1]:b[0]):a=b,a=c.indexOf(a)+1):a=0;for(;athis._saveValueFromComponent(c.target)}): f.tsx("calcite-text-area",{...b,resize:"vertical",onCalciteTextAreaInput:c=>this._saveValueFromComponent(c.target)}):f.tsx("calcite-input",{...b,loading:a.updating,type:"text",onCalciteInputInput:c=>this._saveValueFromComponent(c.target)})}_renderNumberComponent(a,b){return f.tsx("calcite-input-number",{...b,integer:M.isIntegerField(a.field),loading:a.updating,type:"number",onCalciteInputNumberInput:c=>this._saveValueFromComponent(c.target)})}_renderDateComponents(a,b){const {field:c}=a;switch(c.type){case "date":return this._renderDateFieldComponents(a, b);case "date-only":return this._renderDateOnlyFieldComponent(a,b);case "time-only":return this._renderTimeOnlyFieldComponent(a,b);case "timestamp-offset":return this._renderTimestampOffsetFieldComponents(a,b);default:return this._renderReadOnlyComponent(a,w.getLabelForDateFieldValue(c,b.value,{timeZone:this.timeZone,...w.getIntlOptionsForField(c)}))}}_renderDateOnlyFieldComponent(a,b){const {range:c,valid:d,value:e}=a,{class:g,key:k,readOnly:h}=b,{rawMax:r,rawMin:v}=c;return f.tsx("calcite-input-date-picker", {afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!d,class:g,"data-date-part":"date","data-field-name":b["data-field-name"],key:`${k}-date-input`,max:F.isString(r)?r:void 0,min:F.isString(v)?v:void 0,numberingSystem:w.numberingSystem,onblur:q=>{this._focusedFieldName=null;this._saveValueFromDateComponent(q.target)},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:h,value:null!=e?`${e}`:void 0,onCalciteInputDatePickerChange:q=> this._saveValueFromDateComponent(q.target)})}_renderTimeOnlyFieldComponent(a,b){const {valid:c,value:d}=a,{class:e,key:g,readOnly:k}=b;return f.tsx("calcite-input-time-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!c,class:e,"data-date-part":"time","data-field-name":b["data-field-name"],key:`${g}-time-input`,numberingSystem:w.numberingSystem,onblur:h=>{this._focusedFieldName=null;this._saveValueFromDateComponent(h.target)},onfocus:this._onComponentFocus, overlayPositioning:"fixed",readOnly:k,step:a.timeStep,value:null!=d?`${d}`:void 0,onCalciteInputTimePickerChange:h=>this._saveValueFromDateComponent(h.target)})}_renderTimestampOffsetFieldComponents(a,b){const {name:c,range:d,timeZone:e,valid:g,value:k}=a,{class:h,key:r,readOnly:v}=b,{rawMax:q,rawMin:u}=d;b={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!g,numberingSystem:w.numberingSystem,overlayPositioning:"fixed",readOnly:v,["data-field-name"]:c, onfocus:this._onComponentFocus};const A=w.prepareISOFieldValueForDateComponents(q,e),y=w.prepareISOFieldValueForDateComponents(u,e),B=w.prepareISOFieldValueForDateComponents(k,e);return f.tsx("div",{class:m.css.dateInputContainer,key:`${r}-date-time-container`},f.tsx("calcite-input-date-picker",{...b,class:h,"data-date-part":"date",key:`${r}-date-input`,max:A?.date??void 0,min:y?.date??void 0,onblur:z=>{this._focusedFieldName=null;this._saveValueFromDateComponent(z.target)},value:B.date??void 0,onCalciteInputDatePickerChange:z=> this._saveValueFromDateComponent(z.target)}),f.tsx("calcite-input-time-picker",{...b,class:h,"data-date-part":"time",key:`${r}-time-input`,onblur:z=>{this._focusedFieldName=null;this._saveValueFromDateComponent(z.target)},step:a.timeStep,value:B.time??void 0,onCalciteInputTimePickerChange:z=>this._saveValueFromDateComponent(z.target)}),a.includeTimeOffset?f.tsx("calcite-input-time-zone",{...b,class:h,"data-date-part":"timeZone",disabled:v,key:`${r}-timezone-input`,onblur:z=>{this._focusedFieldName= null;this._saveValueFromDateComponent(z.target)},value:B.timeZoneOffset??"0",onCalciteInputTimeZoneChange:z=>this._saveValueFromDateComponent(z.target)}):null)}_renderDateFieldComponents(a,b){const {includeTime:c,name:d,valid:e,value:g}=a,{class:k,key:h,max:r,min:v,readOnly:q}=b;var {timeZone:u}=this;a={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!e,numberingSystem:w.numberingSystem,overlayPositioning:"fixed",readOnly:q,["data-field-name"]:d, onfocus:this._onComponentFocus};b=w.prepareUnixFieldValueForDateComponents(g,u);const A=w.prepareUnixFieldValueForDateComponents(r,u);u=w.prepareUnixFieldValueForDateComponents(v,u);return f.tsx("div",{class:m.css.dateInputContainer,key:`${h}-date-time-container`},f.tsx("calcite-input-date-picker",{...a,class:k,"data-date-part":"date",key:`${h}-date-input`,max:A?.date??void 0,min:u?.date??void 0,onblur:y=>{this._focusedFieldName=null;this._saveValueFromDateComponent(y.target)},value:b.date??void 0, onCalciteInputDatePickerChange:y=>this._saveValueFromDateComponent(y.target)}),c?f.tsx("calcite-input-time-picker",{...a,class:k,"data-date-part":"time",key:`${h}-time-input`,onblur:y=>{this._focusedFieldName=null;this._saveValueFromDateComponent(y.target)},step:1,value:b.time??void 0,onCalciteInputTimePickerChange:y=>this._saveValueFromDateComponent(y.target)}):null)}_renderReadOnlyComponent(a,b){a=this.getCommonInputProps(a);return f.tsx("calcite-input",{...a,class:this.classes(m.css.fieldInput, m.css.inputDisabled),readOnly:!0,type:"text",value:null!=b?`${b}`:a.value})}_renderComboBoxComponent(a,b,c){const {value:d,name:e}=a,{viewModel:g,_inputsWithChanges:k}=this,h="INSERT"===g.arcadeEditType,r=k.has(e),v=null==d&&(!h||r);return f.tsx("calcite-combobox",{...c,allowCustomValues:!1,clearDisabled:!0,disabled:c.readOnly,onblur:h&&a.showNoValueOptionEnabled&&!r?()=>{}:c.onblur,overlayPositioning:"fixed",selectionMode:"single",onCalciteComboboxChange:({target:q})=>{v&&0===q.selectedItems.length? this._ignoreDeselectionOfNoValueOption(q):a.isSubtypeField&&0===q.selectedItems.length?q.value=`${a.value}`:this._saveValueFromComponent(q)}},this.renderComboboxOptionsList(a,b))}renderComboboxOptionsList(a,b){const {value:c,name:d}=a,{messages:e,messagesTemplates:g,viewModel:k,_inputsWithChanges:h}=this,[r,v,q]=b.map(y=>y.map(({name:B,value:z})=>f.tsx("calcite-combobox-item",{key:`#${z}`,selected:c===z,textLabel:B,value:`${z}`})));b=[];0this._renderRadioButtonComponent({key:g,label:g,name:d,value:k,selected:k===e,props:c}));a.showNoValueOptionEnabled&&b.unshift(this._renderRadioButtonComponent({key:"empty-option",label:a.showNoValueLabel||this.messages.empty,name:d,value:"",selected:""===e||null===e,props:c}));return f.tsx("calcite-radio-button-group",{afterCreate:this._afterRadioGroupCreateOrUpdate,afterUpdate:this._afterRadioGroupCreateOrUpdate,class:m.css.inputRadioGroup, "data-field-name":c["data-field-name"],key:`${c.key}-radio-group`,layout:"vertical",name:c.key,required:c.required},b)}_renderSwitchComponent(a,b){const {value:c}=a;a=x.isFieldElementWithInputType(a.element,"switch")?c===a.element.input.onValue:!1;return f.tsx("calcite-switch",{...b,checked:a,class:m.css.inputSwitch,disabled:b.readOnly,onblur:()=>{this._focusedFieldName=null},onCalciteSwitchChange:d=>this._saveValueFromComponent(d.target)})}_renderRadioButtonComponent({key:a,name:b,value:c,selected:d, label:e,props:g}){return f.tsx("calcite-label",{class:m.css.inputRadioLabel,key:a,layout:"inline"},f.tsx("calcite-radio-button",{...g,afterCreate:void 0,afterUpdate:void 0,checked:d,class:m.css.inputRadio,disabled:g.readOnly,name:b,onblur:()=>{this._focusedFieldName=null},value:c,onCalciteRadioButtonChange:({target:k})=>{k.checked&&this._saveValueFromComponent(k)}}),e)}_renderAuxiliaryText(a){const b=a.name,c=this._inputsWithChanges.has(b)&&!a.valid?x.getErrorMessageForFieldInput(a,this.messages, this.timeZone):null!=this.viewModel.contingencyConstraintViolations.get(b)?this.messages.validationErrors.valuesIncompatible:null!=a.valueExpressionExecutor&&a.valueExpressionExecutor.stale?this.messages.valueExpressionError:null;return null!=c?f.tsx("calcite-input-message",{icon:!0,status:"invalid"},c):this._inputsWithChanges.has(b)&&a.valueIsOutOfDomain?f.tsx("calcite-input-message",{icon:!0,status:"idle"},this.messages.subtypes.fieldOutOfSubtypeDomainWarning):this._renderDescriptionOrEmpty(a.description)}_renderShowAllRelatedRecordsListItem(a){const {featureCount:b, relationshipId:c,showAllActionVisible:d}=a;({relatedRecordCallbacks:a}=this);if(d&&a?.showAllRelatedRecords)return a=this.messages,f.tsx("calcite-list-item",{description:E.substitute(a.totalCount,{count:b}),label:a.showAll,value:!0,onCalciteListItemSelect:()=>this._onShowAllRelatedRecordsClick(c)},f.tsx("calcite-icon",{icon:"list",scale:"s",slot:"content-end"}))}_renderAddRelatedRecordButton(a){const {canAddRelatedFeature:b,relationshipId:c,relatedLayer:d}=a,{messages:e,relatedRecordCallbacks:g}= this;if(b&&g?.addRelatedRecord&&d)return f.tsx("calcite-button",{alignment:"center",appearance:"outline-fill",class:m.css.centeredButton,disabled:a.updating||!a.originHasValidKey,iconStart:"plus",key:`${c}-add-button`,onclick:()=>{!a.updating&&a.originHasValidKey&&this._onAddRelatedRecordsClick(c,d)},round:!0,scale:"s",width:"half"},a.relatedLayerIsTable?e.addRecord:e.addFeature)}_renderRelatedRecordListItem(a,b){const {feature:c,description:d,title:e}=a,{feature:g,relatedRecordCallbacks:k}=this, {highlightHelper:h}=this.viewModel;return f.tsx("calcite-list-item",{bind:this,description:d,key:`${b}-${c.uid}`,label:e,onclick:()=>{h?.removeAll();k?.editRelatedRecord&&g&&k.editRelatedRecord({parentFeature:g,relationshipId:b,relatedFeature:c})},onmouseenter:h?()=>h.add(c):void 0,onmouseleave:h?()=>h.remove(c):void 0,value:e},f.tsx("calcite-icon",{icon:x.getIconForFeature(c),slot:"content-start"}),f.tsx("calcite-icon",{icon:"chevron-right",scale:"s",slot:"content-end"}))}_renderRelationshipInput(a){if(this._relatedRecordsEnabled&& a.editable){var {featureCount:b,relationshipId:c,showAllEnabled:d}=a,e=d?null:this._renderDescriptionOrEmpty(a.description),g=0this._renderRelatedRecordListItem(c,b)),this._renderShowAllRelatedRecordsListItem(a), this._renderObserverNode())}_renderNoValidOriginKeyNotice(a){var {messages:b}=this;b=a.relatedLayerIsTable?b.noOriginKeyRecord:b.noOriginKeyFeature;const c=a.relationship?.keyField,d=this.viewModel.findField(c),e=a.layer?.fieldsIndex.get(c);a=E.substitute(b,{relatedLayerName:a.relatedLayer?.title,originKeyField:d?.label||e?.alias||c});return f.tsx("calcite-notice",{icon:"information",kind:"brand",open:!0,scale:"s",width:"full"},f.tsx("div",{slot:"message"},a))}_renderNoRelatedRecordsNotice(){return f.tsx("calcite-notice", {icon:"information",kind:"brand",open:!0,scale:"s",width:"full"},f.tsx("div",{slot:"message"},this.messagesFeature.noRelatedFeatures))}_renderObserverNode(){if(this.viewModel.activeRelationshipInput?.showAllEnabled)return f.tsx("div",{afterCreate:this._afterListObserverCreated,afterRemoved:this._afterListObserverRemoved,bind:this,class:m.css.listObserver,key:"feature-observer"})}_renderTextElementInput(a){return f.tsx("div",{class:m.css.textElement,innerHTML:a.text,key:a.id})}getCommonInputProps(a){var {disabled:b}= this;const {editable:c,hint:d,label:e,maxLength:g,minLength:k,name:h,range:{max:r,min:v},required:q,valid:u,value:A}=a;a=this._inputsWithChanges.has(h);b=!c||b;return{afterCreate:this._afterComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,"aria-invalid":u?"false":"true",class:this.classes(m.css.fieldInput,b?m.css.inputDisabled:null),status:a&&!u?"invalid":"idle",key:h,label:e,max:null!=r?r:void 0,min:null!=v?v:void 0,maxLength:-1{a.value=void 0;switch(b.field.type){case "date":a.value= w.prepareUnixFieldValueForDateComponents(b.value,this.timeZone).date??"";break;case "timestamp-offset":a.value=w.prepareISOFieldValueForDateComponents(b.value,this.timeZone).date??"";break;default:a.value=`${b.value}`}e.unobserve(a)});e.observe(a)}if(null!=d)switch(c){case "date":d.date=a;break;case "time":d.time=a;break;case "timeZone":d.timeZone=a}else this._dateComponentMap.set(b.name,{[c]:a});this._afterDateComponentCreateOrUpdate(a)}_afterDateComponentCreateOrUpdate(a){this._afterComponentCreateOrUpdate(a)}_afterComponentCreate(a){const b= this._getFieldInputFromHTMLElement(a);x.isNumberFieldInput(b)&&null!=a.value&&"setNumberValue"in a&&a.setNumberValue({committing:!1,value:a.value,origin:"direct"});this._afterComponentCreateOrUpdate(a)}_afterRadioGroupCreateOrUpdate(a){var b=a.selectedItem;a=a.querySelector("calcite-radio-button");(b=b||a)&&this._afterComponentCreateOrUpdate(b)}_afterComponentCreateOrUpdate(a){var {viewModel:b}=this;const c=this._getFieldInputFromHTMLElement(a);b=b.findField(this._focusedFieldName);this._attemptFocusOnNextRender&& b===c&&(this._attemptFocusOnNextRender=!1,x.isInputInGroupInput(c)&&(c.group.open=!0),a.setFocus())}_onComponentFocus(a){this._focusedFieldName=this._getFieldInputFromHTMLElement(a.target).name}_onComponentBlur(a){a=a.target;this._focusedFieldName=null;this._saveValueFromComponent(a)}_saveValueFromDateComponent(a){const {timeZone:b}=this;var c=this._getFieldInputFromHTMLElement(a);const d=c.field.type,{name:e,range:g}=c;if(c=this._dateComponentMap.get(e)){var k=this.viewModel.getValue(e),h=null;"date-only"=== d?h=Array.isArray(a.value)?a.value[0]:a.value:"time-only"===d?(k=w.normalizeTimeOnlyString(k),h=w.normalizeTimeOnlyString(a.value)):h="timestamp-offset"===d?null!=a.value?w.getISOFieldValueFromDateComponents({dateComponent:c.date,timeComponent:c.time,timeZoneComponent:c.timeZone,oldValue:k,defaultTimeZone:b}):null:null!=a.value?w.getUnixFieldValueFromDateComponents({oldValue:k,dateComponent:c.date,timeComponent:c.time,timeZone:b,max:g.max,min:g.min}):null;null!==h&&a.value?k!==h&&this._updateFieldValue(e, h):this._updateFieldValue(e,null)}}_saveValueFromComponent(a){const b=this._getFieldInputFromHTMLElement(a);a=this._parseValue(a);const c=b.value;b.isSubtypeField&&x.subtypeChangeShouldPrompt(this.layer,c,a)?this._pendingSubtypeChoice||a===c||(this._pendingSubtypeChoice=this._handleSubtypeChoice(b,a)):this._updateFieldValue(b.name,a)}async _handleSubtypeChoice(a,b){const {value:c,name:d}=a,{layer:e,messages:g,viewModel:k,messagesCommon:h}=this;this._updateFieldValue(d,b);if(e&&"subtypes"in e&&e.subtypes?.length){var r= e.subtypes.find(y=>y.code===b),v=e.subtypes.find(y=>y.code===c)?.name??`${c}`;if(r){k.hasPendingSubtypeChoice=!0;var q=K.createResolver(),u="update-fields",A=[{label:g.subtypes.useDefaultValuesOption,value:"update-fields"},{label:g.subtypes.keepCurrentValuesOption,value:"keep-existing"}];v={context:"info",title:g.subtypes.changeWarningTitle,message:E.substitute(g.subtypes.changeWarning,{originalType:v,newType:r.name}),radios:A,defaultRadioSelection:"update-fields",onRadioSelection:y=>u=y,actions:{primary:{label:h.apply, action:()=>q.resolve(u),type:"positive"},secondary:{label:h.cancel,type:"neutral",action:()=>q.resolve("undo")}},cancel:()=>q.reject()};try{switch(this.showPrompt(v),await q.promise){case "update-fields":k.applySubtypeDefaults(r);this._validateContingenciesForNonNullFields();break;case "keep-existing":this._validateContingenciesForNonNullFields();break;case "undo":this._updateFieldValue(a.name,c)}}finally{k.hasPendingSubtypeChoice=!1,this.clearPrompt(),this._pendingSubtypeChoice=null}}}}_onComponentKeyDown({key:a, target:b}){b=this._getFieldInputFromHTMLElement(b);"Enter"===a&&x.isInputInGroupInput(b)&&!b.group.open&&(b.group.open=!0)}_updateFieldValue(a,b){const c=this.viewModel.getValue(a);this.viewModel.setValue(a,b);this._inputsWithChanges.add(a);c!==b&&this.viewModel.fieldsWithContingentValues.has(a)&&this._validateContingenciesForNonNullFields()}_validateContingenciesForNonNullFields(){const a=Object.fromEntries(Object.entries(this.getValues()).filter(([,b])=>null!=b));this.viewModel.validateContingencyConstraints(a)}_parseValue(a){const b= this._getFieldInputFromHTMLElement(a),c=a.value;return x.isFieldElementWithInputType(b.element,"switch")?a.checked?b.element.input.onValue:b.element.input.offValue:null==c||""===c?null:"number"===b.dataType?"-0"===c||"-0."===c||"-0,"===c?c:parseFloat(c):"date"===b.field.type?parseFloat(c):c}_ignoreDeselectionOfNoValueOption(a){const {firstChild:b,selectedItems:c}=a;0===c.length&&b&&"selected"in b?b.selected=!0:J.getLogger(this).warnOnce("Failed to override user attempt to deselect 'No value' option.")}_onGroupToggle(a, b){a.open?(b.open=!0,this._focusedFieldName=this._getFocusableInput("forward",b)?.name||null,this._attemptFocusOnNextRender=!0,"sequential"===this.groupDisplay&&this.viewModel.allGroupInputs.forEach(c=>{c!==b&&(c.open=!1)})):b.open=!1;this.scheduleRender()}_onFormSubmit(a){a.preventDefault()}_onFormKeyDown(a){"Enter"===a.key&&this.viewModel.submit()}_afterListObserverCreated(a){this.viewModel.activeRelationshipInput&&(this._listObserverNode=a)}_afterListObserverRemoved(){this._listObserverNode=null}_onObserverChange(){this._listObserverNode&& this._listObserver.unobserve(this._listObserverNode);const a=this.viewModel.activeRelationshipInput;a&&this._listObserverNode&&a.showAllEnabled&&this._listObserver.observe(this._listObserverNode)}_incrementRelatedRecordPage(){this.viewModel.activeRelationshipInput?.incrementPage()}_syncGroupInputStates(){if("sequential"===this.groupDisplay){var a=this.viewModel.allGroupInputs;if(a.length){var b=a.filter(c=>c.open);0===b.length?a[0].open=!0:1c.open=!1)}}}get test(){return{inputsWithChanges:this._inputsWithChanges}}}; n.__decorate([p.property()],l.prototype,"_listObserverNode",void 0);n.__decorate([p.property()],l.prototype,"_relatedRecordsEnabled",null);n.__decorate([p.property()],l.prototype,"_prompt",void 0);n.__decorate([p.property()],l.prototype,"disabled",null);n.__decorate([p.property()],l.prototype,"feature",null);n.__decorate([p.property()],l.prototype,"formTemplate",null);n.__decorate([p.property()],l.prototype,"groupDisplay",void 0);n.__decorate([p.property()],l.prototype,"headingLevel",void 0);n.__decorate([p.property()], l.prototype,"icon",null);n.__decorate([p.property()],l.prototype,"label",null);n.__decorate([p.property()],l.prototype,"layer",null);n.__decorate([p.property()],l.prototype,"map",null);n.__decorate([p.property(),D.messageBundle("esri/widgets/FeatureForm/t9n/FeatureForm")],l.prototype,"messages",void 0);n.__decorate([p.property(),D.messageBundle("esri/t9n/common")],l.prototype,"messagesCommon",void 0);n.__decorate([p.property(),D.messageBundle("esri/widgets/Feature/t9n/Feature")],l.prototype,"messagesFeature", void 0);n.__decorate([p.property(),D.messageBundle("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],l.prototype,"messagesTemplates",void 0);n.__decorate([p.property()],l.prototype,"relatedRecordCallbacks",null);n.__decorate([p.property()],l.prototype,"relationshipId",null);n.__decorate([p.property()],l.prototype,"spatialReference",null);n.__decorate([p.property()],l.prototype,"strict",null);n.__decorate([p.property()],l.prototype,"timeZone",null);n.__decorate([p.property()],l.prototype,"showPrompt", null);n.__decorate([p.property()],l.prototype,"clearPrompt",null);n.__decorate([p.property(),R.vmEvent(["value-change","submit"])],l.prototype,"viewModel",void 0);n.__decorate([p.property()],l.prototype,"test",null);return l=n.__decorate([L.subclass("esri.widgets.FeatureForm")],l)});