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

const sv = {
  Total: "Totalt",
  VAT: "moms",
  Quantity: "Antal",
  Name: "Namn",
  Unit: "Enhet",
  Price: "Pris",
};

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

const styleCss = ".sc-ig-items-list-h{display:block}[hidden].sc-ig-items-list-h{display:none}.sc-ig-items-list-h>li.sc-ig-items-list{display:-ms-flexbox;display:flex;-ms-flex-align:stretch;align-items:stretch}.sc-ig-items-list-h>li.sc-ig-items-list>*.sc-ig-items-list:first-child{overflow:hidden;text-overflow:ellipsis}.sc-ig-items-list-h>li.sc-ig-items-list>*.sc-ig-items-list:last-child{margin-left:auto}.sc-ig-items-list-h>li.total.sc-ig-items-list{border-top:solid 1px rgb(var(--smoothly-color-contrast));margin-top:.2em;padding-top:.2em;font-weight:600}.sc-ig-items-list-h>li.vat.sc-ig-items-list{font-size:85%}[editable].sc-ig-items-list-h>li.total.sc-ig-items-list,[editable].sc-ig-items-list-h>li.vat.sc-ig-items-list{margin-right:1em}";

const IntergiroItemsList = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.changed = createEvent(this, "changed", 7);
    this.editable = false;
  }
  componentWillLoad() {
    this.t = create(this.element);
  }
  edited(e, index) {
    const items = this.items;
    if (index && Array.isArray(items)) {
      items[index] = e.detail;
      this.items = [...items];
    }
    else
      this.items = e.detail;
    this.changed.emit(this.items);
  }
  render() {
    const t = this.t;
    const vat = Item.vat(this.items);
    return [
      Array.isArray(this.items) ? (this.items.map((item, index) => (h("ig-item", { onEdit: (e) => this.edited(e, index), editable: this.editable, item: item, currency: this.currency })))) : (h("ig-item", { onEdit: (e) => this.edited(e), editable: this.editable, item: this.items, currency: this.currency })),
      h("li", { class: "total" }, h("span", null, t("Total")), h("smoothly-display", { type: "price", value: Item.amount(this.items), currency: this.currency })),
      vat != undefined ? (h("li", { class: "vat" }, h("span", null, t("VAT")), h("smoothly-display", { type: "price", value: vat, currency: this.currency }))) : (""),
    ];
  }
  get element() { return getElement(this); }
};
IntergiroItemsList.style = styleCss;

export { IntergiroItemsList as ig_items_list };
