class LiquidSwitchBehavior extends LiquidBehavior{static behaviorName="liquidSwitch";static initialModelProps={isOn:!1};static domEvents={"click @switcher:not([type=checkbox])":"onSwitcherChange","change @switcher[type=checkbox]":"onSwitcherChange"};static modelEvents={"change:isOn":"onModelChange"};options(){return{useLocalStorage:!1,attrs:[]}}get ui(){return{switcher:"input[type=checkbox]"}}initialize(){this.handleInitialValues()}handleInitialValues(){if(!this.getOption("useLocalStorage"))return;this.getOption("attrs").forEach(({attr:i,val:o,el:a})=>{getElementFromString(a,this.view.el).getAttribute(i)===o.on&&this.getUI("switcher").forEach(n=>{n.classList.add(STATE_CLASSNAMES.ACTIVE),n.checked=!0,this.model.set("isOn",!0)})})}onModelChange(t,e){this.onSwitchChange(e?"on":"off")}onSwitcherChange(t){const e=t.currentTarget;this.model.set({isOn:e?.checked})}onSwitchChange(t){const e=this.getOption("useLocalStorage");this.getOption("attrs").forEach(o=>{this.handleHtmlAttrs(t,o),e&&this.handleLocalStorate(t,o)})}handleHtmlAttrs(t,{attr:e,el:i,val:o}){getElementFromString(i).setAttribute(e,o[t]),t==="on"?this.getUI("switcher").forEach(s=>{s.classList.add(STATE_CLASSNAMES.ACTIVE),s.checked=!0}):this.getUI("switcher").forEach(s=>{s.classList.remove(STATE_CLASSNAMES.ACTIVE),s.checked=!1})}handleLocalStorate(t,{key:e,val:i}){localStorage.setItem(e,i[t])}}typeof window<"u"&&(window.liquid?.app?window.liquid?.app?.model?.set("loadedBehaviors",[...window.liquid.app.model.get("loadedBehaviors"),LiquidSwitchBehavior]):window.liquid?.loadedBehaviors?.push(LiquidSwitchBehavior));