// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
/// Adapted from: https://github.com/AlmeroSteyn/react-aria-live/blob/master/src/modules/AnnouncerMessage.js
import { useCallback, useEffect } from 'react';
import { v1 as createGUID } from 'uuid';
/** @private */
const AnnouncerMessage = (props) => {
    const { message, ariaLive, clearOnUnmount, announceAssertive, announcePolite } = props;
    const announce = useCallback(() => {
        if (ariaLive === 'assertive') {
            announceAssertive(message || '', createGUID());
        }
        else if (ariaLive === 'polite') {
            announcePolite(message || '', createGUID());
        }
    }, [announceAssertive, announcePolite, ariaLive, message]);
    useEffect(() => {
        announce();
        return () => {
            if (clearOnUnmount) {
                announceAssertive('', createGUID());
                announcePolite('', createGUID());
            }
        };
    }, [message, clearOnUnmount, announce, announceAssertive, announcePolite]);
    return null;
};
export default AnnouncerMessage;
//# sourceMappingURL=AnnouncerMessage.js.map