"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const actions_core_1 = require("@segment/actions-core");
const send_1 = __importDefault(require("./send"));
const destination = {
    name: 'Rokt Conversions API',
    slug: 'actions-rokt-capi',
    mode: 'cloud',
    authentication: {
        scheme: 'custom',
        fields: {
            apiKey: {
                label: 'API Key',
                description: 'Your Rokt CAPI API Key. Contact your Rokt representative to obtain this value.',
                type: 'password',
                required: true
            },
            apiSecret: {
                label: 'API Secret',
                description: 'Your Rokt CAPI API Secret. Contact your Rokt representative to obtain this value.',
                type: 'password',
                required: true
            }
        }
    },
    extendRequest: ({ settings }) => {
        const { apiKey, apiSecret } = settings;
        return {
            headers: {
                Authorization: `Basic ${Buffer.from(`${apiKey}:${apiSecret}`).toString('base64')}`
            }
        };
    },
    presets: [
        {
            name: 'Send',
            subscribe: 'event = "Order Completed"',
            partnerAction: 'send',
            mapping: (0, actions_core_1.defaultValues)(send_1.default.fields),
            type: 'automatic'
        },
        {
            name: 'Sync Engage Audience',
            subscribe: 'type = "identify"',
            partnerAction: 'send',
            mapping: {
                ...(0, actions_core_1.defaultValues)(send_1.default.fields),
                rtid: { '@path': '$.traits.rtid' }
            },
            type: 'automatic'
        },
        {
            name: 'Rokt Browser Plugin',
            subscribe: 'type = "track" or type = "identify" or type = "page" or type = "group" or type = "alias"',
            partnerAction: 'roktPlugin',
            mapping: {},
            type: 'automatic'
        }
    ],
    actions: {
        send: send_1.default
    }
};
exports.default = destination;
//# sourceMappingURL=index.js.map