import{b as s}from"./p-MBsgW7uz.js";import{L as t,a as i}from"./p-C20cwFWy.js";import{l as h}from"./p-Ba5qjFjW.js";class e extends t{async connect(s){super.connect(s),await this.loadLib(),this.PointerListenerLib&&(this.pointerListener=new this.PointerListenerLib(s,{handleTouchEvents:!1}),this.shadowFixPointerDownListener=t=>{const i=t.target;i&&i!==s&&i.shadowRoot&&i.releasePointerCapture(t.pointerId)},s.addEventListener("pointerdown",this.shadowFixPointerDownListener),this.pointerListener.on("swipeleft",(()=>this.notify({left:!0,right:!1}))),this.pointerListener.on("swiperight",(()=>this.notify({left:!1,right:!0}))))}disconnect(){var s;this.shadowFixPointerDownListener&&this.el&&(this.el.removeEventListener("pointerdown",this.shadowFixPointerDownListener),this.shadowFixPointerDownListener=void 0),super.disconnect(),null===(s=this.pointerListener)||void 0===s||s.destroy()}async loadLib(){return new Promise(((s,t)=>{h((async()=>{import("./p-BkEdlCZJ.js").then((t=>{this.PointerListenerLib=t.PointerListener,s()})).catch(t)}))}))}}class r extends i{constructor(s={mobileOnly:!1}){super(((s,t)=>{t&&s.swipeListener(t)})),this.options=s,this.listener=new e}attach(t){(!0===this.options.mobileOnly&&s.isMobile||!0!==this.options.mobileOnly)&&(super.attach(t),this.listener.connect(t.el),this.listener.add((s=>super.notify(s))))}detach(){super.detach(),this.listener.disconnect()}}export{r as B}