import{r as e,c as t,a as s,h as i}from"./p-Cby2wKoI.js";import{i as c}from"./p-CtINY9El.js";import{d as a,t as o}from"./p-DNHOWgWh.js";const r=()=>`:host{display:inline-block;user-select:none}.container{display:flex;flex-direction:row;align-items:center}.container.gap{gap:16px}.switch__checkbox-container{padding:4px;display:flex;align-items:center;position:relative;width:32px;height:16px;background-color:#FFFFFF;border:1px solid #575352;border-radius:20px;cursor:pointer;transition:background-color 0.3s ease;outline:none}.switch__checkbox-container:focus{outline:4px solid #0A8276;outline-offset:2px}.switch__checkbox-container:focus:not(:focus-visible){outline:none}.switch__checkbox-container:focus-visible{outline:2px solid #0A8276;outline-offset:2px}.switch__checkbox-container.disabled{cursor:default;border-color:#BFBBBB}.switch__label-wrapper label:hover{cursor:pointer}.switch__label-wrapper.disabled{color:#BFBBBB}.switch__label-wrapper.disabled label:hover{cursor:default}.switch__checkbox-wrapper .switch{width:16px;height:16px;background-color:#575352;border-radius:50%;transition:transform 0.3s ease, background-color 0.3s ease}.switch__checkbox-wrapper .switch.disabled{background-color:#BFBBBB;border-color:#BFBBBB;cursor:default}.switch__checkbox-wrapper .switch.checked{transform:translateX(16px);background-color:#FFFFFF}.switch__checkbox-wrapper .switch.checked.disabled{cursor:default}.switch__checkbox-container:hover .toggle-switch{box-shadow:0 0 5px rgba(0, 0, 0, 0.2)}.switch__checkbox-container.checked{background-color:#0A8276;border-color:#0A8276}.switch__checkbox-container.checked.disabled{background-color:#BFBBBB;border-color:#BFBBBB;cursor:default}`;const h=class{constructor(s){e(this,s);this.ifxChange=t(this,"ifxChange",7);if(s.$hostElement$["s-ei"]){this.internals=s.$hostElement$["s-ei"]}else{this.internals=s.$hostElement$.attachInternals();s.$hostElement$["s-ei"]=this.internals}}initialChecked;get el(){return s(this)}checked=false;onCheckedChange(e,t){if(e!==t){this.checked=e;this.updateFormValue()}}disabled=false;name="";value="on";internals;ifxChange;componentWillLoad(){this.initialChecked=this.checked;this.updateFormValue()}async componentDidLoad(){if(!c(this.el)){const e=a();o("ifx-switch",await e)}this.toggleLabelGap()}formResetCallback(){this.checked=this.initialChecked;this.updateFormValue()}formStateRestoreCallback(e,t){if(e){this.checked=true;this.updateFormValue()}else{this.checked=false;this.internals.setFormValue(null)}}async isChecked(){return this.checked}async setChecked(e){this.checked=e;return Promise.resolve()}async toggle(){return Promise.resolve(this.toggleSwitch())}handleKeyDown(e){if(this.disabled)return;if(e.key==="Enter"||e.key===" "){this.toggleSwitch()}}toggleSwitch(){if(this.disabled)return;this.checked=!this.checked;this.updateFormValue();this.ifxChange.emit(this.checked);return this.checked}updateFormValue(){if(this.checked){this.internals.setFormValue(this.value)}else{this.internals.setFormValue(null)}}toggleLabelGap(){const e=this.el.shadowRoot.querySelector("slot");const t=this.el.shadowRoot.querySelector(".container");if(e.assignedNodes().length){t.classList.add("gap")}else{t.classList.remove("gap")}}render(){return i("div",{key:"242ae64dcee730edaa3b8b6f96c340b91c07a482",class:"container",role:"switch","aria-checked":this.checked?"true":"false","aria-disabled":this.disabled?"true":"false","aria-labelledby":"switch-label",tabIndex:this.disabled?-1:0,onClick:()=>this.toggleSwitch(),onKeyDown:e=>this.handleKeyDown(e)},i("div",{key:"cf6b23d0518b5eacbe7f4dadc51ceb219e70d49b",class:`switch__checkbox-container ${this.checked?"checked":""} ${this.disabled?"disabled":""}`},i("div",{key:"42943c6c24efae96cf0672116b5641da49b5cd42",class:"switch__checkbox-wrapper"},i("input",{key:"6dbf124821701a009205713ed0e87037d96038ef",type:"checkbox",hidden:true,name:this.name,disabled:this.disabled,checked:this.checked,value:this.value}),i("div",{key:"6d2a5a20a3fc59af44a7c37992a1b0a06be31265",class:`switch ${this.checked?"checked":""} ${this.disabled?"disabled":""}`}))),i("div",{key:"92fc2d3cc3397a266f85fd7d4a317fbad4ac76ae",class:`switch__label-wrapper ${this.disabled?"disabled":""}`},i("label",{key:"0f40584f68da82c38cbca8e7cb575287b87cc4b7",htmlFor:"switch"},i("slot",{key:"f75f8d5f701fa29ee88a985ff0e58b3b4a66da6f",onSlotchange:()=>this.toggleLabelGap()}))))}static get formAssociated(){return true}static get watchers(){return{checked:[{onCheckedChange:0}]}}};h.style=r();export{h as ifx_switch};
//# sourceMappingURL=p-52263ffd.entry.js.map