import{_ as h}from"./js/_plugin-vue_export-helper.5bcc150c.js";import{x as a,c as _,z as f,l as n,b as d,o as c,A as g,t as y,a as R,k as A,P as C}from"./js/vue.runtime.esm-bundler.308f2021.js";import{l as w}from"./js/index.a56340a2.js";import{l as k}from"./js/index.fadde3df.js";import{u as S,r as v,l as x}from"./js/links.bbde6535.js";/* empty css                */import{a as E}from"./js/addons.c8e26c5a.js";import{C as L}from"./js/Index.15a8ee01.js";import{C as b}from"./js/Index.9253ae87.js";import{i as H}from"./js/isEmpty.babda66c.js";import"./js/translations.6e7b2383.js";import"./js/default-i18n.3881921e.js";import"./js/constants.b87c371e.js";import"./js/Caret.baea7fe0.js";import"./js/isArrayLikeObject.965a2149.js";import"./js/upperFirst.56425447.js";import"./js/_stringToArray.4de3b1f3.js";import"./js/toString.1bb388e8.js";import"./js/JsonValues.870a4901.js";import"./js/strings.811ec52c.js";import"./js/isString.f3256d10.js";import"./js/ProBadge.bf5a3f4e.js";import"./js/External.94230600.js";import"./js/Exclamation.a152bf23.js";import"./js/Checkbox.30500119.js";import"./js/Checkmark.85e83e8c.js";import"./js/Gear.0eb3cd0c.js";import"./js/Slide.22dc72dc.js";import"./js/Tooltip.432f1167.js";import"./js/Plus.43cee912.js";import"./js/_getTag.bac3dff1.js";const $={setup(){return{rootStore:S()}},components:{CoreModal:L,CoreAddRedirection:b},data(){return{addons:E,urls:[],display:!1,target:null,loading:!1,strings:{modalHeader:this.$t.__("Add a Redirect",this.$td),redirectAdded:this.$t.sprintf(this.$t.__('%2$sYour redirect was added and you may edit it <a href="%1$s" target="_blank">here</a>.%3$s',this.$td),this.rootStore.aioseo.urls.aio.redirects,"<strong>","</strong>")},watchClasses:["aioseo-redirects-slug-changed","aioseo-redirects-trashed-post"]}},computed:{classSelectors(){return"."+this.watchClasses.join(", .")}},methods:{reload(){var t,s;this.display=!1;const e=(s=(t=this.target)==null?void 0:t.parentElement)==null?void 0:s.parentElement;if(e&&(e.classList.contains("components-notice__content")||e.classList.contains("notice"))){e.innerHTML="<p>"+this.strings.redirectAdded+"</p>";return}this.target.outerHTML=this.strings.redirectAdded},loadRedirect(e){this.loading=!0,v.get(this.$links.restUrl("redirects/manual-redirects/"+e)).then(t=>{this.urls=t.body.redirects,this.loading=!1}).catch(t=>console.error("Redirect modal failed to load the redirect data.",t))},preloadRedirect(){const e=document.querySelector(this.classSelectors);if(e){const t=this.getElementRedirectHash(e);if(!t)return;this.loadRedirect(t)}},watchClicks(){document.body.onclick=e=>{var s;if(!((s=e.target)!=null&&s.classList))return;let t=!1;this.watchClasses.forEach(i=>{e.target.classList.contains(i)&&(t=!0)}),t&&(e.preventDefault(),this.target=e.target,this.display=!0,H(this.url)&&this.loadRedirect(this.getElementRedirectHash(this.target)))}},getElementRedirectHash(e){return new URLSearchParams(e.href).get("aioseo-manual-urls")}},async created(){this.preloadRedirect(),this.watchClicks(),window.aioseoBus.$on("wp-core-notice-created",()=>{this.preloadRedirect()})}},B={key:0,class:"aioseo-redirects-add-redirect-standalone"},P={class:"bd"};function N(e,t,s,i,r,p){const m=a("core-add-redirection"),u=a("core-modal");return r.addons.isActive("aioseo-redirects")?(c(),_("div",B,[f(u,{show:r.display,classes:["aioseo-redirects","modal"],onClose:t[0]||(t[0]=U=>r.display=!1)},{headerTitle:n(()=>[g(y(r.strings.modalHeader),1)]),body:n(()=>[R("div",P,[r.loading?d("",!0):(c(),A(m,{key:0,urls:r.urls,target:r.urls[0].target?r.urls[0].target:"/",disableSource:!0,onAddedRedirect:p.reload},null,8,["urls","target","onAddedRedirect"]))])]),_:1},8,["show"])])):d("",!0)}const T=h($,[["render",N]]),l=document.createElement("div");l.id="aioseo-redirects-add-redirect-standalone";document.body.appendChild(l);let o=C({...T,name:"Standalone/Redirects/AddRedirect"});o=w(o);o=k(o);x(o);o.mount("#aioseo-redirects-add-redirect-standalone");
