const require_rolldown_runtime = require('../../../../../../../../_virtual/rolldown_runtime.js');
const require_ValidateBy$1 = require('../common/ValidateBy.js');

//#region ../../node_modules/.pnpm/class-validator@0.14.1/node_modules/class-validator/cjs/decorator/typechecker/IsEnum.js
var require_IsEnum = /* @__PURE__ */ require_rolldown_runtime.__commonJS({ "../../node_modules/.pnpm/class-validator@0.14.1/node_modules/class-validator/cjs/decorator/typechecker/IsEnum.js": ((exports) => {
	Object.defineProperty(exports, "__esModule", { value: true });
	exports.IsEnum = exports.isEnum = exports.IS_ENUM = void 0;
	const ValidateBy_1 = require_ValidateBy$1.require_ValidateBy();
	exports.IS_ENUM = "isEnum";
	/**
	* Checks if a given value is the member of the provided enum.
	*/
	function isEnum(value, entity) {
		return Object.keys(entity).map((k) => entity[k]).includes(value);
	}
	exports.isEnum = isEnum;
	/**
	* Returns the possible values from an enum (both simple number indexed and string indexed enums).
	*/
	function validEnumValues(entity) {
		return Object.entries(entity).filter(([key, value]) => isNaN(parseInt(key))).map(([key, value]) => value);
	}
	/**
	* Checks if a given value is the member of the provided enum.
	*/
	function IsEnum(entity, validationOptions) {
		return (0, ValidateBy_1.ValidateBy)({
			name: exports.IS_ENUM,
			constraints: [entity, validEnumValues(entity)],
			validator: {
				validate: (value, args) => isEnum(value, args === null || args === void 0 ? void 0 : args.constraints[0]),
				defaultMessage: (0, ValidateBy_1.buildMessage)((eachPrefix) => eachPrefix + "$property must be one of the following values: $constraint2", validationOptions)
			}
		}, validationOptions);
	}
	exports.IsEnum = IsEnum;
}) });

//#endregion
Object.defineProperty(exports, 'default', {
  enumerable: true,
  get: function () {
    return require_IsEnum();
  }
});