'use strict';
import { eq } from 'drizzle-orm';
import { singleOrUndefinedWithWarning, singleOrUndefined } from '../../../../fd-toolbox/server/collections/single-funcs.js';
import { resourceNames } from '../../../../fd-toolbox/resources/resource-names.js';
import { getQuery } from '../../../meta/server/web/drizzle.js';
import { applyFilterToQuery, getTableColumn } from '../../../db/drizzle-queries.js';
import { createError } from '../../../../fd-toolbox/errors/errors.js';
import { toolboxErrorMessages } from '../../../../fd-toolbox/constants/toolbox-error-messages-constants.js';
import { createResource } from '../../../meta/server/resources/crud-resources.js';
import { createResourceDirectlyInDb, execQuery } from '../../../meta/server/db/db.js';
import { getDbSchema } from '../../../db/db-schema.js';
import { schemaNames, columnNames } from '../../../db/constants/schema-names.js';

var __defProp=Object['defineProperty'],__name=(_0x341f36,_0x30d356)=>__defProp(_0x341f36,'name',{'value':_0x30d356,'configurable':!![]});async function getUserSettingByUserId(_0x380ff5){const _0x7081b7=singleOrUndefinedWithWarning(await getUserSettingsByUserId(_0x380ff5));if(!_0x7081b7)throw createError(toolboxErrorMessages['tableForResourceNotFound']['replace']('{0}',resourceNames['userSetting']));return _0x7081b7;}__name(getUserSettingByUserId,'getUserSettingByUserId');async function tryGetUserSettingByUserId(_0x5bf6e4){return singleOrUndefined(await getUserSettingsByUserId(_0x5bf6e4));}__name(tryGetUserSettingByUserId,'tryGetUserSettingByUserId');async function createUserSetting(_0x55dc01){return createResource(_0x55dc01,resourceNames['userSetting']);}__name(createUserSetting,'createUserSetting');async function createUserSettingDirectlyInDb(_0x2625fa){return createResourceDirectlyInDb(_0x2625fa,resourceNames['userSetting']);}__name(createUserSettingDirectlyInDb,'createUserSettingDirectlyInDb');async function getUserSettingsByUserId(_0x5b20d9){const _0x3ad415=getDbSchema(),_0x4a855b=_0x3ad415[schemaNames['userSettingSchema']],{query:_0x145e7d}=await getQuery(_0x4a855b);return applyFilterToQuery(_0x145e7d,eq(getTableColumn(_0x4a855b,columnNames['userId']),_0x5b20d9)),execQuery(_0x145e7d);}__name(getUserSettingsByUserId,'getUserSettingsByUserId');

export { createUserSetting, createUserSettingDirectlyInDb, getUserSettingByUserId, tryGetUserSettingByUserId };
