import { AlTriggerStream, AlEntitlementCollection, AlSession, AlRuntimeConfiguration, ConfigOption } from '@al/core';
import { __awaiter } from 'tslib';

class AlNavigationServiceMock {
    constructor() {
        this.queryParams = {};
        this.entitlements = true;
        this.events = new AlTriggerStream();
        this.navigate = {
            byNamedRoute: (routeId, parameters) => {
                // empty intentional
            },
            byRoute: () => {
                // empty intentional
            },
            byNgRoute: () => {
                // empty intentional
            }
        };
        this.router = {
            getCurrentNavigation: () => {
                return {
                    extras: {
                        state: {}
                    }
                };
            }
        };
    }
    setActiveEntitlements(...productIds) {
        this.entitlements = new AlEntitlementCollection(productIds.map((productId) => {
            return {
                productId: productId,
                active: true,
                expires: new Date(Date.now() + 86400000)
            };
        }));
    }
    evaluateEntitlementExpression(expression) {
        if (typeof (this.entitlements) === 'boolean') {
            return this.entitlements;
        }
        return this.entitlements.evaluateExpression(expression);
    }
    setRouteParameter(parameter, value) {
        // empty intentional
    }
    isExperienceAvailable(xpId) {
        return false;
    }
    getNavigationSchema(schemaId) {
        return Promise.resolve({});
    }
    resolveURL(url, parameters = {}, context) {
        return '';
    }
    track() { }
    trackUsageEvent() { }
}

function setAuthState(accountId = '2', actingAccountId = '2', userId = '1001-ABCDEF00-10105060-1234') {
    return __awaiter(this, void 0, void 0, function* () {
        if (accountId === null) {
            AlSession.deactivateSession();
            return;
        }
        let nowTS = Date.now() / 1000;
        let sessionData = {
            authentication: {
                user: {
                    id: userId,
                    name: 'Mister McNielsen',
                    email: 'mcnielsen@alertlogic.com',
                    active: true,
                    locked: false,
                    version: 1002,
                    linked_users: [],
                    created: {
                        at: 123456789,
                        by: 'McNielsen',
                    },
                    modified: {
                        at: 123456790,
                        by: 'Warsaw',
                    }
                },
                account: {
                    id: accountId,
                    name: "Kevin's Fast Company",
                    active: true,
                    accessible_locations: [
                        "defender-us-denver",
                        "insight-us-virginia"
                    ],
                    default_location: 'defender-us-denver',
                    created: {
                        at: 123456789,
                        by: 'McNielsen',
                    },
                    modified: {
                        at: 123456790,
                        by: 'Warsaw',
                    }
                },
                token: 'BigFatFakeToken',
                token_expiration: nowTS + 86400,
            }
        };
        if (actingAccountId !== accountId) {
            sessionData.acting = Object.assign({}, sessionData.authentication.account);
            sessionData.acting.id = actingAccountId;
            sessionData.acting.name = "Kevin's Slow Company";
        }
        AlRuntimeConfiguration.setOption(ConfigOption.ResolveAccountMetadata, false);
        return AlSession.setAuthentication(sessionData);
    });
}
function timeoutPromise(delay) {
    return __awaiter(this, void 0, void 0, function* () {
        return new Promise((resolve, reject) => {
            setTimeout(() => {
                resolve();
            }, delay);
        });
    });
}
function createEntitlementSet(entitlements = []) {
    return new AlEntitlementCollection(entitlements.map(entitlementId => {
        let date = new Date();
        date.setDate(date.getDate() + 1);
        return {
            productId: entitlementId,
            active: true,
            expires: date
        };
    }));
}

/*
 * Public API Surface of design-client
 */

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

export { AlNavigationServiceMock, createEntitlementSet, setAuthState, timeoutPromise };
//# sourceMappingURL=al-ng-navigation-components-testing.js.map
