import{_ as m,c as h,o as v,b as r,n as c,p as b,d as l,C as f}from"./main-D6qyxymd.js";const w={props:{content:{type:Object,required:!0},uid:{type:String,required:!0},wwElementState:{type:Object,required:!0}},emits:["update:content:effect","trigger-event","add-state","remove-state"],setup(e,{emit:a}){const{value:n,setValue:i}=wwLib.wwVariable.useComponentVariable({uid:e.uid,name:"value",type:"boolean",defaultValue:l(()=>e.content.value===void 0?!1:e.content.value)}),o=f("_wwForm:useForm",()=>{}),t=l(()=>e.content.fieldName),s=l(()=>e.content.validation),u=l(()=>e.content.customValidation),d=l(()=>e.content.required);return o(n,{fieldName:t,validation:s,customValidation:u,required:d,initialValue:l(()=>e.content.value)},{elementState:e.wwElementState,emit:a,sidepanelFormPath:"form",setValue:i}),{variableValue:n,setValue:i}},computed:{isEditing(){return!1},value(){return!!this.variableValue},cssVariables(){const e=wwLib.wwUtils.getLengthUnit(this.content.selectorSize)[0],a=Math.min(Math.max(e,10),100),n=a/100,i=100-a;return{"--selector-size":n,"--transition-ajustement":`${i}%`,"--selector-color-off":this.content.selectorColorOff,"--selector-color-on":this.content.selectorColorOn,"--background-color":this.value?this.content.backgroundColorOn:this.content.backgroundColorOff}},isReadonly(){return this.wwElementState.props.readonly===void 0?this.content.readonly:this.wwElementState.props.readonly}},watch:{"content.value"(e){e=!!e,e!==this.value&&(this.setValue(e),this.$emit("trigger-event",{name:"initValueChange",event:{value:e}}))},isReadonly:{immediate:!0,handler(e){e?this.$emit("add-state","readonly"):this.$emit("remove-state","readonly")}}},methods:{handleManualInput(e){const a=!this.value;this.setValue(a),this.$emit("trigger-event",{name:"change",event:{domEvent:e,value:a}})}}},_=["aria-checked","disabled"],g=["value","name","checked","required","disabled"];function y(e,a,n,i,o,t){return v(),h("button",{type:"button",class:c(["ww-webapp-toggle",{"-active":t.value}]),role:"switch","aria-checked":t.value,style:b(t.cssVariables),onClick:a[0]||(a[0]=s=>t.handleManualInput(s)),disabled:t.isReadonly},[r("div",{class:c(["selector",{"-active":t.value}])},null,2),r("input",{type:"checkbox",value:t.value,class:"ww-webapp-toggle__hidden",name:n.wwElementState.name,checked:t.value,required:n.content.required,disabled:t.isReadonly},null,8,g)],14,_)}const k=m(w,[["render",y],["__scopeId","data-v-11c067a6"]]);export{k as e};
