import { isNonNullable } from "../utils/isNonNullable";
import { useSwatches } from "../../runtimes/react/hooks/makeswift-api";
import {
  getShadowsPropControllerDataResponsiveShadowsData,
  getShadowsPropControllerDataSwatchIds
} from "@makeswift/prop-controllers";
const ShadowDefaultValue = {
  inset: false,
  offsetX: 0,
  offsetY: 2,
  blurRadius: 4,
  spreadRadius: 0,
  color: null
};
function useBoxShadow(data) {
  const swatchIds = getShadowsPropControllerDataSwatchIds(data);
  const swatches = useSwatches(swatchIds);
  const responsiveShadowsData = getShadowsPropControllerDataResponsiveShadowsData(data);
  if (responsiveShadowsData == null)
    return null;
  return responsiveShadowsData.map(({ value: shadows, ...restOfValue }) => ({
    ...restOfValue,
    value: shadows.map(
      ({
        payload: { color, inset, offsetX, offsetY, blurRadius, spreadRadius },
        ...restOfShadow
      }) => ({
        ...restOfShadow,
        payload: {
          color: color != null ? {
            swatch: swatches.filter(isNonNullable).find((s) => s && s.id === color.swatchId),
            alpha: color.alpha
          } : null,
          inset: inset ?? ShadowDefaultValue.inset,
          offsetX: offsetX ?? ShadowDefaultValue.offsetX,
          offsetY: offsetY ?? ShadowDefaultValue.offsetY,
          blurRadius: blurRadius ?? ShadowDefaultValue.blurRadius,
          spreadRadius: spreadRadius ?? ShadowDefaultValue.spreadRadius
        }
      })
    )
  }));
}
export {
  useBoxShadow
};
//# sourceMappingURL=useBoxShadow.js.map