{"size": 2247, "ext": "js", "max_stars_repo_path": "components/activity/type/d2l-activity-type.js", "max_stars_repo_name": "BrightspaceHypermediaComponents/foundation-components", "max_stars_repo_stars_event_min_datetime": "2020-12-22T16:42:23.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-02T16:55:07.000Z", "max_issues_repo_path": "components/activity/type/d2l-activity-type.js", "max_issues_repo_name": "BrightspaceHypermediaComponents/foundation-components", "max_issues_repo_issues_event_min_datetime": "2020-10-21T18:50:03.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T18:35:55.000Z", "max_forks_repo_path": "components/activity/type/d2l-activity-type.js", "max_forks_repo_name": "BrightspaceHypermediaComponents/foundation-components", "max_forks_repo_forks_event_min_datetime": "2021-03-08T22:37:43.000Z", "max_forks_repo_forks_event_max_datetime": "2021-03-08T22:37:43.000Z"}
{"max_stars_count": 4, "max_issues_count": 371, "max_forks_count": 1, "avg_line_length": 31.2083333333, "max_line_length": 130, "alphanum_fraction": 0.7142857143}
import { html, LitElement } from 'lit-element/lit-element.js';
import { HypermediaStateMixin, observableTypes } from '@brightspace-hmc/foundation-engine/framework/lit/HypermediaStateMixin.js';
import { customHypermediaElement } from '@brightspace-hmc/foundation-engine/framework/lit/hypermedia-components.js';
import { LocalizeFoundationType } from './lang/localization.js';
import { SkeletonMixin } from '@brightspace-ui/core/components/skeleton/skeleton-mixin.js';

class ActivityType extends SkeletonMixin(LocalizeFoundationType(HypermediaStateMixin(LitElement))) {
	static get properties() {
		return {
			_classes: { type: Array, observable: observableTypes.classes },
			_childContentClasses: {
				type: Array,
				observable: observableTypes.classes,
				route: [{observable: observableTypes.subEntity, rel: 'https://activities.api.brightspace.com/rels/child-user-activity-usage'}]
			}
		};
	}

	static get styles() {
		return [ super.styles ];
	}
	/**
	 * Standard mappings for type label
	 */
	static get components() {
		return {
			'user-survey-activity': 'label-surveys',
			'learning-path': 'label-learningPath',
			'course-offering': 'label-course',
			'user-assignment-activity': 'label-assignment',
			'user-checklist-activity': 'label-checklist',
			'user-content-activity': 'label-content',
			'user-course-offering-activity-usage': 'label-course',
			'user-activity-usage': 'label-course',
			'user-discussion-activity': 'label-discussion',
			'user-quiz-activity': 'label-quiz',
			'user-quiz-attempt-activity': 'label-quiz',
			default: 'label-activity'
		};
	}

	constructor() {
		super();
		this._classes = [];
		this._childContentClasses = [];
		this.skeleton = true;
	}

	render() {
		let type = ActivityType.components.default;
		const classes = this._childContentClasses.length > 0 ? this._childContentClasses : this._classes;
		classes.some(hmClass => {
			if (!ActivityType.components[hmClass]) return;
			type = ActivityType.components[hmClass];
			return true;
		});
		return html`
			<span class="d2l-skeletize">${this.localize(type)}</span>
		`;
	}

	get _loaded() {
		return !this.skeleton;
	}

	set _loaded(loaded) {
		this.skeleton = !loaded;
	}
}

customHypermediaElement('d2l-activity-type', ActivityType);
