<commit_before>( function( mw, $ ) {"use strict";
/**
 * Add the messages text:
 *  TODO remove once we switch to RL17
 */

mw.KWidgetSupport = function( options ) {
	// Create KWidgetSupport instance
	return this.init( options );
};
mw.KWidgetSupport.prototype = {

	// The Kaltura client local reference
	kClient : null,
	kSessionId: null, // Used for Analytics events

	// Constructor check settings etc
	init: function( options ){
		if( options ){
			$.extend( this, options);
		}
		this.addPlayerHooks();
	},
	isIframeApiServer: function(){
		return ( mw.getConfig( 'EmbedPlayer.IsIframeServer' )
					&&
				mw.getConfig( 'EmbedPlayer.EnableIframeApi' )
					&&
				mw.getConfig( 'EmbedPlayer.IframeParentUrl' ) )
	},
	/**
	* Add Player hooks for supporting Kaltura api
	*/
	addPlayerHooks: function( ){
		var _this = this;
		// Add the hooks to the player manager
		$( mw ).bind( 'EmbedPlayerNewPlayer', function( event, embedPlayer ) {
			// Check if we should add binding: ( we need a widget id )
			if( ! embedPlayer.kwidgetid ){
				return ;
			}
			_this.bindPlayer( embedPlayer );
			// Add KDP API mapping ( will trigger playerReady for adding jsListeners ) 
			new mw.KDPMapping( embedPlayer );

		});
	},
	
	/**
	 * Add player bindings
	 * @param {Object} embedPlayer 
	 */
	bindPlayer: function( embedPlayer ){
		var _this = this;
		// Add player methods: 
		this.addPlayerMethods( embedPlayer );

		// Setup uiConf
		_this.setUiConf( embedPlayer );

		// Overrides the direct download link to kaltura specific download.php tool for
		// selecting a download / playback flavor based on user agent. 
		embedPlayer.bindHelper( 'directDownloadLink', function( event, downloadUrlCallback ) {
			var baseUrl = mw.getConfig('wgLoadScript').replace( 'load.php', '' );
			var downloadUrl = baseUrl + 'modules/KalturaSupport/download.php/wid/' + embedPlayer.kwidgetid;

			// Also add the uiconf id to the url:
			if( embedPlayer.kuiconfid ){
				downloadUrl += '/uiconf_id/' + embedPlayer.kuiconfid;
			}

			if( embedPlayer.kentryid ) {
				downloadUrl += '/entry_id/'+ embedPlayer.kentryid;
			}
			
			// Get KS and append to download url ( should be sync call )
			var client = mw.kApiGetPartnerClient( embedPlayer.kwidgetid );
			// Append ks & referrer for access control
			var referrer = base64_encode( kWidgetSupport.getHostPageUrl() );
			client.getKS(function( ks ){
				downloadUrl += '/?ks=' + ks + '&referrer=' + referrer;
				downloadUrlCallback( downloadUrl );
			});
		});
		
		// Add hook for check player sources to use local kEntry ID source check:
		embedPlayer.bindHelper( 'checkPlayerSourcesEvent', function( event, callback ) {
			_this.loadAndUpdatePlayerData( embedPlayer, callback );
		});

		embedPlayer.bindHelper( 'KalturaSupport_EntryDataReady', function() {
			var thumbUrl = embedPlayer.evaluate('{mediaProxy.entry.thumbnailUrl}');
			// Only append width/height params if thumbnail from kaltura service ( could be external thumbnail )
<<<<<<< HEAD:modules/KalturaSupport/resources/mw.KWidgetSupport.js
			if( thumbUrl.indexOf( "thumbnail/entry_id" ) != -1 ){
			  	thumbUrl += '/width/' + embedPlayer.getWidth();
			  	thumbUrl += '/height/' + embedPlayer.getHeight();
			}
		  	embedPlayer.updatePosterSrc( thumbUrl );
		});
		
		// Add black sources:
		embedPlayer.bindHelper( 'AddEmptyBlackSources', function( event, vid ){
			$.each( mw.getConfig( 'Kaltura.BlackVideoSources' ), function(inx, sourceAttr ){<commit_msg>removed broken merge line <commit_after>( function( mw, $ ) {"use strict";
/**
 * Add the messages text:
 *  TODO remove once we switch to RL17
 */

mw.KWidgetSupport = function( options ) {
	// Create KWidgetSupport instance
	return this.init( options );
};
mw.KWidgetSupport.prototype = {

	// The Kaltura client local reference
	kClient : null,
	kSessionId: null, // Used for Analytics events

	// Constructor check settings etc
	init: function( options ){
		if( options ){
			$.extend( this, options);
		}
		this.addPlayerHooks();
	},
	isIframeApiServer: function(){
		return ( mw.getConfig( 'EmbedPlayer.IsIframeServer' )
					&&
				mw.getConfig( 'EmbedPlayer.EnableIframeApi' )
					&&
				mw.getConfig( 'EmbedPlayer.IframeParentUrl' ) )
	},
	/**
	* Add Player hooks for supporting Kaltura api
	*/
	addPlayerHooks: function( ){
		var _this = this;
		// Add the hooks to the player manager
		$( mw ).bind( 'EmbedPlayerNewPlayer', function( event, embedPlayer ) {
			// Check if we should add binding: ( we need a widget id )
			if( ! embedPlayer.kwidgetid ){
				return ;
			}
			_this.bindPlayer( embedPlayer );
			// Add KDP API mapping ( will trigger playerReady for adding jsListeners ) 
			new mw.KDPMapping( embedPlayer );

		});
	},
	
	/**
	 * Add player bindings
	 * @param {Object} embedPlayer 
	 */
	bindPlayer: function( embedPlayer ){
		var _this = this;
		// Add player methods: 
		this.addPlayerMethods( embedPlayer );

		// Setup uiConf
		_this.setUiConf( embedPlayer );

		// Overrides the direct download link to kaltura specific download.php tool for
		// selecting a download / playback flavor based on user agent. 
		embedPlayer.bindHelper( 'directDownloadLink', function( event, downloadUrlCallback ) {
			var baseUrl = mw.getConfig('wgLoadScript').replace( 'load.php', '' );
			var downloadUrl = baseUrl + 'modules/KalturaSupport/download.php/wid/' + embedPlayer.kwidgetid;

			// Also add the uiconf id to the url:
			if( embedPlayer.kuiconfid ){
				downloadUrl += '/uiconf_id/' + embedPlayer.kuiconfid;
			}

			if( embedPlayer.kentryid ) {
				downloadUrl += '/entry_id/'+ embedPlayer.kentryid;
			}
			
			// Get KS and append to download url ( should be sync call )
			var client = mw.kApiGetPartnerClient( embedPlayer.kwidgetid );
			// Append ks & referrer for access control
			var referrer = base64_encode( kWidgetSupport.getHostPageUrl() );
			client.getKS(function( ks ){
				downloadUrl += '/?ks=' + ks + '&referrer=' + referrer;
				downloadUrlCallback( downloadUrl );
			});
		});
		
		// Add hook for check player sources to use local kEntry ID source check:
		embedPlayer.bindHelper( 'checkPlayerSourcesEvent', function( event, callback ) {
			_this.loadAndUpdatePlayerData( embedPlayer, callback );
		});

		embedPlayer.bindHelper( 'KalturaSupport_EntryDataReady', function() {
			var thumbUrl = embedPlayer.evaluate('{mediaProxy.entry.thumbnailUrl}');
			// Only append width/height params if thumbnail from kaltura service ( could be external thumbnail )
			if( thumbUrl.indexOf( "thumbnail/entry_id" ) != -1 ){
			  	thumbUrl += '/width/' + embedPlayer.getWidth();
			  	thumbUrl += '/height/' + embedPlayer.getHeight();
			}
		  	embedPlayer.updatePosterSrc( thumbUrl );
		});
		
		// Add black sources:
		embedPlayer.bindHelper( 'AddEmptyBlackSources', function( event, vid ){
			$.each( mw.getConfig( 'Kaltura.BlackVideoSources' ), function(inx, sourceAttr ){
{'fraction_non_alphanumeric': 0.12318208260616638, 'fraction_numerical': 0.0014543339150668994, 'mean_word_length': 3.560344827586207, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 26, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4259642', 'n_tokens_mistral': 2396, 'n_tokens_neox': 2093, 'n_words': 579}