'use strict';
import { isEmptyNullOrUndefined } from '../../../../../fd-toolbox/functions/value-checking-functions.js';
import { userConstants } from '../../../../../fd-toolbox/constants/user-infos.js';
import { getSessionToken, getUserIdFromSession, getSessionFromCache } from '../session-access.js';
import { isTest } from '../../../../../fd-toolbox/lib/environments.js';

var __defProp=Object['defineProperty'],__name=(_0x1cd825,_0x55e44d)=>__defProp(_0x1cd825,'name',{'value':_0x55e44d,'configurable':!![]});const defaultUserId=userConstants['timWId'];let processUserIds=new Map();async function getUserId(){let _0x5b7779,_0xf5f87b;const _0x5387e2=processUserIds['get'](process['pid']);if(isTest()&&_0x5387e2)return _0x5387e2;try{_0x5b7779=await getSessionToken();}catch{_0x5b7779=void(0x23ef*0x1+-0xe84*0x2+0x6e7*-0x1);}if(_0x5b7779){const _0x44780c=await getUserIdFromSession(_0x5b7779);!isEmptyNullOrUndefined(_0x44780c)&&(setCurrentUserId(_0x44780c),_0xf5f87b=_0x44780c);}return _0xf5f87b??=_0x5387e2??defaultUserId,_0xf5f87b;}__name(getUserId,'getUserId');async function getUserIdFromCache(){let _0x5b70ad,_0x59a704=defaultUserId;const _0x1ccd65=processUserIds['get'](process['pid']);if(isTest()&&_0x1ccd65)return _0x1ccd65;try{_0x5b70ad=await getSessionToken();}catch{return _0x59a704;}if(_0x5b70ad){const _0x41a46b=await getSessionFromCache(_0x5b70ad),_0x32b58f=_0x41a46b?.['userId']??await getUserIdFromSession(_0x5b70ad);_0x32b58f&&(setCurrentUserId(_0x32b58f),_0x59a704=_0x32b58f);}return _0x59a704;}__name(getUserIdFromCache,'getUserIdFromCache');function setCurrentUserId(_0x93295f){processUserIds['set'](process['pid'],_0x93295f);}__name(setCurrentUserId,'setCurrentUserId');

export { getUserId, getUserIdFromCache, setCurrentUserId };
