import '../../../assert/js/assert.js';
import '../../../globals.js';
import optionize from '../../../phet-core/js/optionize.js';
import Tandem from '../../../tandem/js/Tandem.js';
import sun from '../sun.js';
import RoundButton from './RoundButton.js';
import StickyToggleButtonInteractionStateProperty from './StickyToggleButtonInteractionStateProperty.js';
import StickyToggleButtonModel from './StickyToggleButtonModel.js';
import sharedSoundPlayers from '../../../tambo/js/sharedSoundPlayers.js';
export default class RoundStickyToggleButton extends RoundButton {
    /**
     * @param valueProperty - axon Property that can be either valueUp or valueDown.
     * @param valueUp - value when the toggle is in the 'up' position
     * @param valueDown - value when the toggle is in the 'down' position
     * @param providedOptions?
     */
    constructor(valueProperty, valueUp, valueDown, providedOptions) {
        assert && assert(valueProperty.valueComparisonStrategy === 'reference', 'RoundStickyToggleButton depends on "===" equality for value comparison');
        const options = optionize()({
            // SelfOptions
            soundPlayer: sharedSoundPlayers.get('pushButton'),
            // RoundButtonOptions
            tandem: Tandem.REQUIRED
        }, providedOptions);
        // Note it shares a tandem with this, so the emitter will be instrumented as a child of the button
        const toggleButtonModel = new StickyToggleButtonModel(valueUp, valueDown, valueProperty, options);
        const stickyToggleButtonInteractionStateProperty = new StickyToggleButtonInteractionStateProperty(toggleButtonModel);
        super(toggleButtonModel, stickyToggleButtonInteractionStateProperty, options);
        // sound generation
        const playSound = () => options.soundPlayer.play();
        toggleButtonModel.produceSoundEmitter.addListener(playSound);
        // pdom - signify button is 'pressed' when down
        const setAriaPressed = () => this.setPDOMAttribute('aria-pressed', valueProperty.value === valueDown);
        valueProperty.link(setAriaPressed);
        this.disposeRoundStickyToggleButton = () => {
            valueProperty.unlink(setAriaPressed);
            toggleButtonModel.produceSoundEmitter.removeListener(playSound);
            toggleButtonModel.dispose();
        };
    }
    dispose() {
        this.disposeRoundStickyToggleButton();
        super.dispose();
    }
}
sun.register('RoundStickyToggleButton', RoundStickyToggleButton);
//# sourceMappingURL=RoundStickyToggleButton.js.map