import { BindingError, QueryLanguage } from "@contember/binding";
const createEntityConnectorFactory = (env, ...baseEntity) => {
  if (!baseEntity[baseEntity.length - 1]) {
    throw new BindingError('Cannot use "fileSelectionComponent" when "baseEntity" prop is not set. For more information, please consult the documentation.');
  }
  const path = baseEntity.filter((it) => it !== void 0).map((it) => QueryLanguage.desugarRelativeSingleEntity(it, env)).flatMap((it) => it.hasOneRelationPath);
  return (selected) => {
    const connector = (parent) => {
      const parentEntity = parent.getRelativeSingleEntity({
        hasOneRelationPath: path.slice(0, -1)
      });
      parentEntity.connectEntityAtField(path[path.length - 1].field, selected);
    };
    connector.entity = selected;
    return connector;
  };
};
export { createEntityConnectorFactory };
//# sourceMappingURL=createEntityConnector.js.map
