import { Component, h, Prop, State } from '@stencil/core';
import { getActivationNonce } from '../../utils/utils';
export class QRModal {
  constructor() {
    this.textKey = null;
  }
  async componentWillLoad() {
    this.tokenId = window.sessionStorage.getItem('tokenId');
    this.nonce = await getActivationNonce(+this.tokenId);
    if (this.tokenId)
      this.qrCodeContent = JSON.stringify({
        tokenId: this.tokenId,
        nonce: this.nonce,
        action: 0
      });
    console.log(this.qrCodeContent);
  }
  componentWillRender() {
    this.qrText = {
      skillwallet: [
        'Scan with your ',
        h("a", { href: "", key: 1, style: { textDecoration: 'underline', fontWeight: 'bold' } },
          "SkillWallet App",
          ' '),
        'to ',
        h("b", null, "Login"),
        ' to ',
        h("span", { style: { textDecoration: 'underline', fontWeight: 'bold' } }, this.community.name),
        '!',
      ],
      role: [
        'Now just scan with your ',
        h("a", { href: "", key: 1, style: { textDecoration: 'underline', fontWeight: 'bold' } },
          "SkillWallet App",
          ' '),
        ' & Verify your Membership',
      ],
    };
  }
  render() {
    return (h("div", { class: "qr-modal-window-child" },
      h("div", { class: "wallet-qr" },
        h("qr-code", { "output-mode": "SVG", contents: this.qrCodeContent })),
      h("div", { class: "wallet-text" },
        h("p", null, this.qrText[this.textKey]))));
  }
  static get is() { return "qr-modal"; }
  static get properties() { return {
    "textKey": {
      "type": "string",
      "mutable": true,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "text-key",
      "reflect": false,
      "defaultValue": "null"
    },
    "community": {
      "type": "any",
      "mutable": false,
      "complexType": {
        "original": "any",
        "resolved": "any",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "community",
      "reflect": false
    }
  }; }
  static get states() { return {
    "qrText": {},
    "nonce": {},
    "tokenId": {},
    "qrCodeContent": {}
  }; }
}
