"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("../tslib.es6-C4EgNkz1.js"),n=require("react"),w=require("classnames"),b=require("../dropdown-B6wMNyjP.js"),a=require("../filter-menu-CTZ0wyzf.js"),q=require("../utils-C9NL3q0j.js"),D=require("../icons/ebay-icon-chevron-down-12/index.js"),N=u=>{var{className:d,text:p,"aria-label":y,onExpand:f,onCollapse:h,onChange:l,children:i}=u,o=S.__rest(u,["className","text","aria-label","onExpand","onCollapse","onChange","children"]);const c=n.useRef(null),v=q.filterByType(i,a.EbayFilterMenuItem),[E,F]=n.useState(()=>v.some(t=>t.props.checked)),{isExpanded:_,collapse:r}=b.useExpander({ref:c,options:{hostSelector:".filter-menu-button__button",contentSelector:".filter-menu-button__menu",focusManagement:"interactive",expandOnClick:!0,autoCollapse:!0,alwaysDoFocusManagement:!0},onExpand:f,onCollapse:h}),{overlayStyles:C,refs:m}=b.useFloatingDropdown({open:_}),M=t=>{var e;(e=o.onKeyDown)===null||e===void 0||e.call(o,t),t.key==="Escape"&&r()},g=(...t)=>{var e;(e=o.onFormSubmit)===null||e===void 0||e.call(o,...t),r()},x=(...t)=>{var e;(e=o.onFooterClick)===null||e===void 0||e.call(o,...t),r()},k=(t,e)=>{var s;l?.(t,e),F(((s=e.checked)===null||s===void 0?void 0:s.length)>0)};return n.createElement("span",{ref:c,className:w("filter-menu-button",d)},n.createElement("button",{type:"button",className:"filter-menu-button__button",ref:m.setHost,"aria-expanded":"false","aria-haspopup":"true","aria-label":y,"aria-pressed":E},n.createElement("span",{className:"filter-menu-button__button-cell"},n.createElement("span",{className:"filter-menu-button__button-text"},p),n.createElement(D.EbayIconChevronDown12,null))),n.createElement(a.EbayFilterMenu,Object.assign({},o,{onChange:k,classPrefix:"filter-menu-button",onKeyDown:M,onFooterClick:x,onFormSubmit:g,ref:m.setOverlay,style:C}),i))};exports.EbayFilterMenuFooterButton=a.EbayFilterMenuFooterButton;exports.EbayFilterMenuItem=a.EbayFilterMenuItem;exports.EbayFilterMenuButton=N;
