"use strict";const v=require("react"),a=require("./index3.js"),d=require("./sl-types.js");let i=[],o=0;const s=4,c=u=>{let e=[],t={get(){return t.lc||t.listen(()=>{})(),t.value},lc:0,listen(n){return t.lc=e.push(n),()=>{for(let r=o+s;r<i.length;)i[r]===n?i.splice(r,s):r+=s;let l=e.indexOf(n);~l&&(e.splice(l,1),--t.lc||t.off())}},notify(n,l){let r=!i.length;for(let f of e)i.push(f,t.value,n,l);if(r){for(o=0;o<i.length;o+=s)i[o](i[o+1],i[o+2],i[o+3]);i.length=0}},off(){},set(n){let l=t.value;l!==n&&(t.value=n,t.notify(l))},subscribe(n){let l=t.listen(n);return n(t.value),l},value:u};return t},p=(u={})=>{let e=c(u);return e.setKey=function(t,n){let l=e.value;typeof n>"u"&&t in e.value?(e.value={...e.value},delete e.value[t],e.notify(l,t)):e.value[t]!==n&&(e.value={...e.value,[t]:n},e.notify(l,t))},e},b=u=>[e=>(...t)=>(u&&a.eventBus.emit(u==null?void 0:u.type,u),e?e(t):null)],g=u=>{const e=u.target;e instanceof HTMLAnchorElement&&e.target==="_blank"&&e.getAttribute("data-a")==="web-link"&&a.eventBus.emit("poll",{action:"navigated",payload:{}}),e instanceof Element&&e.getAttribute("data-a")==="intr"&&a.eventBus.emit("interactions",{action:"tap",payload:{}})},y=(u,e)=>{const t=window.innerWidth<d.A.xl;v.useEffect(()=>{const n=t&&e.useDomNode?document:u.current,l=r=>{e.listener(r,u)};return e.enabled&&(n==null||n.addEventListener(e.event,l)),()=>{n==null||n.removeEventListener(e.event,l)}},[t,e.enabled,e.listener])};exports.A=g;exports.a=c;exports.b=y;exports.f=p;exports.f$1=b;
