/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["../../../chunks/_rollupPluginBabelHelpers","../../../chunks/tslib.es6","../../../PopupTemplate","../../../core/Collection","../../../core/reactiveUtils","../../../core/Logger","../../../core/accessorSupport/ensureType","../../../core/arrayUtils","../../../core/has","../../../core/accessorSupport/set","../../../core/accessorSupport/decorators/subclass","../../../renderers/SimpleRenderer","../../../renderers/support/jsonUtils","../../../rest/support/FeatureSet","./LayerView2D","./graphics/GraphicContainer","./graphics/GraphicsView2D","../../layers/LayerView"],(function(e,r,i,t,s,o,a,n,l,p,c,h,u,y,g,w,f,m){"use strict";let d=function(r){function o(){var e;return(e=r.apply(this,arguments)||this)._graphicsViewMap={},e._popupTemplates=new Map,e.graphicsViews=[],e}e._inheritsLoose(o,r);var a=o.prototype;return a.hitTest=function(){var r=e._asyncToGenerator((function*(e,r){if(!this.graphicsViews.length)return null;const i=this.layer;return this.graphicsViews.reverse().map((r=>{const t=this._popupTemplates.get(r),s=r.hitTest(e);for(const e of s)e.layer=i,e.sourceLayer=i,e.popupTemplate=t;return s})).flat().map((r=>({type:"graphic",graphic:r,layer:i,mapPoint:e})))}));function i(e,i){return r.apply(this,arguments)}return i}(),a.update=function(e){if(this.graphicsViews)for(const r of this.graphicsViews)r.processUpdate(e)},a.attach=function(){this.handles.add([s.watch((()=>{var e;return null==(e=this.layer)?void 0:e.featureCollections}),(e=>{this._clear();for(const{popupInfo:r,featureSet:s,layerDefinition:o}of e){const e=y.fromJSON(s),a=new t(e.features),n=o.drawingInfo,l=r?i.fromJSON(r):null,p=u.fromJSON(n.renderer),c=new f({requestUpdateCallback:()=>this.requestUpdate(),view:this.view,graphics:a,renderer:p,container:new w(this.view.featuresTilingScheme)});this._graphicsViewMap[e.geometryType]=c,this._popupTemplates.set(c,l),"polygon"!==e.geometryType||this.layer.polygonSymbol?"polyline"!==e.geometryType||this.layer.lineSymbol?"point"!==e.geometryType||this.layer.pointSymbol||(this.layer.pointSymbol=p.symbol):this.layer.lineSymbol=p.symbol:this.layer.polygonSymbol=p.symbol,this.graphicsViews.push(c),this.container.addChild(c.container)}}),s.initial),s.watch((()=>{var e;return null==(e=this.layer)?void 0:e.polygonSymbol}),(e=>{this._graphicsViewMap.polygon.renderer=new h({symbol:e})}),s.initial),s.watch((()=>{var e;return null==(e=this.layer)?void 0:e.lineSymbol}),(e=>{this._graphicsViewMap.polyline.renderer=new h({symbol:e})}),s.initial),s.watch((()=>{var e;return null==(e=this.layer)?void 0:e.pointSymbol}),(e=>{this._graphicsViewMap.point.renderer=new h({symbol:e})}),s.initial)],"georsslayerview")},a.detach=function(){this.handles.remove("georsslayerview"),this._clear()},a.moveStart=function(){},a.moveEnd=function(){},a.viewChange=function(){for(const e of this.graphicsViews)e.viewChange()},a._clear=function(){this.container.removeAllChildren();for(const e of this.graphicsViews)e.destroy();this._graphicsViewMap={},this._popupTemplates.clear(),this.graphicsViews.length=0},o}(g.LayerView2DMixin(m));d=r.__decorate([c.subclass("esri.views.2d.layers.GeoRSSLayerView2D")],d);return d}));
