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