/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import{__decorate as e}from"tslib";import n from"../../core/Accessor.js";import{property as t,subclass as a}from"../../core/accessorSupport/decorators.js";var i;const l=147914382,c=[{id:"room",minScale:100},{id:"rooms",minScale:400},{id:"smallBuilding",minScale:800},{id:"building",minScale:1999},{id:"buildings",minScale:3999},{id:"street",minScale:7499},{id:"streets",minScale:14999},{id:"neighborhood",minScale:29999},{id:"town",minScale:59999},{id:"city",minScale:119999},{id:"cities",minScale:249999},{id:"metropolitanArea",minScale:499999},{id:"county",minScale:999999},{id:"counties",minScale:1999999},{id:"stateProvince",minScale:3999999},{id:"statesProvinces",minScale:6999999},{id:"countriesSmall",minScale:14999999},{id:"countriesBig",minScale:34999999},{id:"continent",minScale:99999999},{id:"world",minScale:l}];function r(e,n){const t=c,a=t.length,i=[];let l,r=e;e=e>=0?e:0,n=n>0?n:t[a-1].minScale;for(let c=0;c<a;c++){const a=Math.min(t[c].minScale,n);l=Math.min(a,n),e<=a&&r<n&&i.push({id:t[c].id,maxScale:Math.max(r,e),minScale:l}),r=l+1}return i.reverse(),s(i)}function s(e){if(0===e.length)return e;const[n]=e,t=e[e.length-1];return n.minScale===n.maxScale&&(e.shift(),n.minScale+=1),t.minScale===t.maxScale&&(e.pop(),t.maxScale-=1),e}let o=class extends n{static{i=this}constructor(e){super(e),this.ranges=[]}static{this.RecommendedScales=Object.freeze({world:l,continent:5e7,countriesBig:25e6,countriesSmall:12e6,statesProvinces:6e6,stateProvince:3e6,counties:15e5,county:75e4,metropolitanArea:32e4,cities:16e4,city:8e4,town:4e4,neighborhood:2e4,streets:1e4,street:5e3,buildings:2500,building:1250,smallBuilding:800,rooms:400,room:100})}static fromScaleRange({maxScale:e,minScale:n}){return new i({ranges:r(e,n)})}static async fromLayer(e){await e.when();const n="tileInfo"in e?e.tileInfo?.lods:void 0;let t;if(n){t=r(n[n.length-1].scale,n[0].scale)}else t=r(0,0);return new i({ranges:t})}get firstRange(){return this.ranges[0]}get lastRange(){const e=this.ranges;return e[e.length-1]}get length(){return this.ranges.length}get maxScale(){return this.lastRange.maxScale}get minScale(){return this.firstRange.minScale}isMinScaleEdge(e){const{firstRange:n}=this,t=n.minScale,a=i.RecommendedScales[n.id]||n.maxScale;return e<=t&&e>=a}isMaxScaleEdge(e){const{lastRange:n}=this,t=n.maxScale;return e<=(i.RecommendedScales[n.id]||n.minScale)&&e>=t}findScaleRange(e){const n=this.ranges;let t;if(e>=n[0].maxScale)return n[0];if(e<=n[n.length-1].minScale)return n[n.length-1];for(let a=0;a<n.length;a++){const i=n[a];if(e>=i.maxScale&&e<=i.minScale){t=i;break}}return t}findScaleRangeByIndex(e){return this.ranges[this._clampScaleRangeIndex(e)]}scaleToRangeIndex(e){return this.ranges.indexOf(this.findScaleRange(e))}clampScale(e){return Math.min(this.minScale,Math.max(this.maxScale,e))}clampMinScale(e){return 0===e?this.minScale:this.clampScale(e)}clampMaxScale(e){return this.clampScale(e)}contains(e){const n=this.ranges;let t=!1;for(let a=0;a<n.length;a++){const{maxScale:i,minScale:l}=n[a];if(e>=i&&e<=l){t=!0;break}}return t}_clampScaleRangeIndex(e){const n=0;if(e<=n)return n;const t=this.ranges.length-1;return e>t?t:Math.floor(e)}};e([t()],o.prototype,"firstRange",null),e([t()],o.prototype,"lastRange",null),e([t()],o.prototype,"length",null),e([t()],o.prototype,"maxScale",null),e([t()],o.prototype,"minScale",null),e([t({constructOnly:!0})],o.prototype,"ranges",void 0),o=i=e([a("esri.widgets.ScaleRangeSlider.ScaleRanges")],o);const m=o;export{m as default};
