/*
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 t from"../../core/Collection.js";import{IdentifiableMixin as r}from"../../core/Identifiable.js";import{MultiOriginJSONSupport as s}from"../../core/MultiOriginJSONSupport.js";import{on as i,watch as l,sync as o}from"../../core/reactiveUtils.js";import{property as n,cast as a,subclass as p}from"../../core/accessorSupport/decorators.js";import{ensureType as y}from"../../core/accessorSupport/ensureType.js";import d from"../../geometry/Extent.js";import{reader as u}from"../../core/accessorSupport/decorators/reader.js";var h;let c=0,m=h=class extends(r(s)){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([i(()=>this.sublayers,"after-add",({item:e})=>{e.parent=this,e.layer=this.layer},o),i(()=>this.sublayers,"after-remove",({item:e})=>{e.layer=e.parent=null},o),l(()=>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),l(()=>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??c++}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 y(t.ofType(h),e)}set visible(e){this._setAndNotifyLayer("visible",e)}clone(){const e=new h;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([n()],m.prototype,"description",void 0),e([n({readOnly:!0})],m.prototype,"dimensions",void 0),e([n({type:d,json:{name:"extent"}})],m.prototype,"fullExtent",void 0),e([n()],m.prototype,"fullExtents",void 0),e([n({type:Number,json:{write:{enabled:!1,overridePolicy:()=>({ignoreOrigin:!0,enabled:!0})}}})],m.prototype,"id",null),e([n({type:String,json:{name:"legendUrl",write:{ignoreOrigin:!0}}})],m.prototype,"legendUrl",void 0),e([u("legendUrl",["legendUrl","legendURL"])],m.prototype,"readLegendUrl",null),e([n({type:Boolean,json:{name:"showLegend",origins:{"web-map":{read:!1,write:!1},"web-scene":{read:!1,write:!1}}}})],m.prototype,"legendEnabled",void 0),e([n()],m.prototype,"layer",void 0),e([n()],m.prototype,"maxScale",void 0),e([n()],m.prototype,"minScale",void 0),e([n({readOnly:!0})],m.prototype,"effectiveScaleRange",null),e([n({type:String,json:{write:{ignoreOrigin:!0}}})],m.prototype,"name",void 0),e([n()],m.prototype,"parent",void 0),e([n({type:Boolean,json:{read:{source:"showPopup"},write:{ignoreOrigin:!0,target:"showPopup"}}})],m.prototype,"popupEnabled",void 0),e([n({type:Boolean,json:{write:{ignoreOrigin:!0}}})],m.prototype,"queryable",void 0),e([n()],m.prototype,"sublayers",null),e([a("sublayers")],m.prototype,"castSublayers",null),e([n({type:[Number],json:{read:{source:"spatialReferences"}}})],m.prototype,"spatialReferences",void 0),e([n({type:String,json:{write:{ignoreOrigin:!0}}})],m.prototype,"title",void 0),e([n({type:Boolean,value:!0,json:{read:{source:"defaultVisibility"}}})],m.prototype,"visible",null),m=h=e([p("esri.layers.support.WMSSublayer")],m);export{m as default};
