diff --git a/build/cpu-audio.direct-download.js b/build/cpu-audio.direct-download.js index 4abf94c6..7a065c39 100644 --- a/build/cpu-audio.direct-download.js +++ b/build/cpu-audio.direct-download.js @@ -10,7 +10,7 @@ License GNU GPL 3 - use case : http://cpu.pm - blog post : https://dascritch.net/post/2018/11/06/Reconstruire-son-lecteur-audio-pour-le-web **/ -const e="CPU-AUDIO",t="CPU-CONTROLLER",a="#interface",n="audio[controls]",i="cpu-audio audio",o={passive:!0},r={passive:!0,once:!0};function l(e,t,a=document){Array.from(a.querySelectorAll(e)).forEach(t)}function s(e,t,a){if(!e?.indexOf)return null;const n=e.indexOf(t);return-1===n?null:e[n+a]}function d(){return void 0!==window.customElements}function c(e){let t=document.createElement("a");return t.href="string"!=typeof e?e:e.split("#")[0],t.href}function u(){return!window.matchMedia("screen").matches}function p(e){c(window.location.href)===c(e.target.href)&&e.preventDefault()}function h(e){let t=document.createElement("span");t.innerText=e;let a=t.innerHTML;return t.remove(),a}function m(e){return e.closest(a)}function g(a){if([e,t].includes(a.tagName))return a.CPU;let n=a.closest(e);return n?n.CPU:m(a).parentNode.host.CPU}function f(t){window.console.warn(`${e}: `,t)}const v={fr:{loading:"Chargement en cours…",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élécharger",back:"Annuler",chapters:"Chapitres",playlist:"Playlist",media_err_aborted:"Vous avez annulé la lecture.",media_err_network:"Une erreur réseau a causé l'interruption du téléchargement.",media_err_decode:"La lecture du sonore a été annulée suite à des problèmes de corruption ou de fonctionnalités non supportés par votre navigateur.",media_err_src_not_supported:"Le sonore n'a pu être chargé, soit à cause de sourcis sur le serveur, le réseau ou parce que le format n'est pas supporté.",media_err_unknow:"Erreur due à une raison inconnue."},en:{loading:"Loading…",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 b=document.querySelector("html").lang;if(!b.length||!(b.toLowerCase()in v)){b="en";let e=window.navigator.languages;e=void 0!==e?e:[navigator.language||navigator.browserLanguage];let t=!1;for(let a of e)if(a.split){let e=a.split("-")[0];!t&&e in v&&(b=e)}}const w=v[b];let y=document.head;const _={get title(){for(const e of['property="og:title"','name="twitter:title"']){const t=y.querySelector(`meta[${e}]`);if(t)return t.content}const e=document.title;return""===e?null:e},get poster(){for(const e of['property="og:image"','name="twitter:image:src"']){const t=y.querySelector(`meta[${e}]`);if(t)return t.content}return null},get canonical(){const e=y.querySelector('link[rel="canonical"]');return e?e.href:location.href.split("#")[0]},get twitter(){const e=y.querySelector('meta[name="twitter:creator"]');return e&&e.content.length>1?e.content:null},playlist:null,waveform:null,duration:null,download:null},P={d:86400,h:3600,m:60,s:1};let C=[1,60,3600,86400];const k=/^\d+$/,x=/\D*/g,T=function(e){let t=0;return""!==e&&(t=k.test(e)?Number(e):e.includes(":")?A.colontimeInSeconds(e):A.subunittimeInSeconds(e)),t},E=function(e){if(e===1/0)return"?";let t="",a=!1;for(let n in P)if(P.hasOwnProperty(n)){let i=P[n];if(e>=i||a){a=!0;let o=Math.floor(e/i);t+=o+n,e-=o*i}}return""===t?"0s":t},L=function(e){if(e===1/0)return"?";let t="",a=!1;for(let n in P)if(P.hasOwnProperty(n)){let i=P[n];if(e>=i||a){a=!0;let n=Math.floor(e/i);t+=""===t?"":":",t+=(n<10&&""!==t?"0":"")+n,e-=n*i}}return 1===t.length?`0:0${t}`:2===t.length?`0:${t}`:""===t?"0:00":t},U=function(e){return`P${A.secondsInTime(e).toUpperCase()}`},A={timeInSeconds:T,subunittimeInSeconds:function(e){let t,a=0;for(let n in P)P.hasOwnProperty(n)&&e.includes(n)&&([t,e]=e.split(n),a+=Number(t.replace(x,""))*P[n]);return a},colontimeInSeconds:function(e){let t=0,a=e.split(":");for(let e=0;e]+)?( [^>]+)?>/gi,N=/<\/(\w+)( [^>]*)?>/gi,M=/\n/gi;function S(e){return!(e in I)}function O(e,t,a,n){if(S(t=t.toLowerCase()))return"";let i="";return"lang"===t&&(i=` lang="${n.trim()}"`),`<${I[t]}${i}>`}function D(e,t){return S(t=t.toLowerCase())?"":``}function z(e){return e.split("<").length!==e.split(">").length?h(e):e.replace($,O).replace(N,D).replace(M,"
")}const q="_playlist";function H(e){const t=document.CPU.globalController;if(!t||!t.isController)return;let a=t.current_playlist;t.current_playlist=document.CPU.currentPlaylist();const n={};if(t.plane(q)||t.addPlane(q,{title:w.playlist,track:!1,panel:"nocuetime",highlight:!0,_comp:!0}),a!==t.current_playlist){if(t.clearPlane(q),0===t.current_playlist.length)return void t.removePlane(q);for(let e of t.current_playlist)n[e]={text:document.getElementById(e)?.dataset.title,link:`#${e}&t=0`};t.bulkPoints(q,n),t.element.shadowRoot.querySelector("main").insertAdjacentElement("afterend",t.planePanel(q))}if(t.highlightPoint(q,t.audiotag.id,se),e){const[a,n]=pe(e);t.focusPoint(a,n)}}function j(e){let t=e.target;if(null!==document.CPU.currentAudiotagPlaying||B(t))return;let a=Number(window.localStorage.getItem(t.currentSrc));a>0&&!X._last_play_error&&(document.CPU.seekElementAt(t,a),X.play(null,t))}HTMLAudioElement.prototype.CPU_connected=!1;let R=0;function B(e){return null==e||e.duration===1/0||null!=e.dataset.streamed}function F(e){return 0===e||e===1/0||null===e||isNaN(e)}function K(e){let t=null,a=Number(e.duration);if(isNaN(a)){const a=Number(e.dataset.duration);a>0&&(t=a)}else t=a;return t}function W(e,t=null,a=null){e.addEventListener("loadedmetadata",(()=>{t?.(a)}),r),e.setAttribute("preload","metadata")}function V(e){e.addEventListener("loadedmetadata",j,r),e.addEventListener("play",X.playOnce,o),e.addEventListener("ended",X.ended,o),e.addEventListener("ready",j,o),e.addEventListener("canplay",j,o),["ready","load","loadeddata","canplay","abort","error","emptied","play","playing","pause","ended","durationchange","loadedmetadata","timeupdate","waiting"].forEach((t=>{e.addEventListener(t,X.update,o)})),d()||["pause","ended"].forEach((t=>{e.addEventListener(t,X.pause,o)})),""===e.getAttribute("preload")&&W(e)}HTMLAudioElement.prototype.CPU_controller=function(){return this.closest(e)},HTMLAudioElement.prototype.CPU_update=function(){let e=this.CPU_controller();if(e){let t=e.CPU;t&&t.update&&t.update()}document.CPU.globalController&&document.CPU.globalController.update()};let Z=null;function G(e,t){X._last_play_error=!1,document.CPU.autoplay&&X.play(e,t)}const X={_timecode_start:0,_timecode_end:!1,_last_play_error:!1,hashOrder:async function(e,t=null){let a=!0;"string"!=typeof e&&(a="at_start"in e,e=location.hash.substr(1));let n="",i="",o=e.split("&"),r=!1;for(let e of o)if(e.includes("=")||""!==n){let[t,a]=e.split("=");switch(t){case"t":i=a||"0",r=!0;break;case"autoplay":r="1"===a;break;case"auto_play":r="true"===a}}else n=e;if(""===i||a&&!r)return void t?.();let[l,s]=i.split(",");X._timecode_start=T(l),X._timecode_end=void 0!==s&&T(s),!1!==X._timecode_end&&(X._timecode_end=X._timecode_end>X._timecode_start&&X._timecode_end),await document.CPU.jumpIdAt(n,l,t),H()},hover:function(e){const{target:t,clientX:a,targetTouches:n}=e;if(!t)return;const i=g(t),o=i.audiotag;if(F(K(o)))return void(B(o)||W(o,X.hover,e));const{x:r,width:l}=i.shadowId("time").getBoundingClientRect(),s=((a??n?.[0]?.clientX)-r)/l;i.showThrobberAt(s*i.audiotag.duration)},out:function({target:e}){g(e).hideThrobber()},throbble:function(e){const{target:t,offsetX:a}=e,n=document.CPU,i=g(t).audiotag,o=a/t.clientWidth,r=K(i);n.currentAudiotagPlaying&&!n.isAudiotagPlaying(i)&&X.pause(void 0,n.currentAudiotagPlaying),X.play(e),F(r)?i.CPU_controller()?.updateLoading?.(void 0,100):n.seekElementAt(i,e.at??o*r)},pause:function(e=null,t=null){if(!t){let{target:a}=e;t="AUDIO"===a.tagName?a:g(a).audiotag}t.pause(),document.CPU.currentAudiotagPlaying=null,window.localStorage.removeItem(t.currentSrc)},playOnce:function({target:e}){let t=document.CPU;document.CPU.lastUsed=e,t.playStopOthers&&t.currentAudiotagPlaying&&!t.isAudiotagPlaying(e)&&X.pause(void 0,t.currentAudiotagPlaying),t.currentAudiotagPlaying=e},play:function(e=null,t=null){if(!e&&X._last_play_error)return void f("play() prevented because already waiting for focus");var a;t=t??g(e.target).audiotag,X._last_play_error=!1,((a=t.currentTime)X._timecode_end)&&(X._timecode_start=0,X._timecode_end=!1);let n=t.play();n&&n.then((()=>{document.CPU.hadPlayed=!0})).catch((e=>{X._last_play_error=!0;let a=G.bind(this,t);switch(e.name){case"NotAllowedError":if(f("Auto-play prevented : Browser requires a manual interaction first."),document.addEventListener("focus",a,r),document.addEventListener("click",a,r),t.CPU_connected){let e=t.CPU_controller().CPU;e.glowBeforePlay=!0,e.setActContainer("glow")}break;case"NotSupportedError":e("The browser refuses the audio source, probably due to audio format.")}})),function(e){const t=document.CPU.globalController;if(t&&!e.isEqualNode(t.audiotag)){const a=t.focusedId();t.attachAudiotagToController(e),t.audiotag=e,t.showMain(),t.redrawAllPlanes(),t.setModeContainer(),H(a)}}(t)},toggleplay:function({target:e}){const t=g(e).audiotag;t.paused?X.play(null,t):X.pause(null,t)},key:function(e,t=1){if(e.altKey||e.ctrlKey||e.metaKey||e.shiftKey)return;let a=g(e.target),n=a.audiotag;function i(t){let i=a.audiotag.currentTime+t;i=i>0?i:0;let o=n.duration;isNaN(o)||(i=i=t.currentTime&&(i=e);i&&document.CPU.jumpIdAt(t.id,i.start)},cuechange:function(e,t){let a=document.body.classList;a.remove(Z),Z=`cpu_playing_tag_«${t.id}»_cue_«${e.id}»`,a.add(Z)},update:function({target:e}){!1!==X._timecode_end&&e.currentTime>X._timecode_end&&X.pause(void 0,e),e.CPU_update(),e.paused||B(e)||window.localStorage.setItem(e.currentSrc,String(e.currentTime))},ended:function({target:e},t=null){t=t??e;let{dataset:a,id:n}=t;if(!a.playlist)return;let i=a.playlist,o=document.CPU.playlists[i];if(void 0===o)return void f(`Named playlist ${i} not created. WTF ?`);let r=o.indexOf(n);if(r<0)return void f(`Audiotag ${n} not in playlist ${i}. WTF ?`);if(r+1===o.length)return;let l=o[r+1],s=document.getElementById(l);s?(document.CPU.seekElementAt(s,0),X.play({},s)):f(`Audiotag #${l} doesn't exists. WTF ?`)}};let Y=null;const J=["fastreward","reward","foward","fastfoward"],Q={press:function(e){let t=e.target.id?e.target:e.target.closest("button");t.id&&J.includes(t.id)&&(X[t.id](e),Y&&window.clearTimeout(Y),Y=window.setTimeout(Q.repeat,document.CPU.repeatDelay,{target:t}),e.preventDefault())},repeat:function(e){X[e.target.id](e),Y=window.setTimeout(Q.repeat,document.CPU.repeatFactor,e),e.preventDefault?.()},release:function(e){window.clearTimeout(Y),Y=null,e.preventDefault()}},ee="_chapters";function te(e){if(!e)return null;let t=null;if(e.textTracks?.length>0)for(let a of e.textTracks)"chapters"!==a.kind.toLowerCase()||!a.cues||t&&a.language.toLowerCase()!==b||(t=a);return t}async function ae(e){if(e.isController)return;const t=e.audiotag;let a=!1;const n={};if(t){const i=te(t);if(i?.cues.length>0){e.addPlane(ee,{title:w.chapters,track:"chapters"});let t=ne.bind(void 0,e);i.removeEventListener("cuechange",t),i.addEventListener("cuechange",t,o);for(let t of i.cues)if(!e.point(ee,t.id)){let e=Math.floor(t.startTime);n[t.id]={start:e,text:z(t.text),link:!0,end:t.endTime}}i.cues.length>0&&(a=!0),e.bulkPoints(ee,n),ne(e,{target:{activeCues:i.cues}})}}let i=`cpu_tag_«${t.id}»_chaptered`,r=document.body.classList;a?r.add(i):(e.removePlane(ee),r.remove(i))}function ne(e,t=null){const a=t?t.target.activeCues:te(e.audiotag)?.activeCues;let n,i=e.audiotag.currentTime;if(a?.length>0)for(let e of a)e.startTime<=i&&i{t.add("poster-loaded")}),o);let a=e.showMain.bind(e),n={pause:X.pause,play:X.play,time:X.throbble,actions:e.showActions.bind(e),back:a,poster:a,restart:X.restart,toggleplay:X.toggleplay};for(let t in n)e.shadowId(t)?.addEventListener("click",n[t],o);const i=["prevcue","fastreward","reward","foward","fastfoward","nextcue"];for(let t of i){const a=e.shadowId(t);a?.addEventListener("pointerdown",Q.press),a?.addEventListener("pointerout",Q.release),a?.addEventListener("pointerup",Q.release)}e.element.addEventListener("keydown",X.key);const l=e.shadowId("time");if(l?.addEventListener("pointerenter",X.hover,o),l?.addEventListener("pointermove",X.hover,o),l?.addEventListener("pointerout",X.out,o),l?.addEventListener("contextmenu",e.showHandheldNav.bind(e)),navigator.share&&(t.add("hasnativeshare"),e.shadowId("nativeshare")?.addEventListener("click",ie,o)),!e.audiotag)return;e.audiotag.addEventListener("durationchange",e.repositionTracks.bind(e),o),function(e){ae(e);let t=e.audiotag,a=ae.bind(void 0,e);t.addEventListener("loadedmetadata",a,r);let n=t.querySelector('track[kind="chapters"]');n&&!n._CPU_load_ev&&(n._CPU_load_ev=n.addEventListener("load",a,o))}(e),H(),e.showMain(),e.updatePlayButton(),e.emitEvent("ready"),e.updateLinks();let s=e.shadowId("canonical");s&&s.addEventListener("click",p)}const re=["poster","actions","timeline","chapters","panels","panels-title","panels-except-play"],le="with-preview",se="active-cue";let de="_borders";const ce=/^[a-zA-Z0-9\-_]+$/,ue=/^[a-zA-Z0-9\-_]+_«([a-zA-Z0-9\-_]+)(»_.*_«([a-zA-Z0-9\-_]+))?»$/;function pe(e){let t,a;return"string"==typeof e&&([,t,,a]=e?.match(ue)||[]),[t??"",a??""]}function he({target:e}){if(e.id||(e=e.closest("[id]")),!e)return;let[t,a]=pe(e.id);g(e).highlightPoint(t,a)}function me(e,t,a){return`${a?"panel":"track"}_«${e}»_point_«${t}»`}function ge(e=!1){return void 0!==e&&!1!==e}function fe({classList:e},t){t?e.remove("no"):e.add("no")}function ve({start:e,end:t}){return(null==e||e>=0)&&(null==t||t>=e)}class be{constructor(e,a){this.element=e,this.shadow=e.shadowRoot,this.audiotag=e.audiotag,this.container=a,this.mode_when_play=null,this.glowBeforePlay=!!e.hasAttribute("glow"),this.current_playlist=[],this._activecue_id=null,this.mode_was=null,this.act_was=null,e.CPU=this,this.audiotag&&!this.audiotag._CPU_planes&&(this.audiotag._CPU_planes={}),this.isController=this.element.tagName===t,this._planes={},this.audiotag||(document.CPU.globalController=this,this.audiotag=document.querySelector(i)),oe(this),this.attachAudiotagToController(this.audiotag),this.attributesChanges()}attributesChanges(){let e=null;if(this.element.hasAttribute("mode")){e=this.element.getAttribute("mode");let[t,a]=e.split(",");a&&(e=this.audiotag.paused?t:a,this.mode_when_play=a)}this.setModeContainer(e),this.element.hasAttribute("hide")&&this.setHideContainer(this.element.getAttribute("hide").split(" "))}mirroredInController(){let e=document.CPU.globalController;return e&&this.audiotag.isEqualNode(e.audiotag)}translateVTT(e){return z(e)}planeAndPointNamesFromId(e){return pe(e)}async emitEvent(e,t){this.element.dispatchEvent(new CustomEvent(`CPU_${e}`,{target:this.element,bubbles:!0,cancelable:!1,composed:!1,detail:t}))}shadowId(e){return this.shadow.getElementById(e)}setModeContainer(e=null){if(e=e??"default",this.mode_was===e)return;let t=this.container.classList;t.remove(`mode-${this.mode_was}`),t.add(`mode-${e}`),this.mode_was=e}setActContainer(e){if(this.act_was===e)return;if(!document.CPU.hadPlayed&&null!==this.act_was&&"loading"===e)return;let t=this.container.classList;t.remove("act-loading","act-buffer","act-pause","act-play","act-glow"),t.add(`act-${e}`),"play"===this.act_was&&"loading"===e&&t.add("act-buffer"),this.act_was=e}setHideContainer(e){let t=this.container.classList;for(let e of re)t.remove(`hide-${e}`);for(let a of e)a=a.toLowerCase(),re.includes(a)&&t.add(`hide-${a}`)}updatePlayButton(){let e=this.audiotag,t=e.getAttribute("preload"),a=this.shadowId("control");const n="aria-label";let i=!t||"none"!==t.toLowerCase();if(e.readyState${h(i)}`,this.container.appendChild(t),fe(t.querySelector("h6"),i),l(t)}!this.isController&&this.mirroredInController()&&document.CPU.globalController.drawPlane(e)}addPlane(e,t={}){if(!e.match(ce)||this.plane(e))return!1;if((t={track:!0,panel:!0,title:"",highlight:!0,points:{},_comp:!1,...t})._comp)this._planes[e]=t;else{if(this.isController)return!1;this.audiotag._CPU_planes=this.audiotag._CPU_planes??{},this.audiotag._CPU_planes[e]=t}return this.drawPlane(e),!0}removePlane(e){return!(!e.match(ce)||!this.plane(e)||this.isController&&!this._planes[e])&&(delete(this._planes[e]?this._planes:this.audiotag._CPU_planes)[e],this.planeTrack(e)?.remove(),this.planePanel(e)?.remove(),!this.isController&&this.mirroredInController()&&document.CPU.globalController.drawPlane(e),!0)}planePoints(e){return this.plane(e)?.points}point(e,t){return this.plane(e)?.points?.[t]}pointTrack(e,t){return this.shadowId(me(e,t,!1))}pointPanel(e,t){return this.shadowId(me(e,t,!0))}planeSort(e){this.plane(e).points=Object.fromEntries(Object.entries(this.planePoints(e)).sort((([,e],[,t])=>e.start-t.start)));let t=Object.values(this.plane(e).points);this.plane(e)._st_max=t[t.length-1]?.start??0}planePointNames(e){return Object.keys(this.planePoints(e))}panelReorder(e){if(this.planeSort(e),!this.planePanel(e))return;let t,a;for(let n of this.planePointNames(e))a=this.pointPanel(e,n),t?.insertAdjacentElement("afterend",a),t=a}drawPoint(e,t){const a=this.audiotag??document.CPU.globalController.audiotag,n=this.point(e,t),{start:i,link:o,text:r,image:l,end:s}=n;let d="#";!0===o&&(d=`#${a.id}&t=${i}`),"string"==typeof o&&(d=o);let c,u=this.planeTrack(e);if(u){c=this.pointTrack(e,t),c||(c=document.createElement("a"),c.id=me(e,t,!1),c.tabIndex=-1,c.innerHTML='',u.appendChild(c)),c.href=d,c.title=r;let a=c.querySelector("img");fe(a,l),a.src=l||"",c.querySelector("img").innerHTML=r,this.positionTimeElement(c,i,s)}let p,h=this.planeNav(e);if(h){p=this.pointPanel(e,t),p||(p=document.createElement("li"),p.id=me(e,t,!0),p.innerHTML='',h.appendChild(p)),p.querySelector("a").href=d,p.querySelector("strong").innerHTML=r;let a=p.querySelector("time");a.dateTime=U(i),a.innerText=L(i)}this.emitEvent("drawPoint",{planeName:e,pointName:t,pointData:n,elementPointTrack:c,elementPointPanel:p}),!this.isController&&this.mirroredInController()&&document.CPU.globalController.drawPoint(e,t)}addPoint(e,t,a={}){let n=Number(a.start);return!(!t.match(ce)||!this.plane(e)||this.point(e,t)||!ve(a))&&(!(!this._planes[e]&&this.isController)&&(a.start=n,this.plane(e).points[t]=a,this.emitEvent("addPoint",{planeName:e,pointName:t,pointData:a}),this.plane(e)._st_max>n?this.panelReorder(e):(this.drawPoint(e,t),this.plane(e)._st_max=n),!0))}bulkPoints(e,t={}){if(!this.plane(e))return!1;if(!this._planes[e]&&this.isController)return!1;for(let[e,a]of Object.entries(t))if(!e.match(ce)||!ve(a))return!1;t={...this.plane(e).points,...t},this.plane(e).points=t,this.emitEvent("bulkPoints",{planeName:e,pointDataGroup:t});let a=this.planeNav(e);return a&&(a.innerHTML=""),this.refreshPlane(e),!0}editPoint(e,t,a){let n=this.plane(e);if(!n)return!1;let i=this.point(e,t);if(!i)return!1;let{start:o}=a;o=Number(o);let r=null!=o&&o!==i.start;if(!ve(a={...i,...a}))return!1;n.points[t]=a,this.drawPoint(e,t),r&&this.panelReorder(e),this.emitEvent("editPoint",{planeName:e,pointName:t,pointData:a}),n._st_max{e.remove()}),this.container);for(let e of Object.keys({...this._planes,...this.audiotag._CPU_planes}))this.drawPlane(e),this.refreshPlane(e);ne(this)}repositionTracks(){if(!F(this.audiotag.duration))for(let e in this.audiotag._CPU_planes){if(this.plane(e).track)for(let t of this.planePointNames(e)){let a=this.pointTrack(e,t),{start:n,end:i}=this.point(e,t);this.positionTimeElement(a,n,i)}}}removeHighlightsPoints(e,t="with-preview",a=!0){if(l(`#track_«${e}» .${t}, #panel_«${e}» .${t}`,(e=>{e.classList.remove(t)}),this.container),a&&this.mirroredInController()){let a,n=document.CPU.globalController;a=this.isController?g(n.audiotag):n,a.removeHighlightsPoints(e,t,!1)}}highlightPoint(e,t,a="with-preview",n=!0){if(this.removeHighlightsPoints(e,a,n),this.plane(e)?.highlight&&(this.pointTrack(e,t)?.classList.add(a),this.pointPanel(e,t)?.classList.add(a),n&&this.mirroredInController())){let n,i=document.CPU;n=this.isController?g(i.globalController.audiotag):i.globalController,n.highlightPoint(e,t,a,!1)}}focusPoint(e,t){const a=this.pointPanel(e,t)?.querySelector("a")??this.pointTrack(e,t);return!!a&&(a.focus(),!0)}focused(){return this.shadow.querySelector(":focus")}focusedId(){const e=this.focused();if(!e)return;const t=""!=e.id?e.id:e.closest("[id]").id;return""==t?null:t}prevFocus(){we(this,!1)}nextFocus(){we(this,!0)}}function we(e,t){const a=e.planeNames();if(0==a.length)return;const n=t=>{let{track:a,panel:n,points:i}=e.plane(t);return(!1!==a||!1!==n)&&i&&Object.keys(i).length>0};let i,o,r,l,d=e.focused();if(d&&(d.id||(d=d.closest("[id]")),[o,i]=pe(d.id)),""!=i&&(l=e.planePointNames(o),r=s(l,i,t?1:-1)),!r){if(o=t?(e=>{for(let t=a.indexOf(e)+1;t{for(let t=a.indexOf(e)-1;t>=0;t--){let e=a[t];if(n(e))return e}})(o),!o)return;let i=e.planePointNames(o);r=i[t?0:i.length-1]}e.focusPoint(o,r)}function ye([{target:a}]){const n=g(a);let i=n.element,o="audio";if(!i.querySelector(o)&&i.tagName!==t)return r="