import { LogicError } from '@serenity-js/core' ; import { ActivityFinished , ActivityStarts , DomainEvent } from '@serenity-js/core/lib/events' ; import { Stage , StageCrewMember } from '@serenity-js/core/lib/stage' ; import { PhotoTakingStrategy } from './strategies' ; desc The Photographer is a  {@link @serenity-js/core/lib/stage~StageCrewMember} who takes screenshots
 *  of the web browser the  {@link @serenity-js/core/lib/screenplay/actor~Actor} in the spotlight is using.
 *
 *  example example example example see {@link @serenity-js/core/lib/stage~Stage} see TakePhotosBeforeAndAfterInteractions see TakePhotosOfFailures see TakePhotosOfInteractions export class Photographer implements StageCrewMember { desc Instantiates a new  Photographer configured to take photos (screenshots)
     *  as per the specified  PhotoTakingStrategy .
     *
     *  param { Function } strategy - A no-arg constructor function that instantiates a  PhotoTakingStrategy .
     *  returns { StageCrewMember } static whoWill ( strategy ) { return new Photographer ( new strategy ( ) ) ; } param { PhotoTakingStrategy } photoTakingStrategy param { Stage } stage constructor ( private readonly photoTakingStrategy , private stage ? ) { } desc Creates a new instance of this  StageCrewMember and assigns it to a given  Stage .
     *
     *  param { Stage } stage - An instance of a  Stage this  StageCrewMember will be assigned to
     *  returns { StageCrewMember } - A new instance of this  StageCrewMember assignedTo ( stage ) { return new Photographer ( this . photoTakingStrategy , stage ) ; } desc Handles  DomainEvent objects emitted by the  Stage *  this  StageCrewMember is assigned to.
     *
     *  param { DomainEvent } event returns { void } notifyOf ( event ) { if ( ! this . stage ) { throw new LogicError ( `Photographer needs to be assigned to the Stage before it can be notified of any DomainEvents` ) ; } if ( ! this . stage . theShowHasStarted ( ) ) { return void 0 ; } if ( event instanceof ActivityStarts || event instanceof ActivityFinished ) { this . photoTakingStrategy . considerTakingPhoto ( event , this . stage ) ; } } }