import '../../chipper/js/browser/initialize-globals.js';
import '../../assert/js/assert.js';
import '../../query-string-machine/js/QueryStringMachine.js';
import '../../globals.js';
import NumberProperty from '../../axon/js/NumberProperty.js';
import Property from '../../axon/js/Property.js';
import TEmitter, { TReadOnlyEmitter } from '../../axon/js/TEmitter.js';
import TProperty from '../../axon/js/TProperty.js';
import TReadOnlyProperty from '../../axon/js/TReadOnlyProperty.js';
import { Locale } from '../../joist/js/i18n/localeProperty.js';
import Announcer, { AnnouncerOptions } from '../../utterance-queue/js/Announcer.js';
import Utterance from '../../utterance-queue/js/Utterance.js';
import { ResolvedResponse } from './ResponsePacket.js';
export type SpeechSynthesisInitializeOptions = {
    speechAllowedProperty?: TReadOnlyProperty<boolean>;
};
type SelfOptions = {
    debug?: boolean;
};
export type SpeechSynthesisAnnouncerOptions = SelfOptions & AnnouncerOptions;
declare class SpeechSynthesisAnnouncer extends Announcer {
    readonly voiceProperty: Property<null | SpeechSynthesisVoice>;
    readonly voiceRateProperty: NumberProperty;
    readonly voicePitchProperty: NumberProperty;
    private readonly voiceVolumeProperty;
    private timeSinceWakingEngine;
    private timeSincePauseResume;
    private timeSincePendingUtterance;
    private timeSinceUtteranceEnd;
    readonly startSpeakingEmitter: TEmitter<[ResolvedResponse, Utterance]>;
    readonly endSpeakingEmitter: TEmitter<[ResolvedResponse, Utterance]>;
    private enabledComponentImplementation;
    readonly enabledProperty: TProperty<boolean>;
    readonly mainWindowVoicingEnabledProperty: Property<boolean>;
    voicingFullyEnabledProperty: TReadOnlyProperty<boolean>;
    readonly speechAllowedAndFullyEnabledProperty: TReadOnlyProperty<boolean>;
    private readonly _speechAllowedAndFullyEnabledProperty;
    private synth;
    voicesProperty: TProperty<SpeechSynthesisVoice[]>;
    private speakingSpeechSynthesisUtteranceWrapper;
    isInitializedProperty: TProperty<boolean>;
    private canSpeakProperty;
    private readonly boundHandleCanSpeakChange;
    private readonly boundHandleCanAnnounceChange;
    private readonly debug;
    constructor(providedOptions?: SpeechSynthesisAnnouncerOptions);
    get initialized(): boolean;
    /**
     * Indicate that the SpeechSynthesisAnnouncer is ready for use, and attempt to populate voices (if they are ready yet). Adds
     * listeners that control speech.
     *
     * @param userGestureEmitter - Emits when user input happens, which is required before the browser is
     *                                       allowed to use SpeechSynthesis for the first time.
     * @param [providedOptions]
     */
    initialize(userGestureEmitter: TReadOnlyEmitter, providedOptions?: SpeechSynthesisInitializeOptions): void;
    /**
     * @param dt - in seconds from stepTimer
     */
    private step;
    /**
     * When we can no longer speak, cancel all speech to silence everything.
     */
    private handleCanSpeakChange;
    /**
     * Update the list of `voices` available to the synth, and notify that the list has changed.
     */
    private populateVoices;
    /**
     * Returns an array of SpeechSynthesisVoices that are sorted such that the best sounding voices come first.
     * As of 9/27/21, we find that the "Google" voices sound best while Apple's "Fred" sounds the worst so the list
     * will be ordered to reflect that. This way "Google" voices will be selected by default when available and "Fred"
     * will almost never be the default Voice since it is last in the list. See
     * https://github.com/phetsims/scenery/issues/1282/ for discussion and this decision.
     */
    getPrioritizedVoices(): SpeechSynthesisVoice[];
    /**
     * Voicing as a feature is not translatable. This function gets the "prioritized" voices (as decided by PhET) and
     * prunes out the non-english ones. This does not use this.getPrioritizedVoicesForLocale because the required Locale
     * type doesn't include 'en-US' or 'en_US' as valid values, just 'en'.
     */
    getEnglishPrioritizedVoices(): SpeechSynthesisVoice[];
    /**
     * Voicing as a feature is not translatable, but some SpeechSynthesisAnnouncer usages outside of voicing are. This
     * function gets the "prioritized" voices (as decided by PhET) and
     * prunes out everything that is not the "provided" locale. The algorithm for mapping locale is as follows:
     *
     * locale: 'en' - Provided locale parameter
     * voice: 'en_GB' - YES matches!
     * voice: 'en' - YES
     *
     * locale: 'en_GB'
     * voice: 'en' - NO
     * voice: 'en_GB' - YES
     * voice: 'en-GB' - YES
     * voice: 'en-US' - NO
     *
     * locale: 'zh_CN'
     * voice: 'zh' - NO
     * voice: 'zh_CN' - YES
     *
     * locale: 'zh'
     * voice: 'zh' - YES
     * voice: 'zh_CN' - YES
     * voice: 'zh-TW' - YES
     *
     * locale: 'es_ES'
     * voice: 'es_MX' - NO
     * voice: 'es' - NO
     * voice: 'es-ES' - YES
     */
    getPrioritizedVoicesForLocale(locale: Locale): SpeechSynthesisVoice[];
    /**
     * Implements announce so the SpeechSynthesisAnnouncer can be a source of output for utteranceQueue.
     */
    announce(announceText: ResolvedResponse, utterance: Utterance): void;
    /**
     * The announcement of this utterance has failed in some way, signify to clients of this announcer that the utterance
     * will never complete. For example start/end events on the SpeechSynthesisUtterance will never fire.
     */
    private handleAnnouncementFailure;
    /**
     * Use speech synthesis to speak an utterance. No-op unless SpeechSynthesisAnnouncer is initialized and other output
     * controlling Properties are true (see speechAllowedProperty in initialize()). This explicitly ignores
     * this.enabledProperty, allowing speech even when SpeechSynthesisAnnouncer is disabled. This is useful in rare cases, for
     * example when the SpeechSynthesisAnnouncer recently becomes disabled by the user and we need to announce confirmation of
     * that decision ("Voicing off" or "All audio off").
     *
     * NOTE: This will interrupt any currently speaking utterance.
     */
    speakIgnoringEnabled(utterance: Utterance): void;
    /**
     * Request speech with SpeechSynthesis.
     */
    private requestSpeech;
    /**
     * When a canAnnounceProperty changes to false for an Utterance, that utterance should be cancelled.
     */
    private handleCanAnnounceChange;
    /**
     * When a canAnnounceProperty changes, cancel the Utterance if the value becomes false.
     */
    private cancelUtteranceIfCanAnnounceFalse;
    /**
     * All the work necessary when we are finished with an utterance, intended for end or cancel.
     * Emits events signifying that we are done with speech and does some disposal.
     */
    private handleSpeechSynthesisEnd;
    /**
     * Returns a references to the SpeechSynthesis of the SpeechSynthesisAnnouncer that is used to request speech with the Web
     * Speech API. Every references has a check to ensure that the synth is available.
     */
    private getSynth;
    /**
     * Stops any Utterance that is currently being announced or is (about to be announced).
     * (utterance-queue internal)
     */
    cancel(): void;
    /**
     * Cancel the provided Utterance, if it is currently being spoken by this Announcer. Does not cancel
     * any other utterances that may be in the UtteranceQueue.
     * (utterance-queue internal)
     */
    cancelUtterance(utterance: Utterance): void;
    /**
     * Given one utterance, should it cancel another provided utterance?
     */
    shouldUtteranceCancelOther(utterance: Utterance, utteranceToCancel: Utterance): boolean;
    /**
     * When the priority for a new utterance changes or if a new utterance is added to the queue, determine whether
     * we should cancel the synth immediately.
     */
    onUtterancePriorityChange(nextAvailableUtterance: Utterance): void;
    /**
     * Cancel the synth. This will silence speech. This will silence any speech and cancel the
     */
    private cancelSynth;
    /**
     * Returns true if SpeechSynthesis is available on the window. This check is sufficient for all of
     * SpeechSynthesisAnnouncer. On platforms where speechSynthesis is available, all features of it are available, except for the
     * onvoiceschanged event in a couple of platforms. However, the listener can still be set
     * without issue on those platforms so we don't need to check for its existence. On those platforms, voices
     * are provided right on load.
     */
    static isSpeechSynthesisSupported(): boolean;
}
export default SpeechSynthesisAnnouncer;
//# sourceMappingURL=SpeechSynthesisAnnouncer.d.ts.map