import{r as o,_ as K,t as U,N as W,i as t,R as r,O as X,k as Y,P as e,Q as Z,S as $}from"./index-CxHdhPEA.js";import{g as ee,e as ne}from"./getRTLPlacement-C2nYXCSu.js";var x=o.forwardRef(function(n,F){var M=n.children,v=n.animation,j=v===void 0?!0:v,q=n.className,L=n.container,A=n.content,g=n.delay,f=g===void 0?0:g,b=n.fallbackPlacements,B=b===void 0?["top","right","bottom","left"]:b,h=n.offset,I=h===void 0?[0,8]:h,y=n.onHide,P=n.onShow,k=n.placement,Q=k===void 0?"top":k,d=n.popperConfig,V=n.title,w=n.trigger,i=w===void 0?"click":w,m=n.visible,_=K(n,["children","animation","className","container","content","delay","fallbackPlacements","offset","onHide","onShow","placement","popperConfig","title","trigger","visible"]),a=o.useRef(null),s=o.useRef(null),z=U(F,a),C="popover".concat(o.useId()),E=o.useState(!1),l=E[0],R=E[1],T=o.useState(m),c=T[0],N=T[1],S=W(),D=S.initPopper,G=S.destroyPopper,O=typeof f=="number"?{show:f,hide:f}:f,H={modifiers:[{name:"arrow",options:{element:".popover-arrow"}},{name:"flip",options:{fallbackPlacements:B}},{name:"offset",options:{offset:I}}],placement:ee(Q,s.current)},J=t(t({},H),typeof d=="function"?d(H):d);o.useEffect(function(){if(m){u();return}p()},[m]),o.useEffect(function(){if(l&&s.current&&a.current){D(s.current,a.current,J),setTimeout(function(){N(!0)},O.show);return}!l&&s.current&&a.current&&G()},[l]),o.useEffect(function(){!c&&s.current&&a.current&&ne(function(){R(!1)},a.current)},[c]);var u=function(){R(!0),P&&P()},p=function(){setTimeout(function(){N(!1),y&&y()},O.hide)};return r.createElement(r.Fragment,null,r.cloneElement(M,t(t(t(t(t({},c&&{"aria-describedby":C}),{ref:s}),(i==="click"||i.includes("click"))&&{onClick:function(){return c?p():u()}}),(i==="focus"||i.includes("focus"))&&{onFocus:function(){return u()},onBlur:function(){return p()}}),(i==="hover"||i.includes("hover"))&&{onMouseEnter:function(){return u()},onMouseLeave:function(){return p()}})),r.createElement(X,{container:L,portal:!0},l&&r.createElement("div",t({className:Y("popover","bs-popover-auto",{fade:j,show:c},q),id:C,ref:z,role:"tooltip"},_),r.createElement("div",{className:"popover-arrow"}),r.createElement("div",{className:"popover-header"},V),r.createElement("div",{className:"popover-body"},A))))});x.propTypes={animation:e.bool,children:e.node,className:e.string,container:e.any,content:e.oneOfType([e.string,e.node]),delay:e.oneOfType([e.number,e.shape({show:e.number.isRequired,hide:e.number.isRequired})]),fallbackPlacements:$,offset:e.any,onHide:e.func,onShow:e.func,placement:e.oneOf(["auto","top","right","bottom","left"]),popperConfig:e.oneOfType([e.func,e.object]),title:e.oneOfType([e.string,e.node]),trigger:Z,visible:e.bool};x.displayName="CPopover";export{x as C};
|