import { R as ReferenceField } from './reference-field-a5b414d1.js';
import { B as BaseField } from './BaseField-0b01dc2c.js';
import './index-61dcd269.js';
import { M as MultipleChoiceField } from './index-4e451db4.js';
import { h } from './index-ecdfb761.js';
import { r as registerField } from './FieldGenerator-3ae403b2.js';
import { S as SingleChoiceField } from './index-23baeeef.js';
import { S as SubFormField } from './index-09efdc01.js';
import { T as TextField } from './index-150b6a59.js';
import { D as DateField } from './date-1bc489bd.js';

class NumberField extends BaseField {
  constructor(id, title, placeholder, description, step = 1, min = -Infinity, max = Infinity) {
    super(id, 'number');
    this.title = title;
    this.placeholder = placeholder;
    this.description = description;
    this.step = step;
    this.min = min;
    this.max = max;
  }
  showPreview() {
    this.preview = true;
    return this;
  }
  getDisplayValue(value) {
    return value;
  }
}
NumberField.type = 'number';

// component generator
const render$2 = (field, value, errors, disabled, onFieldChange, onFieldBlur) => h("dvn-field-input-number", { disabled: disabled, field: field, errors: errors, onChange: (e) => onFieldChange(field, Number(e.detail)), onBlur: () => onFieldBlur(field), value: value });
// register 'number' field for json form generations
registerField('number', render$2);

class RangeField extends BaseField {
  constructor(id, title, description, step = 1, min = 0, max = 5) {
    super(id, 'range');
    this.title = title;
    this.description = description;
    this.step = step;
    this.min = min;
    this.max = max;
  }
  showPreview() {
    this.preview = true;
    return this;
  }
  getDisplayValue(value) {
    return value;
  }
  setInputType(inputType) {
    this.inputType = inputType;
    return this;
  }
}
RangeField.type = 'range';

// component generator
const render$1 = (field, value, errors, disabled, onFieldChange, onFieldBlur) => h("dvn-field-input-range", { disabled: disabled, field: field, errors: errors, onChange: (e) => onFieldChange(field, Number(e.detail)), onBlur: () => onFieldBlur(field), value: value });
// register 'range' field for json form generations
registerField('range', render$1);

class SectionHeaderField extends BaseField {
  constructor(id, header, sectionDescription) {
    super(id, 'sectionHeader');
    this.id = id;
    this.header = header;
    this.sectionDescription = sectionDescription;
  }
}
SectionHeaderField.type = 'sectionHeader';

const render = (field, 
// @ts-ignore
value, 
// @ts-ignore
errors, disabled, onFieldChange, onFieldBlur) => h("dvn-field-input-section-header", { disabled: disabled, field: field, onChange: (v) => onFieldChange(field, v), onBlur: () => onFieldBlur(field) });
// register 'sectionHeader' key for json form generations
registerField('sectionHeader', render);

function generateFieldModelFromRawData(fieldData) {
  if (!fieldData) {
    return undefined;
  }
  switch (fieldData.type) {
    case DateField.type:
      return Object.assign(Object.create(DateField.prototype), fieldData);
    case MultipleChoiceField.type:
      return Object.assign(Object.create(MultipleChoiceField.prototype), fieldData);
    case NumberField.type:
      return Object.assign(Object.create(NumberField.prototype), fieldData);
    case RangeField.type:
      return Object.assign(Object.create(RangeField.prototype), fieldData);
    case SectionHeaderField.type:
      return Object.assign(Object.create(SectionHeaderField.prototype), fieldData);
    case SingleChoiceField.type:
      return Object.assign(Object.create(SingleChoiceField.prototype), fieldData);
    case SubFormField.type:
      return Object.assign(Object.create(SubFormField.prototype), fieldData);
    case TextField.type:
      return Object.assign(Object.create(TextField.prototype), fieldData);
    case ReferenceField.type:
      return Object.assign(Object.create(ReferenceField.prototype), fieldData);
    default:
      return Object.assign(Object.create(BaseField.prototype), fieldData);
  }
}

export { NumberField as N, RangeField as R, generateFieldModelFromRawData as g };
