"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.batch_size = exports.enable_batching = exports.products = exports.total = exports.order_id = exports.timestamp = exports.email_action_identifiers = exports.user_identifiers = exports.data = exports.event_action = exports.event_type = void 0;
exports.event_type = {
    label: 'Optimizely Event Type',
    description: 'The Optimizely Event Type. Defaults to "custom" if not provided',
    type: 'string',
    required: false,
    default: {
        '@path': '$.event'
    }
};
exports.event_action = {
    label: 'Optimizely Event Action',
    description: 'The name of the Optimizely Event Action.',
    type: 'string',
    required: false
};
exports.data = {
    label: 'Event Properties',
    description: 'Additional information to send with your custom event',
    type: 'object',
    required: false,
    default: {
        '@path': '$.properties'
    }
};
exports.user_identifiers = {
    label: 'User identifiers',
    description: 'User identifier details to send to Optimizely. ',
    type: 'object',
    required: true,
    properties: {
        anonymousId: {
            label: 'Segment Anonymous ID',
            type: 'string',
            description: 'Segment Anonymous ID',
            required: false
        },
        userId: {
            label: 'Segment User ID',
            type: 'string',
            description: 'Segment User ID',
            required: false
        },
        email: {
            label: 'Email',
            type: 'string',
            description: 'User Email address',
            required: false
        },
        optimizely_vuid: {
            label: 'Optimizely VUID',
            type: 'string',
            description: 'Optimizely VUID - user cookie generated created by Optimizely Javascript library',
            required: false
        },
        fs_user_id: {
            label: 'Feature Experimentation ID',
            type: 'string',
            description: 'Feature Experimentation user ID',
            required: false
        },
        web_user_id: {
            label: 'Web Experimentation ID',
            type: 'string',
            description: 'Web User ID',
            required: false
        }
    },
    default: {
        anonymousId: {
            '@path': '$.anonymousId'
        },
        userId: {
            '@path': '$.userId'
        },
        email: {
            '@if': {
                exists: { '@path': '$.properties.email' },
                then: { '@path': '$.properties.email' },
                else: { '@path': '$.traits.email' }
            }
        },
        optimizely_vuid: {
            '@if': {
                exists: { '@path': '$.properties.optimizely_vuid' },
                then: { '@path': '$.properties.optimizely_vuid' },
                else: { '@path': '$.traits.optimizely_vuid' }
            }
        },
        fs_user_id: {
            '@path': '$.userId'
        },
        web_user_id: {
            '@path': '$.userId'
        }
    }
};
exports.email_action_identifiers = {
    ...exports.user_identifiers,
    properties: {
        ...(exports.user_identifiers.properties ?? {}),
        email: {
            required: true,
            label: 'Email',
            type: 'string',
            description: 'User Email address. This is a required field'
        }
    },
    default: {
        ...exports.user_identifiers.default,
        email: {
            '@if': {
                exists: { '@path': '$.properties.email' },
                then: { '@path': '$.properties.email' },
                else: { '@path': '$.context.traits.email' }
            }
        },
        optimizely_vuid: {
            '@if': {
                exists: { '@path': '$.properties.optimizely_vuid' },
                then: { '@path': '$.properties.optimizely_vuid' },
                else: { '@path': '$.context.traits.optimizely_vuid' }
            }
        }
    }
};
exports.timestamp = {
    label: 'Timestamp',
    description: 'Event timestamp',
    type: 'string',
    required: true,
    default: {
        '@path': '$.timestamp'
    }
};
exports.order_id = {
    label: 'Order ID',
    description: 'Identifier for the order',
    type: 'string',
    default: {
        '@path': '$.properties.order_id'
    }
};
exports.total = {
    label: 'Order Total',
    description: 'Total value of the order',
    type: 'string',
    default: {
        '@path': '$.properties.total'
    }
};
exports.products = {
    label: 'Product details',
    description: 'Product details to associate with the event. Product ID field is required for each product',
    type: 'object',
    multiple: true,
    properties: {
        product_id: {
            label: 'Product ID',
            description: 'Identifier for the product',
            type: 'string'
        },
        qty: {
            label: 'Quantity',
            description: 'Quantity of the product',
            type: 'number'
        }
    },
    default: {
        '@arrayPath': [
            '$.properties.products',
            {
                product_id: { '@path': '$.product_id' },
                qty: { '@path': '$.quantity' }
            }
        ]
    }
};
exports.enable_batching = {
    label: 'Enable Batching',
    description: 'Enable batching of event data to Optimizely.',
    type: 'boolean',
    default: true,
    unsafe_hidden: true
};
exports.batch_size = {
    label: 'Batch Size',
    description: 'Number of events to batch before sending to Optimizely.',
    type: 'integer',
    default: 100,
    unsafe_hidden: true
};
//# sourceMappingURL=fields.js.map