import e from"../../_util/classNames.mjs";import t from"../../_util/raf.mjs";import{getTransitionProps as n}from"../../_util/transition.mjs";import r from"../../vc-trigger/index.mjs";import{useInjectForceRender as i,useInjectMenu as a}from"./hooks/useMenuContext.mjs";import o,{placementsRtl as s}from"./placements.mjs";import{computed as c,createVNode as l,defineComponent as u,onBeforeUnmount as d,shallowRef as f,watch as p}from"vue";var m={horizontal:`bottomLeft`,vertical:`rightTop`,"vertical-left":`rightTop`,"vertical-right":`leftTop`},h=u({compatConfig:{MODE:3},name:`PopupTrigger`,inheritAttrs:!1,props:{prefixCls:String,mode:String,visible:Boolean,popupClassName:String,popupOffset:Array,disabled:Boolean,onVisibleChange:Function},slots:Object,emits:[`visibleChange`],setup(u,{slots:h,emit:g}){let _=f(!1),{getPopupContainer:v,rtl:y,subMenuOpenDelay:b,subMenuCloseDelay:x,builtinPlacements:S,triggerSubMenuAction:C,forceSubMenuRender:w,motion:T,defaultMotions:E,rootClassName:D}=a(),O=i(),k=c(()=>y.value?{...s,...S.value}:{...o,...S.value}),A=c(()=>m[u.mode]),j=f();p(()=>u.visible,e=>{t.cancel(j.value),j.value=t(()=>{_.value=e})},{immediate:!0}),d(()=>{t.cancel(j.value)});let M=e=>{g(`visibleChange`,e)},N=c(()=>{let e=T.value||E.value?.[u.mode]||E.value?.other,t=typeof e==`function`?e():e;return t?n(t.name,{css:!0}):void 0});return()=>{let{prefixCls:t,popupClassName:n,mode:i,popupOffset:a,disabled:o}=u;return l(r,{prefixCls:t,popupClassName:e(`${t}-popup`,{[`${t}-rtl`]:y.value},n,D.value),stretch:i===`horizontal`?`minWidth`:null,getPopupContainer:v.value,builtinPlacements:k.value,popupPlacement:A.value,popupVisible:_.value,popupAlign:a&&{offset:a},action:o?[]:[C.value],mouseEnterDelay:b.value,mouseLeaveDelay:x.value,onPopupVisibleChange:M,forceRender:O||w.value,popupAnimation:N.value},{popup:h.popup,default:h.default})}}});export{h as default};