{"size": 1380, "ext": "js", "max_stars_repo_path": "app/components/gh-product-card.js", "max_stars_repo_name": "SimonBackx/Ghost-Admin", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "app/components/gh-product-card.js", "max_issues_repo_name": "SimonBackx/Ghost-Admin", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "app/components/gh-product-card.js", "max_forks_repo_name": "SimonBackx/Ghost-Admin", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 26.0377358491, "max_line_length": 79, "alphanum_fraction": 0.6152173913}
import Component from '@glimmer/component';
import {action} from '@ember/object';
import {getSymbol} from 'ghost-admin/utils/currency';
import {inject as service} from '@ember/service';
import {tracked} from '@glimmer/tracking';

export default class extends Component {
    @service membersUtils;
    @service ghostPaths;
    @service ajax;
    @service store;
    @service config;

    @tracked showProductModal = false;

    get product() {
        return this.args.product;
    }

    get showArchiveOption() {
        return this.product.type === 'paid' && !!this.product.monthlyPrice;
    }

    get productCurrency() {
        if (this.isFreeProduct) {
            const firstPaidProduct = this.args.products.find((product) => {
                return product.type === 'paid';
            });
            return firstPaidProduct?.monthlyPrice?.currency || 'usd';
        } else {
            return this.product?.monthlyPrice?.currency;
        }
    }

    get isPaidProduct() {
        return this.product.type === 'paid';
    }

    get hasCurrencySymbol() {
        const currencySymbol = getSymbol(this.product?.monthlyPrice?.currency);
        return currencySymbol?.length !== 3;
    }

    get isFreeProduct() {
        return this.product.type === 'free';
    }

    @action
    async openEditProduct(product) {
        this.args.openEditProduct(product);
    }
}
