"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const api_1 = require("../api");
const input_fields_1 = require("../input-fields");
const action = {
    title: 'Remove Contact from List',
    description: 'Removes a Contact from a List.',
    defaultSubscription: 'type = "track" and event = "Remove Contact from List"',
    fields: {
        ...input_fields_1.contactIdentifier,
        listId: {
            label: 'List',
            description: `The List to remove the Contact from.`,
            type: 'number',
            required: true,
            disabledInputMethods: ['literal', 'variable', 'function', 'freeform', 'enrichment'],
            dynamic: true
        }
    },
    dynamicFields: {
        listId: async (request, { settings }) => {
            return new api_1.DDListsApi(settings, request).getLists();
        }
    },
    perform: async (request, { settings, payload }) => {
        const { channelIdentifier, emailIdentifier, mobileNumberIdentifier, listId } = payload;
        const identifierValue = channelIdentifier === 'email' ? emailIdentifier : mobileNumberIdentifier;
        const contact = new api_1.DDContactApi(settings, request);
        const response = await contact.getContact(channelIdentifier, identifierValue);
        const lists = new api_1.DDListsApi(settings, request);
        return lists.deleteContactFromList(listId, response.contactId);
    }
};
exports.default = action;
//# sourceMappingURL=index.js.map