<!--begin::Javascript-->
<script>var hostUrl = "/assets/";</script>
<!--begin::Global Javascript Bundle(mandatory for all pages)-->
<script src="/assets/plugins/global/plugins.bundle.js"></script>
<script src="/assets/js/scripts.bundle.js"></script>
<!--end::Global Javascript Bundle-->
<!--begin::Vendors Javascript(used for this page only)-->
<script src="/assets/plugins/custom/fullcalendar/fullcalendar.bundle.js"></script>
<script src="https://cdn.amcharts.com/lib/5/index.js"></script>
<script src="https://cdn.amcharts.com/lib/5/xy.js"></script>
<script src="https://cdn.amcharts.com/lib/5/percent.js"></script>
<script src="https://cdn.amcharts.com/lib/5/radar.js"></script>
<script src="https://cdn.amcharts.com/lib/5/themes/Animated.js"></script>
<script src="https://cdn.amcharts.com/lib/5/map.js"></script>
<script src="https://cdn.amcharts.com/lib/5/geodata/worldLow.js"></script>
<script src="https://cdn.amcharts.com/lib/5/geodata/continentsLow.js"></script>
<script src="https://cdn.amcharts.com/lib/5/geodata/usaLow.js"></script>
<script src="https://cdn.amcharts.com/lib/5/geodata/worldTimeZonesLow.js"></script>
<script src="https://cdn.amcharts.com/lib/5/geodata/worldTimeZoneAreasLow.js"></script>
<script src="/assets/plugins/custom/datatables/datatables.bundle.js"></script>
<!--end::Vendors Javascript-->
<?php echo $__env->yieldPushContent('plugin-script'); ?>
<!--begin::Custom Javascript(used for this page only)-->
<script src="/assets/js/widgets.bundle.js"></script>
<script src="/assets/js/custom/widgets.js"></script>
<script src="/assets/js/custom/apps/chat/chat.js"></script>
<script src="/assets/js/custom/utilities/modals/upgrade-plan.js"></script>
<script src="/assets/js/custom/utilities/modals/create-app.js"></script>
<script src="/assets/js/custom/utilities/modals/create-campaign.js"></script>
<script src="/assets/js/custom/utilities/modals/users-search.js"></script>
<script src="/assets/js/custom/typeahead.bundle.js"></script>
<script src="/assets/plugins/custom/jstree/jstree.bundle.js"></script>
<script src="/assets/plugins/custom/formrepeater/formrepeater.bundle.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vue@2.7.14"></script>

<!--end::Custom Javascript-->
<!--end::Javascript-->
<?php echo $__env->yieldPushContent('page-script'); ?>
<?php echo $__env->yieldPushContent('scripts'); ?>
<!--begin::Theme mode setup on page load-->
<script>
    var defaultThemeMode = "dark";
    var themeMode;
    console.log(themeMode);
    if ( document.documentElement ) {
        if ( document.documentElement.hasAttribute("data-bs-theme-mode")) {
            themeMode = document.documentElement.getAttribute("data-bs-theme-mode");
        } else {
            if ( localStorage.getItem("data-bs-theme") !== null ) {
                themeMode = localStorage.getItem("data-bs-theme");
                console.log(themeMode);
            } else {
                themeMode = defaultThemeMode;
            }
        }
        if (themeMode === "system") {
            themeMode = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
        }
        document.documentElement.setAttribute("data-bs-theme", themeMode);
    }
</script>

<script>
    function showLoading(){
        $("#loading-overlay").show();
    }
    function hideLoading(){
        $("#loading-overlay").hide();
    }

    function showProgressLoading(){
        $("#progress-overlay").show();
    }
    function hideProgressLoading(){
        $("#progress-overlay").hide();
    }

    function submitFormAjax(formSelector, successCallback, errorCallback) {
        $.ajaxSetup({
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            }
        });
        $.ajax({
            // type: 'POST',
            type: $(formSelector).attr('method'),
            url: $(formSelector).attr('action'),
            data: $(formSelector).serialize(),
            beforeSend: function(){
                showLoading();
            },
            success: function(response) {
                console.log(response);
                if (response.status === true) {
                    hideLoading();
                    if(response.hasOwnProperty("message") &&
                        response.message !== null &&
                        response.message !== ""){
                        Swal.fire({
                            title: 'Success!',
                            text: response.message,
                            icon: 'success',
                            button: 'OK'
                        }).then(function() {
                            if (typeof successCallback === 'function') {
                                successCallback(response);
                            }
                        });
                    }else{
                        if (typeof successCallback === 'function') {
                            successCallback(response);
                        }
                    }

                } else {
                    hideLoading();
                    Swal.fire({
                        title: 'Error!',
                        text: response.message,
                        icon: 'error',
                        button: 'OK'
                    }).then(function() {
                        if (typeof errorCallback === 'function') {
                            errorCallback(response);
                        }
                    });
                }
            },
            error: function(error) {
                hideLoading();
                checkTokenExpired(error);
                Swal.fire({
                    title: 'Error!',
                    text: error.responseJSON.message,
                    icon: 'error',
                    button: 'OK'
                }).then(function() {
                    if (typeof errorCallback === 'function') {
                        errorCallback(error);
                    }
                });
            }
        });
    }

    function sendAjaxRequest(url, data, successCallback=false, errorCallback=false) {
        $.ajaxSetup({
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            }
        });
        $.ajax({
            type: "POST",
            data: data,
            url: url,
            beforeSend: function(){
                showLoading();
            },
            success: function(data) {
                hideLoading();
                if (data.status === true) {
                    if(data.message !== undefined && data.message !== ""){
                        Swal.fire(data.message).then((result) => {
                            if(typeof successCallback === 'function')
                                successCallback(data);
                        });
                    }else{
                        if(typeof successCallback === 'function'){
                            console.log(data);
                            successCallback(data);
                        }
                    }

                } else {
                    if(typeof errorCallback === 'function')
                        errorCallback(data);
                    if(data.message !== undefined && data.message !== "") {
                        Swal.fire(data.message);
                    }
                }
            },
            error: function (data) {
                // data = JSON.parse(data.responseText);
                // console.log(data);
                hideLoading();
                checkTokenExpired(data);
                if(typeof errorCallback === 'function')
                    errorCallback(data);
                Swal.fire("<?php echo app('translator')->get('Error, please try again'); ?>");
            }
        });
    }

    function checkTokenExpired(response){
        if(response.hasOwnProperty('responseJSON') && response.responseJSON.hasOwnProperty('message') && response.responseJSON.message === 'CSRF token mismatch.')
            location.reload();
        else
            swal.fire('Error', 'error');
    }

    function numberWithCommas(x) {
        return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
    }
</script>
<?php /**PATH D:\work\techbithub\AAH\aah-hr-site\resources\views/layouts/vertical/_script.blade.php ENDPATH**/ ?>