import"./js/vue2.RHmKp0B5.js";import{x as a,c as h,C as f,m as n,d,o as c,D as _,t as g,a as y,l as R,X as C}from"./js/vue.esm-bundler.CWQFYt9y.js";import{l as A}from"./js/index.C90RWy5A.js";import{l as w}from"./js/index.B8uZtLiV.js";import{u as k,x as S,l as x}from"./js/links.C7Z9vJvv.js";/* empty css                */import{a as E}from"./js/addons.CFmx_7nM.js";import{C as L}from"./js/Index.CowwYZV6.js";import{C as v}from"./js/Index.JibUDaTl.js";import{_ as H}from"./js/_plugin-vue_export-helper.BN1snXvA.js";import{i as b}from"./js/isEmpty.BVq0Sx81.js";import"./js/translations.Buvln_cw.js";import"./js/default-i18n.Bd0Z306Z.js";import"./js/constants.DpuIWwJ9.js";import"./js/Caret.iRBf3wcH.js";import"./js/helpers.DkJd815A.js";import"./js/upperFirst.DnE5bcuK.js";import"./js/_stringToArray.DnK4tKcY.js";import"./js/toString.24fN1xMd.js";import"./js/JsonValues.D25FTfEu.js";import"./js/strings.DHEzgTA5.js";import"./js/isString.DH_10e2z.js";import"./js/ProBadge.WwPkDor4.js";import"./js/External.Bfg4674G.js";import"./js/Exclamation.DKtT8kuH.js";import"./js/Checkbox.D2dfpbIi.js";import"./js/Checkmark.pCOnqh_g.js";import"./js/Gear.aQH8e4fl.js";import"./js/Slide.CRIn0kdn.js";import"./js/Date.wJe5sKwv.js";import"./js/DatePicker.DwFXyUjL.js";import"./js/get.QVQdoK-Q.js";import"./js/isUndefined.KRoivnRl.js";import"./js/_getTag.gDb2R5l9.js";import"./js/debounce.DS72ZDl3.js";import"./js/toNumber.CT-toMIa.js";import"./js/_baseTrim.BYZhh0MR.js";import"./js/Tooltip.Jp05nfCy.js";import"./js/Plus.DrDYrwHh.js";const $={setup(){return{rootStore:k()}},components:{CoreModal:L,CoreAddRedirection:v},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 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.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,b(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"},D={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")?(c(),h("div",B,[f(u,{show:r.display,classes:["aioseo-redirects"],onClose:e[0]||(e[0]=T=>r.display=!1)},{headerTitle:n(()=>[_(g(r.strings.modalHeader),1)]),body:n(()=>[y("div",D,[r.loading?d("",!0):(c(),R(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 P=H($,[["render",N]]),l=document.createElement("div");l.id="aioseo-redirects-add-redirect-standalone";document.body.appendChild(l);let s=C({...P,name:"Standalone/Redirects/AddRedirect"});s=A(s);s=w(s);x(s);s.mount("#aioseo-redirects-add-redirect-standalone");
