"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.useBottomSheet = exports.default = void 0;
var _enums = require("../../../social/enums");
var _toolkit = require("@reduxjs/toolkit");
var _store = require("../store");
const initialState = {
  open: false,
  content: null,
  height: 200,
  pageId: _enums.PageID.WildCardPage,
  componentId: _enums.ComponentID.WildCardComponent
};
const bottomSheetSlice = (0, _toolkit.createSlice)({
  name: 'bottomSheet',
  initialState,
  reducers: {
    openBottomSheet: (state, action) => {
      state.open = true;
      state.content = action.payload.content;
      state.height = action.payload.height || 200;
      state.dark = action.payload.dark ?? false;
    },
    closeBottomSheet: state => {
      state.open = false;
      state.height = 0;
    },
    clearContent: state => {
      state.dark = false;
      state.content = null;
    }
  }
});
var _default = exports.default = bottomSheetSlice;
const useBottomSheet = () => {
  const dispatch = (0, _store.useUIKitDispatch)();
  const {
    openBottomSheet: $openBottomSheet,
    closeBottomSheet: $closeBottomSheet,
    clearContent
  } = bottomSheetSlice.actions;
  const bottomSheetHeight = {
    1: 150,
    2: 180,
    3: 220,
    4: 270,
    5: 300
  };
  const {
    content: $content,
    open: $open,
    height: $height,
    dark: $dark
  } = (0, _store.useUIKitSelector)(state => state.bottomSheet);
  const openBottomSheet = ({
    dark,
    height,
    content
  }) => {
    dispatch($openBottomSheet({
      content,
      height,
      dark
    }));
  };
  const closeBottomSheet = () => {
    dispatch($closeBottomSheet());
    setTimeout(() => {
      dispatch(clearContent());
    }, 300);
  };
  return {
    openBottomSheet,
    height: $height,
    closeBottomSheet,
    content: $content,
    open: $open,
    dark: $dark,
    bottomSheetHeight
  };
};
exports.useBottomSheet = useBottomSheet;
//# sourceMappingURL=bottomSheetSlice.js.map