// Copyright 1999-2023. Plesk International GmbH. All rights reserved.

import classNames from 'classnames';
import React, { isValidElement, cloneElement } from 'react';
import Icon from './Icon';
import { jsx as _jsx } from "react/jsx-runtime";
export const create = function (icon) {
  let defaults = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  if (!icon) {
    return icon;
  }
  if ( /*#__PURE__*/isValidElement(icon)) {
    const {
      className,
      ...props
    } = icon.props;
    const newProps = {
      ...defaults
    };
    Object.keys(props).forEach(name => {
      if (props[name] !== null && props[name] !== undefined) {
        newProps[name] = props[name];
      }
    });
    if (defaults.className || className) {
      newProps.className = classNames(defaults.className, className);
    }
    return /*#__PURE__*/cloneElement(icon, newProps);
  }
  if (typeof icon === 'object') {
    const {
      className,
      ...props
    } = icon;
    return /*#__PURE__*/_jsx(Icon, {
      ...defaults,
      className: defaults.className || className ? classNames(defaults.className, className) : null,
      ...props
    });
  }
  return /*#__PURE__*/_jsx(Icon, {
    ...defaults,
    name: icon
  });
};