(()=>{var j={targetWindow:window,targetDocument:document,initialState:{},modifiedXPaths:{}},s=j;var F="https://seonaapi.usestyle.ai/api/v3/plugin-code-changes",N=async()=>{let{targetWindow:t}=s;try{let e=await fetch(`${F}?url=${encodeURIComponent(t.location.href)}`),{success:i,data:o,error:n}=await e.json();if(!i)throw new Error(n);return o.codeChanges.map(r=>({...r,data:JSON.parse(r.data)}))}catch(e){return console.error(e),[]}},L=N;var I=(t,e)=>{e.innerHTML=t.innerHTML;for(let n of t.attributes)e.setAttribute(n.name,n.value);t.parentElement?.insertBefore(e,t);let i=window.getComputedStyle(t),o=window.getComputedStyle(e);for(let n in i){if(!Object.getOwnPropertyDescriptor(e.style,n)?.writable)return;let a=i[n],l=i.getPropertyValue(a);o.setProperty(a,l)}},h=I;var k=t=>{let{targetDocument:e}=s;return e.evaluate(t,e,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue},m=k;var G=t=>{let e=[];for(;t;){if(t.id){e.unshift(`/*[@id="${t.id}"]`);break}let i=t.parentNode?.childNodes??[],o=1;for(let n=0;n<i.length;n++){let r=i[n];if(r===t){e.unshift(`${t.tagName.toLowerCase()}[${o}]`);break}r.nodeType===1&&r.tagName===t.tagName&&o++}t=t.parentNode}return"/"+e.join("/")},E=G;var W=({xpath:t,status:e})=>{let i=e==="REJECTED",{targetDocument:o,modifiedXPaths:n}=s,r=m(i?n[t]:t);if(!r)return;let a=o.createElement(i?"h1":"h2");if(h(r,a),r.remove(),i){delete n[t];return}n[t]=E(a)},M=W;var z=({xpath:t,data:{tagName:e},status:i})=>{let o=i==="REJECTED",{targetDocument:n,modifiedXPaths:r}=s,a=m(o?r[t]:t);if(!a)return;let l=n.createElement(o?e:"h1");if(h(a,l),a.remove(),o){delete r[t];return}r[t]=E(l)},x=z;var $=({xpath:t,data:e,status:i,id:o})=>{let{alt:n}=e,{initialState:r}=s,a=m(t);a&&(i==="REJECTED"&&(n=r[o].alt),r[o]||(r[o]={alt:a.alt}),a.alt=n)},w=$;var B=({xpath:t,status:e,id:i})=>{let{initialState:o}=s,n=m(t);if(!n)return;let r="_blank";e==="REJECTED"&&(r=o[i].target),o[i]||(o[i]={target:n.target}),n.target=r},y=B;var U=({xpath:t,data:e,status:i,id:o})=>{let{title:n}=e,{initialState:r}=s,a=m(t);a&&(i==="REJECTED"&&(n=r[o].title),r[o]||(r[o]={title:a.title}),a.title=n)},D=U;var V=({xpath:t,data:e,status:i,id:o})=>{let{content:n}=e,{initialState:r,targetDocument:a}=s,l=m(t);if(i==="REJECTED"){if(!l)return;if(!r[o]?.content){l.remove();return}n=r[o].content}if(l){r[o]||(r[o]={content:l.content}),l.content=n;return}let d=a.createElement("meta");d.name="description",d.content=n,a.head.appendChild(d)},H=V;var q=({xpath:t,data:e,status:i,id:o})=>{let{content:n,property:r}=e,{initialState:a,targetDocument:l}=s,d=m(t);if(i==="REJECTED"){if(!d)return;if(!a[o]?.content){d.remove();return}n=a[o].content}if(d){a[o]||(a[o]={content:d.content}),d.content=n;return}let u=l.createElement("meta");u.setAttribute("property",r),u.content=n,l.head.appendChild(u)},P=q;var J=({xpath:t,data:e,status:i,id:o})=>{let{textContent:n}=e,{targetDocument:r,initialState:a}=s,l=m(t);if(i==="REJECTED"){if(!l)return;if(!a[o]?.textContent){l.remove();return}({textContent:n}=a[o])}if(l){a[o]||(a[o]={textContent:l.textContent}),l.textContent=n;return}let d=r.createElement("title");d.textContent=n,r.head.appendChild(d)},R=J;var K={H1_DEMOTION:M,H1_PROMOTION:x,ADD_ALT_TAG:w,ADD_LINK_TARGET:y,ADD_LINK_TITLE:D,OPTIMIZE_DESCRIPTION:H,ADD_OG_SITE_TAG:P,OPTIMIZE_TITLE:R},C=K;var Z=async()=>{let t=await L();for(let e of t)C[e.type](e)},S=Z;var T=["https://seona.usestyle.ai","http://localhost:5181"],Y=t=>{for(let e of T)window.top?.postMessage(t,e)},g=Y;var f=null,p=null,A="#b523f9",Q=()=>{let{targetDocument:t}=s,e=t.createElement("div");return e.style.height="24px",e.style.width="24px",e.style.position="fixed",e.style.zIndex="2147483647",e.style.backgroundColor=A,e.style.borderRadius="50%",e.style.pointerEvents="none",e.style.boxShadow="0 0 256px 256px white",e},tt=()=>{let{targetDocument:t}=s,e=t.createElement("div");return e.style.height="24px",e.style.width="24px",e.style.position="absolute",e.style.left="0",e.style.top="0",e.style.borderRadius="50%",e.style.border=`4px solid ${A}`,e.style.boxSizing="border-box",e},b=()=>{if(!f||!p)return;let{left:t,right:e,top:i,bottom:o}=f.getBoundingClientRect(),{left:n,top:r}=p.getBoundingClientRect(),a=t+(e-t)/2-12,l=i+(o-i)/2-12;(n!==a||r!==l)&&(p.style.left=a+"px",p.style.top=l+"px"),requestAnimationFrame(b)},et=t=>{let{targetDocument:e,modifiedXPaths:i}=s;if(p?.remove(),f=t?m(i[t]??t):null,!f){g("seonajsplugin_not_found");return}let{x:o,y:n,width:r,height:a}=f.getBoundingClientRect();if(o===0&&n===0&&r===0&&a===0){g("seonajsplugin_hidden");return}let l=Q(),d=tt();l.appendChild(d),d.animate([{transform:"scale(1)",opacity:1},{transform:"scale(4)",opacity:0}],{duration:1e3,iterations:4}).addEventListener("finish",()=>{l.remove()}),f.scrollIntoView({behavior:"smooth",inline:"center",block:"center"}),p=l,e.body.append(p),requestAnimationFrame(b)},v=et;var ot=t=>{C[t.type]?.(t)},O=ot;var nt={locate:v,update:O},_=nt;var rt=t=>{if(!T.includes(t.origin)||!t.data.type||!t.data.payload)return;let{type:e,payload:i}=t.data;_[e]?.(i)},it=()=>{let{targetWindow:t}=s;t!==window.top&&(t.addEventListener("message",rt),g("seonajsplugin"))},X=it;var at=async()=>{await S(),X()};document.addEventListener("DOMContentLoaded",at);})();
