'use strict';
import { workspaceProps } from '../../multitenancy/props/workspace-props.js';
import { getResource, getResourcesByFieldId, updateResource, deleteResource } from '../../../../meta/server/db/db.js';
import { resourceNames } from '../../../../../fd-toolbox/resources/resource-names.js';
import { getCurrentWorkspaceId } from '../../../../meta/server/providers/current-workspace-id-provider.js';
import { crudUpdate } from '../../../../meta/server/basic-crud/cruds.js';
import { getWorkerBotCrudUpdateConfig } from '../../../../meta/server/meta-core/crud/crud-update-config.js';
import { getUserById } from '../../users/user-db.js';
import { createResource } from '../../../../meta/server/resources/crud-resources.js';

var __defProp=Object['defineProperty'],__name=(_0x3fe109,_0x4a59d7)=>__defProp(_0x3fe109,'name',{'value':_0x4a59d7,'configurable':!![]});async function getAllUserWorkspaces(_0x5dcebd){const _0x54c1ae=await getUserById(_0x5dcebd),[_0x19fcf2,_0x5e0710]=await Promise['all']([getChildWorkspaces(_0x54c1ae['homeWorkspaceId']),getResource({'resourceName':resourceNames['workspace'],'id':_0x54c1ae['homeWorkspaceId']})]),_0x342cdd={'childWorkspaces':_0x19fcf2,'homeWorkspace':_0x5e0710,'currentWorkspaceId':_0x54c1ae['currentWorkspaceId']};return _0x342cdd;}__name(getAllUserWorkspaces,'getAllUserWorkspaces');async function getChildWorkspaces(_0x4a5c80){return getResourcesByFieldId(resourceNames['workspace'],workspaceProps['parentWorkspaceId'],_0x4a5c80);}__name(getChildWorkspaces,'getChildWorkspaces');function createWorkspace(_0x6316f0){return createResource(_0x6316f0,resourceNames['workspace']);}__name(createWorkspace,'createWorkspace');async function getCurrentWorkspace(){const _0x3757f3=await getCurrentWorkspaceId();return getResource({'resourceName':resourceNames['workspace'],'id':_0x3757f3});}__name(getCurrentWorkspace,'getCurrentWorkspace');async function setWorkspacePaymentSystemId(_0x408cfb){const _0x32932c=await getCurrentWorkspace(),_0x5d29c3={'id':_0x32932c['id'],'paymentSystemCustomerId':_0x408cfb};return crudUpdate({...getWorkerBotCrudUpdateConfig(_0x5d29c3,resourceNames['workspace'])});}__name(setWorkspacePaymentSystemId,'setWorkspacePaymentSystemId');function updateWorkspace(_0x200114){return updateResource(_0x200114,resourceNames['workspace']);}__name(updateWorkspace,'updateWorkspace');async function updateWorkspacePricingId(_0x3c653e,_0x352c7a){const _0x436929=await getResource({'resourceName':resourceNames['workspace'],'id':_0x3c653e});return updateWorkspace({..._0x436929,'pricingId':_0x352c7a});}__name(updateWorkspacePricingId,'updateWorkspacePricingId');async function updateWorkspaceIsSetupFinished(_0x1a79db,_0x37b23f){const _0x465be6=await getResource({'resourceName':resourceNames['workspace'],'id':_0x1a79db});return updateWorkspace({..._0x465be6,'isSetupFinished':_0x37b23f});}__name(updateWorkspaceIsSetupFinished,'updateWorkspaceIsSetupFinished');function deleteWorkspace(_0x2b3c77){return deleteResource(_0x2b3c77,resourceNames['workspace']);}__name(deleteWorkspace,'deleteWorkspace');

export { createWorkspace, deleteWorkspace, getAllUserWorkspaces, getChildWorkspaces, getCurrentWorkspace, setWorkspacePaymentSystemId, updateWorkspace, updateWorkspaceIsSetupFinished, updateWorkspacePricingId };
