@playkit-js/playkit-js-providers 2.40.2-canary.0-c7a43ae → 2.41.0-canary.0-2452bbc
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/playkit-analytics-service.js +1 -1
- package/dist/playkit-analytics-service.js.map +1 -1
- package/dist/playkit-bookmark-service.js +1 -1
- package/dist/playkit-bookmark-service.js.map +1 -1
- package/dist/playkit-ott-provider.js +1 -1
- package/dist/playkit-ott-provider.js.map +1 -1
- package/dist/playkit-ovp-provider.js +1 -1
- package/dist/playkit-ovp-provider.js.map +1 -1
- package/dist/playkit-stats-service.js +1 -1
- package/dist/playkit-stats-service.js.map +1 -1
- package/package.json +9 -9
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var s=e();for(var r in s)("object"==typeof exports?exports:t)[r]=s[r]}}(self,(()=>(()=>{"use strict";var t={d:(e,s)=>{for(var r in s)t.o(s,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:s[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{NAME:()=>_t,Provider:()=>It,ProviderParser:()=>$,RequestBuilder:()=>Q,ResponseTypes:()=>s,VERSION:()=>Rt});var s={};function r(t){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r(t)}function a(t,e,s){return(e=function(t){var e=function(t,e){if("object"!==r(t)||null===t)return t;var s=t[Symbol.toPrimitive];if(void 0!==s){var a=s.call(t,"string");if("object"!==r(a))return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"===r(e)?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}t.r(s),t.d(s,{BaseServiceResult:()=>h,KalturaAccessControlMessage:()=>v,KalturaAccessControlModifyRequestHostRegexAction:()=>E,KalturaBaseEntryListResponse:()=>m,KalturaBumper:()=>_,KalturaDrmPlaybackPluginData:()=>f,KalturaFlavorAsset:()=>R,KalturaMediaEntries:()=>T,KalturaMediaEntry:()=>g,KalturaMetadata:()=>A,KalturaMetadataListResponse:()=>C,KalturaPlaybackContext:()=>O,KalturaPlaybackSource:()=>I,KalturaPlaylist:()=>S,KalturaRuleAction:()=>y,KalturaUIConfResponse:()=>P,KalturaUserEntry:()=>w,KalturaUserEntryListResponse:()=>D});const i={get:()=>({VERSION:"",DEBUG:{value:"",name:""},ERROR:{value:"",name:""},INFO:{value:"",name:""},OFF:{value:"",name:""},TIME:{value:"",name:""},TRACE:{value:"",name:""},WARN:{value:"",name:""},createDefaultHandler:()=>{},debug:()=>{},enabledFor:()=>{},error:()=>{},get:()=>{},getLevel:()=>{},info:()=>{},log:()=>{},setHandler:()=>{},setLevel:()=>{},time:()=>{},timeEnd:()=>{},trace:()=>{},useDefaults:()=>{},warn:()=>{}})};let o={};function n(t){return i.get(t)}const l=n,c=t=>{let e;return Array.isArray(t)?(e=t.length>0?t.slice(0):[],e.forEach(((t,s)=>{("object"==typeof t||Array.isArray(t)&&t.length>0)&&(e[s]=c(t))}))):"object"==typeof t?(e=Object.assign({},t),Object.keys(e).forEach((t=>{("object"==typeof e[t]||Array.isArray(e[t])&&e[t].length>0)&&(e[t]=c(e[t]))}))):e=t,e},d={serviceUrl:"https://cdnapisec.kaltura.com/api_v3",cdnUrl:"https://cdnapisec.kaltura.com",serviceParams:{apiVersion:"3.3.0",format:1},useApiCaptions:!0,loadThumbnailWithKs:!1,replaceHostOnlyManifestUrls:!1};class u{static set(t){t&&Object.assign(d,t)}static get(){return c(d)}}class h{constructor(t){a(this,"hasError",!1),"KalturaAPIException"===t.objectType?(this.hasError=!0,this.error=new p(t.code,t.message)):t.error&&"KalturaAPIException"===t.error.objectType?(this.hasError=!0,this.error=new p(t.error.code,t.error.message)):this.data=t}}class p{constructor(t,e){this.code=t,this.message=e}}class g{constructor(t){this.id=t.id,this.referenceId=t.referenceId,this.externalSourceType=t.externalSourceType,this.name=t.name,this.description=t.description,this.dataUrl=t.dataUrl,this.type=t.type,this.entryType=t.mediaType,this.flavorParamsIds=t.flavorParamsIds,this.duration=t.duration,this.poster=t.thumbnailUrl,this.status=t.status,this.dvrStatus=t.dvrStatus,this.tags=t.tags,this.createdAt=t.createdAt,this.updatedAt=t.updatedAt,this.creatorId=t.creatorId,this.endDate=t.endDate,this.plays=t.plays,this.views=t.views,this.downloadUrl=t.downloadUrl}}a(g,"EntryType",{AUTOMATIC:{value:-1},EXTERNAL_MEDIA:{value:"externalMedia.externalMedia"},MEDIA_CLIP:{value:1},MIX:{value:2},PLAYLIST:{value:5},DATA:{value:6},LIVE_STREAM:{value:7},LIVE_CHANNEL:{value:8},DOCUMENT:{value:10}}),a(g,"MediaType",{VIDEO:{value:1},IMAGE:{value:2},AUDIO:{value:5},LIVE_STREAM_FLASH:{value:201},LIVE_STREAM_WINDOWS_MEDIA:{value:202},LIVE_STREAM_REAL_MEDIA:{value:203},LIVE_STREAM_QUICK_TIME:{value:204}}),a(g,"EntryStatus",{ERROR_IMPORTING:-2,ERROR_CONVERTING:-1,SCAN_FAILURE:"virusScan.ScanFailure",IMPORT:0,INFECTED:"virusScan.Infected",PRECONVERT:1,READY:2,DELETED:3,PENDING:4,MODERATE:5,BLOCKED:6,NO_CONTENT:7}),a(g,"EntryModerationStatus",{PENDING_MODERATION:1,APPROVED:2,REJECTED:3,FLAGGED_FOR_REVIEW:4,MODERATE:5,AUTO_APPROVED:6});class m extends h{constructor(t){super(t),this.hasError||(this.totalCount=t.totalCount,this.totalCount>0&&(this.entries=[],t.objects.map((t=>this.entries.push(new g(t))))))}}class y{constructor(t){this.type=t.type}}a(y,"Type",{DRM_POLICY:"drm.DRM_POLICY",BLOCK:1,PREVIEW:2,LIMIT_FLAVORS:3,ADD_TO_STORAGE:4,LIMIT_DELIVERY_PROFILES:5,SERVE_FROM_REMOTE_SERVER:6,REQUEST_HOST_REGEX:7,LIMIT_THUMBNAIL_CAPTURE:8});class E extends y{constructor(t){super(t),this.pattern=t.pattern,this.replacement=t.replacement,this.replacmenServerNodeId=t.replacmenServerNodeId,this.checkAliveTimeoutMs=t.checkAliveTimeoutMs}}class f{constructor(t){this.scheme=t.scheme,this.licenseURL=t.licenseURL,this.certificate=t.certificate}}a(f,"Scheme",{"drm.PLAYREADY_CENC":"com.microsoft.playready","drm.WIDEVINE_CENC":"com.widevine.alpha","fairplay.FAIRPLAY":"com.apple.fairplay",WIDEVINE_CENC:"com.widevine.alpha",PLAYREADY_CENC:"com.microsoft.playready",FAIRPLAY:"com.apple.fairplay"});class I{constructor(t){a(this,"drm",[]),this.format=t.format,this.deliveryProfileId=t.deliveryProfileId,this.url=t.url,this.protocols=t.protocols,this.flavorIds=t.flavorIds,t.drm&&t.drm.map((t=>this.drm.push(new f(t))))}hasDrmData(){return this.drm&&this.drm.length>0}hasFlavorIds(){return!!this.flavorIds&&this.flavorIds.length>0}getProtocol(t){let e="";if(this.protocols&&this.protocols.length>0)this.protocols.split(",").forEach((s=>{s===t&&(e=s)}));else if("http"===t)return t;return e}}class _{constructor(t){this.entryId=t.entryId,this.clickThroughUrl=t.url,this.sources=t.sources?t.sources.map((t=>new I(t))):[]}}class R{constructor(t){this.id=t.id,this.flavorParamsId=t.flavorParamsId,this.fileExt=t.fileExt,this.bitrate=t.bitrate,this.width=t.width,this.height=t.height,this.id=t.id,this.frameRate=t.frameRate,this.isOriginal=t.isOriginal,this.isWeb=t.isWeb,this.containerFormat=t.containerFormat,this.videoCodecId=t.videoCodecId,this.status=t.status,this.language=t.language,this.label=t.label}}a(R,"Status",{ERROR:-1,QUEUED:0,CONVERTING:1,READY:2,DELETED:3,NOT_APPLICABLE:4,TEMP:5,WAIT_FOR_CONVERT:6,IMPORTING:7,VALIDATING:8,EXPORTING:9});class T extends h{constructor(t){super(t),this.hasError||(this.entries=[],t.map((t=>{const e=new g(t);e.type!==g.EntryType.DOCUMENT.value&&this.entries.push(e)})))}}class A{constructor(t){this.id=t.id,this.metadataProfileId=t.metadataProfileId,this.metadataProfileVersion=t.metadataProfileVersion,this.metadataProfileId=t.metadataProfileId,this.metadataObjectType=t.metadataObjectType,this.objectId=t.objectId,this.version=t.version,this.created=new Date(0),this.created.setUTCSeconds(t.createdAt),this.updated=new Date(0),this.updated.setUTCSeconds(t.updatedAt),this.status=t.status,this.xml=t.xml}}a(A,"ObjectType",{AD_CUE_POINT:"adCuePointMetadata.AdCuePoint",ANNOTATION:"annotationMetadata.Annotation",CODE_CUE_POINT:"codeCuePointMetadata.CodeCuePoint",THUMB_CUE_POINT:"thumbCuePointMetadata.thumbCuePoint",ENTRY:1,CATEGORY:2,USER:3,PARTNER:4,DYNAMIC_OBJECT:5}),a(A,"Status",{VALID:1,INVALID:2,DELETED:3});class C extends h{constructor(t){super(t),this.hasError||(this.totalCount=t.totalCount,this.totalCount>0&&(this.metas=[],t.objects.map((t=>this.metas.push(new A(t))))))}}class v{constructor(t){this.message=t.message,this.code=t.code}}class O extends h{constructor(t){if(super(t),a(this,"sources",[]),a(this,"actions",[]),a(this,"messages",[]),a(this,"flavorAssets",[]),a(this,"bumperData",[]),!this.hasError){const e=t.messages;e&&e.map((t=>this.messages.push(new v(t))));const s=t.actions;s&&s.map((t=>{t.type===y.Type.REQUEST_HOST_REGEX?this.actions.push(new E(t)):this.actions.push(new y(t))}));const r=t.sources;r&&r.map((t=>this.sources.push(new I(t))));const a=t.flavorAssets;a&&a.map((t=>this.flavorAssets.push(new R(t))));const i=t.bumperData;i&&i.map((t=>this.bumperData.push(new _(t))))}}hasBlockAction(){return void 0!==this.getBlockAction()}getBlockAction(){return this.actions.find((t=>t.type===y.Type.BLOCK))}getErrorMessages(){return this.messages}getRequestHostRegexAction(){const t=this.actions.find((t=>t.type===y.Type.REQUEST_HOST_REGEX));if(t instanceof E)return t}}class S{constructor(t){this.id=t.id,this.name=t.name,this.description=t.description,this.poster=t.thumbnailUrl}}class P extends h{constructor(t){super(t),this.hasError||(this.name=t.name,this.description=t.description,this.objTypeAsString=t.objTypeAsString,this.width=t.width,this.height=t.height,this.htmlParams=t.htmlParams,this.swfUrl=t.swfUrl,this.confFilePath=t.confFilePath,this.confFile=t.confFile,this.confFileFeatures=t.confFileFeatures,this.config=t.config,this.confVars=t.confVars,this.useCdn=t.useCdn,this.tags=t.tags,this.swfUrlVersion=t.swfUrlVersion,this.created=new Date(0),this.created.setUTCSeconds(t.createdAt),this.updated=new Date(0),this.updated.setUTCSeconds(t.updatedAt),this.html5Url=t.description,this.version=t.description,this.partnerTags=t.description,this.objType=t.description,this.creationMode=t.description)}}a(P,"Type",{PLAYER:1,CONTRIBUTION_WIZARD:2,SIMPLE_EDITOR:3,ADVANCED_EDITOR:4,PLAYLIST:5,APP_STUDIO:6,KRECORD:7,PLAYER_V3:8,KMC_ACCOUNT:9,KMC_ANALYTICS:10,KMC_CONTENT:11,KMC_DASHBOARD:12,KMC_LOGIN:13,PLAYER_SL:14,CLIENTSIDE_ENCODER:15,KMC_GENERAL:16,KMC_ROLES_AND_PERMISSIONS:17,CLIPPER:18,KSR:19,KUPLOAD:20,WEBCASTING:21}),a(P,"CreationMode",{WIZARD:2,ADVANCED:3});class w{constructor(t){this.playlistLastEntryId=t.playlistLastEntryId,this.entryId=t.entryId,this.id=t.id,this.userId=t.userId,this.partnerId=t.partnerId,this.status=t.status,this.createdAt=t.createdAt,this.updatedAt=t.updatedAt}}class D extends h{constructor(t){super(t),this.hasError||(this.totalCount=t.totalCount,this.entries=[],this.totalCount>0&&t.objects.map((t=>this.entries.push(new w(t)))))}}class b{static build(t){const e=u.get(),s=e.serviceUrl.substr(0,e.serviceUrl.lastIndexOf("/")),{partnerId:r,entryId:a,ks:i,uiConfId:o,format:n,protocol:l,extension:c,flavorIds:d}=t;if(!s||isNaN(Number.parseInt(r))||!a||!n||!l)return"";let h=s;return s.endsWith("/")||(h+="/"),h+="p/"+r+"/sp/"+r+"00/playManifest/entryId/"+a+"/protocol/"+l+"/format/"+n,d?h+="/flavorIds/"+d:o&&(h+="/uiConfId/"+o),""!==i&&(h+="/ks/"+i),""!==c&&(h+="/a."+c),o&&""!==d&&(h+="?uiConfId="+o),h}}class M{static xmlToJson(t){let e={};if(1===t.nodeType){if(t.attributes.length>0){e["@attributes"]={};for(let s=0;s<t.attributes.length;s++){const r=t.attributes.item(s);e["@attributes"][r.nodeName]=r.nodeValue}}}else 3===t.nodeType&&(e=t.nodeValue);if(t.hasChildNodes())for(let s=0;s<t.childNodes.length;s++){const r=t.childNodes.item(s),a=r.nodeName;if(void 0===e[a])e[a]=this.xmlToJson(r);else{if(void 0===e[a].push){const t=e[a];e[a]=[],e[a].push(t)}e[a].push(this.xmlToJson(r))}}return e}}const L={DASH:{name:"dash",mimeType:"application/dash+xml",pathExt:"mpd"},HLS:{name:"hls",mimeType:"application/x-mpegURL",pathExt:"m3u8"},WVM:{name:"wvm",mimeType:"video/wvm",pathExt:"wvm"},MP4:{name:"mp4",mimeType:"video/mp4",pathExt:"mp4"},MP3:{name:"mp3",mimeType:"audio/mpeg",pathExt:"mp3"}},N=new Map([["mpegdash",L.DASH],["applehttp",L.HLS],["url",L.MP4]]);function U(t){const e=N.get(t);return!!e&&e.name===L.MP4.name}class k{constructor(){this.progressive=[],this.dash=[],this.hls=[],this.image=[]}map(t,e){if(e)switch(e.name){case L.MP4.name:this.progressive.push(t);break;case L.DASH.name:this.dash.push(t);break;case L.HLS.name:this.hls.push(t)}}toJSON(){const t={progressive:[],dash:[],hls:[],image:[]};return this.progressive.forEach((e=>t.progressive.push(e.toJSON()))),this.hls.forEach((e=>t.hls.push(e.toJSON()))),this.dash.forEach((e=>t.dash.push(e.toJSON()))),t.image=this.image,t}}class x{constructor(){this.metadata=new Map,this.sources=new k,this.type=x.Type.UNKNOWN}toJSON(){return{id:this.id,name:this.name,sources:this.sources.toJSON(),duration:this.duration,dvrStatus:this.dvrStatus,status:this.status,metadata:this.metadata,type:this.type,poster:this.poster,assetReferenceType:this.assetReferenceType,downloadUrl:this.downloadUrl}}}a(x,"Type",{VOD:"Vod",LIVE:"Live",IMAGE:"Image",AUDIO:"Audio",UNKNOWN:"Unknown"}),a(x,"DvrStatus",{ON:1,OFF:0});class V{constructor(t,e,s){this.licenseUrl=t,this.scheme=e,s&&(this.certificate=s)}toJSON(){const t={licenseUrl:this.licenseUrl,scheme:this.scheme};return this.certificate&&(t.certificate=this.certificate),t}}class j{toJSON(){const t={id:this.id,url:this.url,mimetype:this.mimetype};return this.bandwidth&&(t.bandwidth=this.bandwidth),this.width&&(t.width=this.width),this.height&&(t.height=this.height),this.label&&(t.label=this.label),this.drmData&&this.drmData.length>0&&(t.drmData=[],this.drmData.forEach((e=>{Array.isArray(t.drmData)&&t.drmData.push(e.toJSON())}))),t}}class F{constructor(){this.items=[]}}class q{constructor(){this.items=[]}}class H{constructor(t){this.url=t.url,this.clickThroughUrl=t.clickThroughUrl}}const B={SRT:"1",DFXP:"2",WEBVTT:"3",CAP:"4"},K={3:"vtt",1:"srt"};class W{static createConfig(t,e){return t.map((t=>{let s=t.url,r=K[t.format];return[B.DFXP,B.CAP].includes(t.format)&&(s=t.webVttUrl,r=K[B.WEBVTT]),s=J(s,e),{default:!!t.isDefault,type:r,language:t.languageCode,label:t.label,url:s}}))}}class G{constructor(t){this.id=t.id,this.url=G.extractBaseThumbnailUrl(t.dataUrl),this.mimetype=""}static extractBaseThumbnailUrl(t){return t.match(".+entry_id/[a-zA-Z0-9_]+/")[0].slice(0,-1)}}class Y{static getMediaEntry(t,e,s,r){const a=new x,i=r.entry,o=r.playBackContextResult,n=r.metadataListResult,l=o.sources;return a.sources=Y._getParsedSources(l,t,e,s,i,o),Y._fillBaseData(a,i,n),a.type!==x.Type.LIVE&&u.get().useApiCaptions&&o.data.playbackCaptions&&(a.sources.captions=W.createConfig(o.data.playbackCaptions,t)),a}static addKsToUrl(t,e){let s;return e?(s=-1!==t.split("?")[0].replace(/^.*[\\/]/,"").indexOf(".")?-1===t.indexOf("?")?"?ks=":"&ks=":"/ks/",t+s+e):t}static getPlaylist(t){const e=new F,s=t.playlistData,r=t.playlistItems.entries,a=t.playlistUserEntries.entries;return e.id=s.id,e.name=s.name,e.description=s.description,e.poster=s.poster,e.playlistLastEntryId=a.map((t=>t.playlistLastEntryId))[0],r.forEach((t=>{const s=new x;Y._fillBaseData(s,t),e.items.push(s)})),e}static getEntryList(t){const e=new q;return t.playlistItems.entries.forEach((t=>{const s=new x;Y._fillBaseData(s,t),e.items.push(s)})),e}static getBumper(t,e,s){const r=t.playBackContextResult,a=r.bumperData[0];if(a){const t=(a&&a.sources).find((t=>U(t.format)));if(t){const i=Y._parseProgressiveSources(t,r,e,s,0,a.entryId);if(i[0])return new H({url:i[0].url,clickThroughUrl:a.clickThroughUrl})}}}static _fillBaseData(t,e,s){return t.poster=e.poster,t.id=e.id,t.duration=e.duration,t.downloadUrl=e.downloadUrl||"",t.metadata=Y._parseMetadata(s),t.metadata.description=e.description||"",t.metadata.entryId=e.id||"",t.metadata.name=e.name||"",e.createdAt&&(t.metadata.createdAt=e.createdAt),e.updatedAt&&(t.metadata.updatedAt=e.updatedAt),e.creatorId&&(t.metadata.creatorId=e.creatorId),e.endDate&&(t.metadata.endDate=e.endDate),e.views&&(t.metadata.views=e.views),e.plays&&(t.metadata.plays=e.plays),t.metadata.tags=e.tags||"",t.status=e.status,t.type=Y._getEntryType(e.entryType,e.type),t.type===x.Type.LIVE&&(t.dvrStatus=e.dvrStatus),t}static _getEntryType(t,e){let s=x.Type.UNKNOWN;switch(t){case g.MediaType.IMAGE.value:s=x.Type.IMAGE;break;case g.MediaType.AUDIO.value:s=x.Type.AUDIO;break;default:switch(e){case g.EntryType.MEDIA_CLIP.value:s=x.Type.VOD;break;case g.EntryType.LIVE_STREAM.value:case g.EntryType.LIVE_CHANNEL.value:s=x.Type.LIVE;break;default:s=x.Type.UNKNOWN}}return s}static _getParsedSources(t,e,s,r,a,i){const o=new k;return a.type===g.EntryType.EXTERNAL_MEDIA.value?(()=>{const t=new j;t.mimetype="video/youtube",t.url=a.referenceId,t.id=a.id+"_youtube",o.progressive.push(t)})():a.entryType===g.MediaType.IMAGE.value?o.image.push(new G(a)):t&&t.length>0&&(t.filter((t=>!U(t.format))).forEach((t=>{const n=Y._parseAdaptiveSource(t,i,e,s,r,a.id);if(n){const e=N.get(t.format);o.map(n,e)}})),(()=>{const n=t.find((t=>U(t.format)&&""!==t.getProtocol(Y._getBaseProtocol())));o.progressive=Y._parseProgressiveSources(n,i,e,s,r,a.id)})()),o}static _parseAdaptiveSource(t,e,s,r,a,i){const o=new j;if(t){let n="";const l=N.get(t.format),c=t.getProtocol(Y._getBaseProtocol()),d=t.deliveryProfileId,u=t.format;let h="";if(l&&(h=l.pathExt,o.mimetype=l.mimeType),t.hasFlavorIds()?(!h&&e.flavorAssets&&e.flavorAssets.length>0&&(h=e.flavorAssets[0].fileExt),n=b.build({entryId:i,flavorIds:t.flavorIds,format:u,ks:s,partnerId:r,uiConfId:a,extension:h,protocol:c})):n=Y.addKsToUrl(t.url,s),!n){const t=`failed to create play url from source, discarding source: (${i}_${d}), ${u}`;return Y._logger.warn(t),null}if(o.url=n,o.id=i+"_"+d+","+u,t.hasDrmData()){const e=[];t.drm.forEach((t=>{e.push(new V(t.licenseURL,f.Scheme[t.scheme],t.certificate))})),o.drmData=e}}return o}static _parseProgressiveSources(t,e,s,r,a,i){const o=[],n=[];if(t){const l=t.getProtocol(Y._getBaseProtocol()),c=t.format,d=t.deliveryProfileId,u=d+","+c;e.flavorAssets.map((t=>{const e=new j;e.id=t.id+u,e.mimetype="mp3"===t.fileExt?"audio/mp3":"video/mp4",e.height=t.height,e.width=t.width,e.bandwidth=1024*t.bitrate,e.label=t.label||t.language;const h=b.build({entryId:i,flavorIds:t.id,format:c,ks:s,partnerId:r,uiConfId:a,extension:t.fileExt,protocol:l});if(""===h)return Y._logger.warn(`failed to create play url from source, discarding source: (${i}_${d}), ${c}.`),null;e.url=h,t.height&&t.width?o.push(e):n.push(e)}))}return n.length&&!o.length?n:o}static _parseMetadata(t){const e={};return t&&t.metas&&t.metas.length>0&&t.metas.forEach((t=>{if(t.xml){const s=new DOMParser;t.xml=t.xml.replace(/\r?\n|\r/g,""),t.xml=t.xml.replace(/>\s*/g,">"),t.xml=t.xml.replace(/>\s*/g,">");const r=s.parseFromString(t.xml,"text/xml"),a=M.xmlToJson(r);Object.keys(a.metadata).forEach((t=>{e[t]=a.metadata[t]["#text"]}))}})),e}static _getBaseProtocol(){const t=u.get(),e=/^https?:/.exec(t.cdnUrl),s=e?e[0]:document.location.protocol;return"string"==typeof s?s.slice(0,-1):"https"}static hasBlockAction(t){return t.playBackContextResult.hasBlockAction()}static getBlockAction(t){return t.playBackContextResult.getBlockAction()}static getErrorMessages(t){return t.playBackContextResult.getErrorMessages()}}a(Y,"_logger",l("OVPProviderParser"));const J=Y.addKsToUrl,$=Y;class X{constructor(t,e,s,r={}){this.severity=t,this.category=e,this.code=s,this.data=r,X._logger.error(`Category:${e} | Code:${s} |`,r)}}a(X,"Severity",{RECOVERABLE:1,CRITICAL:2}),a(X,"Category",{NETWORK:1,SERVICE:2,PROVIDER:3}),a(X,"Code",{UNSUPPORTED_SCHEME:1e3,BAD_HTTP_STATUS:1001,HTTP_ERROR:1002,TIMEOUT:1003,MALFORMED_DATA_URI:1004,BAD_SERVER_RESPONSE:1005,MULTIREQUEST_API_ERROR:1006,API_RESPONSE_MISMATCH:1007,ERROR:2e3,BLOCK_ACTION:2001,MEDIA_STATUS_NOT_READY:2002,MISSING_MANDATORY_PARAMS:3e3,MISSING_PLAY_SOURCE:3001,METHOD_NOT_IMPLEMENTED:3002}),a(X,"_logger",l("Error"));class Q{constructor(t=new Map){a(this,"retryConfig",{async:!0,timeout:0,maxAttempts:4}),a(this,"_attemptCounter",1),this.headers=t}getUrl(t){return t+"/service/"+this.service+(this.action?"/action/"+this.action:"")}doHttpRequest(){const t=new Promise(((t,e)=>{this._requestPromise={resolve:t,reject:e}}));return this.url||this._requestPromise.reject(new X(X.Severity.CRITICAL,X.Category.NETWORK,X.Code.MALFORMED_DATA_URI,{url:this.url})),this._createXHR(),t}_createXHR(){const t=new XMLHttpRequest;t.onreadystatechange=()=>{if(4===t.readyState&&200===t.status)try{const e=JSON.parse(t.responseText);return this.responseHeaders=this._getResponseHeaders(t),this._requestPromise.resolve(e)}catch(e){this._requestPromise.reject(this._createError(t,X.Code.BAD_SERVER_RESPONSE,{text:t.responseText}))}},t.open(this.method,this.url,this.retryConfig.async),this.retryConfig.async&&this.retryConfig.timeout&&(t.timeout=this.retryConfig.timeout);const e=performance.now();t.ontimeout=()=>{this._handleError(t,X.Code.TIMEOUT,{timeout:(performance.now()-e)/1e3,statusText:t.statusText})},t.onerror=t.onabort=()=>{this._handleError(t,X.Code.HTTP_ERROR,{text:t.responseText,statusText:t.statusText})},this.headers.forEach(((e,s)=>{t.setRequestHeader(s,e)})),t.send(this.params)}_getResponseHeaders(t){return t.getAllResponseHeaders().split("\n").filter((t=>0===t.toLowerCase().indexOf("x-")))}_handleError(t,e,s){const r=this._createError(t,e,s);if(t.onreadystatechange=function(){},t.onerror=function(){},t.ontimeout=function(){},t.onabort=function(){},!(this.retryConfig.maxAttempts&&this._attemptCounter<this.retryConfig.maxAttempts))return this._requestPromise.reject(r);this._attemptCounter++,this._createXHR()}_createError(t,e,s){return Object.assign(s,{url:this.url,headers:this._getResponseHeaders(t),attempt:this._attemptCounter}),new X(X.Severity.CRITICAL,X.Category.NETWORK,e,s)}}class Z extends Q{constructor(...t){super(...t),a(this,"requests",[])}add(t){this.requests.push(t);const e={},s={service:t.service,action:t.action};return Object.assign(e,{[this.requests.length]:Object.assign(s,t.params)}),Object.assign(e,this.params),this.params=e,this}execute(t){return new Promise(((e,s)=>{try{this.params=JSON.stringify(this.params)}catch(t){Z._logger.error(`${t.message}`),s(new X(X.Severity.CRITICAL,X.Category.PROVIDER,X.Code.FAILED_PARSING_REQUEST,{error:t,params:this.params}))}this.doHttpRequest().then((r=>{const a=new z(r,t);a.success?e({headers:this.responseHeaders,response:a}):s(new X(X.Severity.CRITICAL,X.Category.NETWORK,X.Code.MULTIREQUEST_API_ERROR,{url:this.url,headers:this.responseHeaders,results:a.results}))}),(t=>{s(t)}))}))}}a(Z,"_logger",l("MultiRequestBuilder"));class z{constructor(t,e=!0){a(this,"results",[]);const s=t.result?t.result:t,r=(Array.isArray(s)?s:[s]).map((t=>new h(t))),i=r.filter((t=>t.hasError));i.forEach((t=>{z._logger.error(`Service returned an error with error code: ${t.error.code} and message: ${t.error.message}.`)})),this.results=r,e&&i.length||i.length===this.results.length?this.success=!1:(this.results=this.results.filter((t=>!t.hasError)),this.success=!0)}}a(z,"_logger",l("MultiRequestResult"));class tt{static getMultiRequest(t,e,s){const r=u.get(),a=r.serviceParams;Object.assign(a,{ks:e,clientTag:"html5:v"+t}),s&&Object.assign(a,{partnerId:s});const i=new Map;i.set("Content-Type","application/json");const o=new Z(i);return o.method="POST",o.service="multirequest",o.url=o.getUrl(r.serviceUrl),o.params=a,o}}class et{constructor(t={}){this.type=t.type||et.Type.INCLUDE_FIELDS,this.fields=t.fields||"id,referenceId,name,description,thumbnailUrl,dataUrl,duration,msDuration,flavorParamsIds,mediaType,type,tags,dvrStatus,externalSourceType,status,createdAt,updatedAt,endDate,plays,views,downloadUrl,creatorId"}}a(et,"Type",{INCLUDE_FIELDS:1,EXCLUDE_FIELDS:2});const st="baseEntry";class rt extends tt{static getPlaybackContext(t,e,s){const r=new Map;r.set("Content-Type","application/json");const a=new Q(r);return a.service=st,a.action="getPlaybackContext",a.method="POST",a.url=a.getUrl(t),a.tag="baseEntry-getPlaybackContext",a.params={entryId:s,ks:e,contextDataParams:{objectType:"KalturaContextDataParams",flavorTags:"all"}},a}static list(t,e,s,r,a){const i=new Map;i.set("Content-Type","application/json");const o=new Q(i);return o.service=st,o.action="list",o.method="POST",o.url=o.getUrl(t),o.tag="list",o.params=rt.getEntryListReqParams(s,e,r,a),o}static getEntryListReqParams(t,e,s,r){let a={};return t?a=s?{redirectFromEntryId:t}:{idEqual:t}:r&&(a={objectType:"KalturaBaseEntryFilter",referenceIdEqual:r}),{ks:e,filter:a,responseProfile:new et}}}class at extends tt{static list(t,e,s){const r=new Map;r.set("Content-Type","application/json");const a=new Q(r);a.service="metadata_metadata",a.action="list",a.method="POST",a.url=a.getUrl(t),a.tag="metadata_metadata-list";const i={objectType:"KalturaMetadataFilter",objectIdEqual:s,metadataObjectTypeEqual:"1"};return a.params={filter:i,ks:e},a}}class it{static get id(){return"media"}constructor(t){a(this,"_response",{}),this.requests=this.buildRequests(t),this._entryId=t.entryId,this._referenceId=t.referenceId}set requests(t){this._requests=t}get requests(){return this._requests}set response(t){const e=new m(t[0].data);this._response.entry=e.entries[0],this._response.playBackContextResult=new O(t[1].data),this._response.metadataListResult=new C(t[2].data)}get response(){return this._response}buildRequests(t){const e=u.get(),s=[];s.push(rt.list(e.serviceUrl,t.ks,t.entryId,t.redirectFromEntryId,t.referenceId));const r="{1:result:ks}"===t.ks?"{2:result:objects:0:id}":"{1:result:objects:0:id}";return s.push(rt.getPlaybackContext(e.serviceUrl,t.ks,r)),s.push(at.list(e.serviceUrl,t.ks,r)),s}isValid(){return!(!this._entryId&&!this._referenceId)}}class ot extends tt{static anonymousSession(t,e){const s=new Map;s.set("Content-Type","application/json");const r=new Q(s);return r.service="session",r.action="startWidgetSession",r.method="POST",r.url=r.getUrl(t),r.tag="session-startWidget",r.params={widgetId:e},r}}class nt{static get id(){return"session"}set requests(t){this._requests=t}get requests(){return this._requests}set response(t){this._response.ks=t[0].data.ks}get response(){return this._response.ks}constructor(t){a(this,"_response",{}),this.requests=this.buildRequests(t),this._widgetId=t.widgetId}buildRequests(t){const e=u.get(),s=[];return s.push(ot.anonymousSession(e.serviceUrl,t.widgetId)),s}isValid(){return!!this._widgetId}}class lt{constructor(t){a(this,"_loadersResponseMap",new Map),a(this,"_loaders",new Map),this._networkRetryConfig=t}add(t,e,s){const r=new t(e);if(r.isValid()){this._loaders.set(t.id,r);const e=this._multiRequest.requests.length,a=r.requests;this._multiRequest.retryConfig=this._networkRetryConfig,a.forEach((t=>{t.params=t.params||{},t.params.ks=t.params.ks||s,this._multiRequest.add(t)}));const i=Array.from(new Array(a.length),((t,s)=>s+e));this._loadersResponseMap.set(t.id,i)}}fetchData(t){return new Promise(((e,s)=>{this._multiRequest.execute(t).then((t=>{this._multiResponse=t.response,this.prepareData(t.response).success?e(this._loaders):s(new X(X.Severity.CRITICAL,X.Category.NETWORK,X.Code.API_RESPONSE_MISMATCH,{headers:t.headers}))}),(t=>{s(t)}))}))}prepareData(t){return this._loaders.forEach(((e,s)=>{const r=this._loadersResponseMap.get(s);try{r&&r.length>0&&(e.response=t.results.slice(r[0],r[r.length-1]+1))}catch(t){return{success:!1,error:t}}})),{success:!0,data:this._loaders}}}class ct extends lt{constructor(t,e,s="",r){super(r),this._multiRequest=tt.getMultiRequest(t,s,e)}}const dt="playlist";class ut extends tt{static execute(t,e,s){const r=new Map;r.set("Content-Type","application/json");const a=new Q(r);return a.service=dt,a.action="execute",a.method="POST",a.url=a.getUrl(t),a.tag=`${dt}-execute`,a.params={ks:e,id:s,responseProfile:new et},a}static get(t,e,s){const r=new Map;r.set("Content-Type","application/json");const a=new Q(r);return a.service=dt,a.action="get",a.method="POST",a.url=a.getUrl(t),a.tag=`${dt}-get`,a.params={ks:e,id:s,responseProfile:{fields:"id,name,description,thumbnailUrl",type:1}},a}static getLastEntryId(t,e,s){const r=new Map;r.set("Content-Type","application/json");const a=new Q(r);return a.service="userEntry",a.action="list",a.method="POST",a.url=a.getUrl(t),a.tag="userEntry-list",a.params={ks:e,filter:{objectType:"KalturaViewHistoryUserEntry",entryIdEqual:s,userIdEqualCurrent:1},responseProfile:{fields:"playlistLastEntryId",type:1}},a}}class ht{static get id(){return"playlist"}constructor(t){a(this,"_response",{}),this.requests=this.buildRequests(t),this._playlistId=t.playlistId}set requests(t){this._requests=t}get requests(){return this._requests}set response(t){this._response.playlistData=new S(t[0].data),this._response.playlistItems=new T(t[1].data),this._response.playlistUserEntries=new D(t[2].data)}get response(){return this._response}buildRequests(t){const e=u.get(),s=[];return s.push(ut.get(e.serviceUrl,t.ks,t.playlistId)),s.push(ut.execute(e.serviceUrl,t.ks,t.playlistId)),s.push(ut.getLastEntryId(e.serviceUrl,t.ks,t.playlistId)),s}isValid(){return!!this._playlistId}}class pt{get partnerId(){return this._partnerId}get widgetId(){return this._widgetId||this.defaultWidgetId}get defaultWidgetId(){return"_"+this._partnerId}get uiConfId(){return this._uiConfId}get ks(){return this._ks}set ks(t){this._ks=t}get playerVersion(){return this._playerVersion}get isAnonymous(){return this._isAnonymous}constructor(t,e){a(this,"_networkRetryConfig",{async:!0,timeout:0,maxAttempts:4}),function(t){t&&"function"==typeof t.getLogger&&(i.get=t.getLogger),t&&t.LogLevel&&(o=t.LogLevel)}(t.logger),this._partnerId=t.partnerId,this._widgetId=t.widgetId,this._uiConfId=t.uiConfId,this._isAnonymous=!t.ks,this._ks=t.ks||"",this._playerVersion=e}getMediaConfig(t){return Promise.reject(new X(X.Severity.CRITICAL,X.Category.PROVIDER,X.Code.METHOD_NOT_IMPLEMENTED,{message:"getMediaConfig method must be implement by the derived class"}))}getPlaylistConfig(t){return Promise.reject(new X(X.Severity.CRITICAL,X.Category.PROVIDER,X.Code.METHOD_NOT_IMPLEMENTED,{message:"The provider does not support loading playlist by id"}))}getEntryListConfig(t){return Promise.reject(new X(X.Severity.CRITICAL,X.Category.PROVIDER,X.Code.METHOD_NOT_IMPLEMENTED,{message:"The provider does not support loading entry list"}))}_verifyHasSources(t){if(0===t.hls.concat(t.dash,t.progressive,t.image).length)throw new X(X.Severity.CRITICAL,X.Category.SERVICE,X.Code.MISSING_PLAY_SOURCE,{action:"",messages:`No play source for entry id: ${t.id}`})}get LogLevel(){return o}getLogLevel(t){return function(t){return n(t).getLevel()}(t)}setLogLevel(t,e){!function(t,e){n(e).setLevel(t)}(t,e)}}class gt{static get id(){return"entry_list"}constructor(t){a(this,"_response",{playlistItems:{entries:[]}}),this.requests=this.buildRequests(t),this._entries=t.entries}set requests(t){this._requests=t}get requests(){return this._requests}set response(t){let e;t.forEach((t=>{e=new m(t.data),this._response.playlistItems.entries.push(e.entries[0])}))}get response(){return this._response}buildRequests(t){const e=u.get(),s=[];return t.entries.forEach((r=>{s.push(rt.list(e.serviceUrl,t.ks,r.entryId||r,t.redirectFromEntryId,r.referenceId))})),s}isValid(){return!(!this._entries||!this._entries.length)}}function mt(t,e,s,r,a,i,o){try{var n=t[i](o),l=n.value}catch(t){return void s(t)}n.done?e(l):Promise.resolve(l).then(r,a)}function yt(t){return function(){var e=this,s=arguments;return new Promise((function(r,a){var i=t.apply(e,s);function o(t){mt(i,r,a,o,n,"next",t)}function n(t){mt(i,r,a,o,n,"throw",t)}o(void 0)}))}}class Et{static _applyRegexAction(t,e){if(t){const s=new RegExp(t.pattern,"i");if(e.match(s))return e.replace(s,t.replacement+"/")}return e}static _isECDNUrlAlive(t,e){return yt((function*(){const s=e+"/api_v3/service/system/action/ping/format/1",r=new XMLHttpRequest;return r.open("GET",s),r.timeout=t.checkAliveTimeoutMs,r.onreadystatechange=()=>4===r.readyState&&200===r.status,r.ontimeout=()=>(Et._logger.warn(`Got timeout while pinging the ECDN url. the ping url: ${s}`),!1),r.send(),!1}))()}static handleRegexAction(t,e){return yt((function*(){const s=u.get().cdnUrl,r=Et._extractRegexActionFromData(e),a=Et._getRegExp(r);return!(s&&r&&a&&s.match(a))||r.checkAliveTimeoutMs>0&&!(yield Et._isECDNUrlAlive(r,s.replace(a,r.replacement)))?(Et._logger.debug("exiting handleRegexAction - not applying regex action."),t):(Et._replaceHostUrls(t,r),t)}))()}static _replaceHostUrls(t,e){Et._logger.debug("Starting to modify urls...");const s=t.sources,{hls:r,dash:a,progressive:i,image:o}=s;[...r,...a,...i,...o].forEach((t=>t.url=Et._applyRegexAction(e,t.url))),u.get().replaceHostOnlyManifestUrls||(Et._logger.debug("replaceHostOnlyManifestUrls flag is off - modifying captions and poster URLs"),s.captions&&s.captions.forEach((t=>t.url=Et._applyRegexAction(e,t.url))),"string"==typeof s.poster&&(s.poster=Et._applyRegexAction(e,s.poster))),Et._logger.debug("Finished modifying urls")}static _extractRegexActionFromData(t){var e;return null===(e=t.get(it.id))||void 0===e||null===(e=e.response)||void 0===e?void 0:e.playBackContextResult.getRequestHostRegexAction()}static _getRegExp(t){if(t&&t.pattern&&t.replacement)return new RegExp(t.pattern,"i")}}a(Et,"_logger",l("RegexActionHandler"));const ft=Et;class It extends pt{constructor(t,e){super(t,e),a(this,"_filterOptionsConfig",{redirectFromEntryId:!0}),this._logger=l("OVPProvider"),u.set(t.env),this._setFilterOptionsConfig(t.filterOptions),this._networkRetryConfig=Object.assign(this._networkRetryConfig,t.networkRetryParameters)}get env(){return u.get()}getMediaConfig(t){return t.ks&&(this.ks=t.ks,this._isAnonymous=!1),this.widgetId!==this.defaultWidgetId&&(this._isAnonymous=!1),this._dataLoader=new ct(this.playerVersion,this.partnerId,this.ks,this._networkRetryConfig),new Promise(((e,s)=>{const r=t.entryId,a=t.referenceId;if(r||a){let i=this.ks;i||(i="{1:result:ks}",this._dataLoader.add(nt,{widgetId:this.widgetId}));const o=this._getEntryRedirectFilter(t);return this._dataLoader.add(it,{entryId:r,ks:i,redirectFromEntryId:o,referenceId:a}),this._dataLoader.fetchData().then((t=>{try{const s=this._parseDataFromResponse(t);ft.handleRegexAction(s,t).then(e)}catch(t){s(t)}}),(t=>{s(t)}))}s(new X(X.Severity.CRITICAL,X.Category.PROVIDER,X.Code.MISSING_MANDATORY_PARAMS,{message:"missing entry id"}))}))}doRequest(t,e){const s=e||this.ks,r=new ct(this.playerVersion,this.partnerId,s,this._networkRetryConfig);return new Promise(((e,a)=>(s||r.add(nt,{widgetId:this.widgetId}),t.forEach((t=>{r.add(t.loader,t.params,s||"{1:result:ks}")})),r.fetchData().then((t=>{try{e(t)}catch(t){a(t)}}),(t=>{a(t)})))))}_getEntryRedirectFilter(t){return"boolean"==typeof t.redirectFromEntryId?t.redirectFromEntryId:"boolean"!=typeof this._filterOptionsConfig.redirectFromEntryId||this._filterOptionsConfig.redirectFromEntryId}_setFilterOptionsConfig(t){t&&"boolean"==typeof t.redirectFromEntryId&&(this._filterOptionsConfig.redirectFromEntryId=t.redirectFromEntryId)}_parseDataFromResponse(t){this._logger.debug("Data parsing started");const e={session:{isAnonymous:this._isAnonymous,partnerId:this.partnerId},sources:this._getDefaultSourcesObject(),plugins:{}};if(this.uiConfId&&(e.session.uiConfId=this.uiConfId),t){if(t.has(nt.id)){const s=t.get(nt.id);s&&s.response&&(e.session.ks=s.response,this.widgetId!==this.defaultWidgetId&&(this.ks=e.session.ks))}else e.session.ks=this.ks;if(t.has(it.id)){const s=t.get(it.id);if(s&&s.response){const t=s.response;if($.hasBlockAction(t))throw new X(X.Severity.CRITICAL,X.Category.SERVICE,X.Code.BLOCK_ACTION,{action:$.getBlockAction(t),messages:$.getErrorMessages(t)});const r=$.getMediaEntry(this.isAnonymous?"":this.ks,this.partnerId,this.uiConfId,t);Object.assign(e.sources,this._getSourcesObject(r)),this._verifyMediaStatus(r),this._verifyHasSources(e.sources);const a=$.getBumper(t,this.isAnonymous?"":this.ks,this.partnerId);a&&Object.assign(e.plugins,{bumper:a})}}}return this._logger.debug("Data parsing finished",e),e}_verifyMediaStatus(t){if([g.EntryStatus.IMPORT,g.EntryStatus.PRECONVERT].includes(t.status))throw new X(X.Severity.CRITICAL,X.Category.SERVICE,X.Code.MEDIA_STATUS_NOT_READY,{messages:`Status of entry id ${t.id} is ${t.status} and is still being imported or converted`,data:{status}})}getPlaylistConfig(t){return t.ks&&(this.ks=t.ks,this._isAnonymous=!1),this.widgetId!==this.defaultWidgetId&&(this._isAnonymous=!1),this._dataLoader=new ct(this.playerVersion,this.partnerId,this.ks,this._networkRetryConfig),new Promise(((e,s)=>{const r=t.playlistId;if(r){let t=this.ks;t||(t="{1:result:ks}",this._dataLoader.add(nt,{widgetId:this.widgetId})),this._dataLoader.add(ht,{playlistId:r,ks:t}),this._dataLoader.fetchData().then((t=>{e(this._parsePlaylistDataFromResponse(t))}),(t=>{s(t)}))}else s({success:!1,data:"Missing mandatory parameter"})}))}_parsePlaylistDataFromResponse(t){this._logger.debug("Data parsing started");const e=this._getPlaylistObject();if(t&&t.has(ht.id)){const s=t.get(ht.id);if(s&&s.response){const t=$.getPlaylist(s.response);e.id=t.id,e.poster=t.poster,e.metadata.name=t.name,e.metadata.description=t.description,e.playlistLastEntryId=t.playlistLastEntryId,t.items.forEach((t=>e.items.push({sources:this._getSourcesObject(t)})))}}return this._logger.debug("Data parsing finished",e),e}getEntryListConfig(t){return t.ks&&(this.ks=t.ks,this._isAnonymous=!1),this.widgetId!==this.defaultWidgetId&&(this._isAnonymous=!1),this._dataLoader=new ct(this.playerVersion,this.partnerId,this.ks,this._networkRetryConfig),new Promise(((e,s)=>{const r=t.entries;if(r&&r.length){let a=this.ks;a||(a="{1:result:ks}",this._dataLoader.add(nt,{widgetId:this.widgetId}));const i=this._getEntryRedirectFilter(t);this._dataLoader.add(gt,{entries:r,ks:a,redirectFromEntryId:i}),this._dataLoader.fetchData(!1).then((t=>{e(this._parseEntryListDataFromResponse(t))}),(t=>{s(t)}))}else s({success:!1,data:"Missing mandatory parameter"})}))}_parseEntryListDataFromResponse(t){this._logger.debug("Data parsing started");const e=this._getPlaylistObject();if(t&&t.has(gt.id)){const s=t.get(gt.id);s&&s.response&&$.getEntryList(s.response).items.forEach((t=>e.items.push({sources:this._getSourcesObject(t)})))}return this._logger.debug("Data parsing finished",e),e}_getPlaylistObject(){return{id:"",metadata:{name:"",description:""},poster:"",playlistLastEntryId:"",items:[]}}_getDefaultSourcesObject(){return{hls:[],dash:[],progressive:[],image:[],id:"",duration:0,type:x.Type.UNKNOWN,poster:"",dvr:!1,vr:null,metadata:{name:"",description:"",tags:""}}}_getSourcesObject(t){const e=this._getDefaultSourcesObject(),s=t.sources.toJSON();return e.hls=s.hls,e.dash=s.dash,e.progressive=s.progressive,e.image=s.image,e.id=t.id,e.duration=t.duration,e.type=t.type,e.dvr=!!t.dvrStatus,e.poster=t.poster,e.downloadUrl=t.downloadUrl,t.sources.captions&&(e.captions=t.sources.captions),t.metadata&&"string"==typeof t.metadata.tags&&t.metadata.tags.split(", ").includes("360")&&(e.vr={}),Object.assign(e.metadata,t.metadata),e}}const _t="@playkit-js/playkit-js-providers-ovp",Rt="2.40.2-canary.0-c7a43ae";return e})()));
|
|
1
|
+
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var s=e();for(var r in s)("object"==typeof exports?exports:t)[r]=s[r]}}(globalThis,(()=>(()=>{"use strict";var t={d:(e,s)=>{for(var r in s)t.o(s,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:s[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{NAME:()=>ft,Provider:()=>_t,ProviderParser:()=>Y,RequestBuilder:()=>Z,ResponseTypes:()=>s,VERSION:()=>Rt});var s={};t.r(s),t.d(s,{BaseServiceResult:()=>d,KalturaAccessControlMessage:()=>A,KalturaAccessControlModifyRequestHostRegexAction:()=>m,KalturaBaseEntryListResponse:()=>p,KalturaBumper:()=>I,KalturaDrmPlaybackPluginData:()=>y,KalturaFlavorAsset:()=>_,KalturaMediaEntries:()=>f,KalturaMediaEntry:()=>h,KalturaMetadata:()=>R,KalturaMetadataListResponse:()=>T,KalturaPlaybackContext:()=>C,KalturaPlaybackSource:()=>E,KalturaPlaylist:()=>v,KalturaRuleAction:()=>g,KalturaUIConfResponse:()=>O,KalturaUserEntry:()=>P,KalturaUserEntryListResponse:()=>S});const r={get:()=>({VERSION:"",DEBUG:{value:"",name:""},ERROR:{value:"",name:""},INFO:{value:"",name:""},OFF:{value:"",name:""},TIME:{value:"",name:""},TRACE:{value:"",name:""},WARN:{value:"",name:""},createDefaultHandler:()=>{},debug:()=>{},enabledFor:()=>{},error:()=>{},get:()=>{},getLevel:()=>{},info:()=>{},log:()=>{},setHandler:()=>{},setLevel:()=>{},time:()=>{},timeEnd:()=>{},trace:()=>{},useDefaults:()=>{},warn:()=>{}})};let a={};function i(t){return r.get(t)}const o=i,n=t=>{let e;return Array.isArray(t)?(e=t.length>0?t.slice(0):[],e.forEach(((t,s)=>{("object"==typeof t||Array.isArray(t)&&t.length>0)&&(e[s]=n(t))}))):"object"==typeof t?(e=Object.assign({},t),Object.keys(e).forEach((t=>{("object"==typeof e[t]||Array.isArray(e[t])&&e[t].length>0)&&(e[t]=n(e[t]))}))):e=t,e},c={serviceUrl:"https://cdnapisec.kaltura.com/api_v3",cdnUrl:"https://cdnapisec.kaltura.com",serviceParams:{apiVersion:"3.3.0",format:1},useApiCaptions:!0,loadThumbnailWithKs:!1,replaceHostOnlyManifestUrls:!1};class l{static set(t){t&&Object.assign(c,t)}static get(){return n(c)}}class d{hasError=!1;constructor(t){"KalturaAPIException"===t.objectType?(this.hasError=!0,this.error=new u(t.code,t.message)):t.error&&"KalturaAPIException"===t.error.objectType?(this.hasError=!0,this.error=new u(t.error.code,t.error.message)):this.data=t}}class u{constructor(t,e){this.code=t,this.message=e}}class h{static EntryType={AUTOMATIC:{value:-1},EXTERNAL_MEDIA:{value:"externalMedia.externalMedia"},MEDIA_CLIP:{value:1},MIX:{value:2},PLAYLIST:{value:5},DATA:{value:6},LIVE_STREAM:{value:7},LIVE_CHANNEL:{value:8},DOCUMENT:{value:10}};static MediaType={VIDEO:{value:1},IMAGE:{value:2},AUDIO:{value:5},LIVE_STREAM_FLASH:{value:201},LIVE_STREAM_WINDOWS_MEDIA:{value:202},LIVE_STREAM_REAL_MEDIA:{value:203},LIVE_STREAM_QUICK_TIME:{value:204}};static EntryStatus={ERROR_IMPORTING:-2,ERROR_CONVERTING:-1,SCAN_FAILURE:"virusScan.ScanFailure",IMPORT:0,INFECTED:"virusScan.Infected",PRECONVERT:1,READY:2,DELETED:3,PENDING:4,MODERATE:5,BLOCKED:6,NO_CONTENT:7};static EntryModerationStatus={PENDING_MODERATION:1,APPROVED:2,REJECTED:3,FLAGGED_FOR_REVIEW:4,MODERATE:5,AUTO_APPROVED:6};constructor(t){this.id=t.id,this.referenceId=t.referenceId,this.externalSourceType=t.externalSourceType,this.name=t.name,this.description=t.description,this.dataUrl=t.dataUrl,this.type=t.type,this.entryType=t.mediaType,this.flavorParamsIds=t.flavorParamsIds,this.duration=t.duration,this.poster=t.thumbnailUrl,this.status=t.status,this.dvrStatus=t.dvrStatus,this.tags=t.tags,this.createdAt=t.createdAt,this.updatedAt=t.updatedAt,this.creatorId=t.creatorId,this.endDate=t.endDate,this.plays=t.plays,this.views=t.views,this.downloadUrl=t.downloadUrl}}class p extends d{constructor(t){super(t),this.hasError||(this.totalCount=t.totalCount,this.totalCount>0&&(this.entries=[],t.objects.map((t=>this.entries.push(new h(t))))))}}class g{static Type={DRM_POLICY:"drm.DRM_POLICY",BLOCK:1,PREVIEW:2,LIMIT_FLAVORS:3,ADD_TO_STORAGE:4,LIMIT_DELIVERY_PROFILES:5,SERVE_FROM_REMOTE_SERVER:6,REQUEST_HOST_REGEX:7,LIMIT_THUMBNAIL_CAPTURE:8};constructor(t){this.type=t.type}}class m extends g{constructor(t){super(t),this.pattern=t.pattern,this.replacement=t.replacement,this.replacmenServerNodeId=t.replacmenServerNodeId,this.checkAliveTimeoutMs=t.checkAliveTimeoutMs}}class y{static Scheme={"drm.PLAYREADY_CENC":"com.microsoft.playready","drm.WIDEVINE_CENC":"com.widevine.alpha","fairplay.FAIRPLAY":"com.apple.fairplay",WIDEVINE_CENC:"com.widevine.alpha",PLAYREADY_CENC:"com.microsoft.playready",FAIRPLAY:"com.apple.fairplay"};constructor(t){this.scheme=t.scheme,this.licenseURL=t.licenseURL,this.certificate=t.certificate}}class E{drm=[];constructor(t){this.format=t.format,this.deliveryProfileId=t.deliveryProfileId,this.url=t.url,this.protocols=t.protocols,this.flavorIds=t.flavorIds,t.drm&&t.drm.map((t=>this.drm.push(new y(t))))}hasDrmData(){return this.drm&&this.drm.length>0}hasFlavorIds(){return!!this.flavorIds&&this.flavorIds.length>0}getProtocol(t){let e="";if(this.protocols&&this.protocols.length>0)this.protocols.split(",").forEach((s=>{s===t&&(e=s)}));else if("http"===t)return t;return e}}class I{constructor(t){this.entryId=t.entryId,this.clickThroughUrl=t.url,this.sources=t.sources?t.sources.map((t=>new E(t))):[]}}class _{static Status={ERROR:-1,QUEUED:0,CONVERTING:1,READY:2,DELETED:3,NOT_APPLICABLE:4,TEMP:5,WAIT_FOR_CONVERT:6,IMPORTING:7,VALIDATING:8,EXPORTING:9};constructor(t){this.id=t.id,this.flavorParamsId=t.flavorParamsId,this.fileExt=t.fileExt,this.bitrate=t.bitrate,this.width=t.width,this.height=t.height,this.id=t.id,this.frameRate=t.frameRate,this.isOriginal=t.isOriginal,this.isWeb=t.isWeb,this.containerFormat=t.containerFormat,this.videoCodecId=t.videoCodecId,this.status=t.status,this.language=t.language,this.label=t.label}}class f extends d{constructor(t){super(t),this.hasError||(this.entries=[],t.map((t=>{const e=new h(t);e.type!==h.EntryType.DOCUMENT.value&&this.entries.push(e)})))}}class R{static ObjectType={AD_CUE_POINT:"adCuePointMetadata.AdCuePoint",ANNOTATION:"annotationMetadata.Annotation",CODE_CUE_POINT:"codeCuePointMetadata.CodeCuePoint",THUMB_CUE_POINT:"thumbCuePointMetadata.thumbCuePoint",ENTRY:1,CATEGORY:2,USER:3,PARTNER:4,DYNAMIC_OBJECT:5};static Status={VALID:1,INVALID:2,DELETED:3};constructor(t){this.id=t.id,this.metadataProfileId=t.metadataProfileId,this.metadataProfileVersion=t.metadataProfileVersion,this.metadataProfileId=t.metadataProfileId,this.metadataObjectType=t.metadataObjectType,this.objectId=t.objectId,this.version=t.version,this.created=new Date(0),this.created.setUTCSeconds(t.createdAt),this.updated=new Date(0),this.updated.setUTCSeconds(t.updatedAt),this.status=t.status,this.xml=t.xml}}class T extends d{constructor(t){super(t),this.hasError||(this.totalCount=t.totalCount,this.totalCount>0&&(this.metas=[],t.objects.map((t=>this.metas.push(new R(t))))))}}class A{constructor(t){this.message=t.message,this.code=t.code}}class C extends d{sources=[];actions=[];messages=[];flavorAssets=[];bumperData=[];constructor(t){if(super(t),!this.hasError){const e=t.messages;e&&e.map((t=>this.messages.push(new A(t))));const s=t.actions;s&&s.map((t=>{t.type===g.Type.REQUEST_HOST_REGEX?this.actions.push(new m(t)):this.actions.push(new g(t))}));const r=t.sources;r&&r.map((t=>this.sources.push(new E(t))));const a=t.flavorAssets;a&&a.map((t=>this.flavorAssets.push(new _(t))));const i=t.bumperData;i&&i.map((t=>this.bumperData.push(new I(t))))}}hasBlockAction(){return void 0!==this.getBlockAction()}getBlockAction(){return this.actions.find((t=>t.type===g.Type.BLOCK))}getErrorMessages(){return this.messages}getRequestHostRegexAction(){const t=this.actions.find((t=>t.type===g.Type.REQUEST_HOST_REGEX));if(t instanceof m)return t}}class v{constructor(t){this.id=t.id,this.name=t.name,this.description=t.description,this.poster=t.thumbnailUrl}}class O extends d{static Type={PLAYER:1,CONTRIBUTION_WIZARD:2,SIMPLE_EDITOR:3,ADVANCED_EDITOR:4,PLAYLIST:5,APP_STUDIO:6,KRECORD:7,PLAYER_V3:8,KMC_ACCOUNT:9,KMC_ANALYTICS:10,KMC_CONTENT:11,KMC_DASHBOARD:12,KMC_LOGIN:13,PLAYER_SL:14,CLIENTSIDE_ENCODER:15,KMC_GENERAL:16,KMC_ROLES_AND_PERMISSIONS:17,CLIPPER:18,KSR:19,KUPLOAD:20,WEBCASTING:21};static CreationMode={WIZARD:2,ADVANCED:3};constructor(t){super(t),this.hasError||(this.name=t.name,this.description=t.description,this.objTypeAsString=t.objTypeAsString,this.width=t.width,this.height=t.height,this.htmlParams=t.htmlParams,this.swfUrl=t.swfUrl,this.confFilePath=t.confFilePath,this.confFile=t.confFile,this.confFileFeatures=t.confFileFeatures,this.config=t.config,this.confVars=t.confVars,this.useCdn=t.useCdn,this.tags=t.tags,this.swfUrlVersion=t.swfUrlVersion,this.created=new Date(0),this.created.setUTCSeconds(t.createdAt),this.updated=new Date(0),this.updated.setUTCSeconds(t.updatedAt),this.html5Url=t.description,this.version=t.description,this.partnerTags=t.description,this.objType=t.description,this.creationMode=t.description)}}class P{constructor(t){this.playlistLastEntryId=t.playlistLastEntryId,this.entryId=t.entryId,this.id=t.id,this.userId=t.userId,this.partnerId=t.partnerId,this.status=t.status,this.createdAt=t.createdAt,this.updatedAt=t.updatedAt}}class S extends d{constructor(t){super(t),this.hasError||(this.totalCount=t.totalCount,this.entries=[],this.totalCount>0&&t.objects.map((t=>this.entries.push(new P(t)))))}}class w{static build(t){const e=l.get(),s=e.serviceUrl.substr(0,e.serviceUrl.lastIndexOf("/")),{partnerId:r,entryId:a,ks:i,uiConfId:o,format:n,protocol:c,extension:d,flavorIds:u}=t;if(!s||isNaN(Number.parseInt(r))||!a||!n||!c)return"";let h=s;return s.endsWith("/")||(h+="/"),h+="p/"+r+"/sp/"+r+"00/playManifest/entryId/"+a+"/protocol/"+c+"/format/"+n,u?h+="/flavorIds/"+u:o&&(h+="/uiConfId/"+o),""!==i&&(h+="/ks/"+i),""!==d&&(h+="/a."+d),o&&""!==u&&(h+="?uiConfId="+o),h}}class D{static xmlToJson(t){let e={};if(1===t.nodeType){if(t.attributes.length>0){e["@attributes"]={};for(let s=0;s<t.attributes.length;s++){const r=t.attributes.item(s);e["@attributes"][r.nodeName]=r.nodeValue}}}else 3===t.nodeType&&(e=t.nodeValue);if(t.hasChildNodes())for(let s=0;s<t.childNodes.length;s++){const r=t.childNodes.item(s),a=r.nodeName;if(void 0===e[a])e[a]=this.xmlToJson(r);else{if(void 0===e[a].push){const t=e[a];e[a]=[],e[a].push(t)}e[a].push(this.xmlToJson(r))}}return e}}const M={DASH:{name:"dash",mimeType:"application/dash+xml",pathExt:"mpd"},HLS:{name:"hls",mimeType:"application/x-mpegURL",pathExt:"m3u8"},WVM:{name:"wvm",mimeType:"video/wvm",pathExt:"wvm"},MP4:{name:"mp4",mimeType:"video/mp4",pathExt:"mp4"},MP3:{name:"mp3",mimeType:"audio/mpeg",pathExt:"mp3"}},L=new Map([["mpegdash",M.DASH],["applehttp",M.HLS],["url",M.MP4]]);function b(t){const e=L.get(t);return!!e&&e.name===M.MP4.name}class N{constructor(){this.progressive=[],this.dash=[],this.hls=[],this.image=[]}map(t,e){if(e)switch(e.name){case M.MP4.name:this.progressive.push(t);break;case M.DASH.name:this.dash.push(t);break;case M.HLS.name:this.hls.push(t)}}toJSON(){const t={progressive:[],dash:[],hls:[],image:[]};return this.progressive.forEach((e=>t.progressive.push(e.toJSON()))),this.hls.forEach((e=>t.hls.push(e.toJSON()))),this.dash.forEach((e=>t.dash.push(e.toJSON()))),t.image=this.image,t}}class U{static Type={VOD:"Vod",LIVE:"Live",IMAGE:"Image",AUDIO:"Audio",UNKNOWN:"Unknown"};static DvrStatus={ON:1,OFF:0};constructor(){this.metadata=new Map,this.sources=new N,this.type=U.Type.UNKNOWN}toJSON(){return{id:this.id,name:this.name,sources:this.sources.toJSON(),duration:this.duration,dvrStatus:this.dvrStatus,status:this.status,metadata:this.metadata,type:this.type,poster:this.poster,assetReferenceType:this.assetReferenceType,downloadUrl:this.downloadUrl}}}class k{constructor(t,e,s){this.licenseUrl=t,this.scheme=e,s&&(this.certificate=s)}toJSON(){const t={licenseUrl:this.licenseUrl,scheme:this.scheme};return this.certificate&&(t.certificate=this.certificate),t}}class x{toJSON(){const t={id:this.id,url:this.url,mimetype:this.mimetype};return this.bandwidth&&(t.bandwidth=this.bandwidth),this.width&&(t.width=this.width),this.height&&(t.height=this.height),this.label&&(t.label=this.label),this.drmData&&this.drmData.length>0&&(t.drmData=[],this.drmData.forEach((e=>{Array.isArray(t.drmData)&&t.drmData.push(e.toJSON())}))),t}}class V{constructor(){this.items=[]}}class j{constructor(){this.items=[]}}class F{constructor(t){this.url=t.url,this.clickThroughUrl=t.clickThroughUrl}}const q={SRT:"1",DFXP:"2",WEBVTT:"3",CAP:"4"},H={3:"vtt",1:"srt"};class B{static createConfig(t,e){return t.map((t=>{let s=t.url,r=H[t.format];return[q.DFXP,q.CAP].includes(t.format)&&(s=t.webVttUrl,r=H[q.WEBVTT]),s=G(s,e),{default:!!t.isDefault,type:r,language:t.languageCode,label:t.label,url:s}}))}}class K{constructor(t){this.id=t.id,this.url=K.extractBaseThumbnailUrl(t.dataUrl),this.mimetype=""}static extractBaseThumbnailUrl(t){return t.match(".+entry_id/[a-zA-Z0-9_]+/")[0].slice(0,-1)}}class W{static _logger=o("OVPProviderParser");static getMediaEntry(t,e,s,r){const a=new U,i=r.entry,o=r.playBackContextResult,n=r.metadataListResult,c=o.sources;return a.sources=W._getParsedSources(c,t,e,s,i,o),W._fillBaseData(a,i,n),a.type!==U.Type.LIVE&&l.get().useApiCaptions&&o.data.playbackCaptions&&(a.sources.captions=B.createConfig(o.data.playbackCaptions,t)),a}static addKsToUrl(t,e){let s;return e?(s=-1!==t.split("?")[0].replace(/^.*[\\/]/,"").indexOf(".")?-1===t.indexOf("?")?"?ks=":"&ks=":"/ks/",t+s+e):t}static getPlaylist(t){const e=new V,s=t.playlistData,r=t.playlistItems.entries,a=t.playlistUserEntries.entries;return e.id=s.id,e.name=s.name,e.description=s.description,e.poster=s.poster,e.playlistLastEntryId=a.map((t=>t.playlistLastEntryId))[0],r.forEach((t=>{const s=new U;W._fillBaseData(s,t),e.items.push(s)})),e}static getEntryList(t){const e=new j;return t.playlistItems.entries.forEach((t=>{const s=new U;W._fillBaseData(s,t),e.items.push(s)})),e}static getBumper(t,e,s){const r=t.playBackContextResult,a=r.bumperData[0];if(a){const t=(a&&a.sources).find((t=>b(t.format)));if(t){const i=W._parseProgressiveSources(t,r,e,s,0,a.entryId);if(i[0])return new F({url:i[0].url,clickThroughUrl:a.clickThroughUrl})}}}static _fillBaseData(t,e,s){return t.poster=e.poster,t.id=e.id,t.duration=e.duration,t.downloadUrl=e.downloadUrl||"",t.metadata=W._parseMetadata(s),t.metadata.description=e.description||"",t.metadata.entryId=e.id||"",t.metadata.name=e.name||"",e.createdAt&&(t.metadata.createdAt=e.createdAt),e.updatedAt&&(t.metadata.updatedAt=e.updatedAt),e.creatorId&&(t.metadata.creatorId=e.creatorId),e.endDate&&(t.metadata.endDate=e.endDate),e.views&&(t.metadata.views=e.views),e.plays&&(t.metadata.plays=e.plays),t.metadata.tags=e.tags||"",t.status=e.status,t.type=W._getEntryType(e.entryType,e.type),t.type===U.Type.LIVE&&(t.dvrStatus=e.dvrStatus),t}static _getEntryType(t,e){let s=U.Type.UNKNOWN;switch(t){case h.MediaType.IMAGE.value:s=U.Type.IMAGE;break;case h.MediaType.AUDIO.value:s=U.Type.AUDIO;break;default:switch(e){case h.EntryType.MEDIA_CLIP.value:s=U.Type.VOD;break;case h.EntryType.LIVE_STREAM.value:case h.EntryType.LIVE_CHANNEL.value:s=U.Type.LIVE;break;default:s=U.Type.UNKNOWN}}return s}static _getParsedSources(t,e,s,r,a,i){const o=new N;return a.type===h.EntryType.EXTERNAL_MEDIA.value?(()=>{const t=new x;t.mimetype="video/youtube",t.url=a.referenceId,t.id=a.id+"_youtube",o.progressive.push(t)})():a.entryType===h.MediaType.IMAGE.value?o.image.push(new K(a)):t&&t.length>0&&(t.filter((t=>!b(t.format))).forEach((t=>{const n=W._parseAdaptiveSource(t,i,e,s,r,a.id);if(n){const e=L.get(t.format);o.map(n,e)}})),(()=>{const n=t.find((t=>b(t.format)&&""!==t.getProtocol(W._getBaseProtocol())));o.progressive=W._parseProgressiveSources(n,i,e,s,r,a.id)})()),o}static _parseAdaptiveSource(t,e,s,r,a,i){const o=new x;if(t){let n="";const c=L.get(t.format),l=t.getProtocol(W._getBaseProtocol()),d=t.deliveryProfileId,u=t.format;let h="";if(c&&(h=c.pathExt,o.mimetype=c.mimeType),t.hasFlavorIds()?(!h&&e.flavorAssets&&e.flavorAssets.length>0&&(h=e.flavorAssets[0].fileExt),n=w.build({entryId:i,flavorIds:t.flavorIds,format:u,ks:s,partnerId:r,uiConfId:a,extension:h,protocol:l})):n=W.addKsToUrl(t.url,s),!n){const t=`failed to create play url from source, discarding source: (${i}_${d}), ${u}`;return W._logger.warn(t),null}if(o.url=n,o.id=i+"_"+d+","+u,t.hasDrmData()){const e=[];t.drm.forEach((t=>{e.push(new k(t.licenseURL,y.Scheme[t.scheme],t.certificate))})),o.drmData=e}}return o}static _parseProgressiveSources(t,e,s,r,a,i){const o=[],n=[];if(t){const c=t.getProtocol(W._getBaseProtocol()),l=t.format,d=t.deliveryProfileId,u=d+","+l;e.flavorAssets.map((t=>{const e=new x;e.id=t.id+u,e.mimetype="mp3"===t.fileExt?"audio/mp3":"video/mp4",e.height=t.height,e.width=t.width,e.bandwidth=1024*t.bitrate,e.label=t.label||t.language;const h=w.build({entryId:i,flavorIds:t.id,format:l,ks:s,partnerId:r,uiConfId:a,extension:t.fileExt,protocol:c});if(""===h)return W._logger.warn(`failed to create play url from source, discarding source: (${i}_${d}), ${l}.`),null;e.url=h,t.height&&t.width?o.push(e):n.push(e)}))}return n.length&&!o.length?n:o}static _parseMetadata(t){const e={};return t&&t.metas&&t.metas.length>0&&t.metas.forEach((t=>{if(t.xml){const s=new DOMParser;t.xml=t.xml.replace(/\r?\n|\r/g,""),t.xml=t.xml.replace(/>\s*/g,">"),t.xml=t.xml.replace(/>\s*/g,">");const r=s.parseFromString(t.xml,"text/xml"),a=D.xmlToJson(r);Object.keys(a.metadata).forEach((t=>{e[t]=a.metadata[t]["#text"]}))}})),e}static _getBaseProtocol(){const t=l.get(),e=/^https?:/.exec(t.cdnUrl),s=e?e[0]:document.location.protocol;return"string"==typeof s?s.slice(0,-1):"https"}static hasBlockAction(t){return t.playBackContextResult.hasBlockAction()}static getBlockAction(t){return t.playBackContextResult.getBlockAction()}static getErrorMessages(t){return t.playBackContextResult.getErrorMessages()}}const G=W.addKsToUrl,Y=W,J={RECOVERABLE:1,CRITICAL:2},$={UNSUPPORTED_SCHEME:1e3,BAD_HTTP_STATUS:1001,HTTP_ERROR:1002,TIMEOUT:1003,MALFORMED_DATA_URI:1004,BAD_SERVER_RESPONSE:1005,MULTIREQUEST_API_ERROR:1006,API_RESPONSE_MISMATCH:1007,ERROR:2e3,BLOCK_ACTION:2001,MEDIA_STATUS_NOT_READY:2002,MISSING_MANDATORY_PARAMS:3e3,MISSING_PLAY_SOURCE:3001,METHOD_NOT_IMPLEMENTED:3002},X={NETWORK:1,SERVICE:2,PROVIDER:3};class Q{static Severity=J;static Category=X;static Code=$;static _logger=o("Error");constructor(t,e,s,r={}){this.severity=t,this.category=e,this.code=s,this.data=r,Q._logger.error(`Category:${e} | Code:${s} |`,r)}}class Z{retryConfig={async:!0,timeout:0,maxAttempts:4};_attemptCounter=1;constructor(t=new Map){this.headers=t}getUrl(t){return t+"/service/"+this.service+(this.action?"/action/"+this.action:"")}doHttpRequest(){const t=new Promise(((t,e)=>{this._requestPromise={resolve:t,reject:e}}));return this.url||this._requestPromise.reject(new Q(Q.Severity.CRITICAL,Q.Category.NETWORK,Q.Code.MALFORMED_DATA_URI,{url:this.url})),this._createXHR(),t}_createXHR(){const t=new XMLHttpRequest;t.onreadystatechange=()=>{if(4===t.readyState&&200===t.status)try{const e=JSON.parse(t.responseText);return this.responseHeaders=this._getResponseHeaders(t),this._requestPromise.resolve(e)}catch(e){this._requestPromise.reject(this._createError(t,Q.Code.BAD_SERVER_RESPONSE,{text:t.responseText}))}},t.open(this.method,this.url,this.retryConfig.async),this.retryConfig.async&&this.retryConfig.timeout&&(t.timeout=this.retryConfig.timeout);const e=performance.now();t.ontimeout=()=>{this._handleError(t,Q.Code.TIMEOUT,{timeout:(performance.now()-e)/1e3,statusText:t.statusText})},t.onerror=t.onabort=()=>{this._handleError(t,Q.Code.HTTP_ERROR,{text:t.responseText,statusText:t.statusText})},this.headers.forEach(((e,s)=>{t.setRequestHeader(s,e)})),t.send(this.params)}_getResponseHeaders(t){return t.getAllResponseHeaders().split("\n").filter((t=>0===t.toLowerCase().indexOf("x-")))}_handleError(t,e,s){const r=this._createError(t,e,s);if(t.onreadystatechange=function(){},t.onerror=function(){},t.ontimeout=function(){},t.onabort=function(){},!(this.retryConfig.maxAttempts&&this._attemptCounter<this.retryConfig.maxAttempts))return this._requestPromise.reject(r);this._attemptCounter++,this._createXHR()}_createError(t,e,s){return Object.assign(s,{url:this.url,headers:this._getResponseHeaders(t),attempt:this._attemptCounter}),new Q(Q.Severity.CRITICAL,Q.Category.NETWORK,e,s)}}class z extends Z{static _logger=o("MultiRequestBuilder");requests=[];add(t){this.requests.push(t);const e={},s={service:t.service,action:t.action};return Object.assign(e,{[this.requests.length]:Object.assign(s,t.params)}),Object.assign(e,this.params),this.params=e,this}execute(t){return new Promise(((e,s)=>{try{this.params=JSON.stringify(this.params)}catch(t){z._logger.error(`${t.message}`),s(new Q(Q.Severity.CRITICAL,Q.Category.PROVIDER,Q.Code.FAILED_PARSING_REQUEST,{error:t,params:this.params}))}this.doHttpRequest().then((r=>{const a=new tt(r,t);a.success?e({headers:this.responseHeaders,response:a}):s(new Q(Q.Severity.CRITICAL,Q.Category.NETWORK,Q.Code.MULTIREQUEST_API_ERROR,{url:this.url,headers:this.responseHeaders,results:a.results}))}),(t=>{s(t)}))}))}}class tt{static _logger=o("MultiRequestResult");results=[];constructor(t,e=!0){const s=t.result?t.result:t,r=(Array.isArray(s)?s:[s]).map((t=>new d(t))),a=r.filter((t=>t.hasError));a.forEach((t=>{tt._logger.error(`Service returned an error with error code: ${t.error.code} and message: ${t.error.message}.`)})),this.results=r,e&&a.length||a.length===this.results.length?this.success=!1:(this.results=this.results.filter((t=>!t.hasError)),this.success=!0)}}class et{static getMultiRequest(t,e,s){const r=l.get(),a=r.serviceParams;Object.assign(a,{ks:e,clientTag:"html5:v"+t}),s&&Object.assign(a,{partnerId:s});const i=new Map;i.set("Content-Type","application/json");const o=new z(i);return o.method="POST",o.service="multirequest",o.url=o.getUrl(r.serviceUrl),o.params=a,o}}const st={INCLUDE_FIELDS:1,EXCLUDE_FIELDS:2};class rt{static Type=st;constructor(t={}){this.type=t.type||rt.Type.INCLUDE_FIELDS,this.fields=t.fields||"id,referenceId,name,description,thumbnailUrl,dataUrl,duration,msDuration,flavorParamsIds,mediaType,type,tags,dvrStatus,externalSourceType,status,createdAt,updatedAt,endDate,plays,views,downloadUrl,creatorId"}}const at="baseEntry";class it extends et{static getPlaybackContext(t,e,s){const r=new Map;r.set("Content-Type","application/json");const a=new Z(r);return a.service=at,a.action="getPlaybackContext",a.method="POST",a.url=a.getUrl(t),a.tag="baseEntry-getPlaybackContext",a.params={entryId:s,ks:e,contextDataParams:{objectType:"KalturaContextDataParams",flavorTags:"all"}},a}static list(t,e,s,r,a){const i=new Map;i.set("Content-Type","application/json");const o=new Z(i);return o.service=at,o.action="list",o.method="POST",o.url=o.getUrl(t),o.tag="list",o.params=it.getEntryListReqParams(s,e,r,a),o}static getEntryListReqParams(t,e,s,r){let a={};return t?a=s?{redirectFromEntryId:t}:{idEqual:t}:r&&(a={objectType:"KalturaBaseEntryFilter",referenceIdEqual:r}),{ks:e,filter:a,responseProfile:new rt}}}class ot extends et{static list(t,e,s){const r=new Map;r.set("Content-Type","application/json");const a=new Z(r);a.service="metadata_metadata",a.action="list",a.method="POST",a.url=a.getUrl(t),a.tag="metadata_metadata-list";const i={objectType:"KalturaMetadataFilter",objectIdEqual:s,metadataObjectTypeEqual:"1"};return a.params={filter:i,ks:e},a}}class nt{_response={};static get id(){return"media"}constructor(t){this.requests=this.buildRequests(t),this._entryId=t.entryId,this._referenceId=t.referenceId}set requests(t){this._requests=t}get requests(){return this._requests}set response(t){const e=new p(t[0].data);this._response.entry=e.entries[0],this._response.playBackContextResult=new C(t[1].data),this._response.metadataListResult=new T(t[2].data)}get response(){return this._response}buildRequests(t){const e=l.get(),s=[];s.push(it.list(e.serviceUrl,t.ks,t.entryId,t.redirectFromEntryId,t.referenceId));const r="{1:result:ks}"===t.ks?"{2:result:objects:0:id}":"{1:result:objects:0:id}";return s.push(it.getPlaybackContext(e.serviceUrl,t.ks,r)),s.push(ot.list(e.serviceUrl,t.ks,r)),s}isValid(){return!(!this._entryId&&!this._referenceId)}}class ct extends et{static anonymousSession(t,e){const s=new Map;s.set("Content-Type","application/json");const r=new Z(s);return r.service="session",r.action="startWidgetSession",r.method="POST",r.url=r.getUrl(t),r.tag="session-startWidget",r.params={widgetId:e},r}}class lt{_response={};static get id(){return"session"}set requests(t){this._requests=t}get requests(){return this._requests}set response(t){this._response.ks=t[0].data.ks}get response(){return this._response.ks}constructor(t){this.requests=this.buildRequests(t),this._widgetId=t.widgetId}buildRequests(t){const e=l.get(),s=[];return s.push(ct.anonymousSession(e.serviceUrl,t.widgetId)),s}isValid(){return!!this._widgetId}}class dt{_loadersResponseMap=new Map;_loaders=new Map;constructor(t){this._networkRetryConfig=t}add(t,e,s){const r=new t(e);if(r.isValid()){this._loaders.set(t.id,r);const e=this._multiRequest.requests.length,a=r.requests;this._multiRequest.retryConfig=this._networkRetryConfig,a.forEach((t=>{t.params=t.params||{},t.params.ks=t.params.ks||s,this._multiRequest.add(t)}));const i=Array.from(new Array(a.length),((t,s)=>s+e));this._loadersResponseMap.set(t.id,i)}}fetchData(t){return new Promise(((e,s)=>{this._multiRequest.execute(t).then((t=>{this._multiResponse=t.response,this.prepareData(t.response).success?e(this._loaders):s(new Q(Q.Severity.CRITICAL,Q.Category.NETWORK,Q.Code.API_RESPONSE_MISMATCH,{headers:t.headers}))}),(t=>{s(t)}))}))}prepareData(t){return this._loaders.forEach(((e,s)=>{const r=this._loadersResponseMap.get(s);try{r&&r.length>0&&(e.response=t.results.slice(r[0],r[r.length-1]+1))}catch(t){return{success:!1,error:t}}})),{success:!0,data:this._loaders}}}class ut extends dt{constructor(t,e,s="",r){super(r),this._multiRequest=et.getMultiRequest(t,s,e)}}const ht="playlist";class pt extends et{static execute(t,e,s){const r=new Map;r.set("Content-Type","application/json");const a=new Z(r);return a.service=ht,a.action="execute",a.method="POST",a.url=a.getUrl(t),a.tag=`${ht}-execute`,a.params={ks:e,id:s,responseProfile:new rt},a}static get(t,e,s){const r=new Map;r.set("Content-Type","application/json");const a=new Z(r);return a.service=ht,a.action="get",a.method="POST",a.url=a.getUrl(t),a.tag=`${ht}-get`,a.params={ks:e,id:s,responseProfile:{fields:"id,name,description,thumbnailUrl",type:1}},a}static getLastEntryId(t,e,s){const r=new Map;r.set("Content-Type","application/json");const a=new Z(r);return a.service="userEntry",a.action="list",a.method="POST",a.url=a.getUrl(t),a.tag="userEntry-list",a.params={ks:e,filter:{objectType:"KalturaViewHistoryUserEntry",entryIdEqual:s,userIdEqualCurrent:1},responseProfile:{fields:"playlistLastEntryId",type:1}},a}}class gt{_response={};static get id(){return"playlist"}constructor(t){this.requests=this.buildRequests(t),this._playlistId=t.playlistId}set requests(t){this._requests=t}get requests(){return this._requests}set response(t){this._response.playlistData=new v(t[0].data),this._response.playlistItems=new f(t[1].data),this._response.playlistUserEntries=new S(t[2].data)}get response(){return this._response}buildRequests(t){const e=l.get(),s=[];return s.push(pt.get(e.serviceUrl,t.ks,t.playlistId)),s.push(pt.execute(e.serviceUrl,t.ks,t.playlistId)),s.push(pt.getLastEntryId(e.serviceUrl,t.ks,t.playlistId)),s}isValid(){return!!this._playlistId}}class mt{_networkRetryConfig={async:!0,timeout:0,maxAttempts:4};get partnerId(){return this._partnerId}get widgetId(){return this._widgetId||this.defaultWidgetId}get defaultWidgetId(){return"_"+this._partnerId}get uiConfId(){return this._uiConfId}get ks(){return this._ks}set ks(t){this._ks=t}get playerVersion(){return this._playerVersion}get isAnonymous(){return this._isAnonymous}constructor(t,e){!function(t){t&&"function"==typeof t.getLogger&&(r.get=t.getLogger),t&&t.LogLevel&&(a=t.LogLevel)}(t.logger),this._partnerId=t.partnerId,this._widgetId=t.widgetId,this._uiConfId=t.uiConfId,this._isAnonymous=!t.ks,this._ks=t.ks||"",this._playerVersion=e}getMediaConfig(t){return Promise.reject(new Q(Q.Severity.CRITICAL,Q.Category.PROVIDER,Q.Code.METHOD_NOT_IMPLEMENTED,{message:"getMediaConfig method must be implement by the derived class"}))}getPlaylistConfig(t){return Promise.reject(new Q(Q.Severity.CRITICAL,Q.Category.PROVIDER,Q.Code.METHOD_NOT_IMPLEMENTED,{message:"The provider does not support loading playlist by id"}))}getEntryListConfig(t){return Promise.reject(new Q(Q.Severity.CRITICAL,Q.Category.PROVIDER,Q.Code.METHOD_NOT_IMPLEMENTED,{message:"The provider does not support loading entry list"}))}_verifyHasSources(t){if(0===t.hls.concat(t.dash,t.progressive,t.image).length)throw new Q(Q.Severity.CRITICAL,Q.Category.SERVICE,Q.Code.MISSING_PLAY_SOURCE,{action:"",messages:`No play source for entry id: ${t.id}`})}get LogLevel(){return a}getLogLevel(t){return function(t){return i(t).getLevel()}(t)}setLogLevel(t,e){!function(t,e){i(e).setLevel(t)}(t,e)}}class yt{_response={playlistItems:{entries:[]}};static get id(){return"entry_list"}constructor(t){this.requests=this.buildRequests(t),this._entries=t.entries}set requests(t){this._requests=t}get requests(){return this._requests}set response(t){let e;t.forEach((t=>{e=new p(t.data),this._response.playlistItems.entries.push(e.entries[0])}))}get response(){return this._response}buildRequests(t){const e=l.get(),s=[];return t.entries.forEach((r=>{s.push(it.list(e.serviceUrl,t.ks,r.entryId||r,t.redirectFromEntryId,r.referenceId))})),s}isValid(){return!(!this._entries||!this._entries.length)}}class Et{static _logger=o("RegexActionHandler");static _applyRegexAction(t,e){if(t){const s=new RegExp(t.pattern,"i");if(e.match(s))return e.replace(s,t.replacement+"/")}return e}static async _isECDNUrlAlive(t,e){const s=e+"/api_v3/service/system/action/ping/format/1",r=new XMLHttpRequest;return r.open("GET",s),r.timeout=t.checkAliveTimeoutMs,r.onreadystatechange=()=>4===r.readyState&&200===r.status,r.ontimeout=()=>(Et._logger.warn(`Got timeout while pinging the ECDN url. the ping url: ${s}`),!1),r.send(),!1}static async handleRegexAction(t,e){const s=l.get().cdnUrl,r=Et._extractRegexActionFromData(e),a=Et._getRegExp(r);return!(s&&r&&a&&s.match(a))||r.checkAliveTimeoutMs>0&&!await Et._isECDNUrlAlive(r,s.replace(a,r.replacement))?(Et._logger.debug("exiting handleRegexAction - not applying regex action."),t):(Et._replaceHostUrls(t,r),t)}static _replaceHostUrls(t,e){Et._logger.debug("Starting to modify urls...");const s=t.sources,{hls:r,dash:a,progressive:i,image:o}=s;[...r,...a,...i,...o].forEach((t=>t.url=Et._applyRegexAction(e,t.url))),l.get().replaceHostOnlyManifestUrls||(Et._logger.debug("replaceHostOnlyManifestUrls flag is off - modifying captions and poster URLs"),s.captions&&s.captions.forEach((t=>t.url=Et._applyRegexAction(e,t.url))),"string"==typeof s.poster&&(s.poster=Et._applyRegexAction(e,s.poster))),Et._logger.debug("Finished modifying urls")}static _extractRegexActionFromData(t){return t.get(nt.id)?.response?.playBackContextResult.getRequestHostRegexAction()}static _getRegExp(t){if(t&&t.pattern&&t.replacement)return new RegExp(t.pattern,"i")}}const It=Et;class _t extends mt{_filterOptionsConfig={redirectFromEntryId:!0};constructor(t,e){super(t,e),this._logger=o("OVPProvider"),l.set(t.env),this._setFilterOptionsConfig(t.filterOptions),this._networkRetryConfig=Object.assign(this._networkRetryConfig,t.networkRetryParameters)}get env(){return l.get()}getMediaConfig(t){return t.ks&&(this.ks=t.ks,this._isAnonymous=!1),this.widgetId!==this.defaultWidgetId&&(this._isAnonymous=!1),this._dataLoader=new ut(this.playerVersion,this.partnerId,this.ks,this._networkRetryConfig),new Promise(((e,s)=>{const r=t.entryId,a=t.referenceId;if(r||a){let i=this.ks;i||(i="{1:result:ks}",this._dataLoader.add(lt,{widgetId:this.widgetId}));const o=this._getEntryRedirectFilter(t);return this._dataLoader.add(nt,{entryId:r,ks:i,redirectFromEntryId:o,referenceId:a}),this._dataLoader.fetchData().then((t=>{try{const s=this._parseDataFromResponse(t);It.handleRegexAction(s,t).then(e)}catch(t){s(t)}}),(t=>{s(t)}))}s(new Q(Q.Severity.CRITICAL,Q.Category.PROVIDER,Q.Code.MISSING_MANDATORY_PARAMS,{message:"missing entry id"}))}))}doRequest(t,e){const s=e||this.ks,r=new ut(this.playerVersion,this.partnerId,s,this._networkRetryConfig);return new Promise(((e,a)=>(s||r.add(lt,{widgetId:this.widgetId}),t.forEach((t=>{r.add(t.loader,t.params,s||"{1:result:ks}")})),r.fetchData().then((t=>{try{e(t)}catch(t){a(t)}}),(t=>{a(t)})))))}_getEntryRedirectFilter(t){return"boolean"==typeof t.redirectFromEntryId?t.redirectFromEntryId:"boolean"!=typeof this._filterOptionsConfig.redirectFromEntryId||this._filterOptionsConfig.redirectFromEntryId}_setFilterOptionsConfig(t){t&&"boolean"==typeof t.redirectFromEntryId&&(this._filterOptionsConfig.redirectFromEntryId=t.redirectFromEntryId)}_parseDataFromResponse(t){this._logger.debug("Data parsing started");const e={session:{isAnonymous:this._isAnonymous,partnerId:this.partnerId},sources:this._getDefaultSourcesObject(),plugins:{}};if(this.uiConfId&&(e.session.uiConfId=this.uiConfId),t){if(t.has(lt.id)){const s=t.get(lt.id);s&&s.response&&(e.session.ks=s.response,this.widgetId!==this.defaultWidgetId&&(this.ks=e.session.ks))}else e.session.ks=this.ks;if(t.has(nt.id)){const s=t.get(nt.id);if(s&&s.response){const t=s.response;if(Y.hasBlockAction(t))throw new Q(Q.Severity.CRITICAL,Q.Category.SERVICE,Q.Code.BLOCK_ACTION,{action:Y.getBlockAction(t),messages:Y.getErrorMessages(t)});const r=Y.getMediaEntry(this.isAnonymous?"":this.ks,this.partnerId,this.uiConfId,t);Object.assign(e.sources,this._getSourcesObject(r)),this._verifyMediaStatus(r),this._verifyHasSources(e.sources);const a=Y.getBumper(t,this.isAnonymous?"":this.ks,this.partnerId);a&&Object.assign(e.plugins,{bumper:a})}}}return this._logger.debug("Data parsing finished",e),e}_verifyMediaStatus(t){if([h.EntryStatus.IMPORT,h.EntryStatus.PRECONVERT].includes(t.status))throw new Q(Q.Severity.CRITICAL,Q.Category.SERVICE,Q.Code.MEDIA_STATUS_NOT_READY,{messages:`Status of entry id ${t.id} is ${t.status} and is still being imported or converted`,data:{status}})}getPlaylistConfig(t){return t.ks&&(this.ks=t.ks,this._isAnonymous=!1),this.widgetId!==this.defaultWidgetId&&(this._isAnonymous=!1),this._dataLoader=new ut(this.playerVersion,this.partnerId,this.ks,this._networkRetryConfig),new Promise(((e,s)=>{const r=t.playlistId;if(r){let t=this.ks;t||(t="{1:result:ks}",this._dataLoader.add(lt,{widgetId:this.widgetId})),this._dataLoader.add(gt,{playlistId:r,ks:t}),this._dataLoader.fetchData().then((t=>{e(this._parsePlaylistDataFromResponse(t))}),(t=>{s(t)}))}else s({success:!1,data:"Missing mandatory parameter"})}))}_parsePlaylistDataFromResponse(t){this._logger.debug("Data parsing started");const e=this._getPlaylistObject();if(t&&t.has(gt.id)){const s=t.get(gt.id);if(s&&s.response){const t=Y.getPlaylist(s.response);e.id=t.id,e.poster=t.poster,e.metadata.name=t.name,e.metadata.description=t.description,e.playlistLastEntryId=t.playlistLastEntryId,t.items.forEach((t=>e.items.push({sources:this._getSourcesObject(t)})))}}return this._logger.debug("Data parsing finished",e),e}getEntryListConfig(t){return t.ks&&(this.ks=t.ks,this._isAnonymous=!1),this.widgetId!==this.defaultWidgetId&&(this._isAnonymous=!1),this._dataLoader=new ut(this.playerVersion,this.partnerId,this.ks,this._networkRetryConfig),new Promise(((e,s)=>{const r=t.entries;if(r&&r.length){let a=this.ks;a||(a="{1:result:ks}",this._dataLoader.add(lt,{widgetId:this.widgetId}));const i=this._getEntryRedirectFilter(t);this._dataLoader.add(yt,{entries:r,ks:a,redirectFromEntryId:i}),this._dataLoader.fetchData(!1).then((t=>{e(this._parseEntryListDataFromResponse(t))}),(t=>{s(t)}))}else s({success:!1,data:"Missing mandatory parameter"})}))}_parseEntryListDataFromResponse(t){this._logger.debug("Data parsing started");const e=this._getPlaylistObject();if(t&&t.has(yt.id)){const s=t.get(yt.id);s&&s.response&&Y.getEntryList(s.response).items.forEach((t=>e.items.push({sources:this._getSourcesObject(t)})))}return this._logger.debug("Data parsing finished",e),e}_getPlaylistObject(){return{id:"",metadata:{name:"",description:""},poster:"",playlistLastEntryId:"",items:[]}}_getDefaultSourcesObject(){return{hls:[],dash:[],progressive:[],image:[],id:"",duration:0,type:U.Type.UNKNOWN,poster:"",dvr:!1,vr:null,metadata:{name:"",description:"",tags:""}}}_getSourcesObject(t){const e=this._getDefaultSourcesObject(),s=t.sources.toJSON();return e.hls=s.hls,e.dash=s.dash,e.progressive=s.progressive,e.image=s.image,e.id=t.id,e.duration=t.duration,e.type=t.type,e.dvr=!!t.dvrStatus,e.poster=t.poster,e.downloadUrl=t.downloadUrl,t.sources.captions&&(e.captions=t.sources.captions),t.metadata&&"string"==typeof t.metadata.tags&&t.metadata.tags.split(", ").includes("360")&&(e.vr={}),Object.assign(e.metadata,t.metadata),e}}const ft="@playkit-js/playkit-js-providers-ovp",Rt="2.41.0-canary.0-2452bbc";return e})()));
|
|
2
2
|
//# sourceMappingURL=playkit-ovp-provider.js.map
|