"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 home_1 = __importDefault(require("./home"));
const search_1 = __importDefault(require("./search"));
const addToWishlist_1 = __importDefault(require("./addToWishlist"));
const itemPageView_1 = __importDefault(require("./itemPageView"));
const pageView_1 = __importDefault(require("./pageView"));
const land_1 = __importDefault(require("./land"));
const purchase_1 = __importDefault(require("./purchase"));
const addToCart_1 = __importDefault(require("./addToCart"));
const destination = {
    name: 'Moloco MCM',
    slug: 'actions-moloco-rmp',
    mode: 'cloud',
    description: 'This destination sends user events to Moloco MCM for machine learning and ad attribution.',
    authentication: {
        scheme: 'custom',
        fields: {
            platformId: {
                label: 'Platform ID',
                description: 'ID of the platform',
                type: 'string',
                required: true
            },
            platformName: {
                label: 'Platform Name',
                description: 'Name of the platform (default to the `Platform ID`)',
                type: 'string',
                required: false,
                default: ''
            },
            apiKey: {
                label: 'API Key',
                description: 'The API key for the platform',
                type: 'password',
                required: true
            },
            channel_type: {
                label: 'Channel Type',
                description: 'Type of channel, either APP or SITE. Defaults to SITE.',
                type: 'string',
                required: true,
                choices: [
                    { label: 'App', value: 'APP' },
                    { label: 'Site', value: 'SITE' }
                ]
            }
        }
    },
    presets: [
        {
            name: 'Search',
            subscribe: 'type = "track" and event = "Products Searched"',
            partnerAction: 'search',
            mapping: (0, actions_core_1.defaultValues)(search_1.default.fields),
            type: 'automatic'
        },
        {
            name: 'Purchase',
            subscribe: 'type = "track" and event = "Order Completed"',
            partnerAction: 'purchase',
            mapping: (0, actions_core_1.defaultValues)(purchase_1.default.fields),
            type: 'automatic'
        },
        {
            name: 'Page View',
            subscribe: 'type = "page" and properties.name != "Home" and properties.name != "Land"',
            partnerAction: 'pageView',
            mapping: (0, actions_core_1.defaultValues)(pageView_1.default.fields),
            type: 'automatic'
        },
        {
            name: 'Land',
            subscribe: 'type = "page" and properties.name = "Land"',
            partnerAction: 'land',
            mapping: (0, actions_core_1.defaultValues)(land_1.default.fields),
            type: 'automatic'
        },
        {
            name: 'Item Page View',
            subscribe: 'type = "track" and event = "Product Viewed"',
            partnerAction: 'itemPageView',
            mapping: (0, actions_core_1.defaultValues)(itemPageView_1.default.fields),
            type: 'automatic'
        },
        {
            name: 'Home',
            subscribe: 'type = "page" and properties.name = "Home"',
            partnerAction: 'home',
            mapping: (0, actions_core_1.defaultValues)(home_1.default.fields),
            type: 'automatic'
        },
        {
            name: 'Add to Wishlist',
            subscribe: 'type = "track" and event = "Product Added to Wishlist"',
            partnerAction: 'addToWishlist',
            mapping: (0, actions_core_1.defaultValues)(addToWishlist_1.default.fields),
            type: 'automatic'
        },
        {
            name: 'Add to Cart',
            subscribe: 'type = "track" and event = "Product Added"',
            partnerAction: 'addToCart',
            mapping: (0, actions_core_1.defaultValues)(addToCart_1.default.fields),
            type: 'automatic'
        }
    ],
    actions: {
        home: home_1.default,
        search: search_1.default,
        addToWishlist: addToWishlist_1.default,
        itemPageView: itemPageView_1.default,
        pageView: pageView_1.default,
        land: land_1.default,
        purchase: purchase_1.default,
        addToCart: addToCart_1.default
    }
};
exports.default = destination;
//# sourceMappingURL=index.js.map