import{defineComponent as G,computed as l,ref as h,watch as M,onBeforeUnmount as S,createVNode as n,Fragment as A,Transition as E,withDirectives as T,vShow as I}from"vue";import{CloseOutlined as L,FileTextOutlined as N}from"@antsoo-lib/icons";import R from"../_util/canUseDom.mjs";import g from"../_util/classNames.mjs";import U from"../_util/hooks/useMergedState.mjs";import{findDOMNode as j}from"../_util/props-util/index.mjs";import{getTransitionProps as V}from"../_util/transition.mjs";import b from"../config-provider/hooks/useConfigInject.mjs";import q,{floatButtonPrefixCls as z}from"./FloatButton.mjs";import{useProvideFloatButtonGroupContext as H}from"./context.mjs";import{floatButtonGroupProps as J}from"./interface.mjs";import K from"./style/index.mjs";import Q from"../_util/props-util/initDefaultProps.mjs";const ue=G({compatConfig:{MODE:3},name:"AFloatButtonGroup",inheritAttrs:!1,props:Q(J(),{type:"default",shape:"circle"}),setup(t,{attrs:p,slots:o,emit:a}){const{prefixCls:f,direction:C}=b(z,t),[O,m]=K(f),[u,i]=U(!1,{value:l(()=>t.open)}),d=h(null),v=h(null);H({shape:l(()=>t.shape)});const B={onMouseenter(){i(!0),a("update:open",!0),t.onOpenChange?.(!0)},onMouseleave(){i(!1),a("update:open",!1),t.onOpenChange?.(!1)}},w=l(()=>t.trigger==="hover"?B:{}),$=()=>{const e=!u.value;a("update:open",e),t.onOpenChange?.(e),i(e)},c=e=>{if(d.value?.contains(e.target)){j(v.value)?.contains(e.target)&&$();return}i(!1),a("update:open",!1),t.onOpenChange?.(!1)};return M(l(()=>t.trigger),e=>{R()&&(document.removeEventListener("click",c),e==="click"&&document.addEventListener("click",c))},{immediate:!0}),S(()=>{document.removeEventListener("click",c)}),()=>{const{shape:e="circle",type:x="default",tooltip:P,description:k,trigger:s}=t,r=`${f.value}-group`,F=g(r,m.value,p.class,{[`${r}-rtl`]:C.value==="rtl",[`${r}-${e}`]:e,[`${r}-${e}-shadow`]:!s}),y=g(m.value,`${r}-wrap`),D=V(`${r}-wrap`);return O(n("div",{ref:d,...p,class:F,...w.value},[s&&["click","hover"].includes(s)?n(A,null,[n(E,D,{default:()=>[T(n("div",{class:y},[o.default&&o.default()]),[[I,u.value]])]}),n(q,{ref:v,type:x,shape:e,tooltip:P,description:k},{icon:()=>u.value?o.closeIcon?.()||n(L,null,null):o.icon?.()||n(N,null,null),tooltip:o.tooltip,description:o.description})]):o.default?.()]))}}});export{ue as default};
