<?php
declare(strict_types=1);

namespace Simplyin\Simplyin_W_Plugin\Controller\Ajax\Widget;

use Simplyin\Simplyin_W_Plugin\Controller\Ajax\Abstract_Response;

/**
 * Response for the shop-login email-OTP challenge send.
 *
 * `challenge_started` is the front-end contract: true → show the 6-digit challenge popup (html)
 * and skip the SMS flow; false → fall back to the regular submitEmail/SMS flow.
 * `fallback_reason` is diagnostic only (NO_SIN_ACCOUNT, EMAIL_VERIFIED, WP_ALREADY_LOGGED_IN,
 * UNAUTHORIZED, ERROR) — the front end branches on `challenge_started`. The no-WC-account outcome
 * is deliberately NOT surfaced here (it would leak account existence before any throttle); that
 * reason stays in the server-side log only.
 */
class Send_Shop_Login_Email_Otp_Response extends Abstract_Response {

	protected bool $show_popup = false;
	protected string $html = '';
	protected bool $challenge_started = false;
	protected string $fallback_reason = '';

	public function get_array(): array {
		return [
			'show_popup'        => $this->show_popup,
			'html'              => $this->html,
			'challenge_started' => $this->challenge_started,
			'fallback_reason'   => $this->fallback_reason,
		];
	}

	public function set_show_popup( bool $flag ): void {
		$this->show_popup = $flag;
	}

	public function set_html( string $html ): void {
		$this->html = $html;
	}

	public function set_challenge_started( bool $flag ): void {
		$this->challenge_started = $flag;
	}

	public function set_fallback_reason( string $reason ): void {
		$this->fallback_reason = $reason;
	}
}
