<?php

if (!function_exists('teacher_id_label')) {
    function teacher_id_label(?string $statusKepegawaian): string
    {
        if (in_array($statusKepegawaian, ['PNS', 'PPPK'], true)) {
            return 'NIP';
        }
        return 'PEG ID/NPK/NUPTK';
    }
}

if (!function_exists('teacher_id_number')) {
    function teacher_id_number(array $teacher): ?string
    {
        $status = $teacher['status_kepegawaian'] ?? null;

        if (in_array($status, ['PNS', 'PPPK'], true)) {
            return $teacher['nip'] ?? null;
        }

        return $teacher['peg_id'] ?? ($teacher['nip'] ?? null);
    }
}

if (!function_exists('teacher_id_display')) {
    function teacher_id_display(array $teacher): string
    {
        $number = teacher_id_number($teacher);
        return $number ?: '—';
    }
}

if (!function_exists('teacher_login_identifier')) {
    function teacher_login_identifier(array $teacher): ?string
    {
        return $teacher['nip'] ?: ($teacher['peg_id'] ?: null);
    }
}

if (!function_exists('guess_id_label')) {
    function guess_id_label(?string $value): string
    {
        if (empty($value)) return 'NIP';
        return (strlen($value) >= 18) ? 'NIP' : 'PEG ID/NPK/NUPTK';
    }
}
