<?php $iName = $segment->segmentTemplate->internal_name; ?>
<?php $isLSSegment = strpos($iName, 'lifestyle_') === 0; ?>
<div class="ml-2">
    @if($iName === 'medrisk_vigilence')
        <div class="font-weight-bold text-center flex-grow-1">
            <div class="on-hover-hide font-weight-normal text-info font-weight-bold text-center pt-2 font-size-11">MRV</div>
            <span class="on-hover-only text-left">MedRisk Vigilence</span>
        </div>
    @else
        <span class="font-weight-bold d-flex align-items-center {{$isLSSegment || $iName === 'medrisk_vigilence' ? '' : 'xxxmb-2'}}" style="">
            <span style="color: black; text-decoration: underline; font-size: 13px;">
    @if($isLSSegment && $iName === 'lifestyle_general')
                Lifestyle
            @else
                {{$segment->display_title}}
            @endif
    </span>
            @if($segment->heading && $iName !== 'medrisk_vigilence')
                <span class="text-secondary ml-2 text-sm font-weight-normal">({{$segment->heading}})</span>
            @endif
        </span>
    @endif

    @if($isLSSegment)
        @if($iName === 'lifestyle_general')
            <a href="#" class="ls-segment-trigger ml-2" data-target="lifestyle_general">General</a>
            <span class="mx-2 text-secondary text-sm">|</span>
            <a href="#" class="ls-segment-trigger" data-target="lifestyle_nutrition">Nutrition</a>
            <span class="mx-2 text-secondary text-sm">|</span>
            <a href="#" class="ls-segment-trigger" data-target="lifestyle_physical_activity">Physical Act.</a>
            <span class="mx-2 text-secondary text-sm">|</span>
            <a href="#" class="ls-segment-trigger" data-target="lifestyle_sleep">Sleep</a>
            <span class="mx-2 text-secondary text-sm">|</span>
            <a href="#" class="ls-segment-trigger" data-target="lifestyle_social">Social Relns.</a>
            <span class="mx-2 text-secondary text-sm">|</span>
            <a href="#" class="ls-segment-trigger" data-target="lifestyle_substances">Subst. Use</a>
            <span class="mx-2 text-secondary text-sm">|</span>
            <a href="#" class="ls-segment-trigger" data-target="lifestyle_stress">Stress</a>
        @else
            <span class="text-info ml-auto font-weight-normal">(click to view)</span>
        @endif
    @endif
</div>
@if($segment->proposedSegmentSummarySuggestion && ($segment->proposedSegmentSummarySuggestion->status == 'PENDING' || $segment->proposedSegmentSummarySuggestion->status == 'REJECTED') )
    <div class=" m-2 p-2">
        <div class="d-flex align-items-start mb-2">
            <b class="mr-2 width-70px">Original:</b>
            <div class="border py-2 px-2 flex-grow-1 inline-html-container">{!! $segment->summary_html !!}</div>
        </div>
        <div class="d-flex align-items-start mb-2">
            <b class="mr-2 width-70px">Proposed:</b>
            <div class="border border-info py-2 px-2 flex-grow-1 inline-html-container">{!! $segment->proposedSegmentSummarySuggestion->summary_html !!}</div>
        </div>
        @if($segment->proposedSegmentSummarySuggestion->status == 'REJECTED')
        <div class="alert alert-info">Your suggestion has been rejected.</div>
        @endif
        <div class="d-flex">
            @if(($note->hcp_pro_id == $performer->pro_id || $performer->pro->pro_type === 'ADMIN') && $segment->proposedSegmentSummarySuggestion->status == 'PENDING')
            <div class="d-block mt-1 mr-2" moe>
                <form url="/api/segment/acceptProposedSegmentSummarySuggestion" show>
                    <input type="hidden" name="uid" value="{{$segment->uid}}">
                    <div class="mb-0">
                        <button class="btn btn-primary btn-sm" submit>Accept</button>
                    </div>
                </form>
            </div>
            <div class="d-block mt-1  mr-2" moe>
                <form url="/api/segment/rejectProposedSegmentSummarySuggestion" show>
                    <input type="hidden" name="uid" value="{{$segment->uid}}">
                    <div class="mb-0">
                        <button class="btn btn-primary btn-sm" submit>Reject</button>
                    </div>
                </form>
            </div>
            @endif

            <div class="d-block mt-1 mr-2" moe>
                <a class="btn btn-outline-primary btn-sm " start>Override proposed suggestion</a>
                <form url="/api/segment/overrideProposedSegmentSummarySuggestion">
                    <input type="hidden" name="uid" value="{{$segment->uid}}">
                    <textarea name="proposedSuggestedSummaryHtml" class="form-control" rte>{!! $segment->proposedSegmentSummarySuggestion->summary_html !!}</textarea>
                    <div class="mb-0">
                        <button class="btn btn-primary btn-sm" submit>Submit</button>
                        <button class="btn btn-default border btn-sm" cancel>Cancel</button>
                    </div>
                </form>
            </div>
            <div class="d-block mt-1  mr-2" moe>
                <form url="/api/segmentSummarySuggestion/update-status" show>
                    <input type="hidden" name="uid" value="{{$segment->proposedSegmentSummarySuggestion->uid}}">
                    <input type="hidden" name="status" value="DISCARDED">
                    <div class="mb-0">
                        <button class="btn btn-primary btn-sm" submit>Discard suggestion</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
@else
    <div class=" ml-2 border m-2 p-2">
        @if($segment->accepted_suggestion_summary_html)
            {!! $segment->accepted_suggestion_summary_html !!}
        @else 
            {!! $segment->summary_html !!}
        @endif 
        <hr>
        <div class="d-block mt-1" moe>
            <a href="" start show>Propose suggestion</a>
            <form url="/api/segment/proposeSegmentSummarySuggestion">
                <input type="hidden" name="uid" value="{{$segment->uid}}">
                <textarea name="proposedSuggestedSummaryHtml" rte>
                    @if($segment->accepted_suggestion_summary_html)
                        {!! $segment->accepted_suggestion_summary_html !!}
                    @else 
                        {!! 1 ? $segment->getRecalculatedHtml($performer, $performer->session_key, true)['summaryHtml'] : '' !!}
                    @endif 
                </textarea>
                @if($performer->pro->pro_type == 'ADMIN')
                <div class="checkbox mt-1">
                    <input type="checkbox" name="autoAccept">
                    <label for="" class="checkbox-label">Auto-accept</label>
                </div>
                @endif
                <div class="mb-0 mt-2">
                    <button class="btn btn-primary btn-sm" submit>Submit</button>
                    <button class="btn btn-default border btn-sm" cancel>Cancel</button>
                </div>
            </form>
        </div>
    </div>
@endif
