const e=require("../../_util/classNames.js"),t=require("../../_util/raf.js"),n=require("../../_util/transition.js"),r=require("../../vc-trigger/index.js"),i=require("./hooks/useMenuContext.js"),a=require("./placements.js");let o=require("vue");var s={horizontal:`bottomLeft`,vertical:`rightTop`,"vertical-left":`rightTop`,"vertical-right":`leftTop`},c=(0,o.defineComponent)({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(c,{slots:l,emit:u}){let d=(0,o.shallowRef)(!1),{getPopupContainer:f,rtl:p,subMenuOpenDelay:m,subMenuCloseDelay:h,builtinPlacements:g,triggerSubMenuAction:_,forceSubMenuRender:v,motion:y,defaultMotions:b,rootClassName:x}=i.useInjectMenu(),S=i.useInjectForceRender(),C=(0,o.computed)(()=>p.value?{...a.placementsRtl,...g.value}:{...a.default,...g.value}),w=(0,o.computed)(()=>s[c.mode]),T=(0,o.shallowRef)();(0,o.watch)(()=>c.visible,e=>{t.default.cancel(T.value),T.value=t.default(()=>{d.value=e})},{immediate:!0}),(0,o.onBeforeUnmount)(()=>{t.default.cancel(T.value)});let E=e=>{u(`visibleChange`,e)},D=(0,o.computed)(()=>{let e=y.value||b.value?.[c.mode]||b.value?.other,t=typeof e==`function`?e():e;return t?n.getTransitionProps(t.name,{css:!0}):void 0});return()=>{let{prefixCls:t,popupClassName:n,mode:i,popupOffset:a,disabled:s}=c;return(0,o.createVNode)(r.default,{prefixCls:t,popupClassName:e.default(`${t}-popup`,{[`${t}-rtl`]:p.value},n,x.value),stretch:i===`horizontal`?`minWidth`:null,getPopupContainer:f.value,builtinPlacements:C.value,popupPlacement:w.value,popupVisible:d.value,popupAlign:a&&{offset:a},action:s?[]:[_.value],mouseEnterDelay:m.value,mouseLeaveDelay:h.value,onPopupVisibleChange:E,forceRender:S||v.value,popupAnimation:D.value},{popup:l.popup,default:l.default})}}});exports.default=c;