<!doctype html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}" <?php if (str_replace('_', '-', app()->getLocale()) == 'ar' || @$_COOKIE['is_rtl'] == 'true') { ?> dir="rtl" <?php } ?>>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- CSRF Token -->
    <meta name="csrf-token" content="{{ csrf_token() }}">
    <title>{{ config('app.name', 'GoRide') }}</title>
    <link rel="icon" id="favicon" type="image/x-icon" href="">
    <!-- Fonts -->
    <link rel="dns-prefetch" href="//fonts.gstatic.com">
    <link href="https://fonts.googleapis.com/css?family=Nunito" rel="stylesheet">
    <!-- Styles -->
    <link href="{{ asset('assets/plugins/bootstrap/css/bootstrap.min.css') }}" rel="stylesheet">
    <?php if (str_replace('_', '-', app()->getLocale()) == 'ar' || @$_COOKIE['is_rtl'] == 'true') { ?>
    <link href="{{asset('assets/plugins/bootstrap/css/bootstrap-rtl.min.css')}}" rel="stylesheet">
    <?php } ?>
    <link href="{{ asset('css/style.css') }}" rel="stylesheet">
    <?php if (str_replace('_', '-', app()->getLocale()) == 'ar' || @$_COOKIE['is_rtl'] == 'true') { ?>
    <link href="{{asset('css/style_rtl.css')}}" rel="stylesheet">
    <?php } ?>
    <link href="{{ asset('css/icons/font-awesome/css/font-awesome.css') }}" rel="stylesheet">
    <link href="{{ asset('css/icons/font-awesome/css/all.css') }}" rel="stylesheet">
    <link href="{{ asset('assets/plugins/toast-master/css/jquery.toast.css')}}" rel="stylesheet">
    <link href="{{ asset('css/colors/blue.css') }}" rel="stylesheet">
    <link href="{{ asset('css/chosen.css') }}" rel="stylesheet">
    <link href="{{ asset('css/bootstrap-tagsinput.css') }}" rel="stylesheet">
    <link href="{{ asset('assets/plugins/summernote/summernote-bs4.css') }}" rel="stylesheet">
    <link href="{{ asset('vendor/select2/dist/css/select2.min.css')}}" rel="stylesheet">
    <link
        href="https://fonts.googleapis.com/css2?family=Nunito:ital,wght@0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap"
        rel="stylesheet">
    <link rel="stylesheet" href="https://cdn.datatables.net/1.13.4/css/jquery.dataTables.min.css">
    <link rel="stylesheet" href="https://cdn.datatables.net/responsive/2.4.1/css/responsive.dataTables.min.css">
    <?php if (isset($_COOKIE['admin_panel_color'])) { ?>
    <style type="text/css">
        .topbar {
            background:
                <?php    echo $_COOKIE['admin_panel_color']; ?>
            ;
        }
        .left-sidebar {
            background:
                <?php    echo $_COOKIE['admin_panel_color']; ?>
            ;
        }
        .sidebar-nav ul li a {
            border-bottom:
                <?php    echo $_COOKIE['admin_panel_color']; ?>
            ;
        }
        .sidebar-nav {
            background:
                <?php    echo $_COOKIE['admin_panel_color']; ?>
            ;
        }
        .sidebar-nav ul li a:hover i {
            color:
                <?php    echo $_COOKIE['admin_panel_color']; ?>
            ;
        }
        .vendor_payout_create-inner fieldset legend {
            background:
                <?php    echo $_COOKIE['admin_panel_color']; ?>
            ;
        }
        .restaurant_payout_create-inner fieldset legend {
            background:
                <?php    echo $_COOKIE['admin_panel_color']; ?>
            ;
        }
        a {
            color:
                <?php    echo $_COOKIE['admin_panel_color']; ?>
            ;
        }
        a:hover,
        a:focus {
            color:
                <?php    echo $_COOKIE['admin_panel_color']; ?>
            ;
        }
        a.link:hover,
        a.link:focus {
            color:
                <?php    echo $_COOKIE['admin_panel_color']; ?>
            ;
        }
        html body blockquote {
            border-left: 5px solid<?php    echo $_COOKIE['admin_panel_color']; ?>;
        }
        .text-warning {
            color:
                <?php    echo $_COOKIE['admin_panel_color']; ?>
                !important;
        }
        .text-info {
            color:
                <?php    echo $_COOKIE['admin_panel_color']; ?>
                !important;
        }
        .sidebar-nav ul li a:hover {
            color:
                <?php    echo $_COOKIE['admin_panel_color']; ?>
            ;
        }
        .btn-primary {
            background:
                <?php    echo $_COOKIE['admin_panel_color']; ?>
            ;
            border: 1px solid<?php    echo $_COOKIE['admin_panel_color']; ?>;
        }
        .sidebar-nav>ul>li.active>a {
            color:
                <?php    echo $_COOKIE['admin_panel_color']; ?>
            ;
            border-left: 3px solid<?php    echo $_COOKIE['admin_panel_color']; ?>;
        }
        .sidebar-nav>ul>li.active>a i {
            color:
                <?php    echo $_COOKIE['admin_panel_color']; ?>
            ;
        }
        .bg-info {
            background-color:
                <?php    echo $_COOKIE['admin_panel_color']; ?>
                !important;
        }
        .bellow-text ul li>span {
            color:
                <?php    echo $_COOKIE['admin_panel_color']; ?>
        }
        .table tr td.redirecttopage {
            color:
                <?php    echo $_COOKIE['admin_panel_color']; ?>
        }
        ul.rating {
            color:
                <?php    echo $_COOKIE['admin_panel_color']; ?>
            ;
        }
        .nav-tabs.card-header-tabs .nav-link.active,
        .nav-tabs.card-header-tabs .nav-link:hover {
            background:
                <?php    echo $_COOKIE['admin_panel_color']; ?>
            ;
            border-color:
                <?php    echo $_COOKIE['admin_panel_color']; ?>
                <?php    echo $_COOKIE['admin_panel_color']; ?>
                #fff;
        }
        .btn-warning,
        .btn-warning.disabled {
            background:
                <?php    echo $_COOKIE['admin_panel_color']; ?>
            ;
            border: 1px solid<?php    echo $_COOKIE['admin_panel_color']; ?>;
            box-shadow: none;
        }
        .payment-top-tab .nav-tabs.card-header-tabs .nav-link.active,
        .payment-top-tab .nav-tabs.card-header-tabs .nav-link:hover {
            border-color:
                <?php    echo $_COOKIE['admin_panel_color']; ?>
            ;
        }
        .nav-tabs.card-header-tabs .nav-link span.badge-success {
            background:
                <?php    echo $_COOKIE['admin_panel_color']; ?>
            ;
        }
        .nav-tabs.card-header-tabs .nav-link.active span.badge-success,
        .nav-tabs.card-header-tabs .nav-link:hover span.badge-success,
        .sidebar-nav ul li a.active,
        .sidebar-nav ul li a.active:hover,
        .sidebar-nav ul li.active a.has-arrow:hover,
        .topbar ul.dropdown-user li a:hover {
            color:
                <?php    echo $_COOKIE['admin_panel_color']; ?>
            ;
        }
        .sidebar-nav ul li a.has-arrow:hover::after,
        .sidebar-nav .active>.has-arrow::after,
        .sidebar-nav li>.has-arrow.active::after,
        .sidebar-nav .has-arrow[aria-expanded="true"]::after,
        .sidebar-nav ul li a:hover {
            border-color:
                <?php    echo $_COOKIE['admin_panel_color']; ?>
            ;
        }
        [type="checkbox"]:checked+label::before {
            border-right: 2px solid<?php    echo $_COOKIE['admin_panel_color']; ?>;
            border-bottom: 2px solid<?php    echo $_COOKIE['admin_panel_color']; ?>;
        }
        .btn-primary:hover,
        .btn-primary.disabled:hover {
            background:
                <?php    echo $_COOKIE['admin_panel_color']; ?>
            ;
            border: 1px solid<?php    echo $_COOKIE['admin_panel_color']; ?>;
        }
        .btn-primary.active,
        .btn-primary:active,
        .btn-primary:focus,
        .btn-primary.disabled.active,
        .btn-primary.disabled:active,
        .btn-primary.disabled:focus,
        .btn-primary.active.focus,
        .btn-primary.active:focus,
        .btn-primary.active:hover,
        .btn-primary.focus:active,
        .btn-primary:active:focus,
        .btn-primary:active:hover,
        .open>.dropdown-toggle.btn-primary.focus,
        .open>.dropdown-toggle.btn-primary:focus,
        .open>.dropdown-toggle.btn-primary:hover,
        .btn-primary.focus,
        .btn-primary:focus,
        .btn-primary:not(:disabled):not(.disabled).active:focus,
        .btn-primary:not(:disabled):not(.disabled):active:focus,
        .show>.btn-primary.dropdown-toggle:focus,
        .btn-warning:hover,
        .btn-warning:hover,
        .btn-warning.disabled:hover,
        .btn-warning.active.focus,
        .btn-warning.active:focus,
        .btn-warning.active:hover,
        .btn-warning.focus:active,
        .btn-warning:active:focus,
        .btn-warning:active:hover,
        .open>.dropdown-toggle.btn-warning.focus,
        .open>.dropdown-toggle.btn-warning:focus,
        .open>.dropdown-toggle.btn-warning:hover,
        .btn-warning.focus,
        .btn-warning:focus {
            background:
                <?php    echo $_COOKIE['admin_panel_color']; ?>
            ;
            border-color:
                <?php    echo $_COOKIE['admin_panel_color']; ?>
            ;
            box-shadow: 0 0 0 0.2rem<?php    echo $_COOKIE['admin_panel_color']; ?>;
        }
        .language-options select option,
        .pagination>li>a.page-link:hover {
            background:
                <?php    echo $_COOKIE['admin_panel_color']; ?>
            ;
        }
        .mini-sidebar .sidebar-nav #sidebarnav>li:hover a i,
        .mini-sidebar .sidebar-nav ul li a,
        .sidebar-nav ul li a.active i,
        .sidebar-nav ul li a.active:hover i,
        .sidebar-nav ul li.active a:hover i {
            color:
                <?php    echo $_COOKIE['admin_panel_color']; ?>
            ;
        }
        .cat-slider .cat-item a.cat-link:hover,
        .cat-slider .cat-item.section-selected a.cat-link {
            border-color:
                <?php    echo $_COOKIE['admin_panel_color']; ?>
            ;
        }
        .cat-slider .cat-item a.cat-link {
            border-bottom-color:
                <?php    echo $_COOKIE['admin_panel_color']; ?>
            ;
        }
        .cat-slider .cat-item.section-selected a.cat-link:after {
            border-color:
                <?php    echo $_COOKIE['admin_panel_color']; ?>
            ;
            background:
                <?php    echo $_COOKIE['admin_panel_color']; ?>
            ;
        }
        .cat-slider {
            border-color:
                <?php    echo $_COOKIE['admin_panel_color']; ?>
            ;
        }
        .business-analytics .card-box i {
            background:
                <?php    echo $_COOKIE['admin_panel_color']; ?>
            ;
        }
        .order-status .data i,
        .order-status span.count {
            color:
                <?php    echo $_COOKIE['admin_panel_color']; ?>
            ;
        }
        .print-btn button {
            border-color:
                <?php    echo $_COOKIE['admin_panel_color']; ?>
            ;
            color:
                <?php    echo $_COOKIE['admin_panel_color']; ?>
            ;
        }
        [type="radio"]:checked+label::after,
        [type="radio"].with-gap:checked+label::after {
            background-color:
                <?php    echo $_COOKIE['admin_panel_color']; ?>
            ;
        }
        [type="radio"]:checked+label::after,
        [type="radio"].with-gap:checked+label::before,
        [type="radio"].with-gap:checked+label::after {
            border: 2px solid
                <?php    echo $_COOKIE['admin_panel_color']; ?>
            ;
        }
        .sidebar-nav ul li ul li a:hover, .sidebar-nav ul li ul li.active > a.active{color: <?php    echo $_COOKIE['admin_panel_color']; ?>;border-color:<?php    echo $_COOKIE['admin_panel_color']; ?>;}
        table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control::before, table.dataTable.dtr-inline.collapsed > tbody > tr > th.dtr-control::before {background-color: <?php    echo $_COOKIE['admin_panel_color']; ?>;}
        .card-header .nav{background: <?php    echo $_COOKIE['admin_panel_color']; ?>; border-color: <?php    echo $_COOKIE['admin_panel_color']; ?>;}
        .profile-card,.p-icon{background: <?php echo $_COOKIE['admin_panel_color']; ?>;}
        .table tr td .action-btn .chat-count-message .unread-count{background: <?php echo $_COOKIE['admin_panel_color']; ?>}
        @media screen and (max-width: 767px) {
            .mini-sidebar .sidebar-nav ul li a:hover,
            .sidebar-nav>ul>li.active>a {
                color:
                    <?php    echo $_COOKIE['admin_panel_color']; ?>
                    !important;
            }
            .mini-sidebar .sidebar-nav #sidebarnav>li:hover a i,
            .mini-sidebar .sidebar-nav ul li a,
            .sidebar-nav ul li a.active i,
            .sidebar-nav ul li a.active:hover i,
            .sidebar-nav ul li.active a:hover i {
                color: #fff;
            }
            .sidebar-nav>ul>li.active>a,
            .sidebar-nav>ul>li.active>a i,
            .sidebar-nav>ul>li>a:hover i {
                color:
                    <?php    echo $_COOKIE['admin_panel_color']; ?>
                    !important;
            }
        }
    </style>
    <?php } ?>
</head>
<body>
    <div id="app" class="fix-header fix-sidebar card-no-border">
        <div id="main-wrapper">
            <header class="topbar">
                <nav class="navbar top-navbar navbar-expand-md navbar-light">
                    @include('layouts.header')
                </nav>
            </header>
            <aside class="left-sidebar">
                <!-- Sidebar scroll-->
                <div class="scroll-sidebar">
                    @include('layouts.menu')
                </div>
                <!-- End Sidebar scroll-->
            </aside>
            <footer class="footer">
                @include('layouts.footer')
            </footer>
        </div>
        <main class="py-4">
            @yield('content')
            <div id="overlay" style="display:none">
                <img src="{{ asset('images/spinner.gif') }}">
            </div>
        </main>
    </div>
    <script src="{{ asset('js/jquery.min.js') }}"></script>
    <script src="{{ asset('assets/plugins/bootstrap/js/popper.min.js') }}"></script>
    <script src="{{ asset('assets/plugins/bootstrap/js/bootstrap.min.js') }}"></script>
    <script src="{{ asset('js/jquery.slimscroll.js') }}"></script>
    <script src="{{ asset('js/waves.js') }}"></script>
    <script src="{{ asset('js/sidebarmenu.js') }}"></script>
    <script src="{{ asset('assets/plugins/sticky-kit-master/dist/sticky-kit.min.js') }}"></script>
    <script src="{{ asset('assets/plugins/sparkline/jquery.sparkline.min.js')}}"></script>
    <script src="{{ asset('js/custom.min.js') }}"></script>
    <script src="{{ asset('assets/plugins/summernote/summernote-bs4.js')}}"></script>
    <script src="{{ asset('js/jquery.resizeImg.js') }}"></script>
    <script src="{{ asset('js/mobileBUGFix.mini.js') }}"></script>
    <script src="https://www.gstatic.com/firebasejs/9.23.0/firebase-app-compat.js"></script>
    <script src="https://www.gstatic.com/firebasejs/9.23.0/firebase-firestore-compat.js"></script>
    <script src="https://www.gstatic.com/firebasejs/9.23.0/firebase-storage-compat.js"></script>
    <script src="https://www.gstatic.com/firebasejs/9.23.0/firebase-auth-compat.js"></script>
    <script src="https://www.gstatic.com/firebasejs/9.23.0/firebase-database-compat.js"></script>
    <script src="https://unpkg.com/geofirestore/dist/geofirestore.js"></script>
    <script src="https://cdn.firebase.com/libs/geofire/5.0.1/geofire.min.js"></script>
    <script src="{{ asset('js/chosen.jquery.js') }}"></script>
    <script src="{{ asset('js/bootstrap-tagsinput.js') }}"></script>
    <script src="{{ asset('vendor/select2/dist/js/select2.min.js') }}"></script>
    <script src="{{ asset('js/crypto-js.js') }}"></script>
    <script src="{{ asset('js/jquery.cookie.js') }}"></script>
    <script src="{{ asset('js/jquery.validate.js') }}"></script>
    <script type="text/javascript" src="https://cdn.datatables.net/1.13.4/js/jquery.dataTables.min.js"></script>
    <script type="text/javascript"src="https://cdn.datatables.net/responsive/2.4.1/js/dataTables.responsive.min.js"></script>
    <script src="{{ asset('js/jquery.masking.js') }}"></script>
    <script>
        
        var appLogo = '';
        var appFavIconLogo = '';
        var googleApiKey = '';
        var database = firebase.firestore();
        const datatableLang = {
            "decimal":        "",
            "emptyTable":     "{{ trans('lang.no_record_found') }}",
            "info":           "{{ trans('lang.datatable_info') }}", 
            "infoEmpty":      "{{ trans('lang.datatable_info_empty') }}", 
            "infoFiltered":   "{{ trans('lang.datatable_info_filtered') }}", 
            "lengthMenu":     "{{ trans('lang.datatable_length_menu') }}",
            "loadingRecords": "{{ trans('lang.loading') }}",
            "processing":     "{{ trans('lang.processing') }}",
            "search":         "{{ trans('lang.search') }}",
            "zeroRecords":    "{{ trans('lang.no_record_found') }}",
            "paginate": {
                "first":      "{{ trans('lang.first') }}",
                "last":       "{{ trans('lang.last') }}",
                "next":       "{{ trans('lang.next') }}",
                "previous":   "{{ trans('lang.previous') }}"
            },
            "aria": {
                "sortAscending":  ": {{ trans('lang.sort_asc') }}",
                "sortDescending": ": {{ trans('lang.sort_desc') }}"
            }
        };
        let globalRef = database.collection('settings').doc('global');
        globalRef.get().then(async function (snapshots) {
            var globalSetting = snapshots.data();
            if (globalSetting.appVersion != '') {
                $(".web_version").text('V:' + globalSetting.appVersion);
            }
        });
        $(document).ready(function () {
            let globalLogoRef = database.collection('settings').doc('logo');
            globalLogoRef.get().then(async function (snapshots) {
                var globalLogoSetting = snapshots.data();
                $("#favicon").attr("href", globalLogoSetting.appFavIconLogo)
                $(".dark-logo").attr("src", globalLogoSetting.appLogo);
                $(".light-logo").attr("src", globalLogoSetting.appLogo);
                // appLogo = (globalLogoSetting.appLogo) ? globalLogoSetting.appLogo : "{{ asset('images/goride-logo.png') }}";
                // appFavIconLogo = (globalLogoSetting.appFavIconLogo) ? globalLogoSetting.appFavIconLogo : "{{ asset('images/favicon.png') }}";
            });
        });
        var refGlobalSetting = database.collection('settings').doc('globalKey');
        refGlobalSetting.get().then(function (globalData) {
            var globalValue = globalData.data();
            if (globalValue && globalValue.hasOwnProperty('distanceType')) {
                $('.global_value_label').html("{{trans('lang.per')}} "+(globalValue.distanceType).slice(0,1).toUpperCase()+ (globalValue.distanceType).substring(1) + " {{trans('lang.charge')}}" + '<span class="required-field"></span>');
                $('.global_value_text').html("{{trans('lang.enter')}} {{trans('lang.per')}} " + (globalValue.distanceType).slice(0, 1).toUpperCase() + (globalValue.distanceType).substring(1) + " {{trans('lang.charge')}}");
                $('#distanceType').val(globalValue.distanceType);
            } else {
                $('.global_value_text').html('{{ trans("lang.km_charge_help") }}');
                $('#distanceType').val('Km');
            }
        });
        async function sendNotification(fcmToken = '', title, body, payload = null) {
            var checkFlag = false;
            var sendNotificationUrl = "{{ route('send-notification') }}";
            if (fcmToken !== '') {
                await $.ajax({
                    type: 'POST',
                    url: sendNotificationUrl,
                    data: {
                        _token: $('meta[name="csrf-token"]').attr('content'),
                        'fcm': fcmToken,
                        'title': title,
                        'message': body,
                        'payload': JSON.stringify(payload)
                    },
                    success: function (data) {
                        checkFlag = true;
                    },
                    error: function (error) {
                        checkFlag = true;
                    }
                });
            } else {
                checkFlag = true;
            }
            return checkFlag;
        }
    </script>
    <script type="text/javascript">
        // var doNotDeleteAlert = "This is for demo, We can not allow to delete";
        // var doNotUpdateAlert = "This is for demo, We can not allow to update content";
        jQuery(window).scroll(function () {
            var scroll = jQuery(window).scrollTop();
            if (scroll <= 60) {
                jQuery("body").removeClass("sticky");
            } else {
                jQuery("body").addClass("sticky");
            }
        });
        var langcount = 0;
        var languages_list = database.collection('languages');
        languages_list.get().then(async function (snapshotslang) {
            if (snapshotslang.docs.length > 0) {
                let defaultLang = "<?php echo session()->get('locale') ?? 'en'; ?>";
                console.log(defaultLang);
                snapshotslang.docs.forEach((doc) => {
                    var data = doc.data();
                    if (data.enable == true) {
                        langcount++;
                        var option = $("<option></option>")
                            .attr("value", data.id)
                            .attr("data-isrtl", data.isRtl)
                            .attr("data-code", data.code)
                            .text(data.name);
                        if (data.code === defaultLang) {
                            option.attr("selected", "selected");
                        }
                        $('#language_dropdown').append(option);
                    }
                });
                if (langcount > 1) {
                    $("#language_dropdown_box").css('visibility', 'visible');
                }
            }
        });
        var url = "{{ route('changeLang') }}";
        $(document).on("change", ".changeLang", function () {
            var code = $(this).find(':selected').data('code');
            var isrtl = $(this).find(':selected').data('isrtl');
            if (isrtl == true) {
                setCookie('is_rtl', isrtl.toString(), 365);
            } else {
                setCookie('is_rtl', 'false', 365);
            }
            window.location.href = url + "?lang=" + code;
        });
        function setCookie(cname, cvalue, exdays) {
            const d = new Date();
            d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
            let expires = "expires=" + d.toUTCString();
            document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
        }
        function getCookie(name) {
            var nameEQ = name + "=";
            var ca = document.cookie.split(';');
            for (var i = 0; i < ca.length; i++) {
                var c = ca[i];
                while (c.charAt(0) == ' ') c = c.substring(1, c.length);
                if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
            }
            return null;
        }
        async function loadGoogleMapsScript() {
            var globalKeySnapshot = await database.collection('settings').doc("globalKey").get();
            var globalKeyData = globalKeySnapshot.data();
            googleMapKey = globalKeyData.googleMapKey;
            const script = document.createElement('script');
            script.src = "https://maps.googleapis.com/maps/api/js?key=" + googleMapKey + "&libraries=drawing,geometry,places";
            script.onload = function () {
                navigator.geolocation.getCurrentPosition(GeolocationSuccessCallback, GeolocationErrorCallback);
            };
            document.head.appendChild(script);
        }
        const GeolocationSuccessCallback = (position) => {
            if (position.coords != undefined) {
                default_latitude = position.coords.latitude
                default_longitude = position.coords.longitude
                setCookie('default_latitude', default_latitude, 365);
                setCookie('default_longitude', default_longitude, 365);
            }
        };
        const GeolocationErrorCallback = (error) => {
            console.log('Error: You denied for your default Geolocation', error.message);
            setCookie('default_latitude', '23.022505', 365);
            setCookie('default_longitude', '72.571365', 365);
        };
        loadGoogleMapsScript();
        database.collection('settings').doc("notification_settings").get().then(async function (snapshots) {
            var data = snapshots.data();
            if(data != undefined){
                serviceJson = data.serviceJson;
                if(serviceJson != '' && serviceJson != null){
                    $.ajax({
                        type: 'POST',
                        data: {
                            serviceJson: btoa(serviceJson),
                        },
                        url: "{{ route('store-firebase-service') }}",
                        headers: {
                            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                        },
                        success: function (data) {
                        }
                    });
                }
            }
        });
          //On delete item delete image also from bucket general code
      const deleteDocumentWithImage = async (collection, id, singleImageField, arrayImageField) => {
        // Reference to the Firestore document
        const docRef = database.collection(collection).doc(id);
        try {
            const doc = await docRef.get();
            if (!doc.exists) {
                console.log("No document found for deletion");
                return;
            }
            const data = doc.data();
            // Handle single image deletion
                   // Deleting single image field
                   if (singleImageField) {
                    if (Array.isArray(singleImageField)) {
                        for (const field of singleImageField) {
                            const imageUrl = data[field];
                            if (imageUrl) await deleteImageFromBucket(imageUrl);
                        }
                    } else {
                        const imageUrl = data[singleImageField];
                        if (imageUrl) await deleteImageFromBucket(imageUrl);
                    }
                }
                // Deleting array image field
                if (arrayImageField) {
                    if (Array.isArray(arrayImageField)) {
                        for (const field of arrayImageField) {
                            const arrayImages = data[field];
                            if (arrayImages && Array.isArray(arrayImages)) {
                                for (const imageUrl of arrayImages) {
                                    if (imageUrl) await deleteImageFromBucket(imageUrl);
                                }
                            }
                        }
                    } else {
                        const arrayImages = data[arrayImageField];
                        if (arrayImages && Array.isArray(arrayImages)) {
                            for (const imageUrl of arrayImages) {
                                if (imageUrl) await deleteImageFromBucket(imageUrl);
                            }
                        }
                    }
                }
            // Optionally delete the Firestore document after image deletion
            await docRef.delete();
            console.log("Document and images deleted successfully.");
        } catch (error) {
            console.error("Error deleting document and images:", error);
        }
    };
    const deleteImageFromBucket = async (imageUrl) => {
        try {
            const storageRef = firebase.storage().ref();
            // Check if the imageUrl is a full URL or just a child path
            let oldImageUrlRef;
            if (imageUrl.includes('https://')) {
                // Full URL
                oldImageUrlRef = storageRef.storage.refFromURL(imageUrl);
            } else {
                // Child path, use ref instead of refFromURL
                oldImageUrlRef = storageRef.storage.ref(imageUrl);
            }
            var envBucket = "<?php echo env('FIREBASE_STORAGE_BUCKET'); ?>";
            var imageBucket = oldImageUrlRef.bucket;
            // Check if the bucket name matches
            if (imageBucket === envBucket) {
                // Delete the image
                await oldImageUrlRef.delete();
                console.log("Image deleted successfully.");
            }
        } catch (error) {
        }
    };
    </script>
    @yield('scripts')
</body>
</html>
