@php
    $bodyClass = 'article-detail';
    $layout_path = 'frontend.layouts.content-sidebar';
    if($item->layout_type == 'blocks') {
        $bodyClass .= ' article-detail--blocks';
        $layout_path = 'frontend.layouts.main';

        if($item->header_overlap) {
            $bodyClass .= ' header-over';
        }
    }
@endphp

@extends($layout_path, [
    'body_class' => $bodyClass
])

@if($item->layout_type == 'blocks')

    @section('content')
        <div class="article-detail__content">
            @include('frontend.templates.components.blocks_section', ['blocks' => $item->blocks])
        </div>
    @stop

@else

    @section('content-toolbar')
        @if(!$item->document->isEmpty() && $type != 'publication')
            <a
                target="_blank"
                class="download-btn download-btn--simple"
                href="{{ url('/uploads/media/' . $item->document->first()->filename) }}"
            ></a>
        @endif
        @if(!empty($item->pardot_url))
            <a
                href="#"
                class="download-btn download-btn--simple"
                data-download_id="{{ $item->id }}"
                data-download="{{ base64_encode(json_encode(["title" => $item->title, "url" => $item->pardot_url ])) }}"
                data-controller="components/form-modal"
                data-popupid="download-modal"
            >
            </a>
        @endif
        @include('frontend.templates.components.share_buttons')
    @stop

    @section('content-top')
        <div class="article-detail__header">
            <h1>@title($item->title)</h1>

            <div class="article-detail__header-info">
                <div class="article-detail__info">
                    <span class="article-detail__date">
                        @if($type == 'event')
                            {{ event_date($item->date, $item->end_date) }}
                        @else
                            {{ format_date($item->date, true) }}
                        @endif
                    </span>
                    @if(!empty($item->author))
                        <span class="article-detail__name">@lang('frontend.by') {{ $item->author }}</span>
                    @endif
                    @if(!empty($item->location))
                        <span class="article-detail__name">{{ $item->location }}</span>
                    @endif
                    @if(!empty($item->type))
                        <span>@lang('frontend.article_type_' . $item->type)</span>
                    @endif
                    @if($type == 'event')
                        <span>{{ $eventsDetail->undertitle }}</span>
                    @endif
                </div>
            </div>
        </div>
    @stop
    @section('content-left')
        @if($item->media)
            <div class="article-detail__image">
                {!! getMediaImg($item->media, '800w', htmlspecialchars($item->title)) !!}
            </div>
        @endif
        <div class="rich-content">
            {!! $item->content ? $item->content : $item->summary !!}
        </div>
        @if($type == 'event' && $item->pardotForm)
            <a
                href="#"
                class="pardot-form-open events-content-button std-button blue-button"
                data-fields="{{ base64_encode(json_encode($pardotData)) }}"
                data-formid="{{ $item->pardotForm->id }}"
                data-formurl="{{ $item->pardotForm->form_url }}"
                data-controller="components/form-modal"
                data-popupid="pardot-modal"
            >
                {{ !empty($item->pardot_button_label) ? $item->pardot_button_label : 'Register' }}
            </a>
        @endif
        @if($type == 'publication' && !empty($item->pardot_url))
            <a
                href="#"
                class="pardot-form-open events-content-button std-button blue-button"
                data-download_id="{{ $item->id }}"
                data-download="{{ base64_encode(json_encode(["title" => $item->title, "url" => $item->pardot_url ])) }}"
                data-controller="components/form-modal"
                data-popupid="download-modal"
            >
                Download Now
            </a>
        @endif
        @if(!empty($item->cta))
            {!! generateLink($eventsDetail->cta, 'std-button blue-button events-content-button') !!}
        @endif
        <br>
        @if(!empty($backUrl))
            <a
                href="#"
                class="article-detail__return-to-list"
                data-action="go-back"
            >@lang('frontend.return_to_list')</a>
        @endif
    @stop
@endif
