-
Notifications
You must be signed in to change notification settings - Fork 2
/
cpu-audio.js
74 lines (72 loc) · 48.7 KB
/
cpu-audio.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
(function(){/*
Cpu-Audio: an extension to the hash system to address timecode into audio/video elements.
Version 6.5.1
Copyright (C) 2014-2021 Xavier "dascritch" Mouton-Dubosc & contributors.
License GNU GPL 3
- project mini-site https://dascritch.github.io/cpu-audio/
- project repository : https://github.com/dascritch/cpu-audio
- use case : http://cpu.pm
- blog post : https://dascritch.net/post/2018/11/06/Reconstruire-son-lecteur-audio-pour-le-web
*/
'use strict';let e,h;const k=(document._currentScript||document.currentScript).ownerDocument,l="poster actions timeline chapters panels panels-title panels-except-play".split(" "),m=/^[a-zA-Z0-9\-_]+$/,n=/^([a-zA-Z0-9\-_]+_\u00ab)([a-zA-Z0-9\-_]+)((\u00bb_.*_\u00ab)([a-zA-Z0-9\-_]+))?(\u00bb)$/,p={passive:!0};const r={fr:{loading:"Chargement en cours\u2026",pause:"Pause",play:"Lecture",canonical:"Lien vers la fiche du sonore",moment:"Lien vers ce moment",untitled:"(sans titre)",cover:"pochette",more:"Actions",share:"Partager",twitter:"Partager sur Twitter",facebook:"Partager sur Facebook",e_mail:"Partager par e-mail",download:"T\u00e9l\u00e9charger",back:"Annuler",chapters:"Chapitres",playlist:"Playlist",media_err_aborted:"Vous avez annul\u00e9 la lecture.",media_err_network:"Une erreur r\u00e9seau a caus\u00e9 l'interruption du t\u00e9l\u00e9chargement.",
media_err_decode:"La lecture du sonore a \u00e9t\u00e9 annul\u00e9e suite \u00e0 des probl\u00e8mes de corruption ou de fonctionnalit\u00e9s non support\u00e9s par votre navigateur.",media_err_src_not_supported:"Le sonore n'a pu \u00eatre charg\u00e9, soit \u00e0 cause de sourcis sur le serveur, le r\u00e9seau ou parce que le format n'est pas support\u00e9.",media_err_unknow:"Erreur due \u00e0 une raison inconnue."},en:{loading:"Loading\u2026",pause:"Pause",play:"Play",canonical:"Link to the sound's page",
moment:"Link to this time",untitled:"(untitled)",cover:"cover",more:"Actions",share:"Share",twitter:"Share on Twitter",facebook:"Share on Facebook",e_mail:"Share via e-mail",download:"Download",back:"Back",chapters:"Chapters",playlist:"Playlist",media_err_aborted:"You have aborted the play.",media_err_network:"A network error broke the download.",media_err_decode:"Play was canceled due to file corruption or a not supported function in your browser.",media_err_src_not_supported:"The media cannot be downloaded due to server problems, network problems or unsupported by your browser.",
media_err_unknow:"Error of unknown cause."}};let t=document.querySelector("html").lang;if(!(t.length&&t.toLowerCase()in r)){t="en";let a=window.navigator.languages;a=void 0!==a?a:[navigator.language||navigator.browserLanguage];for(let b of a)if(b.split){let a=b.split("-")[0];a in r&&(t=a)}}const u=r[t];function v(){var a=document.createElement("style");a.innerHTML=' audio[controls] { display : block; width : 100%; } :root { --cpu-height : 64px; --cpu-font-family : Lato, "Open Sans", "Segoe UI", Frutiger, "Frutiger Linotype", "Dejavu Sans", "Helvetica Neue", Arial, sans-serif; --cpu-font-size : 15px; --cpu-font-small-size : calc(var(--cpu-font-size) * 0.8); --cpu-background : #555; --cpu-color : #ddd; --cpu-playing-background : #444; --cpu-playing-color : #fff; --cpu-error-background : #a00 ; --cpu-error-color : #ff7 ; --cpu-popup-background : #aaa; --cpu-popup-color : #333; --cpu-elapse-width : 160px; --cpu-min-padding : 16px; --cpu-inner-shadow : inset 0px 5px 10px -5px black; --cpu-color-transitions : 0s; --cpu-background-transitions : 0s; --cpu-unfold : 0s; } @media (max-width: 640px) { :root , .interface { --cpu-font-size : 13px; --cpu-height : 48px; --cpu-elapse-width : 140px; --cpu-min-padding : 4px; } @media (max-width: 480px) { :root , .interface { --cpu-elapse-width : 70px; } }';
document.head.appendChild(a);a=document.createElement("template");a.id="CPU__template";a.innerHTML=`<style>:host { all: initial; display: block; contain: content; } .act-play { --cpu-background : var(--cpu-playing-background); --cpu-color : var(--cpu-playing-color); } .show-error { --cpu-background : var(--cpu-error-background); --cpu-color : var(--cpu-error-color); } #interface { --cpu-timeline-height : 10px; background : var(--cpu-background); color : var(--cpu-color); } #interface, * { font-family : var(--cpu-font-family); font-size : var(--cpu-font-size); font-weight: normal; font-style: normal; line-height : 1.2; border : none; padding : 0; margin : 0; text-indent: 0; list-style-type: none; user-select: none; transition : color var(--cpu-color-transitions), background-color var(--cpu-background-transitions), opacity var(--cpu-background-transitions); } .show-no main { visibility : hidden; } main { display : flex; overflow : hidden; height : var(--cpu-height); } a, button { color : currentColor; border : none; text-decoration : none; } button { background : transparent; } svg { fill : currentColor; width : var(--cpu-height); height : var(--cpu-height); } i, em { font-style: italic; } b, strong, h5 a { font-weight: bold; } [src=''] { visibility: hidden; } #pageerror { padding: 0px 4px; align-self: center; } #control, #actions { flex : 0 0 var(--cpu-height); width : var(--cpu-height); max-height : var(--cpu-height); height : 100%; text-align : center; vertical-align : middle; } a { cursor : pointer; } #loading, #play, #pause, .show-main #pageshare, .show-main #pageerror, .show-share #pagemain, .show-share #pageerror, .show-error #pagemain, .show-error #pageshare , .show-error #poster, #handheld-nav , .show-handheld-nav #titleline { display : none; } .act-loading #loading, .act-play #play, .act-glow #pause, .act-pause #pause { display : block; } .act-glow #pause { animation : glow 2s infinite; } @keyframes glow { 0% {opacity : 0.5;} 50% {opacity : 1;} 100% {opacity : 0.5;} } .show-share #pageshare, .show-main #pagemain { flex : 1 1 100%; display : flex; align-items: center; } .act-loading #loading circle { fill : #777; opacity : 1; animation: pulse 2s infinite; } #loading circle:nth-child(2) { animation-delay:0.5s; } #loading circle:nth-child(3) { animation-delay:1s; } @keyframes pulse { 50% {opacity : 0;} } #poster { max-width : var(--cpu-height); min-width : var(--cpu-height); max-height : var(--cpu-height); min-height : var(--cpu-height); object-fit: contain; opacity : 0; } .poster-loaded #poster { opacity: 1; } .hide-poster #poster { display : none; } #control svg, #actions svg { vertical-align : middle; max-width : 100%; max-height : 100%; } #titleline { display : flex; align-items: center; } #about, #title { flex : 1 1 auto; position : relative; } #title { overflow: hidden; text-overflow : '\u2026'; } #title a { display : block; max-height: calc(6px + calc(2 * var(--cpu-font-size))); } #canonical.untitled { font-style : italic; } #elapse { flex : 0 1 var(--cpu-elapse-width); text-align : right; } .mode-compact #elapse { flex : 0 0 calc(var(--cpu-elapse-width) + 32px); text-align : center; } #time { background-color : black; background-repeat: no-repeat; background-size: 100% 100%; width : 100%; height : var(--cpu-timeline-height); display : block; position : relative; cursor:none; } #loadingline { background : currentColor; height : var(--cpu-timeline-height); display : block ; position : absolute; left : 0; pointer-events : none; } #loadingline:after { content : ''; position: absolute; right : 0px; width : 0px; height : var(--cpu-timeline-height); display : block; outline : var(--cpu-color) 4px solid; z-index : 127; opacity : 0; } main:hover #loadingline:after, main:focus #loadingline:after { opacity : 1; } aside { position : absolute; width : 100%; } aside a { position : absolute; display : block; } aside a span { display : none; } aside.chapters { height : 2px; bottom : -2px; } aside.chapters a { background : black; height : 2px; border : 1px solid var(--cpu-background); } aside.chapters a.active-cue { background : var(--cpu-color); } aside.borders { pointer-events : none; height : var(--cpu-timeline-height); z-index : 4; top : calc( var(--cpu-timeline-height) + 6px); } aside.borders a { height : var(--cpu-timeline-height); background: transparent; } aside.borders a:before, aside.borders a:after { pointer-events : none; content:""; position : absolute; width : 2px; height : var(--cpu-timeline-height); border : 2px solid red; } aside.borders a:before { border-right-width: 0px; left : 0%; } aside.borders a:after { border-left-width: 0px; left : 100%; } aside.ticker { height : 16px; top : 30px; } aside.ticker a.active-cue { left : 0px !important; right : 0px !important; background : inherit !important; color : inherit !important; } aside.ticker a.active-cue span { display : inline-block; } .act-loading #loadingline { background : repeating-linear-gradient(45deg, var(--cpu-color) 0, var(--cpu-background) 15px, var(--cpu-color) 30px); background-size: 200% 200%; animation: loadingline 1s linear infinite; } @keyframes loadingline { 0% { background-position-y : var(--cpu-timeline-height); } } #handheld-nav { max-height: calc(6px + calc(2 * var(--cpu-font-size))); padding-bottom: 8px; } .show-handheld-nav #handheld-nav { display : flex; } #handheld-nav * { flex : 1 0 auto; height : calc(2 * var(--cpu-font-size)); } [type="time"] { text-align : center; } .hide-actions #actions { visibility : hidden; pointer-events: none; min-width : var(--cpu-min-padding); max-width : var(--cpu-min-padding); } #pageshare { text-align : center; } #pageshare a { display: flex; align-items: center; justify-content: center; height : var(--cpu-height); } #pageshare a, #pageshare div { flex : 1 0; color : white; text-decoration : none; overflow : hidden; text-overflow : clip; } #pageshare svg { vertical-align : middle; width : 32px; height : 32px; } #pageshare #nativeshare { display : none; } .hasnativeshare #pageshare #nativeshare { display : flex; } .hasnativeshare #pageshare .nonativeshare { display : none; } #twitter { background : #4DB5F4 } #facebook, #nativeshare { background : #5974CC } #email { background : #CC0000 } #link { background : #77F } #popup { pointer-events : none; position: absolute; transform: translate(-25px, -19px); z-index : 127; min-width : 50px; font-size : 11px; text-align : center; padding : 2px; border-radius: 4px; box-shadow: black 2px 2px; background : var(--cpu-popup-background); color : var(--cpu-popup-color); opacity : 0; } #popup:before { pointer-events : none; content:""; position: absolute; z-index : 127; left: 20px; bottom: -8px; width: 0; height : 0; border-top: 8px solid var(--cpu-popup-background); border-left: 4px solid transparent; border-right: 4px solid transparent; } .panel { display : flex; list-style: none; flex-direction: column; padding : 0 var(--cpu-min-padding); box-shadow: var(--cpu-inner-shadow); } h6 { text-align : center; } .cue { border-top : 1px solid black; display : flex; margin : 0px; padding : 2px } .cue strong { flex : 1 1; font-weight : normal; } .cue time { flex : 0 0 var(--cpu-elapse-width) 0px; text-align : right; } aside a, h6, .cue time { font-size : var(--cpu-font-small-size); } .mode-compact { width : calc(var(--cpu-elapse-width) + var(--cpu-height) * 2 + 32px); } .mode-button { width : var(--cpu-height); } .mode-compact #title, .mode-compact #line, .mode-compact #actions, .mode-compact aside, .mode-compact .panel, .mode-button #poster, .mode-button #about, .mode-button #actions, .mode-button aside, .mode-button .panel { width : 0; display : none; } .mode-hidden, .hide-chapters .chapters, .hide-timeline #line, .hide-panels .panel, .hide-panels-title h6, .hide-panels-except-play .panel, .media-streamed #link, .media-streamed #line { display : none; } .hide-panels-except-play.last-used .panel { display : flex; } .mode-compact.show-main #pagemain { flex : 0 0 auto; } @media (max-width: 640px) { .nosmall { display : none !important; } #elapse { max-height : 16px; } #interface { --cpu-timeline-height : 8px ; } #handheld-nav { padding-bottom: 4px; } aside.ticker { top: 22px; } } @media (max-width: 480px) { .nosmaller { display : none !important; } .mode-default #elapse { flex : 0 1 var(--cpu-elapse-width); } .mode-default #pagemain { padding-bottom : 16px; } #titleline { height : 32px; } #line { position: absolute; left: calc(0px - var(--cpu-height)); right: calc(0px - var(--cpu-height)); height: 16px; top: 32px; } aside a { pointer-events: none; } aside.borders { top : -2px; } aside.chapters { top : 8px; } #handheld-nav { padding-bottom: 2px; } } @media (max-width: 320px) { .nosmallest, .mode-default #elapse { display : none !important; } } @media print { #interface { display : none; } } a:hover, a:focus, button:hover, button:focus, #pageshare div:hover , .active-cue, .with-preview { background: var(--cpu-focus-background, var(--cpu-color)) !important; color : var(--cpu-focus-color, var(--cpu-background)) !important; }</style><div id="interface" class="show-no" tabindex="0"> <main> <img id="poster" class="nosmall" src="" alt="" loading="lazy" decoding="async" /> <section id="pageerror" role="alert"> </section> <section id="pagemain"> <a id="control" tabindex="0"> <svg id="loading" aria-label="${u.loading}" viewBox="0 0 32 32" aria-hidden="true"> <circle cx="6" cy="22" r="4" /> <circle cx="16" cy="22" r="4" /> <circle cx="26" cy="22" r="4" /> <title>${u.loading}</title> </svg> <svg id="play" aria-label="${u.pause}" viewBox="0 0 32 32" aria-hidden="true"> <title>${u.pause}</title> <path d="M 6,6 12.667,6 12.667,26 6,26 z" /> <path d="M 19.333,6 26,6 26,26 19.333,26 z" /> </svg> <svg id="pause" aria-label="${u.play}" viewBox="0 0 32 32" aria-hidden="true"> <title>${u.play}</title> <path d="M 6,6 6,26 26,16 z" /> </svg> </a> <div id="about"> <div id="titleline"> <h5 id="title"><a href="#" id="canonical" aria-label="${u.canonical}"></a></h5> <a id="elapse" aria-label="${u.moment}" tabindex="-1">\u2026</a> </div> <div id="handheld-nav"> <button type="button" id="restart"> <svg viewBox="0 0 24 16" aria-hidden="true"> <polygon points="4,0 8,0 8,16 4,16"/> <path d="M 16,0 8,8 16,16 z" /> <path d="M 24,0 16,8 24,16 z" /> </svg> </button> <button type="button" id="fastreward"> <svg viewBox="0 0 24 16" aria-hidden="true"> <path d="M 8,0 0,8 8,16 z" /> <path d="M 16,0 8,8 16,16 z" /> <path d="M 24,0 16,8 24,16 z" /> </svg> </button> <button type="button" id="reward" class="nosmallest"> <svg viewBox="0 0 24 16" aria-hidden="true"> <path d="M 12,0 4,8 12,16 z" /> <path d="M 20,0 12,8 20,16 z" /> </svg> </button> <button type="button" id="foward"> <svg viewBox="0 0 24 16" aria-hidden="true"> <path d="M 4,0 12,8 4,16 z" /> <path d="M 12,0 20,8 12,16 z" /> </svg> </button> <button type="button" id="fastfoward"> <svg viewBox="0 0 24 16" aria-hidden="true"> <path d="M 0,0 8,8 0,16 z" /> <path d="M 8,0 16,8 8,16 z" /> <path d="M 16,0 24,8 16,16 z" /> </svg> </button> </div> <div id="line"> <div id="time"> <div id="loadingline" role="progressbar"></div> <time id="popup">--:--</time> </div> </div> </div> <a id="actions" aria-label="${u.more}" title="${u.more}"> <svg viewBox="0 0 32 32" aria-hidden="true"> <circle cx="7" cy="16" r="3" /> <circle cx="16" cy="16" r="3" /> <circle cx="25" cy="16" r="3" /> </svg> </a> </section> <section id="pageshare"> <a href="#" target="social" id="nativeshare" aria-label="${u.share}" title="${u.share}"> <svg viewBox="0 0 32 32" aria-hidden="true"> <path d="M 21 0 C 18.2 0 16 2.2 16 5 C 16 5.1 16 5.2 16.0 5.2 L 8.2 9.2 C 7.3 8.4 6.2 8 5 8 C 2.2 8 0 10.2 0 13 C 0 15.8 2.2 18 5 18 C 6.2 18 7.3 17.5 8.2 16.8 L 16 20.8 C 16.0 20.8 16 20.9 16 21 C 16 23.8 18.2 26 21 26 C 23.8 26 26 23.8 26 21 C 26 18.2 23.8 16 21 16 C 19.8 16 18.7 16.4 17.8 17.2 L 10 13.3 C 10 13.2 10 13.1 10 13 C 10 12.9 10 12.8 10 12.8 L 17.8 8.8 C 18.7 9.6 19.8 10 21 10 C 23.8 10 26 7.8 26 5 C 26 2.2 23.8 0 21 0 Z"></path> </svg> <span class="nosmall">${u.share}</span> </a> <a href="#" target="social" id="twitter" class="nonativeshare" aria-label="${u.twitter}" title="${u.twitter}"> <svg viewBox="0 0 32 32" aria-hidden="true"> <path d="M 25.9,9.9 C 25.2,10.2 24.4,10.4 23.6,10.5 24.5,10 25.1,9.2 25.4,8.2 24.6,8.8 23.8,9.1 22.9,9.3 22.1,8.5 21.1,8 19.9,8 c -2.2,0 -4,1.8 -4,4 0,0 0,0.6 0.1,0.9 -3.3,-0.2 -6.3,-1.8 -8.3,-4.2 -0.3,0.6 -0.5,1.3 -0.5,2 0,1.4 0.7,2.6 1.8,3.4 -0.7,0 -1.3,-0.2 -1.8,-0.5 0,0 0,0 0,0.1 0,2 1.4,3.6 3.2,4 -0.3,0.1 -0.7,0.1 -1.1,0.1 -0.3,0 -0.5,0 -0.8,-0.1 0.5,1.6 2,2.8 3.7,2.8 -1.4,1.1 -3.1,1.7 -5,1.7 -0.3,0 -0.6,0 -1,-0.1 1.8,1.1 3.9,1.8 6.1,1.8 7.4,0 11.4,-6.1 11.4,-11.4 0,-0.2 0,-0.3 0,-0.5 0.8,-0.6 1.4,-1.3 2,-2.1 z" /> </svg> <span class="nosmall">${u.twitter}</span> </a> <a href="#" target="social" id="facebook" class="nonativeshare" aria-label="${u.facebook}" title="${u.facebook}"> <svg viewBox="0 0 32 32" aria-hidden="true"> <path d="m 21.1,16 -3.7,0 0,10 -4.3,0 0,-10 -2.1,0 0,-3.3 2.1,0 0,-2.1 c 0,-2.9 1.2,-4.6 4.7,-4.6 l 3.9,0 0,3.5 -3.2,0 c -1,0 -1.1,0.5 -1.1,1.4 l -0,1.8 4.3,0 -0.6,3.3 0,0 z" /> </svg> <span class="nosmall">${u.facebook}</span> </a> <a href="#" target="social" id="email" class="nonativeshare" aria-label="${u.e_mail}" title="${u.e_mail}"> <svg viewBox="0 0 32 32" aria-hidden="true"> <path d="m 8,9 15.9,0 c 0.3,0 0.6,0.1 0.8,0.2 l -8.8,9 -8.8,-9 c 0.3,-0.1 0.5,-0.2 0.8,-0.2 z m -2,12.3 0,-10.5 c 0,0 0,-0.1 0,-0.1 l 5.8,6 -5.8,5.1 c 0,-0.1 -0.1,-0.3 -0.1,-0.4 z m 17.9,1.8 -15.9,0 c -0.2,0 -0.3,0 -0.5,-0.1 l 5.7,-5 2.8,2.9 2.8,-2.9 5.7,5 c -0.2,0 -0.3,0.1 -0.5,0.1 z m 2,-1.8 c 0,0.2 0,0.3 -0.1,0.5 l -5.8,-5.1 5.8,-6 c 0,0 0,0.1 0,0.1 z" /> </svg> <span class="nosmall">${u.e_mail}</span> </a> <a href="#" target="social" download="" id="link" aria-label="${u.download}" title="${u.download}"> <svg viewBox="0 0 32 32" aria-hidden="true"> <path d="M 6,6 26,6 16,26 z" /> <rect x="6" y="22" width="20" height="4" /> </svg> <span class="nosmall">${u.download}</span> </a> <a id="back" aria-label="${u.back}" title="${u.back}"> <svg viewBox="0 0 32 32" aria-hidden="true"> <path d="M 9,8 24,23 23,24 8,9 z" /> <path d="M 9,24 24,9 23,8 8,23 z" /> </svg> <span class="nosmall">${u.back}</span> </a> </section> </main> <nav id="playlist" class="panel"> </nav> </div> `;
document.head.appendChild(a)}null!==document.head?v():document.addEventListener("DOMContentLoaded",v,!1);function w(a){"function"===typeof a&&a()}function x(a,b,c=void 0){c=void 0===c?document:c;Array.from(c.querySelectorAll(a)).forEach(b)}function y(a){let b=document.createElement("a");b.href="string"!==typeof a?a:a.split("#")[0];return b.href}function z(a){y(window.location.href)===y(a.target.href)&&a.preventDefault()}function A(a){a.addEventListener("click",z)}function B(a){let b=document.createElement("span");b.innerText=a;a=b.innerHTML;b.remove();return a}
function C(a){window.console.warn("CPU-AUDIO: ",a)};const D={units:{d:86400,h:3600,m:60,s:1},_is_only_numeric:/^\d+$/,_any_not_numeric:/\D*/g,Infinity:"?",TimeInSeconds:function(a){let b=0;""!==a&&(b=D._is_only_numeric.test(a)?Number(a):-1===a.indexOf(":")?D.SubunitTimeInSeconds(a):D.ColonTimeInSeconds(a));return b},SubunitTimeInSeconds:function(a){let b=0;for(let c in D.units)D.units.hasOwnProperty(c)&&-1!==a.indexOf(c)&&(a=a.split(c),b+=Number(a[0].replace(D._any_not_numeric,""))*D.units[c],a=a[1]);return b},ColonTimeInSeconds:function(a){let b=
0;a=a.split(":");let c=[1,60,3600,86400];for(let d=0;d<a.length;d++)b+=Number(a[d])*c[a.length-1-d];return b},SecondsInTime:function(a){if(Infinity==a)return D.Infinity;let b="",c=!1;for(let d in D.units)if(D.units.hasOwnProperty(d)){let f=D.units[d];if(a>=f||c){c=!0;let g=Math.floor(a/f);b+=g+d;a-=g*f}}return""===b?"0s":b},SecondsInColonTime:function(a){if(Infinity==a)return D.Infinity;let b="",c=!1;for(let d in D.units)if(D.units.hasOwnProperty(d)){let f=D.units[d];if(a>=f||c){c=!0;let d=Math.floor(a/
f);b+=""===b?"":":";b+=(10>d&&""!==b?"0":"")+d;a-=d*f}}return 1===b.length?"0:0"+b:2===b.length?"0:"+b:""===b?"0:00":b},SecondsInPaddledColonTime:function(a){if(Infinity==a)return D.Infinity;a=D.SecondsInColonTime(a);return"00:00:00".substr(0,8-a.length)+a}};const F={_timecode_start:0,_timecode_end:!1,_last_play_error:!1,_remove_timecode_outofborders:function(a){if(a<F._timecode_start||!1!==F._timecode_end&&a>F._timecode_end)F._timecode_start=0,F._timecode_end=!1},hashOrder:function(a,b=void 0){var c=!0;"string"!==typeof a&&(c="at_start"in a,a=location.hash.substr(1));let d="";var f="",g=a.split("&");a=!1;for(let b of g)if(-1===b.indexOf("=")&&""===d)d=b;else{g=b.split("=");let c=g[1];switch(g[0]){case "t":f=c=""!==c?c:"0";a=!0;break;case "autoplay":a=
"1"===c;break;case "auto_play":a="true"===c}}if(""===f||c&&!a)return w(b),!1;c=f.split(",");f=c[0];F._timecode_start=D.TimeInSeconds(f);F._timecode_end=1<c.length?D.TimeInSeconds(c[1]):!1;!1!==F._timecode_end&&(F._timecode_end=F._timecode_end>F._timecode_start?F._timecode_end:!1);document.CPU.jumpIdAt(d,f,b);document.CPU.global_controller&&document.CPU.global_controller.build_playlist();return!0},hover:function(a){let b=a.target,c=document.CPU.find_container(b);b.getClientRects();c.show_throbber_at(a.offsetX/
b.clientWidth*c.audiotag.duration)},out:function(a){document.CPU.find_container(a.target).hide_throbber()},preview_container_hover:function(a){var b=a.target;b.id||(b=b.closest("[id]"));null!==b&&(a=document.CPU.find_container(b),b=a.get_point_names_from_id(b.id),a.highlight_point(b[0],b[1]))},throbble:function(a){var b=0;b=a.target;let c=document.CPU.find_container(b).audiotag;if(Infinity===c.duration)F.play(a);else if(document.CPU.current_audiotag_playing&&!document.CPU.is_audiotag_playing(c)&&
F.pause(void 0,document.CPU.current_audiotag_playing),isNaN(c.duration)){let d=c.CPU_controller();null!==d&&d.update_loading&&d.update_loading(void 0,100*a.offsetX/b.clientWidth);let f={offsetX:a.offsetX,target:a.target},g=function(){F.throbble(f);c.removeEventListener("loadedmetadata",g)};c.addEventListener("loadedmetadata",g);c.setAttribute("preload","metadata")}else b=void 0!==a.at?a.at:a.offsetX/b.clientWidth*c.duration,document.CPU.seekElementAt(c,b),F.play(a)},pause:function(a=void 0,b=void 0){void 0===
b&&(a=a.target,b="AUDIO"===a.tagName?a:document.CPU.find_container(a).audiotag);b.pause();document.CPU.current_audiotag_playing=null;window.localStorage.removeItem(b.currentSrc)},play_once:function(a){a=a.target;document.CPU.last_used=a;document.CPU.only_play_one_audiotag&&document.CPU.current_audiotag_playing&&!document.CPU.is_audiotag_playing(a)&&F.pause(void 0,document.CPU.current_audiotag_playing);document.CPU.current_audiotag_playing=a},play:function(a,b=void 0){function c(a){F._last_play_error=
!1;F.play(a,b);document.removeEventListener("focus",c);document.removeEventListener("click",c)}void 0===b&&(b=document.CPU.find_container(a.target).audiotag);void 0===a&&F._last_play_error?C("play() prevented because already waiting for focus"):(F._last_play_error=!1,F._remove_timecode_outofborders(b.currentTime),a=b.play(),void 0!==a&&a.then(()=>{}).catch((a)=>{F._last_play_error=!0;switch(a.name){case "NotAllowedError":C("Auto-play prevented : Browser requires a manual interaction first.");document.addEventListener("focus",
c);document.addEventListener("click",c);b.CPU_connected&&b.CPU_controller().CPU.set_act_container("glow");break;case "NotSupportedError":a("The browser refuses the audio source, probably due to audio format.")}}),document.CPU.global_controller&&(a=document.CPU.global_controller,b.isEqualNode(a.audiotag)||(a.attach_audiotag_to_controller(b),a.audiotag=b,a.show_main(),a.redraw_all_planes(),a.set_mode_container()),a.build_playlist()))},key:function(a,b=void 0){function c(b){a.at=d.audiotag.currentTime+
b;d.show_throbber_at(a.at);F.throbble(a);d.hide_throbber_later()}if(!(a.altKey||a.ctrlKey||a.metaKey||a.shiftKey)){b=void 0===b?1:b;var d=document.CPU.find_container(a.target),f=d.audiotag;switch(a.keyCode){case 27:F.restart(a);F.pause(void 0,f);break;case 32:f.paused?F.play(a,f):F.pause(void 0,f);break;case 35:document.CPU.seekElementAt(f,f.duration);break;case 36:F.restart(a);break;case 37:c(-(document.CPU.keymove*b));break;case 39:c(+(document.CPU.keymove*b));break;default:return}a.preventDefault()}},
keydownplay:function(a){if(13===a.keyCode){var b=document.CPU.find_container(a.target).audiotag;b.paused?F.play(void 0,b):F.pause(void 0,b);a.preventDefault()}},restart:function(a){a=document.CPU.find_container(a.target);document.CPU.seekElementAt(a.audiotag,0)},reward:function(a){a.keyCode=37;F.key(a)},foward:function(a){a.keyCode=39;F.key(a)},fastreward:function(a){a.keyCode=37;F.key(a,document.CPU.fast_factor)},fastfoward:function(a){a.keyCode=39;F.key(a,document.CPU.fast_factor)},_hand_on:null,
_press_button:function(a){let b=a.target.id?a.target:a.target.closest("button"),c=["fastreward","reward","foward","fastfoward"];b.id&&-1!==c.indexOf(b.id)&&(F[b.id](a),null!==F._hand_on&&window.clearTimeout(F._hand_on),F._hand_on=window.setTimeout(F._repeat_button,document.CPU.repeat_delay,{target:b,preventDefault:w}),a.preventDefault())},_repeat_button:function(a){F[a.target.id](a);F._hand_on=window.setTimeout(F._repeat_button,document.CPU.repeat_factor,a)},_release_button:function(a){window.clearTimeout(F._hand_on);
F._hand_on=null;a.preventDefault()},cuechange:function(a,b){document.body.classList.remove(document.CPU.body_className_playing_cue);void 0!==b&&(b=document.CPU.find_container(b),b.remove_highlights_points("active-cue"),0!==a.target.activeCues.length&&(a=a.target.activeCues[0].id,null!==document.CPU.current_audiotag_playing&&(document.CPU.body_className_playing_cue=`cpu_playing_tag_\u00ab${document.CPU.current_audiotag_playing.id}\u00bb_cue_\u00ab${a}\u00bb`,document.body.classList.add(document.CPU.body_className_playing_cue)),
b.highlight_point("_chapters",a,"active-cue")))},update:function(a){a=a.target;!1!==F._timecode_end&&a.currentTime>F._timecode_end&&F.pause(void 0,a);a.CPU_update();a.paused||document.CPU.is_audiotag_streamed(a)||window.localStorage.setItem(a.currentSrc,String(a.currentTime))},ended:function(a,b){void 0===b&&(b=a.target);if("playlist"in b.dataset){a=b.dataset.playlist;var c=document.CPU.playlists[a];if(void 0===c)C(`Named playlist ${a} not created. WTF ?`);else{var d=c.indexOf(b.id);-1===d?C(`Audiotag ${b.id} not in playlist ${a}. WTF ?`):
d+1!==c.length&&(b=c[d+1],a=document.getElementById(b),null===a?C(`Audiotag #${b} doesn't exists. WTF ?`):(document.CPU.seekElementAt(a,0),F.play({},a)))}}},observer_cpuaudio:function(a){a=document.CPU.find_container(a[0].target);null===a.element.querySelector("audio")?(window.console.info("CPU-AUDIO: ","<audio> element was removed."),a.element.remove()):a.element.copy_attributes_to_media_dataset()},observer_audio:function(a){a=document.CPU.find_container(a[0].target);a.build_chapters();a.complete_template();
let b=document.CPU.global_controller;null!==b&&a.audiotag.isEqualNode(b.audiotag)&&(b.build_chapters(),b.complete_template())},native_share:function(a){let b=document.CPU.find_container(a.target).fetch_audiotag_dataset();navigator.share({title:b.title,text:b.title,url:b.canonical});a.preventDefault()},_show_alternate_nav:null,touchstart:function(a){a=document.CPU.find_container(a.target);F._show_alternate_nav=setTimeout(a.show_handheld_nav,document.CPU.alternate_delay,a)},touchcancel:function(){clearTimeout(F._show_alternate_nav)}};if(!document.CPU){var G=HTMLDocument.prototype,I;a:{for(let a of["og","twitter"]){let b=document.querySelector(`meta[property="${a}:title"]`);if(null!==b){I=b.content;break a}}let a=document.title;I=""===a?null:a}var J=I,K;a:{for(let a of['property="og:image"','name="twitter:image:src"']){let b=document.querySelector(`meta[${a}]`);if(null!==b){K=b.content;break a}}K=null}var L=K,M;{let a=document.querySelector('link[rel="canonical"]');M=null!==a?a.href:location.href.split("#")[0]}var N;{let a=document.querySelector('meta[name="twitter:creator"]');
N=null!==a&&1<a.content.length?a.content:null}G.CPU={keymove:5,only_play_one_audiotag:!0,alternate_delay:500,fast_factor:4,repeat_delay:400,repeat_factor:100,current_audiotag_playing:null,global_controller:null,body_className_playing_cue:null,dynamicallyAllocatedIdPrefix:"CPU-Audio-tag-",count_element:0,last_used:null,playlists:{},advance_in_playlist:!0,convert:D,trigger:F,default_dataset:{title:J,poster:L,canonical:M,twitter:N,playlist:null,waveform:null,duration:null,download:null},is_audiotag_streamed:function(a){return null===
a||Infinity===a.duration||void 0!==a.dataset.streamed},recall_stored_play:function(a){a=a.target;if(null===document.CPU.current_audiotag_playing&&!document.CPU.is_audiotag_streamed(a)){var b=Number(window.localStorage.getItem(a.currentSrc));0<b&&!F._last_play_error&&(document.CPU.seekElementAt(a,b),F.play(void 0,a))}},attach_events_audiotag:function(a){a.addEventListener("loadedmetadata",document.CPU.recall_stored_play);a.addEventListener("play",F.play_once);a.addEventListener("ended",F.ended);a.addEventListener("ready",
document.CPU.recall_stored_play);a.addEventListener("canplay",document.CPU.recall_stored_play);"ready load loadeddata canplay abort error emptied play playing pause ended durationchange loadedmetadata timeupdate waiting".split(" ").forEach(function(b){a.addEventListener(b,F.update)});void 0===window.customElements&&["pause","ended"].forEach(function(b){a.addEventListener(b,F.pause)});""===a.getAttribute("preload")&&(a.preload="metadata",a.load())},connect_audiotag:function(a){if(!a.CPU_connected&&
(a.CPU_connected=!0,document.CPU.attach_events_audiotag(a),a.hidden=!0,a.removeAttribute("controls"),"string"===typeof a.dataset.playlist)){let b=a.dataset.playlist;b in document.CPU.playlists||(document.CPU.playlists[b]=[]);document.CPU.playlists[b].push(a.id)}},is_audiotag_playing:function(a){return document.CPU.current_audiotag_playing&&a.isEqualNode(document.CPU.current_audiotag_playing)},is_audiotag_global:function(a){return null===this.global_controller?this.is_audiotag_playing(a):a.isEqualNode(this.global_controller.audiotag)},
jumpIdAt:function(a,b,c=void 0){function d(a){let c=a.target;void 0!==a.preventDefault&&c.removeEventListener("loadedmetadata",d,!0);a=D.TimeInSeconds(b);document.CPU.seekElementAt(c,a);a={target:c};c.readyState>=c.HAVE_FUTURE_DATA?f(a):c.addEventListener("canplay",f,!0);F.update(a)}function f(a){let b=a.target;F.play(void 0,b);void 0!==a.preventDefault&&b.removeEventListener("canplay",f,!0);w(c)}let g=""!==a?document.getElementById(a):document.querySelector("cpu-audio audio");if(void 0===g||null===
g||void 0===g.currentTime)return C(`Unknow audiotag ${a}`),!1;a={target:g};g.readyState<HTMLMediaElement.HAVE_CURRENT_DATA?(g.addEventListener("loadedmetadata",d,!0),g.load(a),F.update(a)):d(a);return!0},seekElementAt:function(a,b){if(!isNaN(b)&&!document.CPU.is_audiotag_streamed(a)){if(void 0!==a.fastSeek)a.fastSeek(b);else try{a.currentTime=b}catch(c){a.src=`${a.currentSrc.split("#")[0]}#t=${b}`}a=a.CPU_controller();null!==a&&a.update_loading&&a.update_loading(b)}},find_interface:function(a){return a.closest("#interface")},
find_container:function(a){if("CPU-AUDIO"===a.tagName||"CPU-CONTROLLER"===a.tagName)return a.CPU;let b=a.closest("CPU-AUDIO");return b?b.CPU:document.CPU.find_interface(a).parentNode.host.CPU},find_current_playlist:function(){if(null===this.global_controller)return[];let a=this.global_controller.audiotag;if(null===a)return[];for(let b in this.playlists)if(0<=this.playlists[b].indexOf(a.id))return this.playlists[b];return[]}}};class O{constructor(a,b){this.element=a;this.elements={};this.audiotag=a._audiotag;this.container=b;this.mode_when_play=null;this.glow_before_play=!1;this.current_playlist=[];this.elapse_was=this.act_was=this.mode_was=this._activecue=null;this._loadedmetadata_ev=!1;this.audiotag&&!this.audiotag._CPU_planes&&(this.audiotag._CPU_planes={})}set_mode_container(a=null){a=null!==a?a:"default";this.mode_was!==a&&(this.container.classList.remove(`mode-${this.mode_was}`),this.container.classList.add(`mode-${a}`),
this.mode_was=a)}set_act_container(a){this.act_was!==a&&(this.container.classList.remove("act-loading","act-pause","act-play","act-glow"),this.container.classList.add(`act-${a}`),this.act_was=a)}set_hide_container(a){for(let a of l)this.container.classList.remove(`hide-${a}`);for(let b of a)b=b.toLowerCase(),-1<l.indexOf(b)&&this.container.classList.add(`hide-${b}`)}update_playbutton(){let a=this.audiotag;var b=a.getAttribute("preload");b=b?"none"!==b.toLowerCase():!0;a.readyState<HTMLMediaElement.HAVE_CURRENT_DATA&&
(b||a._CPU_played)?this.set_act_container("loading"):(F._last_play_error&&a.paused||this.set_act_container(a.paused?"pause":"play"),b=document.CPU.last_used,a.paused?(this.audiotag.isEqualNode(b)||this.container.classList.remove("last-used"),!a._CPU_played&&this.glow_before_play&&this.set_act_container("glow")):(a._CPU_played=!0,this.container.classList.add("last-used"),null!==this.mode_when_play&&(this.set_mode_container(this.mode_when_play),this.mode_when_play=null)))}update_line(a,b,c){void 0===
c&&(c=this.audiotag.duration,c=0===c?0:100*b/c);this.elements[`${a}line`].style.width=`${c}%`}update_time(){let a=this.audiotag;var b=document.CPU.is_audiotag_streamed(a)?0:Math.floor(a.currentTime),c=a.dataset.canonical;c=void 0===c?"":c;var d=y(c)+"#";let f=c.indexOf("#");d+=(-1===f?a.id:c.substr(f+1))+"&t="+b;b=this.elements.elapse;b.href=d;d="\u2026";c=Math.round(a.duration);isNaN(c)?(c=Math.round(a.dataset.duration),0<c&&(d=D.SecondsInColonTime(c))):d=D.SecondsInColonTime(c);c=D.SecondsInColonTime(a.currentTime);
d=document.CPU.is_audiotag_streamed(a)?c:`${c}<span class="nosmaller">\u00a0/\u00a0${d}</span>`;this.elapse_was!==d&&(this.elapse_was=b.innerHTML=d);this.update_line("loading",a.currentTime)}update_time_borders(){document.CPU.is_audiotag_global(this.audiotag)&&!1!==F._timecode_end?(this.add_plane("_borders","",{track:"borders",panel:!1,highlight:!1}),this.add_point("_borders",F._timecode_start,"play",{link:!1,end:F._timecode_end})):this.remove_plane("_borders")}update_loading(a,b){this.update_line("loading",
a,b);this.set_act_container("loading")}update_error(){var a=this.audiotag;if(null===a)return!0;var b=a.error;if(null!==b){a=this.elements.pageerror;this.show_interface("error");switch(b.code){case MediaError.MEDIA_ERR_ABORTED:b=u.media_err_aborted;break;case MediaError.MEDIA_ERR_NETWORK:b=u.media_err_network;break;case MediaError.MEDIA_ERR_DECODE:b=u.media_err_decode;break;case MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED:b=u.media_err_src_not_supported;break;default:b=u.media_err_unknow}a.innerText=b;
return!0}return!1}update(){this.update_error()||(this.update_playbutton(),this.update_time(),this.update_time_borders())}show_throbber_at(a){if(!(1>this.audiotag.duration)){var b=this.elements.popup;b.style.opacity=1;b.style.left=100*a/this.audiotag.duration+"%";b.innerHTML=D.SecondsInColonTime(a);b.dateTime=D.SecondsInTime(a).toUpperCase()}}hide_throbber(a=void 0){(void 0===a?this:a).elements.popup.style.opacity=0}hide_throbber_later(){let a=this.elements.popup;a._hider&&window.clearTimeout(a._hider);
a._hider=window.setTimeout(this.hide_throbber,1E3,this)}fetch_audiotag_dataset(){let a={};for(let b in document.CPU.default_dataset){let c=null;b in this.audiotag.dataset?c=this.audiotag.dataset[b]:null!==document.CPU.default_dataset[b]&&(c=document.CPU.default_dataset[b]);a[b]=void 0===c?null:c}return a}update_links(){var a=this.fetch_audiotag_dataset();if(null===a.canonical)var b="";else{b=a.canonical;var c=b.indexOf("#");b=-1===c?b:b.substr(0,c)}b=encodeURI(y(b+`#${this.audiotag.id}`+(0===this.audiotag.currentTime?
"":`&t=${Math.floor(this.audiotag.currentTime)}`)));c="";a.twitter&&"@"===a.twitter[0]&&(c=`&via=${a.twitter.substring(1)}`);this.elements.twitter.href=`https://twitter.com/share?text=${a.title}&url=${b}${c}`;this.elements.facebook.href=`https://www.facebook.com/sharer.php?t=${a.title}&u=${b}`;this.elements.email.href=`mailto:?subject=${a.title}&body=${b}`;b=this.audiotag.currentSrc;a.download&&(b=a.download);if(a=this.audiotag.querySelector("source[data-downloadable]"))b=a.src;this.elements.link.href=
b}show_interface(a){this.container.classList.remove("show-no","show-main","show-share","show-error","media-streamed");document.CPU.is_audiotag_streamed(this.audiotag)&&this.container.classList.add("media-streamed");this.container.classList.add("show-"+a)}show_actions(a){a=void 0!==a?document.CPU.find_container(a.target):this;a.show_interface("share");a.update_links()}show_main(a=void 0){(void 0!==a?document.CPU.find_container(a.target):this).show_interface("main")}show_handheld_nav(a){let b=void 0!==
a?document.CPU.find_container(a.target):this;document.CPU.is_audiotag_streamed(b.audiotag)||(b.container.classList.toggle("show-handheld-nav"),a.preventDefault())}add_id_to_audiotag(){""===this.audiotag.id&&(this.audiotag.id=document.CPU.dynamicallyAllocatedIdPrefix+String(document.CPU.count_element++))}complete_template(){let a=this.fetch_audiotag_dataset(),b=this.elements.canonical;b.href=a.canonical;null===a.title?(b.classList.add("untitled"),a.title=u.untitled):b.classList.remove("untitled");
b.innerText=a.title;this.elements.poster.src=null===a.poster?"":a.poster;this.elements.time.style.backgroundImage=null===a.waveform?"":`url(${a.waveform})`}attach_audiotag_to_controller(a){a&&(this.audiotag=a,this.add_id_to_audiotag(),this.complete_template(),F.update({target:a}))}get_plane(a){return this.audiotag._CPU_planes[a]}get_plane_track(a){return this.elements.line.querySelector(`#track_\u00ab${a}\u00bb`)}get_plane_panel(a){return this.container.querySelector(`#panel_\u00ab${a}\u00bb`)}get_plane_nav(a){return(a=
this.get_plane_panel(a))?a.querySelector("ul"):null}draw_plane(a){function b(a){a.addEventListener("mouseover",f,p);a.addEventListener("focusin",f,p);a.addEventListener("mouseleave",g,p);a.addEventListener("focusout",g,p)}var c=this.get_plane_track(a);c&&c.remove();(c=this.get_plane_panel(a))&&c.remove();let d=this.get_plane(a);if(d){var f=F.preview_container_hover,g=this.remove_highlights_points.bind(this);!1!==d.track&&(c=document.createElement("aside"),c.id=`track_\u00ab${a}\u00bb`,!0!==d.track&&
c.classList.add(d.track),this.elements.line.appendChild(c),b(c));if(!1!==d.panel){c=document.createElement("div");c.id=`panel_\u00ab${a}\u00bb`;!0!==d.panel&&c.classList.add(d.panel);c.classList.add("panel");let f="<nav><ul></ul></nav>";void 0!==d.title&&(f=`<h6>${B(d.title)}</h6>${f}`);c.innerHTML=f;this.container.appendChild(c);b(c)}"CPU-CONTROLLER"!==this.element.tagName&&null!==document.CPU.global_controller&&this.audiotag.isEqualNode(document.CPU.global_controller.audiotag)&&document.CPU.global_controller.draw_plane(a)}}add_plane(a,
b,c){if("CPU-CONTROLLER"===this.element.tagName||!a.match(m)||void 0!==this.get_plane(a))return!1;void 0===c&&(c={});void 0===this.audiotag._CPU_planes&&(this.audiotag._CPU_planes={});b={track:!0,panel:!0,title:b,highlight:!0,points:{}};for(let a in b)void 0===c[a]&&(c[a]=b[a]);this.audiotag._CPU_planes[a]=c;this.draw_plane(a);return!0}remove_plane(a){if("CPU-CONTROLLER"===this.element.tagName||!a.match(m)||void 0===this.audiotag._CPU_planes[a])return!1;this.audiotag&&delete this.audiotag._CPU_planes[a];
let b=this.get_plane_track(a);b&&b.remove();(b=this.get_plane_panel(a))&&b.remove();"CPU-CONTROLLER"!==this.element.tagName&&null!==document.CPU.global_controller&&this.audiotag.isEqualNode(document.CPU.global_controller.audiotag)&&document.CPU.global_controller.draw_plane(a);return!0}get_point_id(a,b,c){return`${c?"panel":"track"}_\u00ab${a}\u00bb_point_\u00ab${b}\u00bb`}get_point(a,b){return this.audiotag._CPU_planes[a].points[b]}get_point_track(a,b){return this.elements.line.querySelector("#"+
this.get_point_id(a,b,!1))}get_point_panel(a,b){return this.container.querySelector("#"+this.get_point_id(a,b,!0))}translate_vtt(a){let b={i:"i",em:"em",b:"b",bold:"strong",u:"u",lang:"i"};return(a.match(/</g)||[]).length!==(a.match(/>/g)||[]).length?B(a):a.replace(/<(\w+)(\.[^>]+)?( [^>]+)?>/gi,function(a,d,f,g){d=d.toLowerCase();if(!(d in b))return"";a="";"lang"===d&&(a=` lang="${g.trim()}"`);return`<${b[d]}${a}>`}).replace(/<\/(\w+)( [^>]*)?>/gi,function(a,d){d=d.toLowerCase();return d in b?`</${b[d]}>`:
""}).replace(/\n/g,"<br/>")}draw_point(a,b){var c=this.get_point_panel(a,b);c&&c.remove();(c=this.get_point_track(a,b))&&c.remove();c=this.get_point(a,b);let d=this.audiotag?this.audiotag:document.CPU.global_controller.audiotag;var f=d.duration,g=this.get_plane_track(a);let E=this.get_plane_nav(a);var q=this.get_point_id(a,b,!1);let H=this.get_point_id(a,b,!0);if(g){let a=document.createElement("a");a.id=q;a.tabIndex=-1;!1!==c.link&&(a.href=`#${d.id}&t=${c.start}`);a.title=c.text;q="";c.image&&(q=
`<img src="${c.image}" alt="">`);q+=`<span>${c.text}</span>`;a.innerHTML=q;a.title=a.innerText;g.appendChild(a);a.style.left=`${c.start/f*100}%`;c.end&&(a.style.right=`${100-c.end/f*100}%`)}E&&(f=document.createElement("li"),g="",c.text&&(g+=`<strong>${c.text}</strong>`),g+=`<time datetime="P${D.SecondsInTime(c.start).toUpperCase()}">${D.SecondsInColonTime(c.start)}</time>`,!1!==c.link?(!0===c.link&&(c.link=`#${d.id}&t=${c.start}`),g=`<a href="${c.link}" class="cue" id="${H}">${g}</a>`):g=`<span class="cue" id="${H}">${g}</span>`,
f.innerHTML=g,E.appendChild(f));"CPU-CONTROLLER"!==this.element.tagName&&null!==document.CPU.global_controller&&this.audiotag.isEqualNode(document.CPU.global_controller.audiotag)&&document.CPU.global_controller.draw_point(a,b)}add_point(a,b,c,d){d=void 0===d?{}:d;if("CPU-CONTROLLER"===this.element.tagName||void 0===this.get_plane(a)||void 0!==this.get_point(a,c)||0>b||!c.match(m))return!1;d.start=b;this.audiotag._CPU_planes[a].points[c]=d;this.draw_point(a,c);return!0}remove_point(a,b){let c=this.get_point_track(a,
b);if(!c)return!1;delete this.audiotag._CPU_planes[a].points[b];c.remove();this.get_point_panel(a,b).remove();"CPU-CONTROLLER"!==this.element.tagName&&null!==document.CPU.global_controller&&this.audiotag.isEqualNode(document.CPU.global_controller.audiotag)&&document.CPU.global_controller.remove_point(a,b);return!0}get_point_names_from_id(a){let b=a.replace(n,"$2");a=a.replace(n,"$5");return[b,a]}clear_plane(a){let b=this.get_plane(a);if(!this.get_plane(a))return!1;for(let c of Object.keys(b.points))this.remove_point(a,
c);a=this.get_plane_nav(a);null!==a&&(a.innerHTML="");return!0}undraw_all_planes(){x("aside , div.panel",function(a){a.remove()},this.container)}redraw_all_planes(){this.undraw_all_planes();for(let a of Object.keys(this.audiotag._CPU_planes)){this.draw_plane(a);for(let b of Object.keys(this.audiotag._CPU_planes[a].points))this.draw_point(a,b)}}remove_highlights_points(a=void 0,b=void 0){b=void 0===b?!0:b;a="string"===typeof a?a:"with-preview";x(`.${a}`,function(b){b.classList.remove(a)},this.container);
b&&null!==document.CPU.global_controller&&this.audiotag.isEqualNode(document.CPU.global_controller.audiotag)&&("CPU-CONTROLLER"!==this.element.tagName?document.CPU.global_controller.remove_highlights_points(a,!1):document.CPU.find_container(document.CPU.global_controller.audiotag).remove_highlights_points(a,!1))}highlight_point(a,b,c=void 0,d=void 0){d=void 0===d?!0:d;c="string"===typeof c?c:"with-preview";this.remove_highlights_points(c,d);var f=this.get_plane(a);f&&f.highlight&&(this.get_plane_track(a)&&
(f=this.get_point_track(a,b))&&f.classList.add(c),this.get_plane_panel(a)&&(f=this.get_point_panel(a,b))&&f.classList.add(c),d&&null!==document.CPU.global_controller&&this.audiotag.isEqualNode(document.CPU.global_controller.audiotag)&&("CPU-CONTROLLER"!==this.element.tagName?document.CPU.global_controller.highlight_point(a,b,c,!1):document.CPU.find_container(document.CPU.global_controller.audiotag).highlight_point(a,b,c,!1)))}_cuechange_event(a){try{let b;b=a.target.activeCues[0];if(Object.is(b,this._activecue))return;
this._activecue=b}catch(b){}F.cuechange(a,this.elements["interface"])}build_chapters(a=void 0,b=void 0){function c(a){let b=d._cuechange_event.bind(d);a.removeEventListener("cuechange",b);a.addEventListener("cuechange",b);for(let b of a.cues)d.add_point("_chapters",Math.floor(b.startTime),b.id,{text:d.translate_vtt(b.text),link:!0,end:b.endTime});0<a.cues.length&&(f=!0)}if("CPU-CONTROLLER"!==this.element.tagName){var d=this;void 0!==a&&(d=document.CPU.find_container(a.target),null===d&&window.console.error("CPU-AUDIO: ",
"Container CPU- not ready yet. WTF ?"));a=d.audiotag;var f=!1;if(a)if(void 0!==b)c(b);else if(a.textTracks&&0<a.textTracks.length){b=null;for(var g of a.textTracks)"chapters"!==g.kind.toLowerCase()||null===g.cues||null!==b&&g.language.toLowerCase()!==t||(b=g);b&&(d.add_plane("_chapters",u.chapters,{track:"chapters"}),d.clear_plane("_chapters"),c(b))}"CPU-AUDIO"===d.element.tagName&&(g=`cpu_tag_\u00ab${a.id}\u00bb_chaptered`,f?document.body.classList.add(g):(d.remove_plane("_chapters"),document.body.classList.remove(g)))}}build_chapters_loader(){this.build_chapters();
let a=this.build_chapters.bind(this);this._loadedmetadata_ev||(this.audiotag.addEventListener("loadedmetadata",a,p),this._loadedmetadata_ev=!0);let b=this.audiotag.querySelector('track[kind="chapters"]');b&&!b._CPU_load_ev&&(b._CPU_load_ev=b.addEventListener("load",a,p))}build_playlist(){if("CPU-CONTROLLER"===this.element.tagName){this.current_playlist=document.CPU.find_current_playlist();var a=this.elements.playlist;a.innerHTML="";if(0!==this.current_playlist.length){a.innerHTML=`<h6>${u.playlist}</h6>`;
for(let b of this.current_playlist){let c=document.getElementById(b),d=document.createElement("a");d.classList.add("cue");b===this.audiotag.id&&d.classList.add("active-cue");d.href=`#${c.id}&t=0`;d.tabIndex=0;d.innerHTML=`<strong>${c.dataset.title}</strong>`;a.append(d)}}}}build_controller(){let a=this;x("[id]",function(b){a.elements[b.id]=b},this.element.shadowRoot);this.elements.poster.addEventListener("load",function(){a.elements["interface"].classList.add("poster-loaded")},p);var b={pause:F.play,
play:F.pause,time:F.throbble,actions:this.show_actions,back:this.show_main,poster:this.show_main,restart:F.restart};for(var c in b)this.elements[c].addEventListener("click",b[c],p);b=["fastreward","reward","foward","fastfoward"];c={touchstart:!0,touchend:!1,touchcancel:!1,mousedown:!0,mouseup:!1,mouseleave:!1};for(var d of b)for(var f in c)this.elements[d].addEventListener(f,c[f]?F._press_button:F._release_button);this.element.addEventListener("keydown",F.key);this.elements.control.addEventListener("keydown",
F.keydownplay);d=this.elements.time;f={mouseover:!0,mousemove:!0,mouseout:!1,touchstart:!0,touchend:!1,touchcancel:!1};for(let a in f)d.addEventListener(a,f[a]?F.hover:F.out,p);d.addEventListener("touchstart",F.touchstart,p);d.addEventListener("touchend",F.touchcancel,p);d.addEventListener("contextmenu",this.show_handheld_nav);this.audiotag&&(this.show_main(),this.build_chapters_loader(),this.audiotag.addEventListener("loadedmetadata",this.redraw_all_planes.bind(this),p))}};HTMLAudioElement.prototype.CPU_connected=!1;HTMLAudioElement.prototype.CPU_controller=function(){return this.closest("CPU-AUDIO")};HTMLAudioElement.prototype.CPU_update=function(){var a=this.CPU_controller();a&&(a=a.CPU)&&a.update&&a.update();null!==document.CPU.global_controller&&document.CPU.global_controller.update()};class P extends HTMLElement{constructor(){super();this.CPU=null;window.matchMedia("screen").matches?"CPU-AUDIO"===this.tagName&&null===this.querySelector("audio[controls]")?(C("Tag <CPU-AUDIO> without <audio controls>.\nSee https://github.com/dascritch/cpu-audio/blob/master/INSTALL.md for a correct installation."),this.remove()):(e=k.querySelector("template#CPU__template"),h=this.attachShadow({mode:"open"}),h.innerHTML=e.innerHTML):this.remove()}connectedCallback(){if(window.matchMedia("screen").matches){this.CPU=
new O(this,this.shadowRoot.querySelector("#interface"));this.CPU.audiotag||(document.CPU.global_controller=this.CPU,this.CPU.audiotag=document.querySelector("cpu-audio audio"));this.CPU.build_controller();x("#canonical",A,this.shadowRoot);this.CPU.attach_audiotag_to_controller(this.CPU.audiotag);var a=this.CPU.elements["interface"].classList,b=this.getAttribute("mode");if(null!==b){let a=b.split(",");1<a.length&&(b=this.CPU.audiotag.paused?a[0]:a[1],this.CPU.mode_when_play=a[1])}this.CPU.set_mode_container(b);
b=this.getAttribute("hide");null!==b&&this.CPU.set_hide_container(b.split(" "));navigator.share&&(a.add("hasnativeshare"),this.CPU.elements.nativeshare.addEventListener("click",F.native_share));null!==this.getAttribute("glow")&&(this.CPU.glow_before_play=!0,this.CPU.update_playbutton())}}disconnectedCallback(){}};class Q extends P{constructor(){super();this.observer_audio=this.observer_cpuaudio=this.audiotag=this._audiotag=null}copy_attributes_to_media_dataset(){for(let a in document.CPU.default_dataset){let b=this.getAttribute(a);null!==b&&(this._audiotag.dataset[a]="duration"!==a?b:D.TimeInSeconds(b))}}connectedCallback(){this._audiotag=this.querySelector("audio[controls]");null!==this._audiotag&&(this.copy_attributes_to_media_dataset(),super.connectedCallback(),document.CPU.connect_audiotag(this.CPU.audiotag),
this.observer_cpuaudio=new MutationObserver(F.observer_cpuaudio),this.observer_cpuaudio.observe(this,{childList:!0,attributes:!0}),this.observer_audio=new MutationObserver(F.observer_audio),this.observer_audio.observe(this,{childList:!0,attributes:!0,subtree:!0}))}};function R(){void 0===window.customElements?(C("WebComponent may NOT behave correctly on this browser. Only timecode hash links are activated.\nSee https://github.com/dascritch/cpu-audio/ for details"),x("audio[controls]",document.CPU.attach_events_audiotag),document.body.classList.add("cpu-audio-without-webcomponents")):(window.customElements.define("cpu-audio",Q),window.customElements.define("cpu-controller",P),document.body.classList.add("cpu-audio-with-webcomponents"));window.addEventListener("hashchange",
F.hashOrder,!1);F.hashOrder({at_start:!0})}null!==document.body?R():document.addEventListener("DOMContentLoaded",R,!1);}).call(this);