/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
import { c as s } from "../../chunks/runtime.js";
import { css as l, html as a } from "lit";
import { u as o } from "../../chunks/useT9n.js";
import { LitElement as n, createEvent as i } from "@arcgis/lumina";
const r = l`:host{display:block}`;
class c extends n {
  constructor() {
    super(...arguments), this.ids = [], this.open = !1, this._isDeleting = !1, this._translations = o({ name: "delete-dialog", blocking: !0 }), this.editsComplete = i(), this.deleteDialogClose = i();
  }
  static {
    this.properties = { ids: 0, layer: 0, open: 5, _isDeleting: 16, _translations: 16 };
  }
  static {
    this.styles = r;
  }
  render() {
    const e = this.layer?.title || "", t = this.ids.length === 1 ? (this._translations.confirmSingle || "").replace("{{layer-name}}", e) : (this._translations.confirmMultiple || "").replace("{{layer-name}}", e);
    return a`<calcite-dialog .heading=${this._translations.deleteFeature} kind=danger modal @calciteDialogClose=${() => this._close()} .open=${this.open} width=s><div>${t}</div><calcite-button appearance=outline kind=danger @click=${() => this._close()} slot=footer-end width=full>${this._translations.cancel}</calcite-button><calcite-button kind=danger .loading=${this._isDeleting} @click=${() => {
      this._deleteFeatures();
    }} slot=footer-end width=full>${this._translations.delete}</calcite-button></calcite-dialog>`;
  }
  async _deleteFeatures() {
    if (this.layer) {
      this._isDeleting = !0;
      const e = this.ids.map((t) => ({ objectId: Number(t) }));
      await this.layer.applyEdits({
        deleteFeatures: e
      }), this._isDeleting = !1, this._close(), this.editsComplete.emit("delete");
    }
  }
  _close() {
    this.open = !1, this.deleteDialogClose.emit();
  }
}
s("delete-dialog", c);
export {
  c as DeleteDialog
};
