import { Host, h } from "@stencil/core";
import { watchBlockNumber, getAccount } from "@wagmi/core";
import state from "../../stores/wallet";
export class NKIsHolder {
  constructor() {
    this.isHolder = false;
    this.tokenId = undefined;
  }
  componentWillLoad() {
    this.disconnect = watchBlockNumber({ listen: true }, async () => {
      const account = getAccount();
      if (this.tokenId) {
        this.isHolder =
          (await state.diamond.base.ownerOf(this.tokenId)) === account.address;
      }
      else {
        this.isHolder =
          (await state.diamond.base.balanceOf(account.address)).toNumber() > 0;
      }
    });
  }
  disconnectedCallback() {
    this.disconnect();
  }
  render() {
    return h(Host, null, this.isHolder ? h("slot", null) : null);
  }
  static get is() { return "nk-is-holder"; }
  static get encapsulation() { return "shadow"; }
  static get properties() {
    return {
      "tokenId": {
        "type": "string",
        "mutable": false,
        "complexType": {
          "original": "string",
          "resolved": "string",
          "references": {}
        },
        "required": false,
        "optional": true,
        "docs": {
          "tags": [],
          "text": "Holding a specific Token ID"
        },
        "attribute": "token-id",
        "reflect": false
      }
    };
  }
  static get states() {
    return {
      "isHolder": {}
    };
  }
}
//# sourceMappingURL=nk-is-holder.js.map
