import {LitElement, html} from './lit-all.min.js';
import * as tfrpc from '/static/tfrpc.js';
import {styles} from './tf-styles.js';
class TfUserElement extends LitElement {
static get properties() {
return {
id: {type: String},
fallback_name: {type: String},
users: {type: Object},
};
}
static styles = styles;
constructor() {
super();
this.id = null;
this.fallback_name = null;
this.users = {};
}
render() {
let user = this.users[this.id];
let shape =
user?.follow_depth === undefined || user.follow_depth >= 2
? 'w3-circle'
: 'w3-round';
let image = html`😎`;
let name = this.users?.[this.id]?.name;
name = html`${name ?? this.fallback_name ?? this.id}`;
if (user) {
let image_link = user.image;
if (typeof image_link == 'string' && !image_link.startsWith('&')) {
try {
image_link = JSON.parse(image_link)?.link;
} catch {}
}
if (image_link !== undefined) {
image = html``;
}
}
return html`