import{__awaiter,__extends,__generator}from"tslib";import{b as balDevice}from"./device-TtMibDFL.js";import{L as ListenerAbstract,a as SingleSubject}from"./listener-CClDIhvK.js";import{l as rOnLoad}from"./helpers-BNj87EbG.js";var BalSwipeListener=function(t){__extends(i,t);function i(){return t!==null&&t.apply(this,arguments)||this}i.prototype.connect=function(i){return __awaiter(this,void 0,void 0,(function(){var n=this;return __generator(this,(function(e){switch(e.label){case 0:t.prototype.connect.call(this,i);return[4,this.loadLib()];case 1:e.sent();if(this.PointerListenerLib){this.pointerListener=new this.PointerListenerLib(i,{handleTouchEvents:false});this.shadowFixPointerDownListener=function(t){var n=t.target;if(n&&n!==i&&n.shadowRoot){n.releasePointerCapture(t.pointerId)}};i.addEventListener("pointerdown",this.shadowFixPointerDownListener);this.pointerListener.on("swipeleft",(function(){return n.notify({left:true,right:false})}));this.pointerListener.on("swiperight",(function(){return n.notify({left:false,right:true})}))}return[2]}}))}))};i.prototype.disconnect=function(){var i;if(this.shadowFixPointerDownListener&&this.el){this.el.removeEventListener("pointerdown",this.shadowFixPointerDownListener);this.shadowFixPointerDownListener=undefined}t.prototype.disconnect.call(this);(i=this.pointerListener)===null||i===void 0?void 0:i.destroy()};i.prototype.loadLib=function(){return __awaiter(this,void 0,void 0,(function(){var t=this;return __generator(this,(function(i){return[2,new Promise((function(i,n){rOnLoad((function(){return __awaiter(t,void 0,void 0,(function(){var t=this;return __generator(this,(function(e){import("./contact-BkEdlCZJ.js").then((function(n){t.PointerListenerLib=n.PointerListener;i()})).catch(n);return[2]}))}))}))}))]}))}))};return i}(ListenerAbstract);var BalSwipeSubject=function(t){__extends(i,t);function i(i){if(i===void 0){i={mobileOnly:false}}var n=t.call(this,(function(t,i){if(i){t.swipeListener(i)}}))||this;n.options=i;n.listener=new BalSwipeListener;return n}i.prototype.attach=function(i){var n=this;if(this.options.mobileOnly===true&&balDevice.isMobile||this.options.mobileOnly!==true){t.prototype.attach.call(this,i);this.listener.connect(i.el);this.listener.add((function(i){return t.prototype.notify.call(n,i)}))}};i.prototype.detach=function(){t.prototype.detach.call(this);this.listener.disconnect()};return i}(SingleSubject);export{BalSwipeSubject as B};