import React, { useEffect } from 'react';
import CSQMethodFilter from '../../csq/CSQMethodFilter';
import { CSMaskProps } from '../../types/types';
import CSMaskedView from './CSMaskedView';
import CSUnmaskedView from './CSUnmaskedView';

export const CSMask: React.FC<CSMaskProps> = ({
  isMasking = true,
  children,
  ...props
}) => {

  useEffect(() => {
      CSQMethodFilter.warnIfDisabled('default', 'CSMask');
  }, []);

  return isMasking ? (
    <CSMaskedView {...props}>{children}</CSMaskedView>
  ) : (
    <CSUnmaskedView {...props}>{children}</CSUnmaskedView>
  );
};
