import {
  LogItem_default
} from "./chunk-RAWY6NFX.mjs";
import {
  Timestamp_default
} from "./chunk-6GL34B7B.mjs";

// tmp-babel/activity-log/web/ActivityLogComponent/LogGroups/index.js
import { Avatar, Box, CircularProgress, Typography } from "@mui/material";
import { Virtuoso } from "react-virtuoso";
import { jsx as _jsx, jsxs as _jsxs } from "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);
}
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);
}
var LogGroups = function LogGroups2(_ref) {
  var logGroups = _ref.logGroups, _ref$LoadingState = _ref.LoadingState, LoadingState = _ref$LoadingState === void 0 ? CircularProgress : _ref$LoadingState, LoadingStateProps = _ref.LoadingStateProps, VirtuosoProps = _ref.VirtuosoProps, loadNext = _ref.loadNext, hasNext = _ref.hasNext, isLoadingNext = _ref.isLoadingNext;
  var renderLogItem = function renderLogItem2(log, isLast) {
    if (!log) return null;
    return /* @__PURE__ */ _jsx(LogItem_default, {
      sx: isLast ? {
        marginBottom: "6px"
      } : void 0,
      log
    }, log.id);
  };
  var renderLoadingState = function renderLoadingState2() {
    if (!isLoadingNext) return /* @__PURE__ */ _jsx(Box, {
      sx: {
        paddingTop: 3
      }
    });
    return /* @__PURE__ */ _jsx(LoadingState, _objectSpread({
      sx: {
        paddingTop: 3,
        paddingBottom: 1
      },
      CircularProgressProps: {
        size: 15
      },
      "aria-label": "loading more activity logs"
    }, LoadingStateProps));
  };
  var renderItemContent = function renderItemContent2(group) {
    var _group$logs$0$user$av, _group$logs$, _group$logs$0$user$fu, _group$logs$2, _group$logs$3;
    return /* @__PURE__ */ _jsxs(Box, {
      display: "flex",
      flexDirection: "column",
      justifyContent: "center",
      pt: "6px",
      pb: "16px",
      maxWidth: "568px",
      children: [/* @__PURE__ */ _jsxs(Box, {
        display: "flex",
        alignItems: "center",
        gap: "12px",
        children: [/* @__PURE__ */ _jsx(Avatar, {
          style: {
            marginBottom: "4px"
          },
          sizes: "small",
          src: (_group$logs$0$user$av = (_group$logs$ = group.logs[0]) === null || _group$logs$ === void 0 || (_group$logs$ = _group$logs$.user) === null || _group$logs$ === void 0 || (_group$logs$ = _group$logs$.avatar) === null || _group$logs$ === void 0 ? void 0 : _group$logs$.url) !== null && _group$logs$0$user$av !== void 0 ? _group$logs$0$user$av : "",
          alt: (_group$logs$0$user$fu = (_group$logs$2 = group.logs[0]) === null || _group$logs$2 === void 0 || (_group$logs$2 = _group$logs$2.user) === null || _group$logs$2 === void 0 ? void 0 : _group$logs$2.fullName) !== null && _group$logs$0$user$fu !== void 0 ? _group$logs$0$user$fu : "User activity log avatar"
        }), /* @__PURE__ */ _jsx(Typography, {
          variant: "subtitle2",
          mb: "6px",
          children: (_group$logs$3 = group.logs[0]) === null || _group$logs$3 === void 0 || (_group$logs$3 = _group$logs$3.user) === null || _group$logs$3 === void 0 ? void 0 : _group$logs$3.fullName
        })]
      }), group.logs.map(function(log, index) {
        return renderLogItem(log, index === group.logs.length - 1);
      }), /* @__PURE__ */ _jsx(Timestamp_default, {
        date: group.lastActivityTimestamp
      })]
    }, group.lastActivityTimestamp);
  };
  return /* @__PURE__ */ _jsx("div", {
    className: "overflow-x-auto hide-scrollbar",
    children: /* @__PURE__ */ _jsx(Virtuoso, _objectSpread({
      useWindowScroll: true,
      data: logGroups,
      itemContent: function itemContent(_index, group) {
        return renderItemContent(group);
      },
      components: {
        Footer: renderLoadingState
      },
      endReached: function endReached() {
        if (hasNext) {
          loadNext(10);
        }
      }
    }, VirtuosoProps))
  });
};
var LogGroups_default = LogGroups;

export {
  LogGroups_default
};
//# sourceMappingURL=chunk-6UTNUNXD.mjs.map