import { connect } from 'react-redux';

var checkPlan = function checkPlan(state) {
  return function (asset) {
    return !(state.plan === 'free' && asset.plan === 'paid');
  };
};

export default function withAsset(options) {
  return function (component) {
    return connect(function (_ref) {
      var asset = _ref.asset;
      return {
        asset: asset,
        canUseAssetButton: checkPlan(asset)
      };
    }, null, null, {
      areStatePropsEqual: function areStatePropsEqual(nextStateProps, prevStateProps) {
        // canUseAssetButton() は常に新しい参照が作られるので, それ以外で比較する
        return nextStateProps.asset === prevStateProps.asset;
      }
    })(component);
  };
}