"use strict";(self.webpackChunkseahub_frontend=self.webpackChunkseahub_frontend||[]).push([[6036],{32781:function(e,a,t){var r=t(23029),i=t(92901),l=t(39874),s=t(85501),n=t(9950),o=t(17119),d=t(65604),p=t(97011),c=t(40326),u=t(49403),m=t(51925),f=t(68238),h=t.n(f),g=t(72517),x=t.n(g),b=t(38804),v=t(6030),F=t(33151),U=t(68879),j=t(18849),A=t(44414),k="uploading",y="error",S="isSaving",N="uploaded",w=function(e){function a(e){var t;return(0,r.A)(this,a),(t=(0,l.A)(this,a,[e])).onUploadCancel=function(e){e.preventDefault(),t.props.onUploadCancel(t.props.resumableFile)},t.onUploadRetry=function(e){e.preventDefault(),t.props.onUploadRetry(t.props.resumableFile)},t.formatFileSize=function(e){return"number"!==typeof e?"":e>=1e9?(e/1e9).toFixed(1)+" G":e>=1e6?(e/1e6).toFixed(1)+" M":e>=1e3?(e/1e3).toFixed(1)+" K":e.toFixed(1)+" B"},t.state={uploadState:k},t}return(0,s.A)(a,e),(0,i.A)(a,[{key:"UNSAFE_componentWillReceiveProps",value:function(e){var a=e.resumableFile,t=k;a.error?t=y:(0!==a.remainingTime||a.isSaved||(t=S),a.isSaved&&(t=N)),this.setState({uploadState:t})}},{key:"render",value:function(){var e=this.props.resumableFile,a=Math.round(100*e.progress()),t=e.error;return(0,A.jsxs)("tr",{className:"file-upload-item",children:[(0,A.jsx)("td",{className:"upload-name",children:(0,A.jsx)("div",{className:"ellipsis",children:e.newFileName})}),(0,A.jsx)("td",{children:(0,A.jsx)("span",{className:"file-size",children:this.formatFileSize(e.size)})}),(0,A.jsxs)("td",{className:"upload-progress",children:[(this.state.uploadState===k||this.state.uploadState===S)&&(0,A.jsxs)(n.Fragment,{children:[e.size>=1e8&&(0,A.jsxs)(n.Fragment,{children:[e.isUploading()&&(0,A.jsxs)("div",{className:"progress-container",children:[(0,A.jsx)("div",{className:"progress",children:(0,A.jsx)("div",{className:"progress-bar",role:"progressbar",style:{width:"".concat(a,"%")},"aria-valuenow":a,"aria-valuemin":"0","aria-valuemax":"100"})}),-1===e.remainingTime&&(0,A.jsx)("div",{className:"progress-text",children:(0,c.AP)("Preparing to upload...")}),e.remainingTime>0&&(0,A.jsxs)("div",{className:"progress-text",children:[(0,c.AP)("Remaining")," ",d.Aq.formatTime(e.remainingTime)]}),0===e.remainingTime&&(0,A.jsx)("div",{className:"progress-text",children:(0,c.AP)("Saving...")})]}),!e.isUploading()&&(0,A.jsx)("div",{className:"progress-container d-flex align-items-center",children:(0,A.jsx)("div",{className:"progress",children:(0,A.jsx)("div",{className:"progress-bar",role:"progressbar",style:{width:"".concat(a,"%")},"aria-valuenow":a,"aria-valuemin":"0","aria-valuemax":"100"})})})]}),e.size<1e8&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("div",{className:"progress-container d-flex align-items-center",children:(0,A.jsx)("div",{className:"progress",children:(0,A.jsx)("div",{className:"progress-bar",role:"progressbar",style:{width:"".concat(a,"%")},"aria-valuenow":a,"aria-valuemin":"0","aria-valuemax":"100"})})}),this.state.uploadState===k&&(0,A.jsxs)(A.Fragment,{children:[0==a&&(0,A.jsx)("p",{className:"progress-text mb-0",children:(0,c.AP)("Waiting...")}),a>0&&(0,A.jsx)("p",{className:"progress-text mb-0",children:"".concat((0,c.AP)("Uploading...")," ").concat(a,"%")})]}),this.state.uploadState===S&&(0,A.jsx)("p",{className:"progress-text mb-0",children:(0,c.AP)("Saving...")})]})]}),this.state.uploadState===N&&(0,A.jsxs)("div",{className:"d-flex align-items-center",children:[(0,A.jsx)("span",{className:"upload-success-icon sf2-icon-tick mr-2"}),(0,A.jsx)("span",{className:"upload-success-msg",children:(0,c.AP)("Uploaded")})]}),this.state.uploadState===y&&(0,A.jsxs)("div",{className:"d-flex align-items-center",children:[(0,A.jsx)("span",{className:"upload-failure-icon sf3-font sf3-font-info mr-2"}),(0,A.jsx)("span",{className:"upload-failure-msg",dangerouslySetInnerHTML:{__html:t}})]})]}),(0,A.jsx)("td",{className:"upload-operation",children:(0,A.jsxs)(n.Fragment,{children:[this.state.uploadState===k&&(0,A.jsx)("a",{href:"#",onClick:this.onUploadCancel,role:"button",children:(0,c.AP)("Cancel")}),this.state.uploadState===y&&(0,A.jsx)("a",{href:"#",onClick:this.onUploadRetry,role:"button",children:(0,c.AP)("Retry")})]})})]})}}])}(n.Component),C=function(e){function a(){return(0,r.A)(this,a),(0,l.A)(this,a,arguments)}return(0,s.A)(a,e),(0,i.A)(a,[{key:"render",value:function(){var e=this.props.file;return(0,A.jsxs)("tr",{className:"file-upload-item",children:[(0,A.jsx)("td",{className:"upload-name",children:(0,A.jsx)("div",{className:"ellipsis",children:e.name})}),(0,A.jsx)("td",{children:d.Aq.bytesToSize(e.size)}),(0,A.jsx)("td",{children:(0,A.jsxs)("div",{className:"d-flex align-items-center",children:[(0,A.jsx)("span",{className:"upload-failure-icon sf3-font sf3-font-info mr-2"}),(0,A.jsx)("span",{className:"upload-failure-msg",children:(0,c.AP)("File too large")})]})}),(0,A.jsx)("td",{})]})}}])}(n.Component),P=C,L=function(e){function a(e){var t;return(0,r.A)(this,a),(t=(0,l.A)(this,a,[e])).toggleDropdown=function(){t.setState({dropdownOpen:!t.state.dropdownOpen})},t.onDropdownToggleKeyDown=function(e){"Enter"!=e.key&&"Space"!=e.key||t.toggleDropdown()},t.onMenuItemKeyDown=function(e){"Enter"!=e.key&&"Space"!=e.key||e.target.click()},t.state={dropdownOpen:!1},t}return(0,s.A)(a,e),(0,i.A)(a,[{key:"render",value:function(){var e,a=this,t=this.props,r=t.totalProgress,i=t.uploadBitrate,l=t.uploadFileList,s=t.forbidUploadFileList,o=t.isUploading,p=(0,c.AP)("{uploaded_files_num}/{all_files_num} Files").replace("{uploaded_files_num}",l.filter((function(e){return e.isSaved})).length).replace("{all_files_num}",l.length);if(!o){var u=l.filter((function(e){return e.error})).length+s.length;u>0&&(e=(0,c.AP)("{failed_files_num} file(s) failed to upload").replace("{failed_files_num}",u))}return(0,A.jsxs)(n.Fragment,{children:[(0,A.jsxs)("div",{className:"text-center",children:[(0,A.jsxs)(b.A,{isOpen:this.state.dropdownOpen,toggle:this.toggleDropdown,children:[(0,A.jsx)(v.A,{color:"primary",caret:!0,onKeyDown:this.onDropdownToggleKeyDown,children:(0,c.AP)("Upload")}),(0,A.jsxs)(F.A,{children:[(0,A.jsx)(U.A,{onClick:this.props.onFileUpload,onKeyDown:this.onMenuItemKeyDown,children:(0,c.AP)("Upload Files")}),(0,A.jsx)(U.A,{onClick:this.props.onFolderUpload,onKeyDown:this.onMenuItemKeyDown,children:(0,c.AP)("Upload Folder")})]})]}),(0,A.jsx)(j.A,{color:"primary",outline:!0,className:"ml-4",onClick:this.props.onCancelAllUploading,disabled:!o,children:(0,c.AP)("Cancel All")})]}),r>0&&(0,A.jsxs)("div",{id:"upload-link-total-progress-container",className:"".concat(o?"":"d-flex align-items-center"," px-6 py-2"),children:[(0,A.jsxs)("div",{className:"d-flex align-items-center flex-fill",children:[o?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("span",{children:(0,c.AP)("File Uploading...")}),(0,A.jsx)("span",{className:"ml-2",children:"".concat(r,"% (").concat(d.Aq.formatBitRate(i),")")})]}):(0,A.jsx)(A.Fragment,{children:e?(0,A.jsx)("p",{className:"m-0 error",children:e}):(0,A.jsx)("p",{className:"m-0",children:(0,c.AP)("All files uploaded")})}),l.length>0&&(0,A.jsx)("span",{className:"ml-auto",children:p})]}),o&&(0,A.jsx)("div",{className:"progress",children:(0,A.jsx)("div",{className:"progress-bar",role:"progressbar",style:{width:"".concat(r,"%")},"aria-valuenow":r,"aria-valuemin":"0","aria-valuemax":"100"})})]}),(0,A.jsx)("div",{className:"mh-2",children:(0,A.jsxs)("table",{className:"table-thead-hidden",children:[(0,A.jsx)("thead",{children:(0,A.jsxs)("tr",{children:[(0,A.jsx)("th",{width:"40%",scope:"col",children:(0,c.AP)("name")}),(0,A.jsx)("th",{width:"15%",scope:"col",children:(0,c.AP)("size")}),(0,A.jsx)("th",{width:"30%",scope:"col",children:(0,c.AP)("progress")}),(0,A.jsx)("th",{width:"15%",scope:"col",children:(0,c.AP)("state")})]})}),(0,A.jsxs)("tbody",{children:[this.props.forbidUploadFileList.map((function(e,a){return(0,A.jsx)(P,{file:e},a)})),this.props.uploadFileList.map((function(e,t){return(0,A.jsx)(w,{resumableFile:e,onUploadCancel:a.props.onUploadCancel,onUploadRetry:a.props.onUploadRetry},t)})).reverse()]})]})})]})}}])}(n.Component),D=t(4086),I=(t(89183),function(e){function a(e){var t;return(0,r.A)(this,a),(t=(0,l.A)(this,a,[e])).componentWillUnmount=function(){window.onbeforeunload=null,!0===t.props.dragAndDrop&&t.resumable.disableDropOnDocument()},t.onbeforeunload=function(){if(window.uploader&&window.uploader.isUploadProgressDialogShow&&100!==window.uploader.totalProgress)return""},t.bindCallbackHandler=function(){var e=t.props,a=e.minFileSizeErrorCallback,r=e.fileTypeErrorCallback;t.maxFilesErrorCallback&&(t.resumable.opts.maxFilesErrorCallback=t.maxFilesErrorCallback),a&&(t.resumable.opts.minFileSizeErrorCallback=t.props.minFileSizeErrorCallback),t.maxFileSizeErrorCallback&&(t.resumable.opts.maxFileSizeErrorCallback=t.maxFileSizeErrorCallback),r&&(t.resumable.opts.fileTypeErrorCallback=t.props.fileTypeErrorCallback)},t.bindEventHandler=function(){t.resumable.on("chunkingComplete",t.onChunkingComplete.bind(t)),t.resumable.on("fileAdded",t.onFileAdded.bind(t)),t.resumable.on("fileProgress",t.onFileProgress.bind(t)),t.resumable.on("fileSuccess",t.onFileUploadSuccess.bind(t)),t.resumable.on("fileError",t.onFileError.bind(t)),t.resumable.on("uploadStart",t.onUploadStart.bind(t)),t.resumable.on("progress",t.onProgress.bind(t)),t.resumable.on("complete",t.onComplete.bind(t)),t.resumable.on("error",t.onError.bind(t)),t.resumable.on("dragstart",t.onDragStart.bind(t))},t.maxFilesErrorCallback=function(e,a){var t=c.YX,r=(0,c.AP)("Please upload no more than {maxFiles} files at a time.");r=r.replace("{maxFiles}",t),D.A.danger(r)},t.maxFileSizeErrorCallback=function(e){var a=t.state.forbidUploadFileList;a.push(e),t.setState({forbidUploadFileList:a})},t.onChunkingComplete=function(e){var a=t.props.path,r=e.fileName,i=e.relativePath,l=r===i;if(e.formData={},l)e.formData={parent_dir:a};else{var s=i.slice(0,i.lastIndexOf("/")+1);e.formData={parent_dir:a,relative_path:s}}},t.onFileAdded=function(e,a){if(e.fileName===e.relativePath&&1===a.length){t.setUploadFileList(t.resumable.files),p.e.sharedUploadLinkGetFileUploadUrl(t.props.token).then((function(a){t.resumable.opts.target=a.data.upload_link+"?ret-json=1",t.resumableUpload(e)})).catch((function(e){var a=d.Aq.getErrorMsg(e);D.A.danger(a)}))}else t.setUploadFileList(t.resumable.files),t.isUploadLinkLoaded||(t.isUploadLinkLoaded=!0,p.e.sharedUploadLinkGetFileUploadUrl(t.props.token).then((function(e){t.resumable.opts.target=e.data.upload_link+"?ret-json=1",t.resumable.upload()})).catch((function(e){var a=d.Aq.getErrorMsg(e);D.A.danger(a)})))},t.resumableUpload=function(e){var a=t.props,r=a.repoID,i=a.path;p.e.getFileUploadedBytes(r,i,e.fileName).then((function(a){var r=a.data.uploadedBytes,i=1024*parseInt(c.QV)*1024||1048576,l=Math.floor(r/i);e.markChunksCompleted(l),t.resumable.upload()})).catch((function(e){var a=d.Aq.getErrorMsg(e);D.A.danger(a)}))},t.filesAddedComplete=function(e,a){t.state.forbidUploadFileList.length>0&&0===a.length&&t.setState({isUploadProgressDialogShow:!0,totalProgress:100})},t.setUploadFileList=function(){var e=t.resumable.files;t.setState({uploadFileList:e,isUploadProgressDialogShow:!0}),d.Aq.registerGlobalVariable("uploader","isUploadProgressDialogShow",!0)},t.onFileProgress=function(e){var a=t.getBitrate(),r=t.state.uploadFileList.map((function(t){if(t.uniqueIdentifier===e.uniqueIdentifier&&a){var r=8*(t.size-t.size*t.progress()),i=Math.floor(r/a);t.remainingTime=i}return t}));t.setState({uploadBitrate:a,uploadFileList:r})},t.getBitrate=function(){var e=0,a=0,r=(new Date).getTime();if(t.resumable.files.forEach((function(a){e+=a.progress()*a.size})),t.timestamp){var i=r-t.timestamp;if(i'.concat(d.Aq.HTMLescape(E),""))}}),(0,A.jsx)("p",{className:"small shared-by",dangerouslySetInnerHTML:{__html:"".concat((0,c.AP)("shared by:")," ").concat(M.avatar," ").concat(M.name)}}),T?(0,A.jsxs)("div",{className:"py-6 text-center",children:[(0,A.jsx)("span",{className:"sf3-font sf3-font-tips warning-icon"}),(0,A.jsx)("p",{children:(0,c.AP)("The owner of this library has run out of space.")})]}):(0,A.jsxs)(n.Fragment,{children:[B&&(0,A.jsx)("p",{className:"small text-gray m-0",children:(0,c.AP)("File size should be smaller than {max_size_placeholder}.").replace("{max_size_placeholder}",d.Aq.bytesToSize(1e3*B*1e3))}),(0,A.jsxs)("div",{id:"upload-link-drop-zone",className:"text-center mt-2 mb-4",children:[(0,A.jsx)("span",{className:"sf3-font sf3-font-upload upload-icon"}),(0,A.jsx)("p",{className:"small text-gray mb-0",children:(0,c.AP)("Drag and drop files or folders here.")})]}),(0,A.jsx)(_,{ref:function(a){return e.uploader=a},dragAndDrop:!0,token:R,repoID:O,path:H,onFileUploadSuccess:this.onFileUploadSuccess})]})]})})]})}}])}(n.Component);o.render((0,A.jsx)(K,{}),document.getElementById("wrapper"))}},function(e){e.O(0,[4223],(function(){return a=32781,e(e.s=a);var a}));e.O()}]);