"use strict";var e=require('./../../ext-esm/tslib/tslib.es6.js'),s=require("react/jsx-runtime"),i=require("classnames"),a=require("@material-ui/core"),n=require("@material-ui/icons/Close"),l=require("@material-ui/icons/GetApp"),r=require("../GoogleDocsViewer/index.js"),o=require("../../utils/env.js"),t=require("../LoadingIndicator/LoadingIndicator.js"),c=require("./effects/useFileContent.js"),d=require("./styles.js");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var _=u(i),f=u(n),g=u(l);module.exports=function(i){var n=i.classes,l=i.open,u=i.fileUrl,m=i.fileName,p=void 0===m?"DocumentViewer":m,j=i.onClose,x=i.fileSize,h=i.webviewType,v=i["data-testid"],q=void 0===v?"DocumentViewer":v,w=d.useStyles(),N=c.useFileContent({fileUrl:u,fileName:p}),C=N.isLoading,b=N.fileContent;return o.isGoogleDocsPreviewEnabled?s.jsx(a.Dialog,e.__assign({open:l,onClose:j,classes:e.__assign(e.__assign({},n),{paper:_.default(w.paper,null==n?void 0:n.paper)})},{children:s.jsx(r,{webviewType:h,fileUrl:u,fileName:p,fileSize:x,onClose:j,width:"100%",height:"100%"})})):s.jsx(a.Dialog,e.__assign({classes:e.__assign(e.__assign({},n),{paper:_.default(w.paper,null==n?void 0:n.paper)}),open:l,onClose:j,onContextMenu:function(e){return e.stopPropagation()}},{children:s.jsxs("div",e.__assign({"data-testid":"".concat(q,"_file_").concat(p),className:w.root},{children:[s.jsxs("div",e.__assign({className:w.toolbar},{children:[s.jsx(a.Typography,e.__assign({"data-testid":"".concat(q,"_fileName")},{children:p})),s.jsxs("div",{children:[s.jsx(a.IconButton,e.__assign({size:"small",className:w.iconButton},{children:s.jsx("a",e.__assign({download:!0,href:u,target:"_blank",rel:"noopener noreferrer"},{children:s.jsx(g.default,{fontSize:"small"})}))})),s.jsx(a.IconButton,e.__assign({size:"small",onClick:j,className:w.iconButton},{children:s.jsx(f.default,{fontSize:"small"})}))]})]})),C&&s.jsx("div",e.__assign({className:w.frame},{children:s.jsx(t,{white:!1})})),!C&&s.jsx("div",e.__assign({className:w.frame},{children:s.jsx("div",e.__assign({className:w.sheet},{children:b}))}))]}))}))};
