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