"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;

var _react = _interopRequireDefault(require("react"));

var _addons = _interopRequireDefault(require("@storybook/addons"));

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

var withCode = function withCode(code, type) {
  var storyFn = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;

  var emitAddCode = function emitAddCode(_ref) {
    var kind = _ref.kind,
        story = _ref.story;

    _addons["default"].getChannel().emit("soft/code/add_".concat(type), {
      code: code,
      type: type
    });
  };

  return function (storyFn, _ref2) {
    var kind = _ref2.kind,
        story = _ref2.story;
    emitAddCode({
      kind: kind,
      story: story
    });
    return storyFn();
  };
};

var _default = withCode;
exports["default"] = _default;