// Copyright 2016-2025, University of Colorado Boulder
/**
 * Shows a Dialog with content describing keyboard interactions. Opened via a button in the navigation bar.
 *
 * @author Jesse Greenberg
 */
import { string_joist_a11y_keyboardHelp_tabToGetStarted_StringProperty } from './strings/a11y/keyboardHelp/tabToGetStarted.js';
import { string_joist_keyboardShortcuts_title_StringProperty } from './strings/keyboardShortcuts/title.js';
import { string_joist_keyboardShortcuts_toGetStarted_StringProperty } from './strings/keyboardShortcuts/toGetStarted.js';
import '../../globals.js';
import '../../chipper/js/browser/initialize-globals.js';
import Multilink from '../../axon/js/Multilink.js';
import optionize from '../../phet-core/js/optionize.js';
import KeyboardHelpSectionRow from '../../scenery-phet/js/keyboard/help/KeyboardHelpSectionRow.js';
import TextKeyNode from '../../scenery-phet/js/keyboard/TextKeyNode.js';
import PhetFont from '../../scenery-phet/js/PhetFont.js';
import VoicingText from '../../scenery/js/accessibility/voicing/nodes/VoicingText.js';
import ReadingBlock from '../../scenery/js/accessibility/voicing/ReadingBlock.js';
import HBox from '../../scenery/js/layout/nodes/HBox.js';
import VBox from '../../scenery/js/layout/nodes/VBox.js';
import Node from '../../scenery/js/nodes/Node.js';
import Dialog from '../../sun/js/Dialog.js';
import Tandem from '../../tandem/js/Tandem.js';
// constants
const TITLE_MAX_WIDTH = 670;
const tabToGetStartedStringProperty = string_joist_a11y_keyboardHelp_tabToGetStarted_StringProperty;
export default class KeyboardHelpDialog extends Dialog {
    constructor(screens, screenProperty, providedOptions) {
        const options = optionize()({
            titleAlign: 'center',
            fill: 'rgb( 214, 237, 249 )',
            ySpacing: 15,
            // phet-io
            phetioReadOnly: true, // the KeyboardHelpDialog should not be settable
            phetioDynamicElement: true,
            // Append the title to the close button
            closeButtonVoicingDialogTitle: string_joist_keyboardShortcuts_title_StringProperty,
            isDisposable: false
        }, providedOptions);
        const content = new Node({
            // help content surrounded by a div unless already specified, so that all content is read when dialog opens
            tagName: 'div'
        });
        const contentTandem = options.tandem.createTandem('content');
        const screenContentNodes = [];
        screens.forEach(screen => {
            ;
            const screenTandem = screen.tandem.supplied ? contentTandem.createTandem(screen.tandem.name) : Tandem.REQUIRED;
            const keyboardHelpNode = screen.createKeyboardHelpNode(screenTandem);
            screenContentNodes.push(keyboardHelpNode);
        });
        const shortcutsTitleText = new VoicingText(string_joist_keyboardShortcuts_title_StringProperty, {
            font: new PhetFont({
                weight: 'bold',
                size: 24
            }),
            maxWidth: TITLE_MAX_WIDTH,
            // voicing options - No PDOM for this text because the title is provided through the accessibleName of the dialog.
            accessibleParagraph: null
        });
        // a 'tab to get started' hint
        const tabHintLine = new TabHintLine();
        // stack the two items with a bit of spacing
        ;
        const titleVBox = new VBox({
            children: [shortcutsTitleText, tabHintLine],
            spacing: 5
        });
        options.title = titleVBox;
        super(content, options);
        // When the screen changes, swap out keyboard help content to the selected screen's content
        Multilink.multilink([screenProperty, this.isShowingProperty], (screen, isShowing) => {
            ;
            const currentContentNode = screenContentNodes[screens.indexOf(screen)];
            if (isShowing) {
                ;
                content.children = [currentContentNode];
            }
        });
        // support for binder documentation, stripped out in builds and only runs when ?binder is specified
        false;
    }
}
class TabHintLine extends ReadingBlock(Node) {
    constructor(providedOptions) {
        const options = optionize()({
            readingBlockNameResponse: tabToGetStartedStringProperty
        }, providedOptions);
        super();
        const tabIcon = TextKeyNode.tab();
        // a line to say "tab to get started" below the "Keyboard Shortcuts" 'title'
        const labelWithIcon = KeyboardHelpSectionRow.labelWithIcon(string_joist_keyboardShortcuts_toGetStarted_StringProperty, tabIcon, {
            labelInnerContent: tabToGetStartedStringProperty,
            iconOptions: {
                tagName: 'p' // because there is only one, and the default is an li tag
            }
        });
        // labelWithIcon is meant to be passed to KeyboardHelpSection, so we have to hack a bit here
        const hBox = new HBox({
            children: [labelWithIcon.icon, labelWithIcon.label],
            spacing: 4
        });
        this.addChild(hBox);
        this.mutate(options);
    }
}
//# sourceMappingURL=KeyboardHelpDialog.js.map