"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.useStoryPermission = useStoryPermission;
var _useAuth = _interopRequireDefault(require("../../core/hooks/useAuth"));
var _useUser = require("./useUser");
var _useSocialSettings = _interopRequireDefault(require("../../core/hooks/useSocialSettings"));
var _permissions = require("../utils/permissions");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function useStoryPermission(communityId) {
  var _socialSettings$story, _socialSettings$story2;
  const {
    client
  } = (0, _useAuth.default)();
  const {
    socialSettings
  } = (0, _useSocialSettings.default)();
  const user = (0, _useUser.useUser)((client === null || client === void 0 ? void 0 : client.userId) || '');
  const isGlobalAdmin = (0, _permissions.isAdmin)(user === null || user === void 0 ? void 0 : user.roles);
  const hasStoryPermission = !communityId ? socialSettings === null || socialSettings === void 0 || (_socialSettings$story = socialSettings.story) === null || _socialSettings$story === void 0 ? void 0 : _socialSettings$story.allowAllUserToCreateStory : (socialSettings === null || socialSettings === void 0 || (_socialSettings$story2 = socialSettings.story) === null || _socialSettings$story2 === void 0 ? void 0 : _socialSettings$story2.allowAllUserToCreateStory) || isGlobalAdmin || (0, _permissions.checkStoryPermission)(client, communityId);
  return {
    hasStoryPermission
  };
}
//# sourceMappingURL=useStoryPermission.js.map