"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.resizeWith = resizeWith;
exports.resizeWithObserver = resizeWithObserver;
function resizeWith(system, element, target) {
    const { api: { document: { ResizeObserver }, }, } = system;
    return resizeWithObserver(element, target, ResizeObserver);
}
function resizeWithObserver(element, target, Observer) {
    const { width, height } = target.getBoundingClientRect();
    element.setAttribute('width', `${width}`);
    element.setAttribute('height', `${height}`);
    const resizeObserver = new Observer((entries) => {
        for (const entry of entries) {
            const { width, height } = entry.contentRect;
            element.setAttribute('width', `${width}`);
            element.setAttribute('height', `${height}`);
        }
    });
    resizeObserver.observe(target);
}
//# sourceMappingURL=resizeWith.js.map