import{r as o,c as a,h as s,H as i,g as t}from"./p-32e583ea.js";import{s as e,c as r,d as n,u as d,v as c,w as p,x as l,n as h}from"./p-52d77e1f.js";const g=":host{display:flex;--wcs-radio-group-gap:var(--wcs-semantic-spacing-base);--wcs-radio-group-option-height:var(--wcs-semantic-size-m);--wcs-radio-group-option-gap:var(--wcs-semantic-spacing-small);--wcs-radio-group-option-padding:var(--wcs-semantic-spacing-small) var(--wcs-semantic-spacing-small);--wcs-radio-group-option-border-radius:var(--wcs-semantic-border-radius-base);--wcs-radio-group-option-background-color:var(--wcs-semantic-color-background-surface-accent-lightest)}:host([mode=radio]){flex-direction:column;gap:var(--wcs-radio-group-gap)}:host([mode=option]){box-sizing:border-box;height:var(--wcs-radio-group-option-height);display:inline-flex;flex-direction:row;align-items:center;gap:var(--wcs-radio-group-option-gap);padding:var(--wcs-radio-group-option-padding);background-color:var(--wcs-radio-group-option-background-color);border-radius:var(--wcs-radio-group-option-border-radius)}:host([mode=horizontal]){justify-content:space-between}";const u=g;const f=class{constructor(s){o(this,s);this.wcsChange=a(this,"wcsChange",7);this.value=undefined;this.name=undefined;this.mode="radio"}onValueChangeHandler(o){this.updateRadioTabIndex(o);this.updateAllRadioState()}async setAriaAttribute(o,a){e(this.el,o,a)}componentDidLoad(){this.onValueChangeHandler(this.value);this.updateAllRadioModeAndName()}onSlotChange(){this.updateRadioTabIndex(this.value);this.updateAllRadioModeAndName()}updateAllRadioState(){this.getSlottedRadios().forEach((o=>o.updateState()))}updateAllRadioModeAndName(){this.getSlottedRadios().forEach((o=>{o.mode=this.mode;o.name=this.name}))}updateRadioTabIndex(o){const a=this.getSlottedRadios();const s=a.find((o=>!o.disabled));const i=a.find((a=>a.value===o&&!a.disabled));if(!s&&!i){return}const t=i||s;for(const o of a){const a=o===t?0:-1;o.setTabIndex(a)}}getSlottedRadios(){return Array.from(this.el.querySelectorAll("wcs-radio"))}getSlottedRadiosNotDisabled(){return Array.from(this.getSlottedRadios().filter((o=>!o.disabled)))}handleRadioClick(o){this.value=o.detail.value;this.wcsChange.emit({value:o.detail.value})}async handleKeyDown(o){const a=this.getSlottedRadiosNotDisabled();const s=a.findIndex((a=>a===o.target));let i;if(r(o)||n(o)){o.preventDefault();i=s}else if(d(o)||c(o)){o.preventDefault();i=(s+1)%a.length}else if(p(o)||l(o)){o.preventDefault();i=(s-1+a.length)%a.length}else if(h(o)){return}const t=a[i];if(t){t.focus();if(this.value!==t.value){this.wcsChange.emit({value:t.value})}this.value=t.value}}render(){return s(i,{key:"3179704d2f1ed56f940941c1777b90a49ecd0ffa",role:"radiogroup"},s("slot",{key:"f01213b0c89bc04622601447005e24df07fea376",name:"option",onSlotchange:this.onSlotChange.bind(this)}))}get el(){return t(this)}static get watchers(){return{value:["onValueChangeHandler"],name:["updateAllRadioModeAndName"],mode:["updateAllRadioModeAndName"]}}};f.style=u;export{f as wcs_radio_group}; //# sourceMappingURL=p-fdeae83e.entry.js.map