import { create } from '../../../../../../node_modules/.pnpm/zustand@4.5.5_@types_react@19.2.6_immer@11.1.3_react@19.2.0/node_modules/zustand/esm/index.mjs';

const store = (set, get) => ({
  previewMode: "responsive",
  setPreviewMode: (mode) => set({ previewMode: mode }),
  registry: {},
  blocks: void 0,
  functionRegistry: void 0,
  initialize: (registry, persistLayerStoreConfig, allowPagesCreation, allowPagesDeletion, allowVariableEditing, blocks, functionRegistry) => {
    set((state) => ({ ...state, registry, persistLayerStoreConfig, allowPagesCreation, allowPagesDeletion, allowVariableEditing, blocks, functionRegistry }));
  },
  getComponentDefinition: (type) => {
    const { registry } = get();
    if (!registry) {
      console.warn("Registry accessed via editor store before initialization.");
      return void 0;
    }
    return registry[type];
  },
  getFunctionDefinition: (id) => {
    const { functionRegistry } = get();
    if (!functionRegistry) {
      return void 0;
    }
    return functionRegistry[id];
  },
  persistLayerStoreConfig: true,
  setPersistLayerStoreConfig: (shouldPersist) => set({ persistLayerStoreConfig: shouldPersist }),
  revisionCounter: 0,
  incrementRevision: () => set((state) => ({ revisionCounter: state.revisionCounter + 1 })),
  allowPagesCreation: true,
  setAllowPagesCreation: (allow) => set({ allowPagesCreation: allow }),
  allowPagesDeletion: true,
  setAllowPagesDeletion: (allow) => set({ allowPagesDeletion: allow }),
  allowVariableEditing: true,
  setAllowVariableEditing: (allow) => set({ allowVariableEditing: allow }),
  // Panel visibility state
  showLeftPanel: true,
  setShowLeftPanel: (show) => set({ showLeftPanel: show }),
  showRightPanel: true,
  setShowRightPanel: (show) => set({ showRightPanel: show }),
  // Clipboard state for copy/cut/paste
  clipboard: {
    layer: null,
    isCut: false,
    sourceLayerId: null
  },
  setClipboard: (clipboard) => set({ clipboard }),
  clearClipboard: () => set({
    clipboard: {
      layer: null,
      isCut: false,
      sourceLayerId: null
    }
  }),
  // Context menu state for right-click menus
  contextMenu: {
    open: false,
    x: 0,
    y: 0,
    layerId: null
  },
  openContextMenu: (x, y, layerId) => set({
    contextMenu: {
      open: true,
      x,
      y,
      layerId
    }
  }),
  closeContextMenu: () => set({
    contextMenu: {
      open: false,
      x: 0,
      y: 0,
      layerId: null
    }
  })
});
const useEditorStore = create()(store);

export { useEditorStore };
