/*
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/Accessor","../../../../../../core/maybe","../../../../../../core/reactiveUtils","../../../../../../core/accessorSupport/decorators/property","../../../../../../core/arrayUtils","../../../../../../core/has","../../../../../../core/accessorSupport/ensureType","../../../../../../core/accessorSupport/decorators/subclass","../../../../../interactive/snapping/featureSources/featureServiceSource/tileUtils","../../../../../support/layerViewUtils"],(function(e,t,r,i,o,s,l,n,c,a,u,p,v){"use strict";e.FeatureServiceTiles2D=function(e){function r(t){var r;return(r=e.call(this,t)||this).pointOfInterest=null,r}t._inheritsLoose(r,e);var i=r.prototype;return i._scaleEnabled=function(){return v.scaleBoundsPredicate(this.view.scale,this.layer.minScale||0,this.layer.maxScale||0)},i.initialize=function(){this.own(s.watch((()=>{var e,t;return null==(e=this.view)||null==(t=e.state)?void 0:t.viewpoint}),(()=>this.notifyChange("tilesCoveringView")),s.sync))},t._createClass(r,[{key:"tiles",get:function(){const e=this.tilesCoveringView,t=o.isSome(this.pointOfInterest)?this.pointOfInterest:this.view.center;return e.sort(((e,r)=>p.distanceToTile(t,e)-p.distanceToTile(t,r))),e}},{key:"tilesCoveringView",get:function(){if(!this.view.ready||!this.view.featuresTilingScheme||!this.view.state||o.isNone(this.tileInfo))return[];if(!this._scaleEnabled)return[];const{spans:e,lodInfo:t}=this.view.featuresTilingScheme.getTileCoverage(this.view.state,0),{level:r}=t,i=[];for(const{row:o,colFrom:s,colTo:l}of e)for(let e=s;e<=l;e++){const s={id:null,level:r,row:o,col:t.normalizeCol(e)};this.tileInfo.updateTileInfo(s),i.push(s)}return i}},{key:"tileInfo",get:function(){var e,t;return null!=(e=null==(t=this.view.featuresTilingScheme)?void 0:t.tileInfo)?e:null}},{key:"tileSize",get:function(){return o.isSome(this.tileInfo)?this.tileInfo.size[0]:256}}]),r}(i),r.__decorate([l.property({readOnly:!0})],e.FeatureServiceTiles2D.prototype,"tiles",null),r.__decorate([l.property({readOnly:!0})],e.FeatureServiceTiles2D.prototype,"_scaleEnabled",null),r.__decorate([l.property({readOnly:!0})],e.FeatureServiceTiles2D.prototype,"tilesCoveringView",null),r.__decorate([l.property({readOnly:!0})],e.FeatureServiceTiles2D.prototype,"tileInfo",null),r.__decorate([l.property({readOnly:!0})],e.FeatureServiceTiles2D.prototype,"tileSize",null),r.__decorate([l.property({constructOnly:!0})],e.FeatureServiceTiles2D.prototype,"view",void 0),r.__decorate([l.property({constructOnly:!0})],e.FeatureServiceTiles2D.prototype,"layer",void 0),r.__decorate([l.property()],e.FeatureServiceTiles2D.prototype,"pointOfInterest",void 0),e.FeatureServiceTiles2D=r.__decorate([u.subclass("esri.views.interactive.snapping.featureSources.featureServiceSource.FeatureServiceTiles2D")],e.FeatureServiceTiles2D),Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
