import { useWidgetSelectedOptionIndex } from './useWidgetSelectedOptionIndex';
import { useIsWidgetDisabled } from './useIsWidgetDisabled';

export type UseIsWidgetOptionDisabledArg = {
  widgetId: string;
  optionIndex: number;
};

export const useIsWidgetOptionDisabled = ({
  widgetId,
  optionIndex,
}: UseIsWidgetOptionDisabledArg) => {
  const selectedOptionIndex = useWidgetSelectedOptionIndex({ widgetId });
  const isWidgetDisabled = useIsWidgetDisabled({ widgetId });

  return isWidgetDisabled || selectedOptionIndex === optionIndex;
};
