import{z as l,r as p}from"./index-jQAa3mQG.js";const g=e=>{const i=l();p.useEffect(()=>{const c=e?`https://clyper.ro${e}`:`https://clyper.ro${i.pathname}`,o=document.querySelector('link[rel="canonical"]');o&&o.remove();const r=document.createElement("link");return r.setAttribute("rel","canonical"),r.setAttribute("href",c),document.head.appendChild(r),()=>{const s=document.querySelector('link[rel="canonical"]');s&&s.remove()}},[i.pathname,e])},y=e=>{p.useEffect(()=>{const i=document.querySelector('meta[name="description"]');i&&i.remove();const c=document.createElement("meta");return c.setAttribute("name","description"),c.setAttribute("content",e),document.head.appendChild(c),()=>{const o=document.querySelector('meta[name="description"]');o&&o.remove()}},[e])},h=e=>{const i=l();p.useEffect(()=>{const c=e.url||`${window.location.origin}${i.pathname}`,o=[{property:"og:title",content:e.title},{property:"og:description",content:e.description},{property:"og:type",content:e.type||"website"},{property:"og:url",content:c},{property:"og:site_name",content:e.siteName||"Clyper"}];if(e.image){const t=e.image.startsWith("http")?e.image:`${window.location.origin}${e.image}`;o.push({property:"og:image",content:t},{property:"og:image:secure_url",content:t},{property:"og:image:width",content:"1200"},{property:"og:image:height",content:"630"},{property:"og:image:alt",content:e.title})}e.type==="product"&&(e.price!==void 0&&e.currency&&o.push({property:"og:price:amount",content:e.price.toString()},{property:"og:price:currency",content:e.currency}),e.availability&&o.push({property:"og:availability",content:e.availability}),e.brand&&o.push({property:"og:brand",content:e.brand}),e.condition&&o.push({property:"og:condition",content:e.condition}));const r=[{name:"twitter:card",content:e.twitterCard||"summary_large_image"},{name:"twitter:title",content:e.title},{name:"twitter:description",content:e.description}];if(e.image){const t=e.image.startsWith("http")?e.image:`${window.location.origin}${e.image}`;r.push({name:"twitter:image",content:t},{name:"twitter:image:alt",content:e.title})}return e.type==="product"&&e.price!==void 0&&r.push({name:"twitter:label1",content:"PreČ›"},{name:"twitter:data1",content:`${e.price.toFixed(2)} ${e.currency||"RON"}`}),e.twitterSite&&r.push({name:"twitter:site",content:e.twitterSite}),e.twitterCreator&&r.push({name:"twitter:creator",content:e.twitterCreator}),document.querySelectorAll('meta[property^="og:"]').forEach(t=>t.remove()),document.querySelectorAll('meta[name^="twitter:"]').forEach(t=>t.remove()),o.forEach(({property:t,content:m})=>{const n=document.createElement("meta");n.setAttribute("property",t),n.setAttribute("content",m),document.head.appendChild(n)}),r.forEach(({name:t,content:m})=>{const n=document.createElement("meta");n.setAttribute("name",t),n.setAttribute("content",m),document.head.appendChild(n)}),()=>{document.querySelectorAll('meta[property^="og:"]').forEach(n=>n.remove()),document.querySelectorAll('meta[name^="twitter:"]').forEach(n=>n.remove())}},[e,i.pathname])};export{y as a,h as b,g as u};