/* COPYRIGHT Esri - https://js.arcgis.com/5.0.18/LICENSE.txt */
import{__decorate as e}from"tslib";import t from"../../core/Accessor.js";import r from"../../core/Collection.js";import{IdentifiableMixin as s}from"../../core/Identifiable.js";import{MultiOriginJSONSupportMixin as i}from"../../core/MultiOriginJSONSupport.js";import{on as l,sync as o,watch as n}from"../../core/reactiveUtils.js";import{property as a,cast as p,subclass as y}from"../../core/accessorSupport/decorators.js";import{ensureType as d}from"../../core/accessorSupport/ensureType.js";import u from"../../geometry/Extent.js";import{reader as h}from"../../core/accessorSupport/decorators/reader.js";var c;let m=0,f=c=class extends(s(i(t))){constructor(e){super(e),this.description=null,this.dimensions=null,this.fullExtent=null,this.fullExtents=null,this.legendUrl=null,this.legendEnabled=!0,this.layer=null,this.maxScale=0,this.minScale=0,this.name=null,this.parent=null,this.popupEnabled=!1,this.queryable=!1,this.spatialReferences=null,this.title=null,this.addHandles([l(()=>this.sublayers,"after-add",({item:e})=>{e.parent=this,e.layer=this.layer},o),l(()=>this.sublayers,"after-remove",({item:e})=>{e.layer=e.parent=null},o),n(()=>this.sublayers,(e,t)=>{if(t)for(const r of t)r.layer=r.parent=null;if(e)for(const r of e)r.parent=this,r.layer=this.layer},o),n(()=>this.layer,e=>{if(this.sublayers)for(const t of this.sublayers)t.layer=e},o)])}get id(){const e=this._get("id");return e??m++}set id(e){this._set("id",e)}readLegendUrl(e,t){return t.legendUrl??t.legendURL??null}get effectiveScaleRange(){const{minScale:e,maxScale:t}=this;return{minScale:e,maxScale:t}}get sublayers(){return this._get("sublayers")}set sublayers(e){this._set("sublayers",e)}castSublayers(e){return d(r.ofType(c),e)}set visible(e){this._setAndNotifyLayer("visible",e)}clone(){const e=new c;return this.hasOwnProperty("description")&&(e.description=this.description),this.hasOwnProperty("fullExtent")&&(e.fullExtent=this.fullExtent.clone()),this.hasOwnProperty("fullExtents")&&(e.fullExtents=this.fullExtents?.map(e=>e.clone())??null),this.hasOwnProperty("legendUrl")&&(e.legendUrl=this.legendUrl),this.hasOwnProperty("legendEnabled")&&(e.legendEnabled=this.legendEnabled),this.hasOwnProperty("layer")&&(e.layer=this.layer),this.hasOwnProperty("name")&&(e.name=this.name),this.hasOwnProperty("parent")&&(e.parent=this.parent),this.hasOwnProperty("queryable")&&(e.queryable=this.queryable),this.hasOwnProperty("sublayers")&&(e.sublayers=this.sublayers?.map(e=>e.clone())),this.hasOwnProperty("spatialReferences")&&(e.spatialReferences=this.spatialReferences?.map(e=>e)),this.hasOwnProperty("visible")&&(e.visible=this.visible),this.hasOwnProperty("title")&&(e.title=this.title),e}_setAndNotifyLayer(e,t){const r=this.layer;this._get(e)!==t&&(this._set(e,t),r&&r.emit("wms-sublayer-update",{propertyName:e,id:this.id}))}};e([a()],f.prototype,"description",void 0),e([a({readOnly:!0})],f.prototype,"dimensions",void 0),e([a({type:u,json:{name:"extent"}})],f.prototype,"fullExtent",void 0),e([a()],f.prototype,"fullExtents",void 0),e([a({type:Number,json:{write:{enabled:!1,overridePolicy:()=>({ignoreOrigin:!0,enabled:!0})}}})],f.prototype,"id",null),e([a({type:String,json:{name:"legendUrl",write:{ignoreOrigin:!0}}})],f.prototype,"legendUrl",void 0),e([h("legendUrl",["legendUrl","legendURL"])],f.prototype,"readLegendUrl",null),e([a({type:Boolean,json:{name:"showLegend",origins:{"web-map":{read:!1,write:!1},"web-scene":{read:!1,write:!1}}}})],f.prototype,"legendEnabled",void 0),e([a()],f.prototype,"layer",void 0),e([a()],f.prototype,"maxScale",void 0),e([a()],f.prototype,"minScale",void 0),e([a({readOnly:!0})],f.prototype,"effectiveScaleRange",null),e([a({type:String,json:{write:{ignoreOrigin:!0}}})],f.prototype,"name",void 0),e([a()],f.prototype,"parent",void 0),e([a({type:Boolean,json:{read:{source:"showPopup"},write:{ignoreOrigin:!0,target:"showPopup"}}})],f.prototype,"popupEnabled",void 0),e([a({type:Boolean,json:{write:{ignoreOrigin:!0}}})],f.prototype,"queryable",void 0),e([a()],f.prototype,"sublayers",null),e([p("sublayers")],f.prototype,"castSublayers",null),e([a({type:[Number],json:{read:{source:"spatialReferences"}}})],f.prototype,"spatialReferences",void 0),e([a({type:String,json:{write:{ignoreOrigin:!0}}})],f.prototype,"title",void 0),e([a({type:Boolean,value:!0,json:{read:{source:"defaultVisibility"}}})],f.prototype,"visible",null),f=c=e([y("esri.layers.support.WMSSublayer")],f);export{f as default};
