import{_}from"./js/_plugin-vue_export-helper.b97bdf23.js";import{r as d,c as f,b as c,w as l,f as i,o as a,g,t as y,a as R,G as C}from"./js/vue.runtime.esm-bundler.b39e1078.js";import{l as A}from"./js/index.cfe09a50.js";import{l as k}from"./js/index.0eabb636.js";import{u as w,s as S,l as v}from"./js/links.23796d97.js";/* empty css                */import{a as E}from"./js/addons.afbe11a7.js";import{C as L}from"./js/Portal.6c1bcf12.js";import{C as b}from"./js/Index.4b06a1ea.js";import{i as x}from"./js/isEmpty.fcd10c81.js";import"./js/translations.6e7b2383.js";import"./js/default-i18n.3881921e.js";import"./js/constants.1758f66e.js";import"./js/Caret.164d8058.js";import"./js/isArrayLikeObject.22a096cb.js";import"./js/upperFirst.8df5cd57.js";import"./js/_stringToArray.4de3b1f3.js";import"./js/toString.0891eb3e.js";import"./js/Index.4ee78e0e.js";/* empty css                                                 *//* empty css                                               *//* empty css                                                 */import"./js/JsonValues.870a4901.js";import"./js/strings.c89d2b51.js";import"./js/isString.714e3ec6.js";import"./js/ProBadge.34da75c2.js";import"./js/External.8186427a.js";import"./js/Exclamation.2f8bed1f.js";import"./js/Checkbox.17c05fc5.js";import"./js/Checkmark.e0bb6305.js";import"./js/Row.5242dafa.js";import"./js/Gear.a85d4a2b.js";import"./js/Slide.cdf6c622.js";import"./js/Tooltip.6979830f.js";import"./js/Plus.3a43a085.js";import"./js/_getTag.89be5fac.js";const H={setup(){return{rootStore:w()}},components:{CoreModalPortal: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 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()})}},$={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(),f("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=_(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);v(s);s.mount("#aioseo-redirects-add-redirect-standalone");
