"use strict";var e=require("@babel/runtime/helpers/defineProperty"),r=require("@babel/runtime/helpers/objectWithoutProperties"),i=require("@babel/runtime/helpers/slicedToArray"),n=require("react"),t=require("prop-types"),o=require("react-sizeme"),l=require("@material-ui/core"),s=require("@material-ui/core/styles"),a=require("./components/FiltersToggler.js"),c=require("./components/PinAppSwitch.js"),u=require("./effects/index.js"),d=require("./utils.js"),p=require("./constants.js"),h=require("./PinnableFilters.css.js"),f=require("react/jsx-runtime");function m(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var j=m(e),b=m(r),v=m(i),x=m(t),O=["children"];function S(e,r){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),i.push.apply(i,n)}return i}function y(e){for(var r=1;r<arguments.length;r++){var i=null!=arguments[r]?arguments[r]:{};r%2?S(Object(i),!0).forEach((function(r){j.default(e,r,i[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):S(Object(i)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(i,r))}))}return e}function P(e){var r=e.children,i=e.classes,t=e.appWidth,o=e.isPinnedInitial,s=e.isShownInitial,m=e.onShowCallback,j=e.onPinCallback,b=n.useState(null),x=v.default(b,2),O=x[0],S=x[1],y=n.useState(o),P=v.default(y,2),g=P[0],C=P[1],q=n.useState(s),w=v.default(q,2),M=w[0],N=w[1],T=n.useState(!1),k=v.default(T,2),E=k[0],L=k[1],I=function(e){N(e),m&&m(e)},W=u.useComonentsWidth(r),A=u.useAppFilterTogglerWidth(),B=u.useFilterLayout(r,W,A,t),_=d.getStartComponent(r),z=d.getMiddleComponent(r),D=d.getEndComponents(r),R=function(e){g?I(!M):S(e.currentTarget)},F=function(){var e,r=!g;r&&(S(null),I(!0)),C(e=r),j&&j(e)};return f.jsxs("div",{style:{width:"100%"},children:[f.jsx(l.Collapse,{timeout:10,in:B===p.LARGE_SIZE_LAYOUT,children:f.jsxs("div",{className:h.containerLarge,children:[f.jsx("div",{children:_}),f.jsxs("div",{className:h.containerLargeTopright,children:[z,D]})]})}),f.jsx(l.Collapse,{timeout:10,in:B===p.MEDIUM_SIZE_LAYOUT,children:f.jsxs("div",{className:h.containerMedium,children:[f.jsxs("div",{className:h.containerMediumTop,children:[f.jsxs("div",{className:h.containerButtonsWrapper,onMouseEnter:function(){return L(!0)},onMouseLeave:function(){return L(!1)},children:[f.jsx(a,{onClick:R}),(E||g||Boolean(O))&&f.jsx(c,{isPinned:g,onClick:F})]}),f.jsxs("div",{className:h.containerMediumTopright,children:[z,D]})]}),f.jsx(l.Collapse,{timeout:100,in:g&&M,children:f.jsx("div",{className:h.containerMediumBottom,children:_})})]})}),f.jsx(l.Collapse,{timeout:10,in:B===p.SMALL_SIZE_LAYOUT,children:f.jsxs("div",{className:h.containerSmall,children:[f.jsxs("div",{className:h.containerSmallTop,children:[f.jsxs("div",{className:h.containerButtonsWrapper,onMouseEnter:function(){return L(!0)},onMouseLeave:function(){return L(!1)},children:[f.jsx(a,{onClick:R}),(E||g||Boolean(O))&&f.jsx(c,{isPinned:g,onClick:F})]}),f.jsx("div",{children:D})]}),f.jsx(l.Collapse,{timeout:100,in:g&&M,children:f.jsx("div",{className:h.containerSmallMiddle,children:_})}),f.jsx("div",{className:h.containerSmallBottom,children:z})]})}),f.jsx(l.Popover,{id:"filters-popper",classes:{paper:i.paper},open:Boolean(O),anchorEl:O,onClose:function(){S(null)},anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},children:f.jsx("div",{className:h.containerPopper,children:_})})]})}P.propTypes={classes:x.default.shape({}).isRequired,appWidth:x.default.number.isRequired,children:x.default.arrayOf(x.default.node).isRequired,isPinnedInitial:x.default.bool,isShownInitial:x.default.bool,onShowCallback:x.default.func,onPinCallback:x.default.func},P.defaultProps={isPinnedInitial:!1,isShownInitial:!1,onShowCallback:void 0,onPinCallback:void 0};var g=s.withStyles({paper:{backgroundColor:"#414141"}})(P);function C(e){var r=e.children,i=b.default(e,O);return f.jsx(o.SizeMe,{monitorWidth:!0,children:function(e){var n=e.size;return f.jsx(g,y(y({appWidth:n.width-21},i),{},{children:r}))}})}C.propTypes={children:x.default.arrayOf(x.default.node).isRequired},module.exports=C;
