import { Component, h, Listen, Prop, State, Watch } from "@stencil/core";
import { Settlement } from "@payfunc/model";
export class IntergiroPortalSettlements {
  constructor() {
    this.selected = {};
  }
  componentWillLoad() {
    this.settlementsChanged();
  }
  settlementsChanged() {
    var _a;
    if (!this.settlementsFiltered)
      this.settlementsFiltered = (_a = this.settlements) === null || _a === void 0 ? void 0 : _a.sort((a, b) => (a.period.start < b.period.start ? 1 : -1));
  }
  handleFilterChanged(event) {
    this.settlementsFiltered = event.detail;
    event.stopPropagation();
  }
  handleSelectedChanged(event) {
    this.selected = event.detail;
  }
  render() {
    return [
      h("ig-filter", { value: this.settlements, template: Settlement.template }),
      h("ig-portal-settlement-table", { settlements: this.settlementsFiltered, interchange: this.interchange }),
      h("ig-portal-settlement-footer", { color: "light", selected: this.selected, interchange: this.interchange, settlements: this.settlementsFiltered }),
    ];
  }
  static get is() { return "ig-portal-settlements"; }
  static get encapsulation() { return "scoped"; }
  static get originalStyleUrls() { return {
    "$": ["style.css"]
  }; }
  static get styleUrls() { return {
    "$": ["style.css"]
  }; }
  static get properties() { return {
    "settlements": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "Settlement[]",
        "resolved": "Settlement[]",
        "references": {
          "Settlement": {
            "location": "import",
            "path": "@payfunc/model"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      }
    },
    "interchange": {
      "type": "boolean",
      "mutable": false,
      "complexType": {
        "original": "true",
        "resolved": "boolean | undefined",
        "references": {}
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "interchange",
      "reflect": false
    }
  }; }
  static get states() { return {
    "settlementsFiltered": {},
    "selected": {}
  }; }
  static get watchers() { return [{
      "propName": "settlements",
      "methodName": "settlementsChanged"
    }]; }
  static get listeners() { return [{
      "name": "filterChanged",
      "method": "handleFilterChanged",
      "target": undefined,
      "capture": false,
      "passive": false
    }, {
      "name": "selectedChanged",
      "method": "handleSelectedChanged",
      "target": undefined,
      "capture": false,
      "passive": false
    }]; }
}
