'use strict';

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

const index$1 = require('./index-0b1e2673.js');
require('./_commonjsHelpers-937cd5b3.js');
const index$3 = require('./index-ab186017.js');
const index = require('./index-36cf3884.js');
const index$4 = require('./index-061d0ccd.js');
const index$2 = require('./index-8a61808f.js');

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

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

const PayfuncOrderEvents = class {
  constructor(hostRef) {
    index$1.registerInstance(this, hostRef);
  }
  componentWillLoad() {
    this.t = create(this.element);
  }
  render() {
    return (index$1.h("ul", null, this.event.map(e => (index$1.h("li", null, e.type == "fail" && e.items != undefined
      ? [
        index$1.h("details", null, index$1.h("summary", null, index$2.dist.DateTime.localize(index$2.dist.DateTime.parse(e.date)), index$1.h("b", null, " ", this.t(e.original)), " ", this.t(" (failed)"), "\u2003", index$3.Item.amount(e.items), " ", this.currency), this.renderEvent(e)),
      ]
      : e.type == "fail" && e.items == undefined
        ? [
          index$1.h("details", null, index$1.h("summary", null, index$2.dist.DateTime.localize(index$2.dist.DateTime.parse(e.date)), index$1.h("b", null, " ", this.t(e.original)), " ", this.t(" (failed)")), this.renderEvent(e)),
        ]
        : e.type == "settle"
          ? [
            index$1.h("summary", null, "\u2003", index$2.dist.DateTime.localize(index$2.dist.DateTime.parse(e.date)), index$1.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
            ? [
              index$1.h("summary", null, "\u2003", index$2.dist.DateTime.localize(index$2.dist.DateTime.parse(e.date)), index$1.h("b", null, " ", this.t(e.type))),
            ]
            : e.type != "fail" && e.items != undefined
              ? [
                index$1.h("summary", null, "\u2003", index$2.dist.DateTime.localize(index$2.dist.DateTime.parse(e.date)), index$1.h("b", null, " ", this.t(e.type)), "\u2003", index$3.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 = (index$1.h("dl", null, event.items
          ? [
            index$1.h("dt", null, this.t("Amount")),
            index$1.h("dd", null, index$3.Item.amount(event.items), " ", this.currency),
          ]
          : ""));
        break;
      case "fail":
        result = (index$1.h("dl", null, event.items
          ? [
            index$1.h("dt", null, this.t("Amount")),
            index$1.h("dd", null, index$3.Item.amount(event.items), " ", this.currency),
          ]
          : "", event.original ? [index$1.h("dt", null, this.t("Reason")), index$1.h("dd", null, this.t(event.original))] : "", event.error ? [index$1.h("dt", null, this.t("Error")), index$1.h("dd", null, event.error)] : "", ((_a = event.error) === null || _a === void 0 ? void 0 : _a.status) ? [index$1.h("dt", null, this.t("Status")), index$1.h("dd", null, event.error.status)] : "", ((_b = event.error) === null || _b === void 0 ? void 0 : _b.type) ? [index$1.h("dt", null, this.t("Type")), index$1.h("dd", null, event.error.type)] : "", index$3.Event.Fail.is(event) && index$4.dist.server.backendFailure.is(event.error)
          ? [index$1.h("dt", null, this.t("Details")), index$1.h("dd", null, event.error.details.body.status.message)]
          : ""));
        break;
      default:
        result = index$1.h("dl", null);
    }
    return result;
  }
  get element() { return index$1.getElement(this); }
};
PayfuncOrderEvents.style = styleCss;

exports.payfunc_order_events = PayfuncOrderEvents;
