<?php

class ConstBlockOrphicOptionValue
{
  const GLOBAL_COLOR_PALETTE_CLASSIC = 'classic';
  const GLOBAL_COLOR_PALETTE_CUSTOM = 'custom';
  const TOKEN = 'orphic_plugin_token';
  const LICENSE_STATUS = 'orphic_license_status';
}

class ConstBlockOrphicOptionName
{
  const GLOBAL_COLOR_PALETTE = 'orphic_wp_block_global_color_palette_name'; // classic or custom
  const PLUGIN_COLORS = 'orphic_wp_block_plugin_colors'; // array of colors from the chosen palette (classic or custom)
  const PLUGIN_COLORS_CUSTOM = 'orphic_wp_block_plugin_colors_custom'; // array of colors from the custom palette
  const ACTIVE_BLOCKS = 'orphic_wp_block_plugin_active_blocks'; // array of blocks
  const ACTIVE_MODULES = 'orphic_wp_block_plugin_active_modules'; // array of modules
  const BREAKPOINT_MOBILE = 'orphic_wp_block_breakpoint_mobile'; // array of breakpoint settings
  const BREAKPOINT_TABLET_MIN = 'orphic_wp_block_breakpoint_tablet_min'; // array of breakpoint settings
  const BREAKPOINT_TABLET_MAX = 'orphic_wp_block_breakpoint_tablet_max'; // array of breakpoint settings
  const BREAKPOINT_DESKTOP = 'orphic_wp_block_breakpoint_desktop'; // array of breakpoint settings
}

class ConstBlockVariable
{
  const GOOGLE_MAP_API_KEY = 'orphic_wp_block_google_map_api_key';
}

// TODO: auto-activate blocks? Right now they are all de-activated by default
class ConstBlockOrphicBlockList
{
  const BLOCKS = array(
    array(
      "label" => "FAQs",
      "key" => "faq",
      "description" => "Build elegant FAQ sections with collapsible answers, search functionality, and category filtering. Boost your SEO with structured data markup.",
      "svg" => '<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16" viewBox="0 0 512 512"><!--!Font Awesome Free 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM169.8 165.3c7.9-22.3 29.1-37.3 52.8-37.3h58.3c34.9 0 63.1 28.3 63.1 63.1c0 22.6-12.1 43.5-31.7 54.8L280 264.4c-.2 13-10.9 23.6-24 23.6c-13.3 0-24-10.7-24-24V250.5c0-8.6 4.6-16.5 12.1-20.8l44.3-25.4c4.7-2.7 7.6-7.7 7.6-13.1c0-8.4-6.8-15.1-15.1-15.1H222.6c-3.4 0-6.4 2.1-7.5 5.3l-.4 1.2c-4.4 12.5-18.2 19-30.6 14.6s-19-18.2-14.6-30.6l.4-1.2zM224 352a32 32 0 1 1 64 0 32 32 0 1 1 -64 0z"/></svg>'
    ),
    array(
      "label" => "Persistent banner",
      "key" => "persistent-banner",
      "description" => "Display important announcements or promotional content that stays visible while scrolling. Fully responsive with customizable positions and dismiss options.",
      "svg" => '<svg xmlns="http://www.w3.org/2000/svg" height="16" width="18" viewBox="0 0 576 512"><!--!Font Awesome Free 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M64 0C28.7 0 0 28.7 0 64V352c0 35.3 28.7 64 64 64H240l-10.7 32H160c-17.7 0-32 14.3-32 32s14.3 32 32 32H416c17.7 0 32-14.3 32-32s-14.3-32-32-32H346.7L336 416H512c35.3 0 64-28.7 64-64V64c0-35.3-28.7-64-64-64H64zM512 64V352H64V64H512z"/></svg>',
      "experimental" => true
    ),
    array(
      "label" => "Responsive spacer",
      "key" => "spacer-responsive",
      "description" => "Add dynamic spacing that automatically adjusts based on screen size. Perfect for creating balanced layouts across all devices.",
      "svg" => '<svg xmlns="http://www.w3.org/2000/svg" height="16" width="18" viewBox="0 0 512 512"><!--!Font Awesome Pro 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2025 Fonticons, Inc.--><path d="M292.7 196.7L281.4 208 304 230.6l11.3-11.3L480 54.6 480 160l0 16 32 0 0-16 0-144 0-16L496 0 352 0 336 0l0 32 16 0 105.4 0L292.7 196.7zM219.3 315.3L230.6 304 208 281.4l-11.3 11.3L32 457.4 32 352l0-16L0 336l0 16L0 496l0 16 16 0 144 0 16 0 0-32-16 0L54.6 480 219.3 315.3z"/></svg>'
    ),
    array(
      "label" => "Animation wrapper",
      "key" => "animation-wrapper",
      "description" => "Enhance any block with smooth animations triggered by scroll or view. Choose from a variety of effects and customize timing and properties.",
      "svg" => '<svg xmlns="http://www.w3.org/2000/svg" width="20" viewBox="0 0 576 512"><!--!Font Awesome Pro 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2025 Fonticons, Inc.--><path d="M150.6 489.4L128 512l-22.6-22.6L54.6 438.6 32 416l22.6-22.6L425.4 22.6 448 0l22.6 22.6 50.7 50.7L544 96l-22.6 22.6L150.6 489.4zM498.7 96L448 45.3 337.9 155.3l50.7 50.7L498.7 96zM128 466.7L366.1 228.7l-50.7-50.7L77.3 416 128 466.7zM252.2 3.8l0 12.2 0 19.8 19.8 0 12.2 0 0 24.3-12.2 0-19.8 0 0 19.8 0 12.2-24.3 0 0-12.2 0-19.8-19.8 0-12.2 0 0-24.3 12.2 0 19.8 0 0-19.8 0-12.2 24.3 0zM128 80l0 48 48 0 16 0 0 32-16 0-48 0 0 48 0 16-32 0 0-16 0-48-48 0-16 0 0-32 16 0 48 0 0-48 0-16 32 0 0 16zM480 336l0 48 48 0 16 0 0 32-16 0-48 0 0 48 0 16-32 0 0-16 0-48-48 0-16 0 0-32 16 0 48 0 0-48 0-16 32 0 0 16z"/></svg>'
    ),
    array(
      "label" => "Documentation",
      "key" => "documentation",
      "description" => "Create professional documentation pages with syntax highlighting, live previews, and searchable content. Perfect for technical guides and tutorials.",
      "experimental" => true,
      "svg" => '<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16" viewBox="0 0 512 512"><!--!Font Awesome Free 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M40 48C26.7 48 16 58.7 16 72v48c0 13.3 10.7 24 24 24H88c13.3 0 24-10.7 24-24V72c0-13.3-10.7-24-24-24H40zM192 64c-17.7 0-32 14.3-32 32s14.3 32 32 32H480c17.7 0 32-14.3 32-32s-14.3-32-32-32H192zm0 160c-17.7 0-32 14.3-32 32s14.3 32 32 32H480c17.7 0 32-14.3 32-32s-14.3-32-32-32H192zm0 160c-17.7 0-32 14.3-32 32s14.3 32 32 32H480c17.7 0 32-14.3 32-32s-14.3-32-32-32H192zM16 232v48c0 13.3 10.7 24 24 24H88c13.3 0 24-10.7 24-24V232c0-13.3-10.7-24-24-24H40c-13.3 0-24 10.7-24 24zM40 368c-13.3 0-24 10.7-24 24v48c0 13.3 10.7 24 24 24H88c13.3 0 24-10.7 24-24V392c0-13.3-10.7-24-24-24H40z"/></svg>'
    ),
    array(
      "label" => "Testimonials",
      "key" => "testimonials",
      "description" => "Showcase client testimonials in a beautiful grid or slider layout. Features star ratings, profile images, and company logos with multiple display options.",
      "svg" => '<svg xmlns="http://www.w3.org/2000/svg" height="16" width="14" viewBox="0 0 448 512"><!--!Font Awesome Free 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M0 216C0 149.7 53.7 96 120 96h8c17.7 0 32 14.3 32 32s-14.3 32-32 32h-8c-30.9 0-56 25.1-56 56v8h64c35.3 0 64 28.7 64 64v64c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64V320 288 216zm256 0c0-66.3 53.7-120 120-120h8c17.7 0 32 14.3 32 32s-14.3 32-32 32h-8c-30.9 0-56 25.1-56 56v8h64c35.3 0 64 28.7 64 64v64c0 35.3-28.7 64-64 64H320c-35.3 0-64-28.7-64-64V320 288 216z"/></svg>'
    ),
    array(
      "label" => "Hover Highlight",
      "key" => "hover-highlights",
      "description" => "Create a hover effect on text and images. Perfect for creating interactive content.",
      "svg" => '<svg xmlns="http://www.w3.org/2000/svg" width="20" viewBox="0 0 576 512"><!--!Font Awesome Free 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M316.9 18C311.6 7 300.4 0 288.1 0s-23.4 7-28.8 18L195 150.3 51.4 171.5c-12 1.8-22 10.2-25.7 21.7s-.7 24.2 7.9 32.7L137.8 329 113.2 474.7c-2 12 3 24.2 12.9 31.3s23 8 33.8 2.3l128.3-68.5 128.3 68.5c10.8 5.7 23.9 4.9 33.8-2.3s14.9-19.3 12.9-31.3L438.5 329 542.7 225.9c8.6-8.5 11.7-21.2 7.9-32.7s-13.7-19.9-25.7-21.7L381.2 150.3 316.9 18z"/></svg>'
    ),
    array(
      "label" => "Animated Image Layers",
      "key" => "animated-image-layers",
      "description" => "Create a layered animated image.",
      "svg" => '<svg xmlns="http://www.w3.org/2000/svg" width="25" viewBox="0 0 640 512"><!--!Font Awesome Pro 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2025 Fonticons, Inc.--><path d="M608 32L224 32l0 201.4 84.7-84.7L320 137.4l11.3 11.3L384 201.4 500.7 84.7 512 73.4l11.3 11.3L608 169.4 608 32zm32 176c0 0 0 0 0 .1l0 112 0 32-32 0-336 0c0 0 0 0 0 0l-48 0-32 0 0-32 0-48s0 0 0 0l0-240 0-32 32 0L608 0l32 0 0 32 0 176zm-32 6.7l-96-96L395.3 235.3 310.6 320 608 320l0-105.4zM265.4 320l96-96L320 182.6l-96 96 0 41.4 41.4 0zM296 80a24 24 0 1 1 0 48 24 24 0 1 1 0-48zM128 160l32 0 0 32-32 0 0 80 0 128 0 80 256 0 0-96 32 0 0 96 64 0 0-96 32 0 0 96 0 32-32 0-64 0-16 0-16 0-256 0-16 0-16 0-64 0L0 512l0-32L0 192l0-32 32 0 64 0 16 0 16 0zM96 192l-64 0 0 64 64 0 0-64zM32 480l64 0 0-64-64 0 0 64zm64-96l0-96-64 0 0 96 64 0z"/></svg>'
    ),
    array(
      "label" => "Parallax Slider",
      "key" => "parallax-slider",
      "description" => "Create a parallax slider with multiple layers.",
      "svg" => '<svg xmlns="http://www.w3.org/2000/svg" width="25" viewBox="0 0 640 512"><!--!Font Awesome Pro 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2025 Fonticons, Inc.--><path d="M0 64L0 32l32 0 21.5 0C138.3 62.3 230.5 72 320 72s181.7-9.7 266.5-40L608 32l32 0 0 32 0 384 0 32-32 0-21.5 0c-84.8-30.3-176.9-40-266.5-40c-79.2 0-160.4 7.6-236.7 30.3l-.1 .1-.1-.1c-9.9 3-19.8 6.2-29.6 9.7L32 480 0 480l0-32L0 64zM114.2 429.1c27.3-6.3 55-10.9 82.7-14.2L260 330.7l-36-48L114.2 429.1zm125.7-18.3c26.9-1.9 53.7-2.8 80.1-2.8c74.1 0 151.3 6.5 225.4 25.9L384 218.7 292.8 340.3l-52.9 70.5zM596 448l12 0 0-384-16.1 0C504 94.5 409.8 104 320 104s-184-9.5-271.9-40L32 64l0 384 16.1 0c5.3-1.8 10.6-3.6 15.9-5.2l3.3-4.4 144-192L224 229.3l12.8 17.1L280 304l91.2-121.6L384 165.3l12.8 17.1 192 256L596 448zM112 184a24 24 0 1 1 48 0 24 24 0 1 1 -48 0z"/></svg>'
    ),
    array(
      "label" => "Google Map",
      "key" => "google-map",
      "description" => "Show a map of a specific location. Requires a Google Maps API key you can set in the Orphic options.",
      "svg" => '<svg xmlns="http://www.w3.org/2000/svg" height="16" width="12" viewBox="0 0 384 512"><!--!Font Awesome Free 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M215.7 499.2C267 435 384 279.4 384 192C384 86 298 0 192 0S0 86 0 192c0 87.4 117 243 168.3 307.2c12.3 15.3 35.1 15.3 47.4 0zM192 128a64 64 0 1 1 0 128 64 64 0 1 1 0-128z"/></svg>'
    ),
    array(
      "label" => "Carousel",
      "key" => "carousel",
      "description" => "Create a carousel with multiple slides.",
      "svg" => '<svg xmlns="http://www.w3.org/2000/svg" width="25" viewBox="0 0 448 512"><!--!Font Awesome Pro 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2025 Fonticons, Inc.--><path d="M416 256a32 32 0 1 1 -64 0 32 32 0 1 1 64 0zm-160 0a32 32 0 1 1 -64 0 32 32 0 1 1 64 0zM64 288a32 32 0 1 1 0-64 32 32 0 1 1 0 64z"/></svg>'
    ),
    array(
      "label" => "Breakpoint",
      "key" => "breakpoint",
      "description" => "Display a block only on desktop devices.",
      "svg" => '<svg xmlns="http://www.w3.org/2000/svg" width="25" viewBox="0 0 640 512"><!--!Font Awesome Pro 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2025 Fonticons, Inc.--><path d="M96 32l384 0 0 64 32 0 0-64 0-32L480 0 96 0 64 0l0 32 0 256-32 0L0 288l0 32 0 16 48 48 304 0 0-32L61.3 352 32 322.7l0-2.7 32 0 32 0 256 0 0-32L96 288 96 32zM384 512l32 0 192 0 32 0 0-32 0-320 0-32-32 0-192 0-32 0 0 32 0 320 0 32zm224-32l-192 0 0-320 192 0 0 320z"/></svg>'
    ),
    array(
      "label" => "Stack Card",
      "key" => 'stack-card',
      "description" => "Display a block with multiple cards stacked on top of each other.",
      "svg" => '<svg xmlns="http://www.w3.org/2000/svg" width="25" viewBox="0 0 640 512"><!--!Font Awesome Pro 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2025 Fonticons, Inc.--><path d="M96 32l384 0 0 64 32 0 0-64 0-32L480 0 96 0 64 0l0 32 0 256-32 0L0 288l0 32 0 16 48 48 304 0 0-32L61.3 352 32 322.7l0-2.7 32 0 32 0 256 0 0-32L96 288 96 32zM384 512l32 0 192 0 32 0 0-32 0-320 0-32-32 0-192 0-32 0 0 32 0 320 0 32zm224-32l-192 0 0-320 192 0 0 320z"/></svg>'
    ),
    array(
      "label" => "Search Bar",
      "key" => "search-bar",
      "description" => "Create a search bar with multiple options.",
      "svg" => '<svg xmlns="http://www.w3.org/2000/svg" width="25" viewBox="0 0 640 512"><!--!Font Awesome Pro 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2025 Fonticons, Inc.--><path d="M96 32l384 0 0 64 32 0 0-64 0-32L480 0 96 0 64 0l0 32 0 256-32 0L0 288l0 32 0 16 48 48 304 0 0-32L61.3 352 32 322.7l0-2.7 32 0 32 0 256 0 0-32L96 288 96 32zM384 512l32 0 192 0 32 0 0-32 0-320 0-32-32 0-192 0-32 0 0 32 0 320 0 32zm224-32l-192 0 0-320 192 0 0 320z"/></svg>'
    )

  );
}

class ConstBlockOrphicModuleList
{
  const MODULES = array(
    array(
      "label" => "Motion Animation",
      "key" => "motion-animation",
      "type" => "js",
      "description" => "Advanced animation module using Motion library. Provides smooth scroll-based animations and view-triggered effects.",
      "dependencies" => array()
    )
  );
}

class Orphic_WP_Block_Constants
{

  public static function enqueue_constants_script()
  {

    // Check if the file exists
    $file_path = ORPHIC_PLUGIN_UI_DIR_PATH . 'public/const/orphic-wp-block-constants.js';
    if (!file_exists($file_path)) {
      error_log("Orphic WP Block: Constants file not found at: " . $file_path);
      return;
    }

    // Ensure we're using the correct hook for enqueueing scripts
    if (!function_exists('wp_enqueue_script')) {
      error_log("Orphic WP Block: wp_enqueue_script function not available");
      return;
    }

    // Enqueue the script
    wp_enqueue_script(
      'orphic-wp-block-constants',
      ORPHIC_PLUGIN_UI_DIR_URL . 'public/const/orphic-wp-block-constants.js',
      array(), // No dependencies
      filemtime($file_path), // Use file modification time as version
      true // Load in footer
    );

    // Check if the script was successfully enqueued
    if (!wp_script_is('orphic-wp-block-constants', 'enqueued')) {
      error_log("Orphic WP Block: Failed to enqueue constants script");
    }


    // Automatically generate localized script data for ConstBlockOrphicOptionName
    $constBlockOrphicOptionData = [];
    $reflection = new ReflectionClass('ConstBlockOrphicOptionName');
    foreach ($reflection->getConstants() as $name => $value) {
      $constBlockOrphicOptionData[$name] = $value;
    }
    wp_localize_script('orphic-wp-block-constants', 'ConstBlockOrphicOptionName', $constBlockOrphicOptionData);

    // Automatically generate localized script data for ConstBlockOrphicOptionValue
    $constBlockOrphicOptionValueData = [];
    $reflection = new ReflectionClass('ConstBlockOrphicOptionValue');
    foreach ($reflection->getConstants() as $name => $value) {
      $constBlockOrphicOptionValueData[$name] = $value;
    }
    wp_localize_script('orphic-wp-block-constants', 'ConstBlockOrphicOptionValue', $constBlockOrphicOptionValueData);


    // Get all option names from ConstBlockOrphicOptionName
    $option_names = array_values($constBlockOrphicOptionData);

    // Fetch all option values
    $option_values = array();
    foreach ($option_names as $option_name) {
      $option_values[$option_name] = get_option($option_name);
    }

    // Encode option values as JSON and send to JavaScript
    wp_localize_script('orphic-wp-block-constants', 'OrphicWPBlockOptions', $option_values);


    $colors = get_option(ConstBlockOrphicOptionName::PLUGIN_COLORS);
    wp_localize_script('orphic-wp-block-constants', 'OrphicWPColorsTheme', $colors);
  }
}
