import { UserInterface } from "@sankhyalabs/core";
export const buildFieldMetadata = (descriptor, config) => {
  var _a, _b;
  let { name, label, group } = Object.assign({}, config);
  let { readOnly, required } = Object.assign({}, config);
  let props;
  let userInterface;
  if (descriptor) {
    label = label || descriptor.label;
    name = name || descriptor.name;
    required = (_a = descriptor.required) !== null && _a !== void 0 ? _a : config === null || config === void 0 ? void 0 : config.required;
    readOnly = (_b = descriptor.readOnly) !== null && _b !== void 0 ? _b : config === null || config === void 0 ? void 0 : config.readOnly;
    props = descriptor.properties;
    userInterface = descriptor.userInterface;
  }
  return {
    name, label, group,
    readOnly, required,
    props,
    userInterface: userInterface || UserInterface.SHORTTEXT,
  };
};
