'use strict';

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

const index$1 = require('./index-df541290.js');
const index$4 = require('./index-0a8af373.js');
require('./index-2f460f13.js');
const index$3 = require('./index-07607ed6.js');
const index = require('./index-aa81d689.js');
const index$2 = require('./index-50f629f5.js');
require('./App-1e388484.js');
require('./index-e4cf4aa6.js');
require('./_commonjsHelpers-5bbc2693.js');

const sv = {
  "Failed to update customer information.": "Kunde inte uppdatera kundinformation.",
  "Updated customer information.": "Kundinformation uppdaterad.",
  "Updating customer information...": "Uppdaterar kundinformation...",
};

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

const styleCss = ".sc-ig-account-details-h{display:table-row}.sc-ig-account-details-h>td.sc-ig-account-details{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:0.5em}ig-subscription-table.sc-ig-account-details,ig-orders-table.sc-ig-account-details{margin:auto;width:90%;border:solid 1px rgb(var(--smoothly-medium-shade))}ig-account-customer.sc-ig-account-details{max-width:70em;margin:auto;padding:1em;padding-left:4.5em}ig-account-balance.sc-ig-account-details{width:75%;margin:auto}";

const IntergiroAccountDetails = class {
  constructor(hostRef) {
    index$1.registerInstance(this, hostRef);
    this.notice = index$1.createEvent(this, "notice", 7);
    this.updateAccounts = index$1.createEvent(this, "updateAccounts", 7);
    this.opened = "";
  }
  componentWillLoad() {
    this.t = create(this.element);
  }
  async updateCustomer(event) {
    this.notice.emit(index$2.Notice.execute(this.t("Updating customer information..."), async () => {
      let result;
      this.account.customer = event.detail;
      const response = await index$3.Connection.put(`account/${this.account.id}/customer`, this.account.customer);
      if (index$4.Error.is(response))
        result = [false, this.t("Failed to update customer information.")];
      else {
        this.updateAccounts.emit();
        result = [true, this.t("Updated customer information.")];
      }
      return result;
    }));
  }
  render() {
    let result;
    switch (this.opened) {
      case "number":
        result = (index$1.h("ig-number-details", { number: this.account.number, identifier: this.account.id, name: "account" }));
        break;
      case "customer":
        result = index$1.h("ig-account-customer", { account: this.account });
        break;
      case "order":
        result = index$1.h("ig-orders-table", { orders: this.orders, display: true, receipt: this.whitelist });
        break;
      case "subscription":
        result = (index$1.h("ig-subscription-table", { subscriptions: this.account.subscription, account: this.account }));
        break;
      case "method":
        result = index$1.h("ig-account-method", { account: this.account });
        break;
      case "balance":
        result = index$1.h("ig-account-balance", { account: this.account, orders: this.orders });
        break;
      default:
        return "";
    }
    return index$1.h("td", { colSpan: 9 }, result);
  }
  get element() { return index$1.getElement(this); }
};
IntergiroAccountDetails.style = styleCss;

exports.ig_account_details = IntergiroAccountDetails;
