{"version":3,"file":"withStyledSystem.mjs","sources":["../../../packages/styled-system/withStyledSystem.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/explicit-module-boundary-types */\n/* eslint-disable @typescript-eslint/ban-types */\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport styled, {\n  AnyStyledComponent,\n  StyledComponent,\n  StyledComponentInnerComponent,\n  StyledComponentInnerOtherProps,\n  StyledComponentInnerAttrs,\n  DefaultTheme,\n} from '../utils/styled-components-wrapper.js'\n\n// The `@styled-system/should-forward-prop` has issues with ESM modules:\nimport _shouldForwardProp from '@styled-system/should-forward-prop'\n// @ts-expect-error Property 'default' does not exist on type 'genericShouldForwardProp'\nconst shouldForwardProp = _shouldForwardProp.default || _shouldForwardProp\n\nimport {\n  compose,\n  space,\n  color,\n  typography,\n  layout,\n  flexbox,\n  grid,\n  background,\n  border,\n  position,\n  shadow,\n} from 'styled-system'\nimport { ComponentType } from 'react'\nimport { StyledSystemProps } from './types.js'\n\ntype MergePropsWithSS<T extends object> = Omit<T, keyof StyledSystemProps> &\n  StyledSystemProps\n\nfunction withStyledSystem<\n  C extends AnyStyledComponent,\n  T extends object = DefaultTheme,\n  O extends object = {},\n  A extends keyof any = never,\n>(\n  Component: C,\n): StyledComponent<\n  StyledComponentInnerComponent<C>,\n  T,\n  MergePropsWithSS<O & StyledComponentInnerOtherProps<C>>,\n  A | StyledComponentInnerAttrs<C>\n>\n\nfunction withStyledSystem<\n  C extends keyof JSX.IntrinsicElements | ComponentType<any>,\n  T extends object = DefaultTheme,\n  O extends object = {},\n  A extends keyof any = never,\n>(Component: C): StyledComponent<C, T, MergePropsWithSS<O>, A>\n\nfunction withStyledSystem(Component: any) {\n  return styled(Component).withConfig<{}>({\n    shouldForwardProp,\n  })<StyledSystemProps>(\n    compose(\n      space,\n      color,\n      typography,\n      layout,\n      flexbox,\n      grid,\n      background,\n      border,\n      position,\n      shadow,\n    ),\n  )\n}\n\nexport default withStyledSystem\n"],"names":["shouldForwardProp","_shouldForwardProp","default","withStyledSystem","Component","styled","withConfig","compose","space","color","typography","layout","flexbox","grid","background","border","position","shadow"],"mappings":";;;;AAAA;AACA;AACA;;AAaA;AACA,MAAMA,iBAAiB,GAAGC,kBAAkB,CAACC,OAAO,IAAID,kBAAkB,CAAA;AA0C1E,SAASE,gBAAgBA,CAACC,SAAc,EAAE;AACxC,EAAA,OAAOC,MAAM,CAACD,SAAS,CAAC,CAACE,UAAU,CAAK;AACtCN,IAAAA,iBAAAA;GACD,CAAC,CACAO,OAAO,CACLC,KAAK,EACLC,KAAK,EACLC,UAAU,EACVC,MAAM,EACNC,OAAO,EACPC,IAAI,EACJC,UAAU,EACVC,MAAM,EACNC,QAAQ,EACRC,MACF,CACF,CAAC,CAAA;AACH;;;;"}