import { r as registerInstance, j as createEvent, h, g as getElement } from './index-07845439.js';
import { d as dist } from './index-63517df5.js';
import './_commonjsHelpers-8fe71198.js';

const sv = {
  Edit: "Redigera",
  Delete: "Radera",
  primary: "primär",
  billing: "fakturering",
  delivery: "leverans",
  visit: "besök",
};

function create(language) {
  return dist.create({
    sv,
  }, language);
}

const styleCss = ".sc-ig-address-h{display:block;position:relative}[hidden].sc-ig-address-h{display:none}smoothly-icon.sc-ig-address{cursor:pointer;margin-top:.3em}label.sc-ig-address{display:inline-block;-webkit-margin-before:.6em;margin-block-start:.6em;-webkit-margin-after:.2em;margin-block-end:.2em;text-transform:capitalize;margin-bottom:.2em}smoothly-popup.sc-ig-address{display:none;position:absolute;right:0}.sc-ig-address-h:hover smoothly-popup.sc-ig-address{display:inline}";

const IntergiroAddress = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.edit = createEvent(this, "edit", 7);
    this.delete = createEvent(this, "delete", 7);
    this.type = "primary";
    this.mode = "display";
  }
  componentWillLoad() {
    this.t = create(this.element);
  }
  onChange(event) {
    event.stopPropagation();
    this.value = event.detail;
    this.mode = "display";
    this.edit.emit(Object.assign({ type: this.type }, this.value));
  }
  onDelete() {
    this.delete.emit(this.type);
  }
  render() {
    const t = this.t;
    return [
      h("smoothly-popup", null, h("smoothly-icon", { name: "ellipsis-vertical-outline", size: "small" }), h("div", { color: "light", slot: "popup" }, h("smoothly-icon", { size: "small", name: "pencil-outline", toolTip: t("Edit"), onClick: () => (this.mode = "edit") }), h("smoothly-icon", { size: "small", name: "trash", toolTip: "Delete", onClick: () => this.onDelete() }))),
      this.mode == "edit"
        ? [
          h("label", null, t(this.type)),
          h("ig-address-input", { onEdit: (e) => this.onChange(e), value: this.value }),
        ]
        : [h("label", null, t(this.type)), h("ig-address-display", { value: this.value })],
    ];
  }
  get element() { return getElement(this); }
};
IntergiroAddress.style = styleCss;

export { IntergiroAddress as ig_address };
