/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
import { c as k } from "../../chunks/runtime.js";
import { LitElement as M, createEvent as o, safeClassMap as A } from "@arcgis/lumina";
import { html as t, render as U } from "lit";
class F extends M {
  constructor() {
    super(...arguments), this._showInvalidVersionNotice = !0, this.arcgisCreateVersionList = o(), this.arcgisFlowItemBack = o(), this.arcgisFlowItemClose = o(), this.arcgisGetVersions = o(), this.arcgisManageVersion = o(), this.arcgisNewVersion = o();
  }
  static {
    this.properties = { _showInvalidVersionNotice: 16, serviceItemElementProps: 0 };
  }
  disconnectedCallback() {
    super.disconnectedCallback(), this.versionListContainer?.remove();
  }
  render() {
    const { serviceItemElementProps: { allowEditing: v, closable: h, currentUser: $, executionError: p, currentVersionIdentifier: r, flowElement: V, heading: b, isInitialVersionInvalid: I, isVersionAdministrator: f, isVersioningApiAvailable: u, mode: w, pageSize: x, serviceName: i, serviceUrl: c, state: E, strings: n, versionInfos: a } } = this;
    let { _versionList: l } = this;
    const N = I.get(c) && this._showInvalidVersionNotice ? t`<calcite-notice closable kind=warning open scale=s width=full icon @calciteNoticeClose=${() => this._showInvalidVersionNotice = !1}><div slot=title>${n.headers.invalidInitialVersion}</div><div slot=message>${n.loadErrors.invalidInitialVersion}</div></calcite-notice>` : void 0, C = t`<calcite-combobox .ariaLabel=${`combobox-${i}`} .label=${`combobox-${i}`} max-items=5 overlay-positioning=fixed selection-mode=single-persist @calciteComboboxChange=${(s) => {
      const m = s.target, e = a.find((L) => L.versionIdentifier.guid === m.value);
      this.arcgisManageVersion.emit({ actionType: "changeVersion", serviceUrl: c, versionInfo: e });
    }}>${a ? a.map((s) => t`<calcite-combobox-item class=${A(w === "dialog" ? "" : "calcite-combobox-item")} .heading=${s.versionIdentifier.name} .value=${s.versionIdentifier.guid} .selected=${r.guid === s.versionIdentifier.guid && r.name === s.versionIdentifier.name}></calcite-combobox-item>`) : void 0}</calcite-combobox>`;
    let d, g;
    return v && (d = t`<calcite-action icon=list .id=${`action-manage-versions-${i}`} .label=${`action-manage-versions-${i}`} scale=s slot=actions-end .text=${`action-manage-versions-${i}`} @click=${async () => {
      const s = {
        closable: h,
        currentUser: $,
        currentVersionIdentifier: r,
        executionError: p,
        heading: b,
        isVersionAdministrator: f,
        isVersioningApiAvailable: u,
        pageSize: x,
        serviceName: i,
        serviceUrl: c,
        state: E,
        strings: n,
        versionInfos: a
      };
      this.versionListContainer = document.createElement("div");
      const m = U(t`<arcgis-version-management-version-list .versionListElementProps=${s} selected show-back-button @arcgisFlowItemBack=${(e) => {
        e.preventDefault(), this.arcgisFlowItemBack.emit();
      }} @arcgisFlowItemClose=${() => this.arcgisFlowItemClose.emit()} @arcgisGetVersions=${(e) => this.arcgisGetVersions.emit({ serviceUrl: e.detail.serviceUrl })} @arcgisManageVersion=${(e) => this.arcgisManageVersion.emit(e.detail)} @arcgisNewVersion=${(e) => this.arcgisNewVersion.emit({ serviceUrl: e.detail.serviceUrl })}></arcgis-version-management-version-list>`, this.versionListContainer);
      l = Array.from(m.parentNode.childNodes).find((e) => e.nodeName.toUpperCase() === "ARCGIS-VERSION-MANAGEMENT-VERSION-LIST"), V?.append(l), this.arcgisCreateVersionList.emit(l);
    }}></calcite-action>`, g = t`<calcite-tooltip overlay-positioning=fixed .referenceElement=${`action-manage-versions-${i}`}><span>${n.headers.manageVersions}</span></calcite-tooltip>`), t`<calcite-block expanded .heading=${i}>${N}${C}${d}${g}</calcite-block>`;
  }
}
k("arcgis-version-management-service-item", F);
export {
  F as ArcgisVersionManagementServiceItem
};
