<!-- jQuery UI 1.11.4 -->
<!-- Resolve conflict in jQuery UI tooltip with Bootstrap tooltip -->
<script>
  $.widget.bridge('uibutton', $.ui.button);
</script>
<!-- Bootstrap 3.3.7 -->
<script src="{{asset('admin/bower_components/bootstrap/dist/js/bootstrap.min.js')}}"></script>
<!-- Morris.js charts -->


<script src="{{asset('admin/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js')}}"></script>
<!-- Slimscroll -->
<script src="{{asset('admin/bower_components/jquery-slimscroll/jquery.slimscroll.min.js')}}"></script>

<script src="{{asset('admin/dist/js/adminlte.min.js')}}"></script>
<!-- AdminLTE dashboard demo (This is only for demo purposes) -->
<script src="{{asset('admin/dist/js/pages/dashboard.js')}}"></script>
<!-- AdminLTE for demo purposes -->
<script src="{{asset('admin/dist/js/demo.js')}}"></script>


<!-- search item product -->
<script>
    // const search = () => {
    //     const searchbox = document.getElementById("search_input").value.toUpperCase();
    //     const storeitems = document.getElementById("sidebar-menu");
    //     const product = document.querySelectorAll(".treeview");
    //     const pname = storeitems.getElementsByTagName("span");

    //     for(var i = 0; i < pname.length; i++) {
    //         let match = product[i].getElementsByTagName('span')[0];

    //         if(match){
    //             let textvalue = match.textContent || match.innerHTML

    //             if(textvalue.toUpperCase().indexOf(searchbox) > -1) {
    //                 product[i].style.display = "";
    //             } else {
    //                 product[i].style.display = "none";
    //             }
    //         }
    //     }
    // }
    const search = () => {
        const searchbox = document.getElementById("search_input").value.toUpperCase();
        const menuItems = document.querySelectorAll(".sidebar-menu li");
        const allLinks = document.querySelectorAll(".sidebar-menu ul a");

        for (let i = 0; i < menuItems.length; i++) {
            menuItems[i].style.display = "none"; // Hide all items initially
        }

        for (let j = 0; j < allLinks.length; j++) {
            const linkText = allLinks[j].textContent || allLinks[j].innerText;
            if (linkText.toUpperCase().indexOf(searchbox) > -1) {
                allLinks[j].parentElement.style.display = ""; // Show matching item
                let parent = allLinks[j].closest(".treeview");
                if (parent) {
                    parent.style.display = ""; // Show parent item if it has a match in the submenu
                }
            }
        }
    };
</script>