/**
 * Base component class for all ShopyPress components
 * Provides common DOM manipulation methods
 */
class BaseComponent {
    constructor(selector) {
        this._element = jQuery(selector);
        if (this._element.length) {
            this._element.data('initialized', 'true');
        }
    }

    show() {
        if (this._element) {
            this._element.show();
        }
    }

    hide() {
        if (this._element) {
            this._element.hide();
        }
    }

    fadeIn(duration = 300) {
        if (this._element) {
            this._element.fadeIn(duration);
        }
    }

    fadeOut(duration = 300) {
        if (this._element) {
            this._element.fadeOut(duration);
        }
    }

    addClass(className) {
        if (this._element) {
            this._element.addClass(className);
        }
    }

    removeClass(className) {
        if (this._element) {
            this._element.removeClass(className);
        }
    }

    toggleClass(className) {
        if (this._element) {
            this._element.toggleClass(className);
        }
    }
}

export default BaseComponent;
