text: var newBlock = require('./new-block.js');
  
  module.exports = function lostAlign(css, settings) {
    css.walkDecls('lost-align', function alignDirectionFunction(decl) {
      var declArr = [];
      var alignDirection;
      var flexbox = settings.flexbox;
  
      declArr = decl.value.split(' ');
      alignDirection = declArr[0];
  
      if (declArr.indexOf('flex') !== -1) {
        flexbox = 'flex';
      }
  
      if (flexbox !== 'flex') {
        if (alignDirection === 'reset') {
          decl.cloneBefore({
            prop: 'position',
            value: 'static'
          });
          newBlock(
            decl,
            ' > *',
            ['position', 'top', 'right', 'bottom', 'left', 'transform'],
            ['static', 'auto', 'auto', 'auto', 'auto', 'translate(0, 0)']
          );
        } else {
          decl.cloneBefore({
            prop: 'position',
            value: 'relative'
          });
          if (alignDirection === 'horizontal') {
            newBlock(
              decl,
              ' > *',
              ['position', 'top', 'right', 'bottom', 'left', 'transform'],
              ['absolute', 'auto', 'auto', 'auto', '50%', 'translate(-50%, 0)']
            );
          } else if (alignDirection === 'vertical') {
            newBlock(
              decl,
              ' > *',
              ['position', 'top', 'right', 'bottom', 'left', 'transform'],
              ['absolute', '50%', 'auto', 'auto', 'auto', 'translate(0, -50%)']
            );
          } else if (alignDirection === 'top-left') {
            newBlock(
              decl,
              ' > *',
              ['position', 'top', 'right', 'bottom', 'left', 'transform'],
              ['absolute', '0', 'auto', 'auto', '0', 'translate(0, 0)']
            );
          } else if (
            alignDirection === 'top-center' ||
            alignDirection === 'top'
          ) {
            newBlock(
              decl,
              ' > *',
              ['position', 'top', 'right', 'bottom', 'left', 'transform'],
              ['absolute', '0', 'auto', 'auto', '50%', 'translate(-50%, 0)']
            );
          } else if (alignDirection === 'top-right') {
            newBlock(
              decl,
              ' > *',
              ['position', 'top', 'right', 'bottom', 'left', 'transform'],
              ['absolute', '0', '0', 'auto', 'auto', 'translate(0, 0)']
            );
          } else if (
            alignDirection === 'middle-left' ||
            alignDirection === 'left'
          ) {
            newBlock(
              decl,
              ' > *',
              ['position', 'top', 'right', 'bottom', 'left', 'transform'],
              ['absolute', '50%', 'auto', 'auto', '0', 'translate(0, -50%)']
            );
          } else if (
            alignDirection === 'middle-center' ||
            alignDirection === 'center'
          ) {
            newBlock(
              decl,
              ' > *',
              ['position', 'top', 'right', 'bottom', 'left', 'transform'],
              ['absolute', '50%', 'auto', 'auto', '50%', 'translate(-50%, -50%)']
            );
          } else if (
            alignDirection === 'middle-right' ||
            alignDirection === 'right'
          ) {
            newBlock(
              decl,
              ' > *',
              ['position', 'top', 'right', 'bottom', 'left', 'transform'],
              ['absolute', '50%', '0', 'auto', 'auto', 'translate(0, -50%)']
            );
          } else if (alignDirection === 'bottom-left') {
            newBlock(
              decl,
              ' > *',
              ['position', 'top', 'right', 'bottom', 'left', 'transform'],
              ['absolute', 'auto', 'auto', '0', '0', 'translate(0, 0)']
            );
          } else if (
            alignDirection === 'bottom-center' ||
            alignDirection === 'bottom'
          ) {
            newBlock(
              decl,
              ' > *',
              ['position', 'top', 'right', 'bottom', 'left', 'transform'],
              ['absolute', 'auto', 'auto', '0', '50%', 'translate(-50%, 0)']
            );
          } else if (alignDirection === 'bottom-right') {
            newBlock(
              decl,
              ' > *',
              ['position', 'top', 'right', 'bottom', 'left', 'transform'],
              ['absolute', 'auto', '0', '0', 'auto', 'translate(0, 0)']
            );
          } else {
            throw decl.error(
              `lost-align: direction '${alignDirection}' is unknown.`
            );
          }
        }
      } else if (alignDirection === 'reset') {
        decl.cloneBefore({
          prop: 'display',
          value: 'initial'
        });
        newBlock(
          decl,
          '',
          ['justify-content', 'align-items'],
          ['inherit', 'inherit']
        );
      } else {
        decl.cloneBefore({
          prop: 'display',
          value: 'flex'
        });
        if (alignDirection === 'horizontal') {
          newBlock(
            decl,
            '',
            ['justify-content', 'align-items'],
            ['center', 'inherit']
          );
        } else if (alignDirection === 'vertical') {
          newBlock(
            decl,
            '',
            ['justify-content', 'align-items'],
            ['inherit', 'center']
          );
        } else if (alignDirection === 'top-left') {
          newBlock(
            decl,
            '',
            ['justify-content', 'align-items'],
            ['flex-start', 'flex-start']
          );
        } else if (alignDirection === 'top-center' || alignDirection === 'top') {
          newBlock(
            decl,
            '',
            ['justify-content', 'align-items'],
            ['center', 'flex-start']
          );
        } else if (alignDirection === 'top-right') {
          newBlock(
            decl,
            '',
            ['justify-content', 'align-items'],
            ['flex-end', 'flex-start']
          );
        } else if (
          alignDirection === 'middle-left' ||
          alignDirection === 'left'
        ) {
          newBlock(
            decl,
            '',
            ['justify-content', 'align-items'],
            ['flex-start', 'center']
          );
        } else if (
          alignDirection === 'middle-center' ||
          alignDirection === 'center'
        ) {
          newBlock(
            decl,
            '',
            ['justify-content', 'align-items'],
            ['center', 'center']
          );
        } else if (
          alignDirection === 'middle-right' ||
          alignDirection === 'right'
        ) {
          newBlock(
            decl,
            '',
            ['justify-content', 'align-items'],
            ['flex-end', 'center']
          );
        } else if (alignDirection === 'bottom-left') {
          newBlock(
            decl,
            '',
            ['justify-content', 'align-items'],
            ['flex-start', 'flex-end']
          );
        } else if (
          alignDirection === 'bottom-center' ||
          alignDirection === 'bottom'
        ) {
          newBlock(
            decl,
            '',
            ['justify-content', 'align-items'],
            ['center', 'flex-end']
          );
        } else if (alignDirection === 'bottom-right') {
          newBlock(
            decl,
            '',
            ['justify-content', 'align-items'],
            ['flex-end', 'flex-end']
          );
        } else {
          throw decl.error(
            `lost-align: direction '${alignDirection}' is unknown.`
          );
        }
      }
      decl.remove();
    });
  };
  