import{ERROR_TYPES as e}from"@clevercloud/client/esm/utils/payment.js";import{LitElement as r,html as t,css as n}from"lit";import{linkStyles as a}from"./templates/cc-link/cc-link.js";import{i18n as i}from"./translation.js";import"./cc-notice.js";class o extends r{static get properties(){return{errors:{type:Array},mode:{type:String}}}constructor(){super(),this.errors=[{type:e.NO_PAYMENT_METHOD}],this.mode="billing"}_getOrgaError({type:r}){switch(r){case e.NO_PAYMENT_METHOD:return{title:i("cc-payment-warning.orga.no-payment-method.title"),errorMessage:i("cc-payment-warning.orga.no-payment-method")};case e.NO_DEFAULT_PAYMENT_METHOD:return{title:i("cc-payment-warning.orga.no-default-payment-method.title"),errorMessage:i("cc-payment-warning.orga.no-default-payment-method")};case e.DEFAULT_PAYMENT_METHOD_IS_EXPIRED:return{title:i("cc-payment-warning.orga.default-payment-method-is-expired.title"),errorMessage:i("cc-payment-warning.orga.default-payment-method-is-expired")};default:return{title:null,errorMessage:null}}}_getHomeError({type:r,orgaName:t}){switch(r){case e.NO_PAYMENT_METHOD:return i("cc-payment-warning.generic.no-payment-method",{orgaName:t});case e.NO_DEFAULT_PAYMENT_METHOD:return i("cc-payment-warning.generic.no-default-payment-method",{orgaName:t});case e.DEFAULT_PAYMENT_METHOD_IS_EXPIRED:return i("cc-payment-warning.generic.default-payment-method-is-expired",{orgaName:t})}}render(){switch(this.mode){case"home":return this._renderHomeWarning(this.errors);case"billing":case"overview":return this._renderOrgaWarning(this.errors[0])}}_renderOrgaWarning({type:e,orgaName:r,orgaBillingLink:n}){const{title:a,errorMessage:o}=this._getOrgaError({type:e}),g="overview"===this.mode?i("cc-payment-warning.billing-page-link",{orgaName:r,orgaBillingLink:n}):"";return t`<cc-notice .heading=${a} intent=warning><div slot=message>${o} ${g}</div></cc-notice>`}_renderHomeWarning(e){return t`<cc-notice .heading=${i("cc-payment-warning.home.title")} intent=warning><div slot=message class=error-container><span>${i("cc-payment-warning.home",{orgaCount:this.errors.length})}</span><ul>${e.map((e=>t`<li>${this._getHomeError(e)} ${i("cc-payment-warning.billing-page-link",{orgaName:e.orgaName,orgaBillingLink:e.orgaBillingLink})}</li>`))}</ul></div></cc-notice>`}static get styles(){return[a,n`:host{display:block}ul{margin:.5em 0 0 1.5em;padding:0}li{margin-top:.5em}`]}}window.customElements.define("cc-warning-payment",o);export{o as CcWarningPayment};
//# sourceMappingURL=cc-warning-payment.js.map
