import{r as t,c as s,h as i,H as e}from"./p-21516f8c.js";import{n as r}from"./p-6fdf5ce4.js";class h{constructor(){this.gestureId=0;this.requestedStart=new Map;this.disabledGestures=new Map;this.disabledScroll=new Set}createGesture(t){return new n(this,this.newID(),t.name,t.priority||0,!!t.disableScroll)}createBlocker(t={}){return new o(this,this.newID(),t.disable,!!t.disableScroll)}start(t,s,i){if(!this.canStart(t)){this.requestedStart.delete(s);return false}this.requestedStart.set(s,i);return true}capture(t,s,i){if(!this.start(t,s,i)){return false}const e=this.requestedStart;let r=-1e4;e.forEach((t=>{r=Math.max(r,t)}));if(r===i){this.capturedId=s;e.clear();const i=new CustomEvent("luGestureCaptured",{detail:{gestureName:t}});document.dispatchEvent(i);return true}e.delete(s);return false}release(t){this.requestedStart.delete(t);if(this.capturedId===t){this.capturedId=undefined}}disableGesture(t,s){let i=this.disabledGestures.get(t);if(i===undefined){i=new Set;this.disabledGestures.set(t,i)}i.add(s)}enableGesture(t,s){const i=this.disabledGestures.get(t);if(i!==undefined){i.delete(s)}}disableScroll(t){this.disabledScroll.add(t);if(this.disabledScroll.size===1){document.body.classList.add(a)}}enableScroll(t){this.disabledScroll.delete(t);if(this.disabledScroll.size===0){document.body.classList.remove(a)}}canStart(t){if(this.capturedId!==undefined){return false}if(this.isDisabled(t)){return false}return true}isCaptured(){return this.capturedId!==undefined}isScrollDisabled(){return this.disabledScroll.size>0}isDisabled(t){const s=this.disabledGestures.get(t);if(s&&s.size>0){return true}return false}newID(){this.gestureId++;return this.gestureId}}class n{constructor(t,s,i,e,r){this.id=s;this.name=i;this.disableScroll=r;this.priority=e*1e6+s;this.ctrl=t}canStart(){if(!this.ctrl){return false}return this.ctrl.canStart(this.name)}start(){if(!this.ctrl){return false}return this.ctrl.start(this.name,this.id,this.priority)}capture(){if(!this.ctrl){return false}const t=this.ctrl.capture(this.name,this.id,this.priority);if(t&&this.disableScroll){this.ctrl.disableScroll(this.id)}return t}release(){if(this.ctrl){this.ctrl.release(this.id);if(this.disableScroll){this.ctrl.enableScroll(this.id)}}}destroy(){this.release();this.ctrl=undefined}}class o{constructor(t,s,i,e){this.id=s;this.disable=i;this.disableScroll=e;this.ctrl=t}block(){if(!this.ctrl){return}if(this.disable){for(const t of this.disable){this.ctrl.disableGesture(t,this.id)}}if(this.disableScroll){this.ctrl.disableScroll(this.id)}}unblock(){if(!this.ctrl){return}if(this.disable){for(const t of this.disable){this.ctrl.enableGesture(t,this.id)}}if(this.disableScroll){this.ctrl.enableScroll(this.id)}}destroy(){this.unblock();this.ctrl=undefined}}const a="backdrop-no-scroll";const c=new h;const u=":host{left:0;right:0;top:0;bottom:0;display:block;position:absolute;transform:translateZ(0);background-color:rgba(0, 0, 0, 0.24);contain:strict;cursor:pointer;opacity:0.01;touch-action:none;z-index:2}:host(.backdrop-hide){background:transparent}:host(.backdrop-no-tappable){cursor:auto}";const f=class{constructor(i){t(this,i);this.luBackdropTap=s(this,"luBackdropTap",7);this.lastClick=-1e4;this.blocker=c.createBlocker({disableScroll:true});this.visible=true;this.tappable=true;this.stopPropagation=true}connectedCallback(){if(this.stopPropagation){this.blocker.block()}}disconnectedCallback(){this.blocker.unblock()}onTouchStart(t){this.lastClick=r(t);this.emitTap(t)}onMouseDown(t){if(this.lastClick<r(t)-2500){this.emitTap(t)}}emitTap(t){if(this.stopPropagation){t.preventDefault();t.stopPropagation()}if(this.tappable){this.luBackdropTap.emit()}}render(){return i(e,{tabindex:"-1",class:{"backdrop-hide":!this.visible,"backdrop-no-tappable":!this.tappable}})}};f.style=u;export{f as lu_backdrop};
//# sourceMappingURL=p-db898d6e.entry.js.map