<?php defined('BASEPATH') or exit('No direct script access allowed');

$label = isset($label) ? $label : '';
$tone = isset($tone) ? $tone : 'neutral';
$icon = isset($icon) ? $icon : '';
$dot = !empty($dot);
$class = isset($class) ? $class : '';

$tone_map = array(
	'neutral' => 'erp-badge--neutral',
	'primary' => 'erp-badge--primary',
	'success' => 'erp-badge--success',
	'warning' => 'erp-badge--warning',
	'danger' => 'erp-badge--danger',
	'info' => 'erp-badge--info',
	'paid' => 'erp-badge--success',
	'completed' => 'erp-badge--success',
	'partial' => 'erp-badge--warning',
	'partially_paid' => 'erp-badge--warning',
	'waiting' => 'erp-badge--warning',
	'unpaid' => 'erp-badge--danger',
	'overdue' => 'erp-badge--danger',
	'deferred' => 'erp-badge--neutral',
	'draft' => 'erp-badge--neutral',
	'inactive' => 'erp-badge--neutral',
	'open' => 'erp-badge--info',
	'billable' => 'erp-badge--info',
	'active' => 'erp-badge--primary',
	'in_progress' => 'erp-badge--primary',
	'non_billable' => 'erp-badge--neutral',
);

$tone_class = isset($tone_map[$tone]) ? $tone_map[$tone] : $tone_map['neutral'];
?>

<span class="erp-badge <?= $tone_class; ?><?= $class ? ' ' . $class : ''; ?>">
	<?php if ($dot) { ?>
		<span class="erp-badge-dot"></span>
	<?php } ?>
	<?php if ($icon !== '') { ?>
		<i data-lucide="<?= html_escape($icon); ?>" class="h-3.5 w-3.5"></i>
	<?php } ?>
	<span><?= html_escape($label); ?></span>
</span>
