import { Component, Element, h, Prop, State } from "@stencil/core";
import * as translation from "../../../translation";
export class IntergiroMerchantsettlement {
  constructor() {
    this.view = "multiple";
    this.operation = ["authorization", "capture", "refund", "void", "all"];
  }
  componentWillLoad() {
    this.t = translation.create(this.element);
  }
  render() {
    const settlement = this.merchant.reconciliation;
    const fees = settlement.fees && Object.entries(settlement.fees);
    return [
      this.view == "single" && h("label", { color: "light" }, this.t("settlement information")),
      h("main", null,
        settlement.costPlus && (h("section", null,
          h("smoothly-display", null, this.t("cost plus")),
          h("smoothly-display", null, this.t("yes")))),
        settlement.reserves && (h("section", null,
          h("smoothly-display", null, this.t("reserves")),
          h("smoothly-display", null, settlement.reserves.percentage +
            "%" +
            (settlement.reserves.days ? " " + this.t("for") + " " + settlement.reserves.days + " " + "days." : "")))),
        this.operation.map(o => {
          const fee = fees.find(f => f[0] == o);
          return (fee && [
            h("section", null,
              h("smoothly-display", null, this.t(o)),
              h("smoothly-display-amount", { amount: typeof fee[1] == "number" ? fee[1] : undefined, currency: this.merchant.currency })),
          ]);
        })),
      h("ig-merchant-account-table", { account: this.merchant.reconciliation.account, currency: this.merchant.currency }),
      h("ig-merchant-fee-table", { currency: this.merchant.currency, fees: fees }),
    ];
  }
  static get is() { return "ig-merchant-settlement"; }
  static get encapsulation() { return "scoped"; }
  static get originalStyleUrls() { return {
    "$": ["style.css"]
  }; }
  static get styleUrls() { return {
    "$": ["style.css"]
  }; }
  static get properties() { return {
    "merchant": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "Merchant",
        "resolved": "Merchant",
        "references": {
          "Merchant": {
            "location": "import",
            "path": "@payfunc/model-acquirer"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      }
    },
    "view": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "\"single\" | \"multiple\"",
        "resolved": "\"multiple\" | \"single\"",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "view",
      "reflect": true,
      "defaultValue": "\"multiple\""
    }
  }; }
  static get states() { return {
    "t": {}
  }; }
  static get elementRef() { return "element"; }
}
