{"version":3,"sources":["../ui/src/components/player-components/comments/comments.tsx"],"sourcesContent":["import { useEffect, useState } from \"react\";\r\nimport { useAppDispatch, useAppSelector } from \"redux-share/hooks\";\r\nimport store from \"redux-share/store\";\r\nimport { handleCloseCommentPopover, handleCommentsIdsInLocalStorage, handleGetComments } from \"redux-share/actions/comment.action\";\r\nimport { IComments, ConditionName, IUsersCommentsProfiles } from \"interfaces\";\r\nimport { conditions } from \"helpers\";\r\nimport { setCommentPopover } from \"redux-share/slices/popoversSlice\";\r\nimport useIntersect from \"helpers/hooks/useIntersect\";\r\nimport { shallowEqual } from 'react-redux';\r\nimport dynamic from \"next/dynamic\";\r\n\r\nconst ChevronLeftIcon = dynamic(() => import(\"../../icon-components/chevronLeft\"));\r\nconst CommentsPopover = dynamic(() => import(\"./commentsPopover\"));\r\nconst SingleComment = dynamic(() => import(\"./singleComment\"));\r\nconst AddComment = dynamic(() => import(\"./addComment\"));\r\n\r\nconst Comments = () => {\r\n\r\n    const dispatch = useAppDispatch();\r\n    const { commentPopover } = useAppSelector(({ popovers: { commentPopover } }) => ({ commentPopover }), shallowEqual);\r\n    const { comments, commentsCount, usersCommentsProfiles } = useAppSelector(({ comments: { comments, commentsCount, usersCommentsProfiles } }) => ({ comments, commentsCount, usersCommentsProfiles }), shallowEqual);\r\n    const {loadedFragmentsCount} = useAppSelector(({ controller: { loadedFragmentsCount } }) => ({ loadedFragmentsCount }), shallowEqual);\r\n\r\n    const [scrollEnd, setScrollEnd] = useState<boolean>(false);\r\n    const handleIntersect = ([entry]: IntersectionObserverEntry[]) => {\r\n        const { comments, commentsCountPagination } = store.getState().comments\r\n        if (entry.isIntersecting && comments.length !== commentsCountPagination) setScrollEnd(true);\r\n    };\r\n\r\n    useEffect(() => {\r\n        if (!conditions(ConditionName.isTouchScreen) && conditions(ConditionName.hasPermittedLoadedFragment)) handleGetComments(0, setScrollEnd);\r\n    }, [loadedFragmentsCount.length])\r\n\r\n    useEffect(() => {\r\n        if (scrollEnd && comments.length) handleGetComments(comments.length, setScrollEnd);\r\n    }, [scrollEnd]);\r\n\r\n    const handleShowCommentsPopover = () => {\r\n        handleGetComments(0, setScrollEnd);\r\n        dispatch(setCommentPopover(true));\r\n    }\r\n\r\n    const observerRef = useIntersect(handleIntersect);\r\n\r\n    const commentsContent = conditions(ConditionName.isTouchScreen) ? (\r\n        <>\r\n            <div className=\"pl-flex pl-justify-between pl-items-center pl-mx-3 pl-bg-gray-highLight dark:pl-bg-dark-3 pl-p-4 pl-rounded-[8px] pl-my-4\" onClick={handleShowCommentsPopover}>\r\n                <p className=\"pl-text-[15px] pl-font-normal\">{!!commentsCount ? `نمایش ${commentsCount} دیدگاه` : \"دیدگاه خود را وارد کنید\"}</p>\r\n                <ChevronLeftIcon className=\"pl-w-4 pl-h-4 pl-stroke-gray-800/[0.7] dark:pl-stroke-secondary-300 -pl-rotate-90\" />\r\n            </div>\r\n            <CommentsPopover status={commentPopover} onClose={handleCloseCommentPopover} setScrollEnd={setScrollEnd} />\r\n        </>\r\n    ) : (\r\n        <>\r\n            <AddComment type=\"comment\" />\r\n            {comments.length > 0 && (\r\n                <div className=\"pl-flex pl-flex-col pl-gap-2 pl-mb-[80px] pl-mt-6\">\r\n                    {comments.map((comment: IComments) => <SingleComment key={comment.id} comment={comment} user={usersCommentsProfiles.find((profile: IUsersCommentsProfiles) => profile.id === comment.author)} commentsLocalStorageIds={handleCommentsIdsInLocalStorage()}/>)}\r\n                </div>\r\n            )}\r\n            <div id=\"observer\" className=\"pl-bg-transparent pl-pt-5\" ref={observerRef} />\r\n        </>\r\n    )\r\n\r\n    return (\r\n        <>\r\n            {commentsContent}\r\n        </>\r\n    )\r\n}\r\n\r\nexport default Comments;"],"mappings":"oNAAAA,IAAA,OAAS,aAAAC,EAAW,YAAAC,MAAgB,QAQpC,OAAS,gBAAAC,MAAoB,cAC7B,OAAOC,MAAa,eAoCZ,mBAAAC,EAEQ,OAAAC,EADJ,QAAAC,MADJ,oBAlCR,IAAMC,EAAkBJ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I,CAAC,CACpC,EAEMC,EAAcC,EAAaV,CAAe,EAE1CW,EAAkBN,iBAAsC,EAC1DtB,EAAAF,EAAA,CACI,UAAAE,EAAC,OAAI,UAAU,4HAA4H,QAASwB,EAChJ,UAAAzB,EAAC,KAAE,UAAU,gCAAiC,SAAEY,EAAgB,kCAASA,CAAa,wCAAY,yHAA0B,EAC5HZ,EAACE,EAAA,CAAgB,UAAU,oFAAoF,GACnH,EACAF,EAACG,EAAA,CAAgB,OAAQM,EAAgB,QAASqB,EAA2B,aAAcd,EAAc,GAC7G,EAEAf,EAAAF,EAAA,CACI,UAAAC,EAACK,EAAA,CAAW,KAAK,UAAU,EAC1BM,EAAS,OAAS,GACfX,EAAC,OAAI,UAAU,oDACV,SAAAW,EAAS,IAAKoB,GAAuB/B,EAACI,EAAA,CAA+B,QAAS2B,EAAS,KAAMlB,EAAsB,KAAMmB,GAAoCA,EAAQ,KAAOD,EAAQ,MAAM,EAAG,wBAAyBE,EAAgC,GAA7LF,EAAQ,EAAuL,CAAE,EAC/P,EAEJ/B,EAAC,OAAI,GAAG,WAAW,UAAU,4BAA4B,IAAK2B,EAAa,GAC/E,EAGJ,OACI3B,EAAAD,EAAA,CACK,SAAA8B,EACL,CAER,EAEOK,EAAQ5B","names":["init_esm_shims","useEffect","useState","shallowEqual","dynamic","Fragment","jsx","jsxs","ChevronLeftIcon","CommentsPopover","SingleComment","AddComment","Comments","dispatch","useAppDispatch","commentPopover","useAppSelector","comments","commentsCount","usersCommentsProfiles","loadedFragmentsCount","scrollEnd","setScrollEnd","useState","handleIntersect","entry","commentsCountPagination","store_default","useEffect","conditions","handleGetComments","handleShowCommentsPopover","setCommentPopover","observerRef","useIntersect_default","commentsContent","handleCloseCommentPopover","comment","profile","handleCommentsIdsInLocalStorage","comments_default"]}