import{LitElement as t,html as i,css as c}from"lit";import{iconRemixInformationFill as e}from"./assets/cc-remix.icons.js";import{dispatchCustomEvent as a}from"./lib/events.js";import{ccLink as n,linkStyles as o}from"./templates/cc-link/cc-link.js";import{i18n as s}from"./translation.js";import"./cc-block-section.js";import"./cc-block.js";import"./cc-icon.js";import"./cc-img.js";import"./cc-loader.js";import"./cc-notice.js";class r extends t{static get properties(){return{state:{type:Object}}}constructor(){super(),this.state={type:"loading"}}_getDashboards(){return[{title:s("cc-grafana-info.screenshot.organisation.title"),url:"https://assets.clever-cloud.com/grafana/screens/home.png",description:s("cc-grafana-info.screenshot.organisation.description"),alt:s("cc-grafana-info.screenshot.organisation.alt")},{title:s("cc-grafana-info.screenshot.runtime.title"),url:"https://assets.clever-cloud.com/grafana/screens/runtime.png",description:s("cc-grafana-info.screenshot.runtime.description"),alt:s("cc-grafana-info.screenshot.runtime.alt")},{title:s("cc-grafana-info.screenshot.addon.title"),url:"https://assets.clever-cloud.com/grafana/screens/addon.png",description:s("cc-grafana-info.screenshot.addon.description"),alt:s("cc-grafana-info.screenshot.addon.alt")}]}_onEnableSubmit(){a(this,"enable")}_onResetSubmit(){a(this,"reset")}_onDisableSubmit(){a(this,"disable")}render(){const t="loaded"===this.state.type&&("enabling"===this.state.info.action||"disabling"===this.state.info.action),c="error"===this.state.type||"loaded"===this.state.type&&null!=this.state.info.action,a="loaded"===this.state.type&&"disabled"===this.state.info.status,o="loaded"===this.state.type&&"enabled"===this.state.info.status,r="loaded"===this.state.type&&"enabled"===this.state.info.status&&"resetting"===this.state.info.action;return i`<cc-block><div slot=title>${s("cc-grafana-info.main-title")}</div>${t?i`<cc-loader slot=overlay></cc-loader>`:""}<cc-block-section><div slot=title>${s("cc-grafana-info.documentation-title")}</div><div slot=info>${s("cc-grafana-info.documentation-description")}</div><div>${n("https://www.clever-cloud.com/doc/administrate/metrics/overview/",i`<cc-icon size=lg .icon=${e}></cc-icon><span>${s("cc-grafana-info.link.doc")}</span>`)}</div></cc-block-section>${"loading"===this.state.type?i`<cc-block-section><div slot=title>${s("cc-grafana-info.loading-title")}</div><div><cc-loader></cc-loader></div></cc-block-section>`:""} ${"error"===this.state.type?i`<cc-block-section><div slot=title>${s("cc-grafana-info.loading-title")}</div><cc-notice intent=warning message=${s("cc-grafana-info.error-loading")}></cc-notice></cc-block-section>`:""} ${a?i`<cc-block-section><div slot=title>${s("cc-grafana-info.enable-title")}</div><div slot=info><p>${s("cc-grafana-info.enable-description")}</p></div><div><cc-button success ?disabled=${c} @cc-button:click=${this._onEnableSubmit}>${s("cc-grafana-info.enable-title")}</cc-button></div></cc-block-section>`:""} ${o?i`<cc-block-section><div slot=title>${s("cc-grafana-info.grafana-link-title")}</div><div slot=info><p>${s("cc-grafana-info.grafana-link-description")}</p></div>${null==this.state.info.link?i`<cc-notice intent=warning message=${s("cc-grafana-info.error-link-grafana")}></cc-notice>`:i`<div>${n(this.state.info.link,i`<cc-img src=${"https://assets.clever-cloud.com/logos/grafana.svg"}></cc-img><span>${s("cc-grafana-info.link.grafana")}</span>`)}</div>`}</cc-block-section><cc-block-section><div slot=title>${s("cc-grafana-info.reset-title")}</div><div slot=info>${s("cc-grafana-info.reset-description")}</div><div><cc-button primary ?disabled=${c} ?waiting=${r} @cc-button:click=${this._onResetSubmit}>${s("cc-grafana-info.reset-title")}</cc-button></div></cc-block-section>`:""} ${t?"":i`${this._getDashboards().map((t=>i`<cc-block-section><div slot=title>${t.title}</div><div slot=info>${t.description}</div><div>${n(t.url,i`<img class=dashboard-screenshot src=${t.url} alt=${t.alt}>`)}</div></cc-block-section>`))}`} ${o?i`<cc-block-section><div slot=title>${s("cc-grafana-info.disable-title")}</div><div slot=info>${s("cc-grafana-info.disable-description")}</div><div><cc-button danger delay=3 ?disabled=${c} @cc-button:click=${this._onDisableSubmit}>${s("cc-grafana-info.disable-title")}</cc-button></div></cc-block-section>`:""}</cc-block>`}static get styles(){return[o,c`:host{display:block}cc-img{border-radius:var(--cc-border-radius-default,.25em);flex:0 0 auto;height:1.5em;margin-right:.5em;width:1.5em}cc-icon{flex:0 0 auto;margin-right:.5em}.cc-link{align-items:center;display:inline-flex}.dashboard-screenshot{border-radius:var(--cc-border-radius-default,.25em);max-width:50em;width:100%}p{margin:0}br{display:block;margin:.5em 0}`]}}window.customElements.define("cc-grafana-info",r);export{r as CcGrafanaInfo};
//# sourceMappingURL=cc-grafana-info.js.map
