const SessionStorageKey = 'local-url';
// list of paths to ignore when storing the path
const invalidPaths = ['/null', '/sso/entra', '/aad_callback', '/aad_redirect'];
// list of parameters to ignore when storing the path
const ignoredParams = ['id_token_hint'];
export const storeInitialPath = () => {
    if (!window.sessionStorage.getItem(SessionStorageKey) ||
        invalidPaths.includes(window.sessionStorage.getItem(SessionStorageKey))) {
        const params = new URLSearchParams(window.location.search);
        ignoredParams.forEach(param => params.delete(param));
        const queryString = params.toString();
        const path = window.location.pathname + (queryString ? `?${queryString}` : '');
        window.sessionStorage.setItem(SessionStorageKey, window.location.pathname === '/null' ? '/' : path);
    }
};
export const storeCurrentPath = () => {
    window.sessionStorage.setItem(SessionStorageKey, window.location.pathname);
};
export const storeRedirectPath = (pathname = window.location.pathname, search = window.location.search) => {
    if (!pathname || invalidPaths.includes(pathname)) {
        return;
    }
    const params = new URLSearchParams(search);
    ignoredParams.forEach(param => params.delete(param));
    const queryString = params.toString();
    const path = pathname + (queryString ? `?${queryString}` : '');
    window.sessionStorage.setItem(SessionStorageKey, pathname === '/null' ? '/' : path);
};
export const storePath = pathname => {
    window.sessionStorage.setItem(SessionStorageKey, pathname);
};
export const getStoredPath = () => {
    return window.sessionStorage.getItem(SessionStorageKey);
};
export const clearStoredPath = () => {
    window.sessionStorage.removeItem(SessionStorageKey);
};
//# sourceMappingURL=LocalRedirectUrlStorage.js.map