PageSourceSearch

https://kampnagel.de/assets/javascripts/chunks/4f26473129a83c883701.read-aloud-player.js

js kampnagel.de collected 2026-10-01 10:32:00 UTC 10,389 bytes, 2 lines download raw bytes

1"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[757],{1224:(e,t,i)=>{function n(e,t,i,n,s,r,a){try{var l=e[r](a),o=l.value}catch(e){return void i(e)}l.done?t(o):Promise.resolve(o).then(n,s)}function s(e){return function(){var t=this,i=arguments;return new Promise((function(s,r){var a=e.apply(t,i);function l(e){n(a,s,r,l,o,"next",e)}function o(e){n(a,s,r,l,o,"throw",e)}l(void 0)}))}}i.d(t,{YQ:()=>S,ec:()=>y,oz:()=>w}),i(6281),i(4962),i(518),i(6448),i(7593),i(76),i(5021),i(9425),i(3062),i(1810),i(6968),i(2367);var r="read-aloud-current",a="read-aloud-current-sentence",l="undefined"!=typeof window&&"Highlight"in window&&"highlights"in CSS;function o(){return document.documentElement.lang||"de"}var h="kn-read-aloud-rate";function d(e){return Number.isFinite(e)?Math.min(1.5,Math.max(.5,e)):1}var u=[],c=null,g=[[/natural/i,100],[/neural/i,90],[/online/i,80],[/katja|marlene|vicki|hedda|petra/i,60],[/samantha|aria|jenny|ava|allison|serena|libby|sonia/i,60],[/google/i,30]];function p(e){var t=0;return g.forEach((i=>{var[n,s]=i;n.test(e.name)&&(t=Math.max(t,s))})),/female|weiblich|frau/i.test(e.name)&&(t+=5),t}function m(){return(m=s((function*(e){var t=u.length?u:yield c||(c=new Promise((e=>{var t=window.speechSynthesis.getVoices();if(t.length)return u=t,void e(t);var i=()=>{u=window.speechSynthesis.getVoices(),window.speechSynthesis.removeEventListener("voiceschanged",i),e(u)};window.speechSynthesis.addEventListener("voiceschanged",i),setTimeout((()=>{u=window.speechSynthesis.getVoices(),window.speechSynthesis.removeEventListener("voiceschanged",i),e(u)}),1e3)}))),i=e.split("-")[0].toLowerCase(),n=t.filter((e=>e.lang.toLowerCase().split("-")[0]===i));return n.length?n.map(((e,t)=>({voice:e,score:p(e),index:t}))).sort(((e,t)=>t.score-e.score||e.index-t.index))[0].voice:t.find((e=>e.default))||t[0]||null}))).apply(this,arguments)}class v extends EventTarget{constructor(){super(),this.state="idle",this.segments=[],this.totalLength=0,this.currentIndex=0,this.keepAliveTimer=null,this.voice=null,this.rate=function(){try{var e=parseFloat(window.localStorage.getItem(h));return Number.isFinite(e)?d(e):1}catch(e){return 1}}(),this.speakToken=0,this.lastHighlightedElement=null,window.addEventListener("reload",(()=>this.stop())),window.addEventListener("pagehide",(()=>window.speechSynthesis.cancel()))}setState(e){this.state=e,this.dispatchEvent(new CustomEvent("statechange",{detail:{state:e}}))}emitProgress(){var e=this.segments.slice(0,this.currentIndex).reduce(((e,t)=>e+t.text.length),0),t=this.totalLength?Math.min(100,Math.round(e/this.totalLength*100)):0;this.dispatchEvent(new CustomEvent("progress",{detail:{progress:t}}))}play(){var e=this;return s((function*(){var t,i;if("paused"!==e.state){if("playing"!==e.state){var n=function(e){if(void 0===e&&(e=document.querySelector("main")),!e)return[];var t=[],i=[];return e.querySelectorAll("h1, h2, h3, h4, h5, h6, p, li, blockquote, figcaption, dt, dd").forEach((e=>{if(!function(e){return Boolean(e.closest("nav, script, style, button, form, input, select, textarea"))||Boolean(e.closest('[aria-hidden="true"]'))||Boolean(e.closest("[hidden]"))}(e)&&!function(e){if(e.hidden||"true"===e.getAttribute("aria-hidden"))return!0;var t=window.getComputedStyle(e);return"none"===t.display||"hidden"===t.visibility}(e)&&!i.some((t=>t.contains(e)))){var n,s,r,a,l=e.textContent,o=l.replace(/\s+/g," ").trim();o&&/[a-z0-9äöüß]/i.test(o)&&(i.push(e),(n=l,s=[],r=n.split(/(?<=[.!?])\s+/),a=0,r.forEach((e=>{if(e){var t=n.indexOf(e,a);-1!==t&&(s.push({text:e,start:t,end:t+e.length}),a=t+e.length)}})),s).forEach((i=>{var n=i.text.replace(/\s+/g," ").trim();n&&t.push({element:e,text:n,start:i.start,end:i.end})})))}})),t}(),s=document.title.split(" - ")[0].trim(),r=null!=(t=null==(i=n[0])?void 0:i.text.toLowerCase())?t:"",a=s&&r.includes(s.toLowerCase()),l=s&&!a?[{text:s,element:null}]:[];e.segments=[...l,...n],e.segments.length&&(e.totalLength=e.segments.reduce(((e,t)=>e+t.text.length),0),e.currentIndex=0,e.voice=yield function(e){return m.apply(this,arguments)}(o()),e.speakFrom(e.currentIndex))}}else e.resume()}))()}speakFrom(e){if(e>=this.segments.length)this.stop();else{var t=this.segments[e],i=new SpeechSynthesisUtterance(t.text);i.lang=o(),this.voice&&(i.voice=this.voice),i.rate=this.rate,i.pitch=1.05;var n=this.speakToken+=1;i.onend=()=>{n===this.speakToken&&"playing"===this.state&&(this.currentIndex+=1,this.emitProgress(),this.speakFrom(this.currentIndex))},this.highlightSegment(t),this.currentUtterance=i,this.setState("playing"),window.speechSynthesis.speak(i),window.speechSynthesis.resume()}}highlightSegment(e){if(e.element){if(l){var t=function(e,t,i){for(var n,s,r,a,l=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),o=l.nextNode(),h=0;o;){var d=h+o.length;if(void 0===n&&t<=d&&(n=o,s=Math.max(0,t-h)),void 0===r&&i<=d&&(r=o,a=Math.max(0,i-h)),void 0!==n&&void 0!==r)break;h=d,o=l.nextNode()}if(!n||!r)return null;var u=document.createRange();return u.setStart(n,s),u.setEnd(r,a),u}(e.element,e.start,e.end);if(t)return void CSS.highlights.set(r,new Highlight(t))}this.lastHighlightedElement&&this.lastHighlightedElement!==e.element&&this.lastHighlightedElement.classList.remove(a),e.element.classList.add(a),this.lastHighlightedElement=e.element}else this.clearHighlight()}clearHighlight(){l&&CSS.highlights.delete(r),this.lastHighlightedElement&&(this.lastHighlightedElement.classList.remove(a),this.lastHighlightedElement=null)}pause(){"playing"===this.state&&(window.speechSynthesis.pause(),this.setState("paused"),this.keepAliveTimer=window.setInterval((()=>{window.speechSynthesis.pause()}),1e4))}resume(){"paused"===this.state&&(window.clearInterval(this.keepAliveTimer),this.keepAliveTimer=null,window.speechSynthesis.resume(),this.setState("playing"),window.setTimeout((()=>{"playing"!==this.state||window.speechSynthesis.speaking||this.speakFrom(this.currentIndex)}),250))}stop(){window.clearInterval(this.keepAliveTimer),this.keepAliveTimer=null,window.speechSynthesis.cancel(),this.currentIndex=0,this.clearHighlight(),this.setState("idle")}getRate(){return this.rate}setRate(e){var t=d(e);if(t===this.rate)return t;this.rate=t;try{window.localStorage.setItem(h,String(t))}catch(e){}return this.dispatchEvent(new CustomEvent("ratechange",{detail:{rate:t}})),"playing"===this.state&&(window.speechSynthesis.cancel(),this.speakFrom(this.currentIndex)),t}}var w={MIN:.5,MAX:1.5,STEP:.25,DEFAULT:1},f=null;function y(){return f||(f=new v),f}function S(){return"speechSynthesis"in window&&void 0!==window.SpeechSynthesisUtterance}},8575:(e,t,i)=>{i.r(t),i.d(t,{default:()=>a}),i(9698),i(7593);var n=i(2858),s=i.n(n),r=i(1224);const a=class{constructor(e){(0,r.YQ)()?(this.element=e,this.engine=(0,r.ec)(),this.statusElement=e.querySelector('[data-role="status"]'),this.trackElement=e.querySelector('[data-role="progress-track"]'),this.fillElement=e.querySelector('[data-role="progress-fill"]'),this.speedValueElement=e.querySelector('[data-role="speed-value"]'),this.speedDownButton=e.querySelector('[data-role="speed-down"]'),this.speedUpButton=e.querySelector('[data-role="speed-up"]'),this.engine.addEventListener("statechange",(e=>this.handleStateChange(e))),this.engine.addEventListener("progress",(e=>this.handleProgress(e))),this.engine.addEventListener("ratechange",(e=>this.renderRate(e.detail.rate))),this.bindSpeedControls(),this.renderRate(this.engine.getRate()),this.positionRelativeToNav(),window.addEventListener("resize",s()((()=>this.positionRelativeToNav()),200))):e.remove()}positionRelativeToNav(){var e=document.querySelector(".header");if(e){var t=e.querySelector(".navigation__main-links"),i=e.querySelector(".navigation__meta-links"),n=null==t?void 0:t.getBoundingClientRect();if(n&&n.width>0&&"none"!==window.getComputedStyle(t).display){var s=0;
1[t,i].forEach((e=>{e&&(s=Math.max(s,e.getBoundingClientRect().bottom))}));var r=this.leftEdgeClearOfLogo(e,n,s);return this.element.style.position="absolute",this.element.style.marginTop="",this.element.style.marginLeft="",this.element.style.paddingLeft="",this.element.style.top=Math.max(0,Math.round(s+window.scrollY))+"px",this.element.style.left=Math.round(r+window.scrollX)+"px",void(this.element.style.width=Math.round(n.right-r)+"px")}return this.resetInlinePosition(),void this.padContentClearOfLogo(e)}var a=document.querySelector(".site-header");a&&this.alignToReference(a.querySelector(".primary-nav"))}resetInlinePosition(){["position","top","left","marginTop","marginLeft","width","paddingLeft"].forEach((e=>{this.element.style[e]=""}))}leftEdgeClearOfLogo(e,t,i){var n,s=null==(n=e.querySelector(".header__home"))?void 0:n.getBoundingClientRect();if(!s||0===s.width)return t.left;if(s.bottom<=i+1||s.right<=t.left)return t.left;var r=t.left+t.width/2;return Math.min(s.right+12,r)}padContentClearOfLogo(e){var t,i=null==(t=e.querySelector(".header__home"))?void 0:t.getBoundingClientRect(),n=this.element.getBoundingClientRect();if(i&&0!==i.width&&0!==n.width){var s=i.bottom>n.top&&i.top<n.bottom,r=Math.round(i.right-n.left);!s||r<=0||(this.element.style.paddingLeft=Math.min(r+8,Math.round(n.width/2))+"px")}}alignToReference(e){var t=null==e?void 0:e.getBoundingClientRect(),i=t&&t.width>0&&"none"!==window.getComputedStyle(e).display;this.element.style.marginLeft=i?Math.round(t.left)+"px":"",this.element.style.width=i?Math.round(t.width)+"px":""}bindSpeedControls(){this.speedDownButton&&this.speedDownButton.addEventListener("click",(()=>{this.engine.setRate(this.engine.getRate()-r.oz.STEP)})),this.speedUpButton&&this.speedUpButton.addEventListener("click",(()=>{this.engine.setRate(this.engine.getRate()+r.oz.STEP)}))}renderRate(e){this.speedValueElement&&(this.speedValueElement.textContent=function(e){return parseFloat(e.toFixed(2))+"×"}(e)),this.speedDownButton&&(this.speedDownButton.disabled=e<=r.oz.MIN),this.speedUpButton&&(this.speedUpButton.disabled=e>=r.oz.MAX)}handleStateChange(e){var{state:t}=e.detail;this.element.hidden="idle"===t,"idle"!==t?(this.positionRelativeToNav(),this.statusElement.textContent="playing"===t?this.statusElement.dataset.labelPlaying:this.statusElement.dataset.labelPaused):this.handleProgress({detail:{progress:0}})}handleProgress(e){var{progress:t}=e.detail;this.fillElement.style.width=t+"%",this.trackElement.setAttribute("aria-valuenow",String(t))}}}}]);
2//# sourceMappingURL=4f26473129a83c883701.read-aloud-player.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.