import { importShared } from './__federation_fn_import-TbMgVVsT.js';
import { a as createBillingPartialDefinition, c as createStripePluginDefinitionSchema } from './plugin-definition-DC7rEk-r.js';

const {authModelsSpec,createPluginModelSyncChecker,FeatureUtils,PluginUtils} = await importShared('@baseplate-dev/project-builder-lib');
function createStripeSchemaChecker(pluginKey) {
  return createPluginModelSyncChecker({
    pluginKey,
    pluginLabel: "Stripe",
    buildPartialDef: (container) => {
      const stripeConfig = PluginUtils.configByKey(
        container.definition,
        pluginKey
      );
      if (!stripeConfig?.billing.enabled || !stripeConfig.billing.featureRef) {
        return void 0;
      }
      try {
        const authModels = container.pluginStore.use(authModelsSpec);
        const userModelName = authModels.getAuthModelsOrThrow(
          container.definition
        ).user;
        const featureName = FeatureUtils.getFeaturePathByIdOrThrow(
          container.definition,
          stripeConfig.billing.featureRef
        );
        return createBillingPartialDefinition(featureName, userModelName);
      } catch {
        return void 0;
      }
    }
  });
}

const {createPluginModule,definitionIssueCheckerSpec,pluginConfigSpec} = await importShared('@baseplate-dev/project-builder-lib');
const common = createPluginModule({
  name: "common",
  dependencies: {
    pluginConfig: pluginConfigSpec,
    issueCheckers: definitionIssueCheckerSpec
  },
  initialize: ({ pluginConfig, issueCheckers }, { pluginKey }) => {
    pluginConfig.schemas.set(pluginKey, createStripePluginDefinitionSchema);
    issueCheckers.checkers.set(pluginKey, createStripeSchemaChecker(pluginKey));
  }
});

export { common as default };
//# sourceMappingURL=__federation_expose_stripeCoreCommon-j2sKZqn1.js.map
