'use strict';

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

const index$1 = require('./index-df541290.js');
const index$4 = require('./index-0a8af373.js');
require('./index-5e992066.js');
const index$3 = require('./index-c12b8888.js');
const index = require('./index-b7493032.js');
const index$2 = require('./index-3e5f1089.js');
require('./App-1e388484.js');
require('./index-0b6f1dd9.js');
require('./_commonjsHelpers-10109b76.js');
require('./index-fe328b96.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 index.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) {
    index$1.registerInstance(this, hostRef);
    this.notice = index$1.createEvent(this, "notice", 7);
    this.updateCustomers = index$1.createEvent(this, "updateCustomers", 7);
    this.opened = "";
  }
  componentWillLoad() {
    this.t = create(this.element);
  }
  async updateContact(event) {
    this.notice.emit(index$2.Notice.execute(this.t("Updating contact information..."), async () => {
      let result;
      this.customer.contact = event.detail;
      const response = await index$3.Connection.put(`customer/${this.customer.id}/contact`, this.customer.contact);
      if (index$4.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 = (index$1.h("ig-number-details", { number: this.customer.number, identifier: this.customer.id, name: "customer" }));
        break;
      case "contact":
        result = index$1.h("ig-customer-contact", { customer: this.customer });
        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.customer.subscription, customer: this.customer }));
        break;
      case "method":
        result = index$1.h("ig-customer-method", { customer: this.customer });
        break;
      case "balance":
        result = index$1.h("ig-customer-balance", { customer: this.customer, orders: this.orders });
        break;
      default:
        return "";
    }
    return index$1.h("td", { colSpan: 9 }, result);
  }
  get element() { return index$1.getElement(this); }
};
IntergiroCustomerDetails.style = styleCss;

exports.ig_customer_details = IntergiroCustomerDetails;
