"use strict";(self.webpackChunk_jbrowse_web=self.webpackChunk_jbrowse_web||[]).push([[634],{40634:(e,n,t)=>{t.r(n),t.d(n,{default:()=>N});var i=t(41867),r=t(97486),s=t(3762),o=t(90872),l=t(28164),a=t(86163),d=t(7229),c=t(47192),u=t(54560),g=t(80838);const h=(0,c.ZL)()((e=>({paper:{overflowY:"auto",height:"100%",zIndex:e.zIndex.drawer,outline:"none",background:e.palette.background.default},resizeHandle:{width:4,position:"fixed",top:0,zIndex:e.zIndex.drawer+1}}))),v=(0,s.observer)((function(e){let{children:n,session:t}=e;const{drawerPosition:r,drawerWidth:s}=t,{classes:o}=h(),l=(0,i.useRef)(null);return(0,i.useEffect)((()=>{function e(e){if(e.target instanceof Element&&null!==l&&void 0!==l&&l.current&&l.current.contains(e.target)){var n,i;const e=null===(n=t.visibleWidget)||void 0===n||null===(i=n.view)||void 0===i?void 0:i.id;e&&t.setFocusedViewId(e)}}return document.addEventListener("mousedown",e),document.addEventListener("keydown",e),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",e)}}),[l,t]),(0,g.jsxs)(d.Z,{ref:l,className:o.paper,elevation:16,square:!0,children:["right"===r?(0,g.jsx)(u.Z,{onDrag:t.resizeDrawer,className:o.resizeHandle,vertical:!0}):null,n,"left"===r?(0,g.jsx)(u.Z,{onDrag:t.resizeDrawer,className:o.resizeHandle,style:{left:s},vertical:!0}):null]})}));var x=t(70974),w=t(69625),m=t(90552),j=t(36669),p=t(51590),f=t(59231),b=t(68367),Z=t(77573),k=t(89301),y=t(98662),C=t(22177),W=t(18087),z=t(30340);const D=(0,c.ZL)()((e=>({formControl:{margin:0},spacer:{flexGrow:1},drawerSelect:{margin:0,color:e.palette.secondary.contrastText},dropDownIcon:{color:e.palette.secondary.contrastText},headerFocused:{background:e.palette.secondary.main},headerUnfocused:{background:e.palette.secondary.dark}}))),E=(0,s.observer)((function(e){var n,t;let{session:i,setToolbarHeight:r}=e;const{classes:s}=D(),o=i.focusedViewId,l=null===(n=i.visibleWidget)||void 0===n||null===(t=n.view)||void 0===t?void 0:t.id;return(0,g.jsx)(x.Z,{position:"sticky",className:o===l?s.headerFocused:s.headerUnfocused,ref:e=>r((null===e||void 0===e?void 0:e.getBoundingClientRect().height)||0),children:(0,g.jsxs)(w.Z,{disableGutters:!0,children:[(0,g.jsx)(H,{session:i}),(0,g.jsx)("div",{className:s.spacer}),(0,g.jsx)(I,{session:i})]})})})),H=(0,s.observer)((function(e){let{session:n}=e;const{visibleWidget:t,activeWidgets:i}=n,{classes:r}=D(),{pluginManager:s}=(0,o.getEnv)(n);return(0,g.jsx)(m.Z,{className:r.formControl,children:(0,g.jsx)(j.Z,{value:null===t||void 0===t?void 0:t.id,"data-testid":"widget-drawer-selects",className:r.drawerSelect,classes:{icon:r.dropDownIcon},renderValue:e=>{const t=n.activeWidgets.get(e);if(!t)return(0,g.jsx)(p.Z,{variant:"h6",color:"inherit",children:"Unknown widget"});const i=s.getWidgetType(t.type),{HeadingComponent:r,heading:o}=i;return r?(0,g.jsx)(r,{model:t}):(0,g.jsx)(p.Z,{variant:"h6",color:"inherit",children:o})},onChange:e=>{const t=n.activeWidgets.get(e.target.value);t?n.showWidget(t):n.notify("Widget not found ".concat(e.target.value),"warning")},children:[...i.values()].map((e=>{const t=s.getWidgetType(e.type),{HeadingComponent:i,heading:r}=t;return(0,g.jsxs)(f.Z,{"data-testid":"widget-drawer-selects-item-".concat(e.type),value:e.id,children:[i?(0,g.jsx)(i,{model:e}):(0,g.jsx)(p.Z,{variant:"h6",color:"inherit",children:r}),(0,g.jsx)(b.Z,{"data-testid":"".concat(e.type,"-drawer-delete"),color:"inherit","aria-label":"Delete",onClick:()=>n.hideWidget(e),children:(0,g.jsx)(y.Z,{})})]},e.id)}))})})})),I=(0,s.observer)((function(e){let{session:n}=e;const[t,r]=(0,i.useState)(null),{drawerPosition:s,visibleWidget:o}=n;return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(b.Z,{color:"inherit",onClick:e=>r(e.currentTarget),children:(0,g.jsx)(z.Z,{})}),(0,g.jsx)(Z.Z,{title:"Minimize drawer",children:(0,g.jsx)(b.Z,{"data-testid":"drawer-minimize",color:"inherit",onClick:()=>{n.notify("Drawer minimized, click button on ".concat(s," side of screen to re-open"),"info"),n.minimizeWidgetDrawer()},children:(0,g.jsx)(W.Z,{})})}),(0,g.jsx)(Z.Z,{title:"Close drawer",children:(0,g.jsx)(b.Z,{color:"inherit",onClick:()=>n.hideWidget(o),children:(0,g.jsx)(C.Z,{})})}),(0,g.jsx)(k.Z,{anchorEl:t,open:Boolean(t),onClose:()=>r(null),children:["left","right"].map((e=>(0,g.jsx)(f.Z,{selected:"option"===s,onClick:()=>{n.setDrawerPosition(e),r(null)},children:e},e)))})]})})),T=E,N=(0,s.observer)((function(e){let{session:n}=e;const{visibleWidget:t}=n,{pluginManager:s}=(0,o.getEnv)(n),d=t?s.evaluateExtensionPoint("Core-replaceWidget",s.getWidgetType(t.type).ReactComponent,{session:n,model:t}):null,[c,u]=(0,i.useState)(0);return(0,g.jsxs)(v,{session:n,children:[(0,g.jsx)(T,{session:n,setToolbarHeight:u}),(0,g.jsx)(i.Suspense,{fallback:(0,g.jsx)(l.Z,{}),children:(0,g.jsx)(r.SV,{FallbackComponent:e=>{let{error:n}=e;return(0,g.jsx)(a.Z,{error:n})},children:d?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d,{model:t,session:n,toolbarHeight:c}),(0,g.jsx)("div",{style:{height:300}})]}):null})})]})}))}}]);
//# sourceMappingURL=634.940ba4ac.chunk.js.map