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.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 _slicedToArray from "@babel/runtime/helpers/slicedToArray";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
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 "core-js/modules/es.array.push.js";
import { useEffect } from 'react';
import useFcrNotification, { NOTIFICATION_ROOT_CLASS_NAME } from '.';
import { FcrButton } from '../button';
import { FcrIcon } from '../icon';
import { FcrIconType } from '../icon/type';
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
var meta = {
  title: 'Components/Notification',
  tags: ['autodocs'],
  argTypes: {
    rootConfig: {
      type: 'NotificationConfig',
      description: 'Configuration for the notification root',
      defaultValue: {
        stack: true
      }
    }
  },
  args: {
    rootConfig: {
      stack: true
    }
  }
};
var key = 1;
var keys = [];
var openNotification = function openNotification(notification) {
  var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  keys.push(key);
  notification.open(_objectSpread(_objectSpread({
    title: '等候室' + key,
    message: 'ssss、ssss等在等候室',
    duration: 0,
    closable: true,
    placement: 'topLeft',
    onClose: function onClose() {
      console.log('Notification closed');
    },
    onClick: function onClick() {
      console.log('Notification clicked');
    },
    icon: /*#__PURE__*/_jsx(FcrIcon, {
      type: FcrIconType.FCR_WAITING_ROOM,
      size: 40
    }),
    iconStyle: {
      backgroundColor: 'var(--fcr_ui_scene_card2)'
    },
    actions: /*#__PURE__*/_jsxs(_Fragment, {
      children: [/*#__PURE__*/_jsx(FcrButton, {
        size: "XXS",
        type: "text",
        styleType: "normal",
        children: "\u4E0D\u518D\u63D0\u793A"
      }), /*#__PURE__*/_jsx(FcrButton, {
        size: "XXS",
        type: "primary",
        styleType: "danger",
        children: "\u62D2\u7EDD"
      }), /*#__PURE__*/_jsx(FcrButton, {
        size: "XXS",
        type: "primary",
        children: "\u540C\u610F"
      })]
    })
  }, config), {}, {
    key: key++
  }));
};
export var Basic = {
  render: function render(_ref) {
    var rootConfig = _ref.rootConfig;
    useEffect(function () {
      var dom = document.querySelector(".".concat(NOTIFICATION_ROOT_CLASS_NAME));
      if (!dom) {
        var div = document.createElement('div');
        div.className = NOTIFICATION_ROOT_CLASS_NAME;
        document.body.appendChild(div);
      }
    }, []);
    var _useFcrNotification = useFcrNotification({
        className: function className(placement) {
          console.log('placement', placement);
          return "fcr-notification-".concat(placement);
        }
      }),
      _useFcrNotification2 = _slicedToArray(_useFcrNotification, 2),
      notification = _useFcrNotification2[0],
      contextHolder = _useFcrNotification2[1];
    return /*#__PURE__*/_jsxs("div", {
      style: {
        display: 'flex',
        flexDirection: 'column',
        alignItems: 'center',
        justifyContent: 'center',
        gap: '20px',
        width: '100%',
        height: '100%'
      },
      children: [/*#__PURE__*/_jsxs("div", {
        children: [/*#__PURE__*/_jsx(FcrButton, {
          size: "S",
          onClick: function onClick() {
            openNotification(notification);
          },
          children: "topLeft"
        }), /*#__PURE__*/_jsx(FcrButton, {
          size: "S",
          onClick: function onClick() {
            openNotification(notification, {
              duration: 10,
              showProgress: true
            });
          },
          children: "topLeft, showProgress"
        })]
      }), /*#__PURE__*/_jsxs("div", {
        style: {
          display: 'flex',
          gap: '10px'
        },
        children: [/*#__PURE__*/_jsx(FcrButton, {
          size: "S",
          onClick: function onClick() {
            openNotification(notification, {
              placement: 'topRight',
              title: undefined,
              actions: /*#__PURE__*/_jsx(FcrButton, {
                size: "XXS",
                type: "primary",
                children: "\u67E5\u770B"
              })
            });
          },
          children: "topRight, not title"
        }), /*#__PURE__*/_jsx(FcrButton, {
          size: "S",
          onClick: function onClick() {
            openNotification(notification, {
              placement: 'topRight',
              message: undefined,
              actions: /*#__PURE__*/_jsx(FcrButton, {
                size: "XXS",
                type: "primary",
                children: "\u67E5\u770B"
              })
            });
          },
          children: "topRight, not message"
        }), /*#__PURE__*/_jsx(FcrButton, {
          size: "S",
          onClick: function onClick() {
            openNotification(notification, {
              placement: 'topRight',
              message: undefined,
              oneline: true,
              closable: false,
              actions: /*#__PURE__*/_jsx(FcrButton, {
                size: "XXS",
                type: "primary",
                children: "\u67E5\u770B"
              })
            });
          },
          children: "topRight, in one line"
        })]
      }), /*#__PURE__*/_jsx(FcrButton, {
        size: "S",
        type: "secondary-bordered",
        onClick: function onClick() {
          var key = keys.pop();
          key && notification.close(key);
        },
        children: "Close last opened Notification"
      })]
    });
  }
};
export default meta;