class LiveData{static version="1.0.1";constructor(t,e=!1){this._valueIsInitialized=void 0!==t,this._value=t,this._nullSafe=e,this._arrOfFn=[],this._arrOfDebouncedFn=[],this._arrOfThrottledFn=[]}static make(t,e=!1){return new this(t,e)}isInitialized(){return this._valueIsInitialized}async notify(){!this._value&&this._nullSafe||this._arrOfFn.forEach((t=>{t(this._value)}))}async notifyDebounce(){!this._value&&this._nullSafe||this._arrOfDebouncedFn.forEach((t=>{t(this._value)}))}async notifyThrottle(){!this._value&&this._nullSafe||this._arrOfThrottledFn.forEach((t=>{t(this._value)}))}async postValue(t){this._value=t,this.notify(),this.notifyDebounce(),this.notifyThrottle(),this._valueIsInitialized=!0}mutateValue(t){return this.postValue(t(this._value)),this}getValue(){return this._value}set value(t){this.postValue(t)}get value(){return this._value}observe(t){this._arrOfFn.push((async e=>{t(e)})),this._valueIsInitialized}observeDebounce(t,e=500){this._arrOfDebouncedFn.push(this._debounce((async e=>{t(e)}),e)),this._valueIsInitialized&&this._debounce((async e=>{t(e)}),e)}observeThrottle(t,e=500){this._arrOfThrottledFn.push(this._throttle((async e=>{t(e)}),e)),this._valueIsInitialized&&this._throttle((async e=>{t(e)}),e)}_debounce(t,e=500){let s;return async function(){const i=this,a=arguments;clearTimeout(s),s=setTimeout((function(){t.apply(i,a)}),e)}}_throttle(t,e=500){let s=!1;return async function(){if(s)return;const i=arguments;t.apply(this,i),s=!0,setTimeout((()=>{s=!1}),e)}}}class ValidatorMap extends Map{constructor(){super()}set(t,e){return e?super.set(t,!0):super.set(t,!1),this}isValid(){return 0!==this.size&&!Array.from(this.values()).includes(!1)}}class LiveValidator extends Map{constructor(t){super(),this._arrOfFn=[],t&&Array.isArray(t)&&t.forEach((t=>this.set(t,!1)))}async notify(){this._arrOfFn.forEach((t=>{t(this.isValid(),this)}))}keys(){return super.keys()}set(t,e){return super.set(t,!!e),this.notify(),this}get(t){return super.get(t)}observe(t){this._arrOfFn.push((async(e,s)=>{t(e,s)}))}isValid(){return 0!==this.size&&!Array.from(this.values()).includes(!1)}}"undefined"!=typeof exports&&(module.exports={LiveData:LiveData,ValidatorMap:ValidatorMap,LiveValidator:LiveValidator});