<?php

declare(strict_types=1);

namespace App\Support\Audit;

enum AuditActionId: string
{
    case WorkspaceMembershipAdd = 'workspace_membership.add';
    case WorkspaceMembershipRoleChange = 'workspace_membership.role_change';
    case WorkspaceMembershipRemove = 'workspace_membership.remove';
    case WorkspaceMembershipLastOwnerBlocked = 'workspace_membership.last_owner_blocked';
    case WorkspaceMembershipBreakGlassAssignOwner = 'workspace_membership.break_glass.assign_owner';

    case TenantArchived = 'tenant.archived';
    case TenantRestored = 'tenant.restored';
    case TenantReturnedToDraft = 'tenant.returned_to_draft';
    case TenantRemovedFromWorkspace = 'tenant.removed_from_workspace';
    case TenantRestoredToWorkspace = 'tenant.restored_to_workspace';

    case TenantMembershipAdd = 'tenant_membership.add';
    case TenantMembershipRoleChange = 'tenant_membership.role_change';
    case TenantMembershipRemove = 'tenant_membership.remove';
    case TenantMembershipLastOwnerBlocked = 'tenant_membership.last_owner_blocked';
    case ManagedEnvironmentAccessScopeGrant = 'managed_environment_access_scope.grant';
    case ManagedEnvironmentAccessScopeRemove = 'managed_environment_access_scope.remove';

    // Not part of the v1 contract, but used in codebase.
    case TenantMembershipBootstrapRecover = 'tenant_membership.bootstrap_recover';

    // Diagnostics / repair actions.
    case TenantMembershipDuplicatesMerged = 'tenant_membership.duplicates_merged';

    case PolicyProviderMissingDetected = 'policy.provider_missing_detected';
    case PolicyProviderMissingCleared = 'policy.provider_missing_cleared';

    // Managed environment onboarding wizard.
    case ManagedEnvironmentOnboardingStart = 'managed_environment_onboarding.start';
    case ManagedEnvironmentOnboardingResume = 'managed_environment_onboarding.resume';
    case ManagedEnvironmentOnboardingDraftSelected = 'managed_environment_onboarding.draft_selected';
    case ManagedEnvironmentOnboardingDraftUpdated = 'managed_environment_onboarding.draft_updated';
    case ManagedEnvironmentOnboardingProviderConnectionChanged = 'managed_environment_onboarding.provider_connection_changed';
    case ManagedEnvironmentOnboardingVerificationStart = 'managed_environment_onboarding.verification_start';
    case ManagedEnvironmentOnboardingVerificationPersisted = 'managed_environment_onboarding.verification_persisted';
    case ManagedEnvironmentOnboardingBootstrapStarted = 'managed_environment_onboarding.bootstrap_started';
    case ManagedEnvironmentOnboardingCancelled = 'managed_environment_onboarding.cancelled';
    case ManagedEnvironmentOnboardingDeleted = 'managed_environment_onboarding.deleted';
    case ManagedEnvironmentOnboardingActivationOverrideUsed = 'managed_environment_onboarding.activation_override_used';
    case ManagedEnvironmentOnboardingActivation = 'managed_environment_onboarding.activation';
    case VerificationCompleted = 'verification.completed';
    case VerificationCheckAcknowledged = 'verification.check_acknowledged';

    case AlertDestinationCreated = 'alert_destination.created';
    case AlertDestinationUpdated = 'alert_destination.updated';
    case AlertDestinationDeleted = 'alert_destination.deleted';
    case AlertDestinationEnabled = 'alert_destination.enabled';
    case AlertDestinationDisabled = 'alert_destination.disabled';
    case AlertDestinationTestRequested = 'alert_destination.test_requested';

    case AlertRuleCreated = 'alert_rule.created';
    case AlertRuleUpdated = 'alert_rule.updated';
    case AlertRuleDeleted = 'alert_rule.deleted';
    case AlertRuleEnabled = 'alert_rule.enabled';
    case AlertRuleDisabled = 'alert_rule.disabled';

    case WorkspaceSettingUpdated = 'workspace_setting.updated';
    case WorkspaceSettingReset = 'workspace_setting.reset';
    case WorkspaceSubscriptionUpdated = 'workspace_subscription.updated';
    case WorkspaceClosed = 'workspace.closed';
    case WorkspaceReopened = 'workspace.reopened';

    case BaselineProfileCreated = 'baseline_profile.created';
    case BaselineProfileUpdated = 'baseline_profile.updated';
    case BaselineProfileArchived = 'baseline_profile.archived';
    case BaselineProfileScopeBackfilled = 'baseline_profile.scope_backfilled';
    case BaselineCaptureStarted = 'baseline_capture.started';
    case BaselineCaptureCompleted = 'baseline_capture.completed';
    case BaselineCaptureFailed = 'baseline_capture.failed';
    case BaselineCompareStarted = 'baseline_compare.started';
    case BaselineCompareCompleted = 'baseline_compare.completed';
    case BaselineCompareFailed = 'baseline_compare.failed';
    case CrossEnvironmentPromotionPreflightGenerated = 'cross_environment_promotion_preflight.generated';
    case CrossEnvironmentPromotionExecutionQueued = 'cross_environment_promotion_execution.queued';
    case CrossEnvironmentPromotionExecutionCompleted = 'cross_environment_promotion_execution.completed';
    case BaselineAssignmentCreated = 'baseline_assignment.created';
    case BaselineAssignmentUpdated = 'baseline_assignment.updated';
    case BaselineAssignmentDeleted = 'baseline_assignment.deleted';

    case FindingTriaged = 'finding.triaged';
    case FindingInProgress = 'finding.in_progress';
    case FindingAssigned = 'finding.assigned';
    case FindingResolved = 'finding.resolved';
    case FindingClosed = 'finding.closed';
    case FindingRiskAccepted = 'finding.risk_accepted';
    case FindingReopened = 'finding.reopened';
    case FindingExceptionRequested = 'finding_exception.requested';
    case FindingExceptionApproved = 'finding_exception.approved';
    case FindingExceptionRejected = 'finding_exception.rejected';
    case FindingExceptionRenewalRequested = 'finding_exception.renewal_requested';
    case FindingExceptionRenewed = 'finding_exception.renewed';
    case FindingExceptionRevoked = 'finding_exception.revoked';

    case EvidenceSnapshotCreated = 'evidence_snapshot.created';
    case EvidenceSnapshotRefreshed = 'evidence_snapshot.refreshed';
    case EvidenceSnapshotExpired = 'evidence_snapshot.expired';
    case EvidenceSnapshotOpened = 'evidence_snapshot.opened';
    case EnvironmentReviewCreated = 'environment_review.created';
    case EnvironmentReviewRefreshed = 'environment_review.refreshed';
    case EnvironmentReviewPublished = 'environment_review.published';
    case EnvironmentReviewArchived = 'environment_review.archived';
    case EnvironmentReviewOpened = 'environment_review.opened';
    case EnvironmentReviewExported = 'environment_review.exported';
    case EnvironmentReviewSuccessorCreated = 'environment_review.successor_created';
    case CustomerReviewWorkspaceOpened = 'customer_review_workspace.opened';
    case ReviewPackDownloaded = 'review_pack.downloaded';
    case ManagedEnvironmentTriageReviewMarkedReviewed = 'managed_environment_triage_review.marked_reviewed';
    case ManagedEnvironmentTriageReviewMarkedFollowUpNeeded = 'managed_environment_triage_review.marked_follow_up_needed';

    case SupportDiagnosticsOpened = 'support_diagnostics.opened';
    case SupportRequestCreated = 'support_request.created';
    case SupportRequestExternalTicketCreated = 'support_request.external_ticket_created';
    case SupportRequestExternalTicketLinked = 'support_request.external_ticket_linked';
    case SupportRequestExternalHandoffFailed = 'support_request.external_handoff_failed';
    case SupportAccessRequested = 'support_access.requested';
    case SupportAccessActivated = 'support_access.activated';
    case SupportAccessApproved = 'support_access.approved';
    case SupportAccessDenied = 'support_access.denied';
    case SupportAccessEnded = 'support_access.ended';
    case SupportAccessExpired = 'support_access.expired';
    case SupportAccessOwnerlessWaiverUsed = 'support_access.ownerless_waiver_used';
    case AiExecutionDecisionEvaluated = 'ai_execution.decision_evaluated';
    case OperationalControlPaused = 'operational_control.paused';
    case OperationalControlUpdated = 'operational_control.updated';
    case OperationalControlResumed = 'operational_control.resumed';
    case OperationalControlExecutionBlocked = 'operational_control.execution_blocked';

    // Workspace selection / switch events (Spec 107).
    case WorkspaceAutoSelected = 'workspace.auto_selected';
    case WorkspaceSelected = 'workspace.selected';

    /**
     * @return array<string>
     */
    public static function knownValues(): array
    {
        return array_map(
            static fn (self $case): string => $case->value,
            self::cases(),
        );
    }

    public static function labelFor(string|self $action): string
    {
        $value = $action instanceof self ? $action->value : trim($action);

        return self::labels()[$value] ?? self::humanize($value);
    }

    /**
     * @param  array<string, mixed>  $context
     */
    public static function summaryFor(
        string|self $action,
        ?string $targetLabel = null,
        ?string $targetType = null,
        array $context = [],
    ): string {
        $value = $action instanceof self ? $action->value : trim($action);
        $summary = self::summaries()[$value] ?? self::labelFor($value);

        if ($targetLabel !== null && $targetLabel !== '' && ! str_contains($summary, $targetLabel)) {
            $summary .= ' for '.$targetLabel;
        } elseif (($targetLabel === null || $targetLabel === '') && filled($targetType)) {
            $summary .= ' for '.self::humanize((string) $targetType);
        }

        if (($context['after_status'] ?? null) !== null && ($context['before_status'] ?? null) !== null && ! str_contains($summary, 'status')) {
            return sprintf(
                '%s (%s -> %s)',
                $summary,
                (string) $context['before_status'],
                (string) $context['after_status'],
            );
        }

        return $summary;
    }

    /**
     * @return array<string, string>
     */
    private static function labels(): array
    {
        return [
            self::WorkspaceMembershipAdd->value => 'Workspace member add',
            self::WorkspaceMembershipRoleChange->value => 'Workspace member role change',
            self::WorkspaceMembershipRemove->value => 'Workspace member removal',
            self::WorkspaceMembershipLastOwnerBlocked->value => 'Workspace last-owner protection',
            self::TenantArchived->value => 'ManagedEnvironment archived',
            self::TenantRestored->value => 'ManagedEnvironment restored',
            self::TenantReturnedToDraft->value => 'ManagedEnvironment returned to draft',
            self::TenantRemovedFromWorkspace->value => 'ManagedEnvironment removed from workspace',
            self::TenantRestoredToWorkspace->value => 'ManagedEnvironment restored to workspace',
            self::TenantMembershipAdd->value => 'ManagedEnvironment member add',
            self::TenantMembershipRoleChange->value => 'ManagedEnvironment member role change',
            self::TenantMembershipRemove->value => 'ManagedEnvironment member removal',
            self::TenantMembershipLastOwnerBlocked->value => 'ManagedEnvironment last-owner protection',
            self::ManagedEnvironmentAccessScopeGrant->value => 'ManagedEnvironment access scope grant',
            self::ManagedEnvironmentAccessScopeRemove->value => 'ManagedEnvironment access scope removal',
            self::PolicyProviderMissingDetected->value => 'Policy provider missing detected',
            self::PolicyProviderMissingCleared->value => 'Policy provider missing cleared',
            self::ManagedEnvironmentOnboardingStart->value => 'Managed environment onboarding start',
            self::ManagedEnvironmentOnboardingResume->value => 'Managed environment onboarding resume',
            self::ManagedEnvironmentOnboardingDraftSelected->value => 'Managed environment onboarding draft selected',
            self::ManagedEnvironmentOnboardingDraftUpdated->value => 'Managed environment onboarding draft updated',
            self::ManagedEnvironmentOnboardingProviderConnectionChanged->value => 'Managed environment onboarding provider connection changed',
            self::ManagedEnvironmentOnboardingVerificationStart->value => 'Managed environment onboarding verification start',
            self::ManagedEnvironmentOnboardingVerificationPersisted->value => 'Managed environment onboarding verification persisted',
            self::ManagedEnvironmentOnboardingBootstrapStarted->value => 'Managed environment onboarding bootstrap started',
            self::ManagedEnvironmentOnboardingCancelled->value => 'Managed environment onboarding cancelled',
            self::ManagedEnvironmentOnboardingDeleted->value => 'Managed environment onboarding deleted',
            self::ManagedEnvironmentOnboardingActivationOverrideUsed->value => 'Managed environment onboarding activation override used',
            self::ManagedEnvironmentOnboardingActivation->value => 'Managed environment onboarding activation',
            self::VerificationCompleted->value => 'Verification completed',
            self::VerificationCheckAcknowledged->value => 'Verification check acknowledged',
            self::AlertDestinationCreated->value => 'Alert destination created',
            self::AlertDestinationUpdated->value => 'Alert destination updated',
            self::AlertDestinationDeleted->value => 'Alert destination deleted',
            self::AlertDestinationEnabled->value => 'Alert destination enabled',
            self::AlertDestinationDisabled->value => 'Alert destination disabled',
            self::AlertDestinationTestRequested->value => 'Alert destination test requested',
            self::AlertRuleCreated->value => 'Alert rule created',
            self::AlertRuleUpdated->value => 'Alert rule updated',
            self::AlertRuleDeleted->value => 'Alert rule deleted',
            self::AlertRuleEnabled->value => 'Alert rule enabled',
            self::AlertRuleDisabled->value => 'Alert rule disabled',
            self::WorkspaceSettingUpdated->value => 'Workspace setting updated',
            self::WorkspaceSettingReset->value => 'Workspace setting reset',
            self::WorkspaceSubscriptionUpdated->value => 'Workspace subscription updated',
            self::WorkspaceClosed->value => 'Workspace closed',
            self::WorkspaceReopened->value => 'Workspace reopened',
            self::BaselineProfileCreated->value => 'Baseline profile created',
            self::BaselineProfileUpdated->value => 'Baseline profile updated',
            self::BaselineProfileArchived->value => 'Baseline profile archived',
            self::BaselineProfileScopeBackfilled->value => 'Baseline profile scope backfilled',
            self::BaselineCaptureStarted->value => 'Baseline capture started',
            self::BaselineCaptureCompleted->value => 'Baseline capture completed',
            self::BaselineCaptureFailed->value => 'Baseline capture failed',
            self::BaselineCompareStarted->value => 'Baseline compare started',
            self::BaselineCompareCompleted->value => 'Baseline compare completed',
            self::BaselineCompareFailed->value => 'Baseline compare failed',
            self::CrossEnvironmentPromotionPreflightGenerated->value => 'Cross-environment promotion preflight generated',
            self::CrossEnvironmentPromotionExecutionQueued->value => 'Cross-environment promotion execution queued',
            self::CrossEnvironmentPromotionExecutionCompleted->value => 'Cross-environment promotion execution completed',
            self::BaselineAssignmentCreated->value => 'Baseline assignment created',
            self::BaselineAssignmentUpdated->value => 'Baseline assignment updated',
            self::BaselineAssignmentDeleted->value => 'Baseline assignment deleted',
            self::WorkspaceAutoSelected->value => 'Workspace auto-selected',
            self::WorkspaceSelected->value => 'Workspace selected',
            self::FindingTriaged->value => 'Finding triaged',
            self::FindingInProgress->value => 'Finding moved to in progress',
            self::FindingAssigned->value => 'Finding assignment updated',
            self::FindingResolved->value => 'Finding resolved',
            self::FindingClosed->value => 'Finding closed',
            self::FindingRiskAccepted->value => 'Finding risk accepted',
            self::FindingReopened->value => 'Finding reopened',
            self::FindingExceptionRequested->value => 'Finding exception requested',
            self::FindingExceptionApproved->value => 'Finding exception approved',
            self::FindingExceptionRejected->value => 'Finding exception rejected',
            self::FindingExceptionRenewalRequested->value => 'Finding exception renewal requested',
            self::FindingExceptionRenewed->value => 'Finding exception renewed',
            self::FindingExceptionRevoked->value => 'Finding exception revoked',
            self::EvidenceSnapshotCreated->value => 'Evidence snapshot created',
            self::EvidenceSnapshotRefreshed->value => 'Evidence snapshot refreshed',
            self::EvidenceSnapshotExpired->value => 'Evidence snapshot expired',
            self::EvidenceSnapshotOpened->value => 'Evidence snapshot opened',
            self::EnvironmentReviewCreated->value => 'ManagedEnvironment review created',
            self::EnvironmentReviewRefreshed->value => 'ManagedEnvironment review refreshed',
            self::EnvironmentReviewPublished->value => 'ManagedEnvironment review published',
            self::EnvironmentReviewArchived->value => 'ManagedEnvironment review archived',
            self::EnvironmentReviewOpened->value => 'ManagedEnvironment review opened',
            self::EnvironmentReviewExported->value => 'ManagedEnvironment review exported',
            self::EnvironmentReviewSuccessorCreated->value => 'ManagedEnvironment review next cycle created',
            self::CustomerReviewWorkspaceOpened->value => 'Customer review workspace opened',
            self::ReviewPackDownloaded->value => 'Review pack downloaded',
            self::ManagedEnvironmentTriageReviewMarkedReviewed->value => 'Triage review marked reviewed',
            self::ManagedEnvironmentTriageReviewMarkedFollowUpNeeded->value => 'Triage review marked follow-up needed',
            self::SupportDiagnosticsOpened->value => 'Support diagnostics opened',
            self::SupportRequestCreated->value => 'Support request created',
            self::SupportRequestExternalTicketCreated->value => 'Support request external ticket created',
            self::SupportRequestExternalTicketLinked->value => 'Support request external ticket linked',
            self::SupportRequestExternalHandoffFailed->value => 'Support request external handoff failed',
            self::SupportAccessRequested->value => 'Support access requested',
            self::SupportAccessActivated->value => 'Support access activated',
            self::SupportAccessApproved->value => 'Support access approved',
            self::SupportAccessDenied->value => 'Support access denied',
            self::SupportAccessEnded->value => 'Support access ended',
            self::SupportAccessExpired->value => 'Support access expired',
            self::SupportAccessOwnerlessWaiverUsed->value => 'Support access ownerless waiver used',
            self::AiExecutionDecisionEvaluated->value => 'AI execution decision evaluated',
            self::OperationalControlPaused->value => 'Operational control paused',
            self::OperationalControlUpdated->value => 'Operational control updated',
            self::OperationalControlResumed->value => 'Operational control resumed',
            self::OperationalControlExecutionBlocked->value => 'Operational control blocked execution',
            'baseline.capture.started' => 'Baseline capture started',
            'baseline.capture.completed' => 'Baseline capture completed',
            'baseline.capture.failed' => 'Baseline capture failed',
            'baseline.compare.started' => 'Baseline compare started',
            'baseline.compare.completed' => 'Baseline compare completed',
            'baseline.compare.failed' => 'Baseline compare failed',
            'baseline.evidence.resume.started' => 'Baseline evidence capture resumed',
            'backup.created' => 'Backup set created',
            'backup.updated' => 'Backup set updated',
            'backup.archived' => 'Backup set archived',
            'backup.items_added' => 'Backup set items added',
            'backup.assignments.included' => 'Backup set assignments included',
            'backup_schedule.run_started' => 'Backup schedule run started',
            'backup_schedule.run_finished' => 'Backup schedule run finished',
            'backup_schedule.run_failed' => 'Backup schedule run failed',
            'backup_schedule.run_skipped' => 'Backup schedule run skipped',
            'backup_schedule.retention_applied' => 'Backup schedule retention applied',
            'restore.started' => 'Restore started',
            'restore.previewed' => 'Restore preview completed',
            'restore.executed' => 'Restore executed',
            'restore.failed' => 'Restore failed',
            'restore.assignments.summary' => 'Restore assignment summary recorded',
            'restore.group_mapping.applied' => 'Restore group mapping applied',
            'operation.completed' => 'Operation completed',
            'operation.failed' => 'Operation failed',
            'operation.partial' => 'Operation partially completed',
            'operation.blocked' => 'Operation blocked',
        ];
    }

    /**
     * @return array<string, string>
     */
    private static function summaries(): array
    {
        return [
            self::WorkspaceMembershipAdd->value => 'Workspace member added',
            self::WorkspaceMembershipRoleChange->value => 'Workspace member role changed',
            self::WorkspaceMembershipRemove->value => 'Workspace member removed',
            self::WorkspaceMembershipLastOwnerBlocked->value => 'Workspace last-owner protection triggered',
            self::TenantArchived->value => 'ManagedEnvironment archived',
            self::TenantRestored->value => 'ManagedEnvironment restored',
            self::TenantReturnedToDraft->value => 'ManagedEnvironment returned to draft',
            self::TenantRemovedFromWorkspace->value => 'ManagedEnvironment removed from workspace',
            self::TenantRestoredToWorkspace->value => 'ManagedEnvironment restored to workspace',
            self::TenantMembershipAdd->value => 'ManagedEnvironment member added',
            self::TenantMembershipRoleChange->value => 'ManagedEnvironment member role changed',
            self::TenantMembershipRemove->value => 'ManagedEnvironment member removed',
            self::TenantMembershipLastOwnerBlocked->value => 'ManagedEnvironment last-owner protection triggered',
            self::PolicyProviderMissingDetected->value => 'Policy marked provider missing',
            self::PolicyProviderMissingCleared->value => 'Policy provider presence restored',
            self::WorkspaceSettingUpdated->value => 'Workspace setting updated',
            self::WorkspaceSettingReset->value => 'Workspace setting reset',
            self::WorkspaceSubscriptionUpdated->value => 'Workspace subscription updated',
            self::WorkspaceClosed->value => 'Workspace closed',
            self::WorkspaceReopened->value => 'Workspace reopened',
            self::BaselineProfileCreated->value => 'Baseline profile created',
            self::BaselineProfileUpdated->value => 'Baseline profile updated',
            self::BaselineProfileArchived->value => 'Baseline profile archived',
            self::BaselineProfileScopeBackfilled->value => 'Baseline profile scope backfilled',
            self::CrossEnvironmentPromotionPreflightGenerated->value => 'Cross-environment promotion preflight generated',
            self::CrossEnvironmentPromotionExecutionQueued->value => 'Cross-environment promotion execution queued',
            self::CrossEnvironmentPromotionExecutionCompleted->value => 'Cross-environment promotion execution completed',
            self::AlertDestinationCreated->value => 'Alert destination created',
            self::AlertDestinationUpdated->value => 'Alert destination updated',
            self::AlertDestinationDeleted->value => 'Alert destination deleted',
            self::AlertRuleCreated->value => 'Alert rule created',
            self::AlertRuleUpdated->value => 'Alert rule updated',
            self::AlertRuleDeleted->value => 'Alert rule deleted',
            self::FindingTriaged->value => 'Finding triaged',
            self::FindingInProgress->value => 'Finding moved to in progress',
            self::FindingAssigned->value => 'Finding assignment updated',
            self::FindingResolved->value => 'Finding resolved',
            self::FindingClosed->value => 'Finding closed',
            self::FindingRiskAccepted->value => 'Finding risk accepted',
            self::FindingReopened->value => 'Finding reopened',
            self::FindingExceptionRequested->value => 'Finding exception requested',
            self::FindingExceptionApproved->value => 'Finding exception approved',
            self::FindingExceptionRejected->value => 'Finding exception rejected',
            self::FindingExceptionRenewalRequested->value => 'Finding exception renewal requested',
            self::FindingExceptionRenewed->value => 'Finding exception renewed',
            self::FindingExceptionRevoked->value => 'Finding exception revoked',
            self::EvidenceSnapshotCreated->value => 'Evidence snapshot created',
            self::EvidenceSnapshotRefreshed->value => 'Evidence snapshot refreshed',
            self::EvidenceSnapshotExpired->value => 'Evidence snapshot expired',
            self::EvidenceSnapshotOpened->value => 'Evidence snapshot opened',
            self::EnvironmentReviewCreated->value => 'ManagedEnvironment review created',
            self::EnvironmentReviewRefreshed->value => 'ManagedEnvironment review refreshed',
            self::EnvironmentReviewPublished->value => 'ManagedEnvironment review published',
            self::EnvironmentReviewArchived->value => 'ManagedEnvironment review archived',
            self::EnvironmentReviewOpened->value => 'ManagedEnvironment review opened',
            self::EnvironmentReviewExported->value => 'ManagedEnvironment review exported',
            self::EnvironmentReviewSuccessorCreated->value => 'ManagedEnvironment review next cycle created',
            self::CustomerReviewWorkspaceOpened->value => 'Customer review workspace opened',
            self::ReviewPackDownloaded->value => 'Review pack downloaded',
            self::SupportDiagnosticsOpened->value => 'Support diagnostics opened',
            self::SupportRequestCreated->value => 'Support request created',
            self::SupportRequestExternalTicketCreated->value => 'Support request external ticket created',
            self::SupportRequestExternalTicketLinked->value => 'Support request external ticket linked',
            self::SupportRequestExternalHandoffFailed->value => 'Support request external handoff failed',
            self::SupportAccessRequested->value => 'Support access requested',
            self::SupportAccessActivated->value => 'Support access activated',
            self::SupportAccessApproved->value => 'Support access approved',
            self::SupportAccessDenied->value => 'Support access denied',
            self::SupportAccessEnded->value => 'Support access ended',
            self::SupportAccessExpired->value => 'Support access expired',
            self::SupportAccessOwnerlessWaiverUsed->value => 'Support access ownerless waiver used',
            self::AiExecutionDecisionEvaluated->value => 'AI execution decision evaluated',
            self::OperationalControlPaused->value => 'Operational control paused',
            self::OperationalControlUpdated->value => 'Operational control updated',
            self::OperationalControlResumed->value => 'Operational control resumed',
            self::OperationalControlExecutionBlocked->value => 'Operational control blocked execution',
        ];
    }

    private static function humanize(string $value): string
    {
        $normalized = str_replace(['.', '_', '-'], ' ', trim($value));
        $normalized = preg_replace('/\s+/', ' ', $normalized) ?? $normalized;

        return ucfirst($normalized);
    }
}
