import {
  BILLING_REGISTRY,
  BILLING_MATRIX,
  BILLING_METADATA,
  PUBLIC_PLANS
} from "@nextsparkjs/registries/billing-registry";
function planHasFeature(planSlug, featureSlug) {
  var _a;
  const features = BILLING_MATRIX.features;
  return ((_a = features[featureSlug]) == null ? void 0 : _a[planSlug]) ?? false;
}
function getPlanLimit(planSlug, limitSlug) {
  var _a;
  const limits = BILLING_MATRIX.limits;
  return ((_a = limits[limitSlug]) == null ? void 0 : _a[planSlug]) ?? 0;
}
function getPlanFeatures(planSlug) {
  const features = BILLING_MATRIX.features;
  return Object.entries(features).filter(([, plans]) => plans[planSlug]).map(([featureSlug]) => featureSlug);
}
function getPlanLimits(planSlug) {
  const matrixLimits = BILLING_MATRIX.limits;
  const limits = {};
  for (const [limitSlug, plans] of Object.entries(matrixLimits)) {
    limits[limitSlug] = plans[planSlug] ?? 0;
  }
  return limits;
}
function getFullBillingMatrix() {
  return {
    plans: BILLING_REGISTRY.plans,
    features: BILLING_REGISTRY.features,
    limits: BILLING_REGISTRY.limits,
    matrix: BILLING_MATRIX,
    metadata: BILLING_METADATA
  };
}
function getPlan(slug) {
  return BILLING_REGISTRY.plans.find((p) => p.slug === slug);
}
function getPublicPlans() {
  return PUBLIC_PLANS;
}
export {
  BILLING_MATRIX,
  BILLING_METADATA,
  BILLING_REGISTRY,
  PUBLIC_PLANS,
  getFullBillingMatrix,
  getPlan,
  getPlanFeatures,
  getPlanLimit,
  getPlanLimits,
  getPublicPlans,
  planHasFeature
};
