/*!
 * KoliBri - The accessible HTML-Standard
 */
'use strict';

var elementFocus = require('./element-focus-B4BhAkh_.js');

function createCtaRef() {
    const ref = ((el) => {
        ref.el = el;
    });
    ref.el = undefined;
    return ref;
}
function makeMethodDecorator(fn) {
    return (_target, _key, descriptor) => {
        descriptor.value = async function () {
            return fn(this);
        };
        return descriptor;
    };
}
function makeFocusDecorator(fn) {
    return (_target, _key, descriptor) => {
        descriptor.value = async function (options) {
            return fn(this, options);
        };
        return descriptor;
    };
}
function directFocus(refPropName) {
    return makeFocusDecorator((self, options) => {
        var _a;
        const element = (_a = self[refPropName]) === null || _a === void 0 ? void 0 : _a.el;
        return element ? elementFocus.setFocus(element, options) : Promise.resolve();
    });
}
function directClick(refPropName) {
    return makeMethodDecorator((self) => {
        const element = self[refPropName].el;
        return element ? elementFocus.setClick(element) : Promise.resolve();
    });
}
function delegateFocus(refPropName) {
    return makeFocusDecorator((self, options) => {
        const host = self['host'];
        if (!host)
            return Promise.resolve();
        return elementFocus.delegateFocus(host, () => {
            var _a;
            const element = (_a = self[refPropName]) === null || _a === void 0 ? void 0 : _a.el;
            return element ? elementFocus.setFocus(element, options) : Promise.resolve();
        });
    });
}
function delegateClick(refPropName) {
    return makeMethodDecorator((self) => elementFocus.delegateClick(self['host'], () => {
        const element = self[refPropName].el;
        return element ? elementFocus.setClick(element) : Promise.resolve();
    }));
}

exports.createCtaRef = createCtaRef;
exports.delegateClick = delegateClick;
exports.delegateFocus = delegateFocus;
exports.directClick = directClick;
exports.directFocus = directFocus;
//# sourceMappingURL=element-interaction-CmOQWzhR.js.map

//# sourceMappingURL=element-interaction-CmOQWzhR.js.map