'use client';


const require_rolldown_runtime = require('../../../../../../../_virtual/rolldown_runtime.cjs');
const require_messagesKeys = require('./editor/dist/esm/messagesKeys.cjs');
const require_useCrossFrameState = require('./useCrossFrameState.cjs');
const require_nodeType = require('./types/dist/esm/nodeType.cjs');
let react = require("react");
let react_jsx_runtime = require("react/jsx-runtime");

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

//#endregion
exports.FocusDictionaryProvider = FocusDictionaryProvider;
exports.useFocusDictionary = useFocusDictionary;
//# sourceMappingURL=FocusDictionaryContext.cjs.map