import './jquery-3.7.1.min.js';

// Project Router

const projectRouter = document.querySelector(".project-router");
const projectRouterProgress = document.querySelector('.project-router-progress');

function updateProgress(event){
    try{
        let item = projectRouter.querySelector(".owl-stage").children[event.item.index].children[0];
        let count = event.item.count - event.page.size;
        if((count + "").length==1){count = "0"+count}
        let index = event.item.index;
        let prog = (100 * (index / count));
        let progress = prog + "%";
        $(projectRouterProgress).get(0).style.setProperty("--project-router-progress", progress);
        if (prog == 0){
            $(".project-router-prev").css("opacity", 0);
        }else{
            $(".project-router-prev").css("opacity", 1);
        }
        if (prog == 100){
            $(".project-router-next").css("opacity", 0);
        }else{
            $(".project-router-next").css("opacity", 1);
        }
    }catch (e){
    }
}

$(projectRouter).on('changed.owl.carousel', (event)=>{
    updateProgress(event);
});

$(".featured-slider").trigger('next.owl.carousel', 4000)
setInterval(()=>{
    $(".featured-slider").trigger('next.owl.carousel', 4000)
}, 4000)

document.querySelector(".project-router-close-wrapper").addEventListener("click", (event)=>{
    $(".logo-container-wrapper:has(.project-router-nav)").removeClass("active");
})