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

export interface PageViewIdProps {
  value: string;
}

/**
 * Value Object: PageViewId
 *
 * Represents the identifier of a PageView within the analytics bounded context.
 */
export class PageViewId implements IValueObject<PageViewIdProps> {
  public readonly props: PageViewIdProps;

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

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

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

    return new PageViewId(value);
  }

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

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