import{h}from"@stencil/core";import{isRtl}from"../../../functions/page-align";export class ScRadioGroup{constructor(){this.label="",this.invalid=void 0,this.value="",this.required=void 0}async reportValidity(){return this.invalid=!this.input.checkValidity(),this.input.reportValidity()}handleRadioClick(e){if("SC-RADIO"!==e.target.tagName)return;e.stopImmediatePropagation();const t=e.target;t.disabled||t.checked&&(this.value=t.value,this.scChange.emit(t.value))}componentDidLoad(){[...this.el.querySelectorAll("sc-radio")].forEach((e=>{e.checked&&(this.value=e.value)}))}render(){return h("fieldset",{key:"0d9a4ba13a02ca240257a1ea54439573d4bbd5cc",part:"base",class:{"radio-group":!0,"radio-group--invalid":this.invalid,"radio-group--is-required":this.required,"radio-group--is-rtl":isRtl()},"aria-invalid":this.invalid,role:"radiogroup"},h("legend",{key:"3c21b9c1d8ef448d07edf1e108f6085459dace07",part:"label",class:"radio-group__label"},h("slot",{key:"2c72f2c65b564a707c9dbb25c054f30c816b3ae3",name:"label"},this.label)),h("input",{key:"db34f962b73dc1f4c976b841204963fa3068b05c",type:"text",class:"radio-group__hidden-input",ref:e=>this.input=e,required:this.required,value:this.value,tabindex:"-1"}),h("div",{key:"f6c015bd02e42caf4c1e1a2441f1974ac0b7bf28",part:"items",class:"radio-group__items"},h("slot",{key:"11abc8a0e5f0cf8979820facdf61749dda257d97"})))}static get is(){return"sc-radio-group"}static get encapsulation(){return"shadow"}static get originalStyleUrls(){return{$:["sc-radio-group.scss"]}}static get styleUrls(){return{$:["sc-radio-group.css"]}}static get properties(){return{label:{type:"string",mutable:!1,complexType:{original:"string",resolved:"string",references:{}},required:!1,optional:!1,docs:{tags:[],text:"The radio group label. Required for proper accessibility."},attribute:"label",reflect:!1,defaultValue:"''"},invalid:{type:"boolean",mutable:!0,complexType:{original:"boolean",resolved:"boolean",references:{}},required:!1,optional:!1,docs:{tags:[],text:"This will be true when the control is in an invalid state. Validity is determined by props such as `type`,\n`required`, `minlength`, `maxlength`, and `pattern` using the browser's constraint validation API."},attribute:"invalid",reflect:!0},value:{type:"string",mutable:!0,complexType:{original:"string",resolved:"string",references:{}},required:!1,optional:!1,docs:{tags:[],text:"The selected value of the control."},attribute:"value",reflect:!0,defaultValue:"''"},required:{type:"boolean",mutable:!1,complexType:{original:"boolean",resolved:"boolean",references:{}},required:!1,optional:!1,docs:{tags:[],text:"Is one of these items required."},attribute:"required",reflect:!1}}}static get events(){return[{method:"scChange",name:"scChange",bubbles:!0,cancelable:!0,composed:!0,docs:{tags:[],text:""},complexType:{original:"string",resolved:"string",references:{}}}]}static get methods(){return{reportValidity:{complexType:{signature:"() => Promise<boolean>",parameters:[],references:{Promise:{location:"global",id:"global::Promise"}},return:"Promise<boolean>"},docs:{text:"Checks for validity and shows the browser's validation message if the control is invalid.",tags:[]}}}}static get elementRef(){return"el"}static get listeners(){return[{name:"scChange",method:"handleRadioClick",target:void 0,capture:!1,passive:!1}]}}