"use strict";(self.webpackChunk_jbrowse_web=self.webpackChunk_jbrowse_web||[]).push([[9915],{79915:function(e,r,t){t.r(r);var n=t(33028),o=t(32723),a=t(34795),i=t(96234),s=t(30969),c=t(81073),l=t(33528),p=t(97891),d=t(22714),u=t(51526),g=t(80975),h=t(28599),x=t(53239),b=t(90550),f=t(98344),m=t(40232),v=t(43418),Z=t(37574),j=512*Math.pow(1024,2);function y(e,r){return function(t){return r[t[e]]}}var w=(0,d.Z)((function(e){return{root:{margin:e.spacing(1)},paper:{display:"flex",flexDirection:"column"},dropZone:{textAlign:"center",margin:e.spacing(2),padding:e.spacing(2),borderWidth:2,borderRadius:2,borderColor:y("isDragActive",{true:e.palette.secondary.light,false:e.palette.divider}),borderStyle:"dashed",backgroundColor:y("isDragActive",{true:(0,x.Fq)(e.palette.text.primary,e.palette.action.hoverOpacity),false:e.palette.background.default}),outline:"none",transition:"border .24s ease-in-out","&:focus":{borderColor:e.palette.secondary.light}},uploadIcon:{color:e.palette.text.secondary},rejectedFiles:{marginTop:e.spacing(4)},listItem:{padding:e.spacing(0,4)},expandIcon:{color:"#FFFFFF"},error:{margin:e.spacing(2)},errorHeader:{background:e.palette.error.light,color:e.palette.error.contrastText,padding:e.spacing(2),textAlign:"center"},errorMessage:{padding:e.spacing(2)}}}));r.default=(0,b.observer)((function(e){var r=(0,s.useState)(""),t=(0,i.Z)(r,2),d=t[0],x=t[1],b=e.model,y=(0,f.u)({accept:"application/json",maxSize:j,multiple:!1,onDrop:function(){var e=(0,a.Z)((0,o.Z)().mark((function e(r,t){var n,a,s,d,u,g;return(0,o.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.length){e.next=3;break}return r.length||t.length>1?x("Only one session at a time may be imported"):t[0].size>j?x("File size is too large (".concat(Math.round(t[0].size/Math.pow(1024,2))," MiB), max size is ").concat(j/Math.pow(1024,2)," MiB")):"application/json"!==t[0].type?x("File does not appear to be JSON"):x("Unknown file import error"),e.abrupt("return");case 3:return n=(0,i.Z)(r,1),a=n[0],s=(0,l.openLocation)((0,p.storeBlobLocation)({blob:a})),e.prev=5,e.next=8,s.readFile("utf8");case 8:d=e.sent,e.next=16;break;case 11:return e.prev=11,e.t0=e.catch(5),console.error(e.t0),x("Problem opening file ".concat(a.path,": ").concat(e.t0)),e.abrupt("return");case 16:try{u=JSON.parse(d).session}catch(o){console.error(o),u={error:"Error parsing ".concat(a.path,": ").concat(o)}}g=(0,c.getSession)(b);try{g.setSession(u)}catch(o){console.error(o),x("Error activating session: ".concat(o," "))}case 19:case"end":return e.stop()}}),e,null,[[5,11]])})));return function(r,t){return e.apply(this,arguments)}}()}),F=y.getRootProps,k=y.getInputProps,S=y.isDragActive,N=w({isDragActive:S});return(0,Z.jsxs)("div",{className:N.root,children:[(0,Z.jsx)(u.Z,{className:N.paper,children:(0,Z.jsxs)("div",(0,n.Z)((0,n.Z)({},F({className:N.dropZone})),{},{children:[(0,Z.jsx)("input",(0,n.Z)({},k())),(0,Z.jsx)(m.Z,{className:N.uploadIcon,fontSize:"large"}),(0,Z.jsx)(g.Z,{color:"textSecondary",align:"center",variant:"body1",children:"Drag and drop files here"}),(0,Z.jsx)(g.Z,{color:"textSecondary",align:"center",variant:"body2",children:"or"}),(0,Z.jsx)(h.Z,{color:"primary",variant:"contained",children:"Browse Files"})]}))}),d?(0,Z.jsxs)(u.Z,{className:N.error,children:[(0,Z.jsxs)("div",{className:N.errorHeader,children:[(0,Z.jsx)(v.Z,{color:"inherit",fontSize:"large"}),(0,Z.jsx)("div",{children:(0,Z.jsx)(g.Z,{variant:"h6",color:"inherit",align:"center",children:"Import error"})})]}),(0,Z.jsx)(g.Z,{className:N.errorMessage,children:d})]}):null]})}))}}]);
//# sourceMappingURL=9915.fca94428.chunk.js.map