"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const index_1 = require("../index");
const experimentationOpToCFOpMap = {
    [index_1.Experimentation.Operations.InsertBefore]: ['before', (html) => [html, { html: true }]],
    [index_1.Experimentation.Operations.InsertAfter]: ['after', (html) => [html, { html: true }]],
    [index_1.Experimentation.Operations.Prepend]: ['prepend', (html) => [html, { html: true }]],
    [index_1.Experimentation.Operations.Append]: ['append', (html) => [html, { html: true }]],
    [index_1.Experimentation.Operations.Replace]: ['replace', (html) => [html, { html: true }]],
    [index_1.Experimentation.Operations.SetInnerHtml]: ['setInnerContent', (html) => [html, { html: true }]],
    [index_1.Experimentation.Operations.Remove]: ['remove', () => []],
    [index_1.Experimentation.Operations.SetAttribute]: ['setAttribute', (name, value) => [name, value]],
};
class PreUATransformApplicator {
    constructor(op, ...args) {
        this.op = op;
        this.args = args;
    }
    element(element) {
        if (!this.op)
            return;
        // If it's a simple operation that translates to a CloudFlare worker method,
        // we can directly execute it.
        const translatedOperation = experimentationOpToCFOpMap[this.op];
        if (translatedOperation) {
            const [method, fnArgTranslator] = translatedOperation;
            // @ts-ignore
            element[method].call(element, ...fnArgTranslator(...this.args));
            return;
        }
        // Handle any complex operations that involves multiple CF operations.
    }
}
exports.default = PreUATransformApplicator;
