import { t } from "@lingui/macro";
import { CSSResult, customElement, html, LitElement, property, TemplateResult } from "lit-element";
import { OutpostHealth, OutpostsApi } from "authentik-api";
import { DEFAULT_CONFIG } from "../../api/Config";
import PFBase from "@patternfly/patternfly/patternfly-base.css";
import "../../elements/Spinner";
import AKGlobal from "../../authentik.css";
import { PFColor } from "../../elements/Label";
import { EVENT_REFRESH } from "../../constants";
@customElement("ak-outpost-health")
export class OutpostHealthElement extends LitElement {
    @property()
    outpostId?: string;
    @property({attribute: false})
    outpostHealth: OutpostHealth[] = [];
    static get styles(): CSSResult[] {
        return [PFBase, AKGlobal];
    }
    constructor() {
        super();
        this.addEventListener(EVENT_REFRESH, () => {
            this.firstUpdated();
        });
    }
    firstUpdated(): void {
        if (!this.outpostId) return;
        new OutpostsApi(DEFAULT_CONFIG).outpostsInstancesHealthList({
            uuid: this.outpostId
        }).then(health => {
            this.outpostHealth = health;
        });
    }
    render(): TemplateResult {
        if (!this.outpostId) {
            return html`