/* COPYRIGHT Esri - https://js.arcgis.com/1.2/LICENSE.txt */
import { c as customElement } from "../../chunks/runtime.js";
import { css, html } from "lit";
import { LitElement, createEvent } from "@arcgis/lumina";
import LayerList from "@arcgis/core/widgets/LayerList";
const styles = css`/** @license
 * Copyright 2025 Esri
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

:host {
  display: block;
}`;
class LayerListWidget extends LitElement {
  constructor() {
    super(...arguments);
    this.visibilityIcon = "eyeball";
    this.fullscreenStateChange = createEvent();
  }
  static {
    this.properties = { mapView: [0, {}, { attribute: false }], layerListWidget: [0, {}, { attribute: false }], visibilityIcon: 1 };
  }
  static {
    this.styles = styles;
  }
  willUpdate(changes) {
    if (changes.has("mapView")) {
      void this.mapViewWatchHandler();
    }
    if (changes.has("visibilityIcon")) {
      void this.visibilityIconWatchHandler();
    }
  }
  async mapViewWatchHandler() {
    await this.mapView?.when(async () => {
      await this._initLayerListWidget();
    });
  }
  async visibilityIconWatchHandler() {
    if (this.layerListWidget) {
      this.layerListWidget.visibilityAppearance = this.visibilityIcon === "checkbox" ? "checkbox" : "default";
    }
  }
  render() {
    return html`<div class="layer-list-widget"></div>`;
  }
  async updated() {
    if (!this.hasUpdated) {
      await this._initLayerListWidget();
    }
  }
  async loaded() {
    await this._initLayerListWidget();
  }
  async _initLayerListWidget() {
    if (this.mapView) {
      this.layerListWidget = new LayerList({
        view: this.mapView,
        visibilityAppearance: this.visibilityIcon === "checkbox" ? "checkbox" : "default"
      });
    }
  }
}
customElement("layer-list-widget", LayerListWidget);
export {
  LayerListWidget
};
