import{_ as f}from"./js/_plugin-vue_export-helper.3febc96a.js";import{r as d,c as _,d as c,w as l,b as i,o as a,B as g,x as y,a as R,E as C}from"./js/vue.runtime.esm-bundler.f433d23f.js";import{l as A}from"./js/index.c9841ea4.js";import{l as k}from"./js/index.57ad6f19.js";import{u as w,h as S,l as E}from"./js/links.96ffe3f0.js";import{a as L}from"./js/addons.82a86b55.js";import{C as b}from"./js/Portal.1200f0ad.js";import{C as v}from"./js/Index.381d4377.js";import{i as x}from"./js/isEmpty.f4c19578.js";import"./js/translations.f6b76bbe.js";import"./js/default-i18n.41786823.js";import"./js/constants.008ef172.js";import"./js/Caret.b5c2e4ec.js";import"./js/isArrayLikeObject.7c69e632.js";import"./js/upperFirst.6e4a3e83.js";import"./js/_stringToArray.4de3b1f3.js";import"./js/toString.9a2ec6a1.js";import"./js/Index.af046b6e.js";/* empty css                                                 *//* empty css                                               *//* empty css                                                 */import"./js/JsonValues.870a4901.js";import"./js/strings.b34473a6.js";import"./js/isString.9e7d8bc9.js";import"./js/ProBadge.f4f3af83.js";import"./js/External.a9f6d030.js";import"./js/Exclamation.e203242a.js";import"./js/Checkbox.8f797799.js";import"./js/Checkmark.74f4bcd8.js";import"./js/Row.e69aefbc.js";import"./js/Gear.30ee21fa.js";import"./js/Slide.99d45c60.js";import"./js/Tooltip.6a8793f6.js";import"./js/Plus.16164a23.js";import"./js/_getTag.a4119be8.js";const H={setup(){return{rootStore:w()}},components:{CoreModalPortal:b,CoreAddRedirection:v},data(){return{addons:L,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 e,o;this.display=!1;const t=(o=(e=this.target)==null?void 0:e.parentElement)==null?void 0:o.parentElement;if(t&&(t.classList.contains("components-notice__content")||t.classList.contains("notice"))){t.innerHTML="<p>"+this.strings.redirectAdded+"</p>";return}this.target.outerHTML=this.strings.redirectAdded},loadRedirect(t){this.loading=!0,S.get(this.$links.restUrl("redirects/manual-redirects/"+t)).then(e=>{this.urls=e.body.redirects,this.loading=!1}).catch(e=>console.log("Redirect modal failed to load the redirect data.",e))},preloadRedirect(){const t=document.querySelector(this.classSelectors);if(t){const e=this.getElementRedirectHash(t);if(!e)return;this.loadRedirect(e)}},watchClicks(){document.body.onclick=t=>{var o;if(!((o=t.target)!=null&&o.classList))return;let e=!1;this.watchClasses.forEach(n=>{t.target.classList.contains(n)&&(e=!0)}),e&&(t.preventDefault(),this.target=t.target,this.display=!0,x(this.url)&&this.loadRedirect(this.getElementRedirectHash(this.target)))}},getElementRedirectHash(t){return new URLSearchParams(t.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"},$={class:"bd"};function P(t,e,o,n,r,m){const u=d("core-add-redirection"),h=d("core-modal-portal");return r.addons.isActive("aioseo-redirects")?(a(),_("div",B,[r.display?(a(),c(h,{key:0,classes:["aioseo-redirects","modal"],onClose:e[0]||(e[0]=U=>r.display=!1)},{headerTitle:l(()=>[g(y(r.strings.modalHeader),1)]),body:l(()=>[R("div",$,[r.loading?i("",!0):(a(),c(u,{key:0,urls:r.urls,target:r.urls[0].target?r.urls[0].target:"/",disableSource:!0,onAddedRedirect:m.reload},null,8,["urls","target","onAddedRedirect"]))])]),_:1})):i("",!0)])):i("",!0)}const T=f(H,[["render",P]]),p=document.createElement("div");p.id="aioseo-redirects-add-redirect-standalone";document.body.appendChild(p);let s=C({...T,name:"Standalone/Redirects/AddRedirect"});s=A(s);s=k(s);E(s);s.mount("#aioseo-redirects-add-redirect-standalone");
