<?php
/**
 * Helpers for blocksify/accordion + accordion-item blocks.
 *
 * @package Blocksify
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Indicator SVG markup for the accordion header. Mirrors `IndicatorSvg`
 * React component in `src/blocks/accordion/indicators.js` byte-for-byte
 * so editor preview = frontend output.
 *
 * Returns one SVG (chevron / arrow — rotated via CSS on `.is-open`),
 * two SVGs (plus-minus — closed shows `+`, open shows `−`, swapped by
 * CSS), or empty string (none).
 *
 * Renamed 2026-05-10: was `blocksify_accordion_marker_svg`.
 *
 * @param string $type One of 'plus-minus' | 'chevron' | 'arrow' | 'none'.
 * @return string SVG HTML.
 */
function blocksify_accordion_indicator_svg( $type ) {
	if ( 'none' === $type ) {
		return '';
	}
	if ( 'plus-minus' === $type ) {
		$closed = '<svg class="is-when-closed" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true" focusable="false">'
			. '<line x1="12" y1="5" x2="12" y2="19" />'
			. '<line x1="5" y1="12" x2="19" y2="12" />'
			. '</svg>';
		$open = '<svg class="is-when-open" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true" focusable="false">'
			. '<line x1="5" y1="12" x2="19" y2="12" />'
			. '</svg>';
		return $closed . $open;
	}
	if ( 'chevron' === $type ) {
		return '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false">'
			. '<polyline points="6 9 12 15 18 9" />'
			. '</svg>';
	}
	if ( 'arrow' === $type ) {
		return '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false">'
			. '<line x1="12" y1="5" x2="12" y2="19" />'
			. '<polyline points="5 12 12 19 19 12" />'
			. '</svg>';
	}
	return '';
}
