import{LitElement as e,html as t,css as r}from"lit";import{ifDefined as i}from"lit/directives/if-defined.js";import{skeletonStyles as c}from"./styles/skeleton.js";import{i18n as a}from"./translation.js";import"./cc-block.js";import"./cc-input-text.js";import"./cc-notice.js";class s extends e{static get properties(){return{credentials:{type:Array},error:{type:Boolean},image:{type:String},name:{type:String},toggleState:{type:Boolean,attribute:"toggle-state"},type:{type:String}}}constructor(){super(),this.credentials=null,this.error=!1,this.image=null,this.name=null,this.toggleState="off",this.type=null}_getDescription(e){switch(e){case"apm":return a("cc-addon-credentials.description.apm");case"elasticsearch":return a("cc-addon-credentials.description.elasticsearch");case"kibana":return a("cc-addon-credentials.description.kibana");case"pulsar":return a("cc-addon-credentials.description.pulsar");case"materia-kv":return a("cc-addon-credentials.description.materia-kv")}}_getFieldName(e){switch(e){case"auth-token":return a("cc-addon-credentials.field.auth-token");case"host":return a("cc-addon-credentials.field.host");case"password":return a("cc-addon-credentials.field.password");case"url":return a("cc-addon-credentials.field.url");case"user":return a("cc-addon-credentials.field.user");case"port":return a("cc-addon-credentials.field.port")}}render(){return t`<cc-block image=${i(this.image??void 0)} state=${this.toggleState}><div slot=title>${a("cc-addon-credentials.title",{name:this.name})}</div>${this.error?"":t`<div>${this._getDescription(this.type)}</div>${null!=this.credentials?t`<div class=credential-list>${this.credentials.map((({type:e,secret:r,value:c})=>t`<cc-input-text readonly=readonly clipboard ?secret=${r} ?skeleton=${null==c} value=${i(c)} label=${this._getFieldName(e)}></cc-input-text>`))}</div>`:""}`} ${this.error?t`<cc-notice intent=warning message=${a("cc-addon-credentials.loading-error")}></cc-notice>`:""}</cc-block>`}static get styles(){return[c,r`:host{display:block}.credential-list{display:flex;flex-wrap:wrap;gap:1em}cc-input-text{--cc-input-font-family:var(--cc-ff-monospace, monospace);flex:1 1 18em}.skeleton{background-color:#bbb}`]}}window.customElements.define("cc-addon-credentials",s);export{s as CcAddonCredentials};
//# sourceMappingURL=cc-addon-credentials.js.map
