attachments.6af710f9.js 17.5 KB
import{V as y}from"./_plugin-vue2_normalizer.61652a7c.js";import{s as o,e as f,f as v,i as w,j as S,k as C,l as k}from"./index.ec9852b3.js";import{c as A,g}from"./cleanForSlug.51ef7354.js";import{d as U}from"./Caret.19b10233.js";import{c as N,d as D}from"./html.14f2a8b9.js";import{f as ot}from"./helpers.de7566d0.js";const st=()=>!window.aioseo.currentPost||!window.aioseo.currentPost.id?!1:window.aioseo.options.advanced&&window.aioseo.options.advanced.truSeo&&!window.aioseo.currentPost.isSpecialPage&&window.aioseo.currentPost.postType!=="attachment"&&j(),It=()=>!window.aioseo.screen||!window.aioseo.screen.postType?!1:!!(window.aioseo.options.advanced&&window.aioseo.options.advanced.truSeo&&j(window.aioseo.screen.postType)),j=(t=null)=>{if(t)return!!(window.aioseo.dynamicOptions.searchAppearance.postTypes[t]&&window.aioseo.dynamicOptions.searchAppearance.postTypes[t].advanced&&window.aioseo.dynamicOptions.searchAppearance.postTypes[t].advanced.showMetaBox);if(!window.aioseo.currentPost||!window.aioseo.currentPost.id)return!1;const e=window.aioseo.currentPost.postType,n=window.aioseo.currentPost.termType,a=!!(e&&window.aioseo.currentPost.context==="post"&&window.aioseo.dynamicOptions.searchAppearance.postTypes[e]&&window.aioseo.dynamicOptions.searchAppearance.postTypes[e].advanced&&window.aioseo.dynamicOptions.searchAppearance.postTypes[e].advanced.showMetaBox),s=!!(n&&window.aioseo.currentPost.context==="term"&&window.aioseo.dynamicOptions.searchAppearance.taxonomies[n]&&window.aioseo.dynamicOptions.searchAppearance.taxonomies[n].advanced&&window.aioseo.dynamicOptions.searchAppearance.taxonomies[n].advanced.showMetaBox);return a||s},T=async(t=900,e=!0)=>{U(async()=>{await yt(!1),await gt(!1),await ht(!1),await xt(!1),await mt(!1),St(!1),At(!1),Ct(!1),e&&y.prototype.$truSeo.runAnalysis({postId:o.state.currentPost.id})},t)},R=()=>{if(!window.aioseo.currentPost||!window.aioseo.currentPost.postType)return"";const t=window.aioseo.currentPost.postType,e=window.aioseo.dynamicOptions.searchAppearance.postTypes[t].customFields;if(!e||!st)return"";const n=()=>{T(500)},a=e.replace(/\n/g,",").split(","),s=[],c=["INPUT","TEXTAREA","IMG"],r=i=>{try{document.createDocumentFragment().querySelector(i)}catch{return!1}return!0};a.forEach(i=>{i=i.trim();const l=r(`#${i}`)?document.querySelector(`#${i}`):!1,L=document.querySelectorAll("#the-list > tr"),tt=document.querySelectorAll(".acf-field");c.includes(l==null?void 0:l.tagName)&&!(l!=null&&l.closest(".acf-field"))?s.push(l):L.forEach(u=>{const m=u.querySelector(`#${u.id}-key`),P=u.querySelector(`#${u.id}-value`);c.includes(P==null?void 0:P.tagName)&&a.includes(m==null?void 0:m.value)&&s.push(P)}),tt.forEach(u=>{if(i!==u.dataset.name)return"";let m=u.querySelector(`[id^="acf"][name$="[${u.dataset.key}]"]`);if(u.dataset.type==="image"&&(m=u.querySelector(".has-value img")),u.dataset.type==="gallery"&&(m=u.querySelector(".acf-gallery-attachment img")),!m||m.type&&m.type==="hidden")return"";if(u.dataset.type==="wysiwyg"){const P=window.setInterval(()=>{var q,M;(M=(q=window.tinyMCE)==null?void 0:q.activeEditor)!=null&&M.acf&&(window.clearInterval(P),window.tinyMCE.activeEditor.on("keyup",function(){T(500)}),window.tinyMCE.activeEditor.on("PostProcess",function(){U(()=>{T(500)},10)}))},50),et=function(q){q.forEach(M=>{var H;if(M.attributeName==="class"&&u.querySelector(".wp-editor-wrap.tmce-active")&&((H=window.tinyMCE)!=null&&H.activeEditor)){window.tinyMCE.activeEditor.on("keyup",function(){T(500)});const B=u.querySelector(`[name="acf[${u.dataset.key}]"]`);B&&(B.addEventListener("keyup",()=>{T(500)}),B.addEventListener("paste",()=>{T(500)}))}})},nt=new MutationObserver(et),O=u.querySelector(".wp-editor-wrap");O&&nt.observe(O,{attributes:!0})}c.includes(m.tagName)&&s.push(m)})});let d="";return s.forEach(i=>{let l="";if(c.includes(i.tagName)&&i.addEventListener("keyup",n),i.value&&(l=i.value),i.tagName==="IMG"&&i.src){const L=i.alt?`alt="${i.alt}"`:"";l=`<img src="${i.src}" ${L}>`}i.value&&i.type&&i.type==="url"&&(l=`<a href="${l}">${l}</a>`),l&&(d+=`${l} `)}),d},Lt=(t,e=["INPUT","TEXTAREA","IMG"])=>{if(!t)return"";const n=document.querySelector(`#${t}`),a=document.querySelectorAll("#the-list > tr"),s=document.querySelectorAll(".acf-field");let c="";return n&&e.indexOf(n.tagName)!==-1&&(n.closest(".acf-field")||(c=n.tagName==="IMG"?n.getAttribute("src"):n.value)),a.length&&a.forEach(r=>{const d=r.querySelector(`#${r.id}-key`),i=r.querySelector(`#${r.id}-value`);i&&e.indexOf(i.tagName)!==-1&&d.value===t&&(c=i.tagName==="IMG"?i.getAttribute("src"):i.value)}),s.length&&s.forEach(r=>{if(t!==r.dataset.name)return;let d;e.forEach(i=>{const l=i.toLowerCase();d=r.querySelector(`[data-key="${r.dataset.key}"] ${l}`)||d}),d&&(c=d.tagName==="IMG"?d.getAttribute("src"):d.value)}),c},at=()=>{const t=window.elementor.documents.getCurrent(),e=[];return t.$element?(t.$element.find(".elementor-widget-container").each((n,a)=>{let s=a.innerHTML.trim();s=s.replaceAll(/<p.*>(<img.*>)<\/p>/g,"$1"),!(N(s)===""&&D(s).length===0)&&e.push(s)}),e.join(" ")):""},b=()=>{var t;return{content:at(),title:window.elementor.settings.page.model.get("post_title"),excerpt:window.elementor.settings.page.model.get("post_excerpt")||"",slug:A(window.elementor.settings.page.model.get("post_title")),permalink:window.elementor.config.document.urls.permalink||"",featuredImage:((t=window.elementor.settings.page.model.get("post_featured_image"))==null?void 0:t.url)||""}},it=()=>{const t=g(ET_Builder,"Frames.app.frameElement",document.querySelector("iframe#et-fb-app-frame"));if(!t)return document.createElement("div");let e=t.contentWindow.document.querySelectorAll("#et-fb-app");return 1<e.length&&(e=[...e].filter(n=>n.classList.contains("et-fb-root-ancestor"))),e[0]||document.createElement("div")},rt=()=>{const t=[],e=it().querySelectorAll(".et_pb_section"),n=new RegExp(["<style.*?</style>","\\[object Object\\]"].join("|"),"gi");for(let a=0;a<e.length;a++){let s=e[a].innerHTML;s=e[a].innerHTML.replace(n,""),s=s.replaceAll(/<p.*>(<img.*>)<\/p>/g,"$1"),!(N(s)===""&&D(s).length===0)&&t.push(s)}return t.join(" ")},ct=()=>{const t=new URL(g(ETBuilderBackendDynamic,"currentPage.permalink",""));return t.searchParams.delete("PageSpeed"),t.href},_=()=>({content:rt(),title:g(ETBuilderBackendDynamic,"postTitle",""),excerpt:g(ETBuilderBackendDynamic,"postMeta.post_excerpt",""),slug:g(ETBuilderBackendDynamic,"postMeta.post_name",""),permalink:ct(),featuredImage:g(ETBuilderBackendDynamic,"currentPage.thumbnailUrl","")}),lt=t=>{let e;switch(t.type){case"header":e=document.createElement(t.settings.tag),e.innerHTML=t.settings.headerTxt.trim();break;case"image":const n=document.createElement("img");t.settings.altTxt&&n.setAttribute("alt",t.settings.altTxt),t.settings.src&&n.setAttribute("src",t.settings.src),t.settings.noFollow&&n.setAttribute("rel","nofollow"),e=n,t.settings.link&&(e=document.createElement("a"),e.setAttribute("href",t.settings.link),e.innerHTML=n.outerHTML,t.settings.noFollow&&e.setAttribute("rel","nofollow"),t.settings.openNewWindow&&e.setAttribute("target","_blank"));break;case"video":t.settings.type==="youtube"?(e=document.createElement("iframe"),e.setAttribute("src",t.settings.youtubeUrl)):(e=document.createElement("div"),e.innerHTML=t.settings.code);break;case"text":e=document.createElement("div"),e.innerHTML=t.settings.txt.trim();break;case"button":e=document.createElement("a"),e.appendChild(document.createTextNode(t.settings.btnTxt+" "+t.settings.btnSubTxt)),t.settings.link&&e.setAttribute("href",t.settings.link),t.settings.altTxt&&e.setAttribute("alt",t.settings.altTxt),t.settings.src&&e.setAttribute("src",t.settings.src),t.settings.noFollow&&e.setAttribute("rel","nofollow"),t.settings.openNewWindow&&e.setAttribute("target","_blank");break;case"bullet-list":e=document.createElement("ul"),t.settings.items.forEach(a=>{const s=document.createElement("li");s.innerHTML=a.txt,e.appendChild(s)});break;case"custom-html":e=document.createElement("div"),e.innerHTML=t.settings.code;break}return e},ut=()=>{const t=[];return JSON.parse(JSON.stringify(g(seedprod_data,"settings.document.sections",[]))).forEach(n=>{n.rows.forEach(a=>{a.cols.forEach(s=>{s.blocks.forEach(c=>{const r=lt(c);r&&(N(r)===""&&D(r).length===0||t.push(r.outerHTML))})})})}),t.join(" ")},dt=()=>{const t=g(seedprod_data,"home_url",""),e=g(seedprod_data,"settings.post_name","");return`${t}/${e}/`},$=()=>({content:ut(),title:g(seedprod_data,"settings.post_title",""),excerpt:"",slug:g(seedprod_data,"settings.post_name",""),permalink:dt()}),z=()=>{let t="";return S()&&(t=b().permalink),C()&&(t=_().permalink),k()&&(t=$().permalink),t},pt=()=>{if(o.state["live-tags"].liveTags.permalink)return o.state["live-tags"].liveTags.permalink;let t;if(f()||v){const e=document.querySelector("#edit-slug-box a");e&&e.href&&(t=e.href)}return w()&&(t=window.wp.data.select("core/editor").getPermalink()),t||(t=z()),t&&o.commit("live-tags/updatePermalink",t),t},x=()=>{let t;if(f()||v){const e=document.querySelector("#edit-slug-box a");e&&e.href&&(t=e.href)}return w()&&(t=window.wp.data.select("core/editor").getPermalink()),t||(t=z()),t},mt=async(t=!0)=>{let e=pt();const n=x();e!==n&&(e=n,e&&(o.commit("live-tags/updatePermalink",e),t&&y.prototype.$truSeo.runAnalysis({postId:o.state.currentPost.id,postData:{...o.state.currentPost},content:h(),slug:x()})))},W=/base64,(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)/g,G=["acf","aioseo"],V=()=>{let t="";return S()&&(t=b().content),C()&&(t=_().content),k()&&(t=$().content),t},Z=t=>{var a;if(!t.includes('<!-- wp:block {"ref":'))return t;const e=(a=window.wp.blocks)==null?void 0:a.rawHandler({HTML:t});return ot(e).forEach(s=>{var c,r,d;if(s.name==="core/block"){const i=window.wp.data.select("core").getEntityRecord("postType","wp_block",(c=s.attributes)==null?void 0:c.ref);(r=i==null?void 0:i.content)!=null&&r.raw&&(t=t.replace(`<!-- wp:block {"ref":${(d=s.attributes)==null?void 0:d.ref}} /-->`,i.content.raw))}}),t},F=(t,e)=>(window.wp.data.select("core/block-editor").getBlocks().forEach(a=>{if(e.includes(a.name.split("/")[0])){const s=document.getElementById("block-"+a.clientId);if(s&&s.innerHTML){const c=`<!-- wp:${a.name}.*?-->`;t=t.replace(new RegExp(c),s.innerHTML)}}}),t),J=()=>{if(o.state["live-tags"].liveTags.post_content)return o.state["live-tags"].liveTags.post_content;let t="";if(f())if(window.tinyMCE||document.querySelector("#wp-content-wrap.html-active"))t=I();else{const e=window.setInterval(()=>{window.tinyMCE&&(window.clearInterval(e),t=I())},50)}return w()&&(t=window.wp.data.select("core/editor").getCurrentPost().content,t=Z(t),t=F(t,G)),t||(t=V()),window.aioseo.currentPost.descriptionIncludeCustomFields&&(t=t+R()),t=t.replace(W,""),t&&o.commit("live-tags/updatePostContent",t),t},h=()=>{let t="";if(f())if(window.tinyMCE||document.querySelector("#wp-content-wrap.html-active"))t=I();else{const e=window.setInterval(()=>{window.tinyMCE&&(window.clearInterval(e),t=I())},50)}return w()&&(t=window.wp.data.select("core/editor").getEditedPostContent(),t=Z(t),t=F(t,G)),t||(t=V()),window.aioseo.currentPost.descriptionIncludeCustomFields&&(t=t+R()),t=t.replace(W,""),t},gt=async(t=!0)=>{let e=J();const n=h();e!==n&&(e=n,o.commit("live-tags/updatePostContent",e),t&&y.prototype.$truSeo.runAnalysis({postId:o.state.currentPost.id,postData:{...o.state.currentPost},content:h(),slug:x()}))},I=()=>{let t="";const e=window.tinyMCE?window.tinyMCE.get("content"):"";if(document.querySelector("#wp-content-wrap.tmce-active")&&e)t=e.getContent({format:"raw"});else{const n=document.querySelector("textarea#content");t=n?n.value:""}return t},X=()=>{let t="";return S()&&(t=b().title),C()&&(t=_().title),k()&&(t=$().title),t},ft=()=>{if(o.state["live-tags"].liveTags.post_title)return o.state["live-tags"].liveTags.post_title;let t;if(f()||v()){const e=document.querySelector("#post input#title");t=e?e.value:""}return w()&&(t=window.wp.data.select("core/editor").getCurrentPost().title),t||(t=X()),t&&o.commit("live-tags/updatePostTitle",t),t},wt=()=>{let t;if(f()||v()){const e=document.querySelector("#post input#title");t=e?e.value:""}return w()&&(t=window.wp.data.select("core/editor").getEditedPostAttribute("title")),t||(t=X()),t},yt=async(t=!0)=>{let e=ft();const n=wt();e!==n&&(e=n,o.commit("live-tags/updatePostTitle",e),t&&y.prototype.$truSeo.runAnalysis({postId:o.state.currentPost.id,postData:{...o.state.currentPost},content:h(),slug:x()}))},Q=t=>{if(!t)return"";const e=[/\[.*?\]/g,/<\/?[a-z][^>]*?>/gi,/<!--[\s\S]*?-->/g,/(\r\n|\n|\r)/g];return t=t.replaceAll(/\n\n/g," "),e.forEach(n=>{t=t.replace(n,"")}),t.trim()},Y=()=>{let t="";return S()&&(t=b().excerpt),C()&&(t=_().excerpt),k()&&(t=$().excerpt),t},vt=()=>{if(o.state["live-tags"].liveTags.post_excerpt)return o.state["live-tags"].liveTags.post_excerpt;let t;if(f()||v()){const e=document.querySelector("#postexcerpt textarea#excerpt");t=e?e.value:""}return w()&&(t=window.wp.data.select("core/editor").getCurrentPost().excerpt),t||(t=Y()),t||(t=Q(J())),t&&o.commit("live-tags/updatePostExcerpt",t),t},Et=()=>{let t;if(f()||v()){const e=document.querySelector("#postexcerpt textarea#excerpt");t=e?e.value:""}return w()&&(t=window.wp.data.select("core/editor").getEditedPostAttribute("excerpt")),t||(t=Y()),t||(t=Q(h())),t},ht=async(t=!0)=>{let e=vt();const n=Et();e!==n&&(e=n,o.commit("live-tags/updatePostExcerpt",e),t&&y.prototype.$truSeo.runAnalysis({postId:o.state.currentPost.id,postData:{...o.state.currentPost},content:h(),slug:x()}))},K=()=>{let t="";return S()&&(t=b().slug),C()&&(t=_().slug),k()&&(t=$().slug),t},Pt=()=>{if(o.state["live-tags"].permalinkSlug)return o.state["live-tags"].permalinkSlug;let t="";if(f()||v()){const e=document.querySelector("#post_name");e&&(t=A(e.value))}return w()&&(t=window.wp.data.select("core/editor").getCurrentPost().slug),t||(t=K()),t&&o.commit("live-tags/updatePermalinkSlug",t),t},Tt=()=>{let t="";if(f()||v()){const e=document.querySelector("#post_name");e&&(t=A(e.value))}if(w()&&(t=window.wp.data.select("core/editor").getEditedPostAttribute("slug")),S()){const e=window.elementor.settings.page.model.get("post_title");e&&(t=A(e))}return t||(t=K()),t},xt=async(t=!0)=>{let e=Pt();const n=Tt();e!==n&&(e=n,o.commit("live-tags/updatePermalinkSlug",e),t&&y.prototype.$truSeo.runAnalysis({postId:o.state.currentPost.id,postData:{...o.state.currentPost},content:h(),slug:x()}))};let p="",E="";const St=(t=!0)=>{var e;if(f()||v()){const n=document.querySelectorAll('#post input[name="post_category[]"]:checked');n.length?(p!==n[0].parentNode.innerText&&(p=n[0].parentNode.innerText,o.commit("live-tags/updateTaxonomyTitle",p)),E=Array.from(n).map(a=>a.parentNode.innerText).join(", "),o.commit("live-tags/updateCategories",E)):p!==""&&(p=E="",o.commit("live-tags/updateTaxonomyTitle",p),o.commit("live-tags/updateCategories",E))}if(w()){let n=[],a=[];if((e=window.aioseo.user.data.allcaps)!=null&&e.manageCategories&&(n=window.wp.data.select("core").getEntityRecords("taxonomy","category"),a=window.wp.data.select("core/editor").getEditedPostAttribute("categories")),a&&a.length&&n){const s=n.find(c=>c.id===a[0]);s&&p!==s.name&&(p=s.name,o.commit("live-tags/updateTaxonomyTitle",p)),E=n.filter(c=>a.includes(c.id)).map(c=>c.name).join(", "),o.commit("live-tags/updateCategories",E)}else p!==""&&(p=E="",o.commit("live-tags/updateTaxonomyTitle",p),o.commit("live-tags/updateCategories",E))}t&&y.prototype.$truSeo.runAnalysis({postId:o.state.currentPost.id})},At=(t=!1)=>{if(o.state.currentPost.context!=="term")return;const e=document.querySelector("#edittag input#name");e&&(o.commit("live-tags/updateTaxonomyTitle",e.value),e.addEventListener("input",()=>{o.commit("live-tags/updateTaxonomyTitle",e.value)}));const n=document.querySelector("#edittag textarea#description");n&&(o.commit("live-tags/updateTaxonomyDescription",n.value),n.addEventListener("input",()=>{o.commit("live-tags/updateTaxonomyDescription",n.value)}));const a=document.querySelector("#edittag input#slug");if(a){const s=A(a.value);o.commit("live-tags/updatePermalinkSlug",s),o.commit("live-tags/updatePermalink",o.state.currentPost.permalink.replace(`/${o.state["live-tags"].permalinkSlug}`,`/${s.replace(/ /gi,"-").replace(/[^a-z0-9-]/gi,"").toLowerCase()}`)),a.addEventListener("input",()=>{o.commit("live-tags/updatePermalinkSlug",s),o.commit("live-tags/updatePermalink",o.state.currentPost.permalink.replace(`/${o.state["live-tags"].permalinkSlug}`,`/${s.replace(/ /gi,"-").replace(/[^a-z0-9-]/gi,"").toLowerCase()}`))})}o.dispatch("savePostState"),t&&y.prototype.$truSeo.runAnalysis({postId:o.state.currentPost.id})},Ct=(t=!1)=>{if(o.state.currentPost.postType!=="attachment")return;const e=document.querySelector("textarea#attachment_caption");e&&(o.commit("live-tags/updateAttachmentCaption",e.value),e.addEventListener("input",r=>{o.commit("live-tags/updateAttachmentCaption",r.target.value)}));const n=document.querySelector("textarea#attachment-details-caption");n&&(o.commit("live-tags/updateAttachmentCaption",n.value),n.addEventListener("input",r=>{o.commit("live-tags/updateAttachmentCaption",r.target.value)}));const a=document.querySelector("textarea#attachment_content");a&&(o.commit("live-tags/updateAttachmentDescription",a.value),a.addEventListener("input",r=>{o.commit("live-tags/updateAttachmentDescription",r.target.value)}));const s=document.querySelector("input#attachment_alt");s&&(o.commit("live-tags/updateAltTag",s.value),s.addEventListener("input",r=>{o.commit("live-tags/updateAltTag",r.target.value)}));const c=document.querySelector("input#attachment-details-alt-text");c&&(o.commit("live-tags/updateAltTag",s.value),c.addEventListener("input",r=>{o.commit("live-tags/updateAltTag",r.target.value)})),t&&y.prototype.$truSeo.runAnalysis({postId:o.state.currentPost.id})};export{It as a,St as b,At as c,Ct as d,_ as e,b as f,Tt as g,wt as h,h as i,x as j,Lt as k,T as m,j as s,st as t};