import{r as t,c as s,h as i,H as e,g as h}from"./p-ClISz4NF.js";import{p as o}from"./p-CQvUntGY.js";import{S as a}from"./p-BcQO4NH2.js";import{g as n,a as r,t as c}from"./p-CoD1xawt.js";import{v as l}from"./p-NOJjz9dT.js";import{A as f,a as p}from"./p-Bz_RzYFb.js";import{g as u}from"./p-B6CqPcY_.js";import{t as d}from"./p-Cjg0wpDG.js";import{a as m}from"./p-DNztiAH0.js";import{c as b}from"./p-vN03FcXN.js";import{i as v}from"./p-CzXeijOj.js";import"./p-CgDnDrq5.js";import"./p-EeKNA85D.js";import"./p-U40vKHrs.js";import"./p-DYcNEwSZ.js";import"./p-DBXGhafv.js";const g=o(a,["_S","_M","_L"]);const j={root:"gov-form-range",fill:"gov-form-range--fill",input:"gov-form-range--input"};const C=class{constructor(i){t(this,i);this.govFocus=s(this,"gov-focus");this.govBlur=s(this,"gov-blur");this.govInput=s(this,"gov-input");this.size="m";this.tooltip=false;this.input=false;this.required=false;this.disabled=false;this.inheritedAttributes={};this.h=n(this.host);this.f=u(this.h);this.inputId=b("GovInput")}validateSize(t){l(g,t,j.root)}watchValue(){this.controlOutputPosition()}watchControlAttrs(){this.passControlAttrs()}passControlAttrs(){this.f.passAttrToControl("size",this.size);this.f.passAttrToControl("success",r(this.success));this.f.passAttrToControl("disabled",r(this.disabled));this.f.passAttrToControl("invalid",r(this.invalid))}get getThumbWidth(){const t=window.getComputedStyle(this.inputRef);return parseFloat(t.getPropertyValue("--thumb-size"))||1}controlOutputPosition(){const t=+this.value;const s=+this.inputRef.min;const i=+this.inputRef.max;const e=this.getThumbWidth*16;const h=this.inputRef.offsetWidth;const o=(t-s)/(i-s)*100;let a=o/100*(h-e)+e/2;if(this.outputRef){this.outputRef.textContent=this.value;const t=this.outputRef.offsetWidth/2;this.outputRef.style.left=`${a-t}px`}if(this.fillRef){this.fillRef.style.width=`${a}px`}}componentDidLoad(){this.attributeObserver=new f(this.host,((t,s)=>{this.onAriaAttributeChange(t,s)}));this.attributeObserver.startObserving(p)}componentWillLoad(){this.validateSize(this.size);this.inheritedAttributes=v(this.host)}componentDidRender(){this.passControlAttrs();this.f.passAttrToLabel("required",String(this.required));d(this.controlOutputPosition.bind(this))}onAriaAttributeChange(t,s){this.host.removeAttribute(t);this.inheritedAttributes=Object.assign(Object.assign({},this.inheritedAttributes),{[t]:s})}disconnectedCallback(){var t;(t=this.attributeObserver)===null||t===void 0?void 0:t.stopObserving()}render(){return i(e,{key:"52936cc832e35b7f79520c2f89b2a119e769b994",class:j.root,size:this.size},this.h.hasSlot("prefix")&&i("slot",{key:"1f5d3e1d537be5f431cbf4ba366627d82c2daa01",name:"prefix"}),i("span",{key:"cbabb9ff252fbabdd8b2f813de71b31c1a1444e6",class:"element"},i("input",Object.assign({key:"02dd3f62cb518c965c0f5529ae3b213a9c6fd649",type:"range",ref:t=>this.inputRef=t,onInput:this.onInputHandler.bind(this),onFocus:this.onFocusHandler.bind(this),onBlur:this.onBlurHandler.bind(this),id:this.identifier||this.inputId,name:this.name,min:this.min,max:this.max,step:this.step,list:this.listIdentifier,value:this.value,required:this.required,disabled:this.disabled},this.inheritedAttributes,{"aria-required":c(this.required),"aria-invalid":c(this.invalid),"aria-disabled":c(this.disabled)})),i("div",{key:"fff23dd770c71878eae67df3f96b514c3f55ea2e",class:j.fill,ref:t=>this.fillRef=t}),this.tooltip?i("output",{htmlFor:this.name,ref:t=>this.outputRef=t},this.value):null,i("slot",{key:"32a7919602b2527a97bf019ec74744bedd0ef51f",name:"datalist"})),this.h.hasSlot("sufix")&&i("slot",{key:"e9efd215bb9895a6c11666eb694b6c47f8132f12",name:"sufix"}),this.input?i("gov-form-input",Object.assign({"on-gov-input":this.onCustomInputHandler.bind(this),class:j.input,size:this.size,value:this.value,disabled:this.disabled},this.inheritedAttributes)):null)}onCustomInputHandler(t){const s=t.target.value;if(this.step&&m(+this.step)){const i=+s;const e=+this.min;const h=+this.max;const o=+this.step;if(isNaN(i)){return false}if(i<e||i>h){return false}const a=i-e;if(a%o!==0){return false}this.value=s;this.govInput.emit({component:j.root,value:this.value,originalEvent:t})}}onInputHandler(t){this.value=t.target.value;t.stopPropagation();this.govInput.emit({component:j.root,value:this.value,originalEvent:t})}onFocusHandler(t){t.stopPropagation();this.govFocus.emit({component:j.root,value:this.value,originalEvent:t})}onBlurHandler(t){t.stopPropagation();this.govBlur.emit({component:j.root,value:this.value,originalEvent:t})}async setFocus(t){return this.inputRef.focus(t)}async setValue(t){this.value=t}async clearValue(){this.value="";this.inputRef.value=""}async getRef(){return this.inputRef}get host(){return h(this)}static get watchers(){return{size:["validateSize","watchControlAttrs"],value:["watchValue"],disabled:["watchControlAttrs"],invalid:["watchControlAttrs"],success:["watchControlAttrs"]}}};export{C as gov_form_range};
//# sourceMappingURL=p-2cfa670d.entry.js.map