'use strict';

var utils = require('./utils');

/**
 * Create a new `Choice` to create a normalized choice object from the given input.
 * @param {String|Object} `val` Choice value. If an object is passed, it should contains at least one of `value` or `name` property.
 * @api public
 */

function Choice(choice) {
  this.enabled = false;

  if (typeof choice === 'string') {
    choice = { name: choice };
  }

  if (!utils.isObject(choice)) {
    throw new TypeError('expected choice to be a string or object');
  }

  if (choice.type === 'separator' || choice.isSeparator) {
    choice.isSeparator = true;
    return choice;
  }

  utils.extend(this, choice);
  this.name = choice.name || choice.value;
  this.value = choice.hasOwnProperty('value') ? choice.value : choice.name;
  this.short = choice.short || choice.name;

  if (typeof choice.disabled === 'function') {
    this.disabled = !!choice.disabled.call(this);
  } else {
    this.disabled = !!choice.disabled;
  }
};

/**
 * Expose Choice
 */

module.exports = Choice;

@@ -8,16 +8,44 @@
 rict';%0A%0A
+var util = require('util');%0A
 var util
@@ -68,16 +68,16 @@
 tils');%0A
-
 %0A/**%0A * 
@@ -336,36 +336,20 @@
 oice
-) %7B%0A  this.enabled = false;%0A
+, answers) %7B
 %0A  i
@@ -638,16 +638,183 @@
 e;%0A  %7D%0A%0A
+  if (choice.isChoice %7C%7C choice instanceof Choice) %7B%0A    return choice;%0A  %7D%0A%0A  utils.define(this, 'isChoice', true);%0A  this.disabled = false;%0A  this.checked = false;%0A%0A
   utils.
@@ -1042,24 +1042,24 @@
 unction') %7B%0A
-
     this.dis
@@ -1093,16 +1093,25 @@
 all(this
+, answers
 );%0A  %7D e

expose `answers` to choice