{"version":3,"file":"CarouselVariables.cjs","names":["InlineStyles"],"sources":["../../src/CarouselVariables/CarouselVariables.tsx"],"sourcesContent":["import {\n  filterProps,\n  getBaseValue,\n  getSortedBreakpoints,\n  getSpacing,\n  InlineStyles,\n  keys,\n  MantineBreakpoint,\n  px,\n  rem,\n  useMantineTheme,\n} from '@mantine/core';\nimport type { CarouselProps } from '../Carousel';\n\ninterface CarouselVariablesProps extends CarouselProps {\n  selector: string;\n}\n\nexport function CarouselVariables({ slideGap, slideSize, selector }: CarouselVariablesProps) {\n  const theme = useMantineTheme();\n\n  const baseStyles: Record<string, string | undefined> = filterProps({\n    '--carousel-slide-gap': getSpacing(getBaseValue(slideGap)),\n    '--carousel-slide-size': rem(getBaseValue(slideSize)),\n  });\n\n  const queries = keys(theme.breakpoints).reduce<Record<string, Record<string, any>>>(\n    (acc, breakpoint) => {\n      if (!acc[breakpoint]) {\n        acc[breakpoint] = {};\n      }\n\n      if (typeof slideGap === 'object' && slideGap[breakpoint] !== undefined) {\n        acc[breakpoint]['--carousel-slide-gap'] = getSpacing(slideGap[breakpoint]);\n      }\n\n      if (typeof slideSize === 'object' && slideSize[breakpoint] !== undefined) {\n        acc[breakpoint]['--carousel-slide-size'] = getSpacing(slideSize[breakpoint]);\n      }\n\n      return acc;\n    },\n    {}\n  );\n\n  const sortedBreakpoints = getSortedBreakpoints(keys(queries), theme.breakpoints).filter(\n    (breakpoint) => keys(queries[breakpoint.value]).length > 0\n  );\n\n  const media = sortedBreakpoints.map((breakpoint) => ({\n    query: `(min-width: ${theme.breakpoints[breakpoint.value as MantineBreakpoint]})`,\n    styles: queries[breakpoint.value],\n  }));\n\n  return <InlineStyles styles={baseStyles} media={media} selector={selector} />;\n}\n\nfunction getBreakpoints(values: unknown) {\n  if (typeof values === 'object' && values !== null) {\n    return keys(values);\n  }\n\n  return [];\n}\n\nfunction sortBreakpoints(breakpoints: string[]) {\n  return breakpoints.sort((a, b) => (px(a) as number) - (px(b) as number));\n}\n\nfunction getUniqueBreakpoints({ slideGap, slideSize }: Omit<CarouselVariablesProps, 'selector'>) {\n  const breakpoints = Array.from(\n    new Set([...getBreakpoints(slideGap), ...getBreakpoints(slideSize)])\n  );\n\n  return sortBreakpoints(breakpoints);\n}\n\nexport function CarouselContainerVariables({\n  slideGap,\n  slideSize,\n  selector,\n}: CarouselVariablesProps) {\n  const baseStyles: Record<string, string | undefined> = filterProps({\n    '--carousel-slide-gap': getSpacing(getBaseValue(slideGap)),\n    '--carousel-slide-size': rem(getBaseValue(slideSize)),\n  });\n\n  const queries = getUniqueBreakpoints({ slideGap, slideSize }).reduce<\n    Record<string, Record<string, any>>\n  >((acc, breakpoint) => {\n    if (!acc[breakpoint]) {\n      acc[breakpoint] = {};\n    }\n\n    if (typeof slideGap === 'object' && slideGap[breakpoint] !== undefined) {\n      acc[breakpoint]['--carousel-slide-gap'] = getSpacing(slideGap[breakpoint]);\n    }\n\n    if (typeof slideSize === 'object' && slideSize[breakpoint] !== undefined) {\n      acc[breakpoint]['--carousel-slide-size'] = getSpacing(slideSize[breakpoint]);\n    }\n\n    return acc;\n  }, {});\n\n  const media = Object.keys(queries).map((breakpoint) => ({\n    query: `carousel (min-width: ${breakpoint})`,\n    styles: queries[breakpoint],\n  }));\n\n  return <InlineStyles styles={baseStyles} container={media} selector={selector} />;\n}\n"],"mappings":";;;;;AAkBA,SAAgB,kBAAkB,EAAE,UAAU,WAAW,YAAoC;CAC3F,MAAM,SAAA,GAAA,cAAA,iBAAwB;CAE9B,MAAM,cAAA,GAAA,cAAA,aAA6D;EACjE,yBAAA,GAAA,cAAA,aAAA,GAAA,cAAA,cAAgD,QAAQ,CAAC;EACzD,0BAAA,GAAA,cAAA,MAAA,GAAA,cAAA,cAA0C,SAAS,CAAC;CACtD,CAAC;CAED,MAAM,WAAA,GAAA,cAAA,MAAe,MAAM,WAAW,EAAE,QACrC,KAAK,eAAe;EACnB,IAAI,CAAC,IAAI,aACP,IAAI,cAAc,CAAC;EAGrB,IAAI,OAA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