"use client";
import { jsx } from "react/jsx-runtime";
import { createContext, useContext, useState, useEffect } from "react";
import { usePageContext } from "../../hooks/usePageContext.js";
import { useCommandPalette } from "../../hooks/useCommandPalette.js";
const CommandPaletteContext = createContext(null);
function CommandPaletteProvider({
  children,
  tenantId,
  organizationId,
  disableKeyboardShortcut = true
}) {
  const pageContext = usePageContext({ tenantId, organizationId });
  const [selectedEntities, setSelectedEntities] = useState([]);
  useEffect(() => {
    const handleSelectionChange = (event) => {
      setSelectedEntities(event.detail || []);
    };
    window.addEventListener("om:selection-change", handleSelectionChange);
    return () => {
      window.removeEventListener("om:selection-change", handleSelectionChange);
    };
  }, []);
  const commandPalette = useCommandPalette({
    pageContext,
    selectedEntities,
    disableKeyboardShortcut
  });
  return /* @__PURE__ */ jsx(CommandPaletteContext.Provider, { value: commandPalette, children });
}
function useCommandPaletteContext() {
  const context = useContext(CommandPaletteContext);
  if (!context) {
    throw new Error("useCommandPaletteContext must be used within CommandPaletteProvider");
  }
  return context;
}
export {
  CommandPaletteProvider,
  useCommandPaletteContext
};
//# sourceMappingURL=CommandPaletteProvider.js.map
