import{n as e,P as n,o,V as r,W as a,j as t,R as s,X as l,L as c,l as i,Y as p,f as d,_ as u,g as f,d as m,a as x,c as v,p as h,b as j,k as g,i as k}from"../../vendor.js";import{forwardRef as b,useState as N,useReducer as y,useImperativeHandle as T}from"react";import{usePopper as w}from"react-popper";import{a as C,u as O}from"../../hooks.js";import{I as D}from"../Icon/index.js";import{T as E}from"../Text/index.js";function I(e,n){var o=g(e);if(k){var r=k(e);n&&(r=i(r).call(r,(function(n){return v(e,n).enumerable}))),o.push.apply(o,r)}return o}function A(e){for(var n=1;n<arguments.length;n++){var o,r=null!=arguments[n]?arguments[n]:{};if(n%2)d(o=I(Object(r),!0)).call(o,(function(n){u(e,n,r[n])}));else if(f)m(e,f(r));else{var a;d(a=I(Object(r))).call(a,(function(n){x(e,n,v(r,n))}))}}return e}var L=b((function(d,u){var f,m,x=d.globalEventsTarget,v=void 0===x?global:x,g=d.placement,k=void 0===g?"bottom":g,b=d.popperOptions,I=void 0===b?{}:b,L=d.onToggle,P=void 0===L?function(){}:L,R=d.onAppend,V=void 0===R?function(){}:R,W=C().components,X=void 0===W?[]:W,Y=O().otherTabEnabled,_=N(),q=e(_,2),z=q[0],B=q[1],F=N(),G=e(F,2),H=G[0],J=G[1],K=N(),M=e(K,2),Q=M[0],S=M[1],U=y(n,{opened:!1}),Z=e(U,2),$=Z[0],ee=Z[1],ne=w(H,z,{placement:k,modifiers:o(f=[]).call(f,r(I.modifiers||[]),[{name:"arrow",options:{element:Q}},{name:"offset",options:{offset:[Q&&/-(start|end)/.test(k)?-5:0,16]}}])}),oe=ne.styles,re=ne.attributes;a("click",(function(e){se(e)}),v),T(u,(function(){return{open:ae,close:te,opened:$.opened}}));var ae=function(){ee({opened:!0}),P({opened:!0})},te=function(){ee({opened:!1}),P({opened:!1})},se=function(e){z&&H&&(H.contains(e.target)||H===e.target||z.contains(e.target)||z===e.target||te())},le=function(e){var n,r,a;if(!e||!1===Y&&"other"===e.id)return null;var l,p,d,u=o(n=o(r=[]).call(r,e.components)).call(n,c(a=i(X).call(X,(function(n){return n.group===e.id}))).call(a,(function(e){return e.component})));!1===Y&&"core"===e.id&&(u=o(l=o(u).call(u,(null===(p=h(X).call(X,(function(e){return"other"===e.id})))||void 0===p?void 0:p.components)||[])).call(l,c(d=i(X).call(X,(function(e){return"other"===e.group}))).call(d,(function(e){return e.component}))));return t.exports.jsx("div",{className:"oak-components",children:c(u).call(u,(function(e,n){return t.exports.jsx("div",{className:s("oak-component","oak-component-"+(e.id||"unknown")),children:t.exports.jsxs("a",{href:"#",draggable:!1,onClick:j(ce).call(ce,null,e),children:["function"==typeof e.icon?e.icon():t.exports.jsx(D,{className:"oak-component-icon",children:e.icon}),t.exports.jsx("span",{children:t.exports.jsx(E,{children:e.name})})]})},e.id||n)}))})},ce=function(e,n){null==n||n.preventDefault(),V(e)};return t.exports.jsxs("div",{className:s("oak-catalogue",{"oak-opened":$.opened}),children:[t.exports.jsx("a",{ref:J,className:"oak-handle",onClick:function(e){e.preventDefault(),$.opened?te():ae()},draggable:!1,href:"#",children:t.exports.jsx("span",{className:"oak-handle-inner",children:t.exports.jsx(D,{children:"add"})})}),$.opened&&t.exports.jsxs("div",A(A({ref:B,style:oe.popper,className:"oak-popover"},re.popper),{},{"data-placement":k,children:[t.exports.jsx("div",{className:"oak-groups",children:t.exports.jsx(l,{children:c(m=i(X).call(X,(function(e){return"group"===e.type&&(!1!==Y||"other"!==e.id)}))).call(m,(function(e,n){return t.exports.jsx(p,{title:t.exports.jsx(E,{children:e.name}),children:le(e)},n)}))})}),t.exports.jsx("div",{ref:S,style:oe.arrow,className:"oak-arrow"})]}))]})}));export{L as C};
//# sourceMappingURL=index.js.map
