/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import{__decorate as e}from"tslib";import t from"../../core/Accessor.js";import{watch as r,sync as n}from"../../core/reactiveUtils.js";import{generateUID as i}from"../../core/uid.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import{isLayerWithContingentValues as s}from"../support/ContingentValuesManager.js";let l=class extends t{constructor(e){super(e),this._uid=`${i()}`}getAndWatchFieldValueOptions(e){const{feature:t,...i}=e,a=this.manager.getFieldValueOptions({...i,feature:t.plainGraphic}),{layer:o,fieldName:l}=e,u=this._makeHandleId(l);if(t.hasHandles(u)||!s(o))return a;const d=this.manager.getRelatedFields(o,l);if(0===d.size)return a;const p=r(()=>c(t,d),()=>this.manager.resetOptionsForField(o,t.plainGraphic,l),n);return this.addHandles(p),t.addHandles(p,u),a}getViolationTypeForField(e,t){const r=e.layer;if(!s(r))return null;const n=this.manager.getViolationForField(r,e.plainGraphic,t);if(!n)return null;switch(n.type){case"warning":return"contingent-values-validation-error::contingency-violation-warning";case"error":return"contingent-values-validation-error::contingency-violation-error";default:return null}}reset(){this.manager.resetOptions(),this.manager.resetViolations()}validateContingencyConstraints(e,t){const{layer:r}=e;return s(r)?this.manager.validateContingencyConstraints(r,e.plainGraphic,t):[]}validateContingenciesForNonNullFields(e){const{layer:t}=e;s(t)&&this.manager.validateContingenciesForNonNullFields(t,e.plainGraphic)}_makeHandleId(e){return`${this._uid}-${e}`}};function c(e,t){const r=[];for(const n of t)r.push(e.getAttribute(n));return r}e([a()],l.prototype,"manager",void 0),l=e([o("esri.widgets.BatchAttributeForm.ReactiveContingentValuesManager")],l);export{l as ReactiveContingentValuesManager};
