"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const cartLineFields_1 = require("../fields/cartLineFields");
const commonFields_1 = require("../fields/commonFields");
const customerFields_1 = require("../fields/customerFields");
const routes_1 = require("../routes");
const transform_payload_1 = require("./transform-payload");
const action = {
    title: 'Save Cart Event',
    description: 'Save a cart event.',
    fields: {
        ...commonFields_1.commonFields,
        ...customerFields_1.customerFields,
        ...cartLineFields_1.cartLineFields,
        eventName: {
            label: 'Cart Event Name',
            type: 'string',
            description: 'The name of the Cart Event to track.',
            required: true,
            choices: [
                { label: 'product_added_to_cart', value: 'product_added_to_cart' },
                { label: 'product_removed_from_cart', value: 'product_removed_from_cart' }
            ]
        }
    },
    perform: (request, data) => {
        const transformedPayload = (0, transform_payload_1.transformPayload)(data.payload);
        const payload = {
            src: 'SEGMENT',
            data: [transformedPayload]
        };
        return request(routes_1.baseURL + (0, routes_1.eventsEndpoint)(data.settings.workspaceId), {
            method: 'post',
            json: payload
        });
    }
};
exports.default = action;
//# sourceMappingURL=index.js.map