import { createControllerWithKind, Kind, } from '../../../../app/commerce-ssr-engine/types/kind.js';
import { MissingControllerProps } from '../../../../utils/errors.js';
import { buildCart } from './headless-cart.js';
/**
 * Defines a `Cart` controller instance.
 * @group Definers
 *
 * @returns The `Cart` controller definition.
 */
export function defineCart() {
    return {
        listing: true,
        search: true,
        standalone: true,
        recommendation: true,
        buildWithProps: (engine, props) => {
            if (props === undefined) {
                throw new MissingControllerProps(Kind.Cart);
            }
            const controller = buildCart(engine, { initialState: props.initialState });
            return createControllerWithKind(controller, Kind.Cart);
        },
    };
}
