import { ReferenceKind } from '@mikro-orm/core';
import { processDecoratorParameters, validateSingleDecorator, getMetadataFromDecorator } from '../utils.js';
export function OneToOne(entity, mappedByOrOptions, options = {}) {
  const mappedBy = typeof mappedByOrOptions === 'object' ? mappedByOrOptions.mappedBy : mappedByOrOptions;
  options = typeof mappedByOrOptions === 'object' ? { ...mappedByOrOptions, ...options } : options;
  return function (target, propertyName) {
    options = processDecoratorParameters({ entity, mappedBy, options });
    const meta = getMetadataFromDecorator(target.constructor);
    validateSingleDecorator(meta, propertyName, ReferenceKind.ONE_TO_ONE);
    const property = { name: propertyName, kind: ReferenceKind.ONE_TO_ONE };
    meta.properties[propertyName] = Object.assign(meta.properties[propertyName] ?? {}, property, options);
  };
}
