// All material copyright Esri, All Rights Reserved, unless otherwise specified. // See https://js.arcgis.com/4.30/esri/copyright.txt for details. //>>built define("../../chunks/tslib.es6 ../../core/Accessor ../../core/asyncUtils ../../core/Collection ../../core/reactiveUtils ../../core/accessorSupport/decorators/property ../../core/has ../../core/Logger ../../core/RandomLCG ../../core/accessorSupport/decorators/subclass ../../geometry/Extent ../../geometry/SpatialReference ../../geometry/support/contains ../../geometry/support/webMercatorUtils ../../views/3d/layers/Lyr3DWasm".split(" "),function(p,l,y,t,q,r,F,G,H,z,A,B,C,u,D){function v(b,c){return b&& "copyright"in b&&(!c||"function"===typeof b.originOf&&"user"===b.originOf("copyright"))}function E(b,c){return b.length!==c.length||b.some((d,a)=>d.text!==c[a].text)}function n(b,c,d){d&&c&&(b.find(a=>a.layerView===c&&a.text===d)||b.push({text:d,layerView:c}))}const k=[];l=class extends l{constructor(b){super(b);this._clear=()=>{this._fetchedAttributionData.clear();this._pendingAttributions.clear();this.removeHandles("suspension");this.notifyChange("state")};this._pendingAttributions=new Set;this._fetchedAttributionData= new Map;this.items=new t;this.view=null;this._allLayerViewsChange=c=>{this.removeHandles("suspension");this.removeHandles("visible-geometry-changed");const d=this.view?.allLayerViews;d&&(this.addHandles(d.map(a=>q.watch(()=>[a.suspended,a.layer?.attributionVisible],()=>this._updateAttributionItems())).toArray(),"suspension"),d.forEach(a=>{"esri.views.3d.layers.Tiles3DLayerView3D"===a.declaredClass&&this.addHandles(a.on("visible-geometry-changed",()=>this._updateAttributionItems()),"visible-geometry-changed")})); c?.removed&&c.removed.forEach(a=>{this._pendingAttributions.delete(a);this._fetchedAttributionData.delete(a)});this._updateAttributionItems()};this.addHandles([q.on(()=>this.view?.allLayerViews,"change",c=>this._allLayerViewsChange(c),{onListenerAdd:()=>this._allLayerViewsChange(),onListenerRemove:this._clear}),q.when(()=>!0===this.view?.stationary,()=>this._updateAttributionItems())])}destroy(){this.view=null;this._fetchedAttributionData.clear();this._pendingAttributions.clear();this.items.removeAll()}get state(){return this.view?.ready? 0{if(!a.suspended&&a.layer?.attributionVisible){var e=a.layer;if(v(e,"user"))n(k,a,e.copyright);else if(e.hasAttributionData)if(this._fetchedAttributionData.has(a)){var h=this._fetchedAttributionData.get(a);h?n(k,a,this._getDynamicAttribution(h,b,e)):v(e)&&n(k,a,e.copyright)}else this._fetchAttributionData(a);else(h="portalItem"in e?e.portalItem?.accessInformation: void 0)?n(k,a,h):n(k,a,e.copyright)}});c=c.find(a=>"integrated-mesh-3dtiles"===a.layer?.type);if(this.view&&c){var d=D.getLyr3DWasm(this.view);if(d){d=d.getAttributionText();for(let a=0;a=d)return"";b=b[d];const h=u.project(a.center.clone().normalize(),c.spatialReference),m=new Set;return b?b.filter(f=>{const g=f.id;(f=!m.has(g)&& h&&f.extent&&C.extentContainsPoint(f.extent,h))&&m.add(g);return f}).sort((f,g)=>g.score-f.score||f.objectId-g.objectId).map(f=>f.attribution).join(", "):""}};p.__decorate([r.property({readOnly:!0,type:t})],l.prototype,"items",void 0);p.__decorate([r.property({readOnly:!0})],l.prototype,"state",null);p.__decorate([r.property()],l.prototype,"view",void 0);return l=p.__decorate([z.subclass("esri.widgets.Attribution.AttributionViewModel")],l)});