import { r as registerInstance, h } from './index-07845439.js';
import { c as Schedule } from './index-e20749b7.js';
import './index-b6cf748e.js';
import './_commonjsHelpers-8fe71198.js';
import './index-265fba1f.js';
import './index-63517df5.js';

const styleCss = ".sc-ig-customer-balance-h{display:block;padding-top:.5em}[hidden].sc-ig-customer-balance-h{display:none}.sc-ig-customer-balance-h>section.sc-ig-customer-balance>ig-items-list.sc-ig-customer-balance{padding-top:1em}.sc-ig-customer-balance-h>section.sc-ig-customer-balance:first-of-type{display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between}.sc-ig-customer-balance-h>section.sc-ig-customer-balance:last-of-type{display:block}ig-future-due-dates.sc-ig-customer-balance{min-width:13em}ig-orders-table.sc-ig-customer-balance{border:1px solid rgb(var(--smoothly-medium-color));margin-top:1em}main.sc-ig-customer-balance{display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap}main.sc-ig-customer-balance>*.sc-ig-customer-balance{width:-webkit-min-content;width:-moz-min-content;width:min-content}";

const IntergiroCustomerBalance = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
  }
  componentWillLoad() {
    this.filterOrders();
  }
  filterOrders() {
    const orders = this.orders
      ? this.orders.filter(o => o.payment.type == "customer" || o.payment.type == "card" ? o.payment.charge == "balance" : false)
      : undefined;
    this.ordersFiltered = orders;
  }
  render() {
    return [
      h("section", null, h("main", null, h("ig-schedule", { schedule: this.customer.schedule }), this.customer.limit ? h("ig-customer-limit", { customer: this.customer }) : []), h("ig-future-due-dates", { dates: Schedule.calculateDueDates(this.customer.schedule, 4) })),
      h("section", null, this.customer.balance.length > 0 ? h("ig-items-list", { items: this.customer.balance }) : [], this.ordersFiltered && this.ordersFiltered.length > 0 ? (h("ig-orders-table", { display: true, orders: this.ordersFiltered })) : ([])),
    ];
  }
  static get watchers() { return {
    "orders": ["filterOrders"]
  }; }
};
IntergiroCustomerBalance.style = styleCss;

export { IntergiroCustomerBalance as ig_customer_balance };
