<?php

namespace App\Enums;

/**
 * Built-in template keys. Clinics may override the ar/en body of any key
 * (wa_templates). Placeholders use {name} style tokens, documented per key.
 */
enum WaTemplateKey: string
{
    case Confirmation = 'confirmation';
    case Reminder24h = 'reminder_24h';
    case Reminder1h = 'reminder_1h';
    case ReviewHigh = 'review_high';   // >= 4 stars → Google review link
    case ReviewLow = 'review_low';     // <= 3 stars → internal feedback
    case Recall = 'recall';            // follow-up / next visit
    case InstallmentDue = 'installment_due';
    case TreatmentPlan = 'treatment_plan'; // caption for plan PDF
    case Invoice = 'invoice';              // caption for invoice PDF

    public function label(): string
    {
        return __(match ($this) {
            self::Confirmation => 'Appointment confirmation',
            self::Reminder24h => '24-hour reminder',
            self::Reminder1h => '1-hour reminder',
            self::ReviewHigh => 'Review request (happy)',
            self::ReviewLow => 'Feedback request (unhappy)',
            self::Recall => 'Recall / next visit',
            self::InstallmentDue => 'Installment due',
            self::TreatmentPlan => 'Treatment plan (PDF caption)',
            self::Invoice => 'Invoice (PDF caption)',
        });
    }

    /** Tokens available to this template, for the editor help text. */
    public function tokens(): array
    {
        return match ($this) {
            self::Confirmation, self::Reminder24h, self::Reminder1h =>
                ['clinic', 'patient', 'dentist', 'date', 'time'],
            self::ReviewHigh, self::ReviewLow => ['clinic', 'patient', 'link'],
            self::Recall => ['clinic', 'patient', 'reason', 'link'],
            self::InstallmentDue => ['clinic', 'patient', 'amount', 'due_date'],
            self::TreatmentPlan, self::Invoice => ['clinic', 'patient'],
        };
    }
}
