import{r as e,c as t,a as s,h as i}from"./p-Cby2wKoI.js";import{i as r}from"./p-CtINY9El.js";import{d as o,t as a}from"./p-DNHOWgWh.js";const l=()=>`.group{display:flex;flex-direction:column;justify-content:space-between}.group__label{font-size:1rem;color:#1D1D1D;line-height:1.5rem;font-weight:400}.group__label:empty{display:none}.group__label .required{color:#575352;margin-left:4px}.group__label .required.error{color:#CD002F}.group__controls{display:flex;flex-wrap:wrap}.group__controls ::slotted(*){margin-left:-1px;margin-top:-1px}.group__caption{margin-top:4px;display:flex;align-items:center;gap:8px;font-weight:400;font-size:0.75rem;line-height:1rem}.group__caption.error{color:#CD002F}`;const c=class{constructor(s){e(this,s);this.ifxChange=t(this,"ifxChange",7)}get el(){return s(this)}ifxChange;caption="";label="";size="regular";required=false;error=false;onSegmentSelect(e){const{previousValue:t,selectedValue:s}=this.unselectPreviousSegment(e.detail);this.selectedValue=s;this.ifxChange.emit({previousValue:t,selectedValue:s})}selectedValue="";unselectPreviousSegment(e){let t;let s;const i=this.getSegments();i.forEach((i=>{if(i.selected){if(i.segmentIndex!==e){i.selected=false;t=i.value}else{s=i.value}}}));return{previousValue:t,selectedValue:s}}getSegments(){return this.el.querySelectorAll("ifx-segment")}setActiveSegment(){const e=this.getSegments();let t=false;e.forEach(((e,s)=>{e.segmentIndex=s;if(t){if(e.selected)e.selected=false}else{if(e.selected){t=true;this.selectedValue=e.value}}}))}setSegmentSize(){const e=this.getSegments();e.forEach((e=>{e.shadowRoot.querySelector(".segment").classList.add(`segment--${this.size}`)}))}async componentDidLoad(){if(!r(this.el)){const e=o();a("ifx-segmented-control",await e)}this.setActiveSegment()}render(){return i("div",{key:"4a19a4e8c3201489acf1c7680e813b5a84d722cb","aria-value":this.selectedValue,"aria-label":"segmented control",class:"group"},i("div",{key:"0d3dc143ec6539de17d5335a73299ab41cf7bc41",class:"group__label"},this.label.trim(),this.required&&this.label.trim().toLowerCase()!==""&&i("span",{key:"07c4cddf3bf580d38f933a3243bbec3aeff11dcf",class:`required ${this.error?"error":""}`},"*")),i("div",{key:"8d289fa48cd45dc0d5f5afd6a3276831e1b5b4df",class:"group__controls"},i("slot",{key:"3a3fe1d81b02f4f3f4109094077712bcfba0a930"})),this.caption.trim()&&i("div",{key:"c597aed322b377950c50f84b25d045fcd1e400df",class:`group__caption ${this.error?"error":""}`},i("ifx-icon",{key:"729ec3b8c7adba39d11ea063d82af303c8f06f75",icon:"c-info-16"})," ",this.caption.trim()))}componentDidRender(){this.setSegmentSize()}};c.style=l();export{c as ifx_segmented_control};
//# sourceMappingURL=p-a273dbae.entry.js.map