<?php

namespace SugarCalendarBookings\Support\ElementorWidgets;

use Elementor\Widget_Base;

/**
 * Abstract Elementor Widget.
 *
 * Base class for all Elementor widgets in the plugin.
 *
 * @since 1.0.0
 */
abstract class AbstractElementorWidget extends Widget_Base {

	/**
	 * Get widget name.
	 *
	 * Subclasses must override this method.
	 *
	 * @since 1.0.0
	 *
	 * @return string
	 */
	public function get_name(): string {

		return '';
	}

	/**
	 * Get widget title.
	 *
	 * Subclasses must override this method.
	 *
	 * @since 1.0.0
	 *
	 * @return string
	 */
	public function get_title(): string {

		return '';
	}

	/**
	 * Get widget icon.
	 *
	 * @since 1.0.0
	 *
	 * @return string
	 */
	public function get_icon(): string {

		return 'eicon-calendar';
	}

	/**
	 * Get widget categories.
	 *
	 * @since 1.0.0
	 *
	 * @return array
	 */
	public function get_categories(): array {

		return [ 'general' ];
	}

	/**
	 * Get widget keywords.
	 *
	 * @since 1.0.0
	 *
	 * @return array
	 */
	public function get_keywords(): array {

		return [ 'booking', 'calendar', 'appointment', 'sugar calendar' ];
	}

	/**
	 * Register widget assets (scripts and styles).
	 *
	 * Called during wp_enqueue_scripts to allow each widget to register its own assets.
	 *
	 * @since 1.0.0
	 */
	public function register_widget_assets(): void {
		// Override in child classes to register specific assets.
	}

	/**
	 * Enqueue preview assets for Elementor editor.
	 *
	 * Called during elementor/preview/enqueue_scripts for editor preview functionality.
	 *
	 * @since 1.0.0
	 */
	public function enqueue_preview_assets(): void {
		// Override in child classes to enqueue preview assets.
	}

	/**
	 * Register widget controls.
	 *
	 * Subclasses must override this method.
	 *
	 * @since 1.0.0
	 */
	protected function register_controls(): void {}

	/**
	 * Render widget output.
	 *
	 * Subclasses must override this method.
	 *
	 * @since 1.0.0
	 */
	protected function render(): void {}

	/**
	 * Check if this widget should be loaded.
	 *
	 * @since 1.0.0
	 *
	 * @return bool
	 */
	public function allow_load(): bool {

		return did_action( 'elementor/loaded' ) && class_exists( Widget_Base::class );
	}
}
