/* COPYRIGHT Esri - https://js.arcgis.com/5.0.18/LICENSE.txt */
import{__decorate as t}from"tslib";import e from"../../../core/Accessor.js";import{equals as i}from"../../../core/arrayUtils.js";import{watch as s,when as o,on as r}from"../../../core/reactiveUtils.js";import{property as a,subclass as n}from"../../../core/accessorSupport/decorators.js";import{getLyr3DWasm as l}from"../layers/Lyr3DWasm.js";import m from"../../support/AttributionItem.js";const h=Symbol("attributions"),u=new m("Google Maps",1e3);let d=class extends e{constructor(t){super(t),this.attributionItems=[],this.view=null,this._allLayerViewsChange=()=>{this.removeHandles("items");const t=this.view?.allLayerViews;let e=!1;if(t)for(const i of t)"integrated-mesh-3dtiles"===i.type&&(e=!0,this.addHandles([s(()=>i.suspended,()=>this._updateAttributionItems()),i.on("visible-geometry-changed",()=>this._updateAttributionItems())],h));e&&this.addHandles(o(()=>!0===this.view?.stationary,()=>this._updateAttributionItems()),h),this._updateAttributionItems()}}initialize(){this.addHandles([r(()=>this.view?.allLayerViews,"change",this._allLayerViewsChange,{onListenerAdd:this._allLayerViewsChange,onListenerRemove:()=>{this.removeHandles(h),this.attributionItems=[]}})])}destroy(){this.view=null,this.attributionItems=[]}_updateAttributionItems(){const t=this.view,e=t?.allLayerViews;if(!t||!e)return void(this.attributionItems.length&&(this.attributionItems=[]));if(!t.stationary)return;const s=[];let o=u.score-1;for(const i of e)if(!i.suspended&&"integrated-mesh-3dtiles"===i.type){i.layer.hasGoogleUrl&&s.push(u);const e=l(t);if(e){const t=e.getAttributionText();for(const e of t)s.push(new m(e,o--))}break}i(this.attributionItems,s,(t,e)=>t.text===e.text)||(this.attributionItems=s)}};t([a()],d.prototype,"attributionItems",void 0),t([a()],d.prototype,"view",void 0),d=t([n("esri.views.3d.support.Attribution3D")],d);const p=d;export{p as default};
