1import q from"woody_library_woody_controller";class P extends q{#t={headerIconPicto:".podcast-wicon",headerIconImg:".podcast-icon-img",headerPretitle:".podcast-pretitle",headerTitle:".podcast-title",headerSubtitle:".podcast-subtitle",headerDescription:".podcast-description",audio:".podcast-audio-source",audioSource:".podcast-audio-source source",audioName:'[itemprop="name"]',playToggle:".podcast-play-toggle",currentTime:".podcast-time-current",totalTime:".podcast-time-total",progressRange:".podcast-progress-range",volumeToggle:".podcast-volume-toggle",volumeRange:".podcast-volume-range",seekBack:".podcast-back-seconds",seekForward:".podcast-forward-seconds",skipBack:".podcast-skip-back",skipForward:".podcast-skip-forward",transcriptionButton:".podcast-transcription-button",transcription:".podcast-transcription",transcriptionLine:".podcast-transcription-line",playlistToggle:".podcast-playlist-toggle",playlistList:".podcast-playlist-list",track:".podcast-track"};constructor(t){super(t)}init(t){super.init(t),this.config=Object.assign(this.#t,this.config);const e=this.el.querySelector(this.config.audio);if(!e)return;const{updateProgress:i,stopProgressLoop:s}=this.initPlayer(e),{bindTranscriptionTrack:o}=this.initTranscription(e),{collapse:r,setDefaultLabel:d}=this.initTranscriptionToggle();this.initPlaylistToggle(),this.initPlaylist(e,i,s,o,r,d)}formatTime(t){if(!isFinite(t)||t<0)return"00:00";const e=Math.floor(t/60),i=Math.floor(t%60),s=String(e).padStart(2,"0"),o=String(i).padStart(2,"0");return`${s}:${o}`}initPlayer(t){const{updateProgress:e,stopProgressLoop:i}=this.initProgress(t);return this.initPlayToggle(t),this.initSeek(t,e),this.initSeekButtons(t,e),this.initVolume(t),{updateProgress:e,stopProgressLoop:i}}initProgress(t){const e=this.el.querySelector(this.config.currentTime),i=this.el.querySelector(this.config.totalTime),s=this.el.querySelector(this.config.progressRange),o=u=>{if(!t.duration)return;const y=Math.min(u/t.duration,1);if(s){const T=y*100;s.value=String(T),s.style.setProperty("--progress-percent",`${T}%`),s.setAttribute("aria-valuetext",`${this.formatTime(u)} sur ${this.formatTime(t.duration)}`)}e&&(e.textContent=this.formatTime(u))};let r,d;const h=()=>{r=t.currentTime,d=performance.now()};h();const n=()=>{h(),o(r)};let a=null;const l=()=>{a!==null&&(cancelAnimationFrame(a),a=null)},f=()=>{const u=(performance.now()-d)/1e3;o(r+u*t.playbackRate),a=requestAnimationFrame(f)},m=()=>{i&&(i.textContent=this.formatTime(t.duration))};return t.readyState>=1?m():t.addEventListener("loadedmetadata",m),t.addEventListener("timeupdate",n),t.addEventListener("play",()=>{this.getCurrentTrackButton?.()?.classList.add("is-playing"),h(),f()}),t.addEventListener("pause",()=>{this.getCurrentTrackButton?.()?.classList.remove("is-playing"),l()}),t.addEventListener("ended",()=>{this.getCurrentTrackButton?.()?.classList.remove("is-playing"),l()}),{updateProgress:n,stopProgressLoop:l}}initPlayToggle(t){const e=this.el.querySelector(this.config.playToggle);e&&(t.addEventListener("play",()=>{e.setAttribute("aria-label","Pause")}),t.addEventListener("pause",()=>{e.setAttribute("aria-label","Lecture")}),e.addEventListener("click",()=>{t.paused?t.play():t.pause()}))}initSeek(t,e){const i=this.el.querySelector(this.config.progressRange);i?.addEventListener("input",()=>{if(!t.duration)return;const s=Number(i.value)/100;t.currentTime=s*t.duration,e()})}initSeekButtons(t,e){const i=this.el.querySelector(this.config.seekBack),s=this.el.querySelector(this.config.seekForward),o=15,r=30;i?.addEventListener("click",()=>{t.duration&&(t.currentTime=Math.max(t.currentTime-o,0),e())}),s?.addEventListener("click",()=>{t.duration&&(t.currentTime=Math.min(t.currentTime+r,t.duration),e())})}initVolume(t){const e=this.el.querySelector(this.config.volumeToggle),i=this.el.querySelector(this.config.volumeRange),s=()=>{const o=t.muted||t.volume===0;if(e&&e.setAttribute("aria-label",o?"Activer le son":"Couper le son"),i){const r=Math.round((t.muted?0:t.volume)*100);i.value=String(r),i.style.setProperty("--volume-percent",`${r}%`)}};t.addEventListener("volumechange",s),s(),e?.addEventListener("click",()=>{t.muted=!t.muted}),i?.addEventListener("input",()=>{const o=Number(i.value)/100;t.volume=o,t.muted=o===0})}initTranscription(t){const e=this.el.querySelector("track"),i=this.el.querySelector(this.config.transcription),s=this.el.querySelector(this.config.transcriptionButton);if(!e||!i)return{bindTranscriptionTrack:()=>{}};const o=()=>{const n=t.textTracks?.[0];!n||i.dataset.built||!n.cues||n.cues.length===0||(i.dataset.built="1",Array.from(n.cues).forEac
1h(a=>{const l=document.createElement("button");l.type="button",l.className="podcast-transcription-line",l.textContent=a.text,l.dataset.start=String(a.startTime),l.addEventListener("click",()=>{t.currentTime=a.startTime,t.play()}),a.woodyLine=l,i.appendChild(l)}))},r=()=>{const n=t.textTracks?.[0];n&&(i.querySelectorAll(this.config.transcriptionLine).forEach(a=>{a.classList.remove("active")}),Array.from(n.activeCues||[]).forEach(a=>{const l=a.woodyLine;l&&(l.classList.add("active"),l.scrollIntoView({block:"nearest",behavior:"smooth"}))}))};e.readyState===2?o():e.addEventListener("load",o);const d=()=>{const n=t.textTracks?.[0];n&&(n.mode="hidden",n.removeEventListener("cuechange",r),n.addEventListener("cuechange",r))};return d(),{bindTranscriptionTrack:n=>{i.innerHTML="",delete i.dataset.built;const a=n.hasTranscription==="1";if(s&&(s.hidden=!a),!a){e.src="";return}if(n.transcriptionMode==="manual"){i.innerHTML=n.transcriptionText||"",e.src="";return}e.src=n.transcriptSrc||"",d()}}}initTranscriptionToggle(){const t=this.el.querySelector(this.config.transcriptionButton),e=this.el.querySelector(this.config.transcription);if(!t||!e)return{collapse:()=>{},setDefaultLabel:()=>{}};let i=t.textContent;const s=()=>{t.setAttribute("aria-expanded","false"),t.textContent=i,e.hidden=!0},o=r=>{i=r};return t.addEventListener("click",()=>{let r;t.getAttribute("aria-expanded")==="true"?r=!0:r=!1,t.setAttribute("aria-expanded",String(!r)),t.textContent=r?i:"Masquer la transcription",e.hidden=r}),{collapse:s,setDefaultLabel:o}}initPlaylistToggle(){const t=this.el.querySelector(this.config.playlistToggle),e=this.el.querySelector(this.config.playlistList);!t||!e||t.addEventListener("click",()=>{const i=t.getAttribute("aria-expanded")==="true";t.setAttribute("aria-expanded",String(!i)),e.hidden=i})}initPlaylist(t,e,i,s,o,r){const d=Array.from(this.el.querySelectorAll(this.config.track)),h=this.el.querySelector(this.config.skipBack),n=this.el.querySelector(this.config.skipForward);if(d.length===0){h?.addEventListener("click",()=>{t.currentTime=0,e()}),n&&(n.disabled=!0);return}const a=this.el.querySelector(this.config.headerPretitle),l=this.el.querySelector(this.config.headerTitle),f=this.el.querySelector(this.config.headerSubtitle),m=this.el.querySelector(this.config.headerDescription),u=this.el.querySelector(this.config.headerIconPicto),y=this.el.querySelector(this.config.headerIconImg),T=this.el.querySelector(this.config.audioSource),v=this.el.querySelector(this.config.audioName);let p=d.findIndex(g=>g.classList.contains("is-current"));p===-1&&(p=0),this.getCurrentTrackButton=()=>d[p];const L=()=>{n&&(n.disabled=p===d.length-1)},S=(g,{autoplay:k})=>{const c=d[g];c&&(t.pause(),i(),a&&(a.textContent=c.dataset.pretitle,a.hidden=!c.dataset.pretitle),l&&(l.textContent=c.dataset.title),f&&(f.textContent=c.dataset.subtitle,f.hidden=!c.dataset.subtitle),m&&(m.innerHTML=c.dataset.description,m.hidden=!c.dataset.description),u&&(u.hidden=c.dataset.iconType!=="picto",u.className=`podcast-wicon wicon wicon-woody-icons ${c.dataset.iconPicto}`),y&&(y.hidden=c.dataset.iconType!=="img",y.src=c.dataset.iconImgSrc,y.alt=c.dataset.iconImgAlt),T&&(T.src=c.dataset.audioSrc,T.type=c.dataset.audioMime),v&&(v.textContent=c.dataset.audioFilename),t.load(),e(),s(c.dataset),r(c.dataset.transcriptionButtonLabel),o(),d.forEach(b=>{b.classList.remove("is-current","is-playing")}),c.classList.add("is-current"),p=g,L(),k&&t.play())};d.forEach((g,k)=>{g.addEventListener("click",()=>{if(k===p){t.paused?t.play():t.pause();return}S(k,{autoplay:!0})})}),h?.addEventListener("click",()=>{if(p>0){S(p-1,{autoplay:!0});return}t.currentTime=0,e()}),n?.addEventListener("click",()=>{S(p+1,{autoplay:!0})}),L()}}export{P as default};
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.