'use strict';

var describeParentCallSite = require('../frontend-plugin-api/src/routing/describeParentCallSite.cjs.js');

function createBackendFeatureLoader(options) {
  return {
    $$type: "@backstage/BackendFeature",
    version: "v1",
    featureType: "loader",
    description: `created at '${describeParentCallSite.describeParentCallSite()}'`,
    deps: options.deps,
    async loader(deps) {
      const it = await options.loader(deps);
      const result = new Array();
      for await (const item of it) {
        if ("$$type" in item && item.$$type === "@backstage/BackendFeature") {
          result.push(item);
        } else if ("default" in item) {
          result.push(item.default);
        } else {
          throw new Error(`Invalid item "${item}"`);
        }
      }
      return result;
    }
  };
}

exports.createBackendFeatureLoader = createBackendFeatureLoader;
//# sourceMappingURL=createBackendFeatureLoader.cjs.js.map
