import { element } from "./element.js"; class submission { #name; #description; #thumbnail; #elements; constructor(name) { if (typeof(name) !== "string") { throw "Name must be an string."; } this.#name = name; this.#description = ""; this.#thumbnail = ""; this.clean(); } get name() { return this.#name; } get description() { return this.#description; } set description(content) { if (typeof(content) !== "string") { throw "Description must be an string."; } this.#description = content; } get thumbnail() { return this.#thumbnail; } set thumbnail(content) { if (typeof(content) !== "string") { throw "Thumbnail must be an string."; } this.#thumbnail = content; } get names() { return Object.keys(this.#elements); } get elements() { return Object.values(this.#elements); } add(item) { if (!(item instanceof element)) { throw "Trying to add something which is not an element."; } if (item.name in this.#elements) { throw "Trying to add element which already exists in submission."; } this.#elements[item.name] = item; } get(name) { if (typeof(name) !== "string") { throw "Name must be an string."; } if (!(name in this.#elements)) { throw "Trying to get element which not exists."; } return this.#elements[name]; } clean() { this.#elements = {}; } } export { submission };