import t from"@babel/runtime/helpers/slicedToArray";import{memo as e,useState as o}from"react";import{makeStyles as n,Menu as i,MenuItem as r}from"@material-ui/core";import a from"@material-ui/icons/MoreVert";import l from"react-player";import c from"../../IconButton/index.js";import{getIsVideo as d}from"../../../utils/fileExtension.js";import{jsxs as m,Fragment as u,jsx as s}from"react/jsx-runtime";var p=n((function(t){return{actionsIconButtonRoot:{marginLeft:5,color:t.palette.primary.text7}}})),f=e((function(e){var n,f,h,v,_=e.feedItem,k=e.copyFeedItemLink,I=e.currentUser,P=e.isEditableItem,g=e.canDeleteFeedItem,B=e.handleEditMenuItem,y=e.handleDeleteMenuItem,C=e.isPost,F=p(),x=o(null),E=t(x,2),b=E[0],w=E[1],D=(null===(n=_.user)||void 0===n?void 0:n.id)===I.id,L=null===(f=_.context)||void 0===f||null===(h=f.post)||void 0===h||null===(v=h.attachment)||void 0===v?void 0:v.url,j=d(L)&&l.canPlay(L),z=function(t){t.stopPropagation(),w(null)},M=P&&D,A=g||M,N=C&&j;return M||A||N?m(u,{children:[s(c,{"data-testid":"".concat("FeedPo","_menuButton"),"aria-label":"Actions","aria-owns":b?"c-feed-item__actions-menu":void 0,"aria-haspopup":"true",className:F.actionsIconButtonRoot,size:"small",onClick:function(t){t.stopPropagation(),w(t.currentTarget)},children:s(a,{})}),m(i,{id:"c-feed-item__actions-menu",anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},anchorEl:b,open:!!b,onClick:z,onClose:z,children:[N&&s("a",{href:L,className:"c-feed-item__download-link",children:s(r,{"data-testid":"".concat("FeedPo","_downloadButton"),children:"Download"})}),M&&s(r,{"data-testid":"".concat("FeedPo","_editButton"),onClick:B,children:"Edit"}),A&&s(r,{"data-testid":"".concat("FeedPo","_deleteButton"),onClick:y,children:"Delete"}),s(r,{"data-testid":"".concat("FeedPo","_copyLinkButton"),onClick:k,children:"Copy Link"})]})]}):null}));export{f as default};
