@if(!isset($_REQUEST['optimised']))
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Scholar</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="/AdminLTE-3.0.5/plugins/fontawesome-free/css/all.min.css">
    <!-- Theme style -->
    <link rel="stylesheet" href="/AdminLTE-3.0.5/dist/css/adminlte.min.css">
    <!-- overlayScrollbars -->
    <link rel="stylesheet" href="/AdminLTE-3.0.5/plugins/overlayScrollbars/css/OverlayScrollbars.min.css">

    <link rel="stylesheet" href="{{asset('jquery-ui/jquery-ui.min.css')}}">


    <link href=/css/z.css rel=stylesheet>

    <style>
        .loading-rotate {
            -webkit-animation: spin 0.3s linear infinite;
            -moz-animation: spin 0.3s linear infinite;
            animation: spin 0.3s linear infinite;
        }

        @-moz-keyframes spin {
            100% {
                -moz-transform: rotate(360deg);
            }
        }

        @-webkit-keyframes spin {
            100% {
                -webkit-transform: rotate(360deg);
            }
        }

        @keyframes spin {
            100% {
                -webkit-transform: rotate(360deg);
                transform: rotate(360deg);
            }
        }
    </style>

    {{-- stag theme --}}
    <link rel="stylesheet" href="/css/theme.css">
</head>

<body class="hold-transition sidebar-mini layout-fixed">
    <div class="wrapper">

        <!-- Navbar -->
        <nav class="main-header navbar navbar-expand navbar-white navbar-light">
            <!-- Left navbar links -->
            <ul class="navbar-nav">
                <li class="nav-item">
                    <a class="nav-link" data-widget="pushmenu" href="#" role="button"><i class="fas fa-bars"></i></a>
                </li>
            </ul>

            <!-- Right navbar links -->
            {{--<ul class="navbar-nav ml-auto ml-2">
            <li class="nav-item">
                <a id="reload-icon" class="nav-link" href="#" role="button" onclick="window.location.reload(); return false">
                    <i class="fa fa-sync"></i>
                </a>
            </li>
        </ul>--}}

            <ul class="navbar-nav ml-auto ml-2">
                <li class="nav-item">
                    <a class="nav-link small d-flex align-items-center" href="#" title="Cell# {{$pro->cell_number}}">
                        Hello {{$pro->name_first}}!
                    </a>
                </li>

                <li class="nav-item">
                    <a class="nav-link small d-flex align-items-center" href="{{env('HCP_PORTAL_URL', 'https://pro.securecpu.com')}}/pro_log_in_with_session_key/{{$performer->session_key}}" title="">
                        Go to HCP portal
                    </a>
                </li>
            </ul>

            <!-- SEARCH FORM -->
            <form class="form-inline ml-2 w-25 stag-search-form">
                <div class="input-group input-group-sm w-100">
                    <input class="form-control form-control-navbar" type="search" placeholder="Search" aria-label="Search">
                    <div class="input-group-append">
                        <button class="btn btn-navbar" type="submit">
                            <i class="fas fa-search"></i>
                        </button>
                    </div>
                </div>
            </form>

            <ul class="navbar-nav ml-2 ml-2">
                <li class="nav-item">
                    <a class="nav-link px-2" href="/api/session/logOut" target="_top" role="button" logout>
                        <i class="fas fa-sign-out-alt"></i>
                    </a>
                </li>
            </ul>
        </nav>
        <!-- /.navbar -->

        @endif

        <!-- Main Sidebar Container -->
        <aside class="main-sidebar sidebar-light-primary elevation-4">
            <!-- Brand Logo -->
            <a href="#" class="brand-link">
                <img src="/AdminLTE-3.0.5/dist/img/AdminLTELogo.png" alt="AdminLTE Logo" class="brand-image img-circle elevation-3" style="opacity: .8">
                <span class="brand-text font-weight-light">Scholar</span>
            </a>

            <!-- Sidebar -->
            <div class="sidebar">

                <!-- Sidebar Menu -->
                <nav class="mt-2">
                    <ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu" data-accordion="false" id="main-sidenav">
                        <li class="nav-item">
                            <a href="/dashboard" class="nav-link {{ request()->route()->getActionName() === 'App\Http\Controllers\ProController@dashboard' ? 'active' : '' }}">
                                <i class="nav-icon fa fa-palette"></i>
                                <p>
                                    Dashboard
                                </p>
                            </a>
                            @if(\Illuminate\Support\Facades\View::exists('layouts.generated-links'))
                            @include('layouts.generated-links')
                            @endif
                    </ul>
                </nav>
                <!-- /.sidebar-menu -->
            </div>
            <!-- /.sidebar -->
        </aside>

        @if(!isset($_REQUEST['optimised']))
        <!-- Content Wrapper. Contains page content -->
        <div class="content-wrapper">
            <!-- Main content -->
            <section class="content p-0">
                <div class="container-fluid p-0">
                    <div class="row mb-2 mx-0">
                        @endif
                        <div class="col-12 px-0" id="main-content">
                            @yield('content')
                        </div>
                        @if(!isset($_REQUEST['optimised']))
                    </div>
                </div><!-- /.container-fluid -->
            </section>
            <!-- /.content -->
        </div>

    </div>
    <!-- ./wrapper -->

    <!-- Google Font: Source Sans Pro -->
    <link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700" rel="stylesheet">

    <!-- jQuery -->
    <script src="/AdminLTE-3.0.5/plugins/jquery/jquery.min.js"></script>
    <!-- overlayScrollbars -->
    <script src="/AdminLTE-3.0.5/plugins/overlayScrollbars/js/jquery.overlayScrollbars.min.js"></script>
    <!-- AdminLTE App -->
    <script src="/AdminLTE-3.0.5/dist/js/adminlte.js"></script>

    <!-- unpoly -->
    <script src="/unpoly-0.62.0/es6-promise.min.js"></script>
    <script src="/unpoly-0.62.0/es6-promise.auto.min.js"></script>
    <script src="/unpoly-0.62.0/unpoly.min.js"></script>
    <link rel="stylesheet" href="/unpoly-0.62.0/unpoly.min.css">
    <script src="{{asset('jquery-ui/jquery-ui.min.js')}}"></script>

    <style>
        .up-modal-content {
            padding: 0;
        }

        .up-modal-close {
            display: none;
        }

        .up-modal-dialog {
            border-radius: 8px;
            overflow: hidden;
        }

        .inner-side-nav {
            width: 200px;
        }

        .inner-content {
            width: calc(100% - 200px);
        }
    </style>

    {{--<script>
    if(window === window.top) {
        window.location.href = '/mc' + window.location.pathname;
    }
</script>--}}

    <script>
        $(document).ready(function() {

            /*let stagCache = {}, stagCacheDone = {};
            function clearStagCache() {
                stagCache = {};
            }
            function preloadIntoStagCache(_target, _done) {
                if(!!stagCache[_target] && stagCache[_target] !== 'loading') {
                    if(_done) _done(_data);
                    else if(stagCacheDone[_target]) {
                        stagCacheDone[_target](_done);
                        stagCacheDone[_target] = false;
                    }
                    console.log('Not pre-loading. Already in cache!');
                    return;
                }
                stagCache[_target] = 'loading';
                $.get('/' + _target + '?optimised=1', function(_data) {
                    stagCache[_target] = _data;
                    if(_done) _done(_data);
                    else if(stagCacheDone[_target]) {
                        stagCacheDone[_target](_data);
                        stagCacheDone[_target] = false;
                    }
                });
            }
            function getFromStagCache(_target, _done) {
                if(!stagCache[_target]) { // unlikely to be hit if using mouse clicks
                    preloadIntoStagCache(_target, _done);
                }
                else if(stagCache[_target] === 'loading') {
                    stagCacheDone[_target] = _done;
                }
                else {
                    _done(stagCache[_target]);
                }
            }
            function gotoTarget(target, pushState) {
                getFromStagCache(target, function(_data) {
                    $('#reload-icon').removeClass('loading-rotate');
                    if(pushState) {
                        window.top.history.pushState(target, null, '/mc/' + target);
                    }
                    var received = $('<div>' + _data + '</div>');
                    $('#main-content').replaceWith(received.find('#main-content'));
                    var activeHref = received.find('#main-sidenav').find('.nav-link.active').attr('href');
                    $('#main-sidenav a.nav-link.active').removeClass('active').blur();
                    $('#main-sidenav a[href="' + activeHref + '"]').addClass('active');
                    $(window).scrollTop(0);
                    window.setTimeout(function() {
                        clearStagCache();
                    }, 250);
                });
            }
            $(document).on('mouseenter', 'a:not([href="#"]):not([up-modal]):not([up-close]):not([no-ajax]):not([logout])', function() {
                var target = this.href;
                if(target.indexOf('//') !== -1) {
                    target = target.split('//')[1];
                    if(target.indexOf('/') !== -1) {
                        target = target.substr(target.indexOf('/') + 1);
                    }
                }
                preloadIntoStagCache(target);
            });
            $(document).on('click', 'a:not([href="#"]):not([up-modal]):not([up-close]):not([no-ajax]):not([logout])', function() {
                $('#reload-icon').addClass('loading-rotate');
                var target = this.href;
                if(target.indexOf('//') !== -1) {
                    target = target.split('//')[1];
                    if(target.indexOf('/') !== -1) {
                        target = target.substr(target.indexOf('/') + 1);
                    }
                }
                gotoTarget(target, true);
                return false;
            });
            $(document).on('submit', 'form[action="/post-to-api"]:not(.custom-submit)', function() {
                $('#reload-icon').addClass('loading-rotate');
                $.post(this.action, $(this).serialize(), function(_data) {
                    $('#main-content').replaceWith($(_data).find('#main-content'));
                    $(window).scrollTop(0);
                    $('#reload-icon').removeClass('loading-rotate');
                });
                return false;
            });
            window.top.addEventListener('popstate', function(event) {
                if(!!event.state) {
                    gotoTarget(event.state, false);
                }
            });*/
            $(document).on('click', '[logout]', function() {
                $.get('/api/session/logOut', function(_data) {
                    window.top.location = '/';
                });
            });
        });
    </script>

    <script>
        $(document).ready(function() {
            $(function() {
                $("#sortable-section-templates").sortable({
                    stop: function(event, ui) {
                        var sectionTemplates = [];
                        $('#sortable-section-templates').children('tr').each(function(index, element) {
                            var sectionTemplateInternalName = $(element).attr('data-internal-name');
                            console.log(index, sectionTemplateInternalName);
                            sectionTemplates.push({
                                positionIndex: index,
                                internalName: sectionTemplateInternalName
                            });
                        })
                        console.log(sectionTemplates);
                        $.ajax({
                            type: "POST",
                            url: '/api/sectionTemplate/sort',
                            data: JSON.stringify(sectionTemplates),
                            contentType: 'application/json',
                            success: function(response){
                                console.log(response);
                            },
                            dataType: 'json'
                        });
                    }
                });
                $("#sortable-section-templates").disableSelection();
            });
        })
    </script>

</body>

</html>
@endif