import { r as registerInstance, j as createEvent, h, g as getElement } from './index-07845439.js';
import { E as Error } from './index-38089f62.js';
import './index-cd3eb450.js';
import { C as Connection } from './index-e20749b7.js';
import { d as dist } from './index-63517df5.js';
import { N as Notice } from './index-f068b00b.js';
import './App-15d9fce3.js';
import './index-b6cf748e.js';
import './_commonjsHelpers-8fe71198.js';
import './index-265fba1f.js';

const sv = {
  "Failed to update contact information.": "Kunde inte uppdatera kontaktinformation.",
  "Updated contact information.": "Kontaktinformation uppdaterad.",
  "Updating contact information...": "Uppdaterar kontaktinformation...",
};

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

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

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

export { IntergiroCustomerDetails as ig_customer_details };
