import { Component, Element, Event, h, Listen, Prop, State } from "@stencil/core";
import * as translation from "./translation";
export class IntergiroPortalSettlement {
  constructor() {
    this.opened = false;
  }
  componentWillLoad() {
    this.t = translation.create(this.element);
  }
  select(e) {
    this.settlementSelected.emit({ settlement: this.settlement, checked: !this.selected });
    e.stopPropagation();
    e.preventDefault();
  }
  componentDidLoad() {
    const columns = this.element.querySelectorAll("td:not(.checkbox)");
    const handle = (e) => {
      this.opened = !this.opened;
      this.viewOrders.emit(this.settlement.reference);
      e.stopPropagation();
      e.preventDefault();
    };
    for (let i = 0; i < columns.length; i++)
      columns[i].addEventListener("click", handle);
  }
  render() {
    var _a;
    return [
      h("td", { class: "checkbox" },
        h("smoothly-checkbox", { selected: this.selected })),
      h("td", null, this.settlement.reference),
      h("td", null, this.settlement.period.start),
      h("td", null, this.settlement.period.end),
      h("td", null, (_a = this.settlement.payout) !== null && _a !== void 0 ? _a : this.t("unknown")),
      h("td", { class: "right" },
        h("smoothly-display-amount", { amount: this.settlement.gross, currency: this.settlement.currency })),
      h("td", { class: "right" },
        h("smoothly-display-amount", { amount: typeof this.settlement.fee == "object" ? this.settlement.fee.total : this.settlement.fee, currency: this.settlement.currency })),
      this.interchange && (h("td", { class: "right" },
        h("smoothly-display-amount", { amount: typeof this.settlement.fee == "object" ? this.settlement.fee.scheme : 0, currency: this.settlement.currency }))),
      h("td", { class: "right" },
        h("smoothly-display-amount", { amount: this.settlement.net, currency: this.settlement.currency })),
    ];
  }
  static get is() { return "ig-portal-settlement"; }
  static get encapsulation() { return "scoped"; }
  static get originalStyleUrls() { return {
    "$": ["style.css"]
  }; }
  static get styleUrls() { return {
    "$": ["style.css"]
  }; }
  static get properties() { return {
    "settlement": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "Settlement",
        "resolved": "Settlement",
        "references": {
          "Settlement": {
            "location": "import",
            "path": "@payfunc/model"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      }
    },
    "selected": {
      "type": "boolean",
      "mutable": true,
      "complexType": {
        "original": "boolean",
        "resolved": "boolean | undefined",
        "references": {}
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "selected",
      "reflect": true
    },
    "interchange": {
      "type": "boolean",
      "mutable": false,
      "complexType": {
        "original": "boolean",
        "resolved": "boolean | undefined",
        "references": {}
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "interchange",
      "reflect": false
    },
    "opened": {
      "type": "boolean",
      "mutable": false,
      "complexType": {
        "original": "boolean",
        "resolved": "boolean",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "opened",
      "reflect": true,
      "defaultValue": "false"
    }
  }; }
  static get states() { return {
    "t": {}
  }; }
  static get events() { return [{
      "method": "settlementSelected",
      "name": "settlementSelected",
      "bubbles": true,
      "cancelable": true,
      "composed": true,
      "docs": {
        "tags": [],
        "text": ""
      },
      "complexType": {
        "original": "any",
        "resolved": "any",
        "references": {}
      }
    }, {
      "method": "viewOrders",
      "name": "viewOrders",
      "bubbles": true,
      "cancelable": true,
      "composed": true,
      "docs": {
        "tags": [],
        "text": ""
      },
      "complexType": {
        "original": "any",
        "resolved": "any",
        "references": {}
      }
    }]; }
  static get elementRef() { return "element"; }
  static get listeners() { return [{
      "name": "checked",
      "method": "select",
      "target": undefined,
      "capture": false,
      "passive": false
    }]; }
}
