/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../../chunks/_rollupPluginBabelHelpers","../../../chunks/tslib.es6","../../../core/Error","../../../core/maybe","../../../core/reactiveUtils","../../../core/accessorSupport/decorators/property","../../../core/arrayUtils","../../../core/has","../../../core/accessorSupport/ensureType","../../../core/accessorSupport/decorators/subclass","../support/updatingProperties","../terrain/terrainUtils"],(function(e,t,r,i,n,a,o,l,s,c,p,u,h){"use strict";const d=e=>{let l=function(e){function r(){return e.apply(this,arguments)||this}t._inheritsLoose(r,e);var o=r.prototype;return o.getTileUrl=function(e,t,r){return this.layer.getTileUrl(e,t,r)},o._addTilingSchemeMatchPromise=function(){if(n.isNone(this.fullExtent))return this.addResolvingPromise(Promise.reject(new i("tilingscheme:extent-not-defined","This layer doesn't define a fullExtent.")));const e=this._getTileInfoSupportError(this.tileInfo,this.fullExtent);if(n.isSome(e))return this.addResolvingPromise(Promise.reject(e));const t=a.whenOnce((()=>{var e,t;return null==(e=this.view)||null==(t=e.basemapTerrain)?void 0:t.tilingSchemeLocked})).then((()=>{const e=this.view.basemapTerrain.tilingScheme,t=this._getTileInfoCompatibilityError(this.tileInfo,e);if(t)throw t}));this.addResolvingPromise(t)},o._getTileInfoSupportError=function(e,t){const r=h.checkIfTileInfoSupportedForView(e,t,this.view.spatialReference,this.view.state.viewingMode);if(r){const e={layer:this.layer,error:r};let t;switch(r.name){case"tilingscheme:spatial-reference-mismatch":case"tilingscheme:global-unsupported-spatial-reference":case"tilingscheme:local-unsupported-spatial-reference":t=new i("layerview:spatial-reference-incompatible","The spatial reference of this layer does not meet the requirements of the view",e);break;default:t=new i("layerview:tiling-scheme-unsupported","The tiling scheme of this layer is not supported by SceneView",e)}return t}return null},o._getTileInfoCompatibilityError=function(e,t){return t.compatibleWith(e)?null:new i("layerview:tiling-scheme-incompatible","The tiling scheme of this layer is incompatible with the tiling scheme of the surface")},o.levelRangeFromScaleRange=function(e,t){const r={minLevel:0,maxLevel:1/0},i=this.view&&this.view.basemapTerrain&&this.view.basemapTerrain.tilingScheme;if(!i)return r;const n=i.levels[0],a=e=>{const t=Math.log(n.scale/e)/Math.LN2;return.5-Math.abs(.5-t%1)<1e-9?Math.round(t):Math.ceil(t)};return null!=e&&e>0&&(r.minLevel=Math.max(0,a(e))),null!=t&&t>0&&(r.maxLevel=Math.max(0,a(t))),r},o.isUpdating=function(){return!!(this.view&&this.view.basemapTerrain&&this.view.basemapTerrain.updating)},t._createClass(r,[{key:"imageFormatIsOpaque",get:function(){return!1}},{key:"fullExtent",get:function(){return this.layer.fullExtent}},{key:"isOpaque",get:function(){return this.fullOpacity>=1&&this.imageFormatIsOpaque}},{key:"dataLevelRange",get:function(){const e=this.tileInfo.lods,t=e[0].scale,r=e[e.length-1].scale;return this.levelRangeFromScaleRange(t,r)}},{key:"displayLevelRange",get:function(){const e=this.tileInfo.lods,t=this.layer.minScale||e[0].scale,r=this.layer.maxScale||e[e.length-1].scale,i=this.levelRangeFromScaleRange(t,r);return this.layer.maxScale&&i.maxLevel++,i}}]),r}(e);return r.__decorate([o.property({readOnly:!0})],l.prototype,"imageFormatIsOpaque",null),r.__decorate([o.property({readOnly:!0})],l.prototype,"updating",void 0),r.__decorate([o.property(u.updatingProgress)],l.prototype,"updatingProgress",void 0),r.__decorate([o.property(u.updatingProgressValue)],l.prototype,"updatingProgressValue",void 0),r.__decorate([o.property()],l.prototype,"fullExtent",null),r.__decorate([o.property({readOnly:!0})],l.prototype,"isOpaque",null),r.__decorate([o.property({readOnly:!0})],l.prototype,"dataLevelRange",null),r.__decorate([o.property({readOnly:!0})],l.prototype,"displayLevelRange",null),r.__decorate([o.property()],l.prototype,"layer",void 0),r.__decorate([o.property()],l.prototype,"tileInfo",void 0),l=r.__decorate([p.subclass("esri.views.3d.layers.TiledLayerView3D")],l),l};e.TiledLayerView3D=d,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
