import '../../../globals.js';
// Copyright 2013-2024, University of Colorado Boulder
/**
 * Base class for molecules with N atoms aligned on the horizontal axis, for N > 0.
 * Note that here is technically no such thing as a single-atom molecule,
 * but allowing N=1 simplifies the Equation model.
 *
 * Origin is at geometric center of the node's bounding rectangle.
 *
 * @author Chris Malley (PixelZoom, Inc.)
 * @author Jonathan Olson <jonathan.olson@colorado.edu>
 */
import optionize from '../../../phet-core/js/optionize.js';
import nitroglycerin from '../nitroglycerin.js';
import AtomNode from './AtomNode.js';
import MoleculeNode from './MoleculeNode.js';
export default class HorizontalMoleculeNode extends MoleculeNode {
    constructor(elements, providedOptions) {
        const options = optionize()({
            direction: 'leftToRight',
            overlapPercent: 0.25
        }, providedOptions);
        // Add atoms from left to right, overlapping consistently.
        const atomNodes = [];
        let previousNode = null;
        elements.forEach(element => {
            const currentNode = new AtomNode(element, options.atomNodeOptions);
            atomNodes.push(currentNode);
            if (previousNode !== null) {
                const overlap = (options.overlapPercent * currentNode.width);
                if (options.direction === 'leftToRight') {
                    currentNode.left = previousNode.right - overlap;
                }
                else {
                    currentNode.right = previousNode.left + overlap;
                }
            }
            previousNode = currentNode;
        });
        super(atomNodes, options);
    }
}
nitroglycerin.register('HorizontalMoleculeNode', HorizontalMoleculeNode);
//# sourceMappingURL=HorizontalMoleculeNode.js.map