'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const index = require('./index-b8c5f2d4.js');
const i18n = require('./i18n-92762f48.js');
require('./_commonjsHelpers-dcc4cf71.js');

const DrawToolbar = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
    this.glDrawCancel = index.createEvent(this, "glDrawCancel", 7);
    this.glDrawConfirm = index.createEvent(this, "glDrawConfirm", 7);
    this.callCancel = () => this.cancel();
    this.callConfirm = () => this.confirm();
    this.visible = false;
    this.featureCount = 0;
    this.cancelText = i18n._t("webmapgl.draw-toolbar.cancel");
    this.color = "primary";
    this.confirmText = i18n._t("webmapgl.draw-toolbar.confirm");
    this.label = i18n._t("webmapgl.draw-toolbar.label");
    this.mapId = "";
    this.maxFeatures = 1;
    this.minFeatures = 1;
  }
  handleDrawEnter(e) {
    if (e.detail.mapId !== this.mapId)
      return;
    this.featureCount = 0;
    this.visible = true;
  }
  handleDrawExit(e) {
    if (e.detail.mapId !== this.mapId)
      return;
    this.visible = false;
  }
  handleDrawCreate(e) {
    if (e.detail.mapId !== this.mapId)
      return;
    this.featureCount += 1;
  }
  handleDrawDelete(e) {
    if (e.detail.mapId !== this.mapId)
      return;
    this.featureCount -= 1;
  }
  cancel() {
    this.glDrawCancel.emit({
      mapId: this.mapId,
    });
  }
  confirm() {
    this.glDrawConfirm.emit({
      mapId: this.mapId,
    });
  }
  render() {
    if (!this.visible)
      return;
    let small = screen.width <= 640;
    let canConfirm = this.featureCount >= this.minFeatures &&
      this.featureCount <= this.maxFeatures;
    return (index.h("ion-toolbar", { color: this.color }, index.h("ion-title", null, this.label), index.h("ion-buttons", { slot: "end" }, index.h("ion-button", { onClick: this.callCancel }, index.h("ion-icon", { slot: small ? "icon-only" : "start", name: "close" }), small ? null : this.cancelText), index.h("ion-button", { onClick: canConfirm ? this.callConfirm : undefined, disabled: !canConfirm }, index.h("ion-icon", { slot: small ? "icon-only" : "start", name: "checkmark" }), small ? null : this.confirmText))));
  }
};

exports.gl_draw_toolbar = DrawToolbar;

//# sourceMappingURL=gl-draw-toolbar.cjs.entry.js.map