import{LitElement as t,html as e,css as n}from"lit";import{dispatchCustomEvent as i}from"./lib/events.js";import{i18n as a}from"./translation.js";import"./cc-block-section.js";import"./cc-block.js";import"./cc-input-text.js";import"./cc-loader.js";import"./cc-notice.js";class c extends t{static get properties(){return{noDangerZoneBackupText:{type:Boolean,attribute:"no-danger-zone-backup-text"},noDangerZoneVmText:{type:Boolean,attribute:"no-danger-zone-vm-text"},state:{type:Object},_name:{type:String,state:!0},_tags:{type:Array,state:!0}}}constructor(){super(),this.noDangerZoneBackupText=!1,this.noDangerZoneVmText=!1,this.state={type:"loading"},this._name=null,this._tags=null}_onDeleteSubmit(){i(this,"delete-addon")}_onNameInput({detail:t}){this._name=t}_onNameSubmit(){i(this,"update-name",{name:this._name})}_onTagsInput({detail:t}){this._tags=t}_onTagsSubmit(){i(this,"update-tags",{tags:this._tags})}willUpdate(t){t.has("state")&&"name"in this.state&&(this._name=this.state.name),t.has("state")&&"tags"in this.state&&(this._tags=this.state.tags)}render(){return e`<cc-block><div slot=title>${a("cc-addon-admin.admin")}</div>${"error"===this.state.type?e`<cc-notice intent=warning message=${a("cc-addon-admin.error-loading")}></cc-notice>`:""} ${"error"!==this.state.type?this._renderContent(this.state):""}</cc-block>`}_renderContent(t){const n="loading"===t.type,i="updatingTags"===t.type||"updatingName"===t.type||"deleting"===t.type,c="loading"===t.type||i,o=!this.noDangerZoneBackupText,s=!this.noDangerZoneVmText;return e`<cc-block-section><div slot=title>${a("cc-addon-admin.heading.name")}</div><div slot=info></div><div class=one-line-form><cc-input-text label=${a("cc-addon-admin.input.name")} ?skeleton=${n} ?disabled=${c} .value=${this._name} @cc-input-text:input=${this._onNameInput} @cc-input-text:requestimplicitsubmit=${this._onNameSubmit}></cc-input-text><cc-button primary ?skeleton=${n} ?disabled=${c} ?waiting=${"updatingName"===t.type} @cc-button:click=${this._onNameSubmit}>${a("cc-addon-admin.update")}</cc-button></div></cc-block-section><cc-block-section><div slot=title>${a("cc-addon-admin.heading.tags")}</div><div slot=info>${a("cc-addon-admin.tags-description")}</div><div class=one-line-form><cc-input-text label=${a("cc-addon-admin.input.tags")} ?skeleton=${n} ?disabled=${c} .tags=${this._tags} placeholder=${a("cc-addon-admin.tags-empty")} @cc-input-text:tags=${this._onTagsInput} @cc-input-text:requestimplicitsubmit=${this._onTagsSubmit}></cc-input-text><cc-button primary ?skeleton=${n} ?disabled=${c} ?waiting=${"updatingTags"===t.type} @cc-button:click=${this._onTagsSubmit}>${a("cc-addon-admin.tags-update")}</cc-button></div></cc-block-section><cc-block-section><div slot=title class=danger>${a("cc-addon-admin.danger-zone")}</div><div slot=info class=danger-desc><p>${a("cc-addon-admin.delete-disclaimer")}</p>${s?e`<p>${a("cc-addon-admin.delete-vm")}</p>`:""} ${o?e`<p>${a("cc-addon-admin.delete-backups")}</p>`:""}</div><div><cc-button danger ?skeleton=${n} ?disabled=${c} ?waiting=${"deleting"===t.type} @cc-button:click=${this._onDeleteSubmit}>${a("cc-addon-admin.delete")}</cc-button></div></cc-block-section>`}static get styles(){return[n`:host{display:block}.one-line-form{display:flex}.one-line-form cc-input-text{flex:1 1 10em;margin-right:.5em}.one-line-form cc-button{margin-top:var(--cc-margin-top-btn-horizontal-form)}.danger-desc p{margin:0}`]}}window.customElements.define("cc-addon-admin",c);export{c as CcAddonAdmin};
//# sourceMappingURL=cc-addon-admin.js.map
