import { ReferenceKind } from '@mikro-orm/core';
import { validateSingleDecorator, getMetadataFromDecorator } from '../utils.js';
function createDecorator(options, serialized) {
  return function (target, propertyName) {
    const meta = getMetadataFromDecorator(target.constructor);
    validateSingleDecorator(meta, propertyName, ReferenceKind.SCALAR);
    const k = serialized ? 'serializedPrimaryKey' : 'primary';
    options[k] = true;
    meta.properties[propertyName] = {
      name: propertyName,
      kind: ReferenceKind.SCALAR,
      ...options,
    };
  };
}
/** Marks a property as the primary key of an entity (legacy TypeScript decorator). */
export function PrimaryKey(options = {}) {
  return createDecorator(options, false);
}
/** Marks a property as the serialized form of the primary key, e.g. for MongoDB ObjectId (legacy TypeScript decorator). */
export function SerializedPrimaryKey(options = {}) {
  return createDecorator(options, true);
}
