import { Component, Element, h, Prop, State } from "@stencil/core";
import { Customer } from "@payfunc/model";
import * as translation from "./translation";
export class IntergiroCustomerFooter {
  componentWillLoad() {
    this.t = translation.create(this.element);
  }
  render() {
    var _a;
    const [active, created, pending, suspended] = this.customers
      ? this.customers.reduce(([a, c, p, s], customer) => {
        var _a, _b;
        const status = (_a = customer.status) !== null && _a !== void 0 ? _a : Customer.Status.getStatus(customer, this.orders ? (_b = this.orders[customer.id]) === null || _b === void 0 ? void 0 : _b.slice(0, 1).shift() : undefined);
        return status == "active"
          ? [++a, c, p, s]
          : status == "created"
            ? [a, ++c, p, s]
            : status == "pending"
              ? [a, c, ++p, s]
              : [a, c, p, ++s];
      }, [0, 0, 0, 0])
      : [0, 0, 0, 0];
    return (h("footer", null,
      h("td", null,
        h("span", null, this.t("total count: ")),
        h("span", null, this.customers ? (_a = this.customers) === null || _a === void 0 ? void 0 : _a.length : 0)),
      h("td", null,
        h("span", null, this.t("active: ")),
        h("span", null, active)),
      h("td", null,
        h("span", null, this.t("created: ")),
        h("span", null, created)),
      h("td", null,
        h("span", null, this.t("pending: ")),
        h("span", null, pending)),
      h("td", null,
        h("span", null, this.t("suspended: ")),
        h("span", null, suspended))));
  }
  static get is() { return "ig-customers-footer"; }
  static get encapsulation() { return "scoped"; }
  static get originalStyleUrls() { return {
    "$": ["style.css"]
  }; }
  static get styleUrls() { return {
    "$": ["style.css"]
  }; }
  static get properties() { return {
    "customers": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "Customer[]",
        "resolved": "Customer[]",
        "references": {
          "Customer": {
            "location": "import",
            "path": "@payfunc/model"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      }
    },
    "orders": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "{ [id: string]: Order[] | undefined }",
        "resolved": "undefined | { [id: string]: Order[] | undefined; }",
        "references": {
          "Order": {
            "location": "import",
            "path": "@payfunc/model"
          }
        }
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [],
        "text": ""
      }
    }
  }; }
  static get states() { return {
    "t": {}
  }; }
  static get elementRef() { return "element"; }
}
