import { Component, h, Event, State, Fragment, Prop } from '@stencil/core';
import { signIn } from '../../providers/auth/auth.ic';
export class IcSignin {
  constructor() {
    this.signInInProgress = false;
  }
  async signUserIn() {
    this.inProgress.emit(true);
    this.signInInProgress = true;
    await signIn({ onSuccess: this.signInSuccess, onError: this.signInError });
  }
  render() {
    return (h(Fragment, null,
      h("div", { class: "actions" }, this.renderAction()),
      this.renderTerms()));
  }
  renderAction() {
    if (this.signInInProgress) {
      return h("ion-spinner", { color: "medium" });
    }
    return (h("ion-button", { shape: "round", color: "dark", onClick: async () => await this.signUserIn() },
      h("ion-icon", { src: `${this.config.globalAssetsUrl}/icons/dfinity.svg`, "aria-label": "", "aria-hidden": true, slot: "start", lazy: true }),
      h("ion-label", null, this.i18n.sign_in.internet_identity)));
  }
  renderTerms() {
    return (h("p", { class: "ion-text-center ion-margin terms" },
      "By continuing, you are indicating that you accept our",
      ' ',
      h("a", { href: "https://deckdeckgo.com/terms", rel: "noopener norefferer", target: "_blank" },
        h("ion-label", null, this.i18n.links.terms_of_use)),
      ' ',
      "and",
      ' ',
      h("a", { href: "https://deckdeckgo.com/privacy", rel: "noopener norefferer", target: "_blank" },
        h("ion-label", null, this.i18n.links.privacy_policy)),
      "."));
  }
  static get is() { return "deckgo-ic-signin"; }
  static get originalStyleUrls() { return {
    "$": ["ic-signin.scss"]
  }; }
  static get styleUrls() { return {
    "$": ["ic-signin.css"]
  }; }
  static get properties() { return {
    "i18n": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "Record<string, Record<string, string>>",
        "resolved": "{ [x: string]: Record<string, string>; }",
        "references": {
          "Record": {
            "location": "global"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      }
    },
    "config": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "Record<string, string>",
        "resolved": "{ [x: string]: string; }",
        "references": {
          "Record": {
            "location": "global"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      }
    },
    "signInSuccess": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "() => void",
        "resolved": "() => void",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      }
    },
    "signInError": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "(err?: string) => void",
        "resolved": "(err?: string) => void",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      }
    }
  }; }
  static get states() { return {
    "signInInProgress": {}
  }; }
  static get events() { return [{
      "method": "inProgress",
      "name": "inProgress",
      "bubbles": true,
      "cancelable": true,
      "composed": true,
      "docs": {
        "tags": [],
        "text": ""
      },
      "complexType": {
        "original": "boolean",
        "resolved": "boolean",
        "references": {}
      }
    }]; }
}
