var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
  for (var prop in b || (b = {}))
    if (__hasOwnProp.call(b, prop))
      __defNormalProp(a, prop, b[prop]);
  if (__getOwnPropSymbols)
    for (var prop of __getOwnPropSymbols(b)) {
      if (__propIsEnum.call(b, prop))
        __defNormalProp(a, prop, b[prop]);
    }
  return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var ModalActions = /* @__PURE__ */ ((ModalActions2) => {
  ModalActions2["PUSH_MODAL"] = "PUSH_MODAL";
  ModalActions2["POP_MODAL"] = "POP_MODAL";
  ModalActions2["REMOVE_MODAL"] = "REMOVE_MODAL";
  ModalActions2["CLOSE_MODAL"] = "CLOSE_MODAL";
  ModalActions2["RESET_MODAL"] = "RESET_MODAL";
  return ModalActions2;
})(ModalActions || {});
const initialModalState = {
  stack: [],
  closeId: 0
};
let MODAL_ID = 1;
const modalReducer = (state = initialModalState, action) => {
  switch (action.type) {
    case "PUSH_MODAL" /* PUSH_MODAL */:
      if (state.stack.some(
        (modal) => modal.component === action.payload.component
      )) {
        return state;
      }
      return __spreadProps(__spreadValues({}, state), {
        stack: state.stack.concat(__spreadProps(__spreadValues({}, action.payload), {
          id: MODAL_ID++
        }))
      });
    case "POP_MODAL" /* POP_MODAL */:
      return __spreadProps(__spreadValues({}, state), {
        stack: state.stack.slice(0, -1)
      });
    case "REMOVE_MODAL" /* REMOVE_MODAL */:
      return __spreadProps(__spreadValues({}, state), {
        closeId: 0,
        stack: state.stack.filter((m) => m.id !== action.id)
      });
    case "CLOSE_MODAL" /* CLOSE_MODAL */:
      return __spreadProps(__spreadValues({}, state), {
        closeId: action.id
      });
    case "RESET_MODAL" /* RESET_MODAL */:
      return initialModalState;
    default:
      return state;
  }
};

export { ModalActions, initialModalState, modalReducer };
