import Keyframes from './Keyframes'
import type { StyleContextProps, StyleProviderProps } from './StyleContext'
import { StyleProvider, createCache, useStyleInject, useStyleProvider } from './StyleContext'
import useCacheToken from './hooks/useCacheToken'
import type { CSSInterpolation, CSSObject } from './hooks/useStyleRegister'
import useStyleRegister, { extractStyle } from './hooks/useStyleRegister'
import type { Linter } from './linters'
import { legacyNotSelectorLinter, logicalPropertiesLinter, parentSelectorLinter } from './linters'
import type { DerivativeFunc, TokenType } from './theme'
import { Theme, createTheme } from './theme'
import type { Transformer } from './transformers/interface'
import legacyLogicalPropertiesTransformer from './transformers/legacyLogicalProperties'
import px2remTransformer from './transformers/px2rem'
import { supportLogicProps, supportWhere } from './util'

const cssinjs = {
  Theme,
  createTheme,
  useStyleRegister,
  useCacheToken,
  createCache,
  useStyleInject,
  useStyleProvider,
  Keyframes,
  extractStyle,

  // Transformer
  legacyLogicalPropertiesTransformer,
  px2remTransformer,

  // Linters
  logicalPropertiesLinter,
  legacyNotSelectorLinter,
  parentSelectorLinter,

  // cssinjs
  StyleProvider,
}
export {
  createCache,
  createTheme,
  extractStyle,
  Keyframes,
  // Transformer
  legacyLogicalPropertiesTransformer,
  legacyNotSelectorLinter,
  // Linters
  logicalPropertiesLinter,
  parentSelectorLinter,
  px2remTransformer,

  // cssinjs
  StyleProvider,
  Theme,
  useCacheToken,
  useStyleInject,
  useStyleProvider,
  useStyleRegister,
}
export type {
  CSSInterpolation,
  CSSObject,
  DerivativeFunc,
  Linter,
  StyleContextProps,
  StyleProviderProps,
  TokenType,
  Transformer,
}

export const _experimental = {
  supportModernCSS: () => supportWhere() && supportLogicProps(),
}

export default cssinjs
