'use strict';

const index = require('./index-8277cbb3.js');
const JSS = require('./JSS-8503a151.js');
const ErrorView = require('./ErrorView-ee7b0f36.js');

const style = {
  DialogContainer: {
    maxWidth: "390px !important",
  },
  Container: {
    width: "100%",
    display: "flex",
    flexDirection: "row",
    gap: "var(--sl-spacing-small)",
  },
  TextContainer: {
    display: "flex",
    gap: "var(--sl-spacing-medium)",
    flexDirection: "column",
    alignItems: "center",
  },
  ButtonContainer: {
    display: "flex",
    gap: "var(--sl-spacing-medium)",
  },
  FooterContainer: {
    textAlign: "left",
    display: "flex",
    flexDirection: "column",
    gap: "var(--sl-spacing-medium)",
  },
  CodeContainer: {
    display: "flex",
    width: "100%",
    alignItems: "center",
    justifyContent: "center",
  },
  Code: {
    width: "100%",
    height: "100%",
    maxWidth: "335px",
  },
  LoadingSkeleton: {
    "&::part(indicator)": {
      borderRadius: "0px !important",
    },
  },
};
const sheet = JSS.createStyleSheet(style);
const styleString = sheet.toString();
const vanillaStyle = `
  :host{
    display: flex;
    width: 100%;
  }
  @media (max-width: 499px) {
    :host{
      display: block;
    }

  }`;
function QrCodeView({ error, qrLink, titleText, downloadCodeText, printCodeText, errorHeaderText, errorDescriptionText, createDownloadable, createPrintable, hideTitle, alignment, loading, }) {
  const codeAlignment = alignment === "left"
    ? "flex-start"
    : alignment === "right"
      ? "flex-end"
      : "center";
  const getCodeContent = (error, qrLink, loading) => {
    if (error) {
      return (index.h(ErrorView.ErrorView, { loadingErrorAlertDescription: errorHeaderText, loadingErrorAlertHeader: errorDescriptionText }));
    }
    else if (loading) {
      return index.h("sqm-skeleton", { height: "100px", width: "100px" });
    }
    else if (qrLink) {
      return (index.h("svg", { width: "100", height: "100" },
        index.h("image", { href: qrLink, width: "100", height: "100" })));
    }
    return null;
  };
  const codeContent = getCodeContent(error, qrLink, loading);
  return (index.h("div", { class: sheet.classes.Container, style: { justifyContent: codeAlignment }, part: "sqm-base" },
    index.h("style", null, vanillaStyle),
    index.h("style", null, styleString),
    index.h("div", { class: sheet.classes.TextContainer, style: { alignItems: codeAlignment } },
      !hideTitle && index.h("span", { part: "sqm-title" }, titleText),
      codeContent,
      index.h("div", { class: sheet.classes.ButtonContainer },
        index.h("sl-button", { loading: loading, size: "small", exportparts: "base: primarybutton-base", type: "primary", onClick: createDownloadable }, downloadCodeText),
        index.h("sl-button", { loading: loading, size: "small", exportparts: "base: secondarybutton-base", type: "text", onClick: createPrintable }, printCodeText)))));
}

exports.QrCodeView = QrCodeView;
