<div class="text-center">
    <div class="btn-group">
        {{-- @can("impersonate $modelName")
            @isset($userId)
                @if(auth()->user()->canImpersonate() && !auth()->user()->isImpersonating() ?? auth()->user()->getAttribute('id') !== $userId)
                    <a href="{{ route('admin:impersonation.start', $userId) }}" class="btn btn-success js-bs-tooltip-enabled">
                        <i class="far fa-eye"></i>
                    </a>
                @endif
                @if(auth()->user()->isImpersonating() && auth()->user()->getImpersonatedUser()->id === $userId)
                    <a href="{{ route('admin:impersonation.stop') }}" class="btn btn-danger js-bs-tooltip-enabled">
                        <i class="far fa-eye"></i>
                    </a>
                @endif
            @endisset
        @endcan --}}
        @can("show $modelName")
            @isset($showUrl)
                <a href="{{$showUrl}}" class="btn btn-secondary js-bs-tooltip-enabled">
                    <i data-feather="eye" class="nav-icon me-2 icon-xxs"> @lang('Show')</i>                </a>
            @endisset
        @endcan
        @can("edit $modelName")
            @isset($editUrl)
                <a href="{{$editUrl}}" type="button" class="btn btn-secondary mb-2">
                    <i data-feather="edit" class="nav-icon me-2 icon-xxs"></i> @lang('Edit') </a>
            @endisset
        @endcan
        @can("destroy $modelName")
            @isset($deleteUrl)
                <form method="POST" action="{{$deleteUrl}}" onsubmit="return confirm('Confirm deletion!')">
                    @csrf
                    @method('DELETE')
                    <button type="submit" class="btn btn-danger mb-2">
                        <i data-feather="edit" class="nav-icon me-2 icon-xxs"></i> @lang('Delete')
                    </button>
                </form>
            @endisset
        @endcan
    </div>
</div>
@can("destroy $modelName")
    @once
        @isset($deleteUrl)
            <script>
                function deleteFunction(element) {
                    const swalWithBootstrapButtons = Swal.mixin({
                        customClass: {
                            confirmButton: 'btn btn-success me-2',
                            cancelButton: 'btn btn-danger'
                        },
                        buttonsStyling: false
                    });
                    swalWithBootstrapButtons.fire({
                        title: '{{__('Confirm deletion!')}}',
                        text: "{{__('It will be impossible to return the data!')}}",
                        icon: 'info',
                        showCancelButton: true,
                        confirmButtonText: '{{__('Delete')}}',
                        cancelButtonText: '{{__('Cancel')}}',
                    }).then((result) => {
                        if (result.isConfirmed) {
                            let deleteUrl = element.getAttribute('data-delete-url');
                            fetch(deleteUrl, {
                                method: 'POST',
                                headers: {
                                    'X-CSRF-TOKEN': "{{csrf_token()}}",
                                    'Content-Type': 'application/json'
                                },
                                body: JSON.stringify({
                                    _method: 'DELETE',
                                })
                            }).then(response => {
                                if (!response.ok) {
                                    throw new Error('Сетевой ответ был не в порядке');
                                }
                                table.draw();
                            }).catch(error => {
                                console.error('Возникла проблема с операцией выборки:', error);
                            });
                        }
                    })
                }
            </script>
        @endif
    @endonce
@endcan
