<?php
/**
 * Inline SVG icon helper (Lucide icon paths).
 *
 * @since   1.0.0
 * @package DonationRouter
 */

declare( strict_types=1 );

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
/**
 * Return an inline Lucide SVG icon as an HTML string.
 *
 * @since 1.0.0
 *
 * @param  string $name      Icon slug: copy | check | alert-triangle | info | link.
 * @param  string $css_class Optional CSS class added to the <svg> element.
 * @return string  SVG markup, or empty string for unknown icon names.
 */
function ador_icon( string $name, string $css_class = '' ): string {
	$paths = array(
		'copy'           =>
			'<rect width="14" height="14" x="8" y="8" rx="2" ry="2"/>' .
			'<path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/>',
		'check'          =>
			'<polyline points="20 6 9 17 4 12"/>',
		'alert-triangle' =>
			'<path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z"/>' .
			'<path d="M12 9v4"/>' .
			'<path d="M12 17h.01"/>',
		'info'           =>
			'<circle cx="12" cy="12" r="10"/>' .
			'<path d="M12 16v-4"/>' .
			'<path d="M12 8h.01"/>',
		'link'           =>
			'<path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/>' .
			'<path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/>',
	);

	if ( ! isset( $paths[ $name ] ) ) {
		return '';
	}

	$class_attr = '' !== $css_class
		? ' class="' . esc_attr( $css_class ) . '"'
		: '';

	return sprintf(
		'<svg%s xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">%s</svg>',
		$class_attr,
		$paths[ $name ]
	);
}
