import { r as registerInstance, j as createEvent, h, g as getElement } from './index-07845439.js';
import './index-cd3eb450.js';
import { d as dist } from './index-63517df5.js';
import { N as Notice } from './index-f068b00b.js';
import './App-15d9fce3.js';
import './_commonjsHelpers-8fe71198.js';
import './index-265fba1f.js';

const sv = {
  Save: "Spara",
  Cancel: "Avbryt",
  primary: "primär",
  cellphone: "mobiltelefon",
  landline: "fast telefon",
  "Please enter a valid phone number.": "Ange ett giltigt telefonnummer.",
  "Phone number": "Telefonnummer",
};

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

const styleCss = ".sc-ig-phone-number-input-h{margin-top:.5em;display:block}smoothly-submit.sc-ig-phone-number-input,smoothly-submit.sc-ig-phone-number-input>button.sc-ig-phone-number-input{background-color:transparent;border:none;cursor:pointer;color:transparent;width:auto;float:right;margin-top:.2em}smoothly-input.sc-ig-phone-number-input{border:1px solid rgb(var(--smoothly-medium-color))}form.sc-ig-phone-number-input{display:-ms-flexbox;display:flex;-ms-flex-flow:row;flex-flow:row;-ms-flex-wrap:wrap;flex-wrap:wrap}form.sc-ig-phone-number-input>*.sc-ig-phone-number-input:not(smoothly-icon){width:100%}form.sc-ig-phone-number-input>tr.sc-ig-phone-number-input>span.sc-ig-phone-number-input>smoothly-icon.sc-ig-phone-number-input{float:left;margin-right:.2em}form.sc-ig-phone-number-input>tr.sc-ig-phone-number-input>span.sc-ig-phone-number-input{float:left;margin-right:1em;padding-bottom:.5em;padding-top:.5em;font-size:.9em}";

const IntergiroPhoneNumberInput = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.add = createEvent(this, "add", 7);
    this.edit = createEvent(this, "edit", 7);
    this.notice = createEvent(this, "notice", 7);
    this.types = [];
    this.type = this.types[0];
    this.mode = "edit";
  }
  componentWillLoad() {
    this.t = create(this.element);
  }
  onSubmit(e) {
    const value = e.detail.phone;
    if (value) {
      if (this.mode == "add")
        this.add.emit({ type: this.type, value });
      else
        this.edit.emit(value);
    }
    else
      this.notice.emit(Notice.failed(this.t("Please enter a valid phone number.")));
  }
  onCancel() {
    this.edit.emit(this.value);
  }
  onSelectionChanged(e) {
    this.type = e.detail.value;
  }
  toUpperCase(value) {
    return value.charAt(0).toUpperCase() + value.slice(1);
  }
  render() {
    const t = this.t;
    return (h("form", null, this.mode == "add" ? (h("smoothly-select", { background: "transparent" }, this.types.map(option => this.type == option ? (h("option", { value: option, selected: true }, this.toUpperCase(t(option)))) : (h("option", { value: option }, this.toUpperCase(t(option))))))) : ([]), h("smoothly-input", { type: "phone", name: "phone", value: this.value }, this.mode == "add" ? t("Phone number") : t(this.type)), h("div", null, h("smoothly-submit", { prevent: true, onSubmit: (e) => this.onSubmit(e) }, h("smoothly-icon", { name: "checkmark-circle", toolTip: t("Save"), color: "success", fill: "clear", size: "small" })), h("smoothly-submit", { prevent: true, onSubmit: () => this.onCancel() }, h("smoothly-icon", { name: "close-circle", toolTip: t("Cancel"), color: "light", fill: "clear", size: "small" })))));
  }
  get element() { return getElement(this); }
};
IntergiroPhoneNumberInput.style = styleCss;

export { IntergiroPhoneNumberInput as ig_phone_number_input };
