/*!
 * Custom elements for Nanopore-Digital Web applications
 */
import{i as e,j as t}from"./index-BM3Om9WE.js";const s=e=>!("isConnected"in e)||e.isConnected,n=(()=>{let e;return(...t)=>{e&&clearTimeout(e),e=setTimeout((()=>{e=0,(e=>{for(let t of e.keys())e.set(t,e.get(t).filter(s))})(...t)}),2e3)}})(),o=e=>"function"==typeof e?e():e,r=(e,t)=>{const s=e.indexOf(t);s>=0&&(e[s]=e[e.length-1],e.length--)},c=(s,c)=>{const a=((e,t=(e,t)=>e!==t)=>{const s=o(e);let n=new Map(Object.entries(s??{}));const c={dispose:[],get:[],set:[],reset:[]},a=new Map,i=()=>{n=new Map(Object.entries(o(e)??{})),c.reset.forEach((e=>e()))},p=e=>(c.get.forEach((t=>t(e))),n.get(e)),u=(e,s)=>{const o=n.get(e);t(s,o,e)&&(n.set(e,s),c.set.forEach((t=>t(e,s,o))))},f="undefined"==typeof Proxy?{}:new Proxy(s,{get:(e,t)=>p(t),ownKeys:()=>Array.from(n.keys()),getOwnPropertyDescriptor:()=>({enumerable:!0,configurable:!0}),has:(e,t)=>n.has(t),set:(e,t,s)=>(u(t,s),!0)}),d=(e,t)=>(c[e].push(t),()=>{r(c[e],t)});return{state:f,get:p,set:u,on:d,onChange:(t,s)=>{const n=(e,n)=>{e===t&&s(n)},r=()=>s(o(e)[t]),c=d("set",n),i=d("reset",r);return a.set(s,{setHandler:n,resetHandler:r,propName:t}),()=>{c(),i(),a.delete(s)}},use:(...e)=>{const t=e.reduce(((e,t)=>(t.set&&e.push(d("set",t.set)),t.get&&e.push(d("get",t.get)),t.reset&&e.push(d("reset",t.reset)),t.dispose&&e.push(d("dispose",t.dispose)),e)),[]);return()=>t.forEach((e=>e()))},dispose:()=>{c.dispose.forEach((e=>e())),i()},reset:i,forceUpdate:e=>{const t=n.get(e);c.set.forEach((s=>s(e,t,t)))},removeListener:(e,t)=>{const s=a.get(t);s&&s.propName===e&&(r(c.set,s.setHandler),r(c.reset,s.resetHandler),a.delete(t))}}})(s,c);return a.use((()=>{if("function"!=typeof e)return{};const s=new Map;return{dispose:()=>s.clear(),get:t=>{const n=e();n&&((e,t,s)=>{const n=e.get(t);n?n.includes(s)||n.push(s):e.set(t,[s])})(s,t,n)},set:e=>{const o=s.get(e);o&&s.set(e,o.filter(t)),n(s)},reset:()=>{s.forEach((e=>e.forEach(t))),n(s)}}})()),a};export{c}