"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:()=>s,Breadcrumbs:()=>i,FetchHoc:()=>d,GB_SIZE:()=>m,InlineLoader:()=>p,KB_SIZE:()=>c,MB_SIZE:()=>l,NOTIFICATION_TYPES:()=>N,SearchBox:()=>v,copyToClipboard:()=>A,formatPlural:()=>F,formatSize:()=>x,sendNotification:()=>g});var n=a(62971);var r=a(40746);var o=a(2411);class i extends o.PureComponent{render(){const{items:e}=this.props;return o.createElement(r.Breadcrumb,null,e.map((e=>e.onClick?o.createElement(r.BreadcrumbItem,{key:e.text},o.createElement(r.Button,{appearance:"lightweight",onClick:e.onClick},e.text)):o.createElement(r.BreadcrumbItem,{key:e.text,href:e.href},e.text))))}}var s;(function(e){e["PENDING"]="PENDING";e["SUCCESS"]="SUCCESS";e["FAILED"]="FAILED"})(s||(s={}));const c=1024;const l=1024*c;const m=1024*l;var u=a(98078);class p extends o.PureComponent{render(){const{text:e}=this.props;return o.createElement("div",{className:"loader-wrapper padding"},o.createElement(r.ProgressRing,null),e&&o.createElement("p",{className:"text loader-text"},e))}}class d extends o.PureComponent{constructor(e){super(e);this.componentDidMount=()=>{this.tryFetch()};this.tryFetch=async()=>{const{url:e}=this.props;this.setState({apiStatus:s.PENDING});const t=u.ServerConnection.makeSettings();const a=await u.ServerConnection.makeRequest(e,{},t);if(!a.ok){this.setState({error:a.statusText,apiStatus:s.FAILED})}else{this.setState({data:await a.json(),apiStatus:s.SUCCESS})}};this.state={data:null,apiStatus:s.PENDING,error:""}}render(){const{apiStatus:e,data:t,error:a}=this.state;const{children:n,loadingMessage:i,genericErrorMessage:c}=this.props;if(e===s.PENDING){return o.createElement(p,{text:i})}if(e===s.FAILED){return o.createElement("p",{className:"paragraph padding"},a||c||"Error occurred while fetching data"," ",o.createElement(r.Button,{appearance:"lightweight",onClick:this.tryFetch},"Try again"))}return o.createElement(o.Fragment,null,n(t))}}var E=a(5089);var f=a(30325);var h=a(6277);var S=a(37106);const N={SUCCESS:"success",DANGER:"danger",INFO:"info",DEFAULT:"default",WARNING:"warning"};const C={[N.SUCCESS]:f.faCheckCircle,[N.DANGER]:f.faTimesCircle,[N.INFO]:f.faInfoCircle,[N.DEFAULT]:f.faInfoCircle,[N.WARNING]:f.faExclamationCircle};class I extends o.PureComponent{render(){const{id:e,type:t,title:a,message:n}=this.props;return o.createElement("div",{className:"notification-item"},o.createElement("p",{className:(0,h.Z)("notification-icon",t)},o.createElement(E.FontAwesomeIcon,{icon:C[t]})),o.createElement("div",{className:"notification-content"},a&&o.createElement("p",{className:(0,h.Z)("notification-title",t)},a),n&&o.createElement("p",{className:"notification-message"},n)),o.createElement("button",{className:"notification-close"},o.createElement(E.FontAwesomeIcon,{icon:f.faTimes,onClick:()=>S.Store.removeNotification(e)})))}}const g=({type:e=N.DEFAULT,title:t,message:a,duration:n})=>{const r=S.Store.addNotification({content:({id:n})=>o.createElement(I,{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((()=>{S.Store.removeNotification(r)}),n)}};class v extends o.PureComponent{constructor(e){super(e);this._searchRef=o.createRef()}render(){return o.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._searchRef.current.value="";this.props.onSubmit(a)}}},o.createElement("div",{className:"btn-group"},o.createElement(r.Search,{ref:this._searchRef,placeholder:"Search"}),o.createElement(r.Button,{appearance:"neutral",type:"submit"},o.createElement(E.FontAwesomeIcon,{icon:f.faSearch}))))}}var _=a(47);const F=(e,t)=>`${e} ${t}${e>1?"s":""}`;const x=e=>{if(e>m){return`${(0,_.round)(e/m,2)} GB`}if(e>l){return`${(0,_.round)(e/l,2)} MB`}if(e>c){return`${(0,_.round)(e/c,2)} KB`}return`${e} bytes`};const A=(e,t)=>{navigator.clipboard.writeText(e).then((()=>{g({type:N.INFO,message:`Copied ${t&&`${t} `}to clipboard`,duration:3e3})})).catch((e=>console.error(e)))};(0,n.e)()}}]);