import { h } from './index-ecdfb761.js';

const fieldTypeMap = new Map();
function registerField(fieldType, inputGenerator) {
  fieldTypeMap.set(fieldType, inputGenerator);
}
function generateField(field, value, errors = [], disabled, onFieldChange, onFieldBlur) {
  if (field.render) {
    return field.render(field, value, errors, disabled, onFieldChange, onFieldBlur);
  }
  if (field.customViewTag) {
    const Tag = field.customViewTag;
    return h(Tag, { disabled: disabled, field: field, errors: errors, onChange: onFieldChange, onBlur: onFieldBlur, value: value });
  }
  const generator = fieldTypeMap.get(field.type);
  if (generator) {
    return generator(field, value, errors, disabled, onFieldChange, onFieldBlur);
  }
  return null;
}

export { generateField as g, registerField as r };
