import{r as e,a as o,h as t}from"./p-wX3eJOEL.js";import{i}from"./p-CtINY9El.js";import{d as r,t as a}from"./p-DNHOWgWh.js";const c=class{constructor(o){e(this,o)}errorStates=new Map;get el(){return o(this)}alignment="vertical";size;showGroupLabel;groupLabelText="Group Label Text";showCaption;captionText;showCaptionIcon;required=!1;hasErrors=!1;handleCheckboxError(e){const o=e.target;"ifx-checkbox"===o.tagName.toLowerCase()&&(this.errorStates.set(o,e.detail),this.updateHasErrors())}async setGroupError(e){Array.from(this.el.querySelectorAll("ifx-checkbox")).forEach((o=>{o.error=e}))}componentWillLoad(){this.initializeState()}async componentDidLoad(){if(!i(this.el)){const e=r();a("ifx-checkbox-group",await e)}}handleSlotChange=()=>{this.initializeState()};initializeState(){this.errorStates.clear(),Array.from(this.el.querySelectorAll("ifx-checkbox")).forEach((e=>{this.errorStates.has(e)||this.errorStates.set(e,e.error||!1)})),this.updateHasErrors()}updateHasErrors(){this.hasErrors=Array.from(this.errorStates.values()).some((e=>e))}render(){return t("div",{key:"a1e3451daad606492f8c667a424bca92bcbf8968",class:"checkbox-group-container"},this.showGroupLabel&&t("div",{key:"523e9597394ba4f5b91bae7345a7fd16898a3f97",class:"group-label"},this.groupLabelText,this.required&&t("span",{key:"3f40ced787640ca76fb9961c2569bd2f26e43894",class:"required "+(this.hasErrors?"error":"")},"*")),t("div",{key:"67eeb3658426d2e0510cc4e6c9b7249064efae76",class:`checkbox-group ${this.alignment} ${this.size}`},t("slot",{key:"6941d0650ce6ac373e562d33962b1a761b336573",onSlotchange:this.handleSlotChange})),this.showCaption?t("div",{class:"caption "+(this.hasErrors?"error":"default")},this.showCaptionIcon?t("div",{class:"caption-icon"},t("ifx-icon",{icon:"c-info-16"})):"",t("div",{class:"caption-text"},this.captionText)):"")}};c.style=".checkbox-group-container{display:flex;flex-direction:column}.checkbox-group{display:flex;gap:8px}.checkbox-group.horizontal{flex-direction:row;column-gap:12px}.checkbox-group.vertical{flex-direction:column;row-gap:12px}.group-label{font-size:1rem;color:#1D1D1D;line-height:1.5rem;font-weight:400;margin-bottom:8px;text-align:left;text-underline-position:from-font;text-decoration-skip-ink:none}.group-label .required{color:#575352;margin-left:4px}.group-label .required.error{color:#CD002F}.caption{margin-top:8px;align-self:flex-start;display:flex;width:100%;column-gap:8px;justify-content:space-between;align-items:center}.caption.default{color:#1D1D1D}.caption.error{color:#CD002F}.caption-text{font-weight:400;font-size:0.75rem;line-height:1rem;flex:1;text-align:left;text-underline-position:from-font;text-decoration-skip-ink:none}.caption-icon{flex:0;display:flex}";export{c as ifx_checkbox_group}