import * as React from 'react';
export function sendEventPostMessage(action, data) {
    const message = { action, data };
    window.parent.postMessage(message);
}
export function listenPostMessageActions(action, callback) {
    const onMessage = (e) => {
        const message = e.data;
        if ('action' in message && message.action === action) {
            return callback(message.data);
        }
        return undefined;
    };
    window.addEventListener('message', onMessage);
    return () => {
        window.removeEventListener('message', onMessage);
    };
}
export function useInternalPostMessageAPIListener(action, callback) {
    React.useEffect(() => {
        return listenPostMessageActions(action, callback);
    }, [action, callback]);
}
//# sourceMappingURL=usePostMessageAPI.js.map
