// angular
import { ActivatedRoute } from '@angular/router';

// libs
import { BehaviorSubject, Observable, Subject, of, throwError, from, combineLatest } from 'rxjs';

import { getSafeRedirectUrl } from '../utils/safe-redirect';

export { }

declare global {
	interface RouterExtensions {
		addDays(days: number): Date;
	}
	}

export class ExActivatedRoute extends ActivatedRoute {

	getCurrentRoute(): string {
		const raw = this.snapshot.queryParams['r'] as string | undefined;
		return getSafeRedirectUrl(raw);
	}
}

interface Action<T> {
	(item: T): void;
}

interface Func<T, TResult> {
	(item: T): TResult;
}

export class SubjectExtensions {

	static start<T>(start: Action<Subject<T>>): Subject<T> {
		var result = new Subject<T>();

		start(result);

		return result;
	}
}
