import type { ValueObject } from '@core/shared/domain/ValueObject';

export interface AnalyticsEntityIdProps {
  value: string;
}

/**
 * Value Object: AnalyticsEntityId
 *
 * Represents the ID of an entity (league, driver, team, race, sponsor)
 * within the analytics bounded context.
 */
export class AnalyticsEntityId implements ValueObject<AnalyticsEntityIdProps> {
  public readonly props: AnalyticsEntityIdProps;

  private constructor(value: string) {
    this.props = { value };
  }

  static create(raw: string): AnalyticsEntityId {
    const value = raw.trim();

    if (!value) {
      throw new Error('AnalyticsEntityId must be a non-empty string');
    }

    return new AnalyticsEntityId(value);
  }

  get value(): string {
    return this.props.value;
  }

  equals(other: ValueObject<AnalyticsEntityIdProps>): boolean {
    return this.props.value === other.props.value;
  }
}