import Tooltip from "bootstrap/js/src/tooltip";
import Dropdown from "bootstrap/js/src/dropdown";
import Collapse from "bootstrap/js/src/collapse";
import Modal from "bootstrap/js/src/modal";

export default function () {
    applyBootstrapPlugin('[data-bs-toggle="tooltip"]', Tooltip);
    applyBootstrapPlugin('[data-bs-toggle="dropdown"]', Dropdown);
    applyBootstrapPlugin('[data-bs-toggle="collapse"]', Collapse);
    applyBootstrapPlugin('div.modal', Modal);
}

function applyBootstrapPlugin(selector, plugin) {
    let els = document.querySelectorAll(selector);
    els.forEach((el) => {
        let key = 'aaBootstrap' + plugin.name;
        console.log(key);
        el[key] = new plugin(el);
    });
}