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