/*
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","../../Color","../../Graphic","../../core/Accessor","../../core/mathUtils","../../core/maybe","../../core/accessorSupport/decorators/property","../../core/arrayUtils","../../core/has","../../core/accessorSupport/ensureType","../../core/accessorSupport/decorators/subclass","../../symbols/PointSymbol3D","../../symbols/SimpleFillSymbol","../../symbols/TextSymbol","../../symbols/TextSymbol3DLayer"],(function(e,s,t,o,l,r,i,a,n,c,h,y,b,p,u,g,_){"use strict";const d=[[0,179,255],[117,62,128],[0,104,255],[215,189,166],[32,0,193],[98,162,206],[102,112,129],[52,125,0],[142,118,246],[138,83,0],[92,122,255],[122,55,83],[0,142,255],[81,40,179],[0,200,244],[13,24,127],[0,170,147],[19,58,241],[22,44,35]];e.TileTreeDebugger=function(e){function t(s){var t;return(t=e.call(this,s)||this).updating=!1,t.enablePolygons=!0,t.enableLabels=!0,t._polygons=new Map,t._labels=new Map,t._enabled=!0,t}s._inheritsLoose(t,e);var r=t.prototype;return r.initialize=function(){this._symbols=d.map((e=>new u({color:[e[0],e[1],e[2],.6],outline:{color:"black",width:1}}))),this.update()},r.destroy=function(){this._enabled=!1,this.clear()},r.update=function(){if(!this._enabled)return void this.clear();const e=e=>{if(a.isSome(e.label))return e.label;let s=e.lij.toString();return a.isSome(e.loadPriority)&&(s+=` (${e.loadPriority})`),s},s=this.getTiles(),t=new Array,r=new Set((this._labels.size,this._labels.keys()));s.forEach(((n,c)=>{const h=n.lij.toString();r.delete(h);const y=n.lij[0],b=n.geometry;if(this.enablePolygons&&!this._polygons.has(h)){const e=new l({geometry:b,symbol:this._symbols[y%this._symbols.length]});this._polygons.set(h,e),t.push(e)}if(this.enableLabels){const r=e(n),y=c/(s.length-1),u=i.lerp(0,200,y),d=i.lerp(20,6,y)/.75,m=a.isSome(n.loadPriority)&&n.loadPriority>=s.length,f=new o([u,m?0:u,m?0:u]),w="3d"===this.view.type?()=>new p({verticalOffset:{screenLength:40/.75},callout:{type:"line",color:"white",border:{color:"black"}},symbolLayers:[new _({text:r,halo:{color:"white",size:1/.75},material:{color:f},size:d})]}):()=>new g({text:r,haloColor:"white",haloSize:1/.75,color:f,size:d});if(this._labels.has(h)){const e=this._labels.get(h),s=w();(a.isNone(e.symbol)||JSON.stringify(s)!==JSON.stringify(e.symbol))&&(e.symbol=s)}else{const e=new l({geometry:b.extent.center,symbol:w()});this._labels.set(h,e),t.push(e)}}}));const n=new Array;r.forEach((e=>{this._polygons.has(e)&&(n.push(this._polygons.get(e)),this._polygons.delete(e)),this._labels.has(e)&&(n.push(this._labels.get(e)),this._labels.delete(e))})),this.view.graphics.removeMany(n),this.view.graphics.addMany(t)},r.clear=function(){this.view.graphics.removeMany(Array.from(this._polygons.values())),this.view.graphics.removeMany(Array.from(this._labels.values())),this._polygons.clear(),this._labels.clear()},s._createClass(t,[{key:"enabled",get:function(){return this._enabled},set:function(e){this._enabled!==e&&(this._enabled=e,this.update())}}]),t}(r),t.__decorate([n.property({constructOnly:!0})],e.TileTreeDebugger.prototype,"view",void 0),t.__decorate([n.property({readOnly:!0})],e.TileTreeDebugger.prototype,"updating",void 0),t.__decorate([n.property()],e.TileTreeDebugger.prototype,"enabled",null),e.TileTreeDebugger=t.__decorate([b.subclass("esri.views.support.TileTreeDebugger")],e.TileTreeDebugger),Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
