text: import { __rest } from "tslib";
  import { namespaced } from './namespaced';
  import { processState } from '../utils';
  export function lazy(configurations) {
      let app;
      return {
          onInitialize(_, value) {
              app = value;
          },
          effects: {
              lazy: {
                  loadConfig(config) {
                      return app.actions.lazy.loadConfig(config);
                  },
              },
          },
          actions: {
              lazy: {
                  loadConfig(_a, key) {
                      var { state } = _a, rest = __rest(_a, ["state"]);
                      const configToLoad = configurations[key];
                      return configToLoad().then((loadedConfig) => {
                          const newConfig = namespaced({
                              [key]: loadedConfig,
                          });
                          if (newConfig.state && newConfig.state[key])
                              state[key] = processState(newConfig.state[key]);
                          if (newConfig.effects && newConfig.effects[key])
                              app.effects[key] = newConfig.effects[key];
                          if (newConfig.actions && newConfig.actions[key])
                              app.actions[key] = app.getActions(newConfig.actions[key]);
                          if (newConfig.onInitialize)
                              newConfig.onInitialize(Object.assign({ state }, rest), app);
                      });
                  },
              },
          },
      };
  }
  //# sourceMappingURL=lazy.js.map