define('@cardstack/codegen/index', ['exports', '@cardstack/plugin-utils/environment', 'fetch', '@cardstack/codegen/-ember-private-api'], function (exports, _environment, _fetch, _emberPrivateApi) {
  'use strict';

  Object.defineProperty(exports, "__esModule", {
    value: true
  });
  exports.default = Ember.Service.extend({
    config: Ember.computed(function () {
      return Ember.getOwner(this).resolveRegistration('config:environment');
    }),
    refreshCode: function refreshCode() {
      var _this = this;

      var branch = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _environment.defaultBranch;

      var modulePrefix = this.get('config.modulePrefix');
      return (0, _fetch.default)(_environment.hubURL + '/codegen/' + branch + '/' + modulePrefix).then(function (response) {
        return response.text();
      }).then(function (source) {
        return load(source, modulePrefix, Ember.getOwner(_this));
      });
    }
  });


  function load(source, modulePrefix, owner) {
    /* eslint no-unused-vars: 0 */
    function define(moduleName) {
      (0, _emberPrivateApi.unload)(moduleName, modulePrefix, owner);
      window.define.apply(this, arguments);
    }
    eval(source);
  }
});