import { ActionTypes, isKnownAction } from "../actions";
function getElementImperativeHandles(state) {
  return state;
}
function getInitialState() {
  return /* @__PURE__ */ new Map();
}
function reducer(state = getInitialState(), action) {
  if (!isKnownAction(action))
    return state;
  switch (action.type) {
    case ActionTypes.REGISTER_COMPONENT_HANDLE:
      return new Map(state).set(
        action.payload.documentKey,
        new Map(new Map(state.get(action.payload.documentKey) ?? [])).set(
          action.payload.elementKey,
          action.payload.componentHandle
        )
      );
    case ActionTypes.UNREGISTER_COMPONENT_HANDLE: {
      const byElementKey = new Map(state.get(action.payload.documentKey) ?? []);
      const deleted = byElementKey.delete(action.payload.elementKey);
      if (!deleted)
        return state;
      return new Map(state).set(action.payload.documentKey, byElementKey);
    }
    default:
      return state;
  }
}
export {
  getElementImperativeHandles,
  reducer
};
//# sourceMappingURL=element-imperative-handles.js.map