/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import{__decorate as e}from"tslib";import{property as t,subclass as r}from"../../core/accessorSupport/decorators.js";import{shouldOpenInNewTab as o}from"../../popup/support/featureUtils.js";import a from"../Widget.js";import i from"./FeatureContent/FeatureContentViewModel.js";import{tsx as s,isWidget as d}from"../support/widget.js";const n="esri-feature-content",l={base:n,loaderContainer:`${n}__loader-container`,loader:`${n}__loader`};let c=class extends a{constructor(e,t){super(e,t),this.viewModel=null,this._addTargetToAnchors=e=>{Array.from(e.querySelectorAll("a")).forEach(e=>{o(e.href)&&!e.hasAttribute("target")&&e.setAttribute("target","_blank")})}}get creator(){return this.viewModel?.creator}set creator(e){this.viewModel&&(this.viewModel.creator=e)}get graphic(){return this.viewModel?.graphic}set graphic(e){this.viewModel&&(this.viewModel.graphic=e)}render(){const e=this.viewModel?.state;return s("div",{class:l.base},"loading"===e?this._renderLoading():this._renderCreated())}_renderLoading(){return s("div",{class:l.loaderContainer,key:"loader"},s("div",{class:l.loader}))}_renderCreated(){const e=this.viewModel?.created;return e?e instanceof HTMLElement?s("div",{afterCreate:this._attachToNode,bind:e,key:e}):d(e)?s("div",{key:e},!e.destroyed&&e.render()):s("div",{afterCreate:this._addTargetToAnchors,innerHTML:e,key:e}):null}_attachToNode(e){const t=this;e.appendChild(t)}};e([t()],c.prototype,"creator",null),e([t()],c.prototype,"graphic",null),e([t({type:i})],c.prototype,"viewModel",void 0),c=e([r("esri.widgets.Feature.FeatureContent")],c);export{c as default};
