Local modifications to ClusterLabs/Anvil by Alteeve
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

1 lines
23 KiB

(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[941],{8283:function(e,n,r){(window.__NEXT_P=window.__NEXT_P||[]).push(["/file-manager",function(){return r(32)}])},9297:function(e,n,r){"use strict";r.d(n,{C:function(){return d},k:function(){return x}});var t=r(5893),o=r(1458),i=r(1496),a=r(7169),l=(0,i.ZP)(o.Z)({height:"1em",borderRadius:a.n_,backgroundColor:a.v9});function c(e,n,r){return n in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}var u="AllocationBar",s={barOk:"".concat(u,"-barOk"),barWarning:"".concat(u,"-barWarning"),barAlert:"".concat(u,"-barAlert"),underline:"".concat(u,"-underline")},f=(0,i.ZP)("div")((function(){var e;return c(e={},"& .".concat(s.barOk),{backgroundColor:a.Ej}),c(e,"& .".concat(s.barWarning),{backgroundColor:a.Wd}),c(e,"& .".concat(s.barAlert),{backgroundColor:a.hM}),c(e,"& .".concat(s.underline),{borderRadius:a.n_}),e})),d=function(e){var n=e.allocated;return(0,t.jsxs)(f,{children:[(0,t.jsx)(l,{classes:{bar:n>70?n>90?s.barAlert:s.barWarning:s.barOk},variant:"determinate",value:n}),(0,t.jsx)(o.Z,{className:s.underline,variant:"determinate",value:0})]})};function p(e,n,r){return n in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}var v="ProgressBar",h={barOk:"".concat(v,"-barOk"),barInProgress:"".concat(v,"-barInProgress"),underline:"".concat(v,"-underline")},m=(0,i.ZP)("div")((function(){var e;return p(e={},"& .".concat(h.barOk),{backgroundColor:a.Ej}),p(e,"& .".concat(h.barInProgress),{backgroundColor:a.Wd}),p(e,"& .".concat(h.underline),{borderRadius:a.n_}),e})),x=function(e){var n=e.progressPercentage;return(0,t.jsxs)(m,{children:[(0,t.jsx)(l,{classes:{bar:n<100?h.barInProgress:h.barOk},variant:"determinate",value:n}),(0,t.jsx)(o.Z,{className:h.underline,variant:"determinate",value:0})]})}},1706:function(e,n,r){"use strict";r.d(n,{Z:function(){return a}});var t=r(1496),o=r(3946),i=r(7169),a=(0,t.ZP)(o.Z)({borderRadius:i.n_,backgroundColor:i.s7,"&:hover":{backgroundColor:i.lD},color:i.E5})},1200:function(e,n){"use strict";function r(e,n){(null==n||n>e.length)&&(n=e.length);for(var r=0,t=new Array(n);r<n;r++)t[r]=e[r];return t}function t(e){return function(e){if(Array.isArray(e))return r(e)}(e)||function(e){if("undefined"!==typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,n){if(!e)return;if("string"===typeof e)return r(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return r(e,n)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}n.Z=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return fetch.apply(void 0,t(n)).then((function(e){return e.json()}))}},1905:function(e,n,r){"use strict";var t=r(2515),o=r(1200);n.Z=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=n.refreshInterval,i=void 0===r?5e3:r,a=n.onSuccess,l=(0,t.ZP)(e,o.Z,{refreshInterval:i,onSuccess:a}),c=l.data,u=l.error;return{data:c,isLoading:!u&&!c,isError:u}}},32:function(e,n,r){"use strict";r.r(n),r.d(n,{default:function(){return Qe}});var t,o=r(5893),i=r(9008),a=r(4051),l=r.n(a),c=r(7294),u=r(7357),s=r(2428),f=r(2026),d=r(1797),p=r(5293),v=r.n(p),h=null===(t="/cgi-bin")?void 0:t.replace("/cgi-bin","/api"),m=r(7169),x=r(8128),y=r(3631),b=r(8262),g=r(1496),j=r(3321),w=(0,g.ZP)(j.Z)({backgroundColor:m.lD,color:m.E5,textTransform:"none","&:hover":{backgroundColor:m.s7}}),Z=function(e){var n=e.children,r=e.onClick,t=e.sx,i=e.type;return(0,o.jsx)(w,{onClick:r,sx:t,type:i,variant:"contained",children:n})},C=r(9203),P=r(3430),k={actionCancelText:"Cancel",proceedButtonProps:{sx:void 0}},S=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:k,n=e.actionCancelText,r=e.actionProceedText,t=e.contentText,i=e.dialogProps.open,a=e.onCancel,l=e.onProceed,c=e.proceedButtonProps,s=e.titleText,f=null!==c&&void 0!==c?c:k.proceedButtonProps,d=f.sx;return(0,o.jsxs)(b.Z,{open:i,PaperComponent:C.s_,children:[(0,o.jsx)(C.V9,{children:(0,o.jsx)(P.z,{text:s})}),(0,o.jsx)(P.A,{sx:{marginBottom:"1em"},text:t}),(0,o.jsxs)(u.Z,{sx:{display:"flex",flexDirection:"row",justifyContent:"flex-end",width:"100%","& > :not(:first-child)":{marginLeft:".5em"}},children:[(0,o.jsx)(Z,{onClick:a,children:n}),(0,o.jsx)(Z,{sx:d,onClick:l,children:r})]})]})};S.defaultProps=k;var A,O=S,I=r(2366),U=r(5603),D=r(40),F=r(2429),E=r(3457),L=r(4054),T=r(480),N=r(267),_=r(1925),R=r(5934),M=[["iso",["application/x-cd-image","ISO (optical disc)"]],["other",["text/plain","Other file type"]],["script",["text/plain","Script (program)"]]],B=new Map(M),W=r(7709),V=r(4656);function $(e,n,r){return n in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}var z=(0,g.ZP)(W.Z)(($(A={color:m.s7},"& .".concat(V.Z.notchedOutline),{borderColor:m.UZ}),$(A,"&:hover",$({},"& .".concat(V.Z.notchedOutline),{borderColor:m.s7})),$(A,"&.".concat(V.Z.focused),$({color:m.lD},"& .".concat(V.Z.notchedOutline),{borderColor:m.s7,"& legend":{paddingRight:"1.2em"}})),A)),G=r(3340),X=r(6727);var J=function(e){var n,r,t,i=e.children,a=e.htmlFor;return(0,o.jsx)(G.Z,{htmlFor:a,sx:(n={color:m.s7},r="&.".concat(X.Z.focused),t={backgroundColor:m.s7,borderRadius:m.n_,color:m.E5,padding:".1em .6em"},r in n?Object.defineProperty(n,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[r]=t,n),variant:"outlined",children:i})};function Y(e,n){(null==n||n>e.length)&&(n=e.length);for(var r=0,t=new Array(n);r<n;r++)t[r]=e[r];return t}function q(e,n,r){return n in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}function H(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){var r=null==e?null:"undefined"!==typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var t,o,i=[],a=!0,l=!1;try{for(r=r.call(e);!(a=(t=r.next()).done)&&(i.push(t.value),!n||i.length!==n);a=!0);}catch(c){l=!0,o=c}finally{try{a||null==r.return||r.return()}finally{if(l)throw o}}return i}}(e,n)||function(e,n){if(!e)return;if("string"===typeof e)return Y(e,n);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Y(e,n)}(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var K,Q={isReadonly:void 0,onChange:void 0},ee=(0,g.ZP)(I.Z)(q({},"& .".concat(U.Z.icon),{color:m.s7})),ne=(0,g.ZP)(D.Z)((q(K={backgroundColor:m.lD,paddingRight:"3em"},"&.".concat(F.Z.selected),{backgroundColor:m.s7,fontWeight:400,"&:hover":{backgroundColor:m.s7}}),q(K,"&:hover",{backgroundColor:m.s7}),K)),re=(0,g.ZP)(x.Z)(q({color:m.hM},"&.".concat(y.Z.checked),{color:m.Ej})),te=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Q,n=e.fileName,r=e.fileType,t=e.fileLocations,i=e.isReadonly,a=e.onChange,l=(0,R.Z)(),c="file-name-".concat(l),u="File name",s="file-type-".concat(l),f="File type";return(0,o.jsxs)(E.Z,{sx:{"> :not(:first-child)":{marginTop:"1em"}},children:[(0,o.jsxs)(L.Z,{children:[(0,o.jsx)(J,{htmlFor:c,children:u}),(0,o.jsx)(z,{defaultValue:n,disabled:i,id:c,label:u,onChange:function(e){var r=e.target.value;null===a||void 0===a||a.call(null,{fileName:r===n?void 0:r})}})]}),r&&(0,o.jsxs)(L.Z,{children:[(0,o.jsx)(J,{htmlFor:s,children:f}),(0,o.jsx)(ee,{defaultValue:r,disabled:i,id:s,input:(0,o.jsx)(z,{label:f}),onChange:function(e){var n=e.target.value;null===a||void 0===a||a.call(null,{fileType:n===r?void 0:n})},children:M.map((function(e){var n=H(e,2),r=n[0],t=H(n[1],2)[1];return(0,o.jsx)(ne,{value:r,children:t},r)}))})]}),t.map((function(e,n){var r=e.anvilName,t=e.anvilDescription,l=e.anvilUUID,c=e.isFileLocationActive;return(0,o.jsx)(T.Z,{control:(0,o.jsx)(re,{checkedIcon:(0,o.jsx)(N.Z,{}),defaultChecked:c,disabled:i,icon:(0,o.jsx)(_.Z,{}),onChange:function(e){var r=e.target.checked;null===a||void 0===a||a.call(null,{isFileLocationActive:r===c?void 0:r},{fileLocationIndex:n})}}),label:"".concat(r,": ").concat(t),sx:{color:m.lD},value:"".concat(l,"-sync")},l)}))]})};te.defaultProps=Q;var oe,ie=te,ae=r(2152),le=r(1200),ce=new(r(9669).Axios)({baseURL:null===(oe="/cgi-bin")?void 0:oe.replace("/cgi-bin","/api")});function ue(e,n){(null==n||n>e.length)&&(n=e.length);for(var r=0,t=new Array(n);r<n;r++)t[r]=e[r];return t}function se(e,n,r,t,o,i,a){try{var l=e[i](a),c=l.value}catch(u){return void r(u)}l.done?n(c):Promise.resolve(c).then(t,o)}function fe(e){return function(){var n=this,r=arguments;return new Promise((function(t,o){var i=e.apply(n,r);function a(e){se(i,t,o,a,l,"next",e)}function l(e){se(i,t,o,a,l,"throw",e)}a(void 0)}))}}function de(e,n,r){return n in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}function pe(e){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{},t=Object.keys(r);"function"===typeof Object.getOwnPropertySymbols&&(t=t.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),t.forEach((function(n){de(e,n,r[n])}))}return e}function ve(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){var r=null==e?null:"undefined"!==typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var t,o,i=[],a=!0,l=!1;try{for(r=r.call(e);!(a=(t=r.next()).done)&&(i.push(t.value),!n||i.length!==n);a=!0);}catch(c){l=!0,o=c}finally{try{a||null==r.return||r.return()}finally{if(l)throw o}}return i}}(e,n)||function(e,n){if(!e)return;if("string"===typeof e)return ue(e,n);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return ue(e,n)}(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var he={onEditFilesComplete:void 0,onPurgeFilesComplete:void 0},me=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:he,n=e.filesOverview,r=e.onEditFilesComplete,t=e.onPurgeFilesComplete,i=(0,c.useState)([]),a=i[0],s=i[1],f=(0,c.useState)([]),d=f[0],p=f[1],v=(0,c.useState)(!1),b=v[0],g=v[1],j=(0,c.useState)(!1),w=j[0],C=j[1],P=(0,c.useState)(0),k=P[0],S=P[1],A={backgroundColor:m.hM,color:m.lD,"&:hover":{backgroundColor:m.hM}},I=function(e){return function(n){var r=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).fileLocationIndex;void 0!==r?a[e].fileLocations[r]=pe({},a[e].fileLocations[r],n):a[e]=pe({},a[e],n)}},U=function(e){e.preventDefault(),g(!0);var n=a.reduce((function(e,n){var r=n.fileLocations,t=n.fileName,o=n.fileType,i=n.fileUUID,a={};void 0!==t&&(a.fileName=t),void 0!==o&&(a.fileType=o);var l=r.reduce((function(e,n){var r=n.fileLocationUUID,t=n.isFileLocationActive;return void 0!==t&&e.push({fileLocationUUID:r,isFileLocationActive:t}),e}),[]);l.length>0&&(a.fileLocations=l);var c=JSON.stringify(a);return"{}"!==c&&e.push(ce.put("/files/".concat(i),c,{headers:{"Content-Type":"application/json"}})),e}),[]);Promise.all(n).then((function(){g(!1)})).then(r)},D=function(){C(!1),g(!0);var e=d.filter((function(e){return e.isSelected})).map((function(e){var n=e.fileUUID;return ce.delete("/files/".concat(n))}));Promise.all(e).then((function(){g(!1)})).then(t)},F=function(){C(!1)},E=function(){var e=d.filter((function(e){return e.isSelected})).length;S(e),e>0&&C(!0)};return(0,c.useEffect)((function(){g(!0),Promise.all(n.map(function(){var e=fe(l().mark((function e(n){var r,t;return l().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=pe({},n,{fileLocations:[]}),e.prev=1,e.next=4,(0,le.Z)("".concat(h,"/files/").concat(n.fileUUID));case 4:t=e.sent,r.fileLocations=t.map((function(e){var n=ve(e,10),r=n[5],t=n[6],o=n[7],i=n[8];return{anvilDescription:n[9],anvilName:i,anvilUUID:o,fileLocationUUID:r,isFileLocationActive:1===parseInt(t,10)}})),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),r.dataIncompleteError=e.t0;case 11:return e.abrupt("return",r);case 12:case"end":return e.stop()}}),e,null,[[1,8]])})));return function(n){return e.apply(this,arguments)}}())).then((function(e){p(e);for(var n=[],r=0;r<e.length;r+=1){var t=e[r];n.push({fileUUID:t.fileUUID,fileLocations:t.fileLocations.map((function(e){return{fileLocationUUID:e.fileLocationUUID}}))})}s(n),g(!1)}))}),[n]),(0,o.jsx)(o.Fragment,{children:b?(0,o.jsx)(ae.Z,{}):(0,o.jsxs)("form",{onSubmit:U,children:[(0,o.jsxs)(u.Z,{sx:{display:"flex",flexDirection:"column","& > :not(:first-child)":{marginTop:"1em"}},children:[d.map((function(e,n){var r=e.fileName,t=e.fileLocations,i=e.fileType,a=e.fileUUID;return(0,o.jsxs)(u.Z,{sx:{display:"flex",flexDirection:"row","& > :last-child":{flexGrow:1}},children:[(0,o.jsx)(u.Z,{sx:{marginTop:".4em"},children:(0,o.jsx)(x.Z,{onChange:function(e){var r=e.target.checked;d[n].isSelected=r},sx:de({color:m.s7},"&.".concat(y.Z.checked),{color:m.lD})})}),(0,o.jsx)(ie,{fileName:r,fileType:i,fileLocations:t,onChange:I(n)})]},"file-edit-".concat(a))})),d.length>0&&(0,o.jsxs)(u.Z,{sx:{display:"flex",flexDirection:"row",justifyContent:"flex-end","& > :not(:last-child)":{marginRight:".5em"}},children:[(0,o.jsx)(Z,{onClick:E,sx:A,children:"Purge"}),(0,o.jsx)(Z,{type:"submit",children:"Update"})]})]}),(0,o.jsx)(O,{actionProceedText:"Purge",contentText:"".concat(k," files will be removed from the system. You cannot undo this purge."),dialogProps:{open:w},onCancel:F,onProceed:D,proceedButtonProps:{sx:A},titleText:"Are you sure you want to purge ".concat(k," selected files? ")})]})})};me.defaultProps=he;var xe=me,ye=r(8462),be=r(891),ge=r(7720),je=r(8600),we=r.n(je),Ze=function(e){var n=e.filesOverview;return(0,o.jsx)(ye.Z,{children:n.map((function(e){var n,r,t=e.fileChecksum,i=e.fileName,a=e.fileSizeInBytes,l=e.fileType,c=e.fileUUID,s=we()(a,{binary:!0});return(0,o.jsx)(be.ZP,{sx:{padding:".6em 0"},children:(0,o.jsxs)(u.Z,{sx:{display:"flex",flexDirection:{xs:"column",md:"row"},width:"100%"},children:[(0,o.jsxs)(u.Z,{sx:{flexGrow:1},children:[(0,o.jsxs)(u.Z,{sx:{display:"flex",flexDirection:"row"},children:[(0,o.jsx)(P.A,{sx:{fontFamily:"Source Code Pro",fontWeight:400},text:i}),(0,o.jsx)(ge.Z,{flexItem:!0,orientation:"vertical",sx:{backgroundColor:m.d,marginLeft:".5em",marginRight:".5em"}}),(0,o.jsx)(P.A,{text:null!==(r=null===(n=B.get(l))||void 0===n?void 0:n[1])&&void 0!==r?r:""})]}),(0,o.jsx)(P.A,{text:s})]}),(0,o.jsx)(u.Z,{sx:{alignItems:"center",display:"flex",flexDirection:"row"},children:(0,o.jsx)(P.A,{sx:{fontFamily:"Source Code Pro",fontWeight:400},text:t})})]})},c)}))})},Ce=r(89),Pe=r(9297),ke=r(6576),Se=r(6195),Ae=r(238);function Oe(e,n,r){return n in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}var Ie,Ue="MessageBox",De={error:"".concat(Ue,"-error"),info:"".concat(Ue,"-info"),warning:"".concat(Ue,"-warning")},Fe=(0,g.ZP)(u.Z)((Oe(Ie={alignItems:"center",borderRadius:m.n_,display:"flex",flexDirection:"row",padding:".3em .6em","& > *":{color:m.lD},"& > :first-child":{marginRight:".3em"}},"&.".concat(De.error),{backgroundColor:m.hM}),Oe(Ie,"&.".concat(De.info),{backgroundColor:m.s7,"& > :first-child":{color:"".concat(m.E5)}}),Oe(Ie,"&.".concat(De.warning),{backgroundColor:m.Wd}),Ie)),Ee=function(e){var n,r=e.type,t=e.text;return(0,o.jsxs)(Fe,{className:(n=r,De[n]),children:[function(e){var n;switch(e){case"error":n=(0,o.jsx)(ke.Z,{});break;case"warning":n=(0,o.jsx)(Se.Z,{});break;default:n=(0,o.jsx)(Ae.Z,{})}return n}(r),function(e,n){return(0,o.jsx)(P.A,{inverted:"info"===n,text:e})}(t,r)]})};function Le(e,n){(null==n||n>e.length)&&(n=e.length);for(var r=0,t=new Array(n);r<n;r++)t[r]=e[r];return t}function Te(e,n,r){return n in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}function Ne(e){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{},t=Object.keys(r);"function"===typeof Object.getOwnPropertySymbols&&(t=t.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),t.forEach((function(n){Te(e,n,r[n])}))}return e}function _e(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){var r=null==e?null:"undefined"!==typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var t,o,i=[],a=!0,l=!1;try{for(r=r.call(e);!(a=(t=r.next()).done)&&(i.push(t.value),!n||i.length!==n);a=!0);}catch(c){l=!0,o=c}finally{try{a||null==r.return||r.return()}finally{if(l)throw o}}return i}}(e,n)||Me(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Re(e){return function(e){if(Array.isArray(e))return Le(e)}(e)||function(e){if("undefined"!==typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||Me(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Me(e,n){if(e){if("string"===typeof e)return Le(e,n);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(r):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Le(e,n):void 0}}var Be={onFileUploadComplete:void 0,eventEmitter:void 0},We=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Be,n=e.onFileUploadComplete,r=e.eventEmitter,t=(0,c.useRef)(),i=(0,c.useState)([]),a=i[0],l=i[1],s=(0,c.useState)([]),f=s[0],d=s[1],p=function(e){var n,r=B.entries();do{var t=r.next();if(t.value){var o=_e(t.value,2),i=o[0];e===_e(o[1],1)[0]&&(n=i)}else n="other"}while(!n);return n},v=function(e){var n=e.target.files;n&&l(Array.from(n).map((function(e){return{file:e,fileName:e.name,fileLocations:[],fileType:p(e.type)}})))},h=function(e){return function(n){a[e]=Ne({},a[e],n)}},m=function(e){for(e.preventDefault();a.length>0;){var r=a.shift();if(r){var t=r.file,o=r.fileName,i=new FormData;i.append("file",new File([t],o,Ne({},t)));var c={fileName:o,progressValue:0};f.push(c),ce.post("/files",i,{headers:{"Content-Type":"multipart/form-data"},onUploadProgress:function(e){var n=e.loaded,r=e.total;c.progressValue=Math.round(n/r*100),d(Re(f))}}).then((function(){null===n||void 0===n||n.call(null),f.splice(f.indexOf(c),1),d(Re(f))}))}}l([]),d(Re(f))};return(0,c.useEffect)((function(){null===r||void 0===r||r.addListener("openFilePicker",(function(){var e;null===(e=t.current)||void 0===e||e.click()})),null===r||void 0===r||r.addListener("clearSelectedFiles",(function(){l([])}))}),[r]),(0,o.jsxs)("form",{onSubmit:m,children:[(0,o.jsx)(G.Z,{htmlFor:"select-file",children:(0,o.jsx)(Ce.Z,{id:"select-file",inputProps:{multiple:!0},onChange:v,ref:t,sx:{display:"none"},type:"file"})}),(0,o.jsx)(u.Z,{sx:{display:"flex",flexDirection:"column"},children:f.map((function(e){var n=e.fileName,r=e.progressValue;return(0,o.jsxs)(u.Z,{sx:{alignItems:{md:"center"},display:"flex",flexDirection:{xs:"column",md:"row"},"& > :first-child":{minWidth:100,overflow:"hidden",overflowWrap:"normal",textOverflow:"ellipsis",whiteSpace:"nowrap",width:{xs:"100%",md:200},wordBreak:"keep-all"},"& > :last-child":{flexGrow:1}},children:[(0,o.jsx)(P.A,{text:n}),(0,o.jsx)(Pe.k,{progressPercentage:r})]},"in-upload-".concat(n))}))}),(0,o.jsxs)(u.Z,{sx:{display:"flex",flexDirection:"column","& > :not(:first-child)":{marginTop:"1em"}},children:[a.length>0&&(0,o.jsx)(Ee,{text:"Uploaded files will be listed automatically, but it may take a while for larger files to appear.",type:"info"}),a.map((function(e,n){var r=e.file.name,t=e.fileName,o=e.fileLocations;return(0,c.createElement)(ie,{fileName:t,fileLocations:o,key:"selected-".concat(r),onChange:h(n)})})),a.length>0&&(0,o.jsx)(u.Z,{sx:{display:"flex",flexDirection:"row",justifyContent:"flex-end"},children:(0,o.jsx)(Z,{type:"submit",children:"Upload"})})]})]})};We.defaultProps=Be;var Ve=We,$e=r(1706),ze=r(1905);function Ge(e,n){(null==n||n>e.length)&&(n=e.length);for(var r=0,t=new Array(n);r<n;r++)t[r]=e[r];return t}function Xe(e,n,r,t,o,i,a){try{var l=e[i](a),c=l.value}catch(u){return void r(u)}l.done?n(c):Promise.resolve(c).then(t,o)}function Je(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){var r=null==e?null:"undefined"!==typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var t,o,i=[],a=!0,l=!1;try{for(r=r.call(e);!(a=(t=r.next()).done)&&(i.push(t.value),!n||i.length!==n);a=!0);}catch(c){l=!0,o=c}finally{try{a||null==r.return||r.return()}finally{if(l)throw o}}return i}}(e,n)||function(e,n){if(!e)return;if("string"===typeof e)return Ge(e,n);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Ge(e,n)}(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var Ye="".concat(h,"/files"),qe=function(){var e=(0,c.useState)([]),n=e[0],r=e[1],t=(0,c.useState)(),i=t[0],a=t[1],p=(0,c.useState)(!1),h=p[0],x=p[1],y=(0,c.useState)(!1),b=y[0],g=y[1],j=new(v()),w=function(){var e,n=(e=l().mark((function e(){var n;return l().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return x(!0),e.prev=1,e.next=4,(0,le.Z)(Ye);case 4:n=e.sent,r(n),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),a("Failed to get files due to a network issue.");case 11:x(!1);case 12:case"end":return e.stop()}}),e,null,[[1,8]])})),function(){var n=this,r=arguments;return new Promise((function(t,o){var i=e.apply(n,r);function a(e){Xe(i,t,o,a,l,"next",e)}function l(e){Xe(i,t,o,a,l,"throw",e)}a(void 0)}))});return function(){return n.apply(this,arguments)}}();return(0,ze.Z)(Ye,{onSuccess:function(e){e.length!==n.length&&r(e)}}),(0,c.useEffect)((function(){b||w()}),[b]),(0,o.jsxs)(C.s_,{children:[(0,o.jsxs)(u.Z,{sx:{alignItems:"center",display:"flex",flexDirection:"row",marginBottom:"1em",width:"100%","& > :first-child":{flexGrow:1},"& > :not(:first-child, :last-child)":{marginRight:".3em"}},children:[(0,o.jsx)(P.z,{text:"Files"}),!b&&(0,o.jsx)($e.Z,{onClick:function(){j.emit("openFilePicker")},children:(0,o.jsx)(s.Z,{})}),(0,o.jsx)($e.Z,{onClick:function(){j.emit("clearSelectedFiles"),g(!b)},children:b?(0,o.jsx)(f.Z,{sx:{color:m.Ej}}):(0,o.jsx)(d.Z,{})})]}),i&&(0,o.jsx)(Ee,{text:i,type:"error"}),(0,o.jsx)(Ve,{eventEmitter:j,onFileUploadComplete:w}),function(){var e;if(h)e=(0,o.jsx)(ae.Z,{});else{var r=n.map((function(e){var n=Je(e,5),r=n[0],t=n[1],o=n[2],i=n[3];return{fileChecksum:n[4],fileName:t,fileSizeInBytes:parseInt(o,10),fileType:i,fileUUID:r}}));e=b?(0,o.jsx)(xe,{filesOverview:r,onEditFilesComplete:w,onPurgeFilesComplete:w}):(0,o.jsx)(Ze,{filesOverview:r})}return e}()]})},He=qe,Ke=r(8750),Qe=function(){return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(i.default,{children:(0,o.jsx)("title",{children:"File Manager"})}),(0,o.jsx)(Ke.Z,{}),(0,o.jsx)(He,{})]})}}},function(e){e.O(0,[806,100,616,478,774,888,179],(function(){return n=8283,e(e.s=n);var n}));var n=e.O();_N_E=n}]);