{"version":3,"file":"face-pile-B1ysUeXq.js","sources":["../src/webcomponents/face-pile.js"],"sourcesContent":["import { UnshadowedElement, html } from \"../lib/unshadowed.js\";\r\nimport { PostJSON } from \"../lib/fetchers.js\";\r\n\r\nimport { UserAvatar } from \"./user-avatar.js\";\r\n\r\n// Register required webcomponents\r\nUserAvatar.Register();\r\n\r\n/**\r\n * Array of user avatars\r\n * Relies on window.CurrentTrain\r\n */\r\nexport class FacePile extends UnshadowedElement {\r\n static elementName() { return \"face-pile\" }\r\n\r\n static properties = {\r\n maxAvatars: { type: Number },\r\n\r\n participants: { state: true, type: Array },\r\n totalParticipants: { state: true, type: Number },\r\n };\r\n\r\n constructor() {\r\n super();\r\n // Defaults\r\n this.maxAvatars = 6;\r\n }\r\n\r\n async connectedCallback() {\r\n super.connectedCallback();\r\n // Load facepile from backend\r\n try {\r\n const result = await PostJSON(\"/trains/\" + window.CurrentTrain.Id + \"/facepile\", { max: this.maxAvatars });\r\n this.participants = result.participants;\r\n this.totalParticipants = result.totalParticipants;\r\n } catch {\r\n // On failure, we just won't show\r\n }\r\n }\r\n\r\n render() {\r\n if (this.participants && this.participants.length) {\r\n const nodes = [];\r\n for (const participant of this.participants) {\r\n nodes.push(html`