import { BooleanValue, RecordValue, Schema, StringValue } from '@coveo/bueno';
import { cartDefinition } from '../../features/commerce/context/cart/cart-validation.js';
import { contextDefinition } from '../../features/commerce/context/context-validation.js';
import { nonEmptyString } from '../../utils/validate-payload.js';
import { engineConfigurationDefinitions, } from '../engine-configuration.js';
export const commerceEngineConfigurationSchema = new Schema({
    ...engineConfigurationDefinitions,
    analytics: new RecordValue({
        options: { required: true },
        values: {
            enabled: new BooleanValue({ required: false, default: true }),
            proxyBaseUrl: new StringValue({ required: false, url: true }),
            source: new RecordValue({
                options: { required: false },
                values: {
                    '@coveo/atomic': nonEmptyString,
                    '@coveo/quantic': nonEmptyString,
                },
            }),
            trackingId: new StringValue({
                required: true,
                emptyAllowed: false,
                regex: /^[a-zA-Z0-9_\-.]{1,100}$/,
            }),
        },
    }),
    context: new RecordValue({
        options: { required: true },
        values: contextDefinition,
    }),
    cart: new RecordValue({
        values: cartDefinition,
    }),
    proxyBaseUrl: new StringValue({ required: false, url: true }),
});
export function getSampleCommerceEngineConfiguration() {
    return {
        // This API key is intentionally public — it belongs to a sample organization used for samples/docs.
        accessToken: 'xx564559b1-0045-48e1-953c-3addd1ee4457',
        analytics: {
            trackingId: 'sports-ui-samples',
        },
        context: {
            language: 'en',
            country: 'US',
            currency: 'USD',
            view: {
                url: 'https://sports.barca.group',
            },
        },
        cart: {
            items: [
                {
                    productId: 'SP01057_00001',
                    quantity: 1,
                    name: 'Kayaker Canoe',
                    price: 800,
                },
                {
                    productId: 'SP00081_00001',
                    quantity: 1,
                    name: 'Bamboo Canoe Paddle',
                    price: 120,
                },
                {
                    productId: 'SP04236_00005',
                    quantity: 1,
                    name: 'Eco-Brave Rashguard',
                    price: 33,
                },
                {
                    productId: 'SP04236_00005',
                    quantity: 1,
                    name: 'Eco-Brave Rashguard',
                    price: 33,
                },
            ],
        },
        organizationId: 'searchuisamples',
    };
}
