import{a as n,b as e,D as t,$ as o,N as a,E as l,_ as i,a0 as r,a1 as s,a2 as u,F as c,G as p,m as d,A as f,n as m,o as g,q as v,r as b,s as h,a3 as y,y as j,z as x,g as E}from"../../vendor.js";import{forwardRef as k,useReducer as C,useMemo as F,useImperativeHandle as P,Children as w,cloneElement as O}from"react";import{createPortal as R}from"react-dom";import{u as S,a as N}from"../../hooks.js";import{F as _}from"./Form.js";function q(n,e){var t=j(n);if(x){var o=x(n);e&&(o=E(o).call(o,(function(e){return h(n,e).enumerable}))),t.push.apply(t,o)}return t}function z(n){for(var e=1;e<arguments.length;e++){var t=null!=arguments[e]?arguments[e]:{};e%2?q(Object(t),!0).forEach((function(e){m(n,e,t[e])})):g?v(n,g(t)):q(Object(t)).forEach((function(e){b(n,e,h(t,e))}))}return n}var A=k((function(m,g){var v,b,h,j=m.children,x=m.element,E=m.component,k=m.onToggle,q=S(),A=q._settingsHolderRef,B=q.oakRef,D=N(),G=C(n,{opened:!1,visible:!1}),H=e(G,2),M=H[0],T=H[1],$=F((function(){var n,e;return("function"==typeof(null==E||null===(n=E.settings)||void 0===n?void 0:n.floatingSettings)?E.settings.floatingSettings({optionButtonElement:L}):null==E||null===(e=E.settings)||void 0===e?void 0:e.floatingSettings)||{}}),[E]),I=t({open:M.opened,onOpenChange:function(n){return n?Z():nn()},whileElementsMounted:o,placement:$.placement||"bottom",middleware:a(v=[l(5)]).call(v,i(!1!==(null==$||null===(b=$.shift)||void 0===b?void 0:b.enabled)?[r(z({boundary:null==B?void 0:B.current,limiter:s()},$.shift||{}))]:[]),i(!1!==(null==$||null===(h=$.autoPlacement)||void 0===h?void 0:h.enabled)?[u(z({boundary:null==B?void 0:B.current,allowedPlacements:["bottom","top"]},$.autoPlacement||{}))]:[]),i($.middleware||[]))}),J=I.x,K=I.y,L=I.reference,Q=I.floating,U=I.strategy,V=I.context,W=c([p(V)]),X=W.getReferenceProps,Y=W.getFloatingProps;P(g,(function(){return{open:Z,close:nn,toggle:en}}));var Z=function(){T({opened:!0,visible:!0}),null==k||k({opened:!0})},nn=function(){T({opened:!1}),null==k||k({opened:!1})},en=function(){return M.opened?nn():Z()},tn=function(){T({visible:!1})},on=function(){return M.visible&&d.jsx("div",z(z({style:{position:U,top:null!=K?K:0,left:null!=J?J:0},"data-placement":V.placement,ref:Q},Y()),{},{children:y(d.jsx(_,{element:x,component:E,placement:V.placement,onSave:nn,onCancel:nn}),{opened:M.opened,onExited:tn})}))},an=w.only(j);return d.jsxs(d.Fragment,{children:[an&&O(an,z({ref:function(n){L(null!=n&&n.isOak?n.innerRef.current:n)},className:f(an.props.className,{"oak-opened":M.opened})},X({onClick:an.props.onClick}))),D.settingsContainer||A?R(on(),D.settingsContainer||A):on()]})}));export{A as E};
//# sourceMappingURL=index.js.map
