import { Component, Element, h, Prop, State } from "@stencil/core";
import { Addresses, EmailAddresses, Name, PhoneNumbers } from "@payfunc/model";
import * as translation from "../../translation";
export class IntergiroAuthorizationHistoryVerification {
  componentWillLoad() {
    this.t = translation.create(this.element);
  }
  render() {
    var _a;
    const history = this.history;
    return (history.type == "verification" && [
      h("section", null,
        h("smoothly-display", null, this.t("status")),
        h("smoothly-display", null, this.t(history.status))),
      (history.response.challenge || history.response.method || history.status == "success") && (h("section", null,
        h("smoothly-display", null, "3D"),
        history.response.challenge ? "3D2 challenge" : history.response.method ? "3D2 method" : "3D1")),
      h("section", null,
        h("smoothly-display", null, this.t("merchant")),
        h("smoothly-display", null, history.merchant)),
      h("section", null,
        h("smoothly-display", null, this.t("number")),
        h("smoothly-display", null, history.number)),
      h("section", null,
        h("smoothly-display", null, this.t("step")),
        h("smoothly-display", null, history.step)),
      h("section", { class: typeof history.items != "number" ? "items" : "" },
        h("smoothly-display", null, this.t("items")),
        typeof history.items == "number" ? (h("smoothly-display-amount", { amount: history.items, currency: history.currency })) : (h("ig-items-list", { items: history.items, currency: history.currency }))),
      history.recurring && (h("section", null,
        h("smoothly-display", null, this.t("recurring")),
        h("smoothly-display", null, typeof history.recurring == "string" ? history.recurring : history.recurring.type))),
      history.contact && Object.entries(history.contact).length > 0 && (h("section", null,
        h("smoothly-display", null, this.t("customer")),
        history.contact.type && (h("smoothly-display", { type: "text", value: this.t("Type") + ": " + history.contact.type })),
        history.contact.name && (h("smoothly-display", { type: "text", value: this.t("name") + " " + Name.get(history.contact.name) })),
        ((_a = history.contact) === null || _a === void 0 ? void 0 : _a.email) && (h("smoothly-display", { type: "email", value: EmailAddresses.is(history.contact.email) ? history.contact.email.primary : history.contact.email })),
        history.contact.address && (h("ig-address-display", { value: Addresses.is(history.contact.address) ? history.contact.address.primary : history.contact.address })),
        history.contact.phone && (h("smoothly-display", { type: "phone", value: PhoneNumbers.is(history.contact.phone) ? history.contact.phone.primary : history.contact.phone })),
        history.contact.id && h("smoothly-display", { value: "ID: " + history.contact.id }))),
      h("ig-authorization-history-error", { history: this.history }),
      history.browser && Object.entries(history.browser).length > 0 && (h("details", null,
        h("summary", null, this.t("browser")),
        h("section", null, Object.entries(history.browser).map(value => (h("smoothly-display", { type: "text", value: value[0] + ": " + value[1] })))))),
      h("details", null,
        h("summary", null, this.t("target")),
        h("section", null,
          h("smoothly-display", null, history.target))),
      h("details", null,
        h("summary", null, this.t("response")),
        h("section", { class: "response" }, Object.entries(history.response).map(value => [
          h("smoothly-display", { style: { fontWeight: "bold", textTransform: "capitalize" }, type: "text", value: value[0] + ": " }),
          typeof value[1] == "object"
            ? Object.entries(value[1]).map(value => (h("smoothly-display", { style: { marginLeft: "1em" }, type: "text", value: value[0] + ": " + value[1] })))
            : value[1],
        ]))),
    ]);
  }
  static get is() { return "ig-authorization-history-verification"; }
  static get encapsulation() { return "scoped"; }
  static get originalStyleUrls() { return {
    "$": ["style.css"]
  }; }
  static get styleUrls() { return {
    "$": ["style.css"]
  }; }
  static get properties() { return {
    "history": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "Authorization.History",
        "resolved": "Fail | Pending | Settlement | Success",
        "references": {
          "Authorization": {
            "location": "import",
            "path": "@payfunc/model-acquirer"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      }
    }
  }; }
  static get states() { return {
    "t": {}
  }; }
  static get elementRef() { return "element"; }
}
