/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import{__decorate as e}from"tslib";import r from"../../../../core/Accessor.js";import{AsyncUpdateMixin as t}from"../../../../core/AsyncUpdate.js";import s from"../../../../core/Logger.js";import{property as i,subclass as l}from"../../../../core/accessorSupport/decorators.js";import{fallbackObjectIDAttribute as o}from"../../../../layers/LayerConstants.js";import{fixFields as d,collectLabelingFields as n,collectFilterFields as a}from"../../../../layers/support/fieldUtils.js";let y=class extends(t(r)){get layer(){return this.layerView.layer}get requiredFields(){const{layerView:{layer:{fieldsIndex:e,objectIdField:r},definitionExpressionFields:t},rendererFields:s,labelingFields:i,viewFilterFields:l}=this;return d(e,[...t??[],...s??[],...i??[],...l??[],r??o])}constructor(e){super(e)}initialize(){this.addHandles([this.autoUpdateAsync("rendererFields",async()=>{const{fieldsIndex:e,renderer:r}=this.layer;return r?this._getFieldsAsync(t=>r.collectRequiredFields(t,e)):null}),this.autoUpdateAsync("labelingFields",async()=>{const{layer:e}=this;return e.labelsVisible?this._getFieldsAsync(r=>n(r,e)):null}),this.autoUpdateAsync("viewFilterFields",()=>{const{layer:e,mergedFilter:r}=this.layerView;return this._getFieldsAsync(t=>a(t,e,r))})])}async _getFieldsAsync(e){const r=new Set;try{return await e(r),Array.from(r).sort()}catch(t){return s.getLogger(this).error(t),null}}};e([i()],y.prototype,"layerView",void 0),e([i()],y.prototype,"layer",null),e([i()],y.prototype,"requiredFields",null),e([i()],y.prototype,"rendererFields",void 0),e([i()],y.prototype,"labelingFields",void 0),e([i()],y.prototype,"viewFilterFields",void 0),y=e([l("esri.views.3d.layers.support.SceneLayerViewRequiredFields")],y);export{y as SceneLayerViewRequiredFields};
