import{p as e,H as t,c as s,h as i,t as r}from"./p-CHfEnK-2.js";import{i as o,d as n,t as a}from"./p-94ZtGp9D.js";import{d as l}from"./p-B5hDbbCP.js";const c=e(class extends t{constructor(e){super(),!1!==e&&this.__registerHost(),this.__attachShadow(),this.ifxChange=s(this,"ifxChange",7)}get el(){return this}ifxChange;caption="";label="";size="regular";required=!1;error=!1;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,s;return this.getSegments().forEach((i=>{i.selected&&(i.segmentIndex!==e?(i.selected=!1,t=i.value):s=i.value)})),{previousValue:t,selectedValue:s}}getSegments(){return this.el.querySelectorAll("ifx-segment")}setActiveSegment(){const e=this.getSegments();let t=!1;e.forEach(((e,s)=>{e.segmentIndex=s,t?e.selected&&(e.selected=!1):e.selected&&(t=!0,this.selectedValue=e.value)}))}setSegmentSize(){this.getSegments().forEach((e=>{e.shadowRoot.querySelector(".segment").classList.add("segment--"+this.size)}))}async componentDidLoad(){if(!o(this.el)){const e=n();a("ifx-segmented-control",await e)}this.setActiveSegment()}render(){return i("div",{key:"2f1d91daf15a367b18fcef6ff72c142dab8c9b98","aria-value":this.selectedValue,"aria-label":"segmented control",class:"group"},i("div",{key:"992df80e17f0631903a242649ff6f219f66f0d2d",class:"group__label"},this.label.trim(),this.required&&""!==this.label.trim().toLowerCase()&&i("span",{key:"97d41b8045eb735aed381db27ccbbbb08a82ac33",class:"required "+(this.error?"error":"")},"*")),i("div",{key:"f104d35a4ce0d994b016113f3b498e417b7323bc",class:"group__controls"},i("slot",{key:"9f96d3cb140ef0a43aa4ef30677261373dd7907b"})),this.caption.trim()&&i("div",{key:"896da68b262a2cf1d362477d29a29276816dcfd4",class:"group__caption "+(this.error?"error":"")},i("ifx-icon",{key:"391a3b6f37db6021e407fa68dcf9fedebd61533f",icon:"c-info-16"})," ",this.caption.trim()))}componentDidRender(){this.setSegmentSize()}static get style(){return".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}"}},[769,"ifx-segmented-control",{caption:[1],label:[1],size:[1],required:[4],error:[4]},[[0,"segmentSelect","onSegmentSelect"]]]),d=c,f=function(){"undefined"!=typeof customElements&&["ifx-segmented-control","ifx-icon"].forEach((e=>{switch(e){case"ifx-segmented-control":customElements.get(r(e))||customElements.define(r(e),c);break;case"ifx-icon":customElements.get(r(e))||l()}}))};export{d as IfxSegmentedControl,f as defineCustomElement}