import { useCallback } from "react";
import { Instance, ReactFlowInstance, useReactFlow } from "reactflow";
import { create } from "./Create";

type State = {
  edgebrix: ReactFlowInstance | null;
};

type Actions = {
  setEdgebrix: (edgebrix: ReactFlowInstance) => void;
  reset: () => void;
};

// define the initial state
const initialState: State = {
  edgebrix: null,
};

// create store
const useEdgebrix = create<State & Actions>()((set, get) => ({
  ...initialState,

  setEdgebrix: (_edgebrix: ReactFlowInstance) => {
    set({ edgebrix: _edgebrix });
  },

  reset: () => {
    set(initialState);
  },
}));

export { useEdgebrix };
