'use strict';
import { notInArray, inArray, lte, lt, gte, gt, ne, eq } from 'drizzle-orm';
import { oDataComparisonTypes } from '../../../../../fd-toolbox/odata/odata-enums.js';
import { error } from 'console';
import { dbLike, dbExtractDate } from '../../../../db/db-connection.js';
import { toolboxErrorMessages } from '../../../../../fd-toolbox/constants/toolbox-error-messages-constants.js';
import { convertFromPascalToCamelCase } from '../../../../../fd-toolbox/strings/casing-converter.js';
import { createError } from '../../../../../fd-toolbox/errors/errors.js';
import { isArray } from '../../../../../fd-toolbox/types/ensure-type.js';
import { wordPluralSuffixes } from '../../../../../base-repo/constants/strings-constants.js';
import { first } from '../../../../../fd-toolbox/server/collections/single-funcs.js';

var __defProp=Object['defineProperty'],__name=(_0xce8080,_0x1e2258)=>__defProp(_0xce8080,'name',{'value':_0x1e2258,'configurable':!![]});function getComparisonTypeFromOperation(_0x37500e){switch(_0x37500e){case oDataComparisonTypes['equal']:return (_0x26ea88,_0x2f8ffe)=>compareDateOrDefault(_0x26ea88,_0x2f8ffe);case oDataComparisonTypes['notEqual']:return (_0xa9b51e,_0x4481ed)=>ne(_0xa9b51e,_0x4481ed);case oDataComparisonTypes['greaterThan']:return (_0x12693b,_0x12e2d6)=>gt(_0x12693b,_0x12e2d6);case oDataComparisonTypes['greaterThanOrEqual']:return (_0x245e87,_0x291241)=>gte(_0x245e87,_0x291241);case oDataComparisonTypes['lessThan']:return (_0x5cae8d,_0xc1f6c7)=>lt(_0x5cae8d,_0xc1f6c7);case oDataComparisonTypes['lessThanOrEqual']:return (_0xf81346,_0x302cfb)=>lte(_0xf81346,_0x302cfb);case oDataComparisonTypes['in']:return (_0x132a75,_0x42035d)=>{if(!isArray(_0x42035d))throw createError(toolboxErrorMessages['valueIsNotArray']);return inArray(_0x132a75,_0x42035d);};case oDataComparisonTypes['nin']:return (_0x11b9e3,_0x38b9c4)=>{if(!isArray(_0x38b9c4))throw createError(toolboxErrorMessages['valueIsNotArray']);return notInArray(_0x11b9e3,_0x38b9c4);};case oDataComparisonTypes['startsWith']:return (_0x1b7d4d,_0x599377)=>dbLike(_0x1b7d4d,_0x599377+'%');case oDataComparisonTypes['includes']:return (_0x2b98e,_0x46735b)=>dbLike(_0x2b98e,'%'+_0x46735b+'%');default:throw createError(toolboxErrorMessages['odataUnsupportedType']['replace']('{0}',_0x37500e['toString']()));}}__name(getComparisonTypeFromOperation,'getComparisonTypeFromOperation');function isNullOrUndefinedWithLogging(_0x484fac,_0x90debe){if(!_0x90debe)return error(toolboxErrorMessages['objectWasNull']['replace']('{0}',_0x484fac)),!![];return ![];}__name(isNullOrUndefinedWithLogging,'isNullOrUndefinedWithLogging');function convertPropertyNameToTableName(_0x2a4586){return ''+convertFromPascalToCamelCase(_0x2a4586)+(_0x2a4586['endsWith'](wordPluralSuffixes['s'])?'':wordPluralSuffixes['s']);}__name(convertPropertyNameToTableName,'convertPropertyNameToTableName');function compareDateOrDefault(_0x3967fd,_0x783690){const _0x1a8338='T';let _0x4fbcd4;if(_0x783690 instanceof Date)_0x4fbcd4=first(_0x783690['toISOString']()['split'](_0x1a8338));else typeof _0x783690==='string'&&_0x783690['includes'](_0x1a8338)?_0x4fbcd4=first(_0x783690['split'](_0x1a8338)):_0x4fbcd4=_0x783690;const _0x3b6908=dbExtractDate(_0x3967fd);if(_0x4fbcd4 instanceof Date||typeof _0x4fbcd4==='string'&&_0x4fbcd4['length']===0x1c98+-0x25c0+0x932)return eq(_0x3b6908,_0x4fbcd4);return eq(_0x3967fd,_0x783690);}__name(compareDateOrDefault,'compareDateOrDefault');

export { compareDateOrDefault, convertPropertyNameToTableName, getComparisonTypeFromOperation, isNullOrUndefinedWithLogging };
