<?php
/**
 * NeccoSpeak — Admin screen: CTA vocabulary (G14 quick actions / CTA).
 * docs/phase4-design.md §8.6.
 *
 * 0.3.0-dev.42 撤去記録: このファイルは元々「アクション」タブのレンダラ
 * neccospeak_render_tab_actions() と、その repeater 行を描く
 * neccospeak_render_cta_repeat_row() を持っていた。両者は
 * includes/settings.php の旧タブディスパッチャからしか呼ばれておらず、
 * includes/agent-ui.php が menu callback を差し替えて以降その画面ごと
 * 到達不能になったため削除した。CTA編集UIは
 * includes/agent-ui-tabs/tab-flow.php が本番パリティで作り直している。
 *
 * 残っているのは、その tab-flow が現役で読んでいる <option> 語彙だけ:
 *   neccospeak_cta_type_options( $force )
 *   neccospeak_cta_cond_options()
 * (neccospeak_cta_icon_options() は dev.38 の共通アイコンピッカー導入で
 * 呼び出し元が無くなったが、キーが neccospeak_sanitize_cta_list() の
 * allow-list の写しなので参照用に温存している。)
 *
 * Sanitizing `cta_list` / `cta_enabled` / etc. on save is impl-admin's job
 * (includes/settings.php, `cta_list` sanitize type — design phase4 §2.9(d)).
 *
 * Never calls wp_enqueue_*() or any other side-effecting WP function at
 * load time (design phase4 §8.6 / tests/test-admin-cta.php C7): the test
 * suite requires this file directly outside of is_admin(), so a stray
 * enqueue call here would fatal under tests/bootstrap.php's minimal shim.
 *
 * All visible strings are English originals wrapped in translation
 * functions (INV-12, design phase4 §0.2). Japanese translations for the
 * new msgids introduced here belong in docs/i18n-new-strings-cta.txt
 * (Phase 4b, impl-admin's job to fold into languages/neccospeak-ja.po).
 *
 * @package NeccoSpeak
 */

defined( 'ABSPATH' ) || exit;

// Row cap for the `cta_list` repeater (design phase4 §2.6). Guarded so this
// file and includes/settings.php (impl-admin, same constant per §2.6) can
// both define it in either load order without a redeclaration fatal.
if ( ! defined( 'NECCOSPEAK_CTA_MAX_ITEMS' ) ) {
	define( 'NECCOSPEAK_CTA_MAX_ITEMS', 8 );
}

/**
 * Allow-listed `icon` values for a CTA row (design phase4 §2.6 / §10.3).
 * Keys match neccospeak_sanitize_cta_list()'s allow-list (impl-admin);
 * values are only used as the visible <option> label here.
 *
 * @return array<string,string>
 */
function neccospeak_cta_icon_options() {
	return array(
		'none'       => __( 'None', 'neccospeak' ),
		'link'       => __( 'Link', 'neccospeak' ),
		'chat'       => __( 'Chat bubble', 'neccospeak' ),
		'phone'      => __( 'Phone', 'neccospeak' ),
		'mail'       => __( 'Mail', 'neccospeak' ),
		'calendar'   => __( 'Calendar', 'neccospeak' ),
		'cart'       => __( 'Cart', 'neccospeak' ),
		'doc'        => __( 'Document', 'neccospeak' ),
		'sparkle'    => __( 'Sparkle', 'neccospeak' ),
		'help'       => __( 'Help', 'neccospeak' ),
		'arrowRight' => __( 'Arrow', 'neccospeak' ),
	);
}

/**
 * Allow-listed `type` values for a CTA row (design phase4 §2.6; Phase 6
 * design phase6 §8.1/§8.3 adds 'cf7_prefill').
 *
 * 'cf7_prefill' is only ever included when Contact Form 7 is active — design
 * phase6 §8.1: "CF7 が無効なときは UI を一切出さない […] CTA 行の type
 * <option> も描画しない". `$force` overrides that for ONE specific reason
 * (the caller is now includes/agent-ui-tabs/tab-flow.php): a row that
 * already has `type === 'cf7_prefill'` saved from when CF7 WAS active must
 * still be able to show its own current value in a disabled <select>,
 * rather than the browser silently falling back to whichever option happens
 * to render first.
 *
 * @param bool $force Include 'cf7_prefill' even if CF7 is currently inactive.
 * @return array<string,string>
 */
function neccospeak_cta_type_options( $force = false ) {
	$options = array(
		'link'    => __( 'Link (URL)', 'neccospeak' ),
		'message' => __( 'Send a chat message', 'neccospeak' ),
		'tel'     => __( 'Phone call', 'neccospeak' ),
		'mail'    => __( 'Email', 'neccospeak' ),
	);
	if ( $force || ( function_exists( 'neccospeak_cf7_active' ) && neccospeak_cf7_active() ) ) {
		$options['cf7_prefill'] = __( 'Contact Form 7 (prefill)', 'neccospeak' );
	}
	return $options;
}

/**
 * Allow-listed `cond` (display condition) values for a CTA row (design
 * phase4 §2.6).
 *
 * @return array<string,string>
 */
function neccospeak_cta_cond_options() {
	return array(
		'always'  => __( 'Always', 'neccospeak' ),
		'delay'   => __( 'After a delay', 'neccospeak' ),
		'replies' => __( 'After a number of replies', 'neccospeak' ),
	);
}
