import { h } from "@stencil/core";
import { intl } from "../../global/global";
import { AuthColumn, AuthWrapper } from "../../global/mixins";
import { createStyleSheet } from "../../styling/JSS";
import { TextSpanView } from "../sqm-text-span/sqm-text-span-view";
const style = {
  Wrapper: AuthWrapper,
  Column: { ...AuthColumn },
  ButtonLink: {
    fontSize: "14px",
    color: "var(--sl-color-primary-500)",
    display: "inline-block !important",
    "&:hover": {
      cursor: "pointer",
      textDecoration: "underline",
    },
  },
  ButtonLinkLoading: {
    fontSize: "14px",
    color: "var(--sqm-text-subdued)",
    opacity: "0.6",
    display: "inline-block !important",
    textDecoration: "underline",
    "&:hover": {
      cursor: "not-allowed",
    },
  },
};
const vanillaStyle = `
:host {
  display: block;
}
:host([hidden]): {
  display: none;
}
`;
const sheet = createStyleSheet(style);
const styleString = sheet.toString();
export function PortalEmailVerificationView(props) {
  const { states, callbacks, content: { email, verifyMessage, emailVerificationHeader, resendEmailButtonText, verificationStatusMessage, verificationLoadingMessage, verificationResentMessage, }, } = props;
  return (h("div", { class: sheet.classes.Wrapper },
    h("style", { type: "text/css" },
      vanillaStyle,
      styleString),
    h(TextSpanView, { type: "h3" }, emailVerificationHeader),
    h("sl-form", { class: sheet.classes.Column, "onSl-submit": callbacks.submit },
      props.states.error && (h("sqm-form-message", { type: "error", exportparts: "erroralert-icon" },
        h("div", { part: "erroralert-text" }, props.states.error))),
      props.states.success && (h("sqm-form-message", { type: "success", exportparts: "successalert-icon" },
        h("div", { part: "successalert-text" }, verificationResentMessage))),
      h(TextSpanView, { type: "p" }, intl.formatMessage({
        id: "verifyMessage",
        defaultMessage: verifyMessage,
      }, {
        email: (h("span", { style: { fontWeight: "var(--sl-font-weight-semibold)" } }, email)),
      })),
      h("p", { style: { color: "var(--sqm-text-subdued)", fontSize: "14px" } }, intl.formatMessage({
        id: `verificationStatus`,
        defaultMessage: states.loadingVerification
          ? verificationLoadingMessage + " {countdown}"
          : verificationStatusMessage,
      }, {
        countdown: states.loadingVerification ? (h("sl-spinner", null)) : (states.countdown),
      })),
      h("sl-button", { type: "primary", exportparts: "base: primarybutton-base", onClick: callbacks.submit, loading: states.loading }, resendEmailButtonText))));
}
