Files
sm-seo-plugin/assets/dist/seo.js

2 lines
27 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
const K={count:":chars characters · :px / :max px",good:"Good length",emptyTitle:"Empty: the title template is used",emptyDescription:"Empty: the template or the excerpt is used",shortTitle:"Short: aim for 30–60 characters",shortDescription:"Short: aim for 120–160 characters",longTitle:"Too long: Google cuts titles after about 580 px",longDescription:"Too long: Google cuts descriptions after about 920 px on desktop and 680 px on mobile",indexing:"Indexing",links:"Links",inherit:"Inherit",siteDefault:"Site default",index:"Index",noindex:"Noindex",follow:"Follow",nofollow:"Nofollow",advanced:"Advanced directives",advancedSet:{one:":count set",other:":count set"},maxSnippet:"Maximum snippet length (characters)",maxSnippetHint:"Empty: no limit. 0: no snippet. -1: no limit.",maxImagePreview:"Image preview size",notSet:"Not set",none:"None",standard:"Standard",large:"Large",maxVideoPreview:"Maximum video preview (seconds)",noarchive:"Do not show a cached copy (noarchive)",nosnippet:"Do not show a snippet (nosnippet)",noimageindex:"Do not index images (noimageindex)",unavailableAfter:"Remove from results after",invalidNumber:"Enter a whole number, -1 or more.",desktop:"Desktop",mobile:"Mobile",device:"Preview device",language:"Language: :locale",fromTemplate:"Title from the template “:template”",fromContent:"Description from the content excerpt",noDescription:"No description: Google picks text from the page.",noUrl:"The address appears after the first save.",savedNote:"The address and the H1 come from the saved record. Save to refresh them.",checking:"Checking for duplicates…",dupTitle:{one:"Same title as :count other page: :list",other:"Same title as :count other pages: :list"},dupDescription:{one:"Same description as :count other page: :list",other:"Same description as :count other pages: :list"},andMore:"and :count more",keyphrase:"Focus keyphrase “:phrase”",kpTitle:"In the SEO title",kpTitleNo:"Not in the SEO title",kpH1:"In the H1",kpH1No:"Not in the H1",kpDesc:"In the meta description",kpDescNo:"Not in the meta description",kpUrl:"In the address",kpUrlNo:"Not in the address",kpLength:"Text length: :count words",kpLengthNo:"Text length: :count words, aim for at least 300",contextFailed:"The preview data could not be loaded.",imageUpload:"Upload image",imageReplace:"Replace image",imageRemove:"Remove",imageUploading:"Uploading…",imageFailed:"The image could not be uploaded.",imageAlt:"Social image preview"},Q={count:"Znaki: :chars · :px / :max px",good:"Dobra długość",emptyTitle:"Puste: używany jest szablon tytułu",emptyDescription:"Puste: używany jest szablon lub zajawka",shortTitle:"Krótki: celuj w 30–60 znaków",shortDescription:"Krótki: celuj w 120–160 znaków",longTitle:"Za długi: Google ucina tytuły po ok. 580 px",longDescription:"Za długi: Google ucina opisy po ok. 920 px na komputerze i 680 px na telefonie",indexing:"Indeksowanie",links:"Linki",inherit:"Dziedzicz",siteDefault:"Domyślne",index:"Indeksuj",noindex:"Nie indeksuj",follow:"Śledź",nofollow:"Nie śledź",advanced:"Dyrektywy zaawansowane",advancedSet:{one:"ustawiona :count",few:"ustawione :count",many:"ustawionych :count",other:"ustawione :count"},maxSnippet:"Maksymalna długość fragmentu (znaki)",maxSnippetHint:"Puste: bez limitu. 0: bez fragmentu. -1: bez limitu.",maxImagePreview:"Rozmiar podglądu obrazu",notSet:"Nie ustawiono",none:"Brak",standard:"Standardowy",large:"Duży",maxVideoPreview:"Maksymalny podgląd wideo (sekundy)",noarchive:"Nie pokazuj kopii (noarchive)",nosnippet:"Nie pokazuj fragmentu (nosnippet)",noimageindex:"Nie indeksuj obrazów (noimageindex)",unavailableAfter:"Usuń z wyników po dniu",invalidNumber:"Wpisz liczbę całkowitą, -1 lub większą.",desktop:"Komputer",mobile:"Telefon",device:"Urządzenie podglądu",language:"Język: :locale",fromTemplate:"Tytuł z szablonu „:template”",fromContent:"Opis z zajawki treści",noDescription:"Brak opisu: Google wybierze tekst ze strony.",noUrl:"Adres pojawi się po pierwszym zapisie.",savedNote:"Adres i H1 pochodzą z zapisanego rekordu. Zapisz, aby je odświeżyć.",checking:"Sprawdzanie duplikatów…",dupTitle:{one:"Ten sam tytuł co :count inna strona: :list",few:"Ten sam tytuł co :count inne strony: :list",many:"Ten sam tytuł co :count innych stron: :list",other:"Ten sam tytuł co :count innej strony: :list"},dupDescription:{one:"Ten sam opis co :count inna strona: :list",few:"Ten sam opis co :count inne strony: :list",many:"Ten sam opis co :count innych stron: :list",other:"Ten sam opis co :count innej strony: :list"},andMore:"i :count więcej",keyphrase:"Fraza kluczowa „:phrase”",kpTitle:"W tytule SEO",kpTitleNo:"Brak w tytule SEO",kpH1:"W nagłówku H1",kpH1No:"Brak w nagłówku H1",kpDesc:"W opisie meta",kpDescNo:"Brak w opisie meta",kpUrl:"W adresie",kpUrlNo:"Brak w adresie",kpLength:"Długość tekstu: :count słów",kpLengthNo:"Długość tekstu: :count słów, celuj w co najmniej 300",contextFailed:"Nie udało się wczytać danych podglądu.",imageUpload:"Wgraj obraz",imageReplace:"Zmień obraz",imageRemove:"Usuń",imageUploading:"Wgrywanie…",imageFailed:"Nie udało się wgrać obrazu.",imageAlt:"Podgląd obrazu w mediach społecznościowych"},ee={en:K,pl:Q};function k(i){return(i.getAttribute("ui-locale")||document.documentElement.lang||"en").toLowerCase().split(/[-_]/)[0]||"en"}function I(i){return ee[i]??K}function y(i,e={}){const t=Object.keys(e).sort((s,o)=>o.length-s.length);let n=i;for(const s of t)n=n.split(":"+s).join(String(e[s]));return n}function $(i,e,t,n={}){let s="other";try{s=new Intl.PluralRules(t).select(e)}catch{s=e===1?"one":"other"}const o=s==="one"&&i.one||s==="few"&&i.few||s==="many"&&i.many||i.other;return y(o,{...n,count:new Intl.NumberFormat(t).format(e)})}function L(i,e){try{return new Intl.NumberFormat(e).format(i)}catch{return String(i)}}const F="http://www.w3.org/2000/svg",te={info:["M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20z","M12 16v-4","M12 8h.01"],"triangle-alert":["m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3","M12 9v4","M12 17h.01"],"circle-check":["M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20z","m9 12 2 2 4-4"],"circle-alert":["M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20z","M12 8v4","M12 16h.01"],"chevron-down":["m6 9 6 6 6-6"]};function E(i,e=14){const t=document.createElementNS(F,"svg");t.setAttribute("width",String(e)),t.setAttribute("height",String(e)),t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("fill","none"),t.setAttribute("stroke","currentColor"),t.setAttribute("stroke-width","2"),t.setAttribute("stroke-linecap","round"),t.setAttribute("stroke-linejoin","round"),t.setAttribute("aria-hidden","true"),t.setAttribute("class","seo-icon seo-icon--"+i);for(const n of te[i]??[]){const s=document.createElementNS(F,"path");s.setAttribute("d",n),t.appendChild(s)}return t}function r(i,e="",t){const n=document.createElement(i);return e&&(n.className=e),t!==void 0&&(n.textContent=t),n}function j(i,e,t){const n=i.getAttribute(e);if(n===null||n==="")return t;try{return JSON.parse(n)}catch{return t}}function A(i,e,t){i.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}let U=0;function N(i){return U+=1,`${i}-${U}`}const H="golem15-seo-image";function ne(i){return/^\/(?!\/)/.test(i)||/^https?:\/\//i.test(i)}class ie extends HTMLElement{static observedAttributes=["disabled","invalid","ui-locale"];current="";pending="";error="";onUploadResult=e=>{const t=e.detail;!t||t.id!==this.pending||(this.pending="",typeof t.url=="string"&&t.url!==""?(this.current=t.url,this.error="",A(this,"summer-change",{value:this.current})):this.error=t.error||this.labels().imageFailed,this.render())};get value(){return this.current}set value(e){this.current=typeof e=="string"?e:"",this.render()}connectedCallback(){this.addEventListener("summer-upload-result",this.onUploadResult),this.render()}disconnectedCallback(){this.removeEventListener("summer-upload-result",this.onUploadResult)}attributeChangedCallback(){this.isConnected&&this.render()}labels(){return I(k(this))}render(){const e=this.labels(),t=this.hasAttribute("disabled"),n=[];if(this.current&&ne(this.current)){const o=r("div","seo-image__preview"),a=r("img","seo-image__img");a.src=this.current,a.alt=e.imageAlt,a.width=240,a.height=126,o.append(a),n.push(o)}if(!t){const o=r("div","seo-image__actions"),a=N("seo-image-file"),l=r("input","seo-visually-hidden");l.type="file",l.accept="image/jpeg,image/png,image/gif,image/webp",l.id=a,l.addEventListener("change",()=>{const u=l.files?.[0];u&&(this.pending=N("seo-image-upload"),this.error="",this.render(),A(this,"summer-upload",{id:this.pending,file:u}))});const c=r("label","seo-image__button",this.current?e.imageReplace:e.imageUpload);if(c.htmlFor=a,o.append(l,c),this.current){const u=r("button","seo-image__button seo-image__button--secondary",e.imageRemove);u.type="button",u.addEventListener("click",()=>{this.current="",this.error="",A(this,"summer-change",{value:""}),this.render()}),o.append(u)}n.push(o)}const s=r("div","seo-image__status"+(this.error?" seo-image__status--error":""));s.setAttribute("role","status"),s.textContent=this.pending?e.imageUploading:this.error,n.push(s),this.classList.toggle("seo-image--invalid",this.hasAttribute("invalid")),this.replaceChildren(...n)}}const O="golem15-seo-robots";function P(){return{index:"",follow:"",noarchive:!1,nosnippet:!1,noimageindex:!1,maxSnippet:null,maxImagePreview:"",maxVideoPreview:null,unavailableAfter:""}}function se(i){const e=P(),t=i.trim();if(t==="")return e;const n=new Set;for(const s of t.split(",")){const o=s.trim().toLowerCase();if(o==="")return null;const a=o.indexOf(":"),l=(a<0?o:o.slice(0,a)).trim(),c=a<0?null:o.slice(a+1).trim(),u=l==="noindex"?"index":l==="nofollow"?"follow":l;if(n.has(u))return null;switch(n.add(u),l){case"index":case"noindex":if(c!==null)return null;e.index=l;break;case"follow":case"nofollow":if(c!==null)return null;e.follow=l;break;case"noarchive":case"nosnippet":case"noimageindex":if(c!==null)return null;e[l]=!0;break;case"max-snippet":case"max-video-preview":{if(c===null||!/^-?\d+$/.test(c))return null;const d=Number.parseInt(c,10);if(d<-1)return null;l==="max-snippet"?e.maxSnippet=d:e.maxVideoPreview=d;break}case"max-image-preview":if(c!=="none"&&c!=="standard"&&c!=="large")return null;e.maxImagePreview=c;break;case"unavailable_after":if(c===null||!/^\d{4}-\d{2}-\d{2}$/.test(c)||Number.isNaN(Date.parse(c+"T00:00:00Z")))return null;e.unavailableAfter=c;break;default:return null}}return e}function oe(i){const e=[];return i.index&&e.push(i.index),i.follow&&e.push(i.follow),i.noarchive&&e.push("noarchive"),i.nosnippet&&e.push("nosnippet"),i.noimageindex&&e.push("noimageindex"),i.maxSnippet!==null&&e.push("max-snippet:"+i.maxSnippet),i.maxImagePreview&&e.push("max-image-preview:"+i.maxImagePreview),i.maxVideoPreview!==null&&e.push("max-video-preview:"+i.maxVideoPreview),i.unavailableAfter&&e.push("unavailable_after:"+i.unavailableAfter),e.join(",")}function z(i){return[i.noarchive,i.nosnippet,i.noimageindex,i.maxSnippet!==null,i.maxImagePreview!=="",i.maxVideoPreview!==null,i.unavailableAfter!==""].filter(Boolean).length}class re extends HTMLElement{static observedAttributes=["options","disabled","invalid","ui-locale","locale"];current="";model=P();open=!1;get value(){return this.current}set value(e){const t=typeof e=="string"?e:e==null?"":String(e);t===this.current&&this.childElementCount>0||(this.current=t,this.model=se(t)??P(),this.open=this.open||z(this.model)>0,this.render())}connectedCallback(){this.open=z(this.model)>0,this.render()}attributeChangedCallback(){this.isConnected&&this.render()}labels(){return I(k(this))}commit(){this.current=oe(this.model),A(this,"summer-change",{value:this.current}),this.render()}render(){const e=this.labels(),t=this.hasAttribute("disabled"),s=j(this,"options",{}).scope==="type"?e.siteDefault:e.inherit;this.classList.toggle("seo-robots--invalid",this.hasAttribute("invalid"));const o=document.activeElement&&this.contains(document.activeElement)?document.activeElement.dataset.focusKey:void 0,a=r("div","seo-robots__groups");a.append(this.radioGroup(e.indexing,"index",[["",s,"inherit"],["index",e.index,"ok"],["noindex",e.noindex,"danger"]],t),this.radioGroup(e.links,"follow",[["",s,"inherit"],["follow",e.follow,"ok"],["nofollow",e.nofollow,"danger"]],t));const l=N("seo-robots-advanced"),c=r("button","seo-robots__toggle");c.type="button",c.setAttribute("aria-expanded",this.open?"true":"false"),c.setAttribute("aria-controls",l),c.dataset.focusKey="toggle",c.append(r("span","",e.advanced),E("chevron-down")),c.addEventListener("click",()=>{this.open=!this.open,this.render()});const u=r("div","seo-robots__advanced-row");u.append(c);const d=z(this.model);d>0&&u.append(r("span","seo-robots__summary",$(e.advancedSet,d,k(this))));const m=r("div","seo-robots__panel");m.id=l,m.hidden=!this.open,m.append(this.numberField(e.maxSnippet,e.maxSnippetHint,"maxSnippet",t,e),this.selectField(e,t),this.numberField(e.maxVideoPreview,"","maxVideoPreview",t,e),this.dateField(e,t));const f=r("div","seo-robots__checks");for(const b of["noarchive","nosnippet","noimageindex"]){const p=r("label","seo-robots__check"),h=r("input");h.type="checkbox",h.checked=this.model[b],h.disabled=t,h.dataset.focusKey=b,h.addEventListener("change",()=>{this.model[b]=h.checked,this.commit()}),p.append(h,r("span","",e[b])),f.append(p)}m.append(f),this.replaceChildren(a,u,m),o&&this.querySelector(`[data-focus-key="${o}"]`)?.focus()}radioGroup(e,t,n,s){const o=r("div","seo-robots__group"),a=N("seo-robots-caption"),l=r("span","seo-robots__caption",e);l.id=a;const c=r("div","seo-robots__track");c.setAttribute("role","radiogroup"),c.setAttribute("aria-labelledby",a);const u=this.model[t];return n.forEach(([d,m,f],b)=>{const p=r("button","seo-robots__segment seo-robots__segment--"+f,m);p.type="button",p.setAttribute("role","radio");const h=u===d;p.setAttribute("aria-checked",h?"true":"false"),p.tabIndex=h?0:-1,p.disabled=s,p.dataset.focusKey=t+"-"+b,p.addEventListener("click",()=>this.choose(t,d)),p.addEventListener("keydown",v=>{const x=v.key==="ArrowRight"||v.key==="ArrowDown"?1:v.key==="ArrowLeft"||v.key==="ArrowUp"?-1:0;if(x===0||s)return;v.preventDefault();const T=(b+x+n.length)%n.length;this.choose(t,n[T][0]),this.querySelector(`[data-focus-key="${t}-${T}"]`)?.focus()}),c.append(p)}),o.append(l,c),o}choose(e,t){this.hasAttribute("disabled")||(e==="index"?this.model.index=t:this.model.follow=t,this.commit())}numberField(e,t,n,s,o){const a=r("label","seo-robots__field");a.append(r("span","seo-robots__label",e));const l=r("input","seo-robots__input");l.type="number",l.min="-1",l.step="1",l.disabled=s,l.dataset.focusKey=n;const c=this.model[n];l.value=c===null?"":String(c);const u=r("span","seo-robots__error");return u.setAttribute("role","status"),l.addEventListener("change",()=>{const d=l.value.trim();if(d===""){this.model[n]=null,this.commit();return}if(!/^-?\d+$/.test(d)||Number.parseInt(d,10)<-1){u.textContent=o.invalidNumber;return}this.model[n]=Number.parseInt(d,10),this.commit()}),a.append(l),t&&a.append(r("span","seo-robots__hint",t)),a.append(u),a}selectField(e,t){const n=r("label","seo-robots__field");n.append(r("span","seo-robots__label",e.maxImagePreview));const s=r("select","seo-robots__input");s.disabled=t,s.dataset.focusKey="maxImagePreview";for(const[o,a]of[["",e.notSet],["none",e.none],["standard",e.standard],["large",e.large]]){const l=r("option","",a);l.value=o,l.selected=this.model.maxImagePreview===o,s.append(l)}return s.addEventListener("change",()=>{this.model.maxImagePreview=s.value,this.commit()}),n.append(s),n}dateField(e,t){const n=r("label","seo-robots__field");n.append(r("span","seo-robots__label",e.unavailableAfter));const s=r("input","seo-robots__input");return s.type="date",s.disabled=t,s.dataset.focusKey="unavailableAfter",s.value=this.model.unavailableAfter,s.addEventListener("change",()=>{this.model.unavailableAfter=/^\d{4}-\d{2}-\d{2}$/.test(s.value)?s.value:"",this.commit()}),n.append(s),n}}const V="20px Arial, sans-serif",X="14px Arial, sans-serif",Z=580,J=920,ae=680,le=30,ce=120;let S;function ue(){if(S!==void 0)return S;try{const e=document.createElement("canvas").getContext("2d");S=e&&typeof e.measureText=="function"?e:null}catch{S=null}return S}function de(i,e){let t=0;for(const n of i)/[ilIj.,:;'!|]/.test(n)?t+=.28:/[mwMW@]/.test(n)?t+=.85:/[A-Z]/.test(n)?t+=.67:n===" "?t+=.28:t+=.53;return t*e}function M(i,e){const t=ue();if(t){t.font=e;const s=t.measureText(i).width;if(Number.isFinite(s)&&(s>0||i===""))return s}const n=Number.parseFloat(e)||14;return de(i,n)}function G(i,e,t){if(M(i,e)<=t)return i;const n=Array.from(i);let s=0,o=n.length;for(;s<o;){const a=Math.ceil((s+o)/2);M(n.slice(0,a).join("").trimEnd()+"…",e)<=t?s=a:o=a-1}return n.slice(0,s).join("").trimEnd()+"…"}function pe(i){return i==="title"?{font:V,maxPx:Z,shortChars:le}:{font:X,maxPx:J,shortChars:ce}}function he(i,e){const{font:t,maxPx:n,shortChars:s}=pe(e),o=i.trim(),a=Array.from(o).length,l=Math.round(M(o,t));let c="good";return o===""?c="empty":l>n?c="long":a<s&&(c="short"),{status:c,chars:a,px:l,maxPx:n}}const W="golem15-seo-serp",me=800,D=3,fe=300;function ge(i,e){return i.trim()===""?"":i.split("%title%").join(e.title).split("%description%").join(e.description??"").split("%site%").join(e.site).split(/\s+/).filter(Boolean).join(" ").replace(/^[\s|\-–—·:,]+|[\s|\-–—·:,]+$/gu,"")}function be(i){return i.toLowerCase().replace(/ł/g,"l").normalize("NFD").replace(/\p{M}/gu,"")}function B(i){return be(i).split(/[^\p{L}\p{N}]+/u).filter(Boolean)}function ve(i,e){if(i===e)return!0;const t=Array.from(i),n=Array.from(e);if(t.length<5||n.length<5)return!1;const s=Math.max(5,Math.min(t.length,n.length)-3);let o=0;for(;o<t.length&&o<n.length&&t[o]===n[o];)o++;return o>=s}function C(i,e){const t=B(i);if(t.length===0)return!1;const n=B(e);for(let s=0;s+t.length<=n.length;s++){let o=!0;for(let a=0;a<t.length;a++)if(!ve(t[a],n[s+a])){o=!1;break}if(o)return!0}return!1}function w(i,e,t){const n=i[e];if(typeof n=="string")return n;if(n&&typeof n=="object"){const s=n[t];return typeof s=="string"?s:""}return""}class xe extends HTMLElement{static observedAttributes=["fill-values","busy","state","record-id","ui-locale","locale","disabled"];context=null;contextFailed=!1;device="desktop";shownLocale="";inflight=null;queued=null;duplicates=new Map;checking=!1;timer;lastChecked="";connected=!1;onResult=e=>{const n=e.detail?.data;this.inflight=null,n&&n.op==="context"?(this.context=n,this.contextFailed=!1,this.render(),this.scheduleDuplicates(!0)):n&&n.op==="duplicates"&&(this.duplicates.set(n.locale,n),this.checking=!1,this.render()),this.flush()};onLocale=e=>{const t=e.detail;typeof t=="string"&&t!==""&&t!==this.shownLocale&&(this.shownLocale=t,this.render(),this.scheduleDuplicates(!1))};connectedCallback(){this.connected=!0,this.addEventListener("summer-result",this.onResult),window.addEventListener("summer:ml-locale",this.onLocale),this.render(),this.request({op:"context"})}disconnectedCallback(){this.connected=!1,this.removeEventListener("summer-result",this.onResult),window.removeEventListener("summer:ml-locale",this.onLocale),clearTimeout(this.timer)}attributeChangedCallback(e,t,n){if(this.connected){if(e==="busy"&&n===null){this.flush();return}if(e==="state"&&n==="error"){this.inflight?.op==="context"&&(this.contextFailed=!0),this.checking=!1,this.inflight=null,this.render();return}if(e==="fill-values"){this.render(),this.scheduleDuplicates(!1);return}this.render()}}labels(){return I(k(this))}request(e){if(this.hasAttribute("busy")||this.inflight){this.queued=e;return}this.inflight=e,A(this,"summer-action",{payload:e})}flush(){if(this.hasAttribute("busy")||this.inflight||!this.queued)return;const e=this.queued;this.queued=null,this.request(e)}fill(){return j(this,"fill-values",{})}locale(){const e=this.context?.locales??[];return e.length===0?null:e.find(t=>t.locale===this.shownLocale)??e[0]}scheduleDuplicates(e){const t=this.locale();if(!t)return;const n=this.fill(),s=w(n,"seo_title",t.locale)||w(n,"title",t.locale),o=w(n,"seo_description",t.locale)||w(n,"description",t.locale),a=JSON.stringify([t.locale,s,o]);if(a===this.lastChecked)return;clearTimeout(this.timer);const l=()=>{this.lastChecked=a,this.checking=!0,this.render(),this.request({op:"duplicates",locale:t.locale,title:s,description:o})};e?l():this.timer=setTimeout(l,me)}render(){const e=this.labels(),t=k(this);if(!this.context&&!this.contextFailed){this.setAttribute("aria-busy","true"),this.replaceChildren(r("div","seo-serp__skeleton"));return}this.removeAttribute("aria-busy");const n=this.locale(),s=n?.locale??this.shownLocale,o=this.fill(),a=(w(o,"seo_title",s)||w(o,"title",s)).trim(),l=(w(o,"seo_description",s)||w(o,"description",s)).trim(),c=w(o,"seo_keyphrase",s).trim(),u=n?.siteName??"",d=a||ge(n?.titleTemplate??"",{title:n?.defaultTitle??"",site:u})||n?.defaultTitle||"",m=l||n?.defaultDescription||"",f=r("div","seo-serp__header"),b=r("div","seo-serp__track");b.setAttribute("role","radiogroup"),b.setAttribute("aria-label",e.device);for(const g of["desktop","mobile"]){const _=r("button","seo-serp__segment",e[g]);_.type="button",_.setAttribute("role","radio"),_.setAttribute("aria-checked",this.device===g?"true":"false"),_.addEventListener("click",()=>{this.device=g,this.render()}),b.append(_)}f.append(b),s&&f.append(r("span","seo-serp__language",y(e.language,{locale:s.toUpperCase()})));const p=r("div","serp-card"+(this.device==="mobile"?" serp-card--mobile":"")),h=r("div","serp-card__site");h.append(r("span","serp-card__favicon",Array.from(u||this.context?.host||"?")[0]?.toUpperCase()??"?"));const v=r("div","serp-card__names");if(v.append(r("span","serp-card__sitename",u||this.context?.host||"")),v.append(r("span","serp-card__crumbs",we(this.context?.host??"",n?.url??null))),h.append(v),p.append(h),p.append(r("div","serp-card__title",G(d,V,Z))),m){const g=this.device==="mobile"?ae:J;p.append(r("div","serp-card__description",G(m,X,g)))}else p.append(r("div","serp-card__description serp-card__description--missing",e.noDescription));const x=r("div","seo-serp__notes");if(this.contextFailed){const g=r("div","seo-serp__error");g.setAttribute("role","status"),g.append(E("circle-alert"),r("span","",e.contextFailed)),x.append(g)}!a&&n?.titleTemplate&&x.append(r("div","",y(e.fromTemplate,{template:n.titleTemplate}))),!l&&n?.defaultDescription&&n.descriptionSource==="content"&&x.append(r("div","",e.fromContent)),n&&n.url===null&&x.append(r("div","",e.noUrl)),(this.getAttribute("record-id")??"")!==""&&n&&x.append(r("div","",e.savedNote));const T=r("div","seo-serp__checks");if(T.setAttribute("role","status"),this.checking)T.append(r("div","seo-serp__checking",e.checking));else{const g=this.duplicates.get(s);if(g)for(const[_,Y]of[[g.title,e.dupTitle],[g.description,e.dupDescription]])_.length>0&&T.append(_e(_,Y,e,t))}const R=[f,p,x,T];c&&n&&R.push(ke(c,{title:d,description:m,h1:n.h1,url:n.url,bodyWords:n.bodyWords},e,t)),this.replaceChildren(...R)}}function we(i,e){const t=(e??"").split("?")[0].split("/").filter(Boolean).map(n=>{try{return decodeURIComponent(n)}catch{return n}});return[i,...t].filter(Boolean).join(" › ")}function _e(i,e,t,n){const s=r("div","seo-serp__check seo-serp__check--warn");s.append(E("triangle-alert"));const o=r("span"),a="\0list\0",l=$(e,i.length,n,{list:a}),[c,u]=l.split(a);return o.append(document.createTextNode(c??"")),i.slice(0,D).forEach((d,m)=>{if(m>0&&o.append(document.createTextNode(", ")),d.url.startsWith("/")&&!d.url.startsWith("//")){const f=r("a","seo-serp__link",d.label);f.href=d.url,f.target="_blank",f.rel="noopener",o.append(f)}else o.append(document.createTextNode(d.label))}),i.length>D&&o.append(document.createTextNode(" "+y(t.andMore,{count:i.length-D}))),o.append(document.createTextNode(u??"")),s.append(o),s}function ke(i,e,t,n){const s=r("div","seo-serp__keyphrase");s.append(r("div","seo-serp__keyphrase-title",y(t.keyphrase,{phrase:i})));const o=(a,l,c)=>{const u=r("div","seo-serp__check "+(a?"seo-serp__check--ok":"seo-serp__check--warn"));u.append(E(a?"circle-check":"triangle-alert"),r("span","",a?l:c)),s.append(u)};if(o(C(i,e.title),t.kpTitle,t.kpTitleNo),e.h1!==null&&o(C(i,e.h1),t.kpH1,t.kpH1No),o(C(i,e.description),t.kpDesc,t.kpDescNo),e.url!==null&&o(C(i,e.url.replace(/[-_/]+/g," ")),t.kpUrl,t.kpUrlNo),e.bodyWords!==null){const a=new Intl.NumberFormat(n).format(e.bodyWords);o(e.bodyWords>=fe,y(t.kpLength,{count:a}),y(t.kpLengthNo,{count:a}))}return s}const q="golem15-seo-text",ye={empty:"info",short:"triangle-alert",long:"triangle-alert",good:"circle-check"};class Te extends HTMLElement{static observedAttributes=["options","disabled","invalid","ui-locale","locale"];current="";control=null;statusIcon=null;statusText=null;countText=null;live=null;lastStatus=null;builtFor="";get value(){return this.current}set value(e){this.current=typeof e=="string"?e:e==null?"":String(e),this.control&&this.control.value!==this.current&&(this.control.value=this.current),this.update(!1)}connectedCallback(){this.build()}attributeChangedCallback(e){if(this.isConnected){if(e==="options"||e==="ui-locale"){this.build();return}this.sync()}}measure(){return j(this,"options",{}).measure==="description"?"description":"title"}labels(){return I(k(this))}build(){const e=this.measure()+"|"+k(this);if(this.builtFor===e&&this.control){this.sync();return}this.builtFor=e,this.replaceChildren();const t=N("seo-text-counter"),s=this.measure()==="description"?r("textarea","seo-text__control seo-text__control--area"):r("input","seo-text__control");s instanceof HTMLTextAreaElement?s.rows=3:s.type="text",s.value=this.current,s.setAttribute("aria-describedby",t);const o=this.getAttribute("field-name");o&&s.setAttribute("aria-label",o),s.addEventListener("input",()=>{this.hasAttribute("disabled")||(this.current=s.value.replace(/\s+$/u,""),this.update(!0),A(this,"summer-change",{value:this.current}))});const a=r("div","seo-text__counter");a.id=t;const l=r("span","seo-text__status");this.statusIcon=r("span","seo-text__icon"),this.statusText=r("span","seo-text__status-text"),l.append(this.statusIcon,this.statusText),this.countText=r("span","seo-text__count"),a.append(l,this.countText),this.live=r("span","seo-visually-hidden"),this.live.setAttribute("aria-live","polite"),this.live.setAttribute("role","status"),this.control=s,this.lastStatus=null,this.append(s,a,this.live),this.sync()}sync(){if(!this.control)return;const e=this.hasAttribute("disabled");this.control.readOnly=e,this.classList.toggle("seo-text--invalid",this.hasAttribute("invalid")),this.control.setAttribute("aria-invalid",this.hasAttribute("invalid")?"true":"false"),this.update(!1)}update(e){if(!this.statusText||!this.countText||!this.statusIcon)return;const t=this.labels(),n=k(this),s=this.measure(),o=he(this.current,s),a=Ae(t,o.status,s);this.statusIcon.replaceChildren(E(ye[o.status])),this.statusText.textContent=a,this.dataset.status=o.status,this.countText.textContent=y(t.count,{chars:L(o.chars,n),px:L(o.px,n),max:L(o.maxPx,n)}),e&&this.live&&o.status!==this.lastStatus&&(this.live.textContent=a),this.lastStatus=o.status}}function Ae(i,e,t){switch(e){case"empty":return t==="title"?i.emptyTitle:i.emptyDescription;case"short":return t==="title"?i.shortTitle:i.shortDescription;case"long":return t==="title"?i.longTitle:i.longDescription;default:return i.good}}customElements.get(q)||customElements.define(q,Te);customElements.get(O)||customElements.define(O,re);customElements.get(W)||customElements.define(W,xe);customElements.get(H)||customElements.define(H,ie);export{H as IMAGE_TAG,O as ROBOTS_TAG,W as SERP_TAG,ie as SeoImageElement,re as SeoRobotsElement,xe as SeoSerpElement,Te as SeoTextElement,q as TEXT_TAG};