'use strict';
import { apiOkResponse, apiBadRequestResponse, apiNoContentResponse } from '../../meta/server/web/responses.js';
import { changeCurrentWorkspace } from './change-current-workspace.js';
import { responseMessages } from '../../../fd-toolbox/server/web/response-messages.js';
import { getUserId } from '../../meta/server/auth/users/current-user-id-provider.js';
import { getAllUserWorkspaces } from '../../fd-app-toolbox/server/infra/workspaces/workspace-db.js';
import { parseJsonBodyFromRequest } from '../../../fd-toolbox/lib/utils.js';
import { serializeCookie } from '../../../fd-toolbox/server/auth/cookies.js';
import { httpHeaders } from '../../../fd-toolbox/server/constants/workspace-constants.js';

var __defProp=Object['defineProperty'],__name=(_0x2a9556,_0x57ba9c)=>__defProp(_0x2a9556,'name',{'value':_0x57ba9c,'configurable':!![]});async function workspaceGetRoute(){const _0xc33a5a=await getUserId(),_0x2f6d12=await getAllUserWorkspaces(_0xc33a5a);return apiOkResponse({'currentWorkspaceId':_0x2f6d12['currentWorkspaceId'],'childWorkspaces':_0x2f6d12['childWorkspaces'],'homeWorkspace':_0x2f6d12['homeWorkspace']});}__name(workspaceGetRoute,'workspaceGetRoute');async function workspacePostRoute(_0xb23d19){const _0x4440d1=await parseJsonBodyFromRequest(_0xb23d19);if(!_0x4440d1['workspaceId'])return apiBadRequestResponse(responseMessages['routingError']);const _0x438c12=await changeCurrentWorkspace(_0x4440d1['workspaceId']);return apiNoContentResponse(_0x438c12?{[httpHeaders['setCookie']]:serializeCookie(_0x438c12)}:void(0x25de+0x2545+-0x5*0xf07));}__name(workspacePostRoute,'workspacePostRoute');

export { workspaceGetRoute, workspacePostRoute };
