/*
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","./geometry","./PopupTemplate","./symbols","./core/Clonable","./core/JSONSupport","./core/maybe","./core/uid","./core/accessorSupport/decorators/property","./core/arrayUtils","./core/has","./core/accessorSupport/ensureType","./core/accessorSupport/decorators/subclass","./geometry/support/jsonUtils"],(function(e,t,r,o,s,i,n,a,p,u,l,y,c,g,h){"use strict";function m(e){if(!e)return null;const t={};for(const r in e){const o=h.fromJSON(e[r]);o&&(t[r]=o)}return 0!==Object.keys(t).length?t:null}function f(e){if(!a.isSome(e))return null;const t={};for(const r in e){const o=e[r];o&&(t[r]=o.toJSON())}return 0!==Object.keys(t).length?t:null}let b=function(t){function r(...r){var o;return(o=t.call(this,...r)||this).isAggregate=!1,o.layer=null,o.popupTemplate=null,o.sourceLayer=null,Object.defineProperty(e._assertThisInitialized(o),"uid",{value:p.generateUID(),configurable:!0}),o}e._inheritsLoose(r,t);var o=r.prototype;return o.normalizeCtorArgs=function(e,t,r,o){return e&&!e.declaredClass?e:{geometry:e,symbol:t,attributes:r,popupTemplate:o}},o.getEffectivePopupTemplate=function(e=!1){if(this.popupTemplate)return this.popupTemplate;for(const t of[this.sourceLayer,this.layer])if(t){if("popupTemplate"in t&&t.popupTemplate)return t.popupTemplate;if(e&&"defaultPopupTemplate"in t&&a.isSome(t.defaultPopupTemplate))return t.defaultPopupTemplate}return null},o.getAttribute=function(e){return this.attributes&&this.attributes[e]},o.setAttribute=function(e,t){if(this.attributes){const r=this.getAttribute(e);this.attributes[e]=t,this._notifyLayer("attributes",r,t,e)}else this.attributes={[e]:t},this._notifyLayer("attributes",void 0,t,e)},o.getObjectId=function(){return this.sourceLayer&&"objectIdField"in this.sourceLayer&&this.sourceLayer.objectIdField?this.getAttribute(this.sourceLayer.objectIdField):null},o.toJSON=function(){return{aggregateGeometries:f(this.aggregateGeometries),geometry:a.isSome(this.geometry)?this.geometry.toJSON():null,symbol:a.isSome(this.symbol)?this.symbol.toJSON():null,attributes:{...this.attributes},popupTemplate:this.popupTemplate&&this.popupTemplate.toJSON()}},o.notifyGeometryChanged=function(){this._notifyLayer("geometry",this.geometry,this.geometry)},o.notifyMeshTransformChanged=function(){a.isSome(this.geometry)&&"mesh"===this.geometry.type&&this._notifyLayer("transform",this.geometry.transform,this.geometry.transform)},o._notifyLayer=function(e,t,r,o){if(!this.layer||!("graphicChanged"in this.layer))return;const s={graphic:this,property:e,oldValue:t,newValue:r};"attributes"===e&&(s.attributeName=o),this.layer.graphicChanged(s)},e._createClass(r,[{key:"aggregateGeometries",set:function(e){const t=this._get("aggregateGeometries");JSON.stringify(t)!==JSON.stringify(e)&&this._set("aggregateGeometries",e)}},{key:"attributes",set:function(e){const t=this._get("attributes");t!==e&&(this._set("attributes",e),this._notifyLayer("attributes",t,e))}},{key:"geometry",set:function(e){const t=this._get("geometry");t!==e&&(this._set("geometry",e),this._notifyLayer("geometry",t,e))}},{key:"symbol",set:function(e){const t=this._get("symbol");t!==e&&(this._set("symbol",e),this._notifyLayer("symbol",t,e))}},{key:"visible",set:function(e){const t=this._get("visible");t!==e&&(this._set("visible",e),this._notifyLayer("visible",t,e))}}]),r}(i.ClonableMixin(n.JSONSupport));t.__decorate([u.property({value:null,json:{read:m}})],b.prototype,"aggregateGeometries",null),t.__decorate([u.property({value:null})],b.prototype,"attributes",null),t.__decorate([u.property({value:null,types:r.geometryTypes,json:{read:h.fromJSON}})],b.prototype,"geometry",null),t.__decorate([u.property({type:Boolean})],b.prototype,"isAggregate",void 0),t.__decorate([u.property({clonable:"reference"})],b.prototype,"layer",void 0),t.__decorate([u.property({type:o})],b.prototype,"popupTemplate",void 0),t.__decorate([u.property({clonable:"reference"})],b.prototype,"sourceLayer",void 0),t.__decorate([u.property({value:null,types:s.symbolTypes})],b.prototype,"symbol",null),t.__decorate([u.property({type:Boolean,value:!0})],b.prototype,"visible",null),b=t.__decorate([g.subclass("esri.Graphic")],b),function(e){e.generateUID=p.generateUID}(b||(b={}));return b}));
