import{b as y}from"./app-core.82d0a9b8.js";import{S as _}from"./Close.ed64f0a2.js";import{as as w,f as t,Q as C,i as l,a0 as d,R as u,M as r,a4 as h,T as c,j as m,B as n,P as g,a2 as v}from"./vendor-vue-ui.02763c14.js";import{_ as k}from"./_plugin-vue_export-helper.eefbdd86.js";const M={emits:["close"],setup(){return{rootStore:y()}},components:{SvgClose:_},props:{classes:{type:Array,default(){return[]}},allowBgClose:{type:Boolean,default:!0},noHeader:Boolean,allowOverflow:Boolean,show:Boolean,modalName:String,teleportTo:{type:[String,HTMLElement],default(){return"#aioseo-modal-portal"}}},data(){return{shouldRender:!0}},watch:{show(e){if(e){this.startListening(),this.scrollToElement(),this.rootStore.setActiveModal(this.modalName||this.$.uid);return}this.closeModal(),this.stopListening()}},computed:{cssClasses(){const e=Array.isArray(this.classes)?[...this.classes]:[];return this.allowOverflow&&e.push("allow-overflow"),e}},methods:{scrollToElement(){const e=this.$el.getElementsByClassName?this.$el.getElementsByClassName("component-wrapper")[0]:null;setTimeout(()=>{e&&(e.firstChild.scrollTop=0)},10)},escapeListener(e){e.key==="Escape"&&(this.modalName||this.$.uid)===this.rootStore.modals.active&&(e.stopPropagation(),this.closeModal())},maybeCloseModal(e){this.allowBgClose&&e.target.classList.contains("modal-wrapper")&&(this.modalName||this.$.uid)===this.rootStore.modals.active&&this.closeModal()},startListening(){document.addEventListener("keydown",this.escapeListener,!0)},stopListening(){document.removeEventListener("keydown",this.escapeListener)},closeModal(){this.$emit("close"),this.rootStore.unsetActiveModal(this.modalName||this.$.uid)}},beforeMount(){this.modalName&&(this.shouldRender=!this.rootStore.modals.rendered.has(this.modalName),this.rootStore.modals.rendered.add(this.modalName))},beforeUnmount(){this.modalName&&this.rootStore.modals.rendered.delete(this.modalName)}},N=["show"],S={key:0,class:"modal-mask"},B={class:"modal-container"},L={key:0,class:"modal-header"},b={class:"modal-body"},T={key:1,class:"modal-container__footer"};function E(e,o,a,A,p,s){const f=w("svg-close");return t(),C(v,{to:a.teleportTo},[p.shouldRender?(t(),l("div",{key:0,show:a.show,class:g(["aioseo-app aioseo-modal",[...s.cssClasses]])},[d(h,{name:"modal-background"},{default:u(()=>[a.show?(t(),l("div",S)):r("",!0)]),_:1}),d(h,{name:"modal-content"},{default:u(()=>[a.show?(t(),l("div",{key:0,class:"modal-wrapper",onClick:o[1]||(o[1]=c((...i)=>s.maybeCloseModal&&s.maybeCloseModal(...i),["stop"])),onContextmenu:o[2]||(o[2]=c(()=>{},["stop"]))},[m("div",B,[a.noHeader?r("",!0):(t(),l("div",L,[n(e.$slots,"header",{},()=>[n(e.$slots,"headerTitle"),m("button",{class:"close",type:"button",onClick:o[0]||(o[0]=c((...i)=>s.closeModal&&s.closeModal(...i),["stop"]))},[d(f,{width:"14",height:"14",onClick:s.closeModal},null,8,["onClick"])])])])),m("div",b,[n(e.$slots,"body")]),e.$slots.footer?(t(),l("div",T,[n(e.$slots,"footer")])):r("",!0)])],32)):r("",!0)]),_:3})],10,N)):r("",!0)],8,["to"])}const P=k(M,[["render",E]]);export{P as C};
