window.Mediasite=window.Mediasite||{},Mediasite.Player=Mediasite.Player||{},Mediasite.Player.PlayCoverHelper=function(){function emptyInfo(){return{Title:"",ThumbnailUrl:null,AirDateUnixTimeInMs:0,ServerClockSkew:0,PlayStatus:MediasitePlayCover.PRESENTATION_STATUS.NotAvailable,IsLiveCountdownEnabled:!1,IsLiveIndicationDelayed:!1,PlayCoverOnlyWhenEmbedded:!1,AllowedPlayerIFrameAPISites:["*"]}}function makeServiceCall(n,t,i,r){var f=JSON.stringify({presentationId:t}),u=new XMLHttpRequest;u.addEventListener("load",function(){var n;if(u.status<400){if(n=u.response,typeof n=="string")try{n=JSON.parse(n)}catch(t){n={}}i(n&&n.d)}else r()}),u.open("POST",n),u.responseType="json",u.setRequestHeader("Content-type","application/json"),u.send(f)}function ServerStrategy(n){this.contextSupportsPlayCover=!0,this.getPlayCoverInfo=function(t,i,r){function success(n){var t=n||emptyInfo();t.ServerClockSkew=+new Date-t.ServerTimeForClockSkew,i(t)}makeServiceCall(n+"/GetPlayCoverInfo",t,success,r)},this.getPresentationStatus=function(t,i,r){function success(n){i({status:n&&n.PlayStatus})}makeServiceCall(n+"/GetLiveStatus",t,success,r)}}function OtherStrategy(){this.contextSupportsPlayCover=!1,this.getPlayCoverInfo=function(n,t){t(emptyInfo())},this.getPresentationStatus=function(n,t){t({status:MediasitePlayCover.PRESENTATION_STATUS.NotAvailable})}}function getPlayCoverStrategy(t,i){return t===n?new ServerStrategy(i):new OtherStrategy}function createPlayCover(n,t){var i=MediasitePlayCover.create(Mediasite.Player.Localization.PlayCover);return i.options.shouldShowTitle=!0,i.options.shouldShowPlayButton=!0,i.options.backgroundImageUrl="Javascript/Players/SmartPlayer/images/default_slide.png",i.options.shouldDelayLiveUntilAirDate=n.IsLiveIndicationDelayed,i.title=n.Title,i.airDateUnixTime=n.AirDateUnixTimeInMs+n.ServerClockSkew,i.presentationStatus=n.PlayStatus,i.thumbnailUrl=n.ThumbnailUrl,i.defaultThumbnailUrl=n.DefaultThumbnailUrl,i.clickAction=t,i}function CrudeApi(n,t,i){function isAllowedOrigin(n){return u.match(n)}function messageHandler(n){var t,i,u=n&&n.origin;if(isAllowedOrigin(u)&&(t=messageEventToMessageData(n),i=t&&typeof t.command=="string"&&t.command,i==="setPlayCoverCustomHtml"&&typeof r.onSetPlayCoverCustomHtml=="function")){htmlString=t.params&&t.params[0]&&t.params[0].htmlString||"";r.onSetPlayCoverCustomHtml(htmlString)}}function listenForMessages(){n.removeEventListener("message",messageHandler,!1),n.addEventListener("message",messageHandler,!1)}function raiseIFrameApiEvent(n){t&&t.postMessage(JSON.stringify({event:n,data:{}}),"*")}function messageEventToMessageData(n){var t="MediasitePlayer:",i=n&&n.data||"",r;return i.indexOf(t)!==0?{}:(r=i.substring(t.length),JSON.parse(r))}var r=this,u=Mediasite.Player.ApiOrigin.createOriginMatcherFromList(i);window.isAllowedOrigin=isAllowedOrigin,r.raisePlayCoverReady=function(){raiseIFrameApiEvent("playcoverready")},r.raisePlayCoverClick=function(){raiseIFrameApiEvent("playcoverclick")},r.onSetPlayCoverCustomHtml=function(){},listenForMessages()}function PlayCoverHelper(n){function getQueryStringBoolOrDefault(n,t){var i=SFMP.Utility.getQueryParam(n)||"",r=i.toLowerCase()==="true",u=i.toLowerCase()==="false";return r||u?r:t}function fixThumbnailUrl(n,t){function getConnector(){return r.indexOf("?")>-1?"&":"?"}if(!t)return t;var f,u,i,r=t;return u=getCollectionIdFromQueryString(),i=getEffectiveAuthTicket(n,u),i&&(r+=getConnector()+SFMP.Utility.queryStringParam.AUTHTICKET+"="+i),r}function getEffectiveAuthTicket(n,t){var i,u,r=[];for(t&&r.push(t),n&&r.push(n),i=0;i0){r=t;break}return r}function getPresentationStatus(t,i){var r=function(n){i(n)},u=function(){i(null)};n.getPresentationStatus(t,r,u)}var t=this;t.strategy=n||new OtherStrategy,t.getPlayCoverInfo=function(t,i){var r=function(n){n.ThumbnailUrl=fixThumbnailUrl(t,n.ThumbnailUrl),i(n)},u=function(){i(null)};n.getPlayCoverInfo(t,r,u)},t.shouldShowPlayCover=function(n){var i=t.getQueryStringOptions();return t.strategy.contextSupportsPlayCover?typeof i.enable=="boolean"?i.enable:n.PlayCoverOnlyWhenEmbedded?SFMP.Utility.isEmbedded():!0:!1},t.makePlayCover=function(n,i){var f={enabled:null,showTitle:!0,showPlayButton:!0,showCountdown:n.IsLiveCountdownEnabled},u,r,e;return r=createPlayCover(n,i),u=t.getQueryStringOptions(f),r.options.shouldShowTitle=u.showTitle,r.options.shouldShowPlayButton=u.showPlayButton,r.options.shouldShowLiveCountdown=u.showCountdown,r},t.makePresentationStatusGetter=function(n){return function(t){getPresentationStatus(n,t)}},t.getQueryStringOptions=function(n){var t=getQueryStringBoolOrDefault,n=n||{},i={enable:t(SFMP.Utility.queryStringParam.COVER_ENABLE,n.enable),showTitle:t(SFMP.Utility.queryStringParam.COVER_TITLE,n.showTitle),showPlayButton:t(SFMP.Utility.queryStringParam.COVER_PLAYBUTTON,n.showPlayButton),showCountdown:t(SFMP.Utility.queryStringParam.COVER_COUNTDOWN,n.showCountdown)};return typeof i.enable!="boolean"&&(i.enable=t(SFMP.Utility.queryStringParam.COVER_ENABLE_OLD,n.enable)),i},t.makeSetPlayCoverCustomHtmlCallback=function(n){return function(t){n.customMessageHtml=SFMP.Utility.sanitizeHtmlString(t)}}}function createPlayCoverHelper(n,t){var i=getPlayCoverStrategy(n,t);return new PlayCoverHelper(i)}function createCrudeApi(n,t,i){return new CrudeApi(n,t,i)}var n=1,t=2;return{create:createPlayCoverHelper,createCrudeApi:createCrudeApi}}()