// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-3.0 (()=>{"use strict";var e={d:(t,o)=>{for(var n in o)e.o(o,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:o[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{init:()=>s});let o="https://wwwb-events.archive.org/events",n=Date.now();const i=["demux-file-size-error","video-loading-error","video-not-archived","itag-not-found","demux-error","demux-audio-error","demux-video-error","demux-source-buffer-error","error-loading-demux-data","flyjs-error","jwplayer-init-fail","jwplayer-error"],r=["time-to-load","time-to-play","time-to-fail","time-to-stop","time-to-play-jwplayer","time-to-load-jwplayer","time-to-stop-jwplayer","time-to-fail-jwplayer","time-to-load-demux","time-to-play-demux","time-to-stop-demux","time-to-fail-demux","time-to-load-flvjs","time-to-play-flvjs","time-to-stop-flvjs","time-to-fail-flvjs"];function d(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",d=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";if(!o)return null;if(!e)return console.error("No video id passed to reportBack!",t),null;let l=t||"",a=d||"";r.indexOf(t)>-1&&(l="videoTiming",a={timingType:t,time:Date.now()-n}),i.indexOf(t)>-1&&(l="videoError",a={errorType:t,errorMessage:String(d)});const s={eventType:"video-playback",payload:{videoId:e,playbackUrl:window.location.href,eventType:l,data:a}};if(navigator.sendBeacon)try{navigator.sendBeacon(o,JSON.stringify(s))}catch(e){console.error("Could not send back video analytics:",e),o=""}return null}let l=!1,a={prefix:"/web"};function s(e){l?console.log("already initialized"):(l=!0,"string"==typeof e?a={prefix:e}:Object.assign(a,e),n=new Date,function(){const e=f;e(),c=setInterval(e,u)}())}const u=1e3;let c;function f(){const e=m.length;!function(){const e=document.location.href.match(/\/embed\/([-_a-zA-Z0-9]{11})/);if(e)console.log("this is a embed for %s",e[1]),y("#player",()=>({vid:e[1]}));else{y("div#flashcontent"),y("div#playerDiv > div#movie_player"),y("div#watch-player.flash-player"),y("div#watch7-player.flash-player");document.querySelector("ytd-app")?y("ytd-app ytd-watch-flexy ytd-player")||y("ytd-app ytd-player:not(.ytd-video-preview)"):y("#player:not(.skeleton) #player-api")}}(),e!=m.length&&console.log("players=%o",m);for(const e of m)e.target&&(e.disconnected||(e.target.isConnected?e.discoverVideoInfo():(console.log("%o: node %s was removed from DOM",e,e.target),e.disconnected=!0)))}const v=[null,null,"The requested video has been archived but is not currently available for playback.","We have not been able to archive the video associated with this YouTube page.",null,null,"The Wayback Machine does not have this video archived."];class p{constructor(e,t){this.target=e,t&&(this.vinfo=t)}playerNode(){const e=this.target.querySelector("embed#movie_player");if(e)return e;const t=this.target.querySelector("div.html5-video-player");return t||this.target}discoverVideoInfo(){if(!this.vinfo){const e=function(e){for(let t=0;t{this.replaced||this.replacePlayer()}))}async getCDXVideoInfo(){const e=this.vinfo,t="/__wb/videoinfo?vtype=youtube&vid="+e.vid,o=await fetch(t);if(200==o.status){const t=await o.json();if(console.log("Response: ",t),t&&null!=t.status_code){e.video_status_code=t.status_code,console.log("Returned from video info server: ",t);const o=v[t.status_code];e.video_status=o||"Status of this video is unknown at this time",this.displayError(e.video_status),d(e.vid,"video-loading-error",e.video_status)}else if(t&&void 0!==t.formats){if(t.dmux)return e.dmuxAudio=t.formats.audio,e.dmuxVideo=t.formats.video,e.dmux=!0,e.location="",!0;for(const o of t.formats){console.log("format:",o),e.location="/web/"+o.timestamp+"oe_/"+o.url,e.ptype=o.ext,e.ctype="video/"+o.ext;break}}}(null==e.location||e.dmux)&&await this.getVideoStreamInfo()}async getVideoStreamInfo(){const e=this.vinfo,t=j("yt/"+e.vid),o=await fetch(t,{method:"HEAD"});if(200!=o.status)return console.log("%s -> %s",t,o.status),void 0===e.video_status&&(e.video_status="Sorry, the Wayback Machine does not have this video ("+e.vid+") archived."),this.displayError(e.video_status),void d(e.vid,"video-not-archived",e.video_status);const n=o.headers.get("content-location");e.location=n||t,console.log("vinfo.location=%s",e.location);const i=o.headers.get("content-type");e.ctype=i,i.indexOf("webm")>=0?e.ptype="webm":i.indexOf("flv")>=0?e.ptype="flv":i.indexOf("mp4")>=0?e.ptype="video/mp4":e.ptype="webm"}replacePlayer(){this.vinfo&&(this.vinfo.location||this.vinfo.dmux)&&(this.target.origId||"watch-player"==this.target.id||(this.target.origId=this.target.id,this.target.id="--wm--"+(this.target.id||Date.now())),function(e){const t=e.vinfo;if(!t||!t.location&&!t.dmux)return!1;const o=e.playerNode();if(!o)return!1;e.fullImgUrl=j("yt/img/"+e.vinfo.vid),window.ytplayer&&(window.ytplayer.config={},window.ytplayer.load=function(){});if(E){const e=o.querySelector("video.html5-main-video");if(e)return console.log("replacing src of %o with %s",e,t.location),e.src=t.location,!0}return async function(e,t,o,n){jwplayer||console.error("jwplayer is not loaded");if(e.setupInitiated)return;const i=e.playerNode();if(!i)return!1;i.id||(i.id="--wm--"+Date.now());i.parentElement.style.zIndex=1e3;const r=i.clientWidth||"100%",l=i.clientHeight||"100%";if(e.setupInitiated=!0,"flv"==e.vinfo.ptype){function a(){i.style.display="flex",i.style.flexDirection="column";try{const t=document.createElement("video");t.autoplay=!0,t.controls=!0,t.style.width="100%";const o=i.querySelector("embed");o?i.replaceChild(t,o):i.appendChild(t);const n=flvjs.createPlayer({type:"flv",url:e.vinfo.location});n.attachMediaElement(t),n.load(),d(e.vinfo.vid,"time-to-load-flvjs",null),t.addEventListener("play",()=>{d(e.vinfo.vid,"time-to-play-flvjs",null)}),t.addEventListener("pause",()=>{d(e.vinfo.vid,"time-to-stop-flvjs",null)})}catch(t){console.error(`error setting up flvjs: ${t}`),d(e.vinfo.vid,"flyjs-error",t),d(e.vinfo.vid,"time-to-fail-flvjs",null),i.parentElement.removeChild(i)}}if(console.log("initializing flvjs on %o (vo=%o)",i,e),"undefined"==typeof flvjs){const s=document.createElement("script");s.src=`${__wm.sp()}js/flv.min.js`,s.addEventListener("load",a),document.head.appendChild(s)}else a();return}if(console.log("vinfo coming in: ",e.vinfo),!e.vinfo.dmux){console.log("Single-source video, using JWPlayer on %o (vo=%o)",i,e),jwplayer.key="sZbikYlI/xtW0U/3Tw1DOdjC1EahhtUCJF5KggVdqDY=";const u=jwplayer(i);return u.setup?(u.setup({height:l,width:r,autostart:o,image:e.fullImgUrl,primary:x()?"flash":"html5",playlist:[{image:e.fullImgUrl,sources:[{file:e.vinfo.location,type:e.vinfo.ptype}]}],events:{onError:n,onReady:function(){d(e.vinfo.vid,"time-to-load-jwplayer",null)},onPlay:function(){d(e.vinfo.vid,"time-to-play-jwplayer",null)},onPause:function(){d(e.vinfo.vid,"time-to-stop-jwplayer",null)}},analytics:{enabled:!1}}),!0):(console.error("failed to initialize jwplayer"),d(e.vinfo.vid,"jwplayer-init-fail",null),!1)}try{await async function(e,t){const o=e.dmuxAudio||[],n=e.dmuxVideo||[],i=n.length?n[0].url:"",r=o.length?o[0].url:"";if(!i)throw"No video URL";if(!r)throw"No audio URL";const l=i?`/web/${n[0].timestamp}/`+i:"",a=r?`/web/${o[0].timestamp}/`+r:"",s=S(n[0],e.vid),u=S(o[0],e.vid);if(!MediaSource.isTypeSupported(s))throw"Unsupported video codec";if(!MediaSource.isTypeSupported(u))throw"Unsupported audio codec";for(;t.firstChild;)t.firstChild.remove();const c=document.createElement("video");t.appendChild(c),c.setAttribute("controls",!0),c.style.height="100%",c.style.width="100%",c.parentElement.style.height="100%",c.parentElement.style.width="100%";const f=new MediaSource;let v,p;c.src=URL.createObjectURL(f);let m=0,h=0;const y=4194304;let g=!0,w=!0,b=!1,x=!1,E=0,j=0,_=0,A=0,T=!1,I=!1;const L=[],M=[];let k=!1,C=!1,O=!1,B=!1,q=!1,D=!1;function U(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];t.indexOf("video")>-1&&(v=f.addSourceBuffer(s),v.addEventListener("updateend",z("video")),v.addEventListener("error",function(t){console.error("Video SourceBuffer error:",v.error),d(e.vid,"demux-video-error",v.error),d(e.vid,"time-to-fail-demux",null)}),g&&(P("video",m),g=!1)),t.indexOf("audio")>-1&&(p=f.addSourceBuffer(u),p.addEventListener("updateend",z("audio")),p.addEventListener("error",function(t){console.error("Audio SourceBuffer error:",p.error),d(e.vid,"demux-audio-error",p.error),d(e.vid,"time-to-fail-demux",null)}),w&&(P("audio",h),w=!1))}function z(t){return function(){"video"===t&&D?D=!1:"audio"===t&&q?q=!1:(console.log(t+" loaded"),"video"===t?(T=!1,b||(m+=E,v.buffered.length?(L[L.length-1].endTimeStamp=v.buffered.end(0),L[L.length-1].startTimeStamp=L.length>1?L[L.length-2].endTimeStamp:0):console.error("No video source buffered length!",v.buffered,L),_&&(E=_)&&(b=!0,console.log("Video finished loading")),b&&x&&(d(e.vid,"time-to-load-demux",null),c.play()),b||P("video",m))):(I=!1,x||(h+=j,p.buffered.length?(M[M.length-1].endTimeStamp=p.buffered.end(0),M[M.length-1].startTimeStamp=M.length>1?M[M.length-2].endTimeStamp:0):console.error("No audio source buffered length!",p.buffered,M),A&&(j=A)&&(x=!0,console.log("Audio finished loading")),b&&x&&(d(e.vid,"time-to-load-demux",null),c.play()),x||P("audio",h))))}}function V(e){if(e&&!e.updating)try{e.abort();for(let t=0;tt&&en&&eo||e>i?(0===M.filter(e=>e.start===a).length&&(I=!1,P("audio",a)),0===L.filter(e=>e.start===s).length&&(T=!1,P("video",s))):(n>e&&(V(p),M.length=0,j=Math.max(0,a-1),I=!1,P("audio",a)),t>e&&(V(v),L.length=0,E=Math.max(0,s-1),T=!1,P("video",s)))});let N=null,$=null;function P(t,o){const n="video"===t?v:p,i="video"===t?l:a;if(n.updating)return void console.warn("SourceBuffer is still updating. Skipping fetchAndAppend for "+t);if("video"===t&&T)return void console.warn("Already appending video. Skipping fetchAndAppend.");if("audio"===t&&I)return void console.warn("Already appending audio. Skipping fetchAndAppend.");const r=new AbortController,s=r.signal;let u=o+y-1;"video"===t?(N&&N.abort(),N=r,T=!0,u=_?Math.min(u,_-1):u):($&&$.abort(),$=r,I=!0,u=A?Math.min(u,A-1):u),fetch(i,{headers:{Range:"bytes="+o+"-"+u},signal:s}).then(o=>{if(206===o.status||200===o.status)return o.arrayBuffer();console.error(`Error fetching data for ${t}:`,o.status),d(e.vid,"error-loading-demux-data",o.status),d(e.vid,"time-to-fail-demux",null),W(n)}).then(e=>{if(e)try{Y(t,new Uint8Array(e),o,e.byteLength)}catch(n){"QuotaExceededError"===n.name?F(t,e,o):console.error("AppendBuffer error: ",n)}}).catch(n=>{"AbortError"===n.name?(console.error("Fetch aborted for "+t),R(t,o)):(console.error(`Error fetching data for ${t}: `,n," Error name: ",n.name),d(e.vid,"error-loading-demux-data",n.name),"video"===t?k=!1:C=!1,R(t,o))})}function R(e,t){("audio"===e&&C||"video"===e&&k)&&setTimeout(()=>{"video"===e?(k=!1,T=!1):(C=!1,I=!1),P(e,t)},1e3)}function W(e,t){f.removeSourceBuffer(t),U([e])}const F=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;const n=c.currentTime,i="video"===e?L[0]:M[0];n>=i.startTimeStamp&&n<=i.endTimeStamp?"video"===e?B=!0:O=!0:H(e,t,o)};function H(e,t,o){const n="video"===e?v:p,i="video"===e?L.shift():M.shift();"video"===e?D=!0:q=!0,n.remove(i.startTimeStamp,i.endTimeStamp);const r=setInterval(()=>{n.updating||(clearInterval(r),t?Y(e,new Uint8Array(t),o,t.byteLength):("video"===e?k=!0:C=!0,R(e,o)))},500)}function Y(t,o,n,i){const r="video"===t?v:p;r.updating?console.warn("SourceBuffer is still updating. Aborting appendBuffer for "+t+", offset: ",n):(r.addEventListener("error",function(t){console.error("SourceBuffer error:",r.error),d(e.vid,"demux-source-buffer-error",r.error.name)}),r.appendBuffer(o),"video"===t?(E=i,L.push({start:n,end:n+i-1})):"audio"===t&&(j=i,M.push({start:n,end:n+i-1})))}function Z(t,o){fetch(t,{method:"HEAD"}).then(e=>{const t=e.headers.get("Content-Length");o(parseInt(t))}).catch(t=>{console.error("Error getting file size:",t),d(e.vid,"demux-file-size-error",t),d(e.vid,"time-to-fail-demux",null)})}c.addEventListener("canplay",()=>{d(e.vid,"time-to-play-demux",null)}),c.addEventListener("pause",()=>{d(e.vid,"time-to-stop-demux",null)}),c.addEventListener("timeupdate",e=>{const t=c.currentTime;B&&L[0].endTimeStamp<=t&&(H("video",null,L[L.length-1].end+1),B=!1,T=!1,P("video",L[L.length-1].end+1)),O&&M[0].endTimeStamp<=t&&(H("audio",null,M[M.length-1].end+1),O=!1)})}(e.vinfo,i)}catch(c){console.error(`Multistream error: ${c}`),d(e.vinfo.vid,"demux-error",c.name)}}(e,t.ptype,!1,function(t){console.error("Error returned from jwplayer: ",t),d(e.vinfo.vid,"jwplayer-error",t.message),d(e.vinfo.vid,"time-to-fail-jwplayer",null)})}(this)&&(this.replaced=!0))}displayError(e){const t=this.target;let o=t.querySelector("div#wm-video-error");o||(o=document.createElement("div"),o.id="wm-video-error",o.setAttribute("style","position:absolute;top:0;background:#000000c0;z-index:9999;padding:20px;left:10%;right:10%;text-align:center;height:10%;color:#fff;border-bottom-left-radius:20px;border-bottom-right-radius:20px;border:solid 4px #ffffff;border-top:none;font-size:12pt;"),t.insertBefore(o,t.firstChild)),o.innerHTML=e}}var m=[];function h(e,t){if(e._wm_videoplayer)return!1;const o=new p(e,t);return e._wm_videoplayer=o,e.classList.add("wm-videoplayer"),m.push(o),!0}function y(e,t){t=t||function(){return null};let o=!1;for(const n of document.querySelectorAll(e))h(n,t(n))&&(console.log("player el=%o %o",n,n._wm_videoplayer),o=!0);return o}const g=/\?video_id=([-_a-zA-Z0-9]+)/,w=/\&video_id=([-_a-zA-Z0-9]+)/,b=[function(e){const t=(e.querySelector("video")||e).src;if(console.log("video.src = %s",t),t){const e=t.match(g);if(e)return{vid:e[1]}}return null},function(e){if("EMBED"!=e.tagName&&!(e=e.querySelector("embed")))return null;const t=e.getAttribute("flashvars");if(console.log("attr flashvars = %s",t),t){const e=t.match(w);if(e)return{vid:e[1]}}return null},function(e){const t=e.querySelector("div.ytp-cued-thumbnail-overlay-image");if(console.log("thumbnail = %o",t),t){const e=window.getComputedStyle(t).backgroundImage;if(e){const t=e.match(/\/vi\/([-_a-zA-Z0-9]+)\/hqdefault/);if(t)return{vid:t[1]}}}return null},function(e){const t=function(e,t){let o=e.parentElement;for(;o&&o!=document.body;){if(o.tagName==t)return o;o=o.parentElement}return null}(e,"YTD-WATCH-FLEXY");if(console.log("ytd-watch-flexy = %o",t),t){const e=t.getAttribute("video-id");if(t.hasAttribute("player-unavailable")){t.removeAttribute("player-unavailable");const e=t.querySelector("#error-screen");e?e.parentElement.removeChild(e):console.log("#error-screen element is not found")}if(e)return{vid:e}}return null},function(e){const t=document.querySelector('div#content meta[itemprop="videoId"]');if(console.log('div#content meta[itemprop="vidoId"] = %o',t),t){const e=t.getAttribute("content");if(e)return{vid:e}}return null},function(e){const t=document.querySelector('div#watch7-content meta[itemprop="videoId"]');if(console.log('div#watch7-content meta[itemprop="videoId"] = %o',t),t){const e=t.content;if(e)return{vid:e}}return null},function(e){if("undefined"!=typeof ytplayer&&ytplayer.config&&ytplayer.config.args){const e=ytplayer.config.args.video_id;if(e)return{vid:e}}}];function x(){return-1!=navigator.userAgent.indexOf("Safari")&&-1!=navigator.userAgent.indexOf("Mac")&&-1==navigator.userAgent.indexOf("Chrome")}const S=(e,t)=>{let o;try{o=e.codec.split(", ").filter(e=>"Unknwn"!==e).join(", ")}catch(o){return console.error("itag not found: ",e.itag,e),d(t,"itag-not-found",e.itag),d(t,"time-to-fail-demux",null),null}if(e.mimetype&&o)return`${e.mimetype}; codecs=${o}`};const E=!1;function j(e){return`${a.prefix}/2oe_/http://wayback-fakeurl.archive.org/${e}`}window._wmVideos_=t})(); // @license-end