import{_ as m}from"./js/_plugin-vue_export-helper.abeb2ae0.js";import{x as e,o as p,c as k,C as a,a as f,H as r,b as _,Y as h}from"./js/vue.runtime.esm-bundler.4a881941.js";import{l as L}from"./js/index.683fda17.js";import{l as S}from"./js/index.e978df4e.js";import{l as g}from"./js/index.0b123ab1.js";import{f as A,b as w,u as y,l as v}from"./js/links.125d59c9.js";import{e as C}from"./js/elemLoaded.9a6eb745.js";import{a as F}from"./js/addons.dca3a5e7.js";import{u as x}from"./js/url.5d7576a2.js";import{S as E}from"./js/Information.8e84b099.js";import{S as V}from"./js/Caret.02d7c74a.js";import"./js/translations.6e7b2383.js";import"./js/default-i18n.3881921e.js";import"./js/constants.238e5b7b.js";import"./js/isArrayLikeObject.ab8f4241.js";import"./js/upperFirst.7faab9f8.js";import"./js/_stringToArray.4de3b1f3.js";import"./js/toString.7b877a36.js";const P={setup(){return{licenseStore:A(),postEditorStore:w(),rootStore:y()}},components:{SvgCircleInformation:E,SvgClose:V},data(){return{linkFormatValue:{},disabled:!1,url:null,strings:{upsell:this.$t.sprintf(this.$t.__("Did you know you can automatically add internal links using Link Assistant? %1$s",this.$td),this.$links.getPlainLink(this.$constants.GLOBAL_STRINGS.learnMore,this.rootStore.aioseo.urls.aio.linkAssistant,!0))}}},computed:{canShowUpsell(){const t=F.getAddon("aioseo-link-assistant"),{options:o}=this.postEditorStore.currentPost,i=o.linkFormat.internalLinkCount,n=o.linkFormat.linkAssistantDismissed;return(this.licenseStore.isUnlicensed||!t||!t.isActive||t.requiresUpgrade)&&2<i&&!n&&!this.disabled&&this.linkFormatValue.url&&this.isInternalLink(this.linkFormatValue.url)}},methods:{async linkAdded(t){var s;await this.$nextTick();const{options:o}=this.postEditorStore.currentPost,i=o.linkFormat.internalLinkCount,n=o.linkFormat.linkAssistantDismissed;2<i||n||this.isInternalLink(t.url||((s=t.suggestion)==null?void 0:s.url)||null)&&this.postEditorStore.incrementInternalLinkCount()},async setLinkFormatValue(){await this.$nextTick();const t=document.querySelector("#aioseo-link-assistant-education input");!this.linkFormatValue.url&&(t!=null&&t.value)&&(this.linkFormatValue=JSON.parse(t.value))},isInternalLink(t){const o=x.parse(t,!1,!0);return t.indexOf("//")===-1&&t.indexOf("/")===0?!0:t.indexOf("#")===0?!1:o.host?o.host===this.rootStore.aioseo.urls.domain:!0}},created(){this.setLinkFormatValue();const{addAction:t,hasAction:o}=window.wp.hooks;o("aioseo-link-format-link-added","aioseo")||t("aioseo-link-format-link-added","aioseo",this.linkAdded)}},D={key:0,class:"aioseo-link-assistant-did-you-know"},I=["innerHTML"];function b(t,o,i,n,s,u){const c=e("svg-circle-information"),d=e("svg-close");return u.canShowUpsell?(p(),k("div",D,[a(c),f("span",{onClick:o[0]||(o[0]=r(U=>s.disabled=!0,["stop"])),innerHTML:s.strings.upsell},null,8,I),a(d,{onClick:r(n.postEditorStore.disableLinkAssistantEducation,["stop"])},null,8,["onClick"])])):_("",!0)}const N=m(P,[["render",b]]),l=()=>{let t=h({...N,name:"Standalone/LinkFormat"});t=L(t),t=S(t),t=g(t),v(t),t.mount("#aioseo-link-assistant-education-mount")};window.aioseo&&window.aioseo.currentPost&&window.aioseo.currentPost.context==="post"&&(document.getElementById("aioseo-link-assistant-education")?l():(C("#aioseo-link-assistant-education","aioseoLaDidYouKnow"),document.addEventListener("animationstart",function(o){o.animationName==="aioseoLaDidYouKnow"&&l()},{passive:!0})));
