import { proxyExports as h, GenericController as c } from "@arcgis/lumina/controllers";
import * as l from "@geoscene/core/core/reactiveUtils.js";
import { signal as a } from "@geoscene/core/applications/Components/reactiveUtils.js";
import { a as i } from "./component-utils.js";
/*! All material copyright GeoScene, All Rights Reserved, unless otherwise specified.
See https://js.geoscene.cn/4.33/geoscene/copyright.txt for details.
v4.33.18 */
const v = (s) => m(s);
class d extends c {
  #e = a(void 0);
  #o = void 0;
  #t = !1;
  constructor(e) {
    super(e);
    const { el: t } = e, n = t.view;
    this.setProvisionalExports(void 0), Object.defineProperty(t, "view", {
      get: () => this.#e.value,
      set: (o) => {
        if (this.exports === o)
          return;
        const r = t.view;
        this.#e.value = o, this.exports = o, this.component.requestUpdate("view", r), this.#i();
      },
      configurable: !0,
      enumerable: !0
    }), e !== t && Object.defineProperty(e, "view", {
      get: () => t.view,
      set: (o) => {
        t.view = o;
      }
    }), queueMicrotask(() => n ? t.view = n : 0);
  }
  hostConnected() {
    this.component.manager.hasDestroy && (this.#o ??= l.when(
      () => this.#e.value?.destroyed,
      () => void this.component.destroy?.().catch(console.error),
      { sync: !0 }
    ), this.onDestroy(() => this.#o?.remove())), this.component.manager.loadedCalled && i(this.component);
  }
  hostLoad() {
    this.component.manager.destroyed;
  }
  hostLoaded() {
    const { el: e } = this.component, t = e.shadowRoot?.firstElementChild ?? e.firstElementChild ?? void 0;
    e.childElem ??= t, this.#t = !0, this.#i(), e.isConnected && i(this.component);
  }
  hostDisconnected() {
    typeof this.component.el.childElem == "object" && this.#e.value?.ui?.remove(this.component.el.childElem);
  }
  hostUpdate(e) {
    e.has("position") && this.component.el.childElem != null && typeof this.component.position == "string" && i(this.component), e.has("referenceElement") && i(this.component);
  }
  #i() {
    !this.#t || this.#e.value == null || (this.#t = !1, this.component.geosceneReady.emit());
  }
}
const m = h(d);
export {
  d as V,
  v as u
};