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