<!--**********************************
           Scripts
       ***********************************-->
<script src="<?php echo e(asset('js/this-site.js?v=1')); ?>"></script>

<!-- Metor JS -->
<script src="<?php echo e(asset('metor/js/vendor.js')); ?>"></script>
<script src="<?php echo e(asset('metor/js/app.js')); ?>"></script>

<!-- JQUI ALSO FOR DATEPICEKR -autocomplete  -->
<script src="<?php echo e(asset('jquery-ui/js/jquery-ui-1.13.js')); ?>" type="text/javascript"></script>

<!-- Chosen JQuery For searchable drop down-->
<script src="<?php echo e(asset('chosen/chosen.jquery.js')); ?>" type="text/javascript"></script>

<script>
    var BASE_URL = "<?php echo e(config('app.url')); ?>/";
    // Get the first segment of the URL after the base URL (e.g., "customers")
    var firstSegment = suSegment(0);

    // Handle image preview for Metor dropzone design
    function handleImagePreview(event, previewId) {
        const file = event.target.files[0];
        if (file) {
            const reader = new FileReader();
            reader.onload = function(e) {
                const previewDiv = document.getElementById(previewId);
                const previewImg = document.getElementById(previewId + '-img');
                const previewName = document.getElementById(previewId + '-name');
                
                if (previewDiv && previewImg) {
                    previewImg.src = e.target.result;
                    if (previewName) {
                        previewName.textContent = file.name;
                    }
                    previewDiv.style.display = 'block';
                }
            };
            reader.readAsDataURL(file);
        }
    }

    // Clear image preview
    function clearImagePreview(inputId, previewId) {
        const input = document.getElementById(inputId);
        const preview = document.getElementById(previewId);
        if (input) {
            input.value = '';
        }
        if (preview) {
            preview.style.display = 'none';
        }
        // Also clear hidden fields if they exist
        const resizedField = document.getElementById('resized-' + inputId);
        const filenameField = document.getElementById(inputId + '-filename');
        if (resizedField) resizedField.value = '';
        if (filenameField) filenameField.value = '';
    }

    // Handle file drop
    function handleFileDrop(event, inputId) {
        event.preventDefault();
        event.currentTarget.classList.remove('border-primary');
        const files = event.dataTransfer.files;
        if (files.length > 0) {
            const input = document.getElementById(inputId);
            if (input) {
                input.files = files;
                // Trigger change event
                const changeEvent = new Event('change', { bubbles: true });
                input.dispatchEvent(changeEvent);
            }
        }
    }
</script>

<?php /**PATH /Applications/MAMP/htdocs/test1/resources/views/layouts/metor/inc/footer-js.blade.php ENDPATH**/ ?>