// Copyright 2018-2025, University of Colorado Boulder
/**
 * Display a score as 'N *', where N is a number and '*' is a star.
 * If N is 0, it is hidden and the star is grayed out.
 * See specification in https://github.com/phetsims/vegas/issues/59.
 *
 * @author Andrea Lin
 */
import '../../globals.js';
import optionize, { combineOptions } from '../../phet-core/js/optionize.js';
import StarNode from '../../scenery-phet/js/StarNode.js';
import StatusBar from '../../scenery-phet/js/StatusBar.js';
import HBox from '../../scenery/js/layout/nodes/HBox.js';
import Text from '../../scenery/js/nodes/Text.js';
import { toFixed } from '../../dot/js/util/toFixed.js';
export default class ScoreDisplayNumberAndStar extends HBox {
    constructor(scoreProperty, providedOptions) {
        const options = optionize()({
            // SelfOptions
            font: StatusBar.DEFAULT_FONT,
            textFill: 'black',
            scoreDecimalPlaces: 0,
            starNodeOptions: {
                starShapeOptions: {
                    outerRadius: 10,
                    innerRadius: 5
                },
                filledLineWidth: 1.5,
                emptyLineWidth: 1.5
            },
            // HBoxOptions
            spacing: 5
        }, providedOptions);
        super(options);
        // Update number displayed based on score.
        const scorePropertyListener = (score) => {
            const children = [];
            if (score === 0) {
                children.push(new StarNode(combineOptions({ value: 0 }, options.starNodeOptions)));
            }
            else {
                children.push(new Text(toFixed(score, options.scoreDecimalPlaces), {
                    font: options.font,
                    fill: options.textFill
                }));
                children.push(new StarNode(combineOptions({ value: 1 }, options.starNodeOptions)));
            }
            this.children = children;
        };
        scoreProperty.link(scorePropertyListener);
        this.disposeScoreDisplayNumberAndStar = function () {
            scoreProperty.unlink(scorePropertyListener);
        };
    }
    dispose() {
        this.disposeScoreDisplayNumberAndStar();
        super.dispose();
    }
}
//# sourceMappingURL=ScoreDisplayNumberAndStar.js.map