import { r as registerInstance, j as createEvent, h, g as getElement } from './index-aeac5cad.js';
import './App-418c0118.js';
import './_commonjsHelpers-91fffb88.js';
import { N as Notice } from './index-4920b0b3.js';
import './index-66cd4113.js';
import { C as Connection } from './index-df45deab.js';
import { d as dist } from './index-fdd60c34.js';
import { d as dist$1 } from './index-909faba2.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 dist.create({
    sv,
  }, language);
}

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

const PayfuncAccountDetails = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.notice = createEvent(this, "notice", 7);
    this.updateAccounts = createEvent(this, "updateAccounts", 7);
    this.opened = "";
  }
  componentWillLoad() {
    this.t = create(this.element);
  }
  async updateCustomer(event) {
    this.notice.emit(Notice.execute(this.t("Updating customer information..."), async () => {
      let result;
      this.account.customer = event.detail;
      const response = await Connection.put(`account/${this.account.id}/customer`, this.account.customer);
      if (dist$1.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 = (h("payfunc-number-details", { number: this.account.number, identifier: this.account.id, name: "account" }));
        break;
      case "customer":
        result = h("payfunc-account-customer", { account: this.account });
        break;
      case "order":
        result = h("payfunc-orders-table", { orders: this.orders, display: true, receipt: this.whitelist });
        break;
      case "subscription":
        result = (h("payfunc-subscription-table", { subscriptions: this.account.subscription, account: this.account }));
        break;
      case "method":
        result = h("payfunc-account-method", { account: this.account });
        break;
      case "balance":
        result = h("payfunc-account-balance", { account: this.account, orders: this.orders });
        break;
      default:
        return "";
    }
    return h("td", { colSpan: 9 }, result);
  }
  get element() { return getElement(this); }
};
PayfuncAccountDetails.style = styleCss;

export { PayfuncAccountDetails as payfunc_account_details };
