import{__decorate as e}from"tslib";import{isSublayerExtension as t,isTableExtension as i}from"../../ItemType.js";import{FeatureSettings as s}from"../../data/FeatureSettings.js";import{TableExtension as n}from"../../data/_TableExtension.js";import{serializable as r}from"../../support/Serializable.js";import{notifyChange as o,onWatch as a,watch as y}from"../../support/observableUtils.js";import{LayerExtension as _}from"../_LayerExtension.js";import{SublayerExtension as l}from"../_SublayerExtension.js";let p=class extends s{_layerExtension;get _bindings(){return this._propertyBindings||(this._propertyBindings=new Map),this._propertyBindings}_propertyBindings;constructor(e){super(),this._layerExtension=e,this._bindSettingToLayerProperty("popupTemplate");const s=this._getLayerLike();if(s)this._onLayerResolved(s);else{const s=e=>this._onLayerResolved(e);t(e)?y(e,"sublayer",s,{sync:!0,once:!0}):i(e)?y(e,"table",s,{sync:!0,once:!0}):y(e,"layer",s,{sync:!0,once:!0})}}_getSerializableProperties(){return{...super._getSerializableProperties(),popupTemplate:{serialize:!1}}}_hasSettingIncludingAncestor(e){const t=this._getLayerLike();return!(!this._bindings.has(e)||!t)||super._hasSettingIncludingAncestor(e)}_getSetting(e,t){const i=this._getLayerLike();if(this._bindings.has(e)&&i){const t=this._bindings.get(e).split(".");let s=i;for(;s&&"object"==typeof s&&t.length;)s=s[t.shift()];return s}return super._getSetting(e,t)}_setSetting(e,t){const i=this._getLayerLike();this._bindings.has(e)&&i?i.set({[this._bindings.get(e)]:t}):super._setSetting(e,t)}_bindSettingToLayerProperty(e,t){const i=this._getLayerLikeType();if(!i)return;const s=t||e;this._bindings.set(e,s),a(this,e,(()=>y(this._layerExtension,`${i}.${s}`,(()=>o(this,e)),{sync:!0})))}_onLayerResolved(e){for(const t of this._bindings.keys())this.isModified(t)&&(e.set({[t]:this[t]}),this.reset(t))}_getLayerLike(){return this._layerExtension instanceof _?this._layerExtension.layer:this._layerExtension instanceof n?this._layerExtension.table:this._layerExtension instanceof l?this._layerExtension.sublayer:void 0}_getLayerLikeType(){return this._layerExtension instanceof _?"layer":this._layerExtension instanceof n?"table":this._layerExtension instanceof l?"sublayer":void 0}};p=e([r],p);export{p as PopupTemplateFeatureSettings};