/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import{__decorate as e}from"tslib";import{Clonable as r}from"../../../core/Clonable.js";import t from"../../../core/Collection.js";import{on as i}from"../../../core/reactiveUtils.js";import{property as o,subclass as s}from"../../../core/accessorSupport/decorators.js";import{isDisplayExternal as l,externalSourcesAreEqual as c,externalIsOnService as p}from"./External.js";let a=class extends r{constructor(e){super(e),this.externalSources=new t,this._explicitDisplaySource=null,this.addHandles(i(()=>this.externalSources,"after-remove",({item:e})=>{e===this._explicitDisplaySource&&(this._explicitDisplaySource=null)},{sync:!0,onListenerRemove:()=>this._explicitDisplaySource=null}))}get displaySource(){return this._explicitDisplaySource??this._implicitDisplaySource}set displaySource(e){if(null!=e&&!l(e))throw new Error("Cannot use this source for display: it is not in a supported format.");this._explicitDisplaySource=e,e&&this.externalSources.every(r=>!c(r,e))&&this.externalSources.add(e)}clearSources(){this.externalSources.removeAll()}getExternalSourcesOnService(e){return this.externalSources.items.filter(r=>p(r,e))}get _implicitDisplaySource(){return this.externalSources.find(l)}};e([o()],a.prototype,"externalSources",void 0),e([o()],a.prototype,"displaySource",null),e([o()],a.prototype,"_implicitDisplaySource",null),e([o()],a.prototype,"_explicitDisplaySource",void 0),a=e([s("esri.geometry.support.meshUtils.Metadata")],a);export{a as Metadata};
