import{_ as h,c as f}from"./js/_plugin-vue_export-helper.BLXtEB-G.js";import{l as _}from"./js/index.DQR9DFri.js";import{l as g}from"./js/index.CdwEuUIl.js";import{u as y,A as R,l as C}from"./js/links.C572zDFG.js";/* empty css                */import{a as w}from"./js/addons.tTxptju5.js";import{C as A}from"./js/Index.CgBueMQV.js";import{C as k}from"./js/Index.N3ar3q9e.js";import{i as S}from"./js/isEmpty.B5KZQsHw.js";import{v as a,c as v,B as E,l as n,b as c,o as d,C as L,t as b,a as x,k as H}from"./js/runtime-core.esm-bundler.DMBo7TXk.js";import"./js/translations.Buvln_cw.js";import"./js/default-i18n.Bd0Z306Z.js";import"./js/constants.B6ynd7gz.js";import"./js/Caret.CGwYaMo_.js";import"./js/helpers.D5tYIqKS.js";import"./js/upperFirst.BGtMw2rr.js";import"./js/_stringToArray.DnK4tKcY.js";import"./js/toString.CkyAieyd.js";import"./js/JsonValues.D25FTfEu.js";import"./js/ProBadge.Bm930amZ.js";import"./js/External.1pzVM6vX.js";import"./js/escapeRegExp.BzEGgRdT.js";import"./js/Exclamation.Dk_xiOnS.js";import"./js/Checkbox.CxE2HV-P.js";import"./js/Checkmark.DL3UTTgg.js";import"./js/Gear.Big5c48d.js";import"./js/Slide.D2pWF0rN.js";import"./js/Date.7QFk4W6o.js";import"./js/DatePicker.zmGSzhsH.js";import"./js/pick.DnO1wEct.js";import"./js/_baseSet.SHpzr1A5.js";import"./js/_getTag.Dxs-K0Yj.js";import"./js/debounce.D8CddFbI.js";import"./js/toNumber.BuBWCMcL.js";import"./js/_baseTrim.BYZhh0MR.js";import"./js/isEqual.6YJSJDqn.js";import"./js/_baseIsEqual.8qmZqLuw.js";import"./js/Tooltip.CRFjFnpF.js";import"./js/Plus.iqCbU08m.js";const $={setup(){return{rootStore:y()}},components:{CoreModal:A,CoreAddRedirection:k},data(){return{addons:w,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,R.get(this.$links.restUrl("redirects/manual-redirects/"+t)).then(e=>{this.urls=e.body.redirects,this.loading=!1}).catch(e=>console.error("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(i=>{t.target.classList.contains(i)&&(e=!0)}),e&&(t.preventDefault(),this.target=t.target,this.display=!0,S(this.urls)&&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.$nextTick(()=>{this.preloadRedirect()})})}},B={key:0,class:"aioseo-redirects-add-redirect-standalone"},T={class:"bd"};function N(t,e,o,i,r,p){const m=a("core-add-redirection"),u=a("core-modal");return r.addons.isActive("aioseo-redirects")?(d(),v("div",B,[E(u,{show:r.display,classes:["aioseo-redirects"],onClose:e[0]||(e[0]=U=>r.display=!1),"allow-overflow":""},{headerTitle:n(()=>[L(b(r.strings.modalHeader),1)]),body:n(()=>[x("div",T,[r.loading?c("",!0):(d(),H(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"])])):c("",!0)}const P=h($,[["render",N]]),l=document.createElement("div");l.id="aioseo-redirects-add-redirect-standalone";document.body.appendChild(l);let s=f({...P,name:"Standalone/Redirects/AddRedirect"});s=_(s);s=g(s);C(s);s.mount("#aioseo-redirects-add-redirect-standalone");
