<commit_before>/*browser:true*/
/*global define*/

define(
    [
        'ko',
        'jquery',
        'uiComponent',
        'Magento_Ui/js/modal/alert',
        'Swarming_SubscribePro/js/model/payment/credit-card-validation/expiration-field-validator',
        'Swarming_SubscribePro/js/model/payment/credit-card-validation/hosted-field-validator',
        'Swarming_SubscribePro/js/model/payment/credit-card-validation/expiration-fields',
        'Swarming_SubscribePro/js/model/payment/credit-card-validation/hosted-fields',
        'Swarming_SubscribePro/js/model/payment/config',
        'Swarming_SubscribePro/js/model/payment/spreedly',
        'Magento_Ui/js/lib/view/utils/dom-observer'
    ],
    function (
        ko,
        $,
        Component,
        alert,
        expirationFieldValidator,
        hostedFieldValidator,
        expirationFields,
        hostedFields,
        config,
        spreedly,
        domObserver
    ) {
        'use strict';

        return Component.extend({
            defaults: {
                $orderForm: null,
                orderFormSelector: 'edit_form',
                container: 'payment_form_subscribe_pro',
                active: false,
                spreedlyInitialized: false,
                isValidHostedFields: false,
                isValidExpDate: false,
                imports: {
                    onActiveChange: 'active'
                }
            },

            initObservable: function () {
                var self = this;

                this.$orderForm = $('#' + this.orderFormSelector);

                this._super()
                    .observe([
                        'active'
                    ]);

                this.$orderForm.off('changePaymentMethod.' + config.getCode())
                    .on('changePaymentMethod.' + config.getCode(), this.changePaymentMethod.bind(this));

                domObserver.get('#' + this.container, function () {
                    // This little hack checks to see if the config is ready yet, if not we wait half a second
                    if (window.subscribeProPaymentConfig != undefined) {
                        self.initSpreedly();
                    } else {
                        window.setTimeout(function () {
                            self.initSpreedly();
                        }, 500);
                    }
                });

                this.$orderForm<commit_msg>Removed the setTimeout hack for the config issue<commit_after>/*browser:true*/
/*global define*/

define(
    [
        'ko',
        'jquery',
        'uiComponent',
        'Magento_Ui/js/modal/alert',
        'Swarming_SubscribePro/js/model/payment/credit-card-validation/expiration-field-validator',
        'Swarming_SubscribePro/js/model/payment/credit-card-validation/hosted-field-validator',
        'Swarming_SubscribePro/js/model/payment/credit-card-validation/expiration-fields',
        'Swarming_SubscribePro/js/model/payment/credit-card-validation/hosted-fields',
        'Swarming_SubscribePro/js/model/payment/config',
        'Swarming_SubscribePro/js/model/payment/spreedly',
        'Magento_Ui/js/lib/view/utils/dom-observer'
    ],
    function (
        ko,
        $,
        Component,
        alert,
        expirationFieldValidator,
        hostedFieldValidator,
        expirationFields,
        hostedFields,
        config,
        spreedly,
        domObserver
    ) {
        'use strict';

        return Component.extend({
            defaults: {
                $orderForm: null,
                orderFormSelector: 'edit_form',
                container: 'payment_form_subscribe_pro',
                active: false,
                spreedlyInitialized: false,
                isValidHostedFields: false,
                isValidExpDate: false,
                imports: {
                    onActiveChange: 'active'
                }
            },

            initObservable: function () {
                var self = this;

                this.$orderForm = $('#' + this.orderFormSelector);

                this._super()
                    .observe([
                        'active'
                    ]);

                this.$orderForm.off('changePaymentMethod.' + config.getCode())
                    .on('changePaymentMethod.' + config.getCode(), this.changePaymentMethod.bind(this));

                domObserver.get('#' + this.container, function () {
                    self.initSpreedly();
                });

                this.$orderForm
{'fraction_non_alphanumeric': 0.10494918250110473, 'fraction_numerical': 0.0006628369421122404, 'mean_word_length': 1.5177975528364849, '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': '2105830', 'n_tokens_mistral': 1214, 'n_tokens_neox': 1129, 'n_words': 168}