'use strict';

var index = require('./index-BjHIBY-I.js');

/**
 * Renders a `ListComponent` as a JSX element.
 *
 * Returns `undefined` when no component is provided, when its `name` is
 * empty, or when its `name` is not a valid custom-element tag (i.e. does
 * not contain a hyphen). The hyphen requirement matches the HTML custom
 * element spec and prevents the slot from being used to render built-in
 * tags like `iframe`, `script`, or `a` with arbitrary attributes.
 *
 * If `extraClass` is provided, it is merged with any consumer-supplied
 * `class` from `component.props` and applied directly to the rendered
 * element. This lets host components style or position the rendered
 * element without wrapping it (which would otherwise block consumer
 * styles like `order` from reaching the surrounding flex layout).
 * @param component the `ListComponent` to render, or `undefined`
 * @param extraClass an optional class to apply to the rendered element,
 *                   merged with any consumer-supplied `class` in `props`
 */
function renderListComponent(component, extraClass) {
    if (!(component === null || component === void 0 ? void 0 : component.name)) {
        return;
    }
    if (!component.name.includes('-')) {
        return;
    }
    const Tag = component.name;
    const props = component.props || {};
    const mergedClass = [extraClass, props.class].filter(Boolean).join(' ') || undefined;
    return index.h(Tag, Object.assign({}, props, { class: mergedClass }));
}

exports.renderListComponent = renderListComponent;
