"use strict";(this.webpackChunk_msteams_react_web_client=this.webpackChunk_msteams_react_web_client||[]).push([[551429],{118854:(t,e,a)=>{a.r(e),a.d(e,{createPluginInstance:()=>l});var i=a(971510),o=a(881267),s=a(664110),n=a(855009),d=a(313356),r=function(){function t(){}return t.prototype.storeItemLastWatchedPosition=function(t,e,a,i,o){if(this.getItemLastWatchedPosition(t)!==e){var s=this.getStoredLastWatchedPositions();s[t]={lastWatchedPositionInSeconds:e,lastUpdatedTime:(new Date).getTime(),lastWatchedStoringSessionInfo:{lastWatchedStoringPlaybackSessionId:a,lastWatchedStoringHostApp:i,lastWatchedStoringHostView:o}},localStorage.setItem(d.J,JSON.stringify(s))}},t.prototype.removeItemLastWatchedPosition=function(t){var e=this.getStoredLastWatchedPositions();delete e[t],localStorage.setItem(d.J,JSON.stringify(e))},t.prototype.getItemLastWatchedPosition=function(t){var e;return null===(e=this.getStoredLastWatchedPositions()[t])||void 0===e?void 0:e.lastWatchedPositionInSeconds},t.prototype.getItemLastUpdatedTimestamp=function(t){var e,a=null===(e=this.getStoredLastWatchedPositions()[t])||void 0===e?void 0:e.lastUpdatedTime;if(a)return new Date(a)},t.prototype.getLastWatchedStoringSessionTelemetryInfo=function(t){var e,a,i,o,s,n,d=this.getStoredLastWatchedPositions();return{lastWatchedStoringPlaybackSessionId:null===(a=null===(e=d[t])||void 0===e?void 0:e.lastWatchedStoringSessionInfo)||void 0===a?void 0:a.lastWatchedStoringPlaybackSessionId,lastWatchedStoringHostApp:null===(o=null===(i=d[t])||void 0===i?void 0:i.lastWatchedStoringSessionInfo)||void 0===o?void 0:o.lastWatchedStoringHostApp,lastWatchedStoringHostView:null===(n=null===(s=d[t])||void 0===s?void 0:s.lastWatchedStoringSessionInfo)||void 0===n?void 0:n.lastWatchedStoringHostView}},t.prototype.removeOldStoredLastWatchedPositions=function(){for(var t=this.getStoredLastWatchedPositions();Object.keys(t).length>300;){var e=this.getOldestItem();e&&delete t[e]}localStorage.setItem(d.J,JSON.stringify(t))},t.prototype.getOldestItem=function(){for(var t=(new Date).getTime(),e=void 0,a=0,i=Object.entries(this.getStoredLastWatchedPositions());a<i.length;a++){var o=i[a],s=o[0],n=o[1];n.lastUpdatedTime<t&&(t=n.lastUpdatedTime,e=s)}return e},t.prototype.getStoredLastWatchedPositions=function(){return JSON.parse(localStorage.getItem(d.J)||"{}")},t}();function l(t){return new c(t)}var c=function(){function t(t){this.metadata=t}return t.prototype.phaseHandler=function(t,e){var a,n;return(0,i.__awaiter)(this,void 0,void 0,(function(){var d,l,c;return(0,i.__generator)(this,(function(i){return"BeforeUi"===t&&(0,o.Pf)()?(this.api=e,void 0!==e.player.mediaDurationInSecondsV2.value&&-1!==e.player.mediaDurationInSecondsV2.value&&e.player.mediaDurationInSecondsV2.value<10?[2]:(this.lastWatchedPositionManager=new r,d=this.lastWatchedPositionManager.getItemLastWatchedPosition(this.metadata.itemId.value),l=this.lastWatchedPositionManager.getItemLastUpdatedTimestamp(this.metadata.itemId.value),c=this.lastWatchedPositionManager.getLastWatchedStoringSessionTelemetryInfo(this.metadata.itemId.value),d&&l&&(null===(n=null===(a=this.metadata.playbackOptions)||void 0===a?void 0:a.value)||void 0===n?void 0:n.restoredStartTimeToLastWatchedPosition)&&e.log.appLogic({name:"RestoredPlaybackToLastWatchedPosition",lastWatchedPositionInSeconds:d,lastUpdatedTimestamp:l,lastWatchedStoringPlaybackSessionId:null==c?void 0:c.lastWatchedStoringPlaybackSessionId,lastWatchedStoringHostApp:null==c?void 0:c.lastWatchedStoringHostApp,lastWatchedStoringHostView:null==c?void 0:c.lastWatchedStoringHostView}),this.timeUpdateUnsubscribe=e.player.currentTimeInSeconds.subscribe((0,s.n)(this.onTimeUpdate.bind(this),200)),[2,Promise.resolve()])):[2]}))}))},t.prototype.unloadHandler=function(){var t,e;null===(t=this.timeUpdateUnsubscribe)||void 0===t||t.call(this),null===(e=this.lastWatchedPositionManager)||void 0===e||e.removeOldStoredLastWatchedPositions()},t.prototype.onTimeUpdate=function(t){var e,a,i,o,s;if(void 0!==t)if(void 0!==this.api.player.mediaDurationInSecondsV2.value&&-1!==this.api.player.mediaDurationInSecondsV2.value&&(this.api.player.mediaDurationInSecondsV2.value-t<4||t<=5))null===(e=this.lastWatchedPositionManager)||void 0===e||e.removeItemLastWatchedPosition(this.metadata.itemId.value);else{var d=t;!!this.api.onePlayerSettingsStore.getSetting("isStartTimeHiddenSectionEnabled","boolean")&&(null===(a=this.metadata.playbackItem)||void 0===a?void 0:a.areHiddenSectionsApplied.value)&&(d=(0,n._E)(this.metadata.playbackItem.hiddenSections.value,t)),null===(i=this.lastWatchedPositionManager)||void 0===i||i.storeItemLastWatchedPosition(this.metadata.itemId.value,d,this.metadata.telemetryContext.onePlayerContext.playbackSessionId,null===(o=this.metadata.telemetryContext.hostContext)||void 0===o?void 0:o.hostApp,null===(s=this.metadata.telemetryContext.hostContext)||void 0===s?void 0:s.hostView)}},t}()}}]);
//# sourceMappingURL=https://local.teams.office.com/sourcemaps/hashed-assets/pluginLastWatchedPosition-fbeb7f78a1204f4d.js.map