import * as i0 from '@angular/core';
import { PLATFORM_ID, Injectable, Inject } from '@angular/core';
import { AppsUrlLinksConst, ROUTING_LIST } from '@testlocallibrary/shared-kernel/models/constants';
import { LanguageEnum, LocalStorageKeysEnum } from '@testlocallibrary/shared-kernel/models/enums';
import { isPlatformBrowser } from '@angular/common';
import * as i1 from '@testlocallibrary/shared-kernel/services/local-storage';
import * as i2 from 'ngx-cookie-service';

class RoutingService {
    constructor(localStorageService, cookieService, platformId) {
        this.localStorageService = localStorageService;
        this.cookieService = cookieService;
        this.platformId = platformId;
        this.currentLanguage = LanguageEnum.En;
        this.isBrowser = isPlatformBrowser(platformId);
        this.currentLanguage =
            this.localStorageService.getFromLocalStorage(LocalStorageKeysEnum.Language) || LanguageEnum.En;
    }
    getRouterName(name) {
        if (this.isBrowser) {
            return (`${AppsUrlLinksConst.ldc}/${this.currentLanguage}/` +
                (ROUTING_LIST.find((item) => item.name === name)
                    ? ROUTING_LIST.find((item) => item.name === name)?.route + '/' +
                        `?currentUrl=${window.location.href}`
                    : ''));
        }
        return '';
    }
    ;
    getWhiteRouterName(name) {
        if (this.isBrowser) {
            return (`${AppsUrlLinksConst.white}/${this.currentLanguage}/` +
                (ROUTING_LIST.find((item) => item.name === name)
                    ? ROUTING_LIST.find((item) => item.name === name)?.route + '/' +
                        `?currentUrl=${window.location.href}`
                    : ''));
        }
        return '';
    }
    ;
    setCurrentUrl() {
        if (this.isBrowser) {
            let url = new URL(window.location.href);
            url.searchParams.delete('currentUrl');
            history.replaceState(history.state, '', url.href);
        }
    }
    resetDynamicForm(form) {
        form.reset();
        Object.keys(form.controls).forEach((key) => {
            form.controls[key].setErrors(null);
        });
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: RoutingService, deps: [{ token: i1.LocalStorageService }, { token: i2.CookieService }, { token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: RoutingService, providedIn: 'root' }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: RoutingService, decorators: [{
            type: Injectable,
            args: [{
                    providedIn: 'root',
                }]
        }], ctorParameters: function () { return [{ type: i1.LocalStorageService }, { type: i2.CookieService }, { type: Object, decorators: [{
                    type: Inject,
                    args: [PLATFORM_ID]
                }] }]; } });

/**
 * Generated bundle index. Do not edit.
 */

export { RoutingService };
//# sourceMappingURL=testlocallibrary-shared-kernel-services-routing.mjs.map
