<commit_before>if (typeof _AljsApp === 'undefined') { throw new Error("Please include ember.aljs-init.js in your compiled Ember Application"); }

_AljsApp.AljsPicklistComponent = Ember.Component.extend({
    init: function() {
        this._super(); 
        
        if (!Ember.Handlebars.helpers['getLabelFromPicklistOption']) {
            Ember.Handlebars.registerBoundHelper('getLabelFromPicklistOption', function(picklistOption, optionValueKey, optionLabelKey, prompt) {            
                if(!Ember.isNone(picklistOption)) {
                    
                    if (optionValueKey) {
                        return new Ember.Handlebars.SafeString(optionLabelKey ? picklistOption[optionLabelKey] : picklistOption[optionValueKey]);
                    } else {
                        return new Ember.Handlebars.SafeString(picklistOption);
                    }
                } else {
                    return prompt || 'Select an Option';
                }
            });
        } 
    },
    attributeBindings: ['content', 'optionValuePath', 'optionLabelPath', 'value', 'selection'],
    layoutName: 'components/aljs-picklist',
    classNames: 'slds-form-element',
    contentObjects: function() {
        var value = this.get('value');
        var optionValueKey = this.get('optionValueKey');
        var optionLabelKey = this.get('optionLabelKey');
        return this.get('content').map(function(picklistOption) {
            return {
                value: optionValueKey ? picklistOption[optionValueKey] : picklistOption,
                isSelected: value === (optionValueKey ? picklistOption[optionValueKey] : picklistOption),
                label: optionLabelKey ? picklistOption[optionLabelKey] : picklistOption[optionValueKey] || picklistOption
            };            
        });
    }.property('content', 'value'),
    optionValueKey: function() {
        var optionValuePath = this.get('optionValuePath');

        return optionValuePath ? optionValuePath.replace('content.', '') : null;
    }.property(),
    optionLabelKey: function() {
        var optionLabelPath = this.get('optionLabelPath');

        return optionLabelPath ? optionLabelPath.replace('content.', '') : null;
    }.property(),
    isOpen: false,

    focusIn: function(e) {
        this.setProperties({
            isOpen: true,
            justOpened: true
        });
    },
    focusOut: function(e) {
        if (Ember.isEmpty(this.$().find(e.relatedTarget))) {
            this.setProperties({
                isOpen: false, 
                justOpened: false
            });
        }
    },
    setSelectedPicklistOption: function(picklistOption, optionValueKey) {
        var optionValueKey = this.get('optionValueKey');

        if (optionValueKey) {
            this.setProperties({
                selection: this.get('content').findBy(optionValueKey, picklistOption.value)
            });
        } else {
            this.setProperties({
                selection: picklistOption ? picklistOption : null
            });
        }
    },
    valueChanged: function() {<commit_msg>Avoid passing in undefined<commit_after>if (typeof _AljsApp === 'undefined') { throw new Error("Please include ember.aljs-init.js in your compiled Ember Application"); }

_AljsApp.AljsPicklistComponent = Ember.Component.extend({
    init: function() {
        this._super(); 
        
        if (!Ember.Handlebars.helpers['getLabelFromPicklistOption']) {
            Ember.Handlebars.registerBoundHelper('getLabelFromPicklistOption', function(picklistOption, optionValueKey, optionLabelKey, prompt) {            
                if(!Ember.isNone(picklistOption)) {
                    
                    if (optionValueKey) {
                        return new Ember.Handlebars.SafeString(optionLabelKey ? picklistOption[optionLabelKey] : picklistOption[optionValueKey]);
                    } else {
                        return new Ember.Handlebars.SafeString(picklistOption);
                    }
                } else {
                    return prompt || 'Select an Option';
                }
            });
        } 
    },
    attributeBindings: ['content', 'optionValuePath', 'optionLabelPath', 'value', 'selection'],
    layoutName: 'components/aljs-picklist',
    classNames: 'slds-form-element',
    contentObjects: function() {
        var value = this.get('value');
        var optionValueKey = this.get('optionValueKey');
        var optionLabelKey = this.get('optionLabelKey');
        return this.get('content').map(function(picklistOption) {
            return {
                value: optionValueKey ? picklistOption[optionValueKey] : picklistOption,
                isSelected: value === (optionValueKey ? picklistOption[optionValueKey] : picklistOption),
                label: optionLabelKey ? picklistOption[optionLabelKey] : picklistOption[optionValueKey] || picklistOption
            };            
        });
    }.property('content', 'value'),
    optionValueKey: function() {
        var optionValuePath = this.get('optionValuePath');

        return optionValuePath ? optionValuePath.replace('content.', '') : null;
    }.property(),
    optionLabelKey: function() {
        var optionLabelPath = this.get('optionLabelPath');

        return optionLabelPath ? optionLabelPath.replace('content.', '') : null;
    }.property(),
    isOpen: false,

    focusIn: function(e) {
        this.setProperties({
            isOpen: true,
            justOpened: true
        });
    },
    focusOut: function(e) {
        if (Ember.isEmpty(this.$().find(e.relatedTarget))) {
            this.setProperties({
                isOpen: false, 
                justOpened: false
            });
        }
    },
    setSelectedPicklistOption: function(picklistOption, optionValueKey) {
        var optionValueKey = this.get('optionValueKey');

        if (optionValueKey && !Ember.isEmpty(picklistOption)) {
            this.setProperties({
                selection: this.get('content').findBy(optionValueKey, picklistOption.value)
            });
        } else {
            this.setProperties({
                selection: picklistOption ? picklistOption : null
            });
        }
    },
    valueChanged: function() {
{'fraction_non_alphanumeric': 0.115673430260425, 'fraction_numerical': 0.0, 'mean_word_length': 2.169620253164557, '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': '4032501', 'n_tokens_mistral': 1639, 'n_tokens_neox': 1578, 'n_words': 288}