// 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 ../../../Graphic ../../../core/arrayUtils ../../../core/has ../../../core/Logger ../../../core/maybe ../../../core/reactiveUtils ../../../core/typedArrayUtil ../../../core/accessorSupport/decorators/property ../../../core/accessorSupport/decorators/subclass ../../../chunks/vec32 ../../../core/libs/gl-matrix-2/factories/vec3f64 ../../../geometry/projection/projectBuffer ../../../geometry/projection/projectVectorToVector ../../../geometry/support/contains ../../../geometry/support/DoubleArray ../../../geometry/support/zscale ../../../layers/LayerConstants ../../../layers/graphics/dehydratedFeatures ../../../layers/graphics/dehydratedPoint ../../../layers/graphics/hydratedFeatures ../../../layers/graphics/controllers/I3SOnDemandController ../../../layers/support/FeatureFilter ../../../rest/support/Query ../../../support/basemapUtils ./I3SPointsWorkerHandle ./LayerView3D ./graphics/Graphics3DFeatureProcessor ./graphics/QueryEngine ./i3s/featureEditing ./i3s/I3SGraphicsMap ./i3s/I3SOverrides ./i3s/I3SUtil ./support/DefinitionExpressionSceneLayerView ./support/fieldProperties ./support/LayerViewPerformanceInfo ./support/PopupSceneLayerView ./support/SceneLayerViewRequiredFields ./support/TemporalSceneLayerView ../support/debugFlags ../support/orientedBoundingBox ../support/updatingProperties ../webgl-engine/lib/Attribute ../webgl-engine/lib/UpdatePolicy ../../layers/SceneLayerView ../../layers/support/popupUtils ../../support/Scheduler".split(" "), function(O,h,G,P,A,x,t,y,Q,l,R,S,H,I,T,J,B,U,V,W,X,Y,Z,aa,K,ba,L,g,ca,da,C,ea,M,w,fa,ha,ia,ja,ka,la,D,ma,na,oa,pa,qa,ra,sa){function E(a){return"geometryBuffer"in a&&null!==a.geometryBuffer}function F(a){const b=a.attributeInfo,d=a.node.index;if(null!=b?.loadedAttributes&&null!=b.attributeData)for(let c=0;c{{const c= b.attributeInfo;if(null==c?.loadedAttributes||null==c.attributeData)a=!1;else{b=!1;for(const {name:e}of c.loadedAttributes)if(c.attributeData[e]){const f=w.getCachedAttributeValue(c.attributeData[e],d);f!==a.attributes[e]&&(a.attributes[e]=f,b=!0)}a=b}}return a},a=>this.processor.graphicsCore.recreateGraphics(a));this.holeFilling="always";this.progressiveLoadFactor=1;this.supportsHeightUnitConversion=!0;this._coordinatesOutsideExtentErrors=0;this._maxCoordinatesOutsideExtentErrors=20}tryRecycleWith(a, b){return a.url===this.layer.url&&this._i3sOverrides.isEmpty?a.load(b).then(()=>{w.checkRecyclable(this.layer,a,this._i3sOverrides);this.layer=a;this._i3sOverrides.destroy();this._i3sOverrides=new M.I3SOverrides({view:this.view,layer:a,memoryController:this.view.resourceController?.memoryController});t.destroyMaybe(this._queryEngine);this._setupQueryEngine();this.processor.resetObjectStates()}):null}initialize(){this.addResolvingPromise(this.layer.indexInfo);this._i3sOverrides=new M.I3SOverrides({view:this.view, layer:this.layer,memoryController:this.view.resourceController?.memoryController});w.checkSpatialReferences(this.layer,this.view.spatialReference,this.view.viewingMode);this._fieldsHelper=new ka.SceneLayerViewRequiredFields({layerView:this});this._updatingHandles.add(()=>this.layer.rangeInfos,a=>this._rangeInfosChanged(a),y.initial);this._updatingHandles.add(()=>this.layer.renderer,(a,b)=>this._rendererChange(a,b));this._updatingHandles.add(()=>[this.parsedDefinitionExpression,this._excludeObjectIdsSorted], ()=>this._filterChange());this.addHandles(y.watch(()=>D.debugFlags.I3S_TREE_SHOW_TILES,a=>{if(a&&!this._treeDebugger){const b=this._controller.crsIndex;(new Promise((d,c)=>O(["./support/I3STreeDebugger"],d,c))).then(({I3STreeDebugger:d})=>{!this._treeDebugger&&D.debugFlags.I3S_TREE_SHOW_TILES&&(this._treeDebugger=new d({lv:this,view:this.view,nodeSR:b}))})}else a||!this._treeDebugger||D.debugFlags.I3S_TREE_SHOW_TILES||(this._treeDebugger.destroy(),this._treeDebugger=null)},y.initial));this._set("processor", new ca.Graphics3DFeatureProcessor({owner:this,preferredUpdatePolicy:pa.UpdatePolicy.ASYNC,scaleVisibilityEnabled:!0,filterVisibilityEnabled:!0,timeExtentEnabled:!1,frustumVisibilityEnabled:!1,elevationAlignmentEnabled:!0,elevationFeatureExpressionEnabled:!1,setUidToIdOnAdd:!1,dataExtent:this.layer.fullExtent,updateClippingExtent:a=>this._updateClippingExtent(a)}));this.processor.elevationAlignment?.events.on("invalidate-elevation",({extent:a,spatialReference:b})=>this._controller.updateElevationChanged(a, b));this.supportsHeightUnitConversion&&(this._verticalScale=U.getGeometryZScaler("point",this.layer.spatialReference,this.view.spatialReference));this.addResolvingPromise(this.processor.initializePromise);this._memCache=this.view.resourceController.memoryController.newCache(`psl-${this.uid}`);this._controller=new Z({layerView:this});w.containsDraco(this.layer.geometryDefinitions)&&(this._worker=new L.I3SPointsWorkerHandle(a=>this.view.resourceController.immediate.schedule(a)));this.addHandles(this.layer.on("apply-edits", a=>this._updatingHandles.addPromise(a.result)));this.addHandles(this.layer.on("edits",a=>{const b=this._pendingEditsQueue.then(()=>this._handleEdits(a)).then();this._pendingEditsQueue=b;this._updatingHandles.addPromise(b)}));this.when(()=>{this._setupQueryEngine();this._updatingHandles.add(()=>this.maximumNumberOfFeatures,a=>this._controller.featureTarget=a,y.initial);this._updatingHandles.add(()=>this.suspended,a=>{a&&this._removeAllNodeData()})})}destroy(){this._treeDebugger=t.destroyMaybe(this._treeDebugger); this._i3sOverrides=t.destroyMaybe(this._i3sOverrides);this._set("processor",t.destroyMaybe(this.processor));this._controller=t.destroyMaybe(this._controller);this._queryEngine=t.destroyMaybe(this._queryEngine);this._worker=t.destroyMaybe(this._worker);this._memCache=t.destroyMaybe(this._memCache);this.loadedGraphics.clear();this._fieldsHelper=t.destroyMaybe(this._fieldsHelper)}get i3slayer(){return this.layer}get updatingProgressValue(){return this._controller?.updatingProgress??1}get requiredFields(){return this._fieldsHelper?.requiredFields?? []}get maximumNumberOfFeatures(){return this.processor?.graphicsCore?.displayFeatureLimit?.maximumNumberOfFeatures??0}set maximumNumberOfFeatures(a){null!=a?(this._override("maximumNumberOfFeatures",a),this._controller.fixedFeatureTarget=!0):(this._clearOverride("maximumNumberOfFeatures"),this._controller.fixedFeatureTarget=!1)}get maximumNumberOfFeaturesExceeded(){return this.suspended?!1:!!this._controller?.useMaximumNumberOfFeatures&&!this._controller.leavesReached}get _excludeObjectIdsSorted(){const a= this.layer.excludeObjectIds;return a.length?a.toArray().sort((b,d)=>b-d):null}get lodFactor(){return"Labels"===this.layer.semantic?1:this.view.qualitySettings.sceneService.point.lodFactor}get hasM(){return!1}get hasZ(){return!0}get contentVisible(){return!this.suspended&&!!this._controller?.rootNodeVisible}get legendEnabled(){return this.contentVisible&&!0===this.i3slayer?.legendEnabled}async whenGraphicAttributes(a,b){return w.whenGraphicAttributes(this.layer,a,this._getObjectIdField(),b,()=>[...this.loadedGraphics.nodes()])}getHit(a){if(!this.loadedGraphics)return null; const b=Y.hydrateGraphic(this.loadedGraphics.find(c=>c.uid===a),this.layer),d=this._getObjectIdField();if(!b?.attributes?.[d])return null;b.layer=this.layer;b.sourceLayer=this.layer;return{type:"graphic",graphic:b,layer:b.layer}}whenGraphicBounds(a,b){return this.processor.whenGraphicBounds(a,b)}computeAttachmentOrigin(a,b){return this.processor.computeAttachmentOrigin(a,b)}isUpdating(){return!!(this._controller?.updating||this.processor?.updating||this._fieldsHelper?.updating||this.layerFilterUpdating)}highlight(a){return this.processor.highlight(a, this.layer.objectIdField)}get updatePolicy(){return this.processor.graphicsCore.effectiveUpdatePolicy}createInteractiveEditSession(a){return C.createInteractiveEditSession(this._attributeEditingContext,a)}async _decompressBinaryPointData(a,b){a={geometryBuffer:a.geometryBuffer};null==this._worker&&(this._worker=new L.I3SPointsWorkerHandle(d=>this.view.resourceController.immediate.schedule(d)));b=await this._worker.invoke(a,b);if(null==b)throw Error("Failed to decompress Draco point data");return{positionData:b.positions, featureIds:b.featureIds}}async addNode(a,b,d){if(!(E(b)||"pointData"in b))throw Error();if(this.loadedGraphics.hasNode(a.index))x.getLogger(this).error("I3S node "+a.id+" already added");else{if(null!=this.layer.fullExtent){var c=this.layer.fullExtent.clone();c.xmin-=.5;c.ymin-=.5;c.xmax+=.5;c.ymax+=.5;null!=c.zmin&&null!=c.zmax&&(c.zmin-=.5,c.zmax+=.5);null!=c.mmin&&null!=c.mmax&&(c.mmin-=.5,c.mmax+=.5)}else c=null;var e=c,{featureIds:f,pointPositions:m}=E(b)?await this._extractBinaryPointPositions(a, b,d):this._extractLegacyPointPositions(b);c=[];this._validatePositions(a,f,m,e,c);var k=this._controller.crsVertex;I.projectBuffer(m,k,0,m,this.view.spatialReference,0,f.length);e=E(b)?a.level:0;e=this._createGraphics(f,m,a.index,e);e=new ta(e,f,b.attributeDataInfo,a);await this._i3sOverrides.applyAttributeOverrides(e.featureIds,b.attributeDataInfo,d);a.numFeatures=e.graphics.length;this._updateNodeMemory(a);F(e);0n||3W.estimateSize(c)+d,Q.estimateSize(a.featureIds)+1024);this._memCache.put(this._getMemCacheKey(a.node),a,b)}_getMemCacheKey(a){return`${a.index}`}_removeAllNodeData(){this.loadedGraphics.forEachNode((a,b)=>{a&&(this._updateNodeMemory(a.node), this._cacheNodeData(a));this._controller.updateLoadStatus(b,!1)});this._treeDebugger&&this._treeDebugger.update();this.loadedGraphics.clear()}removeNode(a){if(a=this._removeNodeStageData(a))this._updateNodeMemory(a.node),this._cacheNodeData(a)}_removeNodeStageData(a){const b=this.loadedGraphics.getNode(a);if(null==b)return null;this._controller.updateLoadStatus(a,!1);this.loadedGraphics.removeNode(a);this._treeDebugger&&this._treeDebugger.update();return b}async loadCachedNodeData(a){return this._memCache?.pop(this._getMemCacheKey(a))}async addCachedNodeData(a, b,d,c){this.loadedGraphics.hasNode(a.index)?x.getLogger(this).error("I3S node "+a.id+" already added"):(await this._i3sOverrides.applyAttributeOverrides(b.featureIds,d,c),b.attributeInfo=d,this.loadedGraphics.addNode(a.index,b),this._controller.updateLoadStatus(a.index,!0),this._updateNodeMemory(a),F(b),this._filterNode(b),this._treeDebugger&&this._treeDebugger.update())}getLoadedNodeIds(){const a=[];this.loadedGraphics.forEachNode(b=>a.push(b.node.id));return a.sort()}getVisibleNodes(){const a=[]; this.loadedGraphics.forEachNode(b=>a.push(b.node));return a}getLoadedNodeIndices(a){this.loadedGraphics.forEachNode((b,d)=>a.push(d))}getLoadedAttributes(a){a=this.loadedGraphics.getNode(a);if(null!=a?.attributeInfo)return a.attributeInfo.loadedAttributes}getAttributeData(a){a=this.loadedGraphics.getNode(a);if(null!=a?.attributeInfo)return a.attributeInfo.attributeData}_setAttributeData(a,b){a=this.loadedGraphics.getNode(a);null!=a?.attributeInfo&&(a.attributeInfo.attributeData=b,this._attributeValuesChanged(a))}async updateAttributes(a, b,d){a=this.loadedGraphics.getNode(a);null!=a&&(await this._i3sOverrides.applyAttributeOverrides(a.featureIds,b,d),a.attributeInfo=b,this._attributeValuesChanged(a))}_attributeValuesChanged(a){F(a);this._filterNode(a);if(this.processor.graphicsCore.labelsEnabled){const b=a.node.index,d=[];a.graphics.forEach(c=>c.nodeIndex===b&&d.push(c.uid));this.processor.graphicsCore.updateLabelingInfo(d)}}_updateClippingExtent(a){this._controller&&this._controller.updateClippingArea(a);return!1}_getObjectIdField(){return this.layer.objectIdField|| V.fallbackObjectIDAttribute}_getGlobalIdField(){return this.layer.associatedLayer?.globalIdField}async _rendererChange(a,b){const {layer:{fieldsIndex:d}}=this,c=new Set;let e;a?(await a.collectRequiredFields(c,d),e=Array.from(c).sort()):e=[];c.clear();let f;b?(await b.collectRequiredFields(c,d),f=Array.from(c).sort()):f=[];e.length===f.length&&e.every((m,k)=>e[k]===f[k])||this._reloadAllNodes()}_rangeInfosChanged(a){null!=a&&0 this._filterNode(a))}_reloadAllNodes(){this._removeAllNodeData();this._controller&&this._controller.restartNodeLoading()}_filterNode(a){const b=this.parsedDefinitionExpression,d=this._excludeObjectIdsSorted,c=this._getObjectIdField();for(const e of a.graphics){a=e.visible;const f=!b||this._evaluateClause(b,e),m=null==d||0>P.binaryIndexOf(d,e.attributes[c]);e.visible=f&&m;a!==e.visible&&(r.graphic=e,r.property="visible",r.oldValue=a,r.newValue=e.visible,this.processor.graphicsCore.graphicUpdateHandler(r))}}createQuery(){const a= {outFields:["*"],returnGeometry:!0,outSpatialReference:this.view.spatialReference};return null!=this.filter?this.filter.createQuery(a):new K(a)}queryFeatures(a,b){return this._queryEngine.executeQuery(this._ensureQuery(a),b?.signal)}queryObjectIds(a,b){return this._queryEngine.executeQueryForIds(this._ensureQuery(a),b?.signal)}queryFeatureCount(a,b){return this._queryEngine.executeQueryForCount(this._ensureQuery(a),b?.signal)}queryExtent(a,b){return this._queryEngine.executeQueryForExtent(this._ensureQuery(a), b?.signal)}_ensureQuery(a){return this._addDefinitionExpressionToQuery(null==a?this.createQuery():K.from(a))}_setupQueryEngine(){const a=()=>this.processor.featureStore;this._queryEngine=new da.QueryEngine({context:{spatialReference:this.view.spatialReference,layer:this.layer,scheduler:this.view.resourceController.scheduler,get featureStore(){return a()},hasZ:this.hasZ,hasM:this.hasM},priority:sa.TaskPriority.FEATURE_QUERY_ENGINE})}get usedMemory(){return this.processor?.graphicsCore?.usedMemory?? 0}get unloadedMemory(){return.8*((this._controller?.unloadedMemoryEstimate??0)+(this.processor?.graphicsCore?.unprocessedMemoryEstimate??0))}get ignoresMemoryFactor(){return this._controller&&this._controller.fixedFeatureTarget}async _handleEdits(a){const b=this._attributeEditingContext;a=await C.normalizeEditResultsEvent(b,a);C.processAttributeEdits(b,a)}get _attributeEditingContext(){const a=this._getObjectIdField(),b=this._getGlobalIdField();return{sessions:this._interactiveEditingSessions,fieldsIndex:this.layer.fieldsIndex, objectIdField:a,globalIdField:b,forEachNode:d=>this.loadedGraphics.forEachNode(c=>d(c.node,c.featureIds)),attributeStorageInfo:this.i3slayer.attributeStorageInfo??[],i3sOverrides:this._i3sOverrides,getAttributeData:d=>this.getAttributeData(d),setAttributeData:(d,c,e)=>{this._setAttributeData(d,c);d=this.loadedGraphics.getNode(d);null!=e?(e=this.loadedGraphics.get(e.attributes[a]),null!=e&&this.processor.graphicsCore.recreateGraphics([e])):null!=d&&this.processor.graphicsCore.recreateGraphics(d.graphics)}, clearMemCache:()=>{}}}get performanceInfo(){return new ia.LayerViewPerformanceInfo(this.usedMemory,this.loadedGraphics.length,-1,this.maximumNumberOfFeatures,this.loadedGraphics.nodeCount,this.processor.graphicsCore.performanceInfo)}get test(){}};h.__decorate([l.property()],g.prototype,"processor",void 0);h.__decorate([l.property({type:aa})],g.prototype,"filter",void 0);h.__decorate([l.property()],g.prototype,"loadedGraphics",void 0);h.__decorate([l.property()],g.prototype,"i3slayer",null);h.__decorate([l.property()], g.prototype,"_controller",void 0);h.__decorate([l.property()],g.prototype,"updating",void 0);h.__decorate([l.property()],g.prototype,"suspended",void 0);h.__decorate([l.property()],g.prototype,"holeFilling",void 0);h.__decorate([l.property(na.updatingProgress)],g.prototype,"updatingProgress",void 0);h.__decorate([l.property()],g.prototype,"updatingProgressValue",null);h.__decorate([l.property(A.requiredFields)],g.prototype,"requiredFields",null);h.__decorate([l.property(A.availableFields)],g.prototype, "availableFields",void 0);h.__decorate([l.property()],g.prototype,"_fieldsHelper",void 0);h.__decorate([l.property({type:Number})],g.prototype,"maximumNumberOfFeatures",null);h.__decorate([l.property({readOnly:!0})],g.prototype,"maximumNumberOfFeaturesExceeded",null);h.__decorate([l.property()],g.prototype,"_excludeObjectIdsSorted",null);h.__decorate([l.property({readOnly:!0})],g.prototype,"lodFactor",null);h.__decorate([l.property({readOnly:!0})],g.prototype,"hasM",null);h.__decorate([l.property({readOnly:!0})], g.prototype,"hasZ",null);h.__decorate([l.property()],g.prototype,"contentVisible",null);h.__decorate([l.property({readOnly:!0})],g.prototype,"legendEnabled",null);h=g=h.__decorate([R.subclass("esri.views.3d.layers.SceneLayerGraphicsView3D")],g);const ua={2:{type:"Embedded",params:{type:"points",vertexAttributes:{position:[0,0]}}},3:{type:"Embedded",params:{type:"points",vertexAttributes:{position:[0,0,0]}}}},u=H.create(),r={graphic:null,property:null,oldValue:null,newValue:null};return h});