import{p as t,H as s,c as e,h as i,a}from"./index.js";import{g as o,d as c,e as n}from"./p-9imLQpxb.js";import{g as h,t as r,c as d}from"./p-DKo9A5gq.js";import{v as l}from"./p-BKP-F1qP.js";import{c as f}from"./p-vN03FcXN.js";import{p as u}from"./p-B0hcuYXk.js";import{t as m}from"./p-Cjg0wpDG.js";import{A as p,a as v,i as b}from"./p-CXgom82_.js";import{d as g}from"./p-BJnSrRNH.js";const w=t(class t extends s{constructor(){super();this.__registerHost();this.govFocus=e(this,"gov-focus");this.govBlur=e(this,"gov-blur");this.govChange=e(this,"gov-change");this.size="m";this.required=false;this.disabled=false;this.optionsState=[];this.inheritedAttributes={};this.h=h(this.host);this.f=o(this.h);this.selectId=f("GovSelect")}validateSize(t){l(n,t,c.root)}watchOptions(t){this.optionsState=u(t)}watchControlAttrs(){this.passControlAttrs()}watchValue(){this.markSelectedValue()}passControlAttrs(){this.f.passAttrToControl("size",this.size);this.f.passAttrToControl("invalid",r(this.invalid));this.f.passAttrToControl("success",r(this.success));this.f.passAttrToControl("disabled",r(this.disabled));this.f.passAttrToControl("type","select")}componentDidLoad(){this.attributeObserver=new p(this.host,((t,s)=>{this.onAriaAttributeChange(t,s)}));this.attributeObserver.startObserving(v)}disconnectedCallback(){var t;(t=this.attributeObserver)===null||t===void 0?void 0:t.stopObserving()}componentWillLoad(){this.validateSize(this.size);this.markSelectedValue();this.optionsState=u(this.options);this.inheritedAttributes=b(this.host)}async componentDidRender(){this.passControlAttrs();this.f.passAttrToLabel("required",String(this.required));m((()=>this.markSelectedValue()))}onAriaAttributeChange(t,s){this.host.removeAttribute(t);this.inheritedAttributes=Object.assign(Object.assign({},this.inheritedAttributes),{[t]:s})}markSelectedValue(){this.host.querySelectorAll("option").forEach((t=>{if(t.value===this.value){t.setAttribute("selected","selected")}else{t.removeAttribute("selected")}}))}render(){return i(a,{key:"784373d222b67be86b39d3ed61bfdf81d9648a36",class:c.root,size:this.size},this.h.hasSlot("prefix")&&i("slot",{key:"23b99e07df8d0d135c93bdd8c14556de4b4a5433",name:"prefix"}),i("span",{key:"f4c931f58a53db5cc2f8379b2dc6b688bbe84bc8",class:"element"},i("select",Object.assign({key:"e259f55116a12a7b821fac43db61b9ed35457c17",id:this.identifier||this.selectId,onFocus:this.onFocusHandler.bind(this),onChange:this.onChangeHandler.bind(this),onBlur:this.onBlurHandler.bind(this),required:this.required,name:this.name,disabled:this.disabled,ref:t=>this.selectRef=t},this.inheritedAttributes,{"aria-disabled":d(this.disabled),"aria-required":d(this.required),"aria-invalid":d(this.invalid)}),i("slot",{key:"223133e692d0c7a4c2c9c4706aee2d447f37c37b"}),Array.isArray(this.optionsState)&&this.optionsState.map((t=>{var s;return i("option",{value:t.value,selected:t.value===this.value,disabled:t===null||t===void 0?void 0:t.disabled},(s=t.label)!==null&&s!==void 0?s:t.value)}))),this.success&&i("gov-icon",{key:"97ceacc7ec59f13a9d994dc6df3b58201b5f68ae",class:"validation-icon",name:"check-lg",type:"components"}),this.invalid&&i("gov-icon",{key:"bd9f33ef6da150e5a3f4a5711d41282fe35df49f",class:"validation-icon",name:"exclamation-lg",type:"components"}),i("gov-icon",{key:"c5ca08441cb8f425a4e310e402d6f208c8a75e15",class:"arrow-icon",name:"chevron-down",type:"components"})),this.h.hasSlot("sufix")&&i("slot",{key:"af16a1bd05ed5d665888cea9a811eee2c0fe5749",name:"sufix"}))}onFocusHandler(t){this.focused=true;this.govFocus.emit({component:c.root,originalEvent:t,value:this.value})}onBlurHandler(t){this.focused=false;this.govBlur.emit({component:c.root,originalEvent:t,value:this.value})}onChangeHandler(t){this.value=t.target.value;t.stopPropagation();this.govChange.emit({component:c.root,originalEvent:t,value:this.value})}async setFocus(t){return this.selectRef.focus(t)}async getRef(){return this.selectRef}get host(){return this}static get watchers(){return{size:["validateSize","watchControlAttrs"],options:["watchOptions"],disabled:["watchControlAttrs"],invalid:["watchControlAttrs"],success:["watchControlAttrs"],value:["watchValue"]}}},[4,"gov-form-select",{value:[1537],options:[1537],identifier:[1],size:[1],name:[1],required:[4],success:[516],disabled:[516],invalid:[4],focused:[32],optionsState:[32],inheritedAttributes:[32],setFocus:[64],getRef:[64]},undefined,{size:["validateSize","watchControlAttrs"],options:["watchOptions"],disabled:["watchControlAttrs"],invalid:["watchControlAttrs"],success:["watchControlAttrs"],value:["watchValue"]}]);function y(){if(typeof customElements==="undefined"){return}const t=["gov-form-select","gov-icon"];t.forEach((t=>{switch(t){case"gov-form-select":if(!customElements.get(t)){customElements.define(t,w)}break;case"gov-icon":if(!customElements.get(t)){g()}break}}))}y();export{w as G,y as d};
//# sourceMappingURL=p-DhGb8cBK.js.map