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