import{LitElement as e,html as r,css as t}from"lit";import{i18n as a}from"./translation.js";import"./cc-env-var-form.js";import"./cc-loader.js";import"./cc-notice.js";class s extends e{static get properties(){return{appName:{type:String,attribute:"app-name"},state:{type:Object},type:{type:String}}}constructor(){super(),this.appName=null,this.state={type:"loading"},this.type=null}_getLoadingMessage(){const e={appName:this.appName};switch(this.type){case"addon":return a("cc-env-var-linked-services.loading.addon",e);case"app":return a("cc-env-var-linked-services.loading.app",e);default:return""}}_getServiceHeading(e){switch(this.type){case"addon":return a("cc-env-var-linked-services.heading.addon",{name:e});case"app":return a("cc-env-var-linked-services.heading.app",{name:e});default:return""}}_getServiceDescription(e){const r={serviceName:e,appName:this.appName};switch(this.type){case"addon":return a("cc-env-var-linked-services.description.addon",r);case"app":return a("cc-env-var-linked-services.description.app",r);default:return""}}_getEmptyMessage(){const e={appName:this.appName};switch(this.type){case"addon":return a("cc-env-var-linked-services.empty.addon",e);case"app":return a("cc-env-var-linked-services.empty.app",e);default:return""}}_getErrorMessage(){const e={appName:this.appName};switch(this.type){case"addon":return a("cc-env-var-linked-services.error.addon",e);case"app":return a("cc-env-var-linked-services.error.app",e);default:return""}}_getEnvVarFormState(e){return"loading"===e.type?{type:"loading"}:"error"===e.type?{type:"error"}:{type:"loaded",variables:e.variables,validationMode:"simple"}}render(){if("error"===this.state.type)return r`<div class=error><cc-notice intent=warning .message=${this._getErrorMessage()}></cc-notice></div>`;if("loading"===this.state.type)return r`<div class=loading><cc-loader></cc-loader><span>${this._getLoadingMessage()}</span></div>`;const e=this.state.servicesStates;return 0===e.length?r`<div class=empty-msg>${this._getEmptyMessage()}</div>`:r`<div class=service-list>${e.map((e=>r`<cc-env-var-form readonly=readonly .state=${this._getEnvVarFormState(e)} heading=${this._getServiceHeading(e.name)}>${this._getServiceDescription(e.name)}</cc-env-var-form>`))}</div>`}static get styles(){return[t`:host{display:block}.empty-msg,.loading{background-color:var(--cc-color-bg-default,#fff);border:1px solid var(--cc-color-border-neutral,#aaa);border-radius:var(--cc-border-radius-default,.25em);box-sizing:border-box;padding:1em}.loading{display:flex}cc-loader{height:1.5em;margin-right:1em;width:1.5em}.service-list{display:grid;grid-gap:1em}.empty-msg{color:var(--cc-color-text-weak);font-style:italic}`]}}window.customElements.define("cc-env-var-linked-services",s);export{s as CcEnvVarLinkedServices};
//# sourceMappingURL=cc-env-var-linked-services.js.map
