var p=Object.defineProperty;var o=Object.getOwnPropertySymbols;var u=Object.prototype.hasOwnProperty,m=Object.prototype.propertyIsEnumerable;var a=(t,e,r)=>e in t?p(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,i=(t,e)=>{for(var r in e||(e={}))u.call(e,r)&&a(t,r,e[r]);if(o)for(var r of o(e))m.call(e,r)&&a(t,r,e[r]);return t};import{n as h,V as c}from"./js/vueComponentNormalizer.87056a83.js";import"./js/index.6be33911.js";import{g as _,m as n,s as f}from"./js/index.24bc83f1.js";import{C as g}from"./js/Modal.f47c8aa2.js";import{C as y}from"./js/Index.c4d61e8a.js";import{i as $}from"./js/isEmpty.19569de9.js";import"./js/client.94d919c5.js";import"./js/_commonjsHelpers.f40d732e.js";import"./js/default-i18n.abde8d59.js";import"./js/constants.50303a5f.js";import"./js/isArrayLikeObject.26ec157b.js";import"./js/ToolsSettings.c7becacb.js";import"./js/helpers.55800a79.js";import"./js/cleanForSlug.d874125b.js";import"./js/JsonValues.08065e69.js";import"./js/ProBadge.7c0de2f7.js";import"./js/External.8868c638.js";import"./js/Close.5e7bcb70.js";import"./js/Exclamation.356738ce.js";import"./js/Checkbox.5873a8d2.js";import"./js/Checkmark.e7547654.js";import"./js/Index.6b49ef32.js";import"./js/Row.13b6f3f1.js";import"./js/Gear.c974e953.js";import"./js/Trash.214b5744.js";import"./js/Slide.f5d21606.js";import"./js/Tooltip.3ec20ff5.js";import"./js/Plus.a9b9ba75.js";import"./js/_getTag.d0abb316.js";var v=function(){var t=this,e=t.$createElement,r=t._self._c||e;return t.$addons.isActive("aioseo-redirects")?r("div",{staticClass:"aioseo-redirects-add-redirect-standalone"},[t.display?r("core-modal",{staticClass:"aioseo-redirects modal",attrs:{isolate:""},on:{close:function(s){t.display=!1}}},[r("div",{attrs:{slot:"headerTitle"},slot:"headerTitle"},[t._v(" "+t._s(t.strings.modalHeader)+" ")]),r("div",{attrs:{slot:"body"},slot:"body"},[t.loading?t._e():r("core-add-redirection",{attrs:{url:t.url,target:t.url.target?t.url.target:"/",disableSource:!0},on:{"added-redirect":function(s){return t.reload()}}})],1)]):t._e()],1):t._e()},R=[];const C={components:{CoreModal:g,CoreAddRedirection:y},data(){return{url:{},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.$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,r;this.display=!1;const t=(r=(e=this.target)==null?void 0:e.parentElement)==null?void 0:r.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,this.$http.get(this.$links.restUrl("redirects/manual-redirects/"+t)).then(e=>{this.url=e.body.redirects[0],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 r;if(!((r=t.target)!=null&&r.classList))return;let e=!1;this.watchClasses.forEach(s=>{t.target.classList.contains(s)&&(e=!0)}),e&&(t.preventDefault(),this.target=t.target,this.display=!0,$(this.url)&&this.loadRedirect(this.getElementRedirectHash(this.target)))}},getElementRedirectHash(t){return new URLSearchParams(t.href).get("aioseo-manual-urls")}},async created(){const{addons:t,redirects:e}=await _(this.$http);this.$set(this.$store.state,"addons",n([...this.$store.state.addons],[...t])),this.$set(this.$store.state,"redirects",n(i({},this.$store.state.redirects),i({},e))),this.preloadRedirect(),this.watchClicks(),this.$bus.$on("wp-core-notice-created",()=>{this.preloadRedirect()})}},d={};var w=h(C,v,R,!1,A,null,null,null);function A(t){for(let e in d)this[e]=d[e]}var E=function(){return w.exports}();const l=document.createElement("div");l.id="aioseo-redirects-add-redirect-standalone";document.body.appendChild(l);c.prototype.$aioseo=window.aioseo;new c({store:f,render:t=>t(E)}).$mount("#aioseo-redirects-add-redirect-standalone");
