import{r as i,c as s,h as e,H as r,a as o}from"./p-B2f84Zog.js";import{m as a}from"./p-C3xDZBme.js";import{b as d}from"./p-D4ys0pep.js";const p=".sc-pds-radio-group-h{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;gap:var(--pine-dimension-sm)}.is-invalid.sc-pds-radio-group-h .pds-radio-group__message--error.sc-pds-radio-group{color:var(--pine-color-text-message-danger)}.pds-radio-group__label.sc-pds-radio-group{color:var(--pine-color-text-label);font:var(--pine-typography-heading-6);font-weight:var(--pine-font-weight-medium);letter-spacing:var(--pine-letter-spacing-heading-6)}.pds-radio-group__radios.sc-pds-radio-group{display:-ms-flexbox;display:flex;gap:var(--pds-radio-group-gap, var(--pine-dimension-xs))}.pds-radio-group__radios--row.sc-pds-radio-group{-ms-flex-align:start;align-items:flex-start;-ms-flex-direction:row;flex-direction:row;-ms-flex-wrap:wrap;flex-wrap:wrap}.pds-radio-group__radios--column.sc-pds-radio-group{-ms-flex-direction:column;flex-direction:column}.pds-radio-group__message.sc-pds-radio-group{color:var(--pine-color-text-message);font:var(--pine-typography-body);width:100%}.pds-radio-group__message--error.sc-pds-radio-group{display:-ms-flexbox;display:flex;gap:var(--pine-dimension-2xs)}.pds-radio-group__message--error.sc-pds-radio-group pds-icon.sc-pds-radio-group{-webkit-margin-before:var(--pine-dimension-050);margin-block-start:var(--pine-dimension-050)}";const n=class{constructor(e){i(this,e);this.pdsRadioGroupChange=s(this,"pdsRadioGroupChange");this.direction="column";this.gap="xs";this.disabled=false;this.invalid=false;this.required=false}handlePropsChange(){this.updateChildRadios()}handleRadioChange(i){const s=i.target;if(s.type!=="radio"){return}if(s.checked){const i=s.closest("pds-radio");if(i){this.pdsRadioGroupChange.emit({checked:true,value:i.value,componentId:i.componentId})}}}updateChildRadios(){const i=this.el.querySelectorAll("pds-radio");i.forEach((i=>{if(this.name){i.setAttribute("name",this.name)}else{i.removeAttribute("name")}if(this.disabled){i.setAttribute("disabled","true")}else{i.removeAttribute("disabled")}if(this.invalid){i.setAttribute("invalid","true")}else{i.removeAttribute("invalid")}if(this.required){i.setAttribute("required","true")}else{i.removeAttribute("required")}}))}componentWillLoad(){if(this.componentId){this._groupId=this.componentId}else{const i=typeof crypto!=="undefined"&&crypto.randomUUID?crypto.randomUUID():`${Date.now()}-${Math.random().toString(36).substring(2,9)}`;this._groupId=`radio-group-${i}`}}componentDidLoad(){if(!this.name){console.warn("pds-radio-group: name prop is required for proper radio group functionality")}this.updateChildRadios()}classNames(){const i=[];if(this.invalid){i.push("is-invalid")}return i.join(" ")}getGapValue(){const i={none:"0",xxs:"var(--pine-dimension-xxs)",xs:"var(--pine-dimension-xs)",sm:"var(--pine-dimension-sm)",md:"var(--pine-dimension-md)",lg:"var(--pine-dimension-lg)",xl:"var(--pine-dimension-xl)",xxl:"var(--pine-dimension-xxl)"};if(i[this.gap]){return i[this.gap]}return`var(--pine-dimension-${this.gap})`}getAriaDescribedBy(){const i=[];if(this.errorMessage){i.push(a(this._groupId,"error"))}if(this.helperMessage){i.push(a(this._groupId,"helper"))}return i.length>0?i.join(" "):undefined}render(){const i=this.getGapValue();const s=this.getAriaDescribedBy();return e(r,{key:"53949e8e878887189482a13e0402402b8ee79c46",class:this.classNames(),id:this._groupId,role:"group","aria-describedby":s,style:{"--pds-radio-group-gap":i}},this.groupLabel&&e("div",{key:"9aa547ff0b60d1eb78ab6806c552391c119c6511",class:"pds-radio-group__label"},this.groupLabel),e("div",{key:"5bad4f6d4c685eca8a97b574511f21b93bdf4821",class:{"pds-radio-group__radios":true,"pds-radio-group__radios--row":this.direction==="row","pds-radio-group__radios--column":this.direction==="column"}},e("slot",{key:"ffd76f30b308f124e1df925b2fe354ffb80f59bc",onSlotchange:()=>this.updateChildRadios()})),this.helperMessage&&e("div",{key:"ea8995384b1e1c1e98d01d704bd969a97bfd2b2a",class:"pds-radio-group__message",id:a(this._groupId,"helper")},this.helperMessage),this.errorMessage&&e("div",{key:"30726bc368c7ad2820ae4cb43faf0a45e94a51e8",class:"pds-radio-group__message pds-radio-group__message--error",id:a(this._groupId,"error"),"aria-live":"assertive"},e("pds-icon",{key:"acc00b6e36ead10cc5cc01033ad0f619bd75f5da",icon:d,size:"small"}),this.errorMessage))}get el(){return o(this)}static get watchers(){return{name:["handlePropsChange"],disabled:["handlePropsChange"],invalid:["handlePropsChange"],required:["handlePropsChange"]}}};n.style=p;export{n as pds_radio_group};
//# sourceMappingURL=p-dab76f15.entry.js.map