import "core-js/modules/es.symbol.js";
import "core-js/modules/es.array.filter.js";
import "core-js/modules/es.array.for-each.js";
import "core-js/modules/es.array.push.js";
import "core-js/modules/es.object.define-properties.js";
import "core-js/modules/es.object.define-property.js";
import "core-js/modules/es.object.get-own-property-descriptor.js";
import "core-js/modules/es.object.get-own-property-descriptors.js";
import "core-js/modules/es.object.keys.js";
import "core-js/modules/es.object.to-string.js";
import "core-js/modules/esnext.iterator.constructor.js";
import "core-js/modules/esnext.iterator.filter.js";
import "core-js/modules/esnext.iterator.for-each.js";
import "core-js/modules/web.dom-collections.for-each.js";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
import React, { useEffect, useState } from 'react';
import { TextBubble } from '../text-bubble';
import { IconText } from '../icon-text';
import { useI18n } from '../../i18n';
import { FcrIconType } from '../icon/type';
import { FcrIcon } from '../icon';
import './index.css';
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
export var MAX_SELECT_CNT = 50;
export var MultiSelect = function MultiSelect(_ref) {
  var onCancel = _ref.onCancel,
    onConfirm = _ref.onConfirm,
    _ref$selectCnt = _ref.selectCnt,
    selectCnt = _ref$selectCnt === void 0 ? 0 : _ref$selectCnt;
  var t = useI18n();
  var _useState = useState(false),
    _useState2 = _slicedToArray(_useState, 2),
    tipsVisible = _useState2[0],
    setTipsVisible = _useState2[1];
  useEffect(function () {
    if (selectCnt >= MAX_SELECT_CNT) setTipsVisible(true);else {
      setTipsVisible(false);
    }
  }, [selectCnt]);
  return /*#__PURE__*/_jsxs("div", {
    className: "fcr-multi-select",
    style: _objectSpread({}, tipsVisible ? {
      padding: '8px 0 16px'
    } : {}),
    children: [tipsVisible && /*#__PURE__*/_jsx("div", {
      className: "fcr-multi-select-tips",
      children: t('fmt_chat_toast_select_more_error')
    }), /*#__PURE__*/_jsx(TextBubble, {
      txt: /*#__PURE__*/_jsxs("div", {
        className: "fcr-multi-select-content",
        onClick: function onClick() {
          if (!selectCnt) return;
          onConfirm && onConfirm();
        },
        children: [/*#__PURE__*/_jsx(TextBubble, {
          styles: {
            cursor: selectCnt > 0 ? 'pointer' : 'not-allowed',
            paddingRight: 60
          },
          lineHeight: "small",
          txt: /*#__PURE__*/_jsx("div", {
            className: "fcr-select-actions",
            children: /*#__PURE__*/_jsx(IconText, {
              fontSize: "medium",
              txt: t('fmt_meetingInfo_window_info_meetingID_copy'),
              icon: FcrIconType.FCR_MOBILE_DUPLICATE,
              colors: {
                iconPrimary: 'var(--fcr_ui_scene_icontext1)'
              }
            })
          })
        }), /*#__PURE__*/_jsx(TextBubble, {
          styles: {
            width: 36,
            height: 36,
            cursor: 'pointer',
            position: 'absolute',
            right: 0
          },
          type: "white",
          txt: /*#__PURE__*/_jsx("div", {
            onClick: function onClick(event) {
              event.stopPropagation();
              onCancel && onCancel();
            },
            children: /*#__PURE__*/_jsx(FcrIcon, {
              size: 20,
              type: FcrIconType.FCR_CLOSE,
              colors: {
                iconPrimary: 'var(--fcr_ui_scene_icontext1)'
              }
            })
          })
        })]
      })
    })]
  });
};