import {ObjectTreesApplicationInterface} from '../../application.interface';
import {ExtensionProvider} from '../../integration/extension.provider';
import {LocationProvider} from '../location/location.provider';
import {LogProvider} from '../log/log.provider';
import {ServerConfigProvider} from '../server-config/server-config.provider';
import {ActionImageService} from './action-image.service';
import {
  CONTENT_IMAGE_PROVIDER,
  DISPLAYED_IMAGE_GALLERY_TYPE,
  IMAGE_ALBUM_IMAGE_SUBTYPE,
  IMAGE_ALBUM_TYPE,
  IMAGE_GALLERIES_IMAGE_ALBUM_SUBTYPE,
  IMAGE_GALLERIES_IMAGE_GALLERY_CONCATENATION_SUBTYPE,
  IMAGE_GALLERIES_TYPE,
  IMAGE_GALLERY_CONCATENATION_ALL_DEFAULT_TYPE,
  IMAGE_GALLERY_CONCATENATION_IMAGE_SUBTYPE,
  IMAGE_GALLERY_CONCATENATION_TYPE,
  IMAGE_GALLERY_REFERRER_TYPE,
  IMAGE_GALLERY_SELECTOR_TYPE,
  IMAGE_GALLERY_TYPE,
  IMAGE_TYPE,
} from './content-image.const';
import {
  ContentImage,
  ContentImageRepository,
  ContentImageService,
  Image,
} from './content-image.definition';
import {InterceptImageService} from './intercept-image.service';
import {TransientImageService} from './transient-image.service';

export class ContentImageProvider extends ExtensionProvider {
  constructor(protected app: ObjectTreesApplicationInterface) {
    super(CONTENT_IMAGE_PROVIDER, app);

    this.requiredProviders.push(
      LocationProvider,
      LogProvider,
      ServerConfigProvider,
    );

    this.models.push(Image, ContentImage);
    this.repositories.push({repoClass: ContentImageRepository});

    this.services.push(
      {cls: ContentImageService},
      {cls: TransientImageService},
      {cls: InterceptImageService},
      {cls: ActionImageService},
    );

    this.objectTypes.push(
      IMAGE_GALLERY_TYPE,
      IMAGE_ALBUM_TYPE,
      IMAGE_GALLERIES_TYPE,
      IMAGE_GALLERY_REFERRER_TYPE,
      IMAGE_TYPE,
      IMAGE_GALLERY_SELECTOR_TYPE,
      DISPLAYED_IMAGE_GALLERY_TYPE,
      IMAGE_GALLERY_CONCATENATION_TYPE,
      IMAGE_GALLERY_CONCATENATION_ALL_DEFAULT_TYPE,
    );

    this.objectSubTypes.push(
      IMAGE_GALLERIES_IMAGE_ALBUM_SUBTYPE,
      IMAGE_ALBUM_IMAGE_SUBTYPE,
      IMAGE_GALLERY_CONCATENATION_IMAGE_SUBTYPE,
      IMAGE_GALLERIES_IMAGE_GALLERY_CONCATENATION_SUBTYPE,
    );
  }
}
