<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
    <meta name="description" content="" />
    <meta name="keywords" content="" />
    <link rel="shortcut icon" href="{{url('')}}/assets/web/images/fav.png" title="Favicon" sizes="16x16" />

    <meta name="csrf-token" content="{{ csrf_token() }}" />
    <!--With LTR -->
    @if(getCurrentLocale() == 'en')
        <link rel="stylesheet" href="{{url('')}}/assets/web/css/lib/bootstrap.min.css">
    @endif
    <!--  -->

    <!--With RTL -->
    @if(getCurrentLocale() == 'ar')
        <link rel="stylesheet" href="{{url('')}}/assets/web/css/lib/bootstrap.rtl.min.css" />
    @endif
    <!--  -->

    <!-- google Karla & Pinyon fonts -->
    <link href="https://fonts.googleapis.com/css2?family=Karla:wght@200;300;400;500;600;700;800&family=Sedgwick+Ave+Display&display=swap" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Pinyon+Script&display=swap" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Sedgwick+Ave+Display&display=swap" rel="stylesheet">
    <!--  -->

    <!-- google Baloo font -->
    <link href="https://fonts.googleapis.com/css2?family=Baloo+Bhaijaan+2:wght@400;500;600;700;800&display=swap" rel="stylesheet">
    <!--  -->

    <link rel="stylesheet" href="{{url('')}}/assets/web/css/lib/animate.css" />
    <link rel="stylesheet" href="{{url('')}}/assets/web/css/lib/jquery.fancybox.css" />
    <link rel="stylesheet" href="{{url('')}}/assets/web/css/lib/swiper.min.css" />
    <link rel="stylesheet" href="{{url('')}}/assets/web/css/lib/all.min.css" />
    <link rel="stylesheet" href="{{url('')}}/assets/web/css/lib/bootstrap_icons.css" />
    <link rel="stylesheet" href="{{url('')}}/assets/web/css/lib/jquery-ui.css" />
    <link rel="stylesheet" href="{{url('')}}/assets/web/css/style.css?v={{ time() }}" />
    @if(getCurrentLocale() == 'ar')
        <link rel="stylesheet" href="{{url('')}}/assets/web/css/style_ar.css?v={{ time() }}">
    @endif
    <title> {{__('web.project')}} | {{$title ?? ''}}</title>
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.js"></script>
    <link  rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.css">

</head>

<body class="">

<!--  start cursor  -->
<!--<div class="mouse-cursor cursor-outer"></div>-->
<!--<div class="mouse-cursor cursor-inner"></div>-->
<div id="preloader">
    <div id="loading-wrapper" class="show">
        <div id="loading-text"> loading </div>
        <div id="loading-content"></div>
    </div>
</div>


        @include('web.layouts.menu')
        <!-- Modal -->
        @yield('content')

        @include('web.layouts.footer')
        <!--Js Files & Libraries-->
        <!--Js Files & Libraries-->
        <script src="{{url('')}}/assets/web/js/lib/jquery-3.0.0.min.js"></script>
        <script src="{{url('')}}/assets/web/js/lib/jquery-migrate-3.0.0.min.js"></script>
        <script src="{{url('')}}/assets/web/js/lib/bootstrap.bundle.min.js"></script>
        <script src="{{url('')}}/assets/web/js/lib/wow.min.js"></script>
        <script src="{{url('')}}/assets/web/js/lib/jquery.fancybox.js"></script>
        <script src="{{url('')}}/assets/web/js/lib/swiper.min.js"></script>
        <script src="{{url('')}}/assets/web/js/lib/jquery.waypoints.min.js"></script>
        <script src="{{url('')}}/assets/web/js/lib/jquery.counterup.js"></script>
        <script src="{{url('')}}/assets/web/js/lib/back-to-top.js"></script>
        <script src="{{url('')}}/assets/web/js/lib/gsap.min.js"></script>
        <script src="{{url('')}}/assets/web/js/lib/particles.min.js"></script>
        <script src="{{url('')}}/assets/web/js/lib/particls.js"></script>
        <script src="{{url('')}}/assets/web/js/lib/jquery-ui.min.js"></script>
        <script src="{{url('')}}/assets/web/js/main.js?v={{ time() }}"></script>
        <!-- Google tag (gtag.js) -->
        <script async src="https://www.googletagmanager.com/gtag/js?id=G-4S1PCQK0GP"></script>
        <script>
          window.dataLayer = window.dataLayer || [];
          function gtag(){dataLayer.push(arguments);}
          gtag('js', new Date());
        
          gtag('config', 'G-4S1PCQK0GP');
        </script>
        @yield('inject_js')
        @if ($errors->any())
            <script>

                setTimeout(
                    function()
                    {
                        toasterError({!! json_encode($errors->first()) !!});
                    }, 500);
            </script>
        @endif
        <script>
                if("{{Session::has('error')}}")
                {
                    setTimeout(
                        function()
                        {
                            toasterError({!! json_encode(Session::get('error')) !!});
                        }, 500);
                }
            </script>

            <script>
                if("{{session('success')}}")
                {
                    setTimeout(
                        function()
                        {
                            toasterSuccess("{{session('success')}}");
                        }, 500);
                }
            </script>
            <script>
                function addToCart(elem)
                {
                    
                    // Get the event object
                    const event = window.event;

                    // Prevent the default action (following the link)
                    event.preventDefault();

                    if("{{\Auth::user()}}")
                    {
                        let url = "{{route('cart.store')}}";
                        let count = $(elem).attr('count-id');
                        if(count == null)
                        {
                            count = $('#count_product').val();
                            console.log(count)
                        }
                        let product_id = $(elem).attr('data-id')
                        $.ajax
                        ({
                            url : url,
                            type: "POST",
                            headers: {
                                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                            },
                            data: 'product_id='+product_id+'&count='+count,
                            dataType:'json',
                            success:function(data)
                            {
                                getCartCount()
                                toasterSuccess(data.message);
                            }
                            ,error:function(data)
                            {
                                toasterError(Object.values(data.responseJSON.errors)[0]);
                            }
                        })
                    }
                    else
                    {
                        window.location.replace("{{route('web.login')}}");
                    }
                }
            </script>
            @if(auth()->user())
                <script>
                    function getCartCount()
                    {
                        $.ajax
                        ({
                            url : "{{route('cartCount')}}",
                            type: "GET",
                            headers: {
                                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                            },
                            dataType:'json',
                            success:function(data)
                            {
                                if (data.data > 0) {
                                    $('.cart-count-container').html(`<span id="cartCount">${data.data}</span>`);
                                }
                                if (data.data === 0 && $('#cartCount').length > 0) {
                                    $('#cartCount').remove();
                                }
                            }
                            ,error:function(data)
                            {
                                toasterError(Object.values(data.responseJSON.errors)[0]);
                            }
                        })
                    }
                    setTimeout(
                    function()
                    {
                        getCartCount()
                    }, 1000);
                </script>
            @endif
            <script src="{{url('')}}/assets/web/js/custom/formAction.js"></script>
            <script src="{{url('')}}/assets/web/js/custom/response.js"></script>
            <script src="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.js"></script>
    </body>
</html>
