'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const index = require('./index-a1121663.js');

const DvnFieldInputRange = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
    this.change = index.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 (index.h("div", null, value, index.h("div", null, error)));
    }
    // const name = Math.random().toString(36).substr(2, 5);
    // render select
    if (field.inputType === 'select') {
      return (index.h("dvn-select", { disabled: disabled || field.disabled, feedback: hasError ? 'error' : undefined, leaned: true, value: value }, options.map(option => (index.h("dvn-select-option", { value: `${option}` }, option)))));
    }
    if (field.inputType === 'stars') {
      return (index.h("dvn-rating-stars", { disabled: disabled || field.disabled, options: options, value: Number(value) }));
    }
    return (index.h("dvn-radio-group", { disabled: disabled || field.disabled, inline: true, leaned: true, options: options.map(o => ({ label: `${o}`, value: `${o}` })), value: value }));
  }
};

exports.dvn_field_input_range = DvnFieldInputRange;
