"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),b=require("../../common/utils/index.cjs"),c=require("../tooltip/tooltip-constants.cjs"),m=require("../popover/popover-constants.cjs"),g=require("../popover/popover.cjs"),C={__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 c.TOOLTIP_DIRECTIONS.includes(t)}},padding:{type:String,default:"large",validator:t=>Object.keys(m.POPOVER_PADDING_CLASSES).some(a=>a===t)},offset:{type:Array,default:()=>[0,16]},id:{type:String,default(){return b.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=>m.POPOVER_APPEND_TO_VALUES.includes(t)||t instanceof HTMLElement},enterDelay:{type:Number,default:c.TOOLTIP_DELAY_MS},leaveDelay:{type:Number,default:c.TOOLTIP_DELAY_MS}},emits:["opened"],setup(t){const a=t,l=e.ref(a.open),s=e.ref(null),i=e.ref(null),d=e.ref(null),u=e.ref(null),f=e.ref(null);e.onMounted(()=>{e.nextTick(()=>{var n,r,o;d.value=(o=(r=(n=f.value)==null?void 0:n.$refs)==null?void 0:r.anchor)==null?void 0:o.firstElementChild,u.value=new MutationObserver(()=>{d.value&&!d.value.isConnected&&(l.value=!1)}),u.value.observe(document.body,{childList:!0,subtree:!0})})}),e.onBeforeUnmount(()=>{u.value&&u.value.disconnect(),clearTimeout(s),clearTimeout(i)}),e.watch(()=>a.open,n=>{l.value=n},{immediate:!0});function y(){s.value=setTimeout(()=>{l.value=!0},a.enterDelay)}function T(){i.value=setTimeout(()=>{l.value=!1},a.leaveDelay)}function v(){a.open===null&&(clearTimeout(i.value),y())}function p(){a.open===null&&(clearTimeout(s.value),T())}return(n,r)=>(e.openBlock(),e.createBlock(e.unref(g.default),{id:t.id,ref_key:"popover",ref:f,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]=o=>n.$emit("opened",o)),onMouseenterPopover:v,onMouseleavePopover:p,onMouseenterPopoverAnchor:v,onMouseleavePopoverAnchor:p},{anchor:e.withCtx(({attrs:o})=>[e.renderSlot(n.$slots,"anchor",e.normalizeProps(e.guardReactiveProps(o)))]),content:e.withCtx(()=>[e.renderSlot(n.$slots,"content")]),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=C;
//# sourceMappingURL=hovercard.cjs.map
