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