/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
class e{constructor(e,t){this._symbol=null,this._featureData=new Map,this._loaded=!1,this._loadingPromise=null,this._renderer=null,this._context=t,this._renderer=e}async load(){return null==this._loadingPromise&&(this._loadingPromise=this._load()),this._loadingPromise}async _load(){const{_renderer:e,_context:t}=this;this._symbol=t.symbolRendererFactory.createSymbolRendererFromSymbol(e.symbol),this._loaded=!0}get loaded(){return this._loaded}async createAddCommand(e){const t=this._context,a=await this._provisionSymbol(),n=null==a?t.createPipelineCommand():await a.createAddCommand(e);return n.appendPipelineStateCommand(()=>this._featureData.set(e.id,e)),n}async createRemoveCommand(e){const t=this._context,a=await this._provisionSymbol(),n=null==a?t.createPipelineCommand():await a.createRemoveCommand(e);return n.appendPipelineStateCommand(()=>this._featureData.delete(e)),n}async createUpdateVisibilityCommand(e){const t=this._context,a=await this._provisionSymbol();return null==a?t.createPipelineCommand():await a.createUpdateVisibilityCommand(e)}async createUpdateLayerViewOpacityCommand(e){const t=this._context,a=await this._provisionSymbol();return null==a?t.createPipelineCommand():await a.createUpdateLayerViewOpacityCommand(e)}async createUpdateElevationCommand(){const{_featureData:e,_context:t}=this,a=await this._provisionSymbol();if(null==a)return t.createPipelineCommand();const n=[];for(const i of e.values())n.push(a.createUpdateElevationCommand(i));const o=await Promise.all(n);return t.joinPipelineCommands(o)}async createDestroyCommand(){const{_symbol:e,_context:t,_featureData:a}=this;if(!e)return t.createPipelineCommand();const n=[];for(const i of a.keys())n.push(this.createRemoveCommand(i));n.push(e.createDestroyCommand());const o=await Promise.all(n);return t.joinPipelineCommands(o)}async _provisionSymbol(){const e=this._symbol;return e?(e.loaded||await e.load(),e):null}}export{e as SimpleFeatureRenderer};
