import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
var _excluded = ["dataList", "onClick", "icon", "children", "handleMoreClick", "moreText"];
import React from 'react';
import "./index.scss";
import NoticeBarItem from "./notice-bar-item";
import arr from "../../assets/icon/teletext-list/arr.png";
var NoticeBar = function NoticeBar(_ref) {
  var dataList = _ref.dataList,
    _ref$onClick = _ref.onClick,
    onClick = _ref$onClick === void 0 ? function () {} : _ref$onClick,
    icon = _ref.icon,
    children = _ref.children,
    handleMoreClick = _ref.handleMoreClick,
    moreText = _ref.moreText,
    otherProps = _objectWithoutPropertiesLoose(_ref, _excluded);
  var _otherProps = otherProps || {};
  var stickyItems = (dataList || []).filter(function (item) {
    return (item === null || item === void 0 ? void 0 : item.isTop) === 1;
  });
  var loopItems = (dataList || []).filter(function (item) {
    return (item === null || item === void 0 ? void 0 : item.isTop) === 0;
  });
  return /*#__PURE__*/React.createElement("div", _extends({
    className: "notice-bar__panel"
  }, _otherProps), /*#__PURE__*/React.createElement("img", {
    className: "notice-bar__panel__item-img",
    src: icon,
    alt: ""
  }), /*#__PURE__*/React.createElement("div", {
    className: "notice-bar__panel__item-list"
  }, stickyItems ? stickyItems.map(function (item, index) {
    return /*#__PURE__*/React.createElement(NoticeBarItem, _extends({
      key: index,
      onClick: onClick
    }, item), children);
  }) : /*#__PURE__*/React.createElement("div", null), /*#__PURE__*/React.createElement("div", {
    className: "notice-bar__panel__item-loop"
  }, /*#__PURE__*/React.createElement("div", null, loopItems.length > 0 ? loopItems.map(function (item, index) {
    return /*#__PURE__*/React.createElement(NoticeBarItem, _extends({
      key: index,
      onClick: onClick
    }, item), children);
  }) : /*#__PURE__*/React.createElement("div", null, "No items to display")))), /*#__PURE__*/React.createElement("div", {
    className: "notice-bar__panel__item-more"
  }, moreText ? /*#__PURE__*/React.createElement("div", {
    className: "notice-bar__panel__item-more-more"
  }, /*#__PURE__*/React.createElement("span", {
    className: "notice-bar__panel__item-more-more-text",
    onClick: handleMoreClick
  }, moreText), /*#__PURE__*/React.createElement("img", {
    src: arr,
    className: "notice-bar__panel__item-more-more-img"
  })) : ''));
};
NoticeBar.displayName = 'NoticeBar';
export default NoticeBar;