export type SignupBillingIntent = "solo" | "team" | "founder";

export const DEFAULT_SIGNUP_BILLING_INTENT: SignupBillingIntent = "solo";

export const SIGNUP_BILLING_INTENT_KEY = "signupBillingIntent";
export const PENDING_BILLING_CHECKOUT_PLAN_KEY = "pendingBillingCheckoutPlan";

export const isSignupBillingIntent = (value: string | null): value is SignupBillingIntent =>
  value === "solo" || value === "team" || value === "founder";

export const satisfiesPendingCheckoutPlan = (
  pendingPlan: SignupBillingIntent,
  activePlan: "solo" | "team" | "annual" | null
): boolean => {
  if (!activePlan) {
    return false;
  }

  if (pendingPlan === "founder") {
    return activePlan === "annual";
  }

  if (pendingPlan === "team") {
    return activePlan === "team" || activePlan === "annual";
  }

  return activePlan === "solo" || activePlan === "team" || activePlan === "annual";
};
