import{a as n,b as e,D as o,E as a,F as r,G as t,H as c,m as l,A as s,I as i,B as d,J as p,n as u,o as f,q as m,r as h,s as v,K as x,L as j,M as g,g as b,N as k,e as N,y,z as C}from"../../vendor.js";import{forwardRef as T,useReducer as w,useImperativeHandle as E}from"react";import{u as O,a as P}from"../../hooks.js";import{I as D}from"../Icon/index.js";import{T as F}from"../Text/index.js";function I(n,e){var o=y(n);if(C){var a=C(n);e&&(a=b(a).call(a,(function(e){return v(n,e).enumerable}))),o.push.apply(o,a)}return o}function A(n){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{};e%2?I(Object(o),!0).forEach((function(e){u(n,e,o[e])})):f?m(n,f(o)):I(Object(o)).forEach((function(e){h(n,e,v(o,e))}))}return n}var J=T((function(u,f){var m,h=u.placement,v=void 0===h?"bottom":h,y=u.onToggle,C=void 0===y?function(){}:y,T=u.onAppend,I=void 0===T?function(){}:T,J=u.onPaste,q=void 0===J?function(){}:J,z=O(),B=z.components,G=void 0===B?[]:B,H=z.getComponent,K=P().otherTabEnabled,L=w(n,{opened:!1,clipboard:null}),M=e(L,2),R=M[0],S=M[1],_=o({open:R.opened,onOpenChange:function(n){return n?en():an()},middleware:[a(16)]}),Q=_.x,U=_.y,V=_.reference,W=_.floating,X=_.strategy,Y=_.context,Z=r([t(Y),c(Y)]),$=Z.getReferenceProps,nn=Z.getFloatingProps;E(f,(function(){return{open:en,close:an,toggle:rn,opened:R.opened}}));var en=function(){S({opened:!0}),C({opened:!0}),on()},on=function(){var n=x(j.mark((function n(){var e,o;return j.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,n.t0=JSON,n.next=4,g.navigator.clipboard.readText();case 4:n.t1=n.sent,o=n.t0.parse.call(n.t0,n.t1),H(o.type)&&(e=o),n.next=11;break;case 9:n.prev=9,n.t2=n.catch(0);case 11:S({clipboard:e});case 12:case"end":return n.stop()}}),n,null,[[0,9]])})));return function(){return n.apply(this,arguments)}}(),an=function(){S({opened:!1,clipboard:null}),C({opened:!1})},rn=function(n){n.preventDefault(),R.opened?an():en()},tn=function(n){var e,o,a;if(!n||!1===K&&"other"===n.id)return null;var r,t,c,i=k(e=k(o=[]).call(o,n.components)).call(e,d(a=b(G).call(G,(function(e){return e.group===n.id}))).call(a,(function(n){return n.component})));!1===K&&"core"===n.id&&(i=k(r=k(i).call(i,(null===(t=N(G).call(G,(function(n){return"other"===n.id})))||void 0===t?void 0:t.components)||[])).call(r,d(c=b(G).call(G,(function(n){return"other"===n.group}))).call(c,(function(n){return n.component}))));return l.jsx("div",{className:"oak-components",children:d(i).call(i,(function(n,e){return l.jsx("div",{className:s("oak-component","oak-component-"+(n.id||"unknown")),children:l.jsxs("a",{href:"#",draggable:!1,onClick:cn.bind(null,n),children:[l.jsx("div",{className:"oak-component-icon",children:"function"==typeof n.icon?n.icon({component:n,className:"oak-icons"}):l.jsx(D,{children:n.icon})}),l.jsx("span",{children:l.jsx(F,{children:n.name})})]})},n.id||e)}))})},cn=function(n,e){null==e||e.preventDefault(),I(n)};return l.jsxs("div",{className:s("oak-catalogue",{"oak-opened":R.opened}),children:[l.jsx("a",A(A({ref:V,className:"oak-handle",draggable:!1},$()),{},{children:l.jsx("span",{className:"oak-handle-inner",children:l.jsx(D,{children:"add"})})})),R.opened&&l.jsx("div",A(A({ref:W,className:"oak-popover",style:{position:X,top:null!=U?U:0,left:null!=Q?Q:0},"data-placement":v},nn()),{},{children:l.jsxs("div",{className:"oak-groups",children:[l.jsx(i,{children:d(m=b(G).call(G,(function(n){return"group"===n.type&&(!1!==K||"other"!==n.id)}))).call(m,(function(n,e){return l.jsx(p,{title:l.jsx(F,{children:n.name}),children:tn(n)},e)}))}),R.clipboard&&l.jsxs("a",{onClick:q.bind(null,R.clipboard),className:"oak-clipboard",children:[l.jsx(D,{children:"content_paste"}),l.jsx(F,{name:"core.pasteFromClipboard",default:"Paste from clipboard"})]})]})}))]})})),q=J;export{q as C};
//# sourceMappingURL=index.js.map
