import {TypedNumericParam} from "./_Numeric";
import {ParamType as ParamType2} from "../poly/ParamType";
import {CoreString} from "../../core/String";
import {CoreType} from "../../core/Type";
export class BooleanParam extends TypedNumericParam {
  static type() {
    return ParamType2.BOOLEAN;
  }
  get default_value_serialized() {
    if (CoreType.isString(this.default_value)) {
      return this.default_value;
    } else {
      return this.convert(this.default_value) || false;
    }
  }
  get raw_input_serialized() {
    return this._raw_input;
  }
  get value_serialized() {
    return this.value;
  }
  _copy_value(param) {
    this.set(param.value);
  }
  static are_raw_input_equal(raw_input1, raw_input2) {
    return raw_input1 == raw_input2;
  }
  static are_values_equal(val1, val2) {
    return val1 == val2;
  }
  convert(raw_val) {
    if (CoreType.isBoolean(raw_val)) {
      return raw_val;
    } else {
      if (CoreType.isNumber(raw_val)) {
        return raw_val >= 1;
      } else {
        if (CoreType.isString(raw_val)) {
          if (CoreString.isBoolean(raw_val)) {
            return CoreString.toBoolean(raw_val);
          } else {
            if (CoreString.isNumber(raw_val)) {
              const parsed = parseFloat(raw_val);
              return parsed >= 1;
            }
          }
        }
      }
    }
    return null;
  }
}
