import{r as i,h as o,H as r}from"./p-9add63ef.js";import{g as t}from"./p-5269cb6b.js";import{s as e,r as n}from"./p-78468e45.js";import{c as s}from"./p-b51de06c.js";import{o as l}from"./p-31faf2b8.js";import"./p-830ab1a3.js";import"./p-2b28ea49.js";import"./p-dd24e53c.js";const a=":host{display:block}ul{margin:6px 0px;padding:0px;list-style:none}";const d=a;const p=class{constructor(o){i(this,o);this.removeStateListener=()=>{}}getAlertType(){switch(e===null||e===void 0?void 0:e.type){case"error":return"danger";case"default":return"primary";default:return e===null||e===void 0?void 0:e.type}}componentWillLoad(){this.removeStateListener=l("formState",(()=>{if(["finalizing","updating"].includes(s())){n()}}))}disconnectedCallback(){this.removeStateListener()}getTopLevelError(){var i;if((e===null||e===void 0?void 0:e.code)==="checkout.invalid"&&((i=t())===null||i===void 0?void 0:i.length)){return""}return e===null||e===void 0?void 0:e.message}render(){if(!(e===null||e===void 0?void 0:e.message)||["finalizing","updating"].includes(s())){return o(r,{style:{display:"none"}})}return o(r,null,o("sc-alert",{type:this.getAlertType(),scrollOnOpen:true,open:!!(e===null||e===void 0?void 0:e.message),closable:!!(e===null||e===void 0?void 0:e.dismissible)},!!this.getTopLevelError()&&o("span",{slot:"title",innerHTML:this.getTopLevelError()}),(t()||[]).map(((i,r)=>o("div",{innerHTML:i,key:r})))),o("slot",null))}};p.style=d;export{p as sc_checkout_form_errors};
//# sourceMappingURL=p-2052f9a7.entry.js.map