"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),S=require("../../common/utils/index.cjs"),v=require("../tooltip/tooltip-constants.cjs"),h=require("../popover/popover.cjs"),T=require("../popover/popover-constants.cjs"),P={__name:"hovercard",props:{transition:{type:Boolean,default:!1},open:{type:Boolean,default:null},fallbackPlacements:{type:Array,default:()=>["auto"]},placement:{type:String,default:"top-start",validator(t){return v.TOOLTIP_DIRECTIONS.includes(t)}},padding:{type:String,default:"large",validator:t=>Object.keys(T.POPOVER_PADDING_CLASSES).some(o=>o===t)},offset:{type:Array,default:()=>[0,16]},id:{type:String,default(){return S.getUniqueString()}},headerClass:{type:[String,Array,Object],default:""},footerClass:{type:[String,Array,Object],default:""},dialogClass:{type:[String,Array,Object],default:""},contentClass:{type:[String,Array,Object],default:""},appendTo:{type:[HTMLElement,String],default:"body",validator:t=>T.POPOVER_APPEND_TO_VALUES.includes(t)||t instanceof HTMLElement},enterDelay:{type:Number,default:v.TOOLTIP_DELAY_MS},leaveDelay:{type:Number,default:v.TOOLTIP_DELAY_MS}},emits:["opened"],setup(t){const o=t,l=e.ref(o.open),s=e.ref(!1),i=e.ref(!1),c=e.ref(null),d=e.ref(null),f=e.ref(null),u=e.ref(null),p=e.ref(null);e.onMounted(()=>{e.nextTick(()=>{var n,r,a;f.value=(a=(r=(n=p.value)==null?void 0:n.$refs)==null?void 0:r.anchor)==null?void 0:a.firstElementChild,u.value=new MutationObserver(()=>{f.value&&!f.value.isConnected&&(l.value=!1)}),u.value.observe(document.body,{childList:!0,subtree:!0})})}),e.onBeforeUnmount(()=>{u.value&&u.value.disconnect(),clearTimeout(c),clearTimeout(d)}),e.watch(()=>o.open,n=>{l.value=n},{immediate:!0});function m(){o.open===null&&(clearTimeout(d.value),c.value=setTimeout(()=>{l.value=!0},o.enterDelay))}function y(){o.open===null&&(clearTimeout(c.value),d.value=setTimeout(()=>{l.value=!1},o.leaveDelay))}function C(){i.value=!0,m()}function O(){i.value=!1,!s.value&&y()}function b(){s.value=!0,m()}function g(){s.value=!1,i.value||y()}return(n,r)=>(e.openBlock(),e.createBlock(e.unref(h.default),{id:t.id,ref_key:"popover",ref:p,open:l.value,placement:t.placement,"content-class":t.contentClass,"dialog-class":t.dialogClass,"fallback-placements":t.fallbackPlacements,padding:t.padding,transition:t.transition?"fade":null,offset:t.offset,modal:!1,"initial-focus-element":"none","header-class":t.headerClass,"footer-class":t.footerClass,"append-to":t.appendTo,"data-qa":"dt-hovercard","enter-delay":t.enterDelay,"leave-delay":t.leaveDelay,onOpened:r[0]||(r[0]=a=>n.$emit("opened",a)),onMouseenterPopover:C,onMouseleavePopover:O,onMouseenterPopoverAnchor:C,onMouseleavePopoverAnchor:O},{anchor:e.withCtx(({attrs:a})=>[e.renderSlot(n.$slots,"anchor",e.normalizeProps(e.guardReactiveProps(a)))]),content:e.withCtx(()=>[e.createElementVNode("div",{onFocusin:b,onFocusout:g},[e.renderSlot(n.$slots,"content")],32)]),headerContent:e.withCtx(()=>[e.renderSlot(n.$slots,"headerContent")]),footerContent:e.withCtx(()=>[e.renderSlot(n.$slots,"footerContent")]),_:3},8,["id","open","placement","content-class","dialog-class","fallback-placements","padding","transition","offset","header-class","footer-class","append-to","enter-delay","leave-delay"]))}};exports.default=P;
//# sourceMappingURL=hovercard.cjs.map
