/* eslint-disable @typescript-eslint/no-explicit-any */
import { TailwindPlayCommonParams } from '@/TailwindPlay/Fields/types.js';
import { InvalidField } from '@/TailwindPlay/Fields/Invalid.js';
import { extractHusarData } from '@/TailwindPlay/shared/extract.js';

export const FieldS3Video: React.FC<TailwindPlayCommonParams> = (props) => {
  const { v, attributes } = extractHusarData(props);
  if (typeof v !== 'object' && v !== null && typeof v !== 'undefined') return <InvalidField />;
  return (
    <>
      {v?.url && (
        <video className="object-cover w-full h-full max-h-64" controls preload="metadata" {...attributes}>
          <source src={v?.url} type="video/mp4" />
        </video>
      )}
    </>
  );
};
