"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("react"),y=require("../../../../utils/cn/cn.cjs.js"),r=require("../../../../src/modules/Testimonial/components/VideoCard/videoCard.module.css"),p=require("../../../../components/PlayButton/PlayButton.cjs.js"),g=require("../../../../components/Typography/Typography.cjs.js"),h=require("../Product/Product.cjs.js"),j=({product:i,review:l,background:d,isActive:f})=>{var m;const[s,t]=n.useState(!1),a=n.useRef(null),u=n.useRef(null);return n.useEffect(()=>{const o=new IntersectionObserver(([c])=>{!c.isIntersecting&&s&&t(!1)},{threshold:.2});return u.current&&o.observe(u.current),()=>o.disconnect()},[s]),n.useEffect(()=>{f||t(!1)},[f]),n.useEffect(()=>{!s&&a.current&&(a.current.pause(),a.current.currentTime=0)},[s]),e.jsxs("div",{className:r.root,ref:u,onClick:()=>s?t(!1):void 0,style:{backgroundImage:`url(${d.preview})`},children:[e.jsxs("div",{className:r.mediaContainer,children:[e.jsx("video",{ref:a,src:d.url,playsInline:!0,controls:!1,muted:!1,onEnded:()=>t(!1),className:y.cn(r.media,!s&&r.mediaHidden)}),!s&&e.jsx("div",{className:r.playButton,children:e.jsx(p.PlayButton,{onClick:o=>{var c;o.stopPropagation(),(c=a.current)==null||c.play(),t(!0)}})})]}),e.jsxs("div",{className:r.infoContainer,children:[((m=l==null?void 0:l.author)==null?void 0:m.username)&&e.jsx(g.Typography,{as:"p",defaultVariant:"labelSm",mobileVariant:"labelXs",emphasis:!0,weight:"regular",children:l.author.username}),i&&e.jsx(h.Product,{image:i.image,name:i.name,link:i.link})]})]})};exports.VideoCard=j;
