/* COPYRIGHT Esri - https://js.arcgis.com/1.2/LICENSE.txt */
import { c as t } from "../../chunks/runtime.js";
import { css as e, html as s } from "lit";
import { LitElement as a, createEvent as c } from "@arcgis/lumina";
import l from "@arcgis/core/widgets/LayerList";
const r = e`:host{display:block}`;
class n extends a {
  constructor() {
    super(...arguments), this.visibilityIcon = "eyeball", this.fullscreenStateChange = c();
  }
  static {
    this.properties = { mapView: 0, layerListWidget: 0, visibilityIcon: 1 };
  }
  static {
    this.styles = r;
  }
  willUpdate(i) {
    i.has("mapView") && this.mapViewWatchHandler(), i.has("visibilityIcon") && this.visibilityIconWatchHandler();
  }
  async mapViewWatchHandler() {
    await this.mapView?.when(async () => {
      await this._initLayerListWidget();
    });
  }
  async visibilityIconWatchHandler() {
    this.layerListWidget && (this.layerListWidget.visibilityAppearance = this.visibilityIcon === "checkbox" ? "checkbox" : "default");
  }
  render() {
    return s`<div class="layer-list-widget"></div>`;
  }
  async updated() {
    this.hasUpdated || await this._initLayerListWidget();
  }
  async loaded() {
    await this._initLayerListWidget();
  }
  async _initLayerListWidget() {
    this.mapView && (this.layerListWidget = new l({
      view: this.mapView,
      visibilityAppearance: this.visibilityIcon === "checkbox" ? "checkbox" : "default"
    }));
  }
}
t("layer-list-widget", n);
export {
  n as LayerListWidget
};
