'use strict';
import { resourceNames } from '../../../../../../fd-toolbox/resources/resource-names.js';
import { getDbSchema } from '../../../../../db/db-schema.js';
import { and, eq } from 'drizzle-orm';
import { permissionTypes } from '../../../../../meta/core/resources/enums/permission-enums.js';
import { getResourcesByName, createResourceDirectlyInDb, updateResource } from '../../../../../meta/server/db/db.js';
import { getQuery } from '../../../../../meta/server/web/drizzle.js';
import { applyFilterToQuery, getTableColumn } from '../../../../../db/drizzle-queries.js';
import { createResource } from '../../../../../meta/server/resources/crud-resources.js';
import { schemaNames, columnNames } from '../../../../../db/constants/schema-names.js';

var __defProp=Object['defineProperty'],__name=(_0x58d6e3,_0x2b4603)=>__defProp(_0x58d6e3,'name',{'value':_0x2b4603,'configurable':!![]});async function getPermissions(){const _0x3fec34=await getResourcesByName(resourceNames['permission']);return _0x3fec34;}__name(getPermissions,'getPermissions');async function getPropertyPermissionsByResourcePropertyId(_0x1b3f9d){const _0x3e2760=getDbSchema(),_0x1b76c4=_0x3e2760[schemaNames['permissionSchema']],{query:_0x36081a}=await getQuery(_0x1b76c4);applyFilterToQuery(_0x36081a,and(eq(getTableColumn(_0x1b76c4,columnNames['type']),permissionTypes['property']),eq(getTableColumn(_0x1b76c4,columnNames['resourcePropertyId']),_0x1b3f9d)));const _0x390a3e=await _0x36081a;return _0x390a3e;}__name(getPropertyPermissionsByResourcePropertyId,'getPropertyPermissionsByResourcePropertyId');async function createPermission(_0x8d2c06){const _0x1c9d40=await createResource(_0x8d2c06,resourceNames['permission']);return _0x1c9d40;}__name(createPermission,'createPermission');async function createPermissionDirectlyInDb(_0x371bdf){return createResourceDirectlyInDb(_0x371bdf,resourceNames['permission']);}__name(createPermissionDirectlyInDb,'createPermissionDirectlyInDb');async function updatePermission(_0x443e00){const _0x2cf6eb=updateResource(_0x443e00,resourceNames['permission']);return _0x2cf6eb;}__name(updatePermission,'updatePermission');

export { createPermission, createPermissionDirectlyInDb, getPermissions, getPropertyPermissionsByResourcePropertyId, updatePermission };
