/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import{__decorate as t}from"tslib";import e from"../../../../core/Accessor.js";import{watch as i}from"../../../../core/reactiveUtils.js";import{property as o,subclass as a}from"../../../../core/accessorSupport/decorators.js";import s from"./createFlowStyle.js";import r from"./FlowContainer.js";import n from"./FlowStrategy.js";import{readFromFlowData as l}from"../../../support/rasterHitTestUtils.js";import{loadImagery as d}from"../../../support/flow/dataUtils.js";let h=class extends e{constructor(){super(...arguments),this._loadImagery=(t,e,i,o,a)=>d(this.layer,t,e,i,o,a),this._createFlowMesh=(t,e,i,o,a)=>this.layer.createFlowMesh({meshType:t,flowData:i,simulationSettings:e,startInfo:o},{signal:a}),this.attached=!1,this.type="flow",this.timeExtent=null,this.redrawOrRefetch=async()=>{this._updateVisualization()}}get updating(){return!this.attached||this._strategy.updating}attach(){const{layer:t}=this,e=()=>{this._loadImagery=(e,i,o,a,s)=>d(t,e,i,o,a,s),this._updateVisualization()};"multidimensionalDefinition"in t?this.addHandles(i(()=>t.multidimensionalDefinition,e)):this.addHandles([i(()=>t.mosaicRule,e),i(()=>t.rasterFunction,e),i(()=>t.definitionExpression,e)]),this.addHandles(i(()=>this.layerView.view.animationsEnabled,()=>this.layerView.requestUpdate())),this.container=new r,this._strategy=new n({flowContainer:this.container}),this._updateVisualization()}detach(){this._strategy.destroy(),this.container?.removeAllChildren(),this.container=null,this.removeHandles()}update(t){t.stationary?this._strategy.update(t,this.layerView.view.animationsEnabled):this.layerView.requestUpdate()}hitTest(t){const e=this.container?.getFlowResources(t,!0);if(!e?.flowData)return null;const{flowData:i,query:{extent:o}}=e;return l({mapPoint:t,layer:this.layer,sourceData:{flowData:i,extent:o}})}moveEnd(){}async doRefresh(){}_updateVisualization(){const t=this.layer.renderer;if(null==t||"flow"!==t.type)return;const e=s(t,{loadImagery:this._loadImagery,createFlowMesh:this._createFlowMesh,timeExtent:this.timeExtent});this.container.flowStyle=e,this.layerView.requestUpdate()}};t([o()],h.prototype,"_strategy",void 0),t([o()],h.prototype,"attached",void 0),t([o()],h.prototype,"container",void 0),t([o()],h.prototype,"layer",void 0),t([o()],h.prototype,"layerView",void 0),t([o()],h.prototype,"scheduler",void 0),t([o()],h.prototype,"type",void 0),t([o()],h.prototype,"updating",null),t([o()],h.prototype,"timeExtent",void 0),h=t([a("esri.views.2d.engine.flow.FlowView2D")],h);export{h as default};
