mattermost-community-enterp.../client/2118.2b5d6bc4d9b0ec17b5b1.js
2025-12-18 00:51:24 +09:00

2 lines
25 KiB
JavaScript

"use strict";(self.webpackChunkmattermost_webapp=self.webpackChunkmattermost_webapp||[]).push([[2118],{84273:(e,t,i)=>{i.d(t,{Z:()=>u});var l=i(70314),n=i(19601),s=i(99566),a=i(23615),o=i.n(a),r=i(84390),c=i.n(r),d=i(70174);const m=e=>{let{fileInfo:t,fileUrl:i,canDownloadFiles:l}=e;const n=[];""!==t.extension&&n.push(d._u({id:"file_info_preview.type",defaultMessage:"File type "})+t.extension.toUpperCase()),t.size&&n.push(d._u({id:"file_info_preview.size",defaultMessage:"Size "})+d.eA(t.size));const s=n.join(", ");let a=null;return a=l?c().createElement("a",{className:"file-details__preview",href:i},c().createElement("span",{className:"file-details__preview-helper"}),c().createElement("img",{alt:"file preview",src:d.c2(t)})):c().createElement("span",{className:"file-details__preview"},c().createElement("span",{className:"file-details__preview-helper"}),c().createElement("img",{alt:"file preview",src:d.c2(t)})),c().createElement("div",{className:"file-details__container"},a,c().createElement("div",{className:"file-details"},c().createElement("div",{className:"file-details__name"},t.name),c().createElement("div",{className:"file-details__info"},s)))};m.propTypes={fileUrl:o().string.isRequired,canDownloadFiles:o().bool.isRequired};const p=c().memo(m),u=(0,l.connect)((function(e){const t=(0,n.iE)(e);return{canDownloadFiles:(0,s.qL)(t)}}))(p)},22118:(e,t,i)=>{i.r(t),i.d(t,{default:()=>ce});var l=i(23615),n=i.n(l),s=(i(61418),i(14078),i(92189),i(60042)),a=i.n(s),o=i(84390),r=i.n(o),c=i(11313),d=i(47407),m=i(72060),p=i(45448);function u(e){const t=(0,m.useIntl)().formatMessage({id:"workspace_limits.archived_file.archived",defaultMessage:"This file is archived"}),i=r().createElement("span",{className:"file-details__preview file-details__preview--archived"},r().createElement(p.ArchiveOutlineIcon,{size:80,color:"rgba(var(--center-channel-color-rgb), 0.48)","data-testid":"archived-file-icon"}));return r().createElement("div",{className:"file-details__container"},i,r().createElement("div",{className:"file-details"},r().createElement("div",{className:"file-details__name"},e.fileInfo.name),r().createElement("div",{className:"file-details__info"},t)))}var h=i(70314),f=i(61057),v=i(84273),g=i(23712);function E(e,t,i){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var l=i.call(e,"string");if("object"!=typeof l)return l;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}class b extends r().PureComponent{constructor(e){super(e),E(this,"sourceRef",r().createRef()),E(this,"videoRef",r().createRef()),E(this,"handleFileInfoChanged",(()=>{let e=this.videoRef.current;e||(e=document.createElement("video")),this.setState({canPlay:!0})})),E(this,"handleLoadError",(()=>{this.setState({canPlay:!1})})),E(this,"stop",(()=>{if(this.videoRef.current){const e=this.videoRef.current;e.pause(),e.currentTime=0}})),this.state={canPlay:!0}}componentDidMount(){this.handleFileInfoChanged(),this.sourceRef.current&&this.sourceRef.current.addEventListener("error",this.handleLoadError,{once:!0})}componentDidUpdate(e){this.props.fileUrl!==e.fileUrl&&this.handleFileInfoChanged(),this.sourceRef.current&&this.sourceRef.current.addEventListener("error",this.handleLoadError,{once:!0})}render(){if(!this.state.canPlay)return r().createElement(v.Z,{fileInfo:this.props.fileInfo,fileUrl:this.props.fileUrl});let e=g.default.WEB_VIDEO_WIDTH,t=g.default.WEB_VIDEO_HEIGHT;return this.props.isMobileView&&(e=g.default.MOBILE_VIDEO_WIDTH,t=g.default.MOBILE_VIDEO_HEIGHT),r().createElement("video",{key:this.props.fileInfo.id,ref:this.videoRef,"data-setup":"{}",controls:!0,width:e,height:t},r().createElement("source",{ref:this.sourceRef,src:this.props.fileUrl}))}}E(b,"propTypes",{fileUrl:n().string.isRequired,isMobileView:n().bool.isRequired});const w=(0,h.connect)((function(e){return{isMobileView:(0,f.E7)(e)}}))(b);var _=i(26337),I=i(49974);function y(e,t,i){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var l=i.call(e,"string");if("object"!=typeof l)return l;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}class C extends r().PureComponent{constructor(e){super(e),y(this,"getCode",(async()=>{if(this.state.lang&&!(this.props.fileInfo.size>g.default.CODE_PREVIEW_MAX_FILE_SIZE))try{const e=await fetch(this.props.fileUrl),t=await e.text();this.handleReceivedCode(t)}catch(e){this.handleReceivedError()}})),y(this,"handleReceivedCode",(async e=>{var t,i;let l=e;const n=e;"#document"===n.nodeName&&(l=(new XMLSerializer).serializeToString(n)),null===(t=(i=this.props).getContent)||void 0===t||t.call(i,l),this.setState({code:l,highlighted:await I.CH(this.state.lang,l),loading:!1,success:!0})})),y(this,"handleReceivedError",(()=>{this.setState({loading:!1,success:!1})})),this.state={code:"",lang:"",highlighted:"",loading:!0,success:!0}}componentDidMount(){this.getCode()}static getDerivedStateFromProps(e,t){if(e.fileUrl!==t.prevFileUrl){const t=I.iP(e.fileInfo.extension);return!t||e.fileInfo.size>g.default.CODE_PREVIEW_MAX_FILE_SIZE?{code:"",lang:"",loading:!1,success:!1,prevFileUrl:e.fileUrl}:{code:"",lang:t,loading:!0,prevFileUrl:e.fileUrl}}return null}componentDidUpdate(e){this.props.fileUrl!==e.fileUrl&&this.getCode()}static supports(e){return Boolean(I.iP(e.extension))}render(){if(this.state.loading)return r().createElement("div",{className:"view-image__loading"},r().createElement(_.Z,null));if(!this.state.success)return r().createElement(v.Z,{fileInfo:this.props.fileInfo,fileUrl:this.props.fileUrl});const e=I.vY(this.state.lang);return r().createElement("div",{className:"post-code code-preview"},r().createElement("span",{className:"post-code__language"},"".concat(this.props.fileInfo.name," - ").concat(e)),r().createElement("div",{className:"hljs"},r().createElement("div",{className:"post-code__line-numbers"},I.wj(this.state.code)),r().createElement("code",{dangerouslySetInnerHTML:{__html:this.state.highlighted}})))}}y(C,"propTypes",{fileUrl:n().string.isRequired,className:n().string.isRequired,getContent:n().func});var N=i(28933),P=i(35887),M=i(70174),R=(i(48410),i(43618)),L=i(23894),x=i(90835);const k=(0,L.RX)(),F=e=>{const t=(0,h.useSelector)((t=>{var i,l;return(0,L.PR)(t,null!==(i=null===(l=e.post)||void 0===l?void 0:l.user_id)&&void 0!==i?i:"")})),i=(0,h.useSelector)((t=>{var i,l;return(0,R.kL)()(t,null!==(i=null===(l=e.post)||void 0===l?void 0:l.channel_id)&&void 0!==i?i:"")})),l=(0,h.useSelector)((t=>{var i,l;return k(t,null!==(i=null===(l=e.post)||void 0===l?void 0:l.user_id)&&void 0!==i?i:"",!0)}));let n;const s=i?r().createElement(m.FormattedMessage,{id:"file_preview_modal_info.shared_in",defaultMessage:"Shared in ~{name}",values:{name:i.display_name||i.name}}):null;return n=e.showFileName?r().createElement(r().Fragment,null,r().createElement("h5",{className:"file-preview-modal__file-name"},e.filename),r().createElement("span",{className:"file-preview-modal__file-details"},r().createElement("span",{className:"file-preview-modal__file-details-user-name"},l),r().createElement("span",{className:"file-preview-modal__channel"},s))):r().createElement(r().Fragment,null,r().createElement("h5",{className:"file-preview-modal__user-name"},l),r().createElement("span",{className:"file-preview-modal__channel"},s)),r().createElement("div",{className:"file-preview-modal__info"},e.post&&Object.keys(e.post).length>0&&r().createElement(x.Z,{size:"lg",url:(0,M.bb)(e.post.user_id,null==t?void 0:t.last_picture_update),className:"file-preview-modal__avatar"}),r().createElement("div",{className:"file-preview-modal__info-details"},n))};F.propTypes={showFileName:n().bool.isRequired,filename:n().string.isRequired};const O=(0,o.memo)(F);var S=i(5352),D=i(75873),q=i(56062),Z=i(35683),U=i(34575);function j(e){return Boolean(e.id)}const T=e=>{const t=(0,m.useIntl)(),i="Header"===e.usedInside?"bottom":"top",l=(0,h.useSelector)((e=>{var t;return null===(t=(0,D.c9)(e))||void 0===t?void 0:t.link})),n=(0,h.useDispatch)(),[s,a]=(0,o.useState)(!1);(0,o.useEffect)((()=>{j(e.fileInfo)&&e.enablePublicLink&&n((0,S.c9)(e.fileInfo.id))}),[e.fileInfo,e.enablePublicLink]),(0,o.useEffect)((()=>{s&&setTimeout((()=>{a(!1)}),2e3)}),[s]);const c=t.formatMessage({id:"full_screen_modal.close",defaultMessage:"Close"}),d=r().createElement(U.Z,{id:"close-icon-tooltip",title:c,placement:i,key:"publicLink"},r().createElement("button",{className:"file-preview-modal-main-actions__action-item",onClick:e.handleModalClose,"aria-label":c},r().createElement("i",{className:"icon icon-close"})));let p;p=s?t.formatMessage({id:"file_preview_modal_main_actions.public_link-copied",defaultMessage:"Public link copied"}):t.formatMessage({id:"view_image_popover.publicLink",defaultMessage:"Get a public link"});const u=r().createElement(U.Z,{id:"link-variant-icon-tooltip.text",key:"filePreviewPublicLink",placement:i,title:p},r().createElement("a",{href:"#",className:"file-preview-modal-main-actions__action-item",onClick:()=>{(0,M.vQ)(null!=l?l:""),a(!0)},"aria-label":p},r().createElement("i",{className:"icon icon-link-variant"}))),f=t.formatMessage({id:"view_image_popover.download",defaultMessage:"Download"}),v=r().createElement(U.Z,{id:"download-icon-tooltip.text",key:"download",placement:i,title:f},r().createElement(Z.Z,{href:e.fileURL,className:"file-preview-modal-main-actions__action-item",location:"file_preview_modal_main_actions",download:e.filename,"aria-label":f},r().createElement("i",{className:"icon icon-download-outline"}))),E=r().createElement(q.Z,{className:"file-preview-modal-main-actions__action-item",isForText:(0,M.JB)(e.fileInfo.extension)===g.ml.TEXT,placement:i,content:e.content});return r().createElement("div",{className:"file-preview-modal-main-actions__actions"},!e.showOnlyClose&&e.canCopyContent&&E,!e.showOnlyClose&&e.enablePublicLink&&e.showPublicLink&&u,!e.showOnlyClose&&e.canDownloadFiles&&v,e.showClose&&d)};T.propTypes={usedInside:n().oneOf(["Header","Footer"]),showOnlyClose:n().bool,showClose:n().bool,showPublicLink:n().bool,filename:n().string.isRequired,fileURL:n().string.isRequired,enablePublicLink:n().bool.isRequired,canDownloadFiles:n().bool.isRequired,canCopyContent:n().bool.isRequired,handleModalClose:n().func.isRequired,content:n().string.isRequired},T.defaultProps={showOnlyClose:!1,usedInside:"Header",showClose:!0,showPublicLink:!0};const A=(0,o.memo)(T),z=["post"];const V=e=>{let{post:t}=e,i=function(e,t){if(null==e)return{};var i,l,n=function(e,t){if(null==e)return{};var i,l,n={},s=Object.keys(e);for(l=0;l<s.length;l++)i=s[l],t.indexOf(i)>=0||(n[i]=e[i]);return n}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(l=0;l<s.length;l++)i=s[l],t.indexOf(i)>=0||Object.prototype.propertyIsEnumerable.call(e,i)&&(n[i]=e[i])}return n}(e,z);return r().createElement("div",{className:"file-preview-modal-footer"},r().createElement(O,{showFileName:!1,post:t,filename:i.filename}),r().createElement(A,Object.assign({},i,{showClose:!1,usedInside:"Footer",showOnlyClose:!1})))};V.propTypes={filename:n().string.isRequired,fileURL:n().string.isRequired,showPublicLink:n().bool,enablePublicLink:n().bool.isRequired,canDownloadFiles:n().bool.isRequired,isExternalFile:n().bool.isRequired,handleModalClose:n().func.isRequired,canCopyContent:n().bool.isRequired,content:n().string.isRequired};const B=(0,o.memo)(V),H=e=>{const t=r().createElement(U.Z,{key:"previewArrowLeft",id:"close-icon-tooltip",title:r().createElement(m.FormattedMessage,{id:"generic.close",defaultMessage:"Close"}),placement:"bottom"},r().createElement("button",{id:"previewArrowLeft",className:"file_preview_modal_main_nav__prev",onClick:e.handlePrev},r().createElement("i",{className:"icon icon-chevron-left"}))),i=r().createElement(U.Z,{key:"publicLink",id:"close-icon-tooltip",title:r().createElement(m.FormattedMessage,{id:"generic.next",defaultMessage:"Next"}),placement:"bottom"},r().createElement("button",{id:"previewArrowRight",className:"file_preview_modal_main_nav__next",onClick:e.handleNext},r().createElement("i",{className:"icon icon-chevron-right"})));return r().createElement("div",{className:"file_preview_modal_main_nav"},t,r().createElement("span",{className:"modal-bar-file-count"},r().createElement(m.FormattedMessage,{id:"file_preview_modal_main_nav.file",defaultMessage:"{count, number} of {total, number}",values:{count:e.fileIndex+1,total:e.totalFiles}})),i)};H.propTypes={fileIndex:n().number.isRequired,totalFiles:n().number.isRequired,handlePrev:n().func.isRequired,handleNext:n().func.isRequired};const W=(0,o.memo)(H),G=["post","totalFiles","fileIndex"];const X=e=>{let{post:t,totalFiles:i,fileIndex:l}=e,n=function(e,t){if(null==e)return{};var i,l,n=function(e,t){if(null==e)return{};var i,l,n={},s=Object.keys(e);for(l=0;l<s.length;l++)i=s[l],t.indexOf(i)>=0||(n[i]=e[i]);return n}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(l=0;l<s.length;l++)i=s[l],t.indexOf(i)>=0||Object.prototype.propertyIsEnumerable.call(e,i)&&(n[i]=e[i])}return n}(e,G),s=r().createElement("div",null);i>1&&(s=r().createElement(W,{totalFiles:i,fileIndex:l,handlePrev:n.handlePrev,handleNext:n.handleNext}));const a=r().createElement(A,Object.assign({},n,{showOnlyClose:n.isMobileView,usedInside:"Header"}));return r().createElement("div",{className:"file-preview-modal-header"},n.isMobileView&&a,!n.isMobileView&&r().createElement(O,{showFileName:!0,post:t,filename:n.filename}),s,!n.isMobileView&&a)};X.propTypes={isMobileView:n().bool.isRequired,fileIndex:n().number.isRequired,totalFiles:n().number.isRequired,filename:n().string.isRequired,fileURL:n().string.isRequired,showPublicLink:n().bool,enablePublicLink:n().bool.isRequired,canDownloadFiles:n().bool.isRequired,canCopyContent:n().bool.isRequired,isExternalFile:n().bool.isRequired,handlePrev:n().func.isRequired,handleNext:n().func.isRequired,handleModalClose:n().func.isRequired,content:n().string.isRequired};const K=(0,o.memo)(X);function J(e){let t,i,{fileInfo:l,canDownloadFiles:n}=e;return l.id?(t=(0,d.gN)(l.id),i=l.has_preview_image?(0,d.iY)(l.id):t):(t=l.link,i=l.link),n?r().createElement("a",{className:"image_preview",href:"#"},r().createElement("img",{className:"image_preview__image",loading:"lazy","data-testid":"imagePreview",alt:"preview url image",src:i})):r().createElement("img",{src:i})}J.propTypes={canDownloadFiles:n().bool.isRequired};var Y,Q,$,ee=i(66726),te=i.n(ee);class ie extends r().PureComponent{render(){const e=[];let t=null;if(this.props.showZoomControls){let i,l,n;l=this.props.scale&&this.props.scale>g.v0.MIN_SCALE?r().createElement("span",{className:"modal-zoom-btn"},r().createElement("a",{onClick:this.props.handleZoomOut&&te()(this.props.handleZoomOut,300,{maxWait:300})},r().createElement("i",{className:"icon icon-minus"}))):r().createElement("span",{className:"btn-inactive"},r().createElement("i",{className:"icon icon-minus"})),e.push(r().createElement(U.Z,{key:"zoomOut",id:"zoom-out-icon-tooltip",title:r().createElement(m.FormattedMessage,{id:"view_image.zoom_out",defaultMessage:"Zoom Out"}),placement:"top"},l)),i=this.props.scale&&this.props.scale>g.v0.DEFAULT_SCALE?r().createElement("span",{className:"modal-zoom-btn"},r().createElement("a",{onClick:this.props.handleZoomReset},r().createElement("i",{className:"icon icon-magnify-minus"}))):this.props.scale&&this.props.scale<g.v0.DEFAULT_SCALE?r().createElement("span",{className:"modal-zoom-btn"},r().createElement("a",{onClick:this.props.handleZoomReset},r().createElement("i",{className:"icon icon-magnify-plus"}))):r().createElement("span",{className:"btn-inactive"},r().createElement("i",{className:"icon icon-magnify-minus"})),e.push(r().createElement(U.Z,{key:"zoomReset",id:"zoom-reset-icon-tooltip",title:r().createElement(m.FormattedMessage,{id:"view_image.zoom_reset",defaultMessage:"Reset Zoom"}),placement:"top"},i)),n=this.props.scale&&this.props.scale<g.v0.MAX_SCALE?r().createElement("span",{className:"modal-zoom-btn"},r().createElement("a",{onClick:this.props.handleZoomIn&&te()(this.props.handleZoomIn,300,{maxWait:300})},r().createElement("i",{className:"icon icon-plus"}))):r().createElement("span",{className:"btn-inactive"},r().createElement("i",{className:"icon icon-plus"})),e.push(r().createElement(U.Z,{key:"zoomIn",id:"zoom-in-icon-tooltip",title:r().createElement(m.FormattedMessage,{id:"view_image.zoom_in",defaultMessage:"Zoom In"}),placement:"top"},n)),t=r().createElement("div",{className:"modal-column"},e)}return r().createElement("div",{"data-testid":"fileCountFooter",className:"modal-button-bar file-preview-modal__zoom-bar"},t)}}Y=ie,Q="propTypes",$={scale:n().number,showZoomControls:n().bool,handleZoomIn:n().func,handleZoomOut:n().func,handleZoomReset:n().func},(Q=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var l=i.call(e,"string");if("object"!=typeof l)return l;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:String(t)}(Q))in Y?Object.defineProperty(Y,Q,{value:$,enumerable:!0,configurable:!0,writable:!0}):Y[Q]=$;const le=ie;function ne(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);t&&(l=l.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,l)}return i}function se(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?ne(Object(i),!0).forEach((function(t){ae(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):ne(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function ae(e,t,i){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var l=i.call(e,"string");if("object"!=typeof l)return l;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}const oe=r().lazy((()=>i.e(1500).then(i.bind(i,21500)))),re=g.default.KeyCodes;class ce extends r().PureComponent{constructor(e){super(e),ae(this,"handleNext",(()=>{let e=this.state.imageIndex+1;e>this.props.fileInfos.length-1&&(e=0),this.showImage(e)})),ae(this,"handlePrev",(()=>{let e=this.state.imageIndex-1;e<0&&(e=this.props.fileInfos.length-1),this.showImage(e)})),ae(this,"handleKeyPress",(e=>{P.p(e,re.RIGHT)?this.handleNext():P.p(e,re.LEFT)&&this.handlePrev()})),ae(this,"showImage",(e=>{this.setState({imageIndex:e});const t=window.innerHeight-100;this.setState({imageHeight:t}),this.state.loaded[e]||this.loadImage(e)})),ae(this,"loadImage",(e=>{const t=this.props.fileInfos[e];if(j(t)&&t.archived)this.handleImageLoaded(e);else if(M.JB(t.extension)===g.ml.IMAGE&&j(t)){let i;i=t.has_preview_image?(0,d.iY)(t.id):(0,d.qm)(t.id),M.po(i,(()=>this.handleImageLoaded(e)),(t=>this.handleImageProgress(e,t)))}else this.handleImageLoaded(e)})),ae(this,"handleImageLoaded",(e=>{this.setState((t=>({loaded:se(se({},t.loaded),{},{[e]:!0})})))})),ae(this,"handleImageProgress",((e,t)=>{this.setState((i=>({progress:se(se({},i.progress),{},{[e]:t})})))})),ae(this,"onMouseEnterImage",(()=>{this.setState({showCloseBtn:!0})})),ae(this,"onMouseLeaveImage",(()=>{this.setState({showCloseBtn:!1})})),ae(this,"setScale",((e,t)=>{this.setState((i=>({scale:se(se({},i.scale),{},{[e]:t})})))})),ae(this,"handleZoomIn",(()=>{let e=this.state.scale[this.state.imageIndex];e=Math.min(e+g.v0.SCALE_DELTA,g.v0.MAX_SCALE),this.setScale(this.state.imageIndex,e)})),ae(this,"handleZoomOut",(()=>{let e=this.state.scale[this.state.imageIndex];e=Math.max(e-g.v0.SCALE_DELTA,g.v0.MIN_SCALE),this.setScale(this.state.imageIndex,e)})),ae(this,"handleZoomReset",(()=>{this.setScale(this.state.imageIndex,g.v0.DEFAULT_SCALE)})),ae(this,"handleModalClose",(()=>{this.setState({show:!1})})),ae(this,"getContent",(e=>{this.setState({content:e})})),ae(this,"handleBgClose",(e=>{e.currentTarget===e.target&&this.handleModalClose()})),this.state={show:!0,imageIndex:this.props.startIndex,imageHeight:"100%",loaded:M.Wt(!1,this.props.fileInfos.length),prevFileInfosCount:0,progress:M.Wt(0,this.props.fileInfos.length),showCloseBtn:!1,showZoomControls:!1,scale:M.Wt(g.v0.DEFAULT_SCALE,this.props.fileInfos.length),content:""}}componentDidMount(){document.addEventListener("keyup",this.handleKeyPress),this.showImage(this.props.startIndex)}componentWillUnmount(){document.removeEventListener("keyup",this.handleKeyPress)}static getDerivedStateFromProps(e,t){const i={};return e.fileInfos[t.imageIndex]&&e.fileInfos[t.imageIndex].extension===g.ml.PDF?i.showZoomControls=!0:i.showZoomControls=!1,e.fileInfos.length!==t.prevFileInfosCount&&(i.loaded=M.Wt(!1,e.fileInfos.length),i.progress=M.Wt(0,e.fileInfos.length),i.prevFileInfosCount=e.fileInfos.length),Object.keys(i).length?i:null}render(){var e;if(this.props.fileInfos.length<1||this.props.fileInfos.length-1<this.state.imageIndex)return null;const t=this.props.fileInfos[this.state.imageIndex],i=M.JB(t.extension);let l,n,s,o,m,p=!1;j(t)?(l=!0,n=t.name,s=(0,d.qm)(t.id),o=(0,d.gN)(t.id),m=!1):(l=!1,n=t.name||t.link,s=t.link,o=t.link,m=!0);let h,f,E="a11y__modal modal-image file-preview-modal";if(j(t)&&t.archived&&(h=r().createElement(u,{fileInfo:t})),!j(t)||!t.archived)if(this.state.loaded[this.state.imageIndex])i===g.ml.IMAGE||i===g.ml.SVG?h=r().createElement(J,{fileInfo:t,canDownloadFiles:this.props.canDownloadFiles}):i===g.ml.VIDEO||i===g.ml.AUDIO?h=r().createElement(w,{fileInfo:t,fileUrl:s}):i===g.ml.PDF?(h=r().createElement("div",{className:"file-preview-modal__scrollable",onClick:this.handleBgClose},r().createElement(r().Suspense,{fallback:null},r().createElement(oe,{fileInfo:t,fileUrl:s,scale:this.state.scale[this.state.imageIndex],handleBgClose:this.handleBgClose}))),f=r().createElement(le,{scale:this.state.scale[this.state.imageIndex],showZoomControls:this.state.showZoomControls,handleZoomIn:this.handleZoomIn,handleZoomOut:this.handleZoomOut,handleZoomReset:this.handleZoomReset})):C.supports(t)?(E+=" modal-code",p=!0,h=r().createElement(C,{fileInfo:t,fileUrl:s,getContent:this.getContent,className:"file-preview-modal__code-preview"})):h=r().createElement(v.Z,{fileInfo:t,fileUrl:s});else{const e=M._u({id:"view_image.loading",defaultMessage:"Loading"}),t=Math.floor(this.state.progress[this.state.imageIndex]);h=r().createElement(N.Z,{loading:e,progress:t})}if(j(t)&&!t.archived)for(const e of this.props.pluginFilePreviewComponents)if(e.override(t,this.props.post)){h=r().createElement(e.component,{fileInfo:t,post:this.props.post,onModalDismissed:this.handleModalClose});break}return r().createElement(c.Modal,{show:this.state.show,onHide:this.handleModalClose,onExited:this.props.onExited,className:"modal-image file-preview-modal",dialogClassName:E,animation:!0,backdrop:!1,role:"dialog",style:{paddingLeft:0},"aria-labelledby":"viewImageModalLabel"},r().createElement(c.Modal.Body,{className:"file-preview-modal__body"},r().createElement("div",{className:"modal-image__wrapper",onClick:this.handleModalClose},r().createElement("div",{className:"file-preview-modal__main-ctr",onMouseEnter:this.onMouseEnterImage,onMouseLeave:this.onMouseLeaveImage,onClick:e=>e.stopPropagation()},r().createElement(c.Modal.Title,{componentClass:"div",id:"viewImageModalLabel",className:"file-preview-modal__title"},r().createElement(K,{isMobileView:this.props.isMobileView,post:this.props.post,showPublicLink:l,fileIndex:this.state.imageIndex,totalFiles:null===(e=this.props.fileInfos)||void 0===e?void 0:e.length,filename:n,fileURL:o,fileInfo:t,enablePublicLink:this.props.enablePublicLink,canDownloadFiles:this.props.canDownloadFiles,canCopyContent:p,isExternalFile:m,handlePrev:this.handlePrev,handleNext:this.handleNext,handleModalClose:this.handleModalClose,content:this.state.content}),f),r().createElement("div",{className:a()("file-preview-modal__content",{"file-preview-modal__content-scrollable":(!j(t)||!t.archived)&&this.state.loaded[this.state.imageIndex]&&i===g.ml.PDF}),onClick:this.handleBgClose},h),this.props.isMobileView&&r().createElement(B,{post:this.props.post,showPublicLink:l,filename:n,fileURL:o,fileInfo:t,enablePublicLink:this.props.enablePublicLink,canDownloadFiles:this.props.canDownloadFiles,canCopyContent:p,isExternalFile:m,handleModalClose:this.handleModalClose,content:this.state.content})))))}}ae(ce,"propTypes",{canDownloadFiles:n().bool.isRequired,enablePublicLink:n().bool.isRequired,isMobileView:n().bool.isRequired,pluginFilePreviewComponents:n().array,onExited:n().func.isRequired,postId:n().string,startIndex:n().number}),ae(ce,"defaultProps",{fileInfos:[],startIndex:0,pluginFilePreviewComponents:[]})}}]);
//# sourceMappingURL=2118.2b5d6bc4d9b0ec17b5b1.js.map