<commit_before>define(["sprd/util/ProductUtil", "underscore", "js/core/Base"], function(ProductUtil, _, Base) {

    var designPrintTypesCache = {};

    return Base.inherit({}, {

        canBePrintedOnProduct: function(design, product) {
            product = product || this.get("product");
            var printAreas = product.get("productType.printAreas");
            var self = this;

            var printArea = _.find(printAreas.$items, function(printArea) {
                return self.canBePrinted(design, product, null, printArea);
            });

            return !!printArea;
        },

        canBePrinted: function(design, product, printTypes, printArea) {
            product = product || this.get("product");

            if (!product) {
                return false;
            }

            printArea = printArea || product.$.view.getDefaultPrintArea();
            var appearance = product.$.appearance;

            if (!(design && product && appearance && (printTypes || design.$.printTypes))) {
                return false;
            }

            var cacheId = [design.$.id, product.$.view.$.id, printArea.$.id, product.$.appearance.$.id].join("-");
            if (!printTypes && !designPrintTypesCache[cacheId]) {
                designPrintTypesCache[cacheId] = ProductUtil.getPossiblePrintTypesForDesignOnPrintArea(design, printArea, appearance);
            }

            var possiblePrintTypes = printTypes || designPrintTypesCache[cacheId];
            if (possiblePrintTypes.length === 0) {
                return false;
            }

            if (!printArea) {
                return false;
            }<commit_msg>DEV-119503 added some more checks<commit_after>define(["sprd/util/ProductUtil", "underscore", "js/core/Base"], function(ProductUtil, _, Base) {

    var designPrintTypesCache = {};

    return Base.inherit({}, {

        canBePrintedOnProduct: function(design, product) {
            product = product || this.get("product");
            var printAreas = product.get("productType.printAreas");
            var self = this;

            var printArea = _.find(printAreas.$items, function(printArea) {
                return self.canBePrinted(design, product, null, printArea);
            });

            return !!printArea;
        },

        canBePrinted: function(design, product, printTypes, printArea) {
            product = product || this.get("product");

            if (!product) {
                return false;
            }

            if (!design) {
                return false;
            }

            var appearance = product.$.appearance,
                view = product.$.view;

            if (!appearance || !view) {
                return false;
            }

            if (!printTypes && !design.$.printTypes) {
                return false;
            }

            printArea = printArea || view.getDefaultPrintArea();

            var cacheId = [design.$.id, product.$.view.$.id, printArea.$.id, product.$.appearance.$.id].join("-");
            if (!printTypes && !designPrintTypesCache[cacheId]) {
                designPrintTypesCache[cacheId] = ProductUtil.getPossiblePrintTypesForDesignOnPrintArea(design, printArea, appearance);
            }

            var possiblePrintTypes = printTypes || designPrintTypesCache[cacheId];
            if (possiblePrintTypes.length === 0) {
                return false;
            }

            if (!printArea) {
                return false;
            }
{'fraction_non_alphanumeric': 0.12310768351899458, 'fraction_numerical': 0.0022850614110254213, 'mean_word_length': 1.8799342105263157, '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': '746199', 'n_tokens_mistral': 918, 'n_tokens_neox': 868, 'n_words': 180}