"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var _chunkULIMWUQLjs = require('./chunk-ULIMWUQL.js');


var _chunkOKMJEWJPjs = require('./chunk-OKMJEWJP.js');


var _chunkSP2GVPV5js = require('./chunk-SP2GVPV5.js');


var _chunkGFUIJZCXjs = require('./chunk-GFUIJZCX.js');

// tmp-babel/notifications/web/NotificationsPopover/index.js
var _react = require('react');
var _animate = require('@baseapp-frontend/design-system/components/web/animate');
var _icons = require('@baseapp-frontend/design-system/components/web/icons');
var _web = require('@baseapp-frontend/design-system/hooks/web');
var _material = require('@mui/material');
var _IconButton = require('@mui/material/IconButton'); var _IconButton2 = _interopRequireDefault(_IconButton);
var _framermotion = require('framer-motion');
var _reactrelay = require('react-relay');
var _jsxruntime = require('react/jsx-runtime');
function _typeof(o) {
  "@babel/helpers - typeof";
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
    return typeof o2;
  } : function(o2) {
    return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
  }, _typeof(o);
}
var _excluded = ["onClose"];
function ownKeys(e, r) {
  var t = Object.keys(e);
  if (Object.getOwnPropertySymbols) {
    var o = Object.getOwnPropertySymbols(e);
    r && (o = o.filter(function(r2) {
      return Object.getOwnPropertyDescriptor(e, r2).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), true).forEach(function(r2) {
      _defineProperty(e, r2, t[r2]);
    }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r2) {
      Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
    });
  }
  return e;
}
function _defineProperty(e, r, t) {
  return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
}
function _toPropertyKey(t) {
  var i = _toPrimitive(t, "string");
  return "symbol" == _typeof(i) ? i : i + "";
}
function _toPrimitive(t, r) {
  if ("object" != _typeof(t) || !t) return t;
  var e = t[Symbol.toPrimitive];
  if (void 0 !== e) {
    var i = e.call(t, r || "default");
    if ("object" != _typeof(i)) return i;
    throw new TypeError("@@toPrimitive must return a primitive value.");
  }
  return ("string" === r ? String : Number)(t);
}
function _objectWithoutProperties(e, t) {
  if (null == e) return {};
  var o, r, i = _objectWithoutPropertiesLoose(e, t);
  if (Object.getOwnPropertySymbols) {
    var n = Object.getOwnPropertySymbols(e);
    for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
  }
  return i;
}
function _objectWithoutPropertiesLoose(r, e) {
  if (null == r) return {};
  var t = {};
  for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
    if (-1 !== e.indexOf(n)) continue;
    t[n] = r[n];
  }
  return t;
}
function _slicedToArray(r, e) {
  return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
}
function _nonIterableRest() {
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _unsupportedIterableToArray(r, a) {
  if (r) {
    if ("string" == typeof r) return _arrayLikeToArray(r, a);
    var t = {}.toString.call(r).slice(8, -1);
    return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
  }
}
function _arrayLikeToArray(r, a) {
  (null == a || a > r.length) && (a = r.length);
  for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
  return n;
}
function _iterableToArrayLimit(r, l) {
  var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
  if (null != t) {
    var e, n, i, u, a = [], f = true, o = false;
    try {
      if (i = (t = t.call(r)).next, 0 === l) {
        if (Object(t) !== t) return;
        f = false;
      } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = true) ;
    } catch (r2) {
      o = true, n = r2;
    } finally {
      try {
        if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
      } finally {
        if (o) throw n;
      }
    }
    return a;
  }
}
function _arrayWithHoles(r) {
  if (Array.isArray(r)) return r;
}
var NotificationsPopover = function NotificationsPopover2(_ref) {
  var _ref$Drawer = _ref.Drawer, Drawer = _ref$Drawer === void 0 ? _material.Drawer : _ref$Drawer, _ref$DrawerProps = _ref.DrawerProps, DrawerProps = _ref$DrawerProps === void 0 ? {} : _ref$DrawerProps, _ref$Badge = _ref.Badge, Badge = _ref$Badge === void 0 ? _material.Badge : _ref$Badge, _ref$BadgeProps = _ref.BadgeProps, BadgeProps = _ref$BadgeProps === void 0 ? {} : _ref$BadgeProps, _ref$NotificationBell = _ref.NotificationBellIcon, NotificationBellIcon = _ref$NotificationBell === void 0 ? _icons.NotificationBellIcon : _ref$NotificationBell, _ref$NotificationBell2 = _ref.NotificationBellIconProps, NotificationBellIconProps = _ref$NotificationBell2 === void 0 ? {} : _ref$NotificationBell2, _ref$NotificationsLis = _ref.NotificationsList, NotificationsList = _ref$NotificationsLis === void 0 ? _chunkULIMWUQLjs.NotificationsList_default : _ref$NotificationsLis, _ref$NotificationsLis2 = _ref.NotificationsListProps, NotificationsListProps = _ref$NotificationsLis2 === void 0 ? {} : _ref$NotificationsLis2;
  var _useState = _react.useState.call(void 0, false), _useState2 = _slicedToArray(_useState, 2), isDrawerOpened = _useState2[0], setIsDrawerOpened = _useState2[1];
  var _useLazyLoadQuery = _reactrelay.useLazyLoadQuery.call(void 0, _chunkSP2GVPV5js.NotificationsPopoverQuery, {}, {
    fetchPolicy: "store-and-network"
  }), me = _useLazyLoadQuery.me;
  var user = _reactrelay.useFragment.call(void 0, _chunkOKMJEWJPjs.NotificationUserMenuFragment, me);
  _chunkGFUIJZCXjs.useNotificationsSubscription.call(void 0, user === null || user === void 0 ? void 0 : user.id);
  var smDown = _web.useResponsive.call(void 0, "down", "sm");
  var _onClose = DrawerProps.onClose, restDrawerProps = _objectWithoutProperties(DrawerProps, _excluded);
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, {
    children: [/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _IconButton2.default, {
      component: _framermotion.m.button,
      whileTap: "tap",
      whileHover: "hover",
      variants: _animate.varHover.call(void 0, 1.05),
      onClick: function onClick() {
        return setIsDrawerOpened(true);
      },
      "aria-label": "see notifications",
      children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Badge, _objectSpread(_objectSpread({
        badgeContent: user === null || user === void 0 ? void 0 : user.notificationsUnreadCount,
        color: "error"
      }, BadgeProps), {}, {
        children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, NotificationBellIcon, _objectSpread({
          color: "secondary"
        }, NotificationBellIconProps))
      }))
    }), /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Drawer, _objectSpread(_objectSpread({
      anchor: smDown ? "bottom" : "right",
      open: isDrawerOpened,
      onClose: function onClose(event, reason) {
        setIsDrawerOpened(false);
        _onClose === null || _onClose === void 0 || _onClose(event, reason);
      },
      sx: {
        "& .MuiDrawer-paper": {
          height: "100vh"
        }
      },
      PaperProps: {
        sx: {
          width: {
            xs: "100%",
            sm: 390,
            md: 420
          }
        }
      }
    }, restDrawerProps), {}, {
      children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, NotificationsList, _objectSpread({
        setIsDrawerOpened
      }, NotificationsListProps))
    }))]
  });
};
var NotificationsPopoverSuspended = function NotificationsPopoverSuspended2(props) {
  var _props$NotificationBe = props.NotificationBellIcon, NotificationBellIcon = _props$NotificationBe === void 0 ? _icons.NotificationBellIcon : _props$NotificationBe, _props$NotificationBe2 = props.NotificationBellIconProps, NotificationBellIconProps = _props$NotificationBe2 === void 0 ? {} : _props$NotificationBe2;
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Suspense, {
    fallback: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _IconButton2.default, {
      disabled: true,
      children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, NotificationBellIcon, _objectSpread({
        color: "secondary"
      }, NotificationBellIconProps))
    }),
    children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, NotificationsPopover, _objectSpread({}, props))
  });
};
var NotificationsPopover_default = NotificationsPopoverSuspended;



exports.NotificationsPopover_default = NotificationsPopover_default;
//# sourceMappingURL=chunk-EKKSNKMW.js.map