import { r as registerInstance, c as createEvent, h } from './index-b6f10a81.js';

const DvnFieldInputRange = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.change = createEvent(this, "change", 7);
  }
  render() {
    const { disabled, errors, field, value } = this;
    const { preview } = field;
    const hasError = errors && errors.length > 0;
    const error = hasError ? errors[0] : undefined;
    const options = [];
    for (let i = field.min; i <= field.max; i += field.step) {
      options.push(i);
    }
    if (preview) {
      return (h("div", null, value, h("div", null, error)));
    }
    // const name = Math.random().toString(36).substr(2, 5);
    // render select
    if (field.inputType === 'select') {
      return (h("dvn-select", { disabled: disabled || field.disabled, feedback: hasError ? 'error' : undefined, leaned: true, value: value }, options.map(option => (h("dvn-select-option", { value: `${option}` }, option)))));
    }
    if (field.inputType === 'stars') {
      return (h("dvn-rating-stars", { disabled: disabled || field.disabled, options: options, value: Number(value) }));
    }
    return (h("dvn-radio-group", { disabled: disabled || field.disabled, inline: true, leaned: true, options: options.map(o => ({ label: `${o}`, value: `${o}` })), value: value }));
  }
};

export { DvnFieldInputRange as dvn_field_input_range };
