<?php
/**
 * MindWebConcierge Plugin Configuration
 *
 * Defines the plugin's internal service endpoint constants.
 *
 * @package MindWebConcierge
 */

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

/**
 * RAG service URL
 */
if ( ! defined( 'MINDWECO_RAG_URL' ) ) {
	define( 'MINDWECO_RAG_URL', 'https://rag.smartprocesses.cloud' );
}

/**
 * Knowledge Notebooks URL
 */
if ( ! defined( 'MINDWECO_NOTEBOOKS_URL' ) ) {
	define( 'MINDWECO_NOTEBOOKS_URL', 'https://spaces.smartmind.services' );
}

/**
 * Stripe API base URL
 */
if ( ! defined( 'MINDWECO_STRIPE_URL' ) ) {
	define( 'MINDWECO_STRIPE_URL', 'https://subscriptions.smartprocesses.cloud/api' );
}

/**
 * Stripe Product ID
 */
if ( ! defined( 'MINDWECO_PROD_ID' ) ) {
	define( 'MINDWECO_PROD_ID', 'prod_U3VYkOBf6Ngqi3' );
}

/**
 * Powered by URL
 */
if ( ! defined( 'MINDWECO_POWER_BY' ) ) {
	define( 'MINDWECO_POWER_BY', 'https://smartmind.it/' );
}

if ( ! defined( 'MIND_WEB_VERSION' ) ) {
	define( 'MIND_WEB_VERSION', '1.3.0' );
}

if ( ! function_exists( 'mindweco_get_locale_code' ) ) {
	/**
	 * Return the current site language code from WordPress locale.
	 *
	 * @return string
	 */
	function mindweco_get_locale_code() {
		$locale = function_exists( 'get_locale' ) ? (string) get_locale() : 'en_US';
		$locale = '' !== $locale ? strtolower( $locale ) : 'en_us';
		$parts  = preg_split( '/[_-]/', $locale );

		if ( ! is_array( $parts ) || empty( $parts[0] ) ) {
			return 'en';
		}

		return $parts[0];
	}
}

if ( ! function_exists( 'mindweco_get_locale_copy' ) ) {
	/**
	 * Get a localized UI string based on the active WordPress locale.
	 *
	 * @param string $key Copy key.
	 * @return string
	 */
	function mindweco_get_locale_copy( $key ) {
		$lang = mindweco_get_locale_code();

		if ( 'chat_online' === $key ) {
			if ( 'sq' === $lang ) {
				return 'Klikoni këtu për të nisur bisedën me ne!';
			}

			if ( 'it' === $lang ) {
				return 'Clicca qui e inizia a chattare con noi!';
			}

			if ( 'en' === $lang ) {
				return 'Click here and start chatting with us!';
			}
		}

		static $copy = null;

		if ( null === $copy ) {
			$copy = array(
			'need_help' => array(
				'en' => 'Need help?',
				'sq' => 'Keni nevojë për ndihmë?',
				'it' => 'Hai bisogno di aiuto?',
				'de' => 'Brauchst du Hilfe?',
				'es' => '¿Necesitas ayuda?',
				'fr' => "Besoin d'aide ?",
				'tr' => 'Yardıma ihtiyacın mı var?',
				'bg' => 'Нуждаеш се от помощ?',
				'nl' => 'Hulp nodig?',
			),
			'need_a_hand' => array(
				'en' => 'Need help?',
				'sq' => 'Keni nevojë për ndihmë?',
				'it' => 'Hai bisogno di aiuto?',
				'de' => 'Brauchst du Hilfe?',
				'es' => '¿Necesitas ayuda?',
				'fr' => "Besoin d'aide ?",
				'tr' => 'Yardıma ihtiyacınız var mı?',
				'bg' => 'Нуждаете се от помощ?',
				'nl' => 'Hulp nodig?',
			),
			'chat_online' => array(
				'en' => "Chat with us, we're online now.",
				'sq' => 'Bisedo me ne, jemi online tani.',
				'it' => 'Chatta con noi, siamo online ora.',
				'de' => 'Chatte mit uns, wir sind jetzt online.',
				'es' => 'Chatea con nosotros, estamos en línea ahora.',
				'fr' => 'Discute avec nous, nous sommes en ligne maintenant.',
				'tr' => 'Bizimle sohbet et, şu anda çevrimiçiyiz.',
				'bg' => 'Чатете с нас, ние сме онлайн сега.',
				'nl' => 'Chat met ons, we zijn nu online.',
			),
			);
		}

		if ( isset( $copy[ $key ][ $lang ] ) ) {
			return $copy[ $key ][ $lang ];
		}

		if ( isset( $copy[ $key ]['en'] ) ) {
			return $copy[ $key ]['en'];
		}

		return '';
	}
}

