// Copyright 2022-2025, University of Colorado Boulder
/**
 * TimeSpeedRadioButtonGroup is a radio button group for selecting TimeSpeed.
 * It's typically a subcomponent of TimeControlNode, and was originally an inner class of TimeControlNode.
 *
 * @author Denzell Barnett (PhET Interactive Simulations)
 * @author Jonathan Olson <jonathan.olson@colorado.edu>
 * @author Chris Malley (PixelZoom, Inc.)
 * @author Jesse Greenberg (PhET Interactive Simulations)
 */
import { string_scenery_phet_speed_fast_StringProperty } from './strings/speed/fast.js';
import { string_scenery_phet_speed_normal_StringProperty } from './strings/speed/normal.js';
import { string_scenery_phet_speed_slow_StringProperty } from './strings/speed/slow.js';
import { string_scenery_phet_a11y_timeControlNode_simSpeeds_StringProperty } from './strings/a11y/timeControlNode/simSpeeds.js';
import { string_scenery_phet_a11y_timeControlNode_simSpeedDescription_StringProperty } from './strings/a11y/timeControlNode/simSpeedDescription.js';
import '../../globals.js';
import optionize from '../../phet-core/js/optionize.js';
import Text from '../../scenery/js/nodes/Text.js';
import VerticalAquaRadioButtonGroup from '../../sun/js/VerticalAquaRadioButtonGroup.js';
import Tandem from '../../tandem/js/Tandem.js';
import PhetFont from './PhetFont.js';
import sceneryPhet from './sceneryPhet.js';
import TimeSpeed from './TimeSpeed.js';
// maps TimeSpeed to its label and Tandem name
const SPEED_LABEL_MAP = new Map();
SPEED_LABEL_MAP.set(TimeSpeed.FAST, {
    stringProperty: string_scenery_phet_speed_fast_StringProperty,
    tandemName: 'fastRadioButton'
});
SPEED_LABEL_MAP.set(TimeSpeed.NORMAL, {
    stringProperty: string_scenery_phet_speed_normal_StringProperty,
    tandemName: 'normalRadioButton'
});
SPEED_LABEL_MAP.set(TimeSpeed.SLOW, {
    stringProperty: string_scenery_phet_speed_slow_StringProperty,
    tandemName: 'slowRadioButton'
});
export default class TimeSpeedRadioButtonGroup extends VerticalAquaRadioButtonGroup {
    constructor(timeSpeedProperty, timeSpeeds, providedOptions) {
        const options = optionize()({
            // SelfOptions
            labelOptions: {
                font: new PhetFont(14),
                maxWidth: 130 // i18n
            },
            // VerticalAquaRadioButtonGroupOptions
            spacing: 9,
            // phetio
            tandem: Tandem.REQUIRED,
            tandemNameSuffix: 'RadioButtonGroup',
            // pdom
            labelTagName: 'h4',
            accessibleName: string_scenery_phet_a11y_timeControlNode_simSpeeds_StringProperty,
            accessibleHelpText: string_scenery_phet_a11y_timeControlNode_simSpeedDescription_StringProperty
        }, providedOptions);
        // by default, radio buttons match height of label before maxWidth scaling adjustments
        if (!options.radioButtonOptions || options.radioButtonOptions.radius === undefined) {
            if (!options.radioButtonOptions) {
                options.radioButtonOptions = {};
            }
            options.radioButtonOptions.radius = new Text('test', options.labelOptions).height / 2;
        }
        const items = timeSpeeds.map(speed => {
            const stringProperty = SPEED_LABEL_MAP.get(speed).stringProperty;
            const item = {
                value: speed,
                createNode: () => new Text(stringProperty, options.labelOptions),
                tandemName: SPEED_LABEL_MAP.get(speed).tandemName,
                options: {
                    accessibleName: stringProperty
                }
            };
            return item;
        });
        super(timeSpeedProperty, items, options);
    }
}
sceneryPhet.register('TimeSpeedRadioButtonGroup', TimeSpeedRadioButtonGroup);
