@props([
    'entity' => '',
    'record' => '',
    'viewUrl' => null,
    'editUrl' => null,
    'duplicateUrl' => null,
    'printUrl' => null,
    'activateUrl' => null,
    'deactivateUrl' => null,
    'deleteUrl' => null,
    'activateMessage' => null,
    'deactivateMessage' => null,
    'deactivateHint' => null,
    'deleteMessage' => null,
    'statusConfirmHint' => null,
    'activateHint' => null,
    'deactivateHint' => null,
    'modal' => 'actionsModal',
])

@php
    $payload = array_filter([
        'entity' => (string) $entity,
        'record' => (string) $record,
        'viewUrl' => $viewUrl ?: null,
        'editUrl' => $editUrl ?: null,
        'duplicateUrl' => $duplicateUrl ?: null,
        'printUrl' => $printUrl ?: null,
        'activateUrl' => $activateUrl ?: null,
        'deactivateUrl' => $deactivateUrl ?: null,
        'deleteUrl' => $deleteUrl ?: null,
        'activateMessage' => $activateMessage ?: null,
        'deactivateMessage' => $deactivateMessage ?: null,
        'deactivateHint' => $deactivateHint ?: null,
        'deleteMessage' => $deleteMessage ?: null,
        'statusConfirmHint' => $statusConfirmHint ?: null,
        'activateHint' => $activateHint ?: null,
        'deactivateHint' => $deactivateHint ?: null,
    ], static fn ($value) => $value !== null && $value !== '');

    $hasAnyAction = collect(['viewUrl', 'editUrl', 'duplicateUrl', 'printUrl', 'activateUrl', 'deactivateUrl', 'deleteUrl'])
        ->contains(fn (string $key) => filled($payload[$key] ?? null));
@endphp

@if ($hasAnyAction)
    <button
        type="button"
        data-bs-toggle="modal"
        data-bs-target="#{{ $modal }}"
        data-erp-actions='@json($payload, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT | JSON_UNESCAPED_UNICODE)'
        {{ $attributes->class(['btn btn-sm btn-outline-primary js-open-actions']) }}
        aria-label="{{ __('common.actions') }}"
    >
        <i class="fe fe-more-vertical" aria-hidden="true"></i>
    </button>
@endif
