Liferay.Loader.define("frontend-taglib-clay@9.1.10/management_toolbar/CreationMenu",["module","exports","require","@frontend-taglib-clay$clayui/button","@frontend-taglib-clay$clayui/drop-down","@frontend-taglib-clay$clayui/icon","liferay!frontend-js-react-web$classnames","liferay!frontend-js-react-web$react","../get_data_attributes","./FeatureFlagContext","./LinkOrButton","./CreationMenu.scss"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=m(a("@frontend-taglib-clay$clayui/button")),r=s(a("@frontend-taglib-clay$clayui/drop-down")),l=s(a("@frontend-taglib-clay$clayui/icon")),u=s(a("liferay!frontend-js-react-web$classnames")),o=m(a("liferay!frontend-js-react-web$react")),i=s(a("../get_data_attributes")),c=s(a("./FeatureFlagContext")),d=s(a("./LinkOrButton"));function s(e){return e&&e.__esModule?e:{default:e}}function f(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return f=function(){return e},e}function m(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=f();if(t&&t.has(e))return t.get(e);var a={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){var l=n?Object.getOwnPropertyDescriptor(e,r):null;l&&(l.get||l.set)?Object.defineProperty(a,r,l):a[r]=e[r]}return a.default=e,t&&t.set(e,a),a}function y(){return(y=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e}).apply(this,arguments)}a("./CreationMenu.scss");var p=({maxPrimaryItems:e,maxSecondaryItems:t,maxTotalItems:a=15,onCreateButtonClick:s,onCreationMenuItemClick:f,onShowMoreButtonClick:m,primaryItems:p,secondaryItems:b,viewMoreURL:g})=>{var v,w;const[E,h]=(0,o.useState)(!1),{showDesignImprovements:C}=(0,o.useContext)(c.default),k=(0,o.useRef)(null!==(v=null==b?void 0:b.reduce(((e,t)=>e+t.items.length),0))&&void 0!==v?v:0),I=(0,o.useRef)(p.length+k.current),L=(0,o.useRef)((null==p?void 0:p[0])||(null==b||null===(w=b[0].items)||void 0===w?void 0:w[0])||(null==b?void 0:b[0])),O=()=>{const e=1===I.current?L.current:null;return(null==e?void 0:e.label)||Liferay.Language.get("new")},[j,M]=(0,o.useState)((()=>{const n=p.length,r=k.current,l=e?n>e?e:n:n>8?8:n,u=t?r>t?t:r:r>7?7:r,o=u>a-l?a-l:u;return 0===r?n>a?a:n:n>l?r>o?l+o:l+r:r>o?n+o:n+r})()),N=({item:e})=>o.default.createElement(r.default.Item,y({href:e.href,onClick:t=>{f(t,{item:e})},symbolLeft:e.icon},(0,i.default)(e.data)),e.label),_=()=>{let e=0;return o.default.createElement(r.default.ItemList,{className:(0,u.default)({"dropdown-menu-indicator-start":p.some((e=>e.icon))})},null==p?void 0:p.map(((t,a)=>(e++,!(e>j)&&o.default.createElement(N,{item:t,key:a})))),null==b?void 0:b.map(((t,a)=>o.default.createElement(r.default.Group,{header:t.label,key:a},t.items.map(((t,a)=>(e++,!(e>j)&&o.default.createElement(N,{item:t,key:a})))),t.separator&&o.default.createElement(r.default.Divider,null)))))};return o.default.createElement(o.default.Fragment,null,I.current>1?o.default.createElement(r.default,{active:E,className:"creation-menu",onActiveChange:h,trigger:C?o.default.createElement(n.default,{"aria-label":O(),className:"nav-btn",title:O()},o.default.createElement(l.default,{className:"d-md-none dropdown-icon",symbol:"plus"}),o.default.createElement("span",{className:"d-md-block d-none pl-3 pr-3"},O())):o.default.createElement(n.ClayButtonWithIcon,{"aria-label":O(),className:"nav-btn nav-btn-monospaced",symbol:"plus",title:O()})},j<I.current?o.default.createElement(o.default.Fragment,null,o.default.createElement("div",{className:"inline-scroller"},o.default.createElement(_,{primaryItems:p,secondaryItems:b,visibleItemsCount:j})),o.default.createElement("div",{className:"dropdown-caption"},Liferay.Util.sub(Liferay.Language.get("showing-x-of-x-elements"),j,I.current)),o.default.createElement("div",{className:"dropdown-section"},o.default.createElement(d.default,{button:{block:!0},displayType:"secondary",href:g,onClick:()=>{m?m():M(I.current)}},Liferay.Language.get("more")))):o.default.createElement(_,{onCreationMenuItemClick:f,primaryItems:p,secondaryItems:b,visibleItemsCount:I.current})):C?o.default.createElement(o.default.Fragment,null,o.default.createElement(d.default,{"aria-label":O(),button:!0,className:"nav-btn",displayType:"primary",href:L.current.href,onClick:e=>{s(e,{item:L.current})},symbol:"plus",title:O(),wide:!0},Liferay.Language.get("new"))):o.default.createElement(d.default,{"aria-label":O(),button:!0,className:"nav-btn nav-btn-monospaced",displayType:"primary",href:L.current.href,onClick:e=>{s(e,{item:L.current})},symbol:"plus",title:O()}))};t.default=p}}));
//# sourceMappingURL=CreationMenu.js.map