import { j as StateBackgroundColorFormatter, k as isSpacingTokenType, l as isBorderRadiusTokenType, m as isBorderColorTokenType, n as isBackgroundColorTokenType, o as isTextColorTokenType, p as isBreakpointsTokenType, q as isShadowsTokenType, h as Spacing, r as isBorderStyleType, B as BorderRadius, C as Colors, f as Shadows, s as isTypographyTokenType } from './type-guard-5e7bf13e.js';
import { B as Breakpoints } from './breakpoints-d9faf11c.js';
import { L as LogUtility } from './global-slimmer-registry-0a7aa308.js';
import { R as ResponsiveFormatFacade } from './responsive-format-facade-d32134a3.js';
import { a as TypographyKeys } from './typography-396de03f.js';
import { S as StateBorderFormatter, a as StateShadowFormatter, b as StateBorderColorFormatter } from './state-border-formatter-7828a6a8.js';
import { B as BorderStyle } from './ui-93922c59.js';

/**
 * The `StateFormatFacade` class in TypeScript provides a method to format different types of
 * state variants based on a specified flag.
 */
class StateFormatFacade {
  /**
   * The function `format` takes in an input and a flag, then formats the input based on the flag
   * provided.
   *
   * @param {StateVariantType} input - The `input` parameter in the `format` function is of type
   * `StateVariantType<ManagedStateScopeInput[Flag], State>`. This means that it expects an input value
   * that corresponds to the specified flag and state. The `Flag` type is a key of
   * `ManagedStateScopeInput
   * @param {keyof ManagedStateScopeInput} flag - The `flag` parameter in the `format` function is a key of the
   * `ManagedStateScopeInput` type. It is used to determine which formatting logic to apply based on the
   * specific flag provided. The function then switches on the flag value to select the appropriate
   * formatting logic for that particular flag.
   * @returns {string} The `format` function takes in an input of type
   * `StateVariantType<ManagedStateScopeInput[Flag], State>` and a flag of type `Flag`. It then switches
   * on the flag value and returns a formatted string based on the flag value. The return value depends
   * on the flag value:
   */
  format(input, flag) {
    switch (flag) {
      case 'backgroundColor':
        return StateBackgroundColorFormatter.format(input);
      case 'borderColor':
        return StateBorderColorFormatter.format(input);
      case 'shadow':
        return StateShadowFormatter.format(input);
      case 'border':
        return StateBorderFormatter.format(input);
      default:
        throw new Error(`Invalid flag ${flag} passed into StateFormatFacade`);
    }
  }
}
const StateFormatFacade$1 = new StateFormatFacade();

/**
 * It logs a warning message to the console.
 *
 * @param {string} tokenType - The name of the token type.
 * @param {unknown} value - The value that was passed into the token.
 * @param {unknown} availableOptions - The available options for the token type.
 */
function logInvalidValueMessage(tokenType, value, availableOptions) {
  LogUtility.warn(`The ${tokenType} value ${value} is invalid, it must be a value of: `, availableOptions);
}
/**
 * Given a token and an array of modes, return a string with the token formatted with the appropriate mode
 *
 * @param {string} token - The name of the token.
 * @param {TokenMode[]} modes - TokenMode[]
 * @returns {string} The formatted token.
 */
function formatTokenWithModes(token, modes) {
  let formattedToken = '';
  if (modes.includes('dark')) {
    formattedToken += ` dark:v-dark-${token}`;
  }
  return formattedToken;
}
/**
 * If the token is a valid spacing token, return the CSS class string. Otherwise, log an error message
 *
 * @param {unknown} token - The value that was passed into the function.
 * @returns {Nullable<string>} The the CSS class string of the padding token.
 */
function formatAndValidPadding(token) {
  if (isSpacingTokenType(token)) {
    return `v-p-${token}`;
  }
  else {
    logInvalidValueMessage('padding', token, Object.keys(Spacing));
  }
}
/**
 * The function `formatAndValidBorderStyle` formats a border style token and returns a string if it is
 * a valid border style type, otherwise it logs an invalid value message.
 *
 * @param {unknown} token - The `token` parameter is a value that represents a border style type.
 * @returns {Nullable<string>} The function `formatAndValidBorderStyle` returns a string that is formatted as
 * `v-border-` if the `token` parameter is of a valid border style type. If the `token` is not
 * a valid border style type, it logs an invalid value message and does not return anything (implicitly
 * returns `undefined`).
 */
function formatAndValidBorderStyle(token) {
  if (isBorderStyleType(token)) {
    return `v-border-${token}`;
  }
  else {
    logInvalidValueMessage('border-style', token, BorderStyle);
  }
}
/**
 * If the token is a valid border radius, return a string with the token prefixed with `v-rounded-`. Otherwise, log an
 * error message
 *
 * @param {unknown} token - The value passed in by the user.
 * @returns {Nullable<string>} The the CSS class string of the border radius token.
 */
function formatAndValidBorderRadius(token) {
  if (isBorderRadiusTokenType(token)) {
    return `v-${token}`;
  }
  else {
    logInvalidValueMessage('border-radius', token, Object.keys(BorderRadius));
  }
}
/**
 * If the token is a valid border color, return CSS class string of the border color. Otherwise, log an error message
 *
 * @param {unknown} token - The value passed in by the user.
 * @returns {Nullable<string>}  return the CSS class string of the border color
 */
function formatAndValidBorderColor(token) {
  if (isBorderColorTokenType(token)) {
    return `v-${token}`;
  }
  else {
    logInvalidValueMessage('border-color', token, Colors.filter(() => /^border-color-.+$/.test));
  }
}
/**
 * If the token is a valid background color, return it with the v- prefix. Otherwise, log an error
 *
 * @param {unknown} token - The value of the token.
 * @param {TokenMode[]} withModes - TokenMode[] = []
 * @returns {Nullable<string>} CSS class string for the background color token with modes supported.
 */
function formatAndValidBackgroundColor(token, withModes = []) {
  if (isBackgroundColorTokenType(token)) {
    return `v-${token}` + formatTokenWithModes(token, withModes);
  }
  else {
    logInvalidValueMessage('background-color', token, Colors.filter(() => /^bg-.+$/.test));
  }
}
/**
 * If the token is a valid text color, return the token prefixed with `v-` and formatted with the given modes. Otherwise,
 * log an error
 *
 * @param {unknown} token - The token to format.
 * @param {TokenMode[]} withModes - TokenMode[] = []
 * @returns {Nullable<string>} A CSS class string that is either a valid color or a valid color with modes.
 */
function formatAndValidTextColor(token, withModes = []) {
  if (isTextColorTokenType(token)) {
    return `v-${token}` + formatTokenWithModes(token, withModes);
  }
  else {
    logInvalidValueMessage('text-color', token, Colors.filter(() => /^text-.+$/.test));
  }
}
/**
 * If the token is a valid breakpoint, return CSS class string for the flex breakpoint. Otherwise, log an error
 *
 * @param {unknown} token - The value of the breakpoint.
 * @returns {Nullable<string>} CSS class string for the flex breakpoint.
 */
function formatAndValidFlexBreakpoint(token) {
  if (isBreakpointsTokenType(token)) {
    return `vega-flex-${token}`;
  }
  else {
    logInvalidValueMessage('breakpoint', token, Object.keys(Breakpoints));
  }
}
/**
 * If the token is a breakpoint, return the breakpoint value. Otherwise, log an error and return 0
 *
 * @param {unknown} token - The value passed in by the user.
 * @returns {Nullable<number>} value of the breakpoint.
 */
function formatAndValidBreakpointSize(token) {
  if (isBreakpointsTokenType(token)) {
    return Breakpoints[token];
  }
  else {
    logInvalidValueMessage('breakpoint', token, Object.keys(Breakpoints));
  }
}
/**
 * If the token is a valid spacing token, return a string with the token name prefixed with `v-gap-`. Otherwise, log an
 * error message
 *
 * @param {unknown} token - The value passed in by the user.
 * @returns {Nullable<string>} CSS class string for the given gap token.
 */
function formatAndValidGap(token) {
  if (isSpacingTokenType(token)) {
    return `v-gap-${token}`;
  }
  else {
    logInvalidValueMessage('gap', token, Object.keys(Spacing));
  }
}
/**
 * If the token is a valid shadows token type, return the token with the prefix "v-". Otherwise, log an error message
 *
 * @param {string} token - The token to format.
 * @param {TokenMode[]} withModes - TokenMode[] = []
 * @returns {Nullable<string>} CSS class string of the shadow token with modes supported
 */
function formatAndValidShadow(token, withModes = []) {
  if (isShadowsTokenType(token)) {
    return `v-${token}` + formatTokenWithModes(token, withModes);
  }
  else {
    logInvalidValueMessage('shadows', token, Shadows);
  }
}
/**
 * It takes a token and a flag, and returns a string
 *
 * @typedef Flag key of ManagedResponsiveScopeInput
 * @param {ResponsiveType<ManagedResponsiveScopeInput[Flag]>} token - The token to format.
 * @param {Flag} flag - The flag that the token is being formatted for.
 * @returns {Nullable<ManagedResponsiveScopeOutput[Flag]>} A nullable string
 */
function formatAndValidResponsiveToken(token, flag) {
  if (token !== null && token !== undefined) {
    return ResponsiveFormatFacade.format(token, flag);
  }
}
/**
 * The function `formatAndValidTypographyToken` formats a typography token by adding a prefix and checks if it is a valid typography token.
 *
 * @param {string} token - The `token` parameter is a string that represents a typography token.
 * @returns {Nullable<string>} a string value.
 */
function formatAndValidTypographyToken(token) {
  if (isTypographyTokenType(token)) {
    return `v-${token}`;
  }
  else {
    logInvalidValueMessage('font', token, TypographyKeys);
  }
}
/**
 * The function `formatAndValidStateToken` formats and validates a state token based on a specified flag.
 *
 * @param {StateVariantType} token - The `token` parameter is a value that represents a state variant for a specific flag
 * in a managed state scope input.
 * @param {Flag} flag - The `flag` parameter is a key of the `ManagedStateScopeInput` type.
 * @returns {Nullable<string>} a formatted and validated state token as a string, or `null` if the input token is `null`
 * or `undefined`.
 */
function formatAndValidStateToken(token, flag) {
  if (token !== null && token !== undefined) {
    return StateFormatFacade$1.format(token, flag);
  }
}

export { formatAndValidGap as a, formatAndValidShadow as b, formatAndValidBreakpointSize as c, formatAndValidBackgroundColor as d, formatAndValidBorderColor as e, formatAndValidResponsiveToken as f, formatAndValidBorderRadius as g, formatAndValidPadding as h, formatAndValidTextColor as i, formatAndValidStateToken as j, formatAndValidBorderStyle as k, formatAndValidFlexBreakpoint as l, formatAndValidTypographyToken as m };
