import { r as registerInstance, c as createEvent, h, g as getElement } from './index-08b73e9e.js';
import { d as dist } from './index-a0a71287.js';
import { E as EmailAddresses, N as Name, C as Contact, P as PhoneNumbers } from './Item-f4cbd6f4.js';
import { I as Item, E as Event, C as Connection, a as Payment } from './index-3299c1c0.js';
import './Credentials-b84c0c5f.js';
import './Token-ba2c5d5c.js';
import './App-364e27cc.js';
import { N as Notice } from './Notice-668f9bc7.js';
import { b as backendFailure, E as Error } from './unknown-97022c22.js';
import { d as dist$1 } from './index-3cf720d3.js';
export { I as ig_orders_table_row } from './index-eb157781.js';
import './_commonjsHelpers-9943807e.js';
import './index-1f953d81.js';
import './TextDecoder-357ac2ce.js';
import './index-8ba22472.js';
import './index-84a8301a.js';
import './index-26d778c4.js';

const sv$d = {
  Edit: "Redigera",
  Delete: "Radera",
  primary: "primär",
  billing: "fakturering",
};

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

const styleCss$d = ".sc-ig-email-address-h{display:block;position:relative}[hidden].sc-ig-email-address-h{display:none}smoothly-display.sc-ig-email-address{border-top:1px solid rgb(var(--smoothly-medium-color));border-bottom:1px solid rgb(var(--smoothly-medium-color));padding-top:0.5em;padding-bottom:0.5em}label.sc-ig-email-address{display:block;-webkit-margin-before:0.6em;margin-block-start:0.6em;-webkit-margin-after:0.2em;margin-block-end:0.2em;text-transform:capitalize;margin-bottom:0.2em}smoothly-popup.sc-ig-email-address{display:none;position:absolute;right:0}.sc-ig-email-address-h:hover smoothly-popup.sc-ig-email-address{display:inline}smoothly-icon.sc-ig-email-address{cursor:pointer}";

const IntergiroEmailAddress = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.edit = createEvent(this, "edit", 7);
    this.delete = createEvent(this, "delete", 7);
    this.editable = true;
    this.type = "primary";
    this.mode = "display";
  }
  componentWillLoad() {
    this.t = create$d(this.element);
  }
  onEdit(event) {
    event.stopPropagation();
    this.value = event.detail;
    this.mode = "display";
    this.edit.emit({ type: this.type, value: this.value });
  }
  onDelete() {
    this.delete.emit(this.type);
  }
  render() {
    const t = this.t;
    return this.value.length > 0
      ? [
        this.mode == "display" ? ([
          this.editable && (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: t("Delete"), onClick: () => this.onDelete() })))),
          h("label", null, t(this.type)),
          h("smoothly-display", { type: "email", value: this.value }),
        ]) : (h("ig-email-input", { value: this.value, type: this.type, mode: "edit", onEdit: (e) => this.onEdit(e) })),
      ]
      : [];
  }
  get element() { return getElement(this); }
};
IntergiroEmailAddress.style = styleCss$d;

const sv$c = {
  Add: "Lägg till",
  Email: "E-post",
};

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

const styleCss$c = ".sc-ig-email-addresses-h{display:block}label.sc-ig-email-addresses{font-weight:bold}.sc-ig-email-addresses-h:not([label]) label.sc-ig-email-addresses{font-weight:bold}smoothly-icon.sc-ig-email-addresses{cursor:pointer;float:right;margin-top:-0.2em;visibility:hidden}ig-email-address.sc-ig-email-addresses{clear:both}.sc-ig-email-addresses-h:hover smoothly-icon.sc-ig-email-addresses{visibility:visible}";

const IntergiroEmailAddresses = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.changed = createEvent(this, "changed", 7);
    this.editable = true;
    this.adding = false;
  }
  get types() {
    return EmailAddresses.types.filter(type => EmailAddresses.is(this.value) ? !this.value[type] : this.value ? type != "primary" : type);
  }
  get emailAddresses() {
    return EmailAddresses.is(this.value) ? Object.assign({}, this.value) : { primary: this.value };
  }
  componentWillLoad() {
    this.t = create$c(this.element);
  }
  onEdit(e) {
    const type = e.detail.type;
    delete e.detail.type;
    let result;
    if (!EmailAddresses.is(this.value))
      result = e.detail.value;
    else {
      result = Object.assign({}, this.value);
      result[type] = e.detail.value;
    }
    this.changed.emit((this.value = result));
  }
  onDelete(e) {
    const type = e.detail;
    const result = Object.assign({}, this.emailAddresses);
    delete result[type];
    this.changed.emit((this.value = result));
  }
  onAdd(e) {
    const type = e.detail.type;
    const value = e.detail.value;
    const result = this.emailAddresses;
    result[type] = value;
    this.changed.emit((this.value = result));
    this.adding = false;
  }
  render() {
    return [
      h("label", null, this.t("Email")),
      this.adding ? (h("ig-email-input", { onEdit: () => (this.adding = false), types: this.types, mode: "add", onAdd: (e) => this.onAdd(e) })) : ([]),
      this.editable && this.types.length > 0 ? (h("smoothly-icon", { name: "add-circle", toolTip: this.t("Add"), fill: "clear", size: "medium", color: "success", style: this.adding ? { display: "none" } : {}, onClick: () => (this.adding = true) })) : ([]),
      EmailAddresses.is(this.value) ? (EmailAddresses.map(this.value, (type, value) => [
        h("ig-email-address", { value: value, type: type, editable: this.editable, onEdit: (e) => this.onEdit(e), onDelete: (e) => this.onDelete(e) }),
      ])) : this.value ? (h("ig-email-address", { value: this.value, editable: this.editable, onEdit: (e) => this.onEdit(e), onDelete: (e) => this.onDelete(e) })) : ([]),
    ];
  }
  get element() { return getElement(this); }
};
IntergiroEmailAddresses.style = styleCss$c;

const sv$b = {
  Save: "Spara",
  Cancel: "Avbryt",
  primary: "primär",
  billing: "fakturering",
  "Please enter a valid email address.": "Ange en giltig e-postadress.",
};

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

const styleCss$b = ".sc-ig-email-input-h{display:block;margin-top:0.5em}smoothly-submit.sc-ig-email-input,smoothly-submit.sc-ig-email-input>button.sc-ig-email-input{background-color:transparent;border:none;cursor:pointer;color:transparent;width:auto;float:right;margin-bottom:0.2em}smoothly-input.sc-ig-email-input{border:1px solid rgb(var(--smoothly-medium-color))}form.sc-ig-email-input{display:-ms-flexbox;display:flex;-ms-flex-flow:row;flex-flow:row;-ms-flex-wrap:wrap;flex-wrap:wrap}form.sc-ig-email-input>*.sc-ig-email-input{width:100%}smoothly-select.sc-ig-email-input{display:grid;margin-bottom:0.5em}";

const IntergiroEmailInput = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.edit = createEvent(this, "edit", 7);
    this.add = createEvent(this, "add", 7);
    this.notice = createEvent(this, "notice", 7);
    this.types = [];
    this.type = this.types[0];
    this.mode = "edit";
  }
  componentWillLoad() {
    this.t = create$b(this.element);
  }
  onSubmit(e) {
    const value = e.detail.email;
    if (value) {
      if (this.mode == "add")
        this.add.emit({ type: this.type, value });
      else
        this.edit.emit(e.detail.email);
    }
    else
      this.notice.emit(Notice.failed(this.t("Please enter a valid email address.")));
  }
  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: "email", name: "email", value: this.value }, this.mode == "add" ? t("Email") : 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); }
};
IntergiroEmailInput.style = styleCss$b;

const sv$a = {
  Name: "Namn",
  Email: "Mail",
  Phone: "Telefon",
  "There is no contact information available.": "Det finns ingen kontaktinformation tillgänglig.",
};

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

const styleCss$a = ".sc-ig-order-contact-h{display:-ms-flexbox;display:flex;width:100%;-ms-flex-direction:row;flex-direction:row;-ms-flex-pack:start;justify-content:flex-start;padding:1em;padding-left:4.5em}[hidden].sc-ig-order-contact-h{display:none}dt.sc-ig-order-contact{font-weight:bold;text-align:left;margin-bottom:0.2em}dt.sc-ig-order-contact::first-letter{text-transform:capitalize}section.sc-ig-order-contact{width:30%}section.sc-ig-order-contact>dt.sc-ig-order-contact+*.sc-ig-order-contact{width:70%}";

const IntergiroOrderContact = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
  }
  componentWillLoad() {
    this.t = create$a(this.element);
  }
  render() {
    return !this.contact || Object.values(this.contact).length < 1 ? (h("p", null, this.t("There is no contact information available."))) : ([
      this.contact.name && (h("section", null, h("dt", null, this.t("Name")), h("smoothly-display", { type: "text", value: Name.get(this.contact.name) }))),
      this.contact.email && (h("section", null, h("dt", null, this.t("Email")), h("ig-email-addresses", { editable: false, value: this.contact.email }))),
      this.contact.phone && (h("section", null, h("dt", null, this.t("Phone")), h("ig-phone-numbers", { editable: false, value: this.contact.phone }))),
    ]);
  }
  get element() { return getElement(this); }
};
IntergiroOrderContact.style = styleCss$a;

const sv$9 = {
  Amount: "Belopp",
  Reason: "Anledning",
  Error: "Fel",
  Status: "Status",
  Type: "Typ",
  Details: "Detaljer",
  " (failed)": " (misslyckades)",
  defer: "skicka",
  order: "beställa",
  cancel: "avbryta",
  charge: "godkänna",
  refund: "återbetala",
  settle: "utbetala",
  fail: "misslycka",
  synchronize: "synkronisera",
  "gross: ": "brutto: ",
  "net: ": "netto: ",
  "fee: ": "avgift: ",
};

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

const styleCss$9 = "*.sc-ig-order-events-h{display:-ms-flexbox;display:flex}[hidden].sc-ig-order-events-h{display:none}.sc-ig-order-events-h>span.sc-ig-order-events{-ms-flex-positive:1;flex-grow:1;padding-left:0.6em;padding-right:0.6em}ul.sc-ig-order-events{width:100%;list-style-type:none;-webkit-padding-start:0;padding-inline-start:0;margin-top:0;margin-bottom:0}summary.sc-ig-order-events{outline:none;text-align:left}dl.sc-ig-order-events{margin:8px;width:100%;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;-ms-flex-wrap:wrap;flex-wrap:wrap;max-height:3em;-ms-flex-pack:start;justify-content:flex-start}dt.sc-ig-order-events{font-weight:bold;text-align:left}dd.sc-ig-order-events{text-align:left;margin:0}";

const IntergiroOrderEvents = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
  }
  componentWillLoad() {
    this.t = create$9(this.element);
  }
  render() {
    return (h("ul", null, this.event.map(e => (h("li", null, e.type == "fail" && e.items != undefined
      ? [
        h("details", null, h("summary", null, dist$1.DateTime.localize(dist$1.DateTime.parse(e.date)), h("b", null, " ", this.t(e.original)), " ", this.t(" (failed)"), "\u2003", Item.amount(e.items), " ", this.currency), this.renderEvent(e)),
      ]
      : e.type == "fail" && e.items == undefined
        ? [
          h("details", null, h("summary", null, dist$1.DateTime.localize(dist$1.DateTime.parse(e.date)), h("b", null, " ", this.t(e.original)), " ", this.t(" (failed)")), this.renderEvent(e)),
        ]
        : e.type == "settle"
          ? [
            h("summary", null, "\u2003", dist$1.DateTime.localize(dist$1.DateTime.parse(e.date)), h("b", null, " ", this.t(e.type)), "\u2003 ", this.t("gross: "), " ", e.gross, " ", this.currency, "\u2003", this.t("fee: "), " ", e.fee, " ", this.currency, "\u2003", this.t("net: "), " ", e.net, " ", this.currency),
          ]
          : e.type != "fail" && e.items == undefined
            ? [
              h("summary", null, "\u2003", dist$1.DateTime.localize(dist$1.DateTime.parse(e.date)), h("b", null, " ", this.t(e.type))),
            ]
            : e.type != "fail" && e.items != undefined
              ? [
                h("summary", null, "\u2003", dist$1.DateTime.localize(dist$1.DateTime.parse(e.date)), h("b", null, " ", this.t(e.type)), "\u2003", Item.amount(e.items), " ", this.currency),
              ]
              : "Error")))));
  }
  renderEvent(event) {
    var _a, _b;
    let result;
    switch (event.type) {
      case "defer":
      case "deny":
      case "cancel":
      case "charge":
      case "order":
      case "pay":
      case "pend":
      case "refund":
      case "settle":
      case "synchronize":
        result = (h("dl", null, event.items
          ? [
            h("dt", null, this.t("Amount")),
            h("dd", null, Item.amount(event.items), " ", this.currency),
          ]
          : ""));
        break;
      case "fail":
        result = (h("dl", null, event.items
          ? [
            h("dt", null, this.t("Amount")),
            h("dd", null, Item.amount(event.items), " ", this.currency),
          ]
          : "", event.original ? [h("dt", null, this.t("Reason")), h("dd", null, this.t(event.original))] : "", event.error ? [h("dt", null, this.t("Error")), h("dd", null, event.error)] : "", ((_a = event.error) === null || _a === void 0 ? void 0 : _a.status) ? [h("dt", null, this.t("Status")), h("dd", null, event.error.status)] : "", ((_b = event.error) === null || _b === void 0 ? void 0 : _b.type) ? [h("dt", null, this.t("Type")), h("dd", null, event.error.type)] : "", Event.Fail.is(event) && backendFailure.is(event.error)
          ? [h("dt", null, this.t("Details")), h("dd", null, event.error.details.body.status.message)]
          : ""));
        break;
      default:
        result = h("dl", null);
    }
    return result;
  }
  get element() { return getElement(this); }
};
IntergiroOrderEvents.style = styleCss$9;

const sv$8 = {
  Qty: "Antal",
  Name: "Namn",
  Price: "Pris",
  VAT: "Moms",
  Total: "Totalt",
  Status: "Status",
};

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

const styleCss$8 = ".sc-ig-order-items-h{display:inline-block}[hidden].sc-ig-order-items-h{display:none}.sc-ig-order-items-h>table.sc-ig-order-items{table-layout:fixed;width:100%}.sc-ig-order-items-h>table.sc-ig-order-items>tr.sc-ig-order-items>th.sc-ig-order-items{text-align:left;padding-top:0.4em;padding-bottom:0.5em}.sc-ig-order-items-h>table.sc-ig-order-items>tr.sc-ig-order-items>th.wide.sc-ig-order-items{width:20%}.sc-ig-order-items-h>table.sc-ig-order-items>tr.sc-ig-order-items>th.status.sc-ig-order-items{width:19%;max-width:20em}";

const IntergiroOrderItems = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.quantityStatus = false;
  }
  componentWillLoad() {
    this.t = create$8(this.element);
  }
  handleQuantityStatus(event) {
    this.quantityStatus = true;
  }
  render() {
    const t = this.t;
    return [
      h("table", null, h("tr", null, h("th", null, this.quantityStatus ? t("Qty") : ""), h("th", { class: "wide" }, this.quantityStatus ? t("Name") : ""), h("th", null, this.quantityStatus ? t("Price") : ""), h("th", null, this.quantityStatus ? t("VAT") : ""), h("th", null, t("Total")), h("th", { class: "status" }, t("Status"))), typeof this.order.items === "number"
        ? []
        : Item.asArray(this.order.items).map((item, index) => (h("ig-order-items-quantity", { order: this.order.id, currency: this.order.currency, item: item }))), h("ig-order-items-total", { currency: this.order.currency, items: this.order.items })),
    ];
  }
  get element() { return getElement(this); }
};
IntergiroOrderItems.style = styleCss$8;

const sv$7 = {
  VAT: "moms",
};

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

const styleCss$7 = ".sc-ig-order-items-quantity-h{display:table-row;width:100%}[hidden].sc-ig-order-items-quantity-h{display:none}.sc-ig-order-items-quantity-h>td.sc-ig-order-items-quantity{vertical-align:middle;width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;padding-right:auto}.sc-ig-order-items-quantity-h>td.sc-ig-order-items-quantity>div.sc-ig-order-items-quantity{padding-right:auto;padding-left:0.15em}.sc-ig-order-items-quantity-h>td.sc-ig-order-items-quantity>div.sc-ig-order-items-quantity>ig-status-change.sc-ig-order-items-quantity{margin-right:0.3em;padding-right:0.5em;-ms-flex-negative:5;flex-shrink:5;max-width:20em;width:100%;-ms-flex-line-pack:stretch;align-content:stretch}.sc-ig-order-items-quantity-h>td.sc-ig-order-items-quantity>div.status.sc-ig-order-items-quantity{display:-ms-flexbox;display:flex;-ms-flex-line-pack:stretch;align-content:stretch;-ms-flex-wrap:nowrap;flex-wrap:nowrap}";

const IntergirOrderItemsQuantity = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.notice = createEvent(this, "notice", 7);
    this.quantityStatus = createEvent(this, "quantityStatus", 7);
  }
  componentWillLoad() {
    this.t = create$7(this.element);
  }
  async emitChangeStatus(e) {
    const response = await Connection.post(`order/${this.order}/event`, {
      type: e.detail.type,
      items: typeof e.detail.items == "number" ? e.detail.items : Object.assign(Object.assign(Object.assign({}, this.item), e.detail.items), { status: undefined }),
    });
    this.notice.emit(Error.is(response)
      ? Notice.failed(this.t("Failed to change status."))
      : Notice.succeded(this.t("Status changed.")));
  }
  sendQuantityStatus(status) {
    this.quantityStatus.emit(status);
  }
  render() {
    const t = this.t;
    this.item.quantity ? this.sendQuantityStatus(true) : "";
    return [
      this.item
        ? [
          h("td", null, h("div", null, this.item.quantity ? this.item.quantity : this.item.unit ? 1 : "", this.item.unit)),
          h("td", null, h("div", null, this.item.name)),
          h("td", null, h("div", null, this.item.quantity
            ? t("@") + (Item.amount(this.item) / (this.item.quantity ? this.item.quantity : 1)).toFixed(2)
            : "")),
          h("td", null, h("div", null, this.item.vat ? this.item.vat.toFixed(2) : "")),
          h("td", null, h("div", null, Item.amount(this.item).toFixed(2), " ", this.currency)),
          h("td", null, h("div", { class: "status" }, ["ordered", "charged", "refunded", "cancelled"]
            .map((status) => { var _a, _b; return [status, (_b = (_a = this.item.status) === null || _a === void 0 ? void 0 : _a.filter(s => s == status).length) !== null && _b !== void 0 ? _b : 0]; })
            .filter(argument => argument[1])
            .map(argument => this.item.quantity ? (h("ig-status-change", { status: argument[0], quantity: argument[1], unit: this.item.unit, onChangeStatus: (e) => this.emitChangeStatus(e) })) : (h("ig-status-change", { status: argument[0], amount: Item.amount(this.item), currency: this.currency, onChangeStatus: (e) => this.emitChangeStatus(e) }))))),
        ]
        : "",
    ];
  }
  get element() { return getElement(this); }
};
IntergirOrderItemsQuantity.style = styleCss$7;

const sv$6 = {
  "Order total": "Orderbelopp",
};

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

const styleCss$6 = ".sc-ig-order-items-total-h{display:table-row;width:100%}[hidden].sc-ig-order-items-total-h{display:none}.sc-ig-order-items-total-h>td.sc-ig-order-items-total>div.sc-ig-order-items-total{vertical-align:middle;width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;padding-top:0.2em;padding-left:0.15em;padding-right:0.15em}.sc-ig-order-items-total-h>td.sc-ig-order-items-total>div.total.sc-ig-order-items-total{border-top:solid 1px rgb(var(--smoothly-light-color));width:6em}";

const IntergirOrderItemsTotal = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
  }
  componentWillLoad() {
    this.t = create$6(this.element);
  }
  render() {
    var _a;
    const t = this.t;
    return [
      h("td", null),
      h("td", null, h("div", null, t("Order total"))),
      h("td", null),
      Item.vat(this.items) ? (h("td", null, h("div", { class: "total" }, (_a = Item.vat(this.items)) === null || _a === void 0 ? void 0 : _a.toFixed(2)))) : (h("td", null, h("div", null))),
      h("td", null, h("div", { class: "total" }, Item.amount(this.items).toFixed(2), " ", this.currency)),
      h("td", null),
    ];
  }
  get element() { return getElement(this); }
};
IntergirOrderItemsTotal.style = styleCss$6;

const sv$5 = {
  Scheme: "System",
  Number: "Nummer",
  Expires: "Giltigt t.o.m.",
  Type: "Typ",
  card: "kort",
  Method: "Metod",
  Contact: "Kontakt",
  Message: "Meddelande",
  "Open link": "Öppna länk",
  defer: "skickad",
  link: "länk",
};

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

const styleCss$5 = "*.sc-ig-order-payment-h{display:-ms-flexbox;display:flex}[hidden].sc-ig-order-payment-h{display:none}.sc-ig-order-payment-h>span.sc-ig-order-payment{-ms-flex-positive:1;flex-grow:1;padding-left:0.6em;padding-right:0.6em}ul.sc-ig-order-payment{width:100%;list-style-type:none;margin-top:0;margin-bottom:0;-webkit-padding-start:0;padding-inline-start:0}summary.sc-ig-order-payment{outline:none;text-align:left}dl.sc-ig-order-payment{margin:8px;width:100%;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;-ms-flex-wrap:wrap;flex-wrap:wrap;max-height:3em;-ms-flex-pack:start;justify-content:flex-start}dt.sc-ig-order-payment{font-weight:bold;text-align:left}dd.sc-ig-order-payment{text-align:left;margin:0}dd.icon.sc-ig-order-payment{width:-webkit-max-content;width:-moz-max-content;width:max-content;padding-top:0.5em}";

const IntergirOrderPayment = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
  }
  componentWillLoad() {
    this.t = create$5(this.element);
  }
  render() {
    const t = this.t;
    return (h("ul", null, h("li", null, this.order.payment.type == "card" ? (h("summary", null, h("dl", null, this.order.payment.type ? [h("dt", null, t("Type")), h("dd", null, t(this.order.payment.type))] : "", this.order.payment.scheme ? [h("dt", null, t("Scheme")), h("dd", null, this.order.payment.scheme)] : "", Payment.Card.is(this.order.payment)
      ? [
        h("dt", null, t("Number")),
        h("dd", null, this.order.payment.iin.substring(0, 4) +
          " " +
          this.order.payment.iin.substring(4) +
          "** **** " +
          this.order.payment.last4),
      ]
      : "", this.order.payment.expires
      ? [
        h("dt", null, t("Expires")),
        h("dd", null, this.order.payment.expires[0], "/", this.order.payment.expires[1]),
      ]
      : ""))) : this.order.payment.type == "defer" ? (h("summary", null, h("dl", null, this.order.payment.type ? [h("dt", null, t("Type")), h("dd", null, t(this.order.payment.type))] : "", this.order.payment.method ? [h("dt", null, t("Method")), h("dd", null, t(this.order.payment.method))] : "", this.order.payment.contact ? [h("dt", null, t("Contact")), h("dd", null, this.order.payment.contact)] : "", this.order.payment.message ? [h("dt", null, t("Message")), h("dd", null, this.order.payment.message)] : "", Payment.Defer.is(this.order.payment) && this.order.payment.link != undefined
      ? [
        h("dt", null),
        h("dd", { class: "icon" }, h("a", { target: "_blank", href: this.order.payment.link }, h("smoothly-icon", { toolTip: t("Open link"), name: "open" }))),
      ]
      : ""))) : ("No payment information available."))));
  }
  get element() { return getElement(this); }
};
IntergirOrderPayment.style = styleCss$5;

const sv$4 = {};

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

const styleCss$4 = ".sc-ig-orders-table-details-h{display:table-row}.sc-ig-orders-table-details-h>.sc-ig-orders-table-details:nth-child(1){border-top:solid 1px rgb(var(--smoothly-medium-shade));border-bottom:solid 1px rgb(var(--smoothly-medium-shade));background-color:rgb(var(--smoothly-dark-shade));padding-top:0.5em;padding-bottom:0.5em;padding-left:5%}";

const IntergiroOrdersTableDetails = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.opened = "";
    this.selected = false;
  }
  componentWillLoad() {
    this.t = create$4(this.element);
  }
  render() {
    let result;
    switch (this.opened) {
      case "number":
        result = (h("ig-number-details", { identifier: this.order.id, number: this.order.number, name: "order" }));
        break;
      case "contact":
        result = (h("ig-order-contact", { contact: Contact.is(this.order.customer) ? this.order.customer : undefined }));
        break;
      case "items":
        result = h("ig-order-items", { order: this.order });
        break;
      case "payment":
        result = h("ig-order-payment", { order: this.order });
        break;
      case "created":
        result = (h("ig-order-events", { event: this.order.event, currency: this.order.currency, payment: this.order.payment }));
        break;
      default:
        result = [];
        break;
    }
    return Array.isArray(result) && result.length == 0 ? result : [h("td", { colSpan: 8 }, result)];
  }
  get element() { return getElement(this); }
};
IntergiroOrdersTableDetails.style = styleCss$4;

const sv$3 = {
  Edit: "Redigera",
  Delete: "Radera",
  primary: "primär",
  cellphone: "mobiltelefon",
  landline: "fast telefon",
};

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

const styleCss$3 = ".sc-ig-phone-number-h{display:block;position:relative}[hidden].sc-ig-phone-number-h{display:none}smoothly-display.sc-ig-phone-number{border-top:1px solid rgb(var(--smoothly-medium-color));border-bottom:1px solid rgb(var(--smoothly-medium-color));padding-top:0.5em;padding-bottom:0.5em}label.sc-ig-phone-number{display:block;-webkit-margin-before:0.6em;margin-block-start:0.6em;-webkit-margin-after:0.2em;margin-block-end:0.2em;text-transform:capitalize;margin-bottom:0.2em}smoothly-popup.sc-ig-phone-number{display:none;position:absolute;right:0}.sc-ig-phone-number-h:hover smoothly-popup.sc-ig-phone-number{display:inline}smoothly-icon.sc-ig-phone-number{cursor:pointer}";

const IntergiroPhoneNumber = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.edit = createEvent(this, "edit", 7);
    this.delete = createEvent(this, "delete", 7);
    this.editable = true;
    this.type = "primary";
    this.mode = "display";
  }
  componentWillLoad() {
    this.t = create$3(this.element);
  }
  onEdit(event) {
    event.stopPropagation();
    this.value = event.detail;
    this.mode = "display";
    this.edit.emit({ type: this.type, value: this.value });
  }
  onDelete() {
    this.delete.emit(this.type);
  }
  render() {
    const t = this.t;
    return this.value.length > 0 ? (this.mode == "display" ? ([
      this.editable && (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() })))),
      h("label", null, t(this.type)),
      h("smoothly-display", { type: "phone", value: this.value }),
    ]) : (h("ig-phone-number-input", { value: this.value, onEdit: (e) => this.onEdit(e) }))) : ([]);
  }
  get element() { return getElement(this); }
};
IntergiroPhoneNumber.style = styleCss$3;

const sv$2 = {
  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$2(language) {
  return dist.create({
    sv: sv$2,
  }, language);
}

const styleCss$2 = ".sc-ig-phone-number-input-h{margin-top:0.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:0.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:0.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:0.5em;padding-top:0.5em;font-size:0.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$2(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$2;

const sv$1 = {
  Add: "Lägg till",
};

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

const styleCss$1 = ".sc-ig-phone-numbers-h{display:block}label.sc-ig-phone-numbers{font-weight:bold}smoothly-icon.sc-ig-phone-numbers{cursor:pointer;float:right;margin-top:-0.2em;visibility:hidden}ig-phone-number.sc-ig-phone-numbers{clear:both}.sc-ig-phone-numbers-h:hover smoothly-icon.sc-ig-phone-numbers{visibility:visible}";

const IntergiroPhoneNumbers = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.changed = createEvent(this, "changed", 7);
    this.editable = true;
    this.adding = false;
  }
  componentWillLoad() {
    this.t = create$1(this.element);
  }
  get types() {
    return PhoneNumbers.types.filter(type => PhoneNumbers.is(this.value) ? !this.value[type] : this.value ? type != "primary" : type);
  }
  get phoneNumbers() {
    return PhoneNumbers.is(this.value) ? Object.assign({}, this.value) : { primary: this.value };
  }
  onEdit(e) {
    const type = e.detail.type;
    delete e.detail.type;
    let result;
    if (!PhoneNumbers.is(this.value))
      result = e.detail.value;
    else {
      result = Object.assign({}, this.value);
      result[type] = e.detail.value;
    }
    this.changed.emit((this.value = result));
  }
  onDelete(e) {
    const type = e.detail;
    const result = Object.assign({}, this.phoneNumbers);
    delete result[type];
    this.changed.emit((this.value = result));
  }
  onAdd(e) {
    const type = e.detail.type;
    const value = e.detail.value;
    const result = this.phoneNumbers;
    result[type] = value;
    this.changed.emit((this.value = result));
    this.adding = false;
  }
  render() {
    return [
      h("label", null, this.label),
      this.adding ? (h("ig-phone-number-input", { onEdit: (e) => (this.adding = false), types: this.types, mode: "add", onAdd: (e) => this.onAdd(e) })) : ([]),
      this.editable && this.types.length > 0 ? (h("smoothly-icon", { name: "add-circle", toolTip: this.t("Add"), fill: "clear", size: "medium", color: "success", style: this.adding ? { display: "none" } : {}, onClick: () => (this.adding = true) })) : ([]),
      this.phoneNumbers ? (PhoneNumbers.is(this.value) ? (PhoneNumbers.map(this.value, (type, value) => [
        h("ig-phone-number", { value: value, type: type, editable: this.editable, onEdit: (e) => this.onEdit(e), onDelete: (e) => this.onDelete(e) }),
      ])) : (h("ig-phone-number", { value: this.value, editable: this.editable, onEdit: (e) => this.onEdit(e), onDelete: (e) => this.onDelete(e) }))) : ([]),
    ];
  }
  get element() { return getElement(this); }
};
IntergiroPhoneNumbers.style = styleCss$1;

const sv = {
  create: "skapad",
  order: "beställa",
  cancel: "avbryt",
  charge: "debitera",
  pay: "betala",
  refund: "återbetala",
  deny: "neka",
  pending: "väntande",
  defer: "skicka",
  Quantity: "Antal",
  Amount: "Summa",
};

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

const styleCss = ".sc-ig-status-change-h{display:inline-block}[hidden].sc-ig-status-change-h{display:none}button.sc-ig-status-change{display:block;padding:0.2em 0.3em;border:none;font-size:inherit}button.sc-ig-status-change:focus{outline:unset}content.sc-ig-status-change>*.sc-ig-status-change{text-align:center;height:2.5em;min-width:2.5em}content.sc-ig-status-change>.sc-ig-status-change:first-child{border-top-left-radius:5px;border-bottom-left-radius:5px}content.sc-ig-status-change>.sc-ig-status-change:last-child{border-top-right-radius:5px;border-bottom-right-radius:5px}#charge.sc-ig-status-change{background-color:rgb(var(--smoothly-success-color))}#cancel.sc-ig-status-change{background-color:rgb(var(--smoothly-danger-color))}#refund.sc-ig-status-change{background-color:rgb(var(--smoothly-danger-color))}#synchronize.sc-ig-status-change{background-color:rgb(var(--smoothly-dark-color))}#amount.sc-ig-status-change{min-width:6em;padding:0;background-color:rgb(var(--smoothly-dark-color))}content.sc-ig-status-change{display:-ms-flexbox;display:flex}.sc-ig-status-change-h>smoothly-popup.sc-ig-status-change{display:inline}";

const IntergiroStatusChange = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.changeStatus = createEvent(this, "changeStatus", 7);
  }
  get mode() {
    return this.amount && dist$1.Currency.is(this.currency) ? "amount" : "quantity";
  }
  componentWillLoad() {
    this.t = create(this.element);
  }
  emitChangeStatus(type) {
    var _a, _b, _c;
    const value = !((_a = this.inputElement) === null || _a === void 0 ? void 0 : _a.value)
      ? 1
      : this.mode == "quantity"
        ? Number.parseInt((_b = this.inputElement) === null || _b === void 0 ? void 0 : _b.value)
        : Number.parseFloat((_c = this.inputElement) === null || _c === void 0 ? void 0 : _c.value);
    this.changeStatus.emit({ type, items: this.mode == "quantity" ? { quantity: value } : value });
    if (this.popupElement)
      this.popupElement.visible = false;
  }
  render() {
    var _a;
    const t = this.t;
    let events;
    switch (this.status) {
      case "created":
      case "deferred":
      case "pending":
        events = [];
        break;
      case "ordered":
        events = [];
        break;
      case "charged":
      case "paid":
        events = ["refund"];
        break;
      default:
      case "denied":
      case "cancelled":
      case "refunded":
      case "synchronized":
        events = [];
        break;
    }
    return [
      events.length != 0 ? (h("smoothly-popup", { ref: (e) => (this.popupElement = e) }, h("main", null, h("ig-status", { quantity: this.quantity, unit: this.unit, status: this.status })), h("content", { slot: "popup" }, this.quantity == 1 ? ("") : this.mode == "quantity" ? (h("smoothly-select", { color: "dark", identifier: "quantity", ref: (e) => (this.inputElement = e) }, generateOptions((_a = this.quantity) !== null && _a !== void 0 ? _a : 1).map(c => (c = this.quantity ? (h("option", { value: c }, c)) : (h("option", { value: c, selected: true }, c)))))) : (h("smoothly-input", { type: "price", name: "amount", id: "amount", value: this.amount, ref: (e) => (this.inputElement = e) }, t("Amount"), " (", this.currency, ")")), events.map(event => (h("button", { onClick: () => this.emitChangeStatus(event), id: event, name: event }, h("smoothly-icon", { toolTip: t(event), name: event == "cancel"
          ? "close"
          : event == "charge"
            ? "checkmark"
            : event == "refund"
              ? "arrow-undo"
              : "", color: event == "cancel"
          ? "danger"
          : event == "charge"
            ? "success"
            : event == "refund"
              ? "danger"
              : "medium" }))))))) : (h("div", null, h("span", null, h("ig-status", { quantity: this.quantity, unit: this.unit, status: this.status })))),
    ];
  }
  get element() { return getElement(this); }
};
function generateOptions(count) {
  const result = [];
  for (let c = 1; c <= count; c++)
    result.push(c);
  return result;
}
IntergiroStatusChange.style = styleCss;

export { IntergiroEmailAddress as ig_email_address, IntergiroEmailAddresses as ig_email_addresses, IntergiroEmailInput as ig_email_input, IntergiroOrderContact as ig_order_contact, IntergiroOrderEvents as ig_order_events, IntergiroOrderItems as ig_order_items, IntergirOrderItemsQuantity as ig_order_items_quantity, IntergirOrderItemsTotal as ig_order_items_total, IntergirOrderPayment as ig_order_payment, IntergiroOrdersTableDetails as ig_orders_table_details, IntergiroPhoneNumber as ig_phone_number, IntergiroPhoneNumberInput as ig_phone_number_input, IntergiroPhoneNumbers as ig_phone_numbers, IntergiroStatusChange as ig_status_change };
