import{u as y}from"./index.bd66e758.js";import{b as _}from"./Caret.382b7591.js";import{x as w,o as s,l as C,c as a,H as d,m,b as l,T as u,J as h,a as c,q as n,K as g,M as v}from"./runtime-dom.esm-bundler.5d5e6b71.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,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"),Array.isArray(this.classes)?this.classes:[]}},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"},B={key:0,class:"modal-header"},L={class:"modal-body"},A={key:1,class:"modal-container__footer"};function T(e,r,t,E,p,o){const f=w("svg-close");return s(),C(v,{to:t.teleportTo},[p.shouldRender?(s(),a("div",{key:0,show:t.show,class:g(["aioseo-app aioseo-modal",[...o.cssClasses]])},[d(u,{name:"modal-background"},{default:m(()=>[t.show?(s(),a("div",S)):l("",!0)]),_:1}),d(u,{name:"modal-content"},{default:m(()=>[t.show?(s(),a("div",{key:0,class:"modal-wrapper",onClick:r[1]||(r[1]=h((...i)=>o.maybeCloseModal&&o.maybeCloseModal(...i),["stop"]))},[c("div",b,[t.noHeader?l("",!0):(s(),a("div",B,[n(e.$slots,"header",{},()=>[n(e.$slots,"headerTitle"),c("button",{class:"close",type:"button",onClick:r[0]||(r[0]=h((...i)=>o.closeModal&&o.closeModal(...i),["stop"]))},[d(f,{onClick:o.closeModal},null,8,["onClick"])])])])),c("div",L,[n(e.$slots,"body")]),e.$slots.footer?(s(),a("div",A,[n(e.$slots,"footer")])):l("",!0)])])):l("",!0)]),_:3})],10,N)):l("",!0)],8,["to"])}const V=k(M,[["render",T]]);export{V as C};
