"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = createRelationSelector;

var _reselect = require("reselect");

var _navigation = _interopRequireDefault(require("./navigation"));

var _find = _interopRequireDefault(require("../utils/find"));

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

function createRelationSelector(key, selectItem) {
  return (0, _reselect.createSelector)(_navigation.default, selectItem, (patterns, item) => {
    if (!item) {
      return [];
    }

    return (item[key] || []).map(id => (0, _find.default)(patterns, `pattern/${id}.html`, {
      type: "pattern"
    })).filter(Boolean);
  });
}
//# sourceMappingURL=relation.js.map