(()=>{var _=(e,t)=>{t.innerHTML=e.innerHTML;for(let n of e.attributes)t.setAttribute(n.name,n.value);e.parentElement?.insertBefore(t,e);let i=window.getComputedStyle(e),a=window.getComputedStyle(t);for(let n in i){if(!Object.getOwnPropertyDescriptor(t.style,n)?.writable)return;let r=i[n],l=i.getPropertyValue(r);a.setProperty(r,l)}},f=_;var v=(e,t)=>e.evaluate(t,e,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue,s=v;var j=(e,{xpath:t,status:i})=>{let a=i==="REJECTED";if(a){let r=t.split("/");t=r.slice(0,r.length-1)+r[r.length-1].replace("h1","h2")}let n=s(e,t);if(!n)return;let o=e.createElement(a?"h1":"h2");f(n,o),n.remove()},E=j;var S=(e,{xpath:t,data:{tagName:i},status:a})=>{let n=a==="REJECTED";if(n){let l=t.split("/");t=l.slice(0,l.length-1)+l[l.length-1].replace(i,"h1")}let o=s(e,t);if(!o)return;let r=e.createElement(n?i:"h1");f(o,r),o.remove()},C=S;var b=(e,{xpath:t,data:i,status:a,id:n},o)=>{let{alt:r}=i,l=s(e,t);l&&(a==="REJECTED"&&(r=o[n].alt),o[n]||(o[n]={alt:l.alt}),l.alt=r)},T=b;var P=(e,{xpath:t,status:i,id:a},n)=>{let o=s(e,t);if(!o)return;let r="_blank";i==="REJECTED"&&(r=n[a].target),n[a]||(n[a]={target:o.target}),o.target=r},M=P;var I=(e,{xpath:t,data:i,status:a,id:n},o)=>{let{title:r}=i,l=s(e,t);l&&(a==="REJECTED"&&(r=o[n].title),o[n]||(o[n]={title:l.title}),l.title=r)},L=I;var k=(e,{xpath:t,data:i,status:a,id:n},o)=>{let{content:r}=i,l=s(e,t);if(a==="REJECTED"){if(!l)return;if(!o[n]?.content){l.remove();return}r=o[n].content}if(l){o[n]||(o[n]={content:l.content}),l.content=r;return}let m=e.createElement("meta");m.name="description",m.content=r,e.head.appendChild(m)},R=k;var G=(e,{xpath:t,data:i,status:a,id:n},o)=>{let{content:r,property:l}=i,m=s(e,t);if(a==="REJECTED"){if(!m)return;if(!o[n]?.content){m.remove();return}r=o[n].content}if(m){o[n]||(o[n]={content:m.content}),m.content=r;return}let h=e.createElement("meta");h.setAttribute("property",l),h.content=r,e.head.appendChild(h)},w=G;var N=(e,{xpath:t,data:i,status:a,id:n},o)=>{let{textContent:r}=i,l=s(e,t);if(a==="REJECTED"){if(!l)return;if(!o[n]?.textContent){l.remove();return}({textContent:r}=o[n])}if(l){o[n]||(o[n]={textContent:l.textContent}),l.textContent=r;return}let m=e.createElement("title");m.textContent=r,e.head.appendChild(m)},y=N;var W="https://seonaapi.usestyle.ai/api/v3/plugin-code-changes",B=async e=>{let t=e.location.href;try{let i=await fetch(`${W}?url=${encodeURIComponent(t)}`),{success:a,data:n,error:o}=await i.json();if(!a)throw new Error(o);return n.codeChanges.map(r=>({...r,data:JSON.parse(r.data)}))}catch(i){return console.error(i),[]}},H=B;var g,p,u=null,c=null,x={},D={H1_DEMOTION:E,H1_PROMOTION:C,ADD_ALT_TAG:T,ADD_LINK_TARGET:M,ADD_LINK_TITLE:L,OPTIMIZE_DESCRIPTION:R,ADD_OG_SITE_TAG:w,OPTIMIZE_TITLE:y},V=e=>{D[e.type]?.(p,e,x)},A=()=>{if(!u||!c)return;let{top:e,bottom:t,left:i,right:a}=u.getBoundingClientRect(),n=c.getBoundingClientRect();(e!==n.top||a!==n.right||t!==n.bottom||i!==n.left)&&(c.style.left=i+"px",c.style.top=e+"px",c.style.width=a-i+"px",c.style.height=t-e+"px"),requestAnimationFrame(A)},F=e=>{if(c?.remove(),u=e?s(p,e):null,!u)return;let t=p.createElement("div");t.style.position="fixed",t.style.zIndex="2147483647",t.style.backgroundColor="red",p.body.append(t),c=t,requestAnimationFrame(A),u.scrollIntoView()},q={update:V,locate:F},O=["https://seona.usestyle.ai","http://localhost:5181"],z=e=>{if(!O.includes(e.origin)||typeof e.data!="object")return;let{type:t,payload:i}=e.data;q[t]?.(i)},J=async()=>{if(p=document,g=window,window.self!==window.parent&&window.location.href==="about:srcdoc"){try{p=window.parent.document}catch(t){console.error(t);return}g=window.parent}let e=await H(g);for(let t of e)D[t.type](p,t,x);if(g!==window.top){g.addEventListener("message",z);for(let t of O)window.top?.postMessage("seonajsplugin",t)}};document.addEventListener("DOMContentLoaded",J);})();
