Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require(`../../chunk-Bmb41Sf3.cjs`),t=require(`../../common/utils/index.cjs`),n=require(`../tooltip/tooltip-constants.cjs`),r=require(`../tooltip/tooltip.cjs`);let i=require(`vue`),a=require(`deep-equal`);a=e.t(a);var o={name:`dt-tooltip-directive`,install(e){if(!globalThis.__DtTooltipDirectiveApp){let e=(0,i.createApp)({name:`DtTooltipDirectiveApp`,components:{DtTooltip:r.default},data(){return{tooltips:[]}},mounted(){globalThis.__DtTooltipDirectiveApp=this},methods:{addOrUpdateTooltip(e,t){let n=this.tooltips.findIndex(t=>t.id===e);n===-1?this.tooltips.push({id:e,...t}):this.tooltips.splice(n,1,{id:e,...t})},removeTooltip(e){this.tooltips=this.tooltips.filter(t=>t.id!==e)}},render(){return(0,i.h)(`div`,this.tooltips.map(({id:e,anchorElement:t,...n})=>(0,i.h)(r.default,{key:e,...n,sticky:n.sticky===void 0?!0:n.sticky,delay:n.delay===void 0?process.env.NODE_ENV!==`test`:n.delay,externalAnchorElement:t})))}}),t=document.createElement(`div`);document.body.appendChild(t),e.mount(t)}let o=globalThis.__DtTooltipDirectiveApp;e.directive(`dt-tooltip`,{beforeMount(e,t){s(e,t)},updated(e,t){(0,a.default)(t.value,t.oldValue)||s(e,t)},unmounted(e){o.removeTooltip(e.getAttribute(`data-dt-tooltip-id`))}});function s(e,r){if(r.value===null||r.value===void 0){let t=e.getAttribute(`data-dt-tooltip-id`);t&&o.removeTooltip(t);return}let i=e.getAttribute(`data-dt-tooltip-id`)||t.getUniqueString(),a;if(typeof r.value==`string`)a={message:r.value,placement:r.arg||`top`};else if(typeof r.value==`object`&&r.value!==null)a={placement:r.arg||r.value.placement||`top`,...r.value};else{console.error(`DtTooltipDirective: binding value must be string, object, null or undefined`);return}Object.keys(r.modifiers).forEach(e=>{switch(e){case`inverted`:a.inverted=!0;break;case`no-delay`:a.delay=!1;break;case`no-transition`:a.transition=!1;break;default:n.TOOLTIP_DIRECTIONS.includes(e)&&(a.placement=e);break}}),a.anchorElement=e,e.setAttribute(`data-dt-tooltip-id`,i),o.addOrUpdateTooltip(i,a)}}};exports.DtTooltipDirective=o,exports.default=o;
//# sourceMappingURL=tooltip.cjs.map