"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const fields_1 = require("./fields");
const functions_1 = require("./functions");
const hook_functions_1 = require("./hook-functions");
const action = {
    title: 'Sync Audience',
    description: 'Sync data to Facebook Custom Audiences.',
    defaultSubscription: 'type = "track" or type = "identify"',
    hooks: {
        retlOnMappingSave: {
            label: 'Select or create an audience in Facebook',
            description: 'When saving this mapping, Segment will either create a new audience in Facebook or connect to an existing one. To create a new audience, enter the name of the audience. To connect to an existing audience, select the audience ID from the dropdown.',
            inputFields: fields_1.retlHookInputFields,
            outputTypes: fields_1.retlHookOutputTypes,
            performHook: async (request, { settings, hookInputs }) => {
                const { operation, audienceName, existingAudienceId } = hookInputs;
                const { retlAdAccountId: adAccountId } = settings;
                return await (0, hook_functions_1.performHook)(request, adAccountId, operation, audienceName, existingAudienceId);
            }
        }
    },
    syncMode: {
        label: 'Sync Mode',
        description: 'Define how the records will be synced to Facebook Custom Audiences.',
        default: 'mirror',
        choices: [
            { value: 'mirror', label: 'Mirror' },
            { value: 'upsert', label: 'Upsert' },
            { value: 'delete', label: 'Delete' }
        ]
    },
    fields: fields_1.fields,
    perform: async (request, { payload, audienceMembership, hookOutputs, features, statsContext }) => {
        return await (0, functions_1.send)(request, [payload], false, [audienceMembership], hookOutputs, features, statsContext);
    },
    performBatch: async (request, { payload, audienceMembership, hookOutputs, features, statsContext }) => {
        return await (0, functions_1.send)(request, payload, true, audienceMembership, hookOutputs, features, statsContext);
    }
};
exports.default = action;
//# sourceMappingURL=index.js.map