/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import{__decorate as e}from"tslib";import r from"../../../PopupTemplate.js";import i from"../../../core/Collection.js";import{watch as s,initial as t}from"../../../core/reactiveUtils.js";import{subclass as o}from"../../../core/accessorSupport/decorators.js";import a from"../../../graphic/GeoRSSGraphicOrigin.js";import p from"../../../renderers/SimpleRenderer.js";import{fromJSON as l}from"../../../renderers/support/jsonUtils.js";import n from"../../../rest/support/FeatureSet.js";import{LayerView2DMixin as h}from"./LayerView2D.js";import c from"./graphics/GraphicContainer.js";import m from"./graphics/GraphicsView2D.js";import y from"../../layers/LayerView.js";let g=class extends(h(y)){constructor(){super(...arguments),this._graphicsViewMap={},this.graphicsViews=[]}async hitTest(e,r){if(!this.graphicsViews.length)return null;const i=this.layer;return this.graphicsViews.reverse().flatMap(r=>r.hitTest(e)).map(r=>({type:"graphic",graphic:r,layer:i,mapPoint:e}))}update(e){if(this.graphicsViews)for(const r of this.graphicsViews)r.processUpdate(e)}attach(){this.addAttachHandles([s(()=>this.layer?.featureCollections,e=>{this._clear();const{layer:s}=this,t=new a(this.layer);for(const{popupInfo:o,featureSet:a,layerDefinition:p}of e){const e=n.fromJSON(a),h=new i(e.features),y=o?r.fromJSON(o):null;h.forEach(e=>{e.layer=s,e.sourceLayer=s,e.popupTemplate=y,e.origin=t});const g=p.drawingInfo,f=l(g.renderer),w=new m({requestUpdateCallback:()=>this.requestUpdate(),view:this.view,graphics:h,renderer:f,container:new c(this.view.featuresTilingScheme)});this._graphicsViewMap[e.geometryType]=w,"polygon"!==e.geometryType||this.layer.polygonSymbol?"polyline"!==e.geometryType||this.layer.lineSymbol?"point"!==e.geometryType||this.layer.pointSymbol||(this.layer.pointSymbol=f.symbol):this.layer.lineSymbol=f.symbol:this.layer.polygonSymbol=f.symbol,this.graphicsViews.push(w),this.container.addChild(w.container)}},t),s(()=>this.layer?.polygonSymbol,e=>{this._graphicsViewMap.polygon.renderer=new p({symbol:e})},t),s(()=>this.layer?.lineSymbol,e=>{this._graphicsViewMap.polyline.renderer=new p({symbol:e})},t),s(()=>this.layer?.pointSymbol,e=>{this._graphicsViewMap.point.renderer=new p({symbol:e})},t)])}detach(){this._clear()}moveEnd(){}viewChange(){for(const e of this.graphicsViews)e.viewChange()}_clear(){this.container.removeAllChildren();for(const e of this.graphicsViews)e.destroy();this._graphicsViewMap={},this.graphicsViews.length=0}};g=e([o("esri.views.2d.layers.GeoRSSLayerView2D")],g);const f=g;export{f as default};
