<commit_before>'use strict';

var React = require('react');
var ReactDOM = require('react-dom');
var SceneStore = require('../stores/full-scene-store');
var ThemeSelector = require('../components/theme-selector.jsx');
var HubSendActions = require('../actions/hub-send-actions');
var FormHelper = require('../mixins/form-helper');
var Router = require('react-router');
var Authentication = require('../mixins/Authentication');
var Loader = require('../components/loader.jsx');
var _ = require('lodash');
var $ = require('jquery');
var TagMatcher = require('../utils/tag-matcher');
var MediaObjectQueueManager = require('../utils/media-object/media-object-queue-manager');
var TextMediaObject = require('../utils/media-object/text-media-object');
var ImageMediaObject = require('../utils/media-object/image-media-object');
var VideoMediaObject = require('../utils/media-object/video-media-object');
var AudioMediaObject = require('../utils/media-object/audio-media-object');
var RandomVisualPlayer = require('../components/viewer/random-visual-player.jsx');
var ActiveTheme = require('../components/viewer/viewer-active-theme.jsx');
var hat = require('hat');

var MINIMUM_NUMBER_OF_MEDIA_TO_BE_MATCHED_WITH_THEME_QUERY = 0;

function getTypeByName(typeName) {
    var t = _.find([TextMediaObject, ImageMediaObject, VideoMediaObject, AudioMediaObject], function (t) {
        return t.typeName === typeName;
    });

    if (!t) {
        throw 'type "' + typeName + '" not found.  Needs to be passed to constructor.';
    }

    return t;
}

var SceneListener = React.createClass({

    statics: {
        willTransitionFrom: function (transition, component) {
            HubSendActions.unsubscribeScene(component.getParams().id);
        }
    },

    _getSceneId: function () {
        if (this.props.activeScene) {
            return this.props.activeScene._id;
        }

        var sceneId = this.props.sceneId || this.props.params.id;

        return sceneId;
    },

    _getScene: function () {

        if (this.props.activeScene) {
            return this.props.activeScene;
        }

        var sceneId = this.props.sceneId || this.props.params.id;

        // console.log("SceneListener - _getScene - sceneId: ", sceneId);

        return SceneStore.getScene(sceneId);
    },

    getInitialState: function () {
        return {
            scene: this._getScene(),
            activeThemes: [],
            fromGraphViewer: this.props.activeScene ? true : false,
            triggeredActiveThemes: {},
            cuePointMediaObjects: [],
            shouldHide: false
        };
    },

    getPlayerElem: function () {
        return this.refs.player;
    },

    _getSceneForUpdatingPlayerComponent: function () {
        return this.props.activeScene || this.state.scene;
    },

    _setPlayerClassCssForScene: function (style) {
        _.forEach(Object.keys(style), function (styleKey) {
            var styleValue = style[styleKey];

            $('.player').css(styleKey, styleValue);
        });
    },

    _maybeUpdatePlayer: function () {

        var scene = this._getSceneForUpdatingPlayerComponent();

        if (scene) {
            // APEP Remove the old style added ready for new style or fallback to css class
            $('.player').removeAttr("style");
            if (scene.style) {
                this._setPlayerClassCssForScene(scene.style);
            }

            // console.log("SceneListenr - setScene for mediaObjectQueue - this.props.activeScene:", this.props.activeScene);

            this.mediaObjectQueue.setScene(scene); // TODO APEP {hardReset: true} I don't think we want to forcefully removal all

            this.updateTags();
        }
    },

    // APEP func to update after queue has made internal switch between modes
    mediaQueueManagerUpdate: function () {
        this.setState({mediaObjectQueue: this.mediaObjectQueue});
    },

    componentWillMount: function () {<commit_msg>Temp turn off of only 1 scene rule for graph player for IoT<commit_after>'use strict';

var React = require('react');
var ReactDOM = require('react-dom');
var SceneStore = require('../stores/full-scene-store');
var ThemeSelector = require('../components/theme-selector.jsx');
var HubSendActions = require('../actions/hub-send-actions');
var FormHelper = require('../mixins/form-helper');
var Router = require('react-router');
var Authentication = require('../mixins/Authentication');
var Loader = require('../components/loader.jsx');
var _ = require('lodash');
var $ = require('jquery');
var TagMatcher = require('../utils/tag-matcher');
var MediaObjectQueueManager = require('../utils/media-object/media-object-queue-manager');
var TextMediaObject = require('../utils/media-object/text-media-object');
var ImageMediaObject = require('../utils/media-object/image-media-object');
var VideoMediaObject = require('../utils/media-object/video-media-object');
var AudioMediaObject = require('../utils/media-object/audio-media-object');
var RandomVisualPlayer = require('../components/viewer/random-visual-player.jsx');
var ActiveTheme = require('../components/viewer/viewer-active-theme.jsx');
var hat = require('hat');

var MINIMUM_NUMBER_OF_MEDIA_TO_BE_MATCHED_WITH_THEME_QUERY = 0;

function getTypeByName(typeName) {
    var t = _.find([TextMediaObject, ImageMediaObject, VideoMediaObject, AudioMediaObject], function (t) {
        return t.typeName === typeName;
    });

    if (!t) {
        throw 'type "' + typeName + '" not found.  Needs to be passed to constructor.';
    }

    return t;
}

var SceneListener = React.createClass({

    statics: {
        willTransitionFrom: function (transition, component) {
            HubSendActions.unsubscribeScene(component.getParams().id);
        }
    },

    _getSceneId: function () {
        if (this.props.activeScene) {
            return this.props.activeScene._id;
        }

        var sceneId = this.props.sceneId || this.props.params.id;

        return sceneId;
    },

    _getScene: function () {

        if (this.props.activeScene) {
            return this.props.activeScene;
        }

        var sceneId = this.props.sceneId || this.props.params.id;

        // console.log("SceneListener - _getScene - sceneId: ", sceneId);

        return SceneStore.getScene(sceneId);
    },

    getInitialState: function () {
        return {
            scene: this._getScene(),
            activeThemes: [],
            fromGraphViewer: this.props.activeScene ? true : false,
            triggeredActiveThemes: {},
            cuePointMediaObjects: [],
            shouldHide: false
        };
    },

    getPlayerElem: function () {
        return this.refs.player;
    },

    _getSceneForUpdatingPlayerComponent: function () {
        return this.props.activeScene || this.state.scene;
    },

    _setPlayerClassCssForScene: function (style) {
        _.forEach(Object.keys(style), function (styleKey) {
            var styleValue = style[styleKey];

            $('.player').css(styleKey, styleValue);
        });
    },

    _maybeUpdatePlayer: function () {

        var scene = this._getSceneForUpdatingPlayerComponent();

        if (scene) {
            // APEP Remove the old style added ready for new style or fallback to css class
            $('.player').removeAttr("style");
            if (scene.style) {
                this._setPlayerClassCssForScene(scene.style);
            }

            // console.log("SceneListenr - setScene for mediaObjectQueue - this.props.activeScene:", this.props.activeScene);

            this.mediaObjectQueue.setScene(scene, {hardReset: true}); // TODO APEP {hardReset: true} I don't think we want to forcefully removal all

            this.updateTags();
        }
    },

    // APEP func to update after queue has made internal switch between modes
    mediaQueueManagerUpdate: function () {
        this.setState({mediaObjectQueue: this.mediaObjectQueue});
    },

    componentWillMount: function () {
{'fraction_non_alphanumeric': 0.1340193248839252, 'fraction_numerical': 0.00037645877776383487, 'mean_word_length': 2.8115734098517455, 'pattern_counts': {'":': 0, '<': 3, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '340529', 'n_tokens_mistral': 2265, 'n_tokens_neox': 2198, 'n_words': 468}