import{_ as f}from"./js/_plugin-vue_export-helper.4292a25a.js";import{r as d,c as _,b as c,w as l,f as i,o as a,g,t as y,a as R,E as C}from"./js/vue.runtime.esm-bundler.1bf81f69.js";import{l as A}from"./js/index.f62253a4.js";import{l as k}from"./js/index.cd7fac8b.js";import{u as w,i as S,l as E}from"./js/links.4e9269a4.js";import{a as L}from"./js/addons.b699e1f7.js";import{C as b}from"./js/Portal.eef1ce3a.js";import{C as v}from"./js/Index.4b5cac99.js";import{i as H}from"./js/isEmpty.356d2658.js";import"./js/translations.f6b76bbe.js";import"./js/default-i18n.41786823.js";import"./js/constants.a78fc4cb.js";import"./js/Caret.0b57d359.js";import"./js/isArrayLikeObject.76f0d098.js";import"./js/upperFirst.65f07810.js";import"./js/_stringToArray.4de3b1f3.js";import"./js/toString.16b91dfe.js";import"./js/Index.d52a1c7e.js";/* empty css                                                 *//* empty css                                               *//* empty css                                                 */import"./js/JsonValues.870a4901.js";import"./js/strings.03d6ae29.js";import"./js/isString.197b32a2.js";import"./js/ProBadge.5f8b58d0.js";import"./js/External.95afe855.js";import"./js/Exclamation.c5d4ba67.js";import"./js/Checkbox.1a2fc75a.js";import"./js/Checkmark.20d31f86.js";import"./js/Row.1358a527.js";import"./js/Gear.a693d6ea.js";import"./js/Slide.c4e68d01.js";import"./js/Tooltip.fc81232d.js";import"./js/Plus.bd65010b.js";import"./js/_getTag.a3b733ba.js";const x={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,H(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()})}},$={key:0,class:"aioseo-redirects-add-redirect-standalone"},B={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",$,[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",B,[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(x,[["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");
