import{H as A,I as F,i as x,u as f,y as _,q as O,J as E,K as y,b as w,L as C}from"./app-core.c8323d51.js";import{r as p,u as P}from"./vendor-vue-ui.232c7c36.js";import{_ as i}from"./vendor-other.39e59221.js";const B=()=>{let t=0;return(A()||F())&&(t=parseInt(document.getElementById("post_author_override")?.value)),x()&&(t=window.wp.data.select("core/editor").getEditedPostAttribute("author")),t||(t=f().currentPost.postAuthor),t},u="all-in-one-seo-pack",k=()=>{let t=null;const r=/<img.*?src=['"](.*?)['"].*?>/i.exec(C());return r&&r[1]&&(t=r[1]),t},U=async(t,r,m)=>{let e=E(t[`${m}image_custom_fields`]);return e||await y().then(a=>{e=a}),e||await f().getFirstAttachedImage({postId:t.id}).then(g=>{e=g}),e||(e=k()),e||(e=_().options.social[r].homePage.image),e},L=async()=>{let t="";const r=B();return await f().getUserImage({userId:r}).then(e=>{t=e}),t},J=()=>{const t=p(["featured","content","author"]),r=p(["auto"]),m=p(["featured","attach","content","author","auto"]),e=p(""),a=p(!1),g=P(()=>[{label:i("Default Image (Set Below)",u),value:"default"},{label:i("Featured Image",u),value:"featured"},{label:i("Attached Image",u),value:"attach"},{label:i("First Image in Content",u),value:"content"},{label:i("Image from Custom Field",u),value:"custom"},{label:i("Post Author Image",u),value:"author"},{label:i("First Available Image",u),value:"auto"}]),h=P(()=>{const n=f(),s=g.value.map(o=>(o.value==="default"&&(o.label=i("Default Image Source (Set in Social Networks)",u)),o)).concat({label:i("Custom Image",u),value:"custom_image"});if(n.currentPost?.context==="term")return s.filter(o=>!m.value.includes(o.value));if(n.currentPost?.context==="post"&&n.currentPost?.postType==="attachment")return s.filter(o=>!t.value.includes(o.value));const c=w(),I=_();return c.aioseo.integration?((c.aioseo.integration==="seedprod"||c.aioseo.integration==="wpbakery"&&window.vc_mode==="admin_frontend_editor")&&r.value.push("featured"),c.aioseo.integration==="siteorigin"&&!I.options.searchAppearance.advanced.runShortcodes&&r.value.push("content"),s.filter(o=>!r.value.includes(o.value))):s});return{getImageSourceOption:n=>g.value.find(s=>s.value===n),getImageSourceOptionFiltered:n=>h.value.find(s=>s.value===n),getTermImageSourceOptions:()=>g.value.filter(n=>!m.value.includes(n.value)),imageSourceOptions:g,imageSourceOptionsFiltered:h,imageUrl:e,loading:a,setImageUrl:async(n="")=>{const s=_(),c=f(),I=O(),o=c.currentPost,l=n||I.metaBoxTabs?.social||"facebook",v=l==="facebook"||l==="twitter"&&o.twitter_use_og?"og_":"twitter_";let S=o[`${v}image_type`]||"default";switch(S==="default"&&(S=s.options.social[l].general.defaultImageSourcePosts),e.value="",S){case"featured":a.value=!0,await y().then(d=>{e.value=d,a.value=!1});break;case"attach":a.value=!0,await c.getFirstAttachedImage({postId:o.id}).then(d=>{e.value=d,a.value=!1});break;case"content":e.value=k();break;case"author":a.value=!0,await L().then(d=>{e.value=d,a.value=!1});break;case"auto":a.value=!0,await U(o,l,v).then(d=>{e.value=d,a.value=!1});break;case"custom":e.value=E(o[`${v}image_custom_fields`]);break;case"custom_image":e.value=o[`${v}image_custom_url`];break;default:e.value=s.options.social[l].general.defaultImagePosts;break}!e.value&&s.options.social[l].general.defaultImagePosts&&(e.value=s.options.social[l].general.defaultImagePosts);const b=w();!e.value&&b.aioseo.urls.siteLogo&&(e.value=b.aioseo.urls.siteLogo),window.aioseoBus.$emit("updateSocialImagePreview",{social:l,image:e.value})}}};export{J as u};
