"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/Alert/Alert.tsx
var Alert_exports = {};
__export(Alert_exports, {
  Alert: () => Alert
});
module.exports = __toCommonJS(Alert_exports);
var import_icons = require("@simplybusiness/icons");
var import_dedupe4 = __toESM(require("classnames/dedupe"));

// src/components/Icon/Icon.tsx
var import_dedupe = __toESM(require("classnames/dedupe"));
var import_Icon = require("@simplybusiness/mobius/src/components/Icon/Icon.css");
var import_jsx_runtime = require("react/jsx-runtime");
var ICON_PREFIX = "mobius-icon";
var capitaliseFirstLetter = (str) => str.charAt(0).toUpperCase() + str.slice(1);
function Icon({
  ref,
  icon,
  className,
  size = "xs",
  color,
  fixedWidth,
  spin,
  spinReverse,
  title,
  ...otherProps
}) {
  if (!icon) {
    throw new Error("Must specify icon object");
  }
  const classes = (0, import_dedupe.default)(
    "mobius",
    "mobius-icon",
    `svg-inline--${ICON_PREFIX}`,
    `--size-${size}`,
    className,
    {
      [`${ICON_PREFIX}-fw`]: fixedWidth,
      [`${ICON_PREFIX}-spin`]: spin || spinReverse,
      [`${ICON_PREFIX}-spin-reverse`]: spinReverse
    }
  );
  const { iconName, width, height, svgPathData } = icon;
  const formattedIconName = iconName.split("-").join(" ");
  const defaultTitle = `${capitaliseFirstLetter(formattedIconName)} icon`;
  const titleText = title || defaultTitle;
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
    "svg",
    {
      ref,
      focusable: "false",
      "data-icon": iconName,
      className: classes,
      role: "img",
      xmlns: "http://www.w3.org/2000/svg",
      viewBox: `0 0 ${width} ${height}`,
      style: { color },
      ...otherProps,
      children: [
        /* @__PURE__ */ (0, import_jsx_runtime.jsx)("title", { children: titleText }),
        /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { fill: "currentColor", d: svgPathData })
      ]
    }
  );
}

// src/components/TextOrHTML/TextOrHTML.tsx
var import_dedupe3 = __toESM(require("classnames/dedupe"));
var import_react = require("react");

// src/components/Text/Text.tsx
var import_dedupe2 = __toESM(require("classnames/dedupe"));
var import_Text = require("@simplybusiness/mobius/src/components/Text/Text.css");
var import_jsx_runtime2 = require("react/jsx-runtime");
var getElementType = (variant, elementType) => {
  if (elementType) {
    return elementType;
  }
  if (variant && ["h1", "h2", "h3", "h4"].includes(variant)) {
    return variant;
  }
  return "p";
};
var Text = ({ ref, elementType, ...props }) => {
  const { variant, className, spacing, ...otherProps } = props;
  const Element = getElementType(variant, elementType);
  const variantType = variant || Element;
  const classes = (0, import_dedupe2.default)(
    "mobius",
    "mobius-text",
    { [`--is-${variantType}`]: variantType },
    { [`--has-line-height-${spacing}`]: spacing },
    className
  );
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Element, { ref, ...otherProps, className: classes });
};
Text.displayName = "Text";

// src/components/TextOrHTML/TextOrHTML.tsx
var import_jsx_runtime3 = require("react/jsx-runtime");
var BLOCK_TAG = /<(div|p|ul|ol|li|h[1-6]|table|tr|td|th|blockquote|pre|hr|dl|dt|dd)[\s>/]/i;
var containsBlockHTML = (text) => BLOCK_TAG.test(text);
var containsHTML = (text) => /<[a-z/]/i.test(text) || /&(?:#\d+|#x[\da-f]+|[a-z]\w*);/i.test(text);
var buildTextClasses = (textProps, htmlClassName) => {
  const { variant, elementType, spacing, className } = textProps;
  const variantType = variant || getElementType(variant, elementType);
  return (0, import_dedupe3.default)(
    "mobius",
    "mobius-text",
    { [`--is-${variantType}`]: variantType },
    { [`--has-line-height-${spacing}`]: spacing },
    className,
    htmlClassName
  );
};
var TextOrHTML = ({
  ref,
  text,
  htmlClassName,
  htmlElementType,
  textWrapper = false,
  autoDetect = false,
  ...textProps
}) => {
  const hasBlockContent = autoDetect && containsBlockHTML(text);
  const dangerousHTML = (0, import_react.useMemo)(() => ({ __html: text }), [text]);
  if (autoDetect && !hasBlockContent) {
    const { variant, spacing, elementType, className, ...domProps } = textProps;
    const Element = getElementType(variant, elementType);
    const classes = buildTextClasses(textProps, htmlClassName);
    return containsHTML(text) ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
      Element,
      {
        ref,
        ...domProps,
        className: classes,
        dangerouslySetInnerHTML: dangerousHTML
      }
    ) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Element, { ref, ...domProps, className: classes, children: text });
  }
  const DangerousComponent = htmlElementType ?? (hasBlockContent ? "div" : "span");
  const dangerousElement = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
    DangerousComponent,
    {
      className: htmlClassName,
      dangerouslySetInnerHTML: dangerousHTML
    }
  );
  if (textWrapper) {
    return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Text, { ref, ...textProps, children: dangerousElement });
  }
  return dangerousElement;
};
TextOrHTML.displayName = "TextOrHTML";

// src/components/Alert/Alert.tsx
var import_Alert = require("@simplybusiness/mobius/src/components/Alert/Alert.css");
var import_jsx_runtime4 = require("react/jsx-runtime");
function isAlertVariant(value) {
  return value === "info" || value === "success" || value === "warning" || value === "error";
}
var Alert = ({ ref, ...props }) => {
  const {
    elementType: Element = "div",
    variant: variantProp,
    show = true,
    header,
    children,
    ...otherProps
  } = props;
  if (!show) return null;
  const variant = variantProp && isAlertVariant(variantProp) ? variantProp : "info";
  const colorValue = variant === "success" ? `var(--color-valid)` : `var(--color-${variant})`;
  const classes = (0, import_dedupe4.default)(
    "mobius",
    "mobius-alert",
    {
      "--info": variant === "info",
      "--success": variant === "success",
      "--warning": variant === "warning",
      "--error": variant === "error",
      "--has-header": header
    },
    otherProps.className
  );
  const icon = {
    info: import_icons.circleInfo,
    success: import_icons.circleTick,
    warning: import_icons.warning,
    error: import_icons.error
  };
  const headerClasses = (0, import_dedupe4.default)("mobius", "mobius-alert__header");
  const iconClasses = (0, import_dedupe4.default)("mobius", "mobius-alert__icon");
  const contentClasses = (0, import_dedupe4.default)("mobius", "mobius-alert__content");
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Element, { ref, role: "alert", ...otherProps, className: classes, children: [
    /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: iconClasses, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { icon: icon[variant], color: colorValue }) }),
    /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { children: [
      header && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
        TextOrHTML,
        {
          autoDetect: true,
          htmlElementType: "span",
          className: headerClasses,
          htmlClassName: headerClasses,
          text: header
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: contentClasses, children })
    ] })
  ] });
};
Alert.displayName = "Alert";
//# sourceMappingURL=Alert.js.map
