1!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.VideoPressIframeApi=t():e.VideoPressIframeApi=t()}(this,()=>(()=>{"use strict";var e={d:(t,n)=>{for(var s in n)e.o(n,s)&&!e.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:n[s]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},t={};function n(e,t,n){return(t=function(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}e.d(t,{default:()=>s});const s=(e,t=null)=>{const s="channel_init",a=new class{constructor(e,t=null){n(this,"initListener",()=>{let e=0;const t=Math.random().toString(36),n=()=>{window.removeEventListener("message",s),clearInterval(a)},s=e=>{e.source===this.iframe.contentWindow&&e.data&&e.data.uid===t&&"iframe_ack_response"===e.data.event&&(n(),this.onIframeLoaded())};window.addEventListener("message",s);const a=setInterval(()=>{e>40?n():this.iframe.contentWindow&&(this.iframe.contentWindow.postMessage({event:"iframe_ack",uid:t},"*"),e++)},300);this.iframe.addEventListener("load",()=>{n(),this.onIframeLoaded()})}),n(this,"onIframeLoaded",()=>{this.channel||(this.channel=new MessageChannel,this.channel.port1.onmessage=e=>this.onMessageReceived(e),this.iframe.contentWindow.postMessage({event:s},"*",[this.channel.port2]))}),n(this,"onChannelInitialized",()=>{this.onReadyCallback&&this.onReadyCallback()}),n(this,"postMessage",(e,t=null,n=null)=>{if(null===this.channel)return;const s={event:e};null!==t&&Array.isArray(t)&&(s.args=t),null!==n&&(s.xchgId=n),this.channel.port1.postMessage(s)}),n(this,"generateXchgId",()=>++this.currentXchgId),n(this,"generateListenerId",()=>++this.currentEventListenerId),n(this,"callMethod",(e,t=null)=>{const n=this.generateXchgId();return new Promise((s,a)=>{this.pendingResolvers[n]={resolve:s,reject:a},this.postMessage(e,t,n)})}),n(this,"listen",(e,t)=>{if(!this.eventListenersByEvent[e])return!1;const n=this.generateListenerId();return this.eventListenersById[n]={event:e,callback:t},this.eventListenersByEvent[e].push(n),n}),n(this,"stopListening",e=>{if(e=Number(e),this.eventListenersById[e]){const t=this.eventListenersById[e],n=this.eventListenersByEvent[t.event].findIndex(t=>e===t);void 0!==n&&this.eventListenersByEvent[t.event].splice(n,1),delete this.eventListenersById[e]}}),n(this,"onMessageReceived",e=>{const t=e.data.event??!1;if(!t)return;if(s===t)return void this.onChannelInitialized();const n=e.data.xchgId??0;n?this.onMessageReceivedWithXchgId(n,t,e):"event"===t&&this.onEventReceived(e)}),n(this,"onEventReceived",e=>{const t=e.data.type??"";if(!t||!this.eventListenersByEvent[t])return;const n=e.data.args??[];this.eventListenersByEvent[t].forEach(e=>{const t=this.eventListenersById[e]??null;t&&t.callback(...n)})}),n(this,"onMessageReceivedWithXchgId",(e,t,n)=>{if(!this.pendingResolvers[e])return;const s=this.pendingResolvers[e];delete this.pendingResolvers[e],"error"===t?s.reject(n.data.code,n.data.message):"result"===t&&s.resolve(n.data.message.result)}),this.currentXchgId=0,this.currentEventListenerId=0,this.pendingResolvers={},this.eventListenersById={},this.eventListenersByEvent={"info.infoUpdated":[],"status.fullscreenChanged":[],"status.playerStatusChanged":[],"status.playbackTimeUpdated":[],"status.timeUpdate":[],"status.chaptersChapterChange":[],"status.chaptersTrackChange":[],"status.borderColorsChanged":[],"status.error":[],"status.segmentsWatched":[],"status.playbackRateUpdate":[]},this.onReadyCallback=t,this.channel=null,this.iframe=e,this.initListener()}}(e,t);return{controls:{play:()=>new Promise((e,t)=>a.callMethod("controls.play",[]).then(e).catch(t)),pause:()=>new Promise((e,t)=>a.callMethod("controls.pause",[]).then(e).catch(t)),seek:e=>new Promise((t,n)=>{if(e=Number(e),!isNaN(e))return a.callMethod("controls.seek",[e]).then(t).cat
1ch(n);n("Invalid argument provided for timeMs")}),volume:e=>new Promise((t,n)=>{if(e=Number(e),!isNaN(e))return a.callMethod("controls.volume",[e]).then(t).catch(n);n("Invalid argument provided for volume")}),mute:e=>new Promise((t,n)=>(e=(!("toLowerCase"in Object(e))||"false"!==e.toLowerCase()&&"0"!==e)&&Boolean(e),a.callMethod("controls.mute",[e]).then(t).catch(n))),fullscreen:e=>new Promise((t,n)=>(e=(!("toLowerCase"in Object(e))||"false"!==e.toLowerCase()&&"0"!==e)&&Boolean(e),a.callMethod("controls.fullscreen",[e]).then(t).catch(n))),setChapters:e=>new Promise((t,n)=>{if(Array.isArray(e))return a.callMethod("controls.setChapters",[e]).then(t).catch(n);n("Invalid argument provided for chapters")})},customize:{get:e=>new Promise((t,n)=>(e=String(e),a.callMethod("customize.get",[e]).then(t).catch(n))),set:e=>new Promise((t,n)=>{if("object"==typeof e)return a.callMethod("customize.set",[e]).then(t).catch(n);n("Invalid argument provided for options")})},info:{onInfoUpdated:e=>a.listen("info.infoUpdated",e),offInfoUpdated:e=>a.stopListening(e),duration:(e=JSON.parse(!1))=>new Promise((t,n)=>(e=(!("toLowerCase"in Object(e))||"false"!==e.toLowerCase()&&"0"!==e)&&Boolean(e),a.callMethod("info.duration",[e]).then(t).catch(n))),guid:()=>new Promise((e,t)=>a.callMethod("info.guid",[]).then(e).catch(t)),title:()=>new Promise((e,t)=>a.callMethod("info.title",[]).then(e).catch(t)),poster:()=>new Promise((e,t)=>a.callMethod("info.poster",[]).then(e).catch(t)),privacy:()=>new Promise((e,t)=>a.callMethod("info.privacy",[]).then(e).catch(t)),getThumbnailSample:e=>new Promise((t,n)=>{if(e=Number(e),!isNaN(e))return a.callMethod("info.getThumbnailSample",[e]).then(t).catch(n);n("Invalid argument provided for count")}),enableWatchedSegments:()=>new Promise((e,t)=>a.callMethod("info.enableWatchedSegments",[]).then(e).catch(t)),disableWatchedSegments:()=>new Promise((e,t)=>a.callMethod("info.disableWatchedSegments",[]).then(e).catch(t)),toggleWatchedSegments:()=>new Promise((e,t)=>a.callMethod("info.toggleWatchedSegments",[]).then(e).catch(t)),watched:()=>new Promise((e,t)=>a.callMethod("info.watched",[]).then(e).catch(t)),resetWatched:()=>new Promise((e,t)=>a.callMethod("info.resetWatched",[]).then(e).catch(t))},status:{fullscreen:()=>new Promise((e,t)=>a.callMethod("status.fullscreen",[]).then(e).catch(t)),onFullscreenChanged:e=>a.listen("status.fullscreenChanged",e),offFullscreenChanged:e=>a.stopListening(e),player:()=>new Promise((e,t)=>a.callMethod("status.player",[]).then(e).catch(t)),onPlayerStatusChanged:e=>a.listen("status.playerStatusChanged",e),offPlayerStatusChanged:e=>a.stopListening(e),audio:()=>new Promise((e,t)=>a.callMethod("status.audio",[]).then(e).catch(t)),playbackTime:()=>new Promise((e,t)=>a.callMethod("status.playbackTime",[]).then(e).catch(t)),onPlaybackTimeUpdated:e=>a.listen("status.playbackTimeUpdated",e),offPlaybackTimeUpdated:e=>a.stopListening(e),onTimeUpdate:e=>a.listen("status.timeUpdate",e),offTimeUpdate:e=>a.stopListening(e),onChaptersChapterChange:e=>a.listen("status.chaptersChapterChange",e),offChaptersChapterChange:e=>a.stopListening(e),onChaptersTrackChange:e=>a.listen("status.chaptersTrackChange",e),offChaptersTrackChange:e=>a.stopListening(e),onBorderColorsChanged:e=>a.listen("status.borderColorsChanged",e),offBorderColorsChanged:e=>a.stopListening(e),borderColors:()=>new Promise((e,t)=>a.callMethod("status.borderColors",[]).then(e).catch(t)),onError:e=>a.listen("status.error",e),offError:e=>a.stopListening(e),onSegmentsWatched:e=>a.listen("status.segmentsWatched",e),offSegmentsWatched:e=>a.stopListening(e),onPlaybackRateUpdate:e=>a.listen("status.playbackRateUpdate",e),offPlaybackRateUpdate:e=>a.stopListening(e)}}};return t.default})());; 2// listen for rlt authentication events and pass them to children of this document. 3( function() { 4 var currentToken; 5 var parentOrigin; 6 var iframeOrigins; 7 var registeredIframes = []; 8 var initializationListeners = []; 9 var hasBeenInitialized = false; 10 var RLT_KEY = 'jetpack:wpcomRLT'; 11 12 // should we inject RLT into this iframe? 13 function rltShouldAuthorizeIframe( frameOrigin ) { 14 if ( ! Array.isArray( iframeOrigins ) ) { 15 return false;
16 } 17 return iframeOrigins.includes( frameOrigin ); 18 } 19 20 function rltInvalidateWindowToken( token, target, origin ) { 21 if ( target && typeof target.postMessage === 'function' ) { 22 try { 23 target.postMessage( JSON.stringify( { 24 type: 'rltMessage', 25 data: { 26 event: 'invalidate', 27 token: token, 28 sourceOrigin: window.location.origin, 29 }, 30 } ), origin ); 31 } catch ( err ) { 32 return; 33 } 34 } 35 } 36 37 /** 38 * PUBLIC METHODS 39 */ 40 window.rltInvalidateToken = function( token, sourceOrigin ) { 41 // invalidate in current context 42 if ( token === currentToken ) { 43 currentToken = null; 44 } 45 46 // remove from localstorage, but only if in a top level window, not iframe 47 try { 48 if ( window.location === window.parent.location && window.localStorage ) { 49 if ( window.localStorage.getItem(RLT_KEY) === token ) { 50 window.localStorage.removeItem(RLT_KEY); 51 } 52 } 53 } catch( e ) { 54 console.info("localstorage access for invalidate denied - probably blocked third-party access", window.location.href); 55 } 56 57 // invalidate in registered iframes 58 for ( const [ frameOrigin, frameWindow ] of registeredIframes ) { 59 if ( frameOrigin !== sourceOrigin ) { 60 rltInvalidateWindowToken( token, frameWindow, frameOrigin ); 61 } 62 } 63 64 // invalidate in parent 65 if ( parentOrigin && parentOrigin !== sourceOrigin && window.parent ) { 66 rltInvalidateWindowToken( token, window.parent, parentOrigin ); 67 } 68 } 69 70 window.rltInjectToken = function( token, target, origin ) { 71 if ( target && typeof target.postMessage === 'function' ) { 72 try { 73 target.postMessage( JSON.stringify( { 74 type: 'loginMessage', 75 data: { 76 event: 'login', 77 success: true, 78 type: 'rlt', 79 token: token, 80 sourceOrigin: window.location.origin, 81 }, 82 } ), origin ); 83 } catch ( err ) { 84 return; 85 } 86 } 87 }; 88 89 window.rltIsAuthenticated = function() { 90 return !! currentToken; 91 }; 92 93 window.rltGetToken = function() { 94 return currentToken; 95 }; 96 97 window.rltAddInitializationListener = function( listener ) { 98 // if RLT is already initialized, call the listener immediately 99 if ( hasBeenInitialized ) { 100 listener( currentToken ); 101 } else { 102 initializationListeners.push( listener ); 103 } 104 }; 105 106 // store the token in localStorage 107 window.rltStoreToken = function( token ) { 108 currentToken = token; 109 try { 110 if ( window.location === window.parent.location && window.localStorage ) { 111 window.localStorage.setItem( RLT_KEY, token ); 112 } 113 } catch( e ) { 114 console.info("localstorage access denied - probably blocked third-party access", window.location.href); 115 } 116 } 117 118 window.rltInitialize = function( config ) { 119 if ( ! config || typeof window.postMessage !== 'function' ) { 120 return; 121 } 122 123 currentToken = config.token; 124 iframeOrigins = config.iframeOrigins; 125 parentOrigin = config.parentOrigin; // needed? 126 127 // load token from localStorage if possible, but only in top level window 128 try { 129 if ( ! currentToken && window.location === window.parent.location && window.localStorage ) { 130 currentToken = window.localStorage.getItem(RLT_KEY); 131 } 132 } catch( e ) { 133 console.info("localstorage access denied - probably blocked third-party access", window.location.href); 134 } 135 136 // listen for RLT events from approved origins 137 window.addEventListener( 'message', function( e ) { 138 var message = e && e.data; 139 if ( typeof message === 'string' ) { 140 try { 141 message = JSON.parse( message ); 142 } catch ( err ) { 143 return; 144 } 145 } 146 147 var type = message && message.type; 148 var data = message && message.data; 149 150 if ( type === 'loginMessage' ) { 151 if ( data && data.type === 'rlt' && data.token !== currentToken ) { 152 // put into localStorage if running in top-level window (not iframe) 153 rltStoreToken( data.token ); 154 155 // send to registered iframes 156 for ( const [ frameOrigin, frameWindow ] of registeredIframes ) { 157 rltInjectToken( currentToken, frameWindow, frameOrigin ); 158 } 159 160 // send to the parent, unless the event was sent _by_ the parent 161 if ( parentOrigin && parentOrigin !== data.sourceOrigin && window.parent ) { 162 rltInjectToken( currentToken, window.parent, parentOrigin ); 163 } 164 } 165 } 166 167 if ( type === 'rltMessage' ) {
168 if ( data && data.event === 'invalidate' && data.token === currentToken ) { 169 rltInvalidateToken( data.token ); 170 } 171 172 if ( data && data.event === 'register' ) { 173 if ( rltShouldAuthorizeIframe( e.origin ) ) { 174 registeredIframes.push( [ e.origin, e.source ] ); 175 if ( currentToken ) { 176 rltInjectToken( currentToken, e.source, e.origin ); 177 } 178 } 179 } 180 } 181 } ); 182 183 initializationListeners.forEach( function( listener ) { 184 listener( currentToken ); 185 } ); 186 187 initializationListeners = []; 188 189 // inform the parent that we are ready to receive the RLT token 190 window.parent.postMessage( { 191 type: 'rltMessage', 192 data: { 193 event: 'register' 194 }, 195 }, '*' ); 196 197 hasBeenInitialized = true; 198 }; 199} )(); 200;
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.