<?php

declare( strict_types=1 );

namespace Limb_Chatbot\Includes\Services\System_Message\Chunks;

use Limb_Chatbot\Includes\Data_Objects\Chatbot;
use Limb_Chatbot\Includes\Utilities\Chatbot_Utility;

/**
 * Custom Instructions Chunk
 *
 * Renders custom instructions configured for the chatbot.
 * Has lowest priority so it appears first.
 *
 * @since 1.1.1
 */
class Custom_Instructions_Chunk extends System_Message_Chunk {

	private string $instructions;

	public function __construct( Chatbot_Utility $utility ) {
		$this->instructions = $utility->chatbot->get_parameter( 'custom_instructions' );
	}

	public function get_title(): string {
		return '';
	}

	public function get_content(): array {
		return [ $this->instructions ];
	}

	public function get_priority(): int {
		return 1;
	}

	public function should_include(): bool {
		return ! empty( trim( $this->instructions ) );
	}
}
