import _JSXStyle from "styled-jsx/style";
// Generated with util/create-component.js
import React, { forwardRef, useMemo } from "react";
import classnames from "classnames";
import { jsx as _jsx } from "react/jsx-runtime";
import { jsxs as _jsxs } from "react/jsx-runtime";
export const AspectRatio = /*#__PURE__*/forwardRef((props, ref) => {
  const {
    aspectRatio = "100%",
    internalProps = {},
    children,
    className,
    ...otherProps
  } = props;
  const handleAspectRatio = useMemo(() => {
    if (aspectRatio.includes("%")) {
      return aspectRatio;
    } else {
      const ratio = aspectRatio.split(":");
      return `${100 / parseFloat((parseFloat(ratio[0]) / parseFloat(ratio[1])).toFixed(2))}%`;
    }
  }, [aspectRatio]);
  return /*#__PURE__*/_jsxs("div", {
    ref: ref,
    ...otherProps,
    className: _JSXStyle.dynamic([["4240365932", [handleAspectRatio]]]) + " " + (otherProps && otherProps.className != null && otherProps.className || classnames("Wps-AspectRatio", className) || ""),
    children: [/*#__PURE__*/_jsx("div", { ...internalProps,
      className: _JSXStyle.dynamic([["4240365932", [handleAspectRatio]]]) + " " + (internalProps && internalProps.className != null && internalProps.className || classnames("Wps-AspectRatioInternal", className) || ""),
      children: children
    }), /*#__PURE__*/_jsx(_JSXStyle, {
      id: "4240365932",
      dynamic: [handleAspectRatio],
      children: `.Wps-AspectRatio.__jsx-style-dynamic-selector{width:100%;background:transparent;position:relative;padding-bottom:${handleAspectRatio};}.Wps-AspectRatio.__jsx-style-dynamic-selector .Wps-AspectRatioInternal.__jsx-style-dynamic-selector{position:absolute;top:0;left:0;right:0;bottom:0;background:transparent;overflow:hidden;width:100%;height:100%;}`
    })]
  });
});