import{Q as w}from"./vendor-other.ac1169a2.js";import{f as l,Q as c,R as i,a0 as S,a4 as O,Y as _,j as n,P as h,B as a,ae as d,U as f,a5 as C,S as m,aq as b,V as E,M as k}from"./vendor-vue-ui.65fbb3e9.js";import{_ as y}from"./_plugin-vue_export-helper.eefbdd86.js";const s=(e,o,t)=>{e&&o&&t&&(document.addEventListener?e.addEventListener(o,t,!1):e.attachEvent("on"+o,t))},r=(e,o,t)=>{e&&o&&(document.removeEventListener?e.removeEventListener(o,t,!1):e.detachEvent("on"+o,t))},P={emits:["show","hide","created","documentClick"],props:{tagName:{type:String,default:"span"},trigger:{type:String,default:"hover",validator:e=>-1<["clickToOpen","click","clickToToggle","hover","focus"].indexOf(e)},delayOnMouseOver:{type:Number,default:10},delayOnMouseOut:{type:Number,default:10},disabled:Boolean,content:String,enterActiveClass:String,leaveActiveClass:String,boundariesSelector:String,reference:{},forceShow:{type:Boolean,default:!1},dataValue:{default:null},appendToBody:Boolean,visibleArrow:{type:Boolean,default:!0},transition:{type:String,default:""},stopPropagation:Boolean,preventDefault:Boolean,options:{type:Object,default(){return{}}},rootClass:{type:String,default:""},classes:{type:Array,default(){return[]}}},data(){return{referenceElm:null,popperJS:null,showPopper:!1,currentPlacement:"",popperOptions:{placement:"bottom",computeStyle:{gpuAcceleration:!1}}}},watch:{showPopper(e){e?(this.$emit("show",this),this.popperJS&&this.popperJS.enableEventListeners(),this.updatePopper()):(this.popperJS&&this.popperJS.disableEventListeners(),this.$emit("hide",this))},forceShow:{handler(e){this[e?"doShow":"doClose"]()},immediate:!0},disabled(e){e&&(this.showPopper=!1)}},computed:{cssClasses(){const e=Array.isArray(this.classes)?this.classes:[];return this.showPopper&&!e.includes("popper-active")&&e.push("popper-active"),Array.isArray(this.classes)?this.classes:[]}},methods:{doToggle(e){this.stopPropagation&&e.stopPropagation(),this.preventDefault&&e.preventDefault(),this.forceShow||(this.showPopper=!this.showPopper)},doShow(){this.showPopper=!0},doClose(){this.showPopper=!1},doDestroy(){this.showPopper||(this.popperJS&&(this.popperJS.destroy(),this.popperJS=null),this.appendedToBody&&(this.appendedToBody=!1,document.body.removeChild(this.popper.parentElement)))},createPopper(){this.$nextTick(()=>{if(this.visibleArrow&&this.appendArrow(this.popper),this.appendToBody&&!this.appendedToBody&&(this.appendedToBody=!0,document.body.appendChild(this.popper.parentElement)),this.popperJS&&this.popperJS.destroy&&this.popperJS.destroy(),this.boundariesSelector){const e=document.querySelector(this.boundariesSelector);e&&(this.popperOptions.modifiers=Object.assign({},this.popperOptions.modifiers),this.popperOptions.modifiers.preventOverflow=Object.assign({},this.popperOptions.modifiers.preventOverflow),this.popperOptions.modifiers.preventOverflow.boundariesElement=e)}this.popperOptions.onCreate=()=>{this.$emit("created",this),this.$nextTick(this.updatePopper)},this.popperJS=new w(this.referenceElm,this.popper,this.popperOptions)})},destroyPopper(){r(this.referenceElm,"click",this.doToggle),r(this.referenceElm,"mouseup",this.doClose),r(this.referenceElm,"mousedown",this.doShow),r(this.referenceElm,"focus",this.doShow),r(this.referenceElm,"blur",this.doClose),r(this.referenceElm,"mouseout",this.onMouseOut),r(this.referenceElm,"mouseover",this.onMouseOver),r(document,"click",this.handleDocumentClick),this.showPopper=!1,this.doDestroy()},appendArrow(e){if(this.appendedArrow)return;this.appendedArrow=!0;const o=document.createElement("div");o.setAttribute("x-arrow",""),o.className="popper__arrow",e.appendChild(o)},updatePopper(){this.popperJS?this.popperJS.scheduleUpdate():this.createPopper()},onMouseOver(){clearTimeout(this._timer),this._timer=setTimeout(()=>{this.showPopper=!0},this.delayOnMouseOver)},onMouseOut(){clearTimeout(this._timer),this._timer=setTimeout(()=>{this.showPopper=!1},this.delayOnMouseOut)},handleDocumentClick(e){!this.$el||!this.referenceElm||this.elementContains(this.$el,e.target)||this.elementContains(this.referenceElm,e.target)||!this.popper||this.elementContains(this.popper,e.target)||(this.$emit("documentClick",this),!this.forceShow&&(this.showPopper=!1))},elementContains(e,o){return typeof e.contains=="function"?e.contains(o):!1}},created(){this.appendedArrow=!1,this.appendedToBody=!1,this.popperOptions=Object.assign(this.popperOptions,this.options)},mounted(){switch(this.referenceElm=this.reference||this.$refs.reference.firstElementChild,this.popper=this.$refs.content.firstElementChild,this.trigger){case"clickToOpen":s(this.referenceElm,"click",this.doShow),s(document,"click",this.handleDocumentClick),s(document,"touchstart",this.handleDocumentClick);break;case"click":case"clickToToggle":s(this.referenceElm,"click",this.doToggle),s(document,"click",this.handleDocumentClick),s(document,"touchstart",this.handleDocumentClick);break;case"hover":s(this.referenceElm,"mouseover",this.onMouseOver),s(this.popper,"mouseover",this.onMouseOver),s(this.referenceElm,"mouseout",this.onMouseOut),s(this.popper,"mouseout",this.onMouseOut);break;case"focus":s(this.referenceElm,"focus",this.onMouseOver),s(this.popper,"focus",this.onMouseOver),s(this.referenceElm,"blur",this.onMouseOut),s(this.popper,"blur",this.onMouseOut);break}},unmounted(){this.destroyPopper()}},T={ref:"content"},A={ref:"reference"};function B(e,o,t,v,u,p){return l(),c(m(t.tagName),{class:h([...p.cssClasses])},{default:i(()=>[S(O,{name:t.transition,"enter-active-class":t.enterActiveClass,"leave-active-class":t.leaveActiveClass,onAfterLeave:p.doDestroy},{default:i(()=>[_(n("div",{ref:"popper",class:h(t.rootClass)},[n("div",T,[a(e.$slots,"default",{},()=>[d(f(t.content),1)])],512)],2),[[C,!t.disabled&&u.showPopper]])]),_:3},8,["name","enter-active-class","leave-active-class","onAfterLeave"]),n("div",A,[a(e.$slots,"reference")],512)]),_:3},8,["class"])}const M=y(P,[["render",B]]),D={components:{CorePopper:M},props:{tooltip:String,type:String,disabled:Boolean,placement:{type:String,default(){return"top"}},trigger:{type:String,default(){return"hover"}},forceShow:{type:Boolean,default(){return!1}},tag:{type:String,default(){return"span"}},offset:{type:String,default(){return"0,0"}},flip:{type:Boolean,default(){return!1}},zIndex:String}};function J(e,o,t,v,u,p){const g=b("core-popper");return l(),c(g,{classes:["aioseo-tooltip"],trigger:t.trigger,"force-show":t.forceShow,disabled:t.disabled,options:{placement:t.placement,modifiers:{flip:{enabled:t.flip},preventOverflow:{escapeWithReference:!0},offset:{offset:t.offset}}}},{reference:i(()=>[a(e.$slots,"default")]),default:i(()=>[n("span",{class:h(["popper",{[t.type]:t.type}]),style:E({zIndex:t.zIndex})},[t.tooltip?(l(),c(m(t.tag),{key:0},{default:i(()=>[d(f(t.tooltip),1)]),_:1})):k("",!0),a(e.$slots,"tooltip")],6)]),_:3},8,["trigger","force-show","disabled","options"])}const V=y(D,[["render",J]]);export{V as C,M as a};