"use strict";var e=require("@babel/runtime/helpers/defineProperty"),r=require("@babel/runtime/helpers/objectWithoutProperties"),n=require("@babel/runtime/helpers/slicedToArray"),i=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(n),x=m(t),O=["children"];function S(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);r&&(i=i.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),n.push.apply(n,i)}return n}function y(e){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?S(Object(n),!0).forEach((function(r){j.default(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):S(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}function P(e){var r=e.children,n=e.classes,t=e.appWidth,o=e.isPinnedInitial,s=e.isShownInitial,m=e.onShowCallback,j=e.onPinCallback,b=i.useState(null),x=v.default(b,2),O=x[0],S=x[1],y=i.useState(o),P=v.default(y,2),g=P[0],C=P[1],q=i.useState(s),w=v.default(q,2),M=w[0],N=w[1],T=i.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=W.componentsWidth,B=W.hiddenElements,_=u.useAppFilterTogglerWidth(),z=u.useFilterLayout(r,A,_,t),D=d.getStartComponent(r),R=d.getMiddleComponent(r),F=d.getEndComponents(r),U=function(e){g?I(!M):S(e.currentTarget)},Y=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:z===p.LARGE_SIZE_LAYOUT,children:f.jsxs("div",{className:h.containerLarge,children:[f.jsx("div",{children:D}),f.jsxs("div",{className:h.containerLargeTopright,children:[R,F]})]})}),f.jsx(l.Collapse,{timeout:10,in:z===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:U}),(E||g||Boolean(O))&&f.jsx(c,{isPinned:g,onClick:Y})]}),f.jsxs("div",{className:h.containerMediumTopright,children:[R,F]})]}),f.jsx(l.Collapse,{timeout:100,in:g&&M,children:f.jsx("div",{className:h.containerMediumBottom,children:D})})]})}),f.jsx(l.Collapse,{timeout:10,in:z===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:U}),(E||g||Boolean(O))&&f.jsx(c,{isPinned:g,onClick:Y})]}),f.jsx("div",{children:F})]}),f.jsx(l.Collapse,{timeout:100,in:g&&M,children:f.jsx("div",{className:h.containerSmallMiddle,children:D})}),f.jsx("div",{className:h.containerSmallBottom,children:R})]})}),f.jsx(l.Popover,{id:"filters-popper",classes:{paper:n.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:D})}),B]})}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,n=b.default(e,O);return f.jsx(o.SizeMe,{monitorWidth:!0,children:function(e){var i=e.size;return f.jsx(g,y(y({appWidth:i.width-21},n),{},{children:r}))}})}C.propTypes={children:x.default.arrayOf(x.default.node).isRequired},module.exports=C;
