import{p as e,H as t,c as s,h as c,t as i}from"./p-CHfEnK-2.js";import{i as o,d as a,t as r}from"./p-94ZtGp9D.js";const h=e(class extends t{constructor(e){super(),!1!==e&&this.__registerHost(),this.__attachShadow(),this.ifxChange=s(this,"ifxChange",7),this.internals=this.attachInternals()}initialChecked;get el(){return this}checked=!1;onCheckedChange(e,t){e!==t&&(this.checked=e,this.updateFormValue())}disabled=!1;name="";value="on";internals;ifxChange;componentWillLoad(){this.initialChecked=this.checked,this.updateFormValue()}async componentDidLoad(){if(!o(this.el)){const e=a();r("ifx-switch",await e)}this.toggleLabelGap()}formResetCallback(){this.checked=this.initialChecked,this.updateFormValue()}formStateRestoreCallback(e,t){e?(this.checked=!0,this.updateFormValue()):(this.checked=!1,this.internals.setFormValue(null))}async isChecked(){return this.checked}async setChecked(e){return this.checked=e,Promise.resolve()}async toggle(){return Promise.resolve(this.toggleSwitch())}handleKeyDown(e){this.disabled||"Enter"!==e.key&&" "!==e.key||this.toggleSwitch()}toggleSwitch(){if(!this.disabled)return this.checked=!this.checked,this.updateFormValue(),this.ifxChange.emit(this.checked),this.checked}updateFormValue(){this.internals.setFormValue(this.checked?this.value:null)}toggleLabelGap(){const e=this.el.shadowRoot.querySelector("slot"),t=this.el.shadowRoot.querySelector(".container");e.assignedNodes().length?t.classList.add("gap"):t.classList.remove("gap")}render(){return c("div",{key:"4f137e21419133c65b822f56d0d257d11797b994",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)},c("div",{key:"217c676f7fc02d91c38b8deaf2f73189d3049bfd",class:`switch__checkbox-container ${this.checked?"checked":""} ${this.disabled?"disabled":""}`},c("div",{key:"3bbce15daf27e6c702b49b91ebf069e57f1d9352",class:"switch__checkbox-wrapper"},c("input",{key:"3ca650f0e2621ee021a90576dc4170a9ac4382f0",type:"checkbox",hidden:!0,name:this.name,disabled:this.disabled,checked:this.checked,value:this.value}),c("div",{key:"52383472e04828baf559b876aa0439644c40faa7",class:`switch ${this.checked?"checked":""} ${this.disabled?"disabled":""}`}))),c("div",{key:"366ffea5902cd0cec213d7c067fb91007ab2ee79",class:"switch__label-wrapper "+(this.disabled?"disabled":"")},c("label",{key:"22b4d8c0706b7ae5f9b84645e54e9e468fa4bee3",htmlFor:"switch"},c("slot",{key:"1023a182f96ca51e4083cb474d3aea84307f34bb",onSlotchange:()=>this.toggleLabelGap()}))))}static get formAssociated(){return!0}static get watchers(){return{checked:[{onCheckedChange:0}]}}static get style(){return":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}"}},[833,"ifx-switch",{checked:[1028],disabled:[4],name:[1],value:[1],isChecked:[64],setChecked:[64],toggle:[64]},void 0,{checked:[{onCheckedChange:0}]}]),n=h,l=function(){"undefined"!=typeof customElements&&["ifx-switch"].forEach((e=>{"ifx-switch"===e&&(customElements.get(i(e))||customElements.define(i(e),h))}))};export{n as IfxSwitch,l as defineCustomElement}