'use strict';
import { fdCookies } from '../../../../fd-toolbox/server/framework/index.js';
import { removeFromCoreCache } from '../../../../fd-toolbox/server/cachings/core-cache.js';
import { invalidateSession, createSessionCookie, createSession } from './fd-sessions.js';
import { validateSession } from './session-validation.js';
import { getSession } from './session-access.js';

var __defProp=Object['defineProperty'],__name=(_0x26bcce,_0x1b3153)=>__defProp(_0x26bcce,'name',{'value':_0x1b3153,'configurable':!![]});const emptySessionValidationResult={'userId':void(0x4cb+-0x1d4d+0x2*0xc41),'workspaceId':void(-0x1571*-0x1+0x1267+-0x258*0x11),'currentWorkspaceId':void(0x3*0x1bb+0x1ff0+-0x1*0x2521)};async function validateSessionToken(_0x4ad00a){const _0x3949fc=await getSession(_0x4ad00a);if(!_0x3949fc)return await invalidateSession(_0x4ad00a),emptySessionValidationResult;const _0x46a299={'userId':_0x3949fc['userId'],'currentWorkspaceId':_0x3949fc['currentWorkspaceId']};if(_0x3949fc['fresh']){const _0x248e6d=await fdCookies(),_0x56bcbe=createSessionCookie(_0x3949fc['id']);_0x248e6d['set'](_0x56bcbe['name'],_0x56bcbe['value'],_0x56bcbe['attributes']);}return _0x46a299;}__name(validateSessionToken,'validateSessionToken');async function updateSessionData(_0x4cc421,_0xb8ede5){const _0x572d96=await updateSession(_0x4cc421,_0xb8ede5);if(!_0x572d96)return void(0x1151*-0x1+0xf6f+0x1e2);return createSessionCookie(_0x572d96['id']);}__name(updateSessionData,'updateSessionData');async function deleteSession(_0x57d1b9){await invalidateSession(_0x57d1b9),await removeFromCoreCache(_0x57d1b9);}__name(deleteSession,'deleteSession');async function updateSession(_0x41c4ed,_0x5e5fc9){const _0x3026ac=await validateSession(_0x41c4ed);if(!_0x3026ac)return void(-0x917*-0x2+0xabb+-0x1ce9);const _0x2f3349=await createSession(_0x3026ac['userId'],{'homeWorkspaceId':_0x5e5fc9['homeWorkspaceId']??_0x3026ac['homeWorkspaceId'],'currentWorkspaceId':_0x5e5fc9['currentWorkspaceId']??_0x3026ac['currentWorkspaceId']});return await deleteSession(_0x41c4ed),_0x2f3349;}__name(updateSession,'updateSession');

export { deleteSession, updateSession, updateSessionData, validateSessionToken };
