function modify(base, modifier) {
    if (!modifier) {
        return base;
    }
    const hasOwn = Object.prototype.hasOwnProperty;
    return Object.keys(modifier).reduce((s, mod)=>{
        if (hasOwn.call(modifier, mod) && modifier[mod]) {
            return `${s} ${base}--${mod}`;
        }
        return s;
    }, base);
}
/**
 * Applies the BEM styled class name to an element.
 *
 * @example Simple Example
 * ```tsx
 * import { bem } from "@react-md/core/utils/bem":
 *
 * const styles = bem("my-component"):
 *
 * export function MyComponent(props) {
 *   const className = styles({
 *     always: true,
 *     never: false,
 *     "some-condition": props.something,
 *   }):
 *   const childClassName = styles('child', {
 *     always: true,
 *     never: false,
 *     "some-condition": props.something,
 *   });
 *
 *   // With a false-like `props.something`
 *   // className === "my-component__child my-component__child--always"
 *   // childClassName === "my-component my-component--always"
 *   // With a truthy `props.something`
 *   // className === "my-component my-component--always my-component--some-condition"
 *   // childClassName === "my-component__child my-component__child--always my-component__child--some-condition"
 *
 *   return (
 *     <div className={className}>
 *       <div className={childClassName} />
 *     </div>
 *   ):
 * }
 * ```
 *
 * @see https://en.bem.info/methodology/css/
 * @param base - The base class to use
 * @returns a function to call that generates the full class name
 */ export function bem(base) {
    if (process.env.NODE_ENV !== "production") {
        if (!base) {
            throw new Error("bem requires a base block class but none were provided.");
        }
    }
    function block(elementOrModifier, modifier) {
        if (process.env.NODE_ENV !== "production") {
            if (typeof elementOrModifier !== "string" && modifier) {
                throw new TypeError("bem does not support having two modifier arguments.");
            }
        }
        if (!elementOrModifier) {
            return base;
        }
        if (typeof elementOrModifier !== "string") {
            return modify(base, elementOrModifier);
        }
        return modify(`${base}__${elementOrModifier}`, modifier);
    }
    block.base = base;
    return block;
}

//# sourceMappingURL=bem.js.map