{"version":3,"sources":["../src/cx.ts","../src/utils/merge-props.ts","../src/cv.ts","../src/scv.ts","../src/sv.ts","../src/ssv.ts"],"names":["toVal","input","result","i","tmpClassValue","tmpClassName","key","cx","args","mergeProps","defaultProps","props","omitKeys","merged","k","cv","config","base","variants","compoundVariants","defaultVariants","classNameResolver","mergedProps","classValues","classValue","compound","matches","value","propValue","scv","slots","slotClassValues","slot","cls","sv","styleValue","ssv","slotStyle"],"mappings":"aAOA,SAASA,CAAAA,CAAMC,EAA2B,CACxC,GAAI,OAAOA,CAAAA,EAAU,QAAA,CACnB,OAAOA,CAAAA,CAGT,GAAI,OAAOA,CAAAA,EAAU,QAAA,EAAY,OAAOA,CAAAA,EAAU,QAAA,CAChD,OAAO,MAAA,CAAOA,CAAK,CAAA,CAGrB,GAAIA,CAAAA,EAAU,IAAA,EAA+B,OAAOA,CAAAA,EAAU,SAAA,CAC5D,OAAO,EAAA,CAGT,IAAIC,EAAS,EAAA,CAEb,GAAI,KAAA,CAAM,OAAA,CAAQD,CAAK,CAAA,CAAG,CACxB,IAAIE,CAAAA,CAAI,EACJC,CAAAA,CACAC,CAAAA,CACJ,KAAOF,CAAAA,CAAIF,CAAAA,CAAM,MAAA,CAAQE,CAAAA,EAAAA,CAAAA,CAClBC,CAAAA,CAAgBH,CAAAA,CAAME,CAAC,CAAA,IACrBE,CAAAA,CAAeL,EAAMI,CAAa,CAAA,CAAA,GACjCF,IAAQA,CAAAA,EAAU,GAAA,CAAA,CACtBA,CAAAA,EAAUG,CAAAA,CAAAA,CAKhB,OAAOH,CACT,CAEA,IAAA,IAAWI,CAAAA,IAAOL,EACZA,CAAAA,CAAMK,CAAG,IACPJ,CAAAA,GAAQA,CAAAA,EAAU,GAAA,CAAA,CACtBA,CAAAA,EAAUI,CAAAA,CAAAA,CAId,OAAOJ,CACT,CAEO,SAASK,KAAMC,CAAAA,CAA4B,CAChD,IAAIN,CAAAA,CAAS,EAAA,CACTC,CAAAA,CAAI,CAAA,CACJC,CAAA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AOe,CAAI,CAAA,CAAG,GAAGrB,CAAAA,EAAO,MAAA,GAASqB,CAAI,CAAE,CAAA,CAG7D,OAAO9B,CACT,CAsDJ","file":"index.cjs","sourcesContent":["// credit: https://github.com/lukeed/clsx\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type ClassDictionary = Record<string, any>\nexport type ClassValue = ClassValue[] | string | number | bigint | ClassDictionary | null | boolean | undefined\nexport type ClassArray = ClassValue[]\n\nfunction toVal(input: ClassValue): string {\n  if (typeof input === 'string') {\n    return input\n  }\n\n  if (typeof input === 'number' || typeof input === 'bigint') {\n    return String(input)\n  }\n\n  if (input === null || input === undefined || typeof input === 'boolean') {\n    return ''\n  }\n\n  let result = ''\n\n  if (Array.isArray(input)) {\n    let i = 0\n    let tmpClassValue: ClassValue\n    let tmpClassName: string\n    for (; i < input.length; i++) {\n      if ((tmpClassValue = input[i])) {\n        if ((tmpClassName = toVal(tmpClassValue))) {\n          if (result) result += ' '\n          result += tmpClassName\n        }\n      }\n    }\n\n    return result\n  }\n\n  for (const key in input) {\n    if (input[key]) {\n      if (result) result += ' '\n      result += key\n    }\n  }\n\n  return result\n}\n\nexport function cx(...args: ClassValue[]): string {\n  let result = ''\n  let i = 0\n  let tmpClassValue: ClassValue\n  let tmpClassName: string\n\n  for (; i < args.length; i++) {\n    if ((tmpClassValue = args[i])) {\n      if ((tmpClassName = toVal(tmpClassValue))) {\n        if (result) result += ' '\n        result += tmpClassName\n      }\n    }\n  }\n\n  return result\n}\n\nexport default cx\n","export function mergeProps<T extends Record<string, unknown>, P extends Record<string, unknown>>(\n  defaultProps: T | undefined,\n  props: P | undefined,\n  omitKeys?: (keyof P)[]\n): Record<string, unknown> {\n  const merged: Record<string, unknown> = { ...defaultProps }\n\n  if (props) {\n    for (const k in props) {\n      if (props[k] !== undefined && (!omitKeys || !omitKeys.includes(k))) {\n        merged[k] = props[k]\n      }\n    }\n  }\n\n  return merged\n}\n","import { ObjectKeyPicker, ObjectKeyArrayPicker } from './utils/types'\nimport { cx, ClassValue } from './cx'\nimport { mergeProps } from './utils/merge-props'\n\nexport type ClassVariantRecord = Record<string, Record<string, ClassValue>>\n\nexport type ClassVariantExtendProps = { className: ClassValue }\n\nexport interface ClassVariantDefinition<T extends ClassVariantRecord | undefined> {\n  base?: ClassValue\n  variants?: T\n  compoundVariants?: (ObjectKeyArrayPicker<T> & ClassVariantExtendProps)[]\n  defaultVariants?: ObjectKeyPicker<T>\n  classNameResolver?: typeof cx\n}\n\nexport type ClassVariantFnProps<T extends ClassVariantRecord | undefined> = T extends undefined\n  ? Partial<ClassVariantExtendProps>\n  : ObjectKeyPicker<T> & Partial<ClassVariantExtendProps>\n\nexport type ClassVariantFn<T extends ClassVariantRecord | undefined> = (props?: ClassVariantFnProps<T>) => string\n\nexport type ClassVariantCreatorFn = <T extends ClassVariantRecord | undefined>(\n  config: ClassVariantDefinition<T>\n) => ClassVariantFn<T>\n\n/**\n * Creates a class variant function that combines base classes, variants, compound variants, and default variants.\n *\n * @template T - Type of the variant record\n * @param config - Configuration object for creating class variants\n * @returns A function that accepts variant props and returns a combined class string\n *\n * @example\n * ```typescript\n * const button = cv({\n *   base: 'px-4 py-2 rounded',\n *   variants: {\n *     color: {\n *       primary: 'bg-blue-500 text-white',\n *       secondary: 'bg-gray-500 text-white'\n *     },\n *     size: {\n *       sm: 'text-sm',\n *       lg: 'text-lg'\n *     }\n *   },\n *   defaultVariants: {\n *     color: 'primary',\n *     size: 'sm'\n *   }\n * });\n *\n * button(); // => 'px-4 py-2 rounded bg-blue-500 text-white text-sm'\n * button({ color: 'secondary' }); // => 'px-4 py-2 rounded bg-gray-500 text-white text-sm'\n * ```\n */\nexport const cv: ClassVariantCreatorFn = (config) => {\n  const { base, variants, compoundVariants, defaultVariants, classNameResolver = cx } = config\n\n  if (!variants) {\n    return (props) => classNameResolver(base, props?.className)\n  }\n\n  return (props) => {\n    const mergedProps = mergeProps(defaultVariants, props, ['className'])\n\n    const classValues: ClassValue[] = []\n\n    for (const key in mergedProps) {\n      const classValue = variants[key]?.[mergedProps[key] as string]\n      if (classValue) {\n        classValues.push(classValue)\n      }\n    }\n\n    if (compoundVariants) {\n      for (let i = 0; i < compoundVariants.length; i++) {\n        const compound = compoundVariants[i]\n        let matches = true\n        for (const key in compound) {\n          if (key === 'className') continue\n          const value = compound[key as keyof typeof compound]\n          const propValue = mergedProps[key]\n          if (Array.isArray(value) ? !value.includes(propValue) : value !== propValue) {\n            matches = false\n            break\n          }\n        }\n        if (matches && compound.className) {\n          classValues.push(compound.className)\n        }\n      }\n    }\n\n    return classNameResolver(base, classValues, props?.className)\n  }\n}\n\nexport default cv\n","import { ObjectKeyPicker, ObjectKeyArrayPicker, PartialRecord } from './utils/types'\nimport { cx, ClassValue } from './cx'\nimport { mergeProps } from './utils/merge-props'\n\nexport type SlotClassRecord<S extends string> = PartialRecord<S, ClassValue>\n\nexport type SlotClassVariantRecord<S extends string> = Record<string, Record<string, SlotClassRecord<S>>>\n\nexport type SlotClassVariantExtendProps<S extends string> = { classNames: SlotClassRecord<S> }\n\nexport interface SlotClassVariantDefinition<S extends string, T extends SlotClassVariantRecord<S> | undefined> {\n  slots: S[]\n  base?: SlotClassRecord<S>\n  variants?: T\n  compoundVariants?: (ObjectKeyArrayPicker<T> & SlotClassVariantExtendProps<S>)[]\n  defaultVariants?: ObjectKeyPicker<T>\n  classNameResolver?: typeof cx\n}\n\nexport type SlotClassVariantFnProps<\n  S extends string,\n  T extends SlotClassVariantRecord<S> | undefined,\n> = T extends undefined\n  ? Partial<SlotClassVariantExtendProps<S>>\n  : ObjectKeyPicker<T> & Partial<SlotClassVariantExtendProps<S>>\n\nexport type SlotClassVariantFn<S extends string, T extends SlotClassVariantRecord<S> | undefined> = (\n  props?: SlotClassVariantFnProps<S, T>\n) => Record<S, string>\n\nexport type SlotClassVariantCreatorFn = <S extends string, T extends SlotClassVariantRecord<S> | undefined>(\n  config: SlotClassVariantDefinition<S, T>\n) => SlotClassVariantFn<S, T>\n\n/**\n * Creates a slot-based class variant function that manages class names for multiple slots with variants.\n *\n * @param config - Configuration object for creating the variant function\n * @returns A function that accepts variant props and returns class names for each slot\n *\n * @example\n * ```typescript\n * const button = scv({\n *   slots: ['root', 'icon'],\n *   base: {\n *     root: 'btn',\n *     icon: 'btn-icon'\n *   },\n *   variants: {\n *     size: {\n *       sm: {\n *         root: 'btn-sm',\n *         icon: 'icon-sm'\n *       },\n *       lg: {\n *         root: 'btn-lg',\n *         icon: 'icon-lg'\n *       }\n *     }\n *   },\n *   defaultVariants: {\n *     size: 'sm'\n *   }\n * })\n *\n * // Usage\n * const classes = button({ size: 'lg' })\n * // Result: { root: 'btn btn-lg', icon: 'btn-icon icon-lg' }\n * ```\n */\nexport const scv: SlotClassVariantCreatorFn = (config) => {\n  const { slots, base, variants, compoundVariants, defaultVariants, classNameResolver = cx } = config\n\n  if (!variants) {\n    return (props) => {\n      const result = {} as Record<(typeof slots)[number], string>\n\n      for (const slot of slots) {\n        result[slot] = classNameResolver(base?.[slot], props?.classNames?.[slot])\n      }\n\n      return result\n    }\n  }\n\n  return (props) => {\n    const mergedProps = mergeProps(defaultVariants, props, ['classNames'])\n\n    const slotClassValues = {} as Record<(typeof slots)[number], ClassValue[]>\n\n    for (const slot of slots) {\n      if (base?.[slot]) {\n        slotClassValues[slot] = Array.isArray(base[slot]) ? [...base[slot]] : [base[slot]]\n      } else {\n        slotClassValues[slot] = []\n      }\n    }\n\n    for (const key in mergedProps) {\n      const cls = variants[key]?.[mergedProps[key] as string]\n\n      if (cls) {\n        for (const slot in cls) {\n          slotClassValues[slot]?.push(cls[slot])\n        }\n      }\n    }\n\n    if (compoundVariants) {\n      for (let i = 0; i < compoundVariants.length; i++) {\n        const compound = compoundVariants[i]\n        let matches = true\n        for (const key in compound) {\n          if (key === 'classNames') continue\n          const value = compound[key as keyof typeof compound]\n          const propValue = mergedProps[key]\n          if (Array.isArray(value) ? !value.includes(propValue) : value !== propValue) {\n            matches = false\n            break\n          }\n        }\n        if (matches && compound.classNames) {\n          for (const slot in compound.classNames) {\n            slotClassValues[slot]?.push(compound.classNames[slot])\n          }\n        }\n      }\n    }\n\n    if (props?.classNames) {\n      for (const slot in props.classNames) {\n        slotClassValues[slot]?.push(props.classNames[slot])\n      }\n    }\n\n    const result = {} as Record<(typeof slots)[number], string>\n\n    for (const slot in slotClassValues) {\n      result[slot] = classNameResolver(slotClassValues[slot])\n    }\n\n    return result\n  }\n}\n\nexport default scv\n","import { CssProperties, ObjectKeyArrayPicker, ObjectKeyPicker } from './utils/types'\nimport { mergeProps } from './utils/merge-props'\n\nexport type StyleVariantRecord = Record<string, Record<string, CssProperties>>\n\nexport type StyleVariantExtendProps = { style: CssProperties }\n\nexport interface StyleVariantDefinition<T extends StyleVariantRecord | undefined> {\n  base?: CssProperties\n  variants?: T\n  compoundVariants?: (ObjectKeyArrayPicker<T> & StyleVariantExtendProps)[]\n  defaultVariants?: ObjectKeyPicker<T>\n}\n\nexport type StyleVariantFnProps<T extends StyleVariantRecord | undefined> = T extends undefined\n  ? Partial<StyleVariantExtendProps>\n  : ObjectKeyPicker<T> & Partial<StyleVariantExtendProps>\n\nexport type StyleVariantFn<T extends StyleVariantRecord | undefined> = (props?: StyleVariantFnProps<T>) => CssProperties\n\nexport type StyleVariantCreatorFn = <T extends StyleVariantRecord | undefined>(\n  config: StyleVariantDefinition<T>\n) => StyleVariantFn<T>\n\n/**\n * Creates a style variant function based on the provided configuration.\n *\n * @template T - The type of the style variant record.\n * @param {StyleVariantDefinition<T>} config - The configuration object for style variants.\n * @returns {StyleVariantFn<T>} A function that takes props and returns the computed CSS properties.\n *\n * @example\n * ```typescript\n *\n * const makeStyle = sv({\n *   base: { color: 'black' },\n *   variants: {\n *     size: {\n *       small: { fontSize: '12px' },\n *       large: { fontSize: '24px' }\n *     }\n *   },\n *   compoundVariants: [\n *     { size: 'large', style: { fontWeight: 'bold' } }\n *   ],\n *   defaultVariants: { size: 'small' }\n * });\n *\n * const style = makeStyle({ size: 'large' });\n * // style = { color: 'black', fontSize: '24px', fontWeight: 'bold' }\n * ```\n */\nexport const sv: StyleVariantCreatorFn = (config) => {\n  const { base, variants, compoundVariants, defaultVariants } = config\n\n  if (!variants) {\n    return (props) => ({ ...base, ...props?.style })\n  }\n\n  return (props) => {\n    const result: CssProperties = { ...base }\n\n    const mergedProps = mergeProps(defaultVariants, props, ['style'])\n\n    for (const key in mergedProps) {\n      const styleValue = variants[key]?.[mergedProps[key] as string]\n      if (styleValue) {\n        Object.assign(result, styleValue)\n      }\n    }\n\n    if (compoundVariants) {\n      for (let i = 0; i < compoundVariants.length; i++) {\n        const compound = compoundVariants[i]\n        let matches = true\n        for (const key in compound) {\n          if (key === 'style') continue\n          const value = compound[key as keyof typeof compound]\n          const propValue = mergedProps[key]\n          if (Array.isArray(value) ? !value.includes(propValue) : value !== propValue) {\n            matches = false\n            break\n          }\n        }\n        if (matches && compound.style) {\n          Object.assign(result, compound.style)\n        }\n      }\n    }\n\n    if (props?.style) {\n      Object.assign(result, props.style)\n    }\n\n    return result\n  }\n}\n\nexport default sv\n","import { ObjectKeyPicker, ObjectKeyArrayPicker, PartialRecord, CssProperties } from './utils/types'\nimport { mergeProps } from './utils/merge-props'\n\nexport type SlotStyleRecord<S extends string> = PartialRecord<S, CssProperties>\n\nexport type SlotStyleVariantRecord<S extends string> = Record<string, Record<string, SlotStyleRecord<S>>>\n\nexport type SlotStyleVariantExtendProps<S extends string> = { styles: SlotStyleRecord<S> }\n\nexport interface SlotStyleVariantDefinition<S extends string, T extends SlotStyleVariantRecord<S> | undefined> {\n  slots: S[]\n  base?: SlotStyleRecord<S>\n  variants?: T\n  compoundVariants?: (ObjectKeyArrayPicker<T> & SlotStyleVariantExtendProps<S>)[]\n  defaultVariants?: ObjectKeyPicker<T>\n}\n\nexport type SlotStyleVariantFnProps<\n  S extends string,\n  T extends SlotStyleVariantRecord<S> | undefined,\n> = T extends undefined\n  ? Partial<SlotStyleVariantExtendProps<S>>\n  : ObjectKeyPicker<T> & Partial<SlotStyleVariantExtendProps<S>>\n\nexport type SlotStyleVariantFn<S extends string, T extends SlotStyleVariantRecord<S> | undefined> = (\n  props?: SlotStyleVariantFnProps<S, T>\n) => Record<S, CssProperties>\n\nexport type SlotStyleVariantCreatorFn = <S extends string, T extends SlotStyleVariantRecord<S> | undefined>(\n  config: SlotStyleVariantDefinition<S, T>\n) => SlotStyleVariantFn<S, T>\n\n/**\n * Creates a slot-based style variant function that composes CSS properties based on variants and compound variants.\n *\n * @param config - Configuration object for creating style variants\n * @returns A function that accepts variant props and returns composed styles for each slot\n *\n * @example\n * ```ts\n * const buttonStyles = ssv({\n *   slots: ['root', 'icon'],\n *   base: {\n *     root: { padding: '8px' },\n *     icon: { size: '16px' }\n *   },\n *   variants: {\n *     size: {\n *       small: {\n *         root: { padding: '4px' },\n *         icon: { size: '12px' }\n *       },\n *       large: {\n *         root: { padding: '12px' },\n *         icon: { size: '20px' }\n *       }\n *     }\n *   }\n * });\n *\n * // Usage\n * const styles = buttonStyles({ size: 'small' });\n * // => { root: { padding: '4px' }, icon: { size: '12px' } }\n * ```\n */\nexport const ssv: SlotStyleVariantCreatorFn = (config) => {\n  const { slots, base, variants, compoundVariants, defaultVariants } = config\n\n  if (!variants) {\n    return (props) => {\n      const result = {} as Record<(typeof slots)[number], CssProperties>\n\n      for (const slot of slots) {\n        result[slot] = { ...base?.[slot], ...props?.styles?.[slot] }\n      }\n\n      return result\n    }\n  }\n\n  return (props) => {\n    const mergedProps = mergeProps(defaultVariants, props, ['styles'])\n\n    const result = {} as Record<(typeof slots)[number], CssProperties>\n\n    for (const slot of slots) {\n      result[slot] = { ...base?.[slot] }\n    }\n\n    for (const key in mergedProps) {\n      const slotStyle = variants[key]?.[mergedProps[key] as string]\n\n      if (slotStyle) {\n        for (const slot in slotStyle) {\n          Object.assign(result[slot], slotStyle[slot])\n        }\n      }\n    }\n\n    if (compoundVariants) {\n      for (let i = 0; i < compoundVariants.length; i++) {\n        const compound = compoundVariants[i]\n        let matches = true\n\n        for (const key in compound) {\n          if (key === 'styles') continue\n          const value = compound[key as keyof typeof compound]\n          const propValue = mergedProps[key]\n\n          if (Array.isArray(value) ? !value.includes(propValue) : value !== propValue) {\n            matches = false\n            break\n          }\n        }\n\n        if (matches && compound.styles) {\n          for (const slot in compound.styles) {\n            Object.assign(result[slot], compound.styles[slot])\n          }\n        }\n      }\n    }\n\n    if (props?.styles) {\n      for (const slot in props.styles) {\n        Object.assign(result[slot], props.styles[slot])\n      }\n    }\n\n    return result\n  }\n}\n\nexport default ssv\n"]}