"use strict";

require("core-js/modules/es.array.iterator.js");
require("core-js/modules/es.object.define-property.js");
require("core-js/modules/es.object.get-own-property-descriptor.js");
require("core-js/modules/es.string.iterator.js");
require("core-js/modules/es.weak-map.js");
require("core-js/modules/esnext.weak-map.delete-all.js");
require("core-js/modules/esnext.weak-map.emplace.js");
require("core-js/modules/web.dom-collections.iterator.js");
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.FcrActionPhone = void 0;
require("core-js/modules/es.array.for-each.js");
require("core-js/modules/es.object.to-string.js");
require("core-js/modules/esnext.iterator.constructor.js");
require("core-js/modules/esnext.iterator.for-each.js");
require("core-js/modules/web.dom-collections.for-each.js");
var _react = _interopRequireWildcard(require("react"));
var _classnames = _interopRequireDefault(require("classnames"));
require("./index.css");
var _icon = require("../icon");
var _type = require("../icon/type");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
var FcrActionPhone = exports.FcrActionPhone = function FcrActionPhone(_ref) {
  var size = _ref.size,
    icon = _ref.icon,
    wrapperColor = _ref.wrapperColor,
    circleColor = _ref.circleColor,
    _ref$animate = _ref.animate,
    animate = _ref$animate === void 0 ? true : _ref$animate,
    iconColors = _ref.iconColors;
  var wrapperRef = (0, _react.useRef)(null);
  var circleRefs = (0, _react.useRef)([/*#__PURE__*/_react["default"].createRef(), /*#__PURE__*/_react["default"].createRef(), /*#__PURE__*/_react["default"].createRef()]);
  (0, _react.useEffect)(function () {
    if (wrapperRef.current && wrapperColor) {
      wrapperRef.current.style.setProperty('background-color', wrapperColor);
    }
    circleRefs.current.forEach(function (ref) {
      if (ref.current && circleColor) {
        ref.current.style.setProperty('background-color', circleColor);
      }
    });
  }, [wrapperColor, circleColor]);
  var wrapperCls = (0, _classnames["default"])('fcr-action-phone-wrapper', {
    'fcr-action-phone-wrapper-l': size === 'large',
    'fcr-action-phone-wrapper-m': size === 'medium',
    'fcr-action-phone-wrapper-s': size === 'small'
  });
  var iconSize = (0, _react.useMemo)(function () {
    return size === 'large' ? 48 : size === 'small' ? 18 : 32;
  }, [size]);
  var circleCls = (0, _classnames["default"])('fcr-action-phone-circle', {
    'fcr-action-phone-circle-animation': animate
  });
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
    ref: wrapperRef,
    className: wrapperCls,
    children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
      ref: circleRefs.current[0],
      className: circleCls
    }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
      ref: circleRefs.current[1],
      className: circleCls
    }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
      ref: circleRefs.current[2],
      className: circleCls
    }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
      className: "fcr-action-phone-icon",
      children: icon ? icon : /*#__PURE__*/(0, _jsxRuntime.jsx)(_icon.FcrIcon, {
        type: _type.FcrIconType.FCR_PHONECALL3,
        size: iconSize,
        colors: iconColors
      })
    })]
  });
};