"use strict";const t=new WeakMap,e={window:window,document:document};function n(t){return null!=t&&"Object"===t.constructor.name}function r(e,o){return new Proxy(null!=o?o:e,{get:(t,o)=>n(t[o])?r(e,t[o]):t[o],set(o,s,i){if(o[s]!==i){const u=n(i)?r(e,i):i;o[s]=u,t.set(e,!0)}return!0}})}function o(t){return n(t)?new Proxy(t,{get:(t,e)=>o(t[e]),set(){throw new Error("Snapshot is immutable.")},deleteProperty(){throw new Error("Snapshot is immutable.")},setPrototypeOf(){throw new Error("Snapshot is immutable.")}}):t}const s=new EventTarget,i=new WeakMap,u=new WeakMap;exports.createEvent=function(){const t=crypto.randomUUID();function e(e){s.dispatchEvent(new CustomEvent(t,{detail:e}))}return i.set(e,t),e},exports.createStore=function(c={}){const a=crypto.randomUUID(),f=function(t){if(!n(t))throw new Error("Initial store value should be an object. \n\t\t\t You can store non-serializable values as $store property.");return t}(c);u.set(f,a);const l=r(f),w=o(f);let p=!1,d=[];return{get:()=>w,on:(n,r)=>{function o(e){let n=p;if(n||(p=!0),r(l,e),!n){p=!1;t.get(f)&&(t.set(f,!1),function(){for(let t=0;to(t.detail)))}else if(function(t){return"string"==typeof t}(n)){const{target:t,event:r}=function(t){const[e,n]=t.split(":");if(function(t){return"document"===t||"window"===t}(e))return{target:e,event:n};throw new Error("Invalid browser event.")}(n);e[t].addEventListener(r,o)}},track:t=>(d.push(t),()=>{d=d.filter((e=>e!==t))})}};