'use client';


import { built_default } from "./config/dist/esm/built.mjs";
import { createContext, useContext, useMemo, useRef } from "react";
import { jsx } from "react/jsx-runtime";
import { v4 } from "uuid";

//#region ../react-intlayer/dist/esm/@intlayer/editor-react/dist/esm/CommunicatorContext.mjs
const { editor } = built_default ?? {};
const CommunicatorContext = createContext({
	postMessage: () => null,
	allowedOrigins: [
		editor?.applicationURL,
		editor?.editorURL,
		editor?.cmsURL
	],
	senderId: ""
});
const CommunicatorProvider = ({ children, allowedOrigins, postMessage }) => {
	const senderIdRef = useRef(v4());
	const value = useMemo(() => ({
		postMessage,
		allowedOrigins,
		senderId: senderIdRef.current
	}), [
		postMessage,
		allowedOrigins,
		senderIdRef.current
	]);
	return /* @__PURE__ */ jsx(CommunicatorContext.Provider, {
		value,
		children
	});
};
const useCommunicator = () => useContext(CommunicatorContext);

//#endregion
export { CommunicatorProvider, useCommunicator };
//# sourceMappingURL=CommunicatorContext.mjs.map