'use strict';

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _react3 = require('@storybook/react');

var _addonInfo = require('@storybook/addon-info');

var _addonKnobs = require('@storybook/addon-knobs');

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

var _2 = _interopRequireDefault(_);

var _TableofContents = require('./TableofContents.md');

var _TableofContents2 = _interopRequireDefault(_TableofContents);

var _index = require('../../../index');

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var getDecorativeLink = function getDecorativeLink(index) {
  var props = {
    info: (0, _addonKnobs.text)('TableofContents Child' + index + ': DecorativeLink info', 'Title info here', 'DecorativeLink' + index),
    text: (0, _addonKnobs.text)('TableofContents Child' + index + ': DecorativeLink text', 'Lorem ipsum dolor sit amet', 'DecorativeLink' + index),
    href: (0, _addonKnobs.text)('TableofContents Child' + index + ': DecorativeLink href', 'index.pdf', 'DecorativeLink' + index),
    showFileIcon: (0, _addonKnobs.boolean)('TableofContents Child' + index + ': DecorativeLink showFileIcon', true, 'DecorativeLink' + index)
  };
  return _react2.default.createElement(_index.DecorativeLink, props);
};

var getAccordionItem = function getAccordionItem(index) {
  var props = {
    title: 'Collapsible Header Two',
    info: 'Collapsible Header Two',
    icon: null,
    border: (0, _addonKnobs.boolean)('TableofContents Child' + index + ': AccordionItem border', false, 'AccordionItem' + index),
    secondary: (0, _addonKnobs.boolean)('TableofContents Child' + index + ': AccordionItem secondary', false, 'AccordionItem' + index),
    emphasize: (0, _addonKnobs.boolean)('TableofContents Child' + index + ': AccordionItem emphasize', true, 'AccordionItem' + index),
    // eslint-disable-next-line radix
    headerLevel: parseInt((0, _addonKnobs.select)('TableofContents Child' + index + ': AccordionItem headerLevel', {
      1: '1',
      2: '2',
      3: '3',
      4: '4',
      5: '5',
      6: '6'
    }, '2', 'AccordionItem' + index))
  };
  return _react2.default.createElement(
    _index.AccordionItem,
    props,
    getLink()
  );
};

var getLink = function getLink() {
  var sampleText = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Sample Link';

  var linkProps = {
    sampleText: sampleText,
    href: 'http://www.mass.gov/'
  };
  return _react2.default.createElement(_index.Link, linkProps);
};

var getColoredHeading = function getColoredHeading() {
  var props = {
    text: (0, _addonKnobs.text)('TableofContents ColoredHeading: text', 'Table of Contents', 'ColoredHeading'),
    // eslint-disable-next-line radix
    level: parseInt((0, _addonKnobs.select)('TableofContents ColoredHeading: level', {
      1: '1',
      2: '2',
      3: '3',
      4: '4',
      5: '5',
      6: '6'
    }, '2', 'ColoredHeading')),
    color: (0, _addonKnobs.select)('TableofContents ColoredHeading: color', {
      '': 'Grey (default)',
      green: 'Green',
      blue: 'Blue'
    }, 'green', 'ColoredHeading')
  };
  return _react2.default.createElement(_index.ColoredHeading, props);
};

var getSidebarHeading = function getSidebarHeading() {
  var levelOptions = {
    1: '1',
    2: '2',
    3: '3',
    4: '4',
    5: '5',
    6: '6'
  };
  var props = {
    title: (0, _addonKnobs.text)('TableofContents SidebarHeading: title', 'Key Agencies', 'SidebarHeading'),
    // eslint-disable-next-line radix
    level: parseInt((0, _addonKnobs.select)('TableofContents SidebarHeading: level', levelOptions, '2', 'SidebarHeading'))
  };
  return _react2.default.createElement(_index.SidebarHeading, props);
};

(0, _react3.storiesOf)('organisms/TableofContents', module).addDecorator(_addonInfo.withInfo).addDecorator((0, _addonKnobs.withKnobs)({ escapeHTML: false })).add('TableofContents with ColoredHeading', function () {
  var props = {
    heading: getColoredHeading()
  };
  return _react2.default.createElement(
    _2.default,
    props,
    getDecorativeLink(0),
    getAccordionItem('phone', 1),
    getAccordionItem('phone', 2),
    getDecorativeLink(3)
  );
}, { info: _TableofContents2.default }).add('TableofContents with SidebarHeading', function () {
  var props = {
    heading: getSidebarHeading()
  };
  return _react2.default.createElement(
    _2.default,
    props,
    getDecorativeLink(0),
    getAccordionItem('phone', 1),
    getAccordionItem('phone', 2),
    getDecorativeLink(3)
  );
}, { info: _TableofContents2.default });