text: 'use strict';
  
  var _slicedToArray2 = require('babel-runtime/helpers/slicedToArray');
  
  var _slicedToArray3 = _interopRequireDefault(_slicedToArray2);
  
  var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
  
  var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
  
  var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
  
  var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
  
  var _createClass2 = require('babel-runtime/helpers/createClass');
  
  var _createClass3 = _interopRequireDefault(_createClass2);
  
  var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
  
  var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
  
  var _inherits2 = require('babel-runtime/helpers/inherits');
  
  var _inherits3 = _interopRequireDefault(_inherits2);
  
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  
  var _require = require('../../errors'),
      CramUnimplementedError = _require.CramUnimplementedError,
      CramMalformedError = _require.CramMalformedError,
      CramBufferOverrunError = _require.CramBufferOverrunError;
  
  var CramCodec = require('./_base');
  
  var _require2 = require('../util'),
      parseItf8 = _require2.parseItf8;
  
  var ExternalCodec = function (_CramCodec) {
    (0, _inherits3.default)(ExternalCodec, _CramCodec);
  
    function ExternalCodec() {
      var parameters = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      var dataType = arguments[1];
      (0, _classCallCheck3.default)(this, ExternalCodec);
  
      var _this = (0, _possibleConstructorReturn3.default)(this, (ExternalCodec.__proto__ || (0, _getPrototypeOf2.default)(ExternalCodec)).call(this, parameters, dataType));
  
      if (_this.dataType === 'int') {
        _this._decodeData = _this._decodeInt;
      } else if (_this.dataType === 'byte') {
        _this._decodeData = _this._decodeByte;
      } else {
        throw new CramUnimplementedError(_this.dataType + ' decoding not yet implemented by EXTERNAL codec');
      }
      return _this;
    }
  
    (0, _createClass3.default)(ExternalCodec, [{
      key: 'decode',
      value: function decode(slice, coreDataBlock, blocksByContentId, cursors) {
        var blockContentId = this.parameters.blockContentId;
  
        var contentBlock = blocksByContentId[blockContentId];
        if (!contentBlock) throw new CramMalformedError('no block found with content ID ' + blockContentId);
        var cursor = cursors.externalBlocks.getCursor(blockContentId);
        return this._decodeData(contentBlock, cursor);
      }
    }, {
      key: '_decodeInt',
      value: function _decodeInt(contentBlock, cursor) {
        var _parseItf = parseItf8(contentBlock.content, cursor.bytePosition),
            _parseItf2 = (0, _slicedToArray3.default)(_parseItf, 2),
            result = _parseItf2[0],
            bytesRead = _parseItf2[1];
  
        cursor.bytePosition += bytesRead;
        return result;
      }
    }, {
      key: '_decodeByte',
      value: function _decodeByte(contentBlock, cursor) {
        if (cursor.bytePosition >= contentBlock.content.length) throw new CramBufferOverrunError('attempted to read beyond end of block. this file seems truncated.');
        var result = contentBlock.content[cursor.bytePosition];
        cursor.bytePosition += 1;
        return result;
      }
    }]);
    return ExternalCodec;
  }(CramCodec);
  
  module.exports = ExternalCodec;