'use client';


import { MessageKey } from "./editor/dist/esm/messagesKeys.mjs";
import { useCrossFrameState } from "./useCrossFrameState.mjs";
import { NodeType } from "./types/dist/esm/nodeType.mjs";
import { createContext, useContext } from "react";
import { jsx } from "react/jsx-runtime";

//#region ../react-intlayer/dist/esm/@intlayer/editor-react/dist/esm/FocusDictionaryContext.mjs
const FocusDictionaryStateContext = createContext(void 0);
const FocusDictionaryActionsContext = createContext(void 0);
const FocusDictionaryProvider = ({ children }) => {
	const [focusedContent, setFocusedContent] = useCrossFrameState(MessageKey.INTLAYER_FOCUSED_CONTENT_CHANGED, null);
	const setFocusedContentKeyPath = (keyPath) => {
		setFocusedContent((prev) => {
			if (!prev) return prev;
			const filteredKeyPath = keyPath.filter((key) => key.type !== NodeType.Translation);
			return {
				...prev,
				keyPath: filteredKeyPath
			};
		});
	};
	return /* @__PURE__ */ jsx(FocusDictionaryStateContext.Provider, {
		value: { focusedContent },
		children: /* @__PURE__ */ jsx(FocusDictionaryActionsContext.Provider, {
			value: {
				setFocusedContent,
				setFocusedContentKeyPath
			},
			children
		})
	});
};
const useFocusDictionaryActions = () => {
	const context = useContext(FocusDictionaryActionsContext);
	if (context === void 0) throw new Error("useFocusDictionaryActions must be used within a FocusDictionaryProvider");
	return context;
};
const useFocusDictionary = () => {
	const actionContext = useFocusDictionaryActions();
	const stateContext = useContext(FocusDictionaryStateContext);
	if (stateContext === void 0) throw new Error("useFocusDictionaryState must be used within a FocusDictionaryProvider");
	return {
		...stateContext,
		...actionContext
	};
};

//#endregion
export { FocusDictionaryProvider, useFocusDictionary };
//# sourceMappingURL=FocusDictionaryContext.mjs.map