var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
  for (var prop in b || (b = {}))
    if (__hasOwnProp.call(b, prop))
      __defNormalProp(a, prop, b[prop]);
  if (__getOwnPropSymbols)
    for (var prop of __getOwnPropSymbols(b)) {
      if (__propIsEnum.call(b, prop))
        __defNormalProp(a, prop, b[prop]);
    }
  return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
import { jsx, jsxs } from "react/jsx-runtime";
import React from "react";
import { arrayOf, bool, node, oneOfType, string, number } from "prop-types";
import styled from "styled-components";
import { media } from "@gympass/yoga-helpers";
import {
  Actions,
  Title,
  PrimaryButton,
  SecondaryButton
} from "./ActionRequirementStyles";
import Text from "../../Text";
import parseDescription from "../../utils/parseDescription";
import Box from "../../Box";
const StyledActionRequirement = styled.div`
  display: flex;
  height: 100%;
  ${media.xxs`
    flex-direction: column;
  `}
  ${media.lg`
    flex-direction: row-reverse;
  `}
`;
const Content = styled.div`
  display: flex;
  flex-direction: column;
  justify-content: center;

  ${media.xxs`
    width: auto;
    margin-right: 0;
  `}

  ${media.lg`
    width: 520px;
    margin-right: 120px;
  `}
`;
const BoxIllustration = styled(Box)`
  flex-grow: 1;
  display: flex;
  justify-content: center;
  align-items: center;
`;
function isChildFromComponent(child, component) {
  return child.type.displayName === component.displayName;
}
function ActionRequirement(props) {
  const {
    title,
    description,
    children,
    checkable,
    illustration,
    list,
    titleAsTextDisplay = false,
    ariaLevelTitle = 1
  } = props;
  let primaryButton;
  let secondaryButton;
  const descriptionArray = parseDescription(description);
  function defineCompoundComponents() {
    React.Children.forEach(children, (child) => {
      if (isChildFromComponent(child, PrimaryButton))
        primaryButton = child;
      if (isChildFromComponent(child, SecondaryButton))
        secondaryButton = child;
    });
  }
  defineCompoundComponents();
  return /* @__PURE__ */ jsxs(StyledActionRequirement, __spreadProps(__spreadValues({}, props), { children: [
    illustration && /* @__PURE__ */ jsx(BoxIllustration, { "aria-hidden": true, children: illustration }),
    /* @__PURE__ */ jsxs(Content, { children: [
      titleAsTextDisplay ? /* @__PURE__ */ jsx(Text.Display2, { as: "h1", "aria-level": ariaLevelTitle, children: title }) : /* @__PURE__ */ jsx(Title, { "aria-level": ariaLevelTitle, children: title }),
      /* @__PURE__ */ jsx(Box, { display: "flex", flexDirection: "column", gap: "large", mt: "small", children: descriptionArray.map((paragraph) => /* @__PURE__ */ jsx(Text.Body1, { color: "deep", children: paragraph }, paragraph == null ? void 0 : paragraph.toString().slice(0, 10))) }),
      list && /* @__PURE__ */ jsx(Box, { mt: "large", children: list }),
      checkable && /* @__PURE__ */ jsx(Box, { mt: "xxlarge", children: checkable }),
      /* @__PURE__ */ jsxs(Actions, { mt: "xlarge", children: [
        primaryButton,
        secondaryButton
      ] })
    ] })
  ] }));
}
ActionRequirement.propTypes = {
  title: oneOfType([arrayOf(node), node]).isRequired,
  children: oneOfType([arrayOf(node), node]),
  description: oneOfType([string, arrayOf(string)]).isRequired,
  checkable: oneOfType([arrayOf(node), node]),
  illustration: oneOfType([arrayOf(node), node]),
  list: oneOfType([arrayOf(node), node]),
  titleAsTextDisplay: bool,
  ariaLevelTitle: number
};
var ActionRequirement_default = ActionRequirement;
export {
  ActionRequirement_default as default
};
