{"version":3,"sources":["../ui/src/components/player-components/recommendationList/recommendationList.tsx"],"sourcesContent":["import {memo, useEffect, useRef, useState} from \"react\";\r\nimport PlayerCard from \"../playerCard/playerCard\";\r\nimport { useAppDispatch, useAppSelector } from \"../../../../../redux/hooks\";\r\nimport useIntersect from \"../../../../../helpers/hooks/useIntersect\";\r\nimport { conditions } from \"../../../../../helpers\";\r\nimport { ConditionName } from \"../../../../../interfaces\";\r\nimport { setPlayListCardPopover } from \"../../../../../redux/slices/popoversSlice\";\r\nimport { handleClickRecommendationCard } from \"../../../../../redux/actions/videoData.actions\";\r\nimport { shallowEqual } from 'react-redux';\r\nimport dynamic from \"next/dynamic\";\r\n\r\nconst PlayListCard = dynamic(() => import(\"../playList/playListCard\"));\r\n\r\nconst RecommendationList = () => {\r\n\r\n    const { recommendationList } = useAppSelector(({ videoData: { recommendationList, isComplexDesktop, isComplexPortrait } }) => ({ recommendationList, isComplexDesktop, isComplexPortrait }), shallowEqual);\r\n\r\n    const list = useRef<any>([]);\r\n    const [scrollEnd, setScrollEnd] = useState(false);\r\n    const [listScrolled, setListScrolled] = useState<any>([]);\r\n    const [playListCardInfo, setPlayListCardInfo] = useState<any>(null);\r\n\r\n    const dispatch = useAppDispatch();\r\n\r\n    useEffect(() => {\r\n        if (scrollEnd) {\r\n            if (list.current && listScrolled.length) {\r\n                const moreData = list.current.slice(listScrolled.length + 1, (listScrolled.length + 10) + 1);\r\n                setListScrolled([...listScrolled, ...moreData]);\r\n            }\r\n            setScrollEnd(false);\r\n        }\r\n    }, [scrollEnd]);\r\n\r\n    useEffect(() => {\r\n        list.current = recommendationList;\r\n        setListScrolled(list.current.slice(0, 10))\r\n    }, [recommendationList]);\r\n\r\n\r\n    const handleIntersect = ([entry]: IntersectionObserverEntry[]) => {\r\n        if (entry.isIntersecting) {\r\n            setScrollEnd(true);\r\n        }\r\n    };\r\n\r\n    const observerRef = useIntersect(handleIntersect);\r\n\r\n    return (\r\n        <div className={`pl-flex pl-flex-col pl-gap-2 ${conditions(ConditionName.isComplexPortrait) && `pl-mb-[300px] pl-mx-3`}`}>\r\n            <p className=\"pl-text-[14px] pl-font-bold\">ویدیوهای پیشنهادی</p>\r\n            {listScrolled.map((item: any,index:number) => (\r\n                <div\r\n                    key={index} \r\n                    id={`recommendationList-${item.id}`}\r\n                    className={`pl-relative pl-overflow-hidden`}\r\n                    style={{ height: conditions(ConditionName.isComplexDesktop) ? 98 : 80 }}\r\n                >\r\n                    <PlayerCard\r\n                        content_type={item.content_type}\r\n                        id={item.id}\r\n                        tags={item.tag}\r\n                        src={item.banner} \r\n                        type={item.type!}\r\n                        status_text={item.status_text} \r\n                        isVideo={false}\r\n                        width={conditions(ConditionName.isComplexDesktop) ? 174 : (conditions(ConditionName.isComplexPortrait) ? 142 : window.innerWidth)}\r\n                        height={conditions(ConditionName.isComplexDesktop) ? 98 : (conditions(ConditionName.isComplexPortrait) ? 80 : (window.innerWidth * 9) / 16)}\r\n                        duration={item.duration} \r\n                        title={item.title}\r\n                        isComplexDesktop={conditions(ConditionName.isComplexDesktop)} \r\n                        viewers={item.viewers}\r\n                        imdb_rate={item.imdb_rate}\r\n                        date={((item.type === \"playlist\" && item.content_type === 1) || (item.type === \"vod\" && (item.content_type === 1 || item.content_type === 0) )) ? item.release_year : item.start_time}\r\n                        onClick={(event: any) => {\r\n                            if(item.type === \"playlist\") {\r\n                                dispatch(setPlayListCardPopover(true));\r\n                                setPlayListCardInfo(item);\r\n                            } else handleClickRecommendationCard(event, item.id, item.user_id, item.type, index + 1);\r\n                        }}\r\n                        commentsCount={item.comments_count}\r\n                        star={item.star}\r\n                    />\r\n                </div>\r\n                \r\n            ))}\r\n            <div id=\"observer\" className=\"pl-bg-transparent pt-5\" ref={observerRef}/>\r\n            {playListCardInfo && <PlayListCard playListCardInfo={playListCardInfo} />}\r\n        </div>\r\n    )\r\n}\r\n\r\nexport default memo(RecommendationList);"],"mappings":"kQAAAA,IAAA,OAAQ,QAAAC,EAAM,aAAAC,EAAW,U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AACY,EAAUC,IACzB1B,EAAC,OAEG,GAAI,sBAAsByB,EAAK,EAAE,GACjC,UAAW,iCACX,MAAO,CAAE,OAAQD,oBAAyC,EAAI,GAAK,EAAG,EAEtE,SAAAxB,EAAC2B,EAAA,CACG,aAAcF,EAAK,aACnB,GAAIA,EAAK,GACT,KAAMA,EAAK,IACX,IAAKA,EAAK,OACV,KAAMA,EAAK,KACX,YAAaA,EAAK,YAClB,QAAS,GACT,MAAOD,oBAAyC,EAAI,IAAOA,qBAA0C,EAAI,IAAM,OAAO,WACtH,OAAQA,oBAAyC,EAAI,GAAMA,qBAA0C,EAAI,GAAM,OAAO,WAAa,EAAK,GACxI,SAAUC,EAAK,SACf,MAAOA,EAAK,MACZ,iBAAkBD,oBAAyC,EAC3D,QAASC,EAAK,QACd,UAAWA,EAAK,UAChB,KAAQA,EAAK,OAAS,YAAcA,EAAK,eAAiB,GAAOA,EAAK,OAAS,QAAUA,EAAK,eAAiB,GAAKA,EAAK,eAAiB,GAAQA,EAAK,aAAeA,EAAK,WAC3K,QAAUG,GAAe,CAClBH,EAAK,OAAS,YACbR,EAASY,EAAuB,EAAI,CAAC,EACrCb,EAAoBS,CAAI,GACrBK,EAA8BF,EAAOH,EAAK,GAAIA,EAAK,QAASA,EAAK,KAAMC,EAAQ,CAAC,CAC3F,EACA,cAAeD,EAAK,eACpB,KAAMA,EAAK,KACf,GA7BKC,CA8BT,CAEH,EACD1B,EAAC,OAAI,GAAG,WAAW,UAAU,yBAAyB,IAAKqB,EAAY,EACtEN,GAAoBf,EAACE,EAAA,CAAa,iBAAkBa,EAAkB,GAC3E,CAER,EAEOgB,EAAQC,EAAK7B,CAAkB","names":["init_esm_shims","memo","useEffect","useRef","useState","shallowEqual","dynamic","jsx","jsxs","PlayListCard","RecommendationList","recommendationList","useAppSelector","isComplexDesktop","isComplexPortrait","list","useRef","scrollEnd","setScrollEnd","useState","listScrolled","setListScrolled","playListCardInfo","setPlayListCardInfo","dispatch","useAppDispatch","useEffect","moreData","observerRef","useIntersect_default","entry","conditions","item","index","playerCard_default","event","setPlayListCardPopover","handleClickRecommendationCard","recommendationList_default","memo"]}