import{a as n,S as e,j as o,C as t,k as r,l as s,m as a,n as i,o as p,t as l,u,f}from"../../vendor.js";import{createPortal as c}from"react-dom";import{forwardRef as m,useState as d,useReducer as v,useEffect as g,useImperativeHandle as j,cloneElement as b,Children as h}from"react";import{usePopper as y}from"react-popper";import{u as x,a as k}from"../../hooks.js";import{F as S}from"./Form.js";function C(n,e){var o=l(n);if(u){var t=u(n);e&&(t=f(t).call(t,(function(e){return p(n,e).enumerable}))),o.push.apply(o,t)}return o}var E=m((function(l,u){var f,m,E,O=l.children,F=l.element,R=l.component,N=x(),w=N._settingsHolderRef,B=N.overrides,H=N.oakRef,_=k(),q=d(),z=n(q,2),A=z[0],D=z[1],G=d(),I=n(G,2),J=I[0],K=I[1],L=v(e,{opened:!1}),M=n(L,2),P=M[0],Q=M[1];g((function(){X()}),[B]);var T=y(J,A,function(n){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{};e%2?C(Object(o),!0).forEach((function(e){r(n,e,o[e])})):s?a(n,s(o)):C(Object(o)).forEach((function(e){i(n,e,p(o,e))}))}return n}({},("function"==typeof(null==R||null===(f=R.settings)||void 0===f?void 0:f.popperSettings)?null==R||null===(m=R.settings)||void 0===m?void 0:m.popperSettings({optionButtonElement:J}):null==R||null===(E=R.settings)||void 0===E?void 0:E.popperSettings)||{modifiers:[{name:"preventOverflow",enabled:!0,options:{boundary:null==H?void 0:H.current}},{name:"offset",options:{offset:[0,5]}}]})),U=T.styles,V=T.attributes;j(u,(function(){return{open:W,close:X,toggle:Y}}));var W=function(){Q({opened:!0})},X=function(){Q({opened:!1})},Y=function(){return P.opened?X():W()},Z=function(){return o.exports.jsx(S,{ref:D,popper:A,element:F,component:R,styles:U,attributes:V,onSave:X,onCancel:X})};return o.exports.jsxs(o.exports.Fragment,{children:[O&&b(h.only(O),{ref:function(n){K(null!=n&&n.isOak?n.innerRef.current:n)},className:t(h.only(O).props.className,{"oak-opened":P.opened})}),P.opened?_.settingsContainer||w?c(Z(),_.settingsContainer||w):Z():null]})}));export{E};
//# sourceMappingURL=index.js.map
