import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
import "core-js/modules/web.timers.js";
import { useEffect, useState } from 'react';
import { FcrIcon } from '../icon';
import { FcrIconType } from '../icon/type';
import './index.css';
import { jsx as _jsx } from "react/jsx-runtime";
export var FcrIconFrame = function FcrIconFrame(props) {
  var _props$frameIcons = props.frameIcons,
    frameIcons = _props$frameIcons === void 0 ? [] : _props$frameIcons,
    _props$size = props.size,
    size = _props$size === void 0 ? 24 : _props$size,
    _props$iconColors = props.iconColors,
    iconColors = _props$iconColors === void 0 ? {
      iconPrimary: 'var(--fcr_web_ui_scene_mainicon1)'
    } : _props$iconColors;
  var _useState = useState(frameIcons.length ? frameIcons[0] : FcrIconType.FCR_NOTICE),
    _useState2 = _slicedToArray(_useState, 2),
    icon = _useState2[0],
    setIcon = _useState2[1];
  useEffect(function () {
    if (frameIcons.length === 0) return;
    var timer = setInterval(function () {
      setIcon(frameIcons[Math.floor(Math.random() * frameIcons.length)]);
    }, 500);
    return function () {
      return timer && clearInterval(timer);
    };
  }, []);
  return /*#__PURE__*/_jsx(FcrIcon, {
    type: icon,
    size: size,
    colors: iconColors
  });
};