/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import{__decorate as e}from"tslib";import r from"../../../core/Error.js";import"../../../core/has.js";import{destroyMaybe as t}from"../../../core/maybe.js";import{watch as i,syncAndInitial as s}from"../../../core/reactiveUtils.js";import{property as a,subclass as u}from"../../../core/accessorSupport/decorators.js";import{getObjectId as o}from"../../../layers/graphics/dehydratedFeatures.js";import{packFields as n}from"../../../layers/support/fieldUtils.js";import{FeatureLikeLayerViewBase3D as p}from"./FeatureLikeLayerViewBase3D.js";import{FeatureGraphics3DGraphicsPipeline as l}from"./graphics/FeatureGraphics3DGraphicsPipeline.js";import{updatingProgress as d}from"../support/updatingProperties.js";const c=c=>{const m=p(c);let h=class extends m{initialize(){this.addHandles(i(()=>this._updatingRequiredPromise,e=>this._updatingHandles.addPromise(e),s))}destroy(){this._updatingHandles.removeAll(),this._fetcherContext=t(this._fetcherContext)}get maximumNumberOfFeatures(){return this.graphicsPipeline.maximumNumberOfFeatures}set maximumNumberOfFeatures(e){this.graphicsPipeline.maximumNumberOfFeatures=e}get maximumNumberOfFeaturesExceeded(){return null!=this.graphicsPipeline&&!this.suspended&&this.graphicsPipeline.maximumNumberOfFeaturesExceeded}get updatingProgressValue(){return this.graphicsPipeline?.updatingProgressValue??0}get updatePolicy(){return this.graphicsPipeline?.updatePolicy??0}get snappingComplexityExceeded(){return this.graphicsPipeline?.snappingComplexityExceeded??!0}get hasZ(){const e=this.layer,r=e.capabilities&&e.capabilities.data;return!(!r||!r.supportsZ)&&("returnZ"in e&&null!=e.returnZ?e.returnZ:r.supportsZ)}get hasM(){const e=this.layer,r=e.capabilities&&e.capabilities.data;return!(!r||!r.supportsM)&&("returnM"in e&&null!=e.returnM&&e.returnM)}get availableFieldsForQuery(){return n(this.layer.fieldsIndex,this.availableFields)}setVisibility(e,r){this.graphicsPipeline?.setVisibility(e,r)}queryFeatures(e,r){const t=()=>super.queryFeatures(e,r);return"mesh"===this.layer.geometryType?this._queryFeaturesMesh(this._ensureQuery(e),t):t()}async createGraphicsPipeline(){return new l({layerView:this})}async doRefresh(e){return await this.graphicsPipeline.doRefresh(e)}_popupFeatureHasRequiredFields(e,r){if(!super._popupFeatureHasRequiredFields(e,r))return!1;const t=o(e,this.layer.objectIdField);if(null==t)return!0;const i=this.graphicsPipeline.getMissingAttributesForFeature(t);if(null==i)return!0;for(const s of r)if(i.has(s))return!1;return!0}get usedMemory(){return this.graphicsPipeline?.usedMemory??0}get unloadedMemory(){return this.graphicsPipeline?.unloadedMemory??0}get ignoresMemoryFactor(){return this.graphicsPipeline?.ignoresMemoryFactor??!1}async _queryFeaturesMesh(e,r){this._validateQueryFeaturesMesh(e);const t=await r(),i=this.graphicsPipeline;if(e?.outStatistics||null==i)return t;const s=this.layer.objectIdField,a=[];for(const u of t.features)if(u.geometry){const e=i.getHydratedGeometry(u.attributes[s]);e&&(u.geometry=e,a.push(u))}else a.push(u);return t.features=a,t}_validateQueryFeaturesMesh(e){if(!e)return;const t=e=>{throw new r("feature-layer-view:unsupported-query",`Queries on Mesh feature collection layers do not support '${e}'`)},i=["quantizationParameters","geometryPrecision","maxAllowableOffset"];for(const r of i)null!=e[r]&&t(r);"returnM"in e&&e.returnM&&t("returnM"),"returnCentroid"in e&&e.returnCentroid&&t("returnCentroid"),null==e.outSpatialReference||e.outSpatialReference.equals(this.view.spatialReference)||t("outSpatialReference")}get test(){}};return e([a()],h.prototype,"layer",void 0),e([a()],h.prototype,"graphicsPipeline",void 0),e([a()],h.prototype,"maximumNumberOfFeatures",null),e([a()],h.prototype,"maximumNumberOfFeaturesExceeded",null),e([a(d)],h.prototype,"updatingProgress",void 0),e([a({readOnly:!0})],h.prototype,"updatingProgressValue",null),e([a({readOnly:!0})],h.prototype,"updatePolicy",null),e([a()],h.prototype,"snappingComplexityExceeded",null),e([a({readOnly:!0})],h.prototype,"hasZ",null),e([a({readOnly:!0})],h.prototype,"hasM",null),e([a()],h.prototype,"availableFieldsForQuery",null),h=e([u("esri.views.3d.layers.FeatureLikeLayerView3D")],h),h};export{c as FeatureLikeLayerView3D};
