import { withHooks } from "@saasquatch/stencil-hooks";
import { Component, h, Host, Method, Prop } from "@stencil/core";
import { useRequestRerender } from "../../../tables/re-render";
/**
 * @uiName Referral Table User Column
 * @validParents ["sqm-referral-table"]
 * @exampleGroup Referrals
 * @example Referral Table User Column - <sqm-referral-table-user-column column-title="Customer" anonymous-user="Your Friend" deleted-user="Deleted User"></sqm-referral-table-user-column>
 */
export class ReferralTableUserColumn {
  constructor() {
    /**
     * @uiName User column title
     */
    this.columnTitle = "Customer";
    /**
     * Name displayed for unknown users
     *
     * @uiName Anonymous user text
     */
    this.anonymousUser = "Your Friend";
    /**
     * Name displayed for deleted users
     *
     * @uiName Deleted user text
     */
    this.deletedUser = "Deleted User";
    withHooks(this);
  }
  disconnectedCallback() { }
  async renderCell(data) {
    var _a, _b, _c, _d, _e, _f, _g, _h;
    let name;
    if (!(data === null || data === void 0 ? void 0 : data.referredUser) && !(data === null || data === void 0 ? void 0 : data.referrerUser)) {
      name = this.deletedUser;
    }
    else if (!((_a = data === null || data === void 0 ? void 0 : data.referredUser) === null || _a === void 0 ? void 0 : _a.firstName) &&
      !((_b = data === null || data === void 0 ? void 0 : data.referredUser) === null || _b === void 0 ? void 0 : _b.lastName) &&
      !((_c = data === null || data === void 0 ? void 0 : data.referrerUser) === null || _c === void 0 ? void 0 : _c.firstName) &&
      !((_d = data === null || data === void 0 ? void 0 : data.referrerUser) === null || _d === void 0 ? void 0 : _d.lastName)) {
      name = this.anonymousUser;
    }
    else if (data === null || data === void 0 ? void 0 : data.referrerUser) {
      name = `${(_e = data === null || data === void 0 ? void 0 : data.referrerUser) === null || _e === void 0 ? void 0 : _e.firstName} ${(_f = data === null || data === void 0 ? void 0 : data.referrerUser) === null || _f === void 0 ? void 0 : _f.lastName}`;
    }
    else {
      name = `${(_g = data === null || data === void 0 ? void 0 : data.referredUser) === null || _g === void 0 ? void 0 : _g.firstName} ${(_h = data === null || data === void 0 ? void 0 : data.referredUser) === null || _h === void 0 ? void 0 : _h.lastName}`;
    }
    return (h("sqm-referral-table-user-cell", { name: name }));
  }
  async renderLabel() {
    return this.columnTitle;
  }
  async renderReferrerCell(data) {
    var _a, _b, _c, _d;
    let name;
    if (!data) {
      name = this.deletedUser;
    }
    else if (!((_a = data === null || data === void 0 ? void 0 : data.referrerUser) === null || _a === void 0 ? void 0 : _a.firstName) && !((_b = data.referrerUser) === null || _b === void 0 ? void 0 : _b.lastName)) {
      name = this.anonymousUser;
    }
    else {
      name = `${(_c = data === null || data === void 0 ? void 0 : data.referrerUser) === null || _c === void 0 ? void 0 : _c.firstName} ${(_d = data === null || data === void 0 ? void 0 : data.referrerUser) === null || _d === void 0 ? void 0 : _d.lastName}`;
    }
    return (h("sqm-referral-table-user-cell", { name: name }));
  }
  render() {
    useRequestRerender([
      this.deletedUser,
      this.anonymousUser,
      this.columnTitle,
    ]);
    return h(Host, { style: { display: "none" } });
  }
  static get is() { return "sqm-referral-table-user-column"; }
  static get encapsulation() { return "shadow"; }
  static get properties() { return {
    "columnTitle": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "User column title",
            "name": "uiName"
          }],
        "text": ""
      },
      "attribute": "column-title",
      "reflect": false,
      "defaultValue": "\"Customer\""
    },
    "anonymousUser": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Anonymous user text",
            "name": "uiName"
          }],
        "text": "Name displayed for unknown users"
      },
      "attribute": "anonymous-user",
      "reflect": false,
      "defaultValue": "\"Your Friend\""
    },
    "deletedUser": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Deleted user text",
            "name": "uiName"
          }],
        "text": "Name displayed for deleted users"
      },
      "attribute": "deleted-user",
      "reflect": false,
      "defaultValue": "\"Deleted User\""
    }
  }; }
  static get methods() { return {
    "renderCell": {
      "complexType": {
        "signature": "(data: Referral) => Promise<any>",
        "parameters": [{
            "tags": [],
            "text": ""
          }],
        "references": {
          "Promise": {
            "location": "global"
          },
          "Referral": {
            "location": "import",
            "path": "../../../saasquatch"
          }
        },
        "return": "Promise<any>"
      },
      "docs": {
        "text": "",
        "tags": []
      }
    },
    "renderLabel": {
      "complexType": {
        "signature": "() => Promise<string>",
        "parameters": [],
        "references": {
          "Promise": {
            "location": "global"
          }
        },
        "return": "Promise<string>"
      },
      "docs": {
        "text": "",
        "tags": []
      }
    },
    "renderReferrerCell": {
      "complexType": {
        "signature": "(data: Referrer) => Promise<any>",
        "parameters": [{
            "tags": [],
            "text": ""
          }],
        "references": {
          "Promise": {
            "location": "global"
          },
          "Referrer": {
            "location": "import",
            "path": "../../../saasquatch"
          }
        },
        "return": "Promise<any>"
      },
      "docs": {
        "text": "",
        "tags": []
      }
    }
  }; }
}
