"use strict";(self["webpackChunk_quetz_frontend_main_app"]=self["webpackChunk_quetz_frontend_main_app"]||[]).push([[9444,4294],{9444:(e,t,a)=>{a.r(t);a.d(t,{API_STATUSES:()=>l,Breadcrumbs:()=>c,FetchHoc:()=>E,GB_SIZE:()=>p,InlineLoader:()=>f,KB_SIZE:()=>m,MB_SIZE:()=>u,NOTIFICATION_TYPES:()=>I,SearchBox:()=>F,copyToClipboard:()=>A,formatPlural:()=>D,formatSize:()=>b,sendNotification:()=>_});var n=a(68288);var r=a(22550);var o=a(62971);var i=a(34494);var s=a(2411);class c extends s.PureComponent{render(){const{items:e}=this.props;return s.createElement(i.Breadcrumb,null,e.map((e=>e.onClick?s.createElement(i.BreadcrumbItem,{key:e.text},s.createElement(i.Button,{appearance:"lightweight",onClick:e.onClick},e.text)):s.createElement(i.BreadcrumbItem,{key:e.text,href:e.href},e.text))))}}var l;(function(e){e["PENDING"]="PENDING";e["SUCCESS"]="SUCCESS";e["FAILED"]="FAILED"})(l||(l={}));const m=1024;const u=1024*m;const p=1024*u;var d=a(98078);class f extends s.PureComponent{render(){const{text:e}=this.props;return s.createElement("div",{className:"loader-wrapper padding"},s.createElement(i.ProgressRing,null),e&&s.createElement("p",{className:"text loader-text"},e))}}class E extends s.PureComponent{constructor(e){super(e);this.componentDidMount=()=>{this.tryFetch()};this.tryFetch=async()=>{const{url:e}=this.props;this.setState({apiStatus:l.PENDING});const t=d.ServerConnection.makeSettings();const a=await d.ServerConnection.makeRequest(e,{},t);if(!a.ok){this.setState({error:a.statusText,apiStatus:l.FAILED})}else{this.setState({data:await a.json(),apiStatus:l.SUCCESS})}};this.state={data:null,apiStatus:l.PENDING,error:""}}render(){const{apiStatus:e,data:t,error:a}=this.state;const{children:n,loadingMessage:r,genericErrorMessage:o}=this.props;if(e===l.PENDING){return s.createElement(f,{text:r})}if(e===l.FAILED){return s.createElement("p",{className:"paragraph padding"},a||o||"Error occurred while fetching data"," ",s.createElement(i.Button,{appearance:"lightweight",onClick:this.tryFetch},"Try again"))}return s.createElement(s.Fragment,null,n(t))}}var h=a(5089);var S=a(30325);var N=a(6277);var C=a(37106);const I={SUCCESS:"success",DANGER:"danger",INFO:"info",DEFAULT:"default",WARNING:"warning"};const g={[I.SUCCESS]:S.faCheckCircle,[I.DANGER]:S.faTimesCircle,[I.INFO]:S.faInfoCircle,[I.DEFAULT]:S.faInfoCircle,[I.WARNING]:S.faExclamationCircle};class v extends s.PureComponent{render(){const{id:e,type:t,title:a,message:n}=this.props;return s.createElement("div",{className:"notification-item"},s.createElement("p",{className:(0,N.Z)("notification-icon",t)},s.createElement(h.FontAwesomeIcon,{icon:g[t]})),s.createElement("div",{className:"notification-content"},a&&s.createElement("p",{className:(0,N.Z)("notification-title",t)},a),n&&s.createElement("p",{className:"notification-message"},n)),s.createElement("button",{className:"notification-close"},s.createElement(h.FontAwesomeIcon,{icon:S.faTimes,onClick:()=>C.Store.removeNotification(e)})))}}const _=({type:e=I.DEFAULT,title:t,message:a,duration:n})=>{const r=C.Store.addNotification({content:({id:n})=>s.createElement(v,{id:n,title:t,type:e,message:a}),insert:"top",container:"top-right",animationIn:["animate__animated","animate__fadeIn"],animationOut:["animate__animated","animate__fadeOut"],dismiss:{duration:n}});if(n){setTimeout((()=>{C.Store.removeNotification(r)}),n)}};class F extends s.PureComponent{constructor(e){super(e);this._searchRef=s.createRef()}render(){return s.createElement("form",{onSubmit:e=>{var t;e.preventDefault();const a=(t=this._searchRef.current)===null||t===void 0?void 0:t.value;if(a){this.props.onSubmit(a)}}},s.createElement("div",{className:"btn-group quetz-search-box"},s.createElement(i.Search,{ref:this._searchRef,value:this.props.value,placeholder:"Search"}),s.createElement(i.Button,{appearance:"neutral",type:"submit"},s.createElement(h.FontAwesomeIcon,{icon:S.faSearch}))))}}var x=a(47);const D=(e,t)=>`${e} ${t}${e>1?"s":""}`;const b=e=>{if(e>p){return`${(0,x.round)(e/p,2)} GB`}if(e>u){return`${(0,x.round)(e/u,2)} MB`}if(e>m){return`${(0,x.round)(e/m,2)} KB`}return`${e} bytes`};const A=(e,t)=>{navigator.clipboard.writeText(e).then((()=>{_({type:I.INFO,message:`Copied ${t&&`${t} `}to clipboard`,duration:3e3})})).catch((e=>console.error(e)))};n.SV.withDefault('"Open Sans", sans-serif');n.z.withDefault(r.w.from({r:242,g:240,b:18}));(0,o.e)()}}]);