<?php

/**
 * Internal Links Frontend Assets
 */

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

/**
 * Enqueue frontend styles for smart links
 */
function content_craft_ai_enqueue_smart_link_styles()
{
  // Get the current template
  $user_settings = get_option('content_craft_ai_user_settings', []);
  $template = $user_settings['smartLinkTemplate'] ?? 'default';

  // Validate template exists
  $valid_templates = ['default', 'bordered', 'minimal', 'card'];
  if (!in_array($template, $valid_templates)) {
    $template = 'default';
  }

  // Enqueue the smart link CSS file
  wp_enqueue_style(
    'content-craft-ai-smart-links',
    CONTENT_CRAFT_AI_PLUGIN_URL . 'app/assets/css/smart-links/' . $template . '.css',
    [],
    CONTENT_CRAFT_AI_VERSION
  );
}

/**
 * Initialize smart links styles
 */
function content_craft_ai_init_smart_links()
{
  // Register actions
  add_action('wp_enqueue_scripts', 'content_craft_ai_enqueue_smart_link_styles');
}

// Initialize the smart links
content_craft_ai_init_smart_links();
