import{defineComponent as k,shallowRef as s,toRef as B,watch as P,computed as y,createVNode as c,Transition as H,withDirectives as L,withModifiers as M,vShow as W}from"vue";import q from"../../_util/classNames.mjs";import{flattenChildren as G}from"../../_util/props-util/index.mjs";import J from"../../_util/supportsPassive.mjs";import{getTransitionProps as K}from"../../_util/transition.mjs";import Q from"../../vc-align/Align.mjs";import{getMotion as U}from"../utils/motionUtil.mjs";import{innerProps as X}from"./interface.mjs";import Y from"./useStretchStyle.mjs";import Z from"./useVisibleStatus.mjs";const me=k({compatConfig:{MODE:3},name:"PopupInner",inheritAttrs:!1,props:X,emits:["mouseenter","mouseleave","mousedown","touchstart","align"],setup(e,{expose:N,attrs:g,slots:S}){const h=s(),f=s(),r=s(),[C,R]=Y(B(e,"stretch")),p=()=>{e.stretch&&R(e.getRootDomNode())},o=s(!1);let b;P(()=>e.visible,t=>{clearTimeout(b),t?b=setTimeout(()=>{o.value=e.visible}):o.value=!1},{immediate:!0});const[a,v]=Z(o,p),A=s(),T=()=>e.point?e.point:e.getRootDomNode,w=()=>{h.value?.forceAlign()},E=(t,i)=>{const n=e.getClassNameFromAlign(i),l=r.value;r.value!==n&&(r.value=n),a.value==="align"&&(l!==n?Promise.resolve().then(()=>{w()}):v(()=>{A.value?.()}),e.onAlign?.(t,i))},u=y(()=>{const t=typeof e.animation=="object"?e.animation:U(e);return["onAfterEnter","onAfterLeave"].forEach(i=>{const n=t[i];t[i]=l=>{v(),a.value="stable",n?.(l)}}),t}),x=()=>new Promise(t=>{A.value=t});P([u,a],()=>{!u.value&&a.value==="motion"&&v()},{immediate:!0}),N({forceAlign:w,getElement:()=>f.value.$el||f.value});const D=y(()=>!(e.align?.points&&(a.value==="align"||a.value==="stable")));return()=>{const{zIndex:t,align:i,prefixCls:n,destroyPopupOnHide:l,onMouseenter:I,onMouseleave:V,onTouchstart:$=()=>{},onMousedown:z}=e,d=a.value,F=[{...C.value,zIndex:t,opacity:d==="motion"||d==="stable"||!o.value?null:0,pointerEvents:!o.value&&d!=="stable"?"none":null},g.style];let m=G(S.default?.({visible:e.visible}));m.length>1&&(m=c("div",{class:`${n}-content`},[m]));const O=q(n,g.class,r.value,!e.arrow&&`${n}-arrow-hidden`),j=o.value||!e.visible?K(u.value.name,u.value):{};return c(H,{ref:f,...j,onBeforeEnter:x},{default:()=>!l||e.visible?L(c(Q,{target:T(),key:"popup",ref:h,monitorWindowResize:!0,disabled:D.value,align:i,onAlign:E},{default:()=>c("div",{class:O,onMouseenter:I,onMouseleave:V,onMousedown:M(z,["capture"]),[J?"onTouchstartPassive":"onTouchstart"]:M($,["capture"]),style:F},[m])}),[[W,o.value]]):null})}}});export{me as default};
