mutts 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/chunks/{decorator-BXsign4Z.js → decorator-8qjFb7dw.js} +2 -2
  2. package/dist/chunks/decorator-8qjFb7dw.js.map +1 -0
  3. package/dist/chunks/{decorator-CPbZNnsX.esm.js → decorator-AbRkXM5O.esm.js} +2 -2
  4. package/dist/chunks/decorator-AbRkXM5O.esm.js.map +1 -0
  5. package/dist/decorator.d.ts +1 -1
  6. package/dist/decorator.esm.js +1 -1
  7. package/dist/decorator.js +1 -1
  8. package/dist/destroyable.esm.js +1 -1
  9. package/dist/destroyable.js +1 -1
  10. package/dist/index.d.ts +1 -1
  11. package/dist/index.esm.js +2 -2
  12. package/dist/index.js +2 -1
  13. package/dist/index.js.map +1 -1
  14. package/dist/mutts.umd.js +1 -1
  15. package/dist/mutts.umd.js.map +1 -1
  16. package/dist/mutts.umd.min.js +1 -1
  17. package/dist/mutts.umd.min.js.map +1 -1
  18. package/dist/reactive.d.ts +4 -3
  19. package/dist/reactive.esm.js +61 -57
  20. package/dist/reactive.esm.js.map +1 -1
  21. package/dist/reactive.js +61 -56
  22. package/dist/reactive.js.map +1 -1
  23. package/dist/std-decorators.esm.js +1 -1
  24. package/dist/std-decorators.js +1 -1
  25. package/docs/reactive.md +616 -0
  26. package/package.json +1 -2
  27. package/dist/chunks/decorator-BXsign4Z.js.map +0 -1
  28. package/dist/chunks/decorator-CPbZNnsX.esm.js.map +0 -1
  29. package/src/decorator.test.ts +0 -495
  30. package/src/decorator.ts +0 -205
  31. package/src/destroyable.test.ts +0 -155
  32. package/src/destroyable.ts +0 -158
  33. package/src/eventful.test.ts +0 -380
  34. package/src/eventful.ts +0 -69
  35. package/src/index.ts +0 -7
  36. package/src/indexable.test.ts +0 -388
  37. package/src/indexable.ts +0 -124
  38. package/src/promiseChain.test.ts +0 -201
  39. package/src/promiseChain.ts +0 -99
  40. package/src/reactive/array.test.ts +0 -923
  41. package/src/reactive/array.ts +0 -352
  42. package/src/reactive/core.test.ts +0 -1663
  43. package/src/reactive/core.ts +0 -866
  44. package/src/reactive/index.ts +0 -28
  45. package/src/reactive/interface.test.ts +0 -1477
  46. package/src/reactive/interface.ts +0 -231
  47. package/src/reactive/map.test.ts +0 -866
  48. package/src/reactive/map.ts +0 -162
  49. package/src/reactive/set.test.ts +0 -289
  50. package/src/reactive/set.ts +0 -142
  51. package/src/std-decorators.test.ts +0 -679
  52. package/src/std-decorators.ts +0 -182
  53. package/src/utils.ts +0 -52
@@ -1,2 +1,2 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Mutts={})}(this,function(t){"use strict";const e=new Set([Object,Array,Date,Function,Set,Map,WeakMap,WeakSet,Promise,Error,TypeError,ReferenceError,SyntaxError,RangeError,URIError,EvalError,Reflect,Proxy,RegExp,String,Number,Boolean]);function n(t){return t&&(e.has(t)||t.toString().startsWith("class "))}function r(t,e){return Object.defineProperties(t,{name:{value:e}})}class o extends Error{constructor(t){super(t),this.name="DecoratorException"}}function s(t){return function(e,r,o,...s){if(void 0===r){if(n(e)){if(!("class"in t))throw new Error("Decorator cannot be applied to a class");return t.class?.(e)}}else if("object"==typeof e&&["string","symbol"].includes(typeof r)){if(!o)throw new Error("Decorator cannot be applied to a field");if("object"==typeof o&&"configurable"in o){if("get"in o||"set"in o){if(!("getter"in t)&&!("setter"in t))throw new Error("Decorator cannot be applied to a getter or setter");if("getter"in t){const e=t.getter?.(o.get,r);e&&(o.get=e)}if("setter"in t){const e=t.setter?.(o.set,r);e&&(o.set=e)}return o}if("function"==typeof o.value){if(!("method"in t))throw new Error("Decorator cannot be applied to a method");const e=t.method?.(o.value,r);return e&&(o.value=e),o}}}if(!("default"in t))throw new Error("Decorator do not have a default implementation");return t.default.call(this,e,r,o,...s)}}function i(t){return function(e,n,...r){if(!n?.kind||"string"!=typeof n.kind){if(!("default"in t))throw new Error("Decorator do not have a default implementation");return t.default.call(this,e,n,...r)}switch(n.kind){case"class":if(!("class"in t))throw new Error("Decorator cannot be applied to a class");return t.class?.(e);case"field":throw new Error("Decorator cannot be applied to a field");case"getter":if(!("getter"in t))throw new Error("Decorator cannot be applied to a getter");return t.getter?.(e,n.name);case"setter":if(!("setter"in t))throw new Error("Decorator cannot be applied to a setter");return t.setter?.(e,n.name);case"method":if(!("method"in t))throw new Error("Decorator cannot be applied to a method");return t.method?.(e,n.name);case"accessor":{if(!("getter"in t)&&!("setter"in t))throw new Error("Decorator cannot be applied to a getter or setter");const r={};if("getter"in t){const o=t.getter?.(e.get,n.name);o&&(r.get=o)}if("setter"in t){const o=t.setter?.(e.set,n.name);o&&(r.set=o)}return r}}}}const c=t=>(e,n,...r)=>{const o=function(t,e){return"object"==typeof e&&null!==e&&"string"==typeof e.kind?"modern":"legacy"}(0,n,r[0]);return"modern"===o?i(t)(e,n,...r):s(t)(e,n,...r)},a=new FinalizationRegistry(t=>t()),h=Symbol("destructor"),l=Symbol("allocated");class u extends Error{static throw(t){return()=>{throw new u(t)}}constructor(t){super(`Object is destroyed. ${t}`),this.name="DestroyedAccessError"}}const f={[Symbol.toStringTag]:"MutTs Destroyable",get:u.throw("Cannot access destroyed object"),set:u.throw("Cannot access destroyed object")};const d=c({setter:(t,e)=>function(n){return this[l][e]=n,t.call(this,n)}});function p(t,e,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(t):r?r.value:e.get(t)}var y,g;"function"==typeof SuppressedError&&SuppressedError;y=new WeakMap,g=new WeakMap;const b=Symbol("getAt"),m=Symbol("setAt");function w(t,e){t&&"function"!=typeof t&&(e=t,t=void 0),t||(t=class{}),e||(e={get(t){if("function"!=typeof this[b])throw new Error("Indexable class must have an [getAt] method");return this[b](t)},set(t,e){if("function"!=typeof this[m])throw new Error("Indexable class has read-only numeric index access");this[m](t,e)}});class n extends t{}return Object.setPrototypeOf(n.prototype,new Proxy(t.prototype,{[Symbol.toStringTag]:"MutTs Indexable",get(t,n,r){if(n in t){const e=Object.getOwnPropertyDescriptor(t,n)?.get;return e?e.call(r):t[n]}if("string"==typeof n){if("length"===n&&e.getLength)return e.getLength.call(r);const t=Number(n);if(!Number.isNaN(t))return e.get.call(r,t)}},set(t,n,r,o){if(n in t){const e=Object.getOwnPropertyDescriptor(t,n)?.set;return e?e.call(o,r):t[n]=r,!0}if("string"==typeof n){if("length"===n&&e.setLength)return e.setLength.call(o,r),!0;const t=Number(n);if(!Number.isNaN(t)){if(!e.set)throw new Error("Indexable class has read-only numeric index access");return e.set.call(o,t,r),!0}}return Object.defineProperty(o,n,{value:r,writable:!0,enumerable:!0,configurable:!0}),!0}})),n}const v=new WeakMap,S=new WeakMap,j=new WeakMap,x=new WeakMap,O=new WeakSet,E=new WeakMap,k=new WeakMap,M=new WeakSet;function*D(t){let e=t.next();for(;!e.done;)yield at(e.value),e=t.next()}function*W(t){let e=t.next();for(;!e.done;){const[n,r]=e.value;yield[at(n),at(r)],e=t.next()}}const P=new WeakMap,R={objectToProxy:S,proxyToObject:j,effectToReactiveObjects:v,watchers:P,objectParents:x,objectsWithDeepWatchers:O,deepWatchers:E,effectToDeepWatchedObjects:k,nonReactiveObjects:M},T=Symbol("native-reactive"),z=Symbol("non-reactive"),A=Symbol("unreactive-properties"),N=Symbol("prototype-forwarding"),C=Symbol("all-props"),I=Symbol("root-function");function $(t,e){return Object.defineProperty(t,I,{value:L(e),writable:!1})}function L(t){return t?.[I]||t}class F extends Error{constructor(t){super(t),this.name="ReactiveError"}}const B={enter:t=>{},leave:t=>{},chain:(t,e)=>{},maxEffectChain:100,maxDeepWatchDepth:100,instanceMembers:!0,warn:(...t)=>{}};function K(t,...e){for(const n of e)for(const e of n){const n=t.get(e);if(n)for(const t of Array.from(n))Y(t)}}function U(t,e,n){G(t,e,[n])}function G(t,e,n){!function(t,e){t=ht(t);const n={},r=q(t);r&&Object.assign(r,{evolution:e,next:n});V.set(t,n)}(t=ht(t),e);const r=P.get(t);r&&(n?K(r,[C],n):K(r,r.keys())),O.has(t)&&rt(t)}const V=new WeakMap;function q(t){t=ht(t);let e=V.get(t);return e||(e={},V.set(t,e)),e}function H(t,e=C){if(t=ht(t),J&&("symbol"!=typeof e||e===C)){let n=P.get(t);n||(n=new Map,P.set(t,n));let r=n.get(e);r||(r=new Set,n.set(e,r)),r.add(J);let o=v.get(J);o||(o=new Set,v.set(J,o)),o.add(t)}}let J,Q,X;function Y(t){const e=L(t);if(B?.chain(L(t),L(J)),X)X.set(e,t);else{const n=[];X=new Map([[e,t]]);try{for(;X.size;){if(n.length>B.maxEffectChain)throw new F("[reactive] Max effect chain reached");const[t,e]=X.entries().next().value;n.push(t),e(),X.delete(t)}}finally{X=void 0}}}function Z(t,e,n){if(L(t)===L(J))return e();const r=J,o=Q;J=t,n||(Q=t);try{return e()}finally{J=r,Q=o}}function _(t,e,n){let r=x.get(t);r||(r=new Set,x.set(t,r)),r.add({parent:e,prop:n})}function tt(t,e,n){const r=x.get(t);r&&(r.delete({parent:e,prop:n}),0===r.size&&x.delete(t))}function et(t){return O.has(t)||nt(t)}function nt(t){const e=x.get(t);if(!e)return!1;for(const{parent:t}of e){if(O.has(t))return!0;if(nt(t))return!0}return!1}function rt(t,e){const n=x.get(t);if(n)for(const{parent:t}of n){const e=E.get(t);if(e)for(const t of e)Y(t);rt(t)}}const ot={[Symbol.toStringTag]:"MutTs Reactive",get(t,e,n){if(e===z)return!1;if(t[A]?.has(e)||"symbol"==typeof e)return Reflect.get(t,e,n);const r=!(e in t);(!B.instanceMembers||Object.hasOwn(n,e)||r)&&H(t,e);const o=Reflect.get(t,e,n);if("object"==typeof o&&null!==o){const n=at(o);return et(t)&&_(n,t,e),n}return o},set(t,e,n,r){if(t[A]?.has(e))return Reflect.set(t,e,n,r);const o=N in t&&t[N]instanceof Array&&(!Number.isNaN(Number(e))||"length"===e),s=ht(n);if(o)return t[e]=s,!0;const i=t[e],c=e in t;return function(t,e,n,r){O.has(t)&&("object"==typeof n&&null!==n&&tt(n,t,e),"object"==typeof r&&null!==r)&&_(at(r),t,e)}(t,e,i,s),i!==s&&(Reflect.set(t,e,s,r),U(t,{type:c?"set":"add",prop:e},e)),!0},deleteProperty(t,e){if(!Object.hasOwn(t,e))return!1;const n=t[e];return O.has(t)&&"object"==typeof n&&null!==n&&tt(n,t,e),delete t[e],U(t,{type:"del",prop:e},e),O.has(t)&&rt(t),!0},getPrototypeOf:t=>N in t?t[N]:Object.getPrototypeOf(t),setPrototypeOf:(t,e)=>!(N in t)&&(Object.setPrototypeOf(t,e),!0),ownKeys:t=>(H(t,C),Reflect.ownKeys(t))},st=new WeakSet;class it{constructor(){return st.has(new.target)?at(this):this}}function ct(t){if(!t||"object"!=typeof t)return t;const e=t;if(j.has(e)||yt(e))return e;if(S.has(e))return S.get(e);const n=!(T in e)||e instanceof e[T]?e:new e[T](e);n!==e&&j.set(n,e);const r=new Proxy(n,ot);return S.set(e,r),j.set(r,e),r}const at=c({class(t){if(t.prototype instanceof it)return st.add(t),t;class e extends t{constructor(...n){return super(...n),new.target===e||st.has(new.target)||B.warn(`${t.name} has been inherited by ${this.constructor.name} that is not reactive.\n@reactive decorator must be applied to the leaf class OR classes have to extend ReactiveBase.`),at(this)}}return Object.defineProperty(e,"name",{value:`Reactive<${t.name}>`}),e},get:t=>ct(t),default:ct});function ht(t){return j.get(t)??t}function lt(t){Z(void 0,t,!0)}const ut=new WeakMap,ft=new FinalizationRegistry(t=>t());function dt(t,...e){let n=null;const r=$(t=>Z(s,t),t);let o=!1;function s(){n?.(),B.enter(t);const i=Z(o?void 0:s,()=>t(r,...e));B.leave(t),n=()=>{n=null,i?.();const t=v.get(s);if(t){for(const e of t){const t=P.get(e);if(t){for(const[e,n]of t.entries())n.delete(s),0===n.size&&t.delete(e);0===t.size&&P.delete(e)}}v.delete(s)}}}if($(s,t),X){const e=X;try{X=new Map([[t,s]]),s(),X.delete(t);for(const[t,n]of X)e.set(t,n)}finally{X=e}}else Y(s);const i=()=>{if(o)return;o=!0,n?.();const t=ut.get(s);if(t){for(const e of t)e();ut.delete(s)}ft.unregister(i)};if(!Q){const t=()=>i();return ft.register(t,i,t),t}let c=ut.get(Q);c||(c=new Set,ut.set(Q,c));const a=Q,h=()=>{c.delete(h),0===c.size&&ut.delete(a),i()};return c.add(h),h}const pt=new Set;function yt(t){return null===t||"object"!=typeof t||(!!M.has(t)||(!!t[z]||!!Array.from(pt).some(e=>e(t))))}function gt(...t){for(const e of t)e&&(e.prototype[z]=!0);return t[0]}function bt(t,e){t.prototype[T]=e,gt(e)}function mt(t,e,{immediate:n=!1}={}){if(null==t)return;if("object"!=typeof t)throw new Error("Target of deep watching must be an object");const r=$(()=>e(t),e);return dt(()=>{O.add(t);let o=k.get(r);o||(o=new Set,k.set(r,o)),o.add(t);const s=new WeakSet;return function t(e,n=0){if(!(s.has(e)||!function(t){return null!==t&&"object"==typeof t}(e)||n>B.maxDeepWatchDepth||yt(e))){s.add(e),O.add(e),o.add(e);for(const r in ht(e))if(Object.hasOwn(e,r)){const o=e[r];t("object"==typeof o&&null!==o?at(o):o,n+1)}if(Array.isArray(e)||e instanceof Array){const r=e.length;for(let o=0;o<r;o++){const r=e[o];t("object"==typeof r&&null!==r?at(r):r,n+1)}}else if(e instanceof Set)for(const r of e){t("object"==typeof r&&null!==r?at(r):r,n+1)}else if(e instanceof Map)for(const[r,o]of e){t("object"==typeof o&&null!==o?at(o):o,n+1)}}}(t),n&&e(t),n=!0,()=>{const t=k.get(r);if(t){for(const e of t){const t=E.get(e);t?(t.delete(r),0===t.size&&(E.delete(e),O.delete(e))):O.delete(e)}k.delete(r)}}})}let wt;gt(Date,RegExp,Error,Promise,Function),"undefined"!=typeof window&&function(...t){for(const e of t){try{Object.defineProperty(e,z,{value:!0,writable:!1,enumerable:!1,configurable:!1})}catch{}z in e||M.add(e)}t[0]}(window,document),"undefined"!=typeof Element&&gt(Element,Node);const vt=new WeakMap;function St(t){const e=L(t);let n=[];return H(vt,e),vt.has(e)||Z(void 0,()=>{const r=dt($(o=>{const s=wt;if(vt.has(e)){for(const t of n)t();n=[],vt.delete(e),U(vt,{type:"set",prop:e},e),r()}else try{wt=n,vt.set(e,t(o))}finally{wt=s}},t))}),vt.get(e)}const jt=c({getter(t,e){const n=new WeakMap;return function(){return n.has(this)||n.set(this,r(()=>t.call(this),`${String(this.constructor.name)}.${String(e)}`)),St(n.get(this))}},default:t=>St(t)}),xt=Symbol("unset-yet");function Ot(t){if(yt(t=ht(t)))return t;try{Object.defineProperty(t,z,{value:!0,writable:!1,enumerable:!1,configurable:!0})}catch{}z in t||M.add(t);for(const e in t)Ot(t[e]);return t}const Et=c({class(t){gt(t)},default:function(t,...e){return"object"==typeof t?Ot(t):n=>{n.prototype[A]=new Set(n.prototype[A]||[]),n.prototype[A].add(t);for(const t of e)n.prototype[A].add(t);return n}}});Object.assign(R,{computedCache:vt});const kt=Symbol("native"),Mt=Array.isArray;Array.isArray=t=>Mt(t)||t instanceof Array&&kt in t;class Dt{}function*Wt(t,{length:e=!0}={}){yield t,e&&(yield"length")}function*Pt(t,e,{length:n=!1}={}){const r=Math.min(t,e),o=Math.max(t,e);for(let t=r;t<=o;t++)yield t;n&&(yield"length")}class Rt extends(w(Dt,{get(t){return H(this[kt],t),at(this[kt][t])},set(t,e){const n=t>=this[kt].length;this[kt][t]=e,G(this[kt],{type:"bunch",method:"set"},Wt(t,{length:n}))},getLength(){return H(this[kt],"length"),this[kt].length},setLength(t){const e=this[kt].length;try{this[kt].length=t}finally{G(this[kt],{type:"set",prop:"length"},Pt(e,t,{length:!0}))}}})){constructor(t){super(),Object.defineProperties(this,{[kt]:{value:t},[N]:{value:t}})}at(t){const e=t<0?this[kt].length+t:t;if(H(this,e),!(e<0||e>=this[kt].length))return at(this[kt][e])}push(...t){const e=this[kt].length;try{return this[kt].push(...t)}finally{G(this,{type:"bunch",method:"push"},Pt(e,e+t.length-1,{length:!0}))}}pop(){if(0!==this[kt].length)try{return at(this[kt].pop())}finally{G(this,{type:"bunch",method:"pop"},Wt(this[kt].length))}}shift(){if(0!==this[kt].length)try{return at(this[kt].shift())}finally{G(this,{type:"bunch",method:"shift"},Pt(0,this[kt].length+1,{length:!0}))}}unshift(...t){try{return this[kt].unshift(...t)}finally{G(this,{type:"bunch",method:"unshift"},Pt(0,this[kt].length-t.length,{length:!0}))}}splice(t,e,...n){const r=this[kt].length;void 0===e&&(e=r-t);try{return at(void 0===e?this[kt].splice(t):this[kt].splice(t,e,...n))}finally{G(this,{type:"bunch",method:"splice"},e===n.length?Pt(t,t+e):Pt(t,r+Math.max(n.length-e,0),{length:!0}))}}reverse(){try{return this[kt].reverse()}finally{G(this,{type:"bunch",method:"reverse"},Pt(0,this[kt].length-1))}}sort(t){try{return this[kt].sort(t)}finally{G(this,{type:"bunch",method:"sort"},Pt(0,this[kt].length-1))}}fill(t,e,n){try{return void 0===e?this[kt].fill(t):void 0===n?this[kt].fill(t,e):this[kt].fill(t,e,n)}finally{G(this,{type:"bunch",method:"fill"},Pt(0,this[kt].length-1))}}copyWithin(t,e,n){try{return void 0===n?this[kt].copyWithin(t,e):this[kt].copyWithin(t,e,n)}finally{G(this,{type:"bunch",method:"copyWithin"},Pt(0,this[kt].length-1))}}toReversed(){return H(this),at(this[kt].toReversed())}toSorted(t){return H(this),at(this[kt].toSorted(t))}toSpliced(t,e,...n){return H(this),void 0===e?this[kt].toSpliced(t):this[kt].toSpliced(t,e,...n)}with(t,e){return H(this),at(this[kt].with(t,e))}entries(){return H(this),W(this[kt].entries())}keys(){return H(this),this[kt].keys()}values(){return H(this),D(this[kt].values())}[Symbol.iterator](){H(this);const t=this[kt][Symbol.iterator]();return{next(){const e=t.next();return e.done?e:{value:at(e.value),done:!1}}}}indexOf(t,e){return H(this),this[kt].indexOf(t,e)}lastIndexOf(t,e){return H(this),this[kt].lastIndexOf(t,e)}includes(t,e){return H(this),this[kt].includes(t,e)}find(t,e){return H(this),at(this[kt].find(t,e))}findIndex(t,e){return H(this),this[kt].findIndex(t,e)}flat(){return H(this),at(this[kt].flat())}flatMap(t,e){return H(this),at(this[kt].flatMap(t,e))}filter(t,e){return H(this),at(this[kt].filter(t,e))}map(t,e){return H(this),at(this[kt].map(t,e))}reduce(t,e){H(this);const n=void 0===e?this[kt].reduce(t):this[kt].reduce(t,e);return at(n)}reduceRight(t,e){H(this);const n=void 0!==e?this[kt].reduceRight(t,e):this[kt].reduceRight(t);return at(n)}slice(t,e){for(const n of Pt(t||0,e||this[kt].length-1))H(this,n);return void 0===t?this[kt].slice():void 0===e?this[kt].slice(t):this[kt].slice(t,e)}concat(...t){return H(this),at(this[kt].concat(...t))}join(t){return H(this),this[kt].join(t)}forEach(t,e){H(this),this[kt].forEach(t,e)}every(t,e){return H(this),this[kt].every(t,e)}some(t,e){return H(this),this[kt].some(t,e)}}const Tt=Symbol("native");class zt{constructor(t){Object.defineProperties(this,{[Tt]:{value:t},[N]:{value:t},content:{value:Symbol("content")},[Symbol.toStringTag]:{value:"ReactiveMap"}})}get size(){return H(this,"size"),this[Tt].size}clear(){const t=this[Tt].size>0;if(this[Tt].clear(),t){const t={type:"bunch",method:"clear"};U(this,t,"size"),G(this.content,t)}}entries(){return H(this.content),W(this[Tt].entries())}forEach(t,e){H(this.content),this[Tt].forEach(t,e)}keys(){return H(this.content),this[Tt].keys()}values(){return H(this.content),D(this[Tt].values())}[Symbol.iterator](){H(this.content);const t=this[Tt][Symbol.iterator]();return{next(){const e=t.next();return e.done?e:{value:[e.value[0],at(e.value[1])],done:!1}}}}delete(t){const e=this[Tt].has(t),n=this[Tt].delete(t);if(e){const e={type:"del",prop:t};U(this.content,e,t),U(this,e,"size")}return n}get(t){return H(this.content,t),at(this[Tt].get(t))}has(t){return H(this.content,t),this[Tt].has(t)}set(t,e){const n=this[Tt].has(t),r=this[Tt].get(t),o=at(e);if(this[Tt].set(t,o),!n||r!==o){const e={type:n?"set":"add",prop:t};U(this.content,e,t),U(this,e,"size")}return this}}const At=Symbol("native");class Nt{constructor(t){Object.defineProperties(this,{[At]:{value:t},[N]:{value:t},content:{value:Symbol("content")},[Symbol.toStringTag]:{value:"ReactiveSet"}})}get size(){return H(this,"size"),this[At].size}add(t){const e=this[At].has(t),n=at(t);if(this[At].add(n),!e){const t={type:"add",prop:n};U(this.content,t,n),U(this,t,"size")}return this}clear(){const t=this[At].size>0;if(this[At].clear(),t){const t={type:"bunch",method:"clear"};U(this,t,"size"),G(this.content,t)}}delete(t){const e=this[At].has(t),n=this[At].delete(t);if(e){const e={type:"del",prop:t};U(this.content,e,t),U(this,e,"size")}return n}has(t){return H(this.content,t),this[At].has(t)}entries(){return H(this.content),W(this[At].entries())}forEach(t,e){H(this.content),this[At].forEach(t,e)}keys(){return H(this.content),D(this[At].keys())}values(){return H(this.content),D(this[At].values())}[Symbol.iterator](){H(this.content);const t=this[At][Symbol.iterator]();return{next(){const e=t.next();return e.done?e:{value:at(e.value),done:!1}}}}}bt(WeakMap,class{constructor(t){Object.defineProperties(this,{[Tt]:{value:t},[N]:{value:t},content:{value:Symbol("content")},[Symbol.toStringTag]:{value:"ReactiveWeakMap"}})}delete(t){const e=this[Tt].has(t),n=this[Tt].delete(t);return e&&U(this.content,{type:"del",prop:t},t),n}get(t){return H(this.content,t),at(this[Tt].get(t))}has(t){return H(this.content,t),this[Tt].has(t)}set(t,e){return U(this.content,{type:this[Tt].has(t)?"set":"add",prop:t},t),this[Tt].set(t,e),this}}),bt(Map,zt),bt(WeakSet,class{constructor(t){Object.defineProperties(this,{[At]:{value:t},[N]:{value:t},content:{value:Symbol("content")},[Symbol.toStringTag]:{value:"ReactiveWeakSet"}})}add(t){const e=this[At].has(t);return this[At].add(t),e||U(this.content,{type:"add",prop:t},t),this}delete(t){const e=this[At].has(t),n=this[At].delete(t);return e&&U(this.content,{type:"del",prop:t},t),n}has(t){return H(this.content,t),this[At].has(t)}}),bt(Set,Nt),bt(Array,Rt);const Ct=[],It=c({getter:(t,e)=>function(){const n=Ct.findIndex(t=>t.object===this&&t.prop===e);if(n>-1)throw new Error(`Circular dependency detected: ${Ct.slice(n).map(t=>`${t.object.constructor.name}.${String(t.prop)}`).join(" -> ")} -> again`);Ct.push({object:this,prop:e});try{const n=t.call(this);return $t(this,e,n),n}finally{Ct.pop()}}});function $t(t,e,n){Object.defineProperty(t,e,{value:n})}const Lt=Object.assign(c({method:(t,e)=>function(...n){return Lt.warn(this,e),t.apply(this,n)},getter:(t,e)=>function(){return Lt.warn(this,e),t.call(this)},setter:(t,e)=>function(n){return Lt.warn(this,e),t.call(this,n)},class:t=>class extends t{constructor(...t){super(...t),Lt.warn(this,"constructor")}},default:t=>c({method:(e,n)=>function(...r){return Lt.warn(this,n,t),e.apply(this,r)},getter:(e,n)=>function(){return Lt.warn(this,n,t),e.call(this)},setter:(e,n)=>function(r){return Lt.warn(this,n,t),e.call(this,r)},class:e=>class extends e{constructor(...e){super(...e),Lt.warn(this,"constructor",t)}}})}),{warn:(t,e,n)=>{}});t.DecoratorError=o,t.Destroyable=function(t,e){var n;return t&&"function"!=typeof t&&(e=t,t=void 0),t||(t=class{}),n=class extends t{static destroy(t){const e=n.destructors.get(t);if(!e)return!1;a.unregister(t),n.destructors.delete(t),Object.setPrototypeOf(t,new Proxy({},f));for(const e of Object.getOwnPropertyNames(t))delete t[e];return e(),!0}static isDestroyable(t){return n.destructors.has(t)}constructor(...t){super(...t);const r={};this[l]=r;const o=e?.destructor??this[h];if(!o)throw new u("Destructor is not defined");function s(){o(r)}n.destructors.set(this,s),a.register(this,s,this)}},n.destructors=new WeakMap,n},t.DestructionError=u,t.Eventful=class{constructor(){y.set(this,new Map),g.set(this,[])}hook(t){return p(this,g,"f").includes(t)||p(this,g,"f").push(t),()=>{p(this,g,"f").splice(p(this,g,"f").indexOf(t),1)}}on(t,e){if("object"==typeof t)for(const e of Object.keys(t))this.on(e,t[e]);else if(void 0!==e){let n=p(this,y,"f").get(t);n||(n=[],p(this,y,"f").set(t,n)),n.push(e)}return()=>this.off(t,e)}off(t,e){if("object"==typeof t)for(const e of Object.keys(t))this.off(e,t[e]);else if(null!=e){const n=p(this,y,"f").get(t);n&&p(this,y,"f").set(t,n.filter(t=>t!==e))}else p(this,y,"f").delete(t)}emit(t,...e){const n=p(this,y,"f").get(t);if(n)for(const t of n)t.apply(this,e);for(const n of p(this,g,"f"))n.call(this,t,...e)}},t.Indexable=w,t.ReactiveBase=it,t.ReactiveError=F,t.allocated=d,t.allocatedValues=l,t.cache=$t,t.cached=It,t.callOnGC=function(t){let e=!1;const n=()=>{e||(e=!0,t())};return a.register(n,t,t),n},t.computed=jt,t.debounce=function(t){return c({method(e,n){let r=null;return function(...n){r&&clearTimeout(r),r=setTimeout(()=>{e.apply(this,n),r=null},t)}}})},t.decorator=c,t.deprecated=Lt,t.describe=function(t){return(...e)=>n=>class extends n{constructor(...n){super(...n);for(const n of e)Object.defineProperty(this,n,{...Object.getOwnPropertyDescriptor(this,n),...t})}}},t.destructor=h,t.effect=dt,t.getAt=b,t.getState=q,t.immutables=pt,t.invalidateComputed=function(t,e=!0){wt?wt.push(t):e&&B.warn("Using `invalidateComputed` outside of a computed property")},t.isCached=function(t,e){return!!Object.getOwnPropertyDescriptor(t,e)},t.isConstructor=n,t.isNonReactive=yt,t.isReactive=function(t){return j.has(t)},t.legacyDecorator=s,t.modernDecorator=i,t.profileInfo=R,t.reactive=at,t.reactiveOptions=B,t.renamed=r,t.setAt=m,t.throttle=function(t){return c({method(e,n){let r=0,o=null;return function(...n){const s=Date.now();if(s-r>=t)return o&&(clearTimeout(o),o=null),r=s,e.apply(this,n);if(!o){const i=t-(s-r),c=[...n];o=setTimeout(()=>{r=Date.now(),e.apply(this,c),o=null},i)}}}})},t.unreactive=Et,t.untracked=lt,t.unwrap=ht,t.watch=function(t,e,n={}){return"function"==typeof t?function(t,e,{immediate:n=!1,deep:r=!1}={}){let o,s=xt;const i=dt($(i=>{const c=t(i);s!==c&&lt($(()=>{s===xt?n&&e(c):e(c,s),s=c,r&&(o&&o(),o=mt(c,$(t=>e(t,t),e)))},e))},t));return()=>{i(),o&&o()}}(t,e,n):"object"==typeof t?function(t,e,{immediate:n=!1,deep:r=!1}={}){return r?mt(t,e,{immediate:n}):dt($(()=>{H(t),n&&lt(()=>e(t)),n=!0},e))}(t,e,n):(()=>{throw new Error("watch: value must be a function or an object")})()},t.zip=function(...t){if(!t.length)return[];const e=Math.min(...t.map(t=>t.length)),n=[];for(let r=0;r<e;r++){const e=t.map(t=>t[r]);n.push(e)}return n}});
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Mutts={})}(this,function(t){"use strict";const e=new Set([Object,Array,Date,Function,Set,Map,WeakMap,WeakSet,Promise,Error,TypeError,ReferenceError,SyntaxError,RangeError,URIError,EvalError,Reflect,Proxy,RegExp,String,Number,Boolean]);function n(t){return t&&(e.has(t)||t.toString?.().startsWith("class "))}function r(t,e){return Object.defineProperties(t,{name:{value:e}})}class o extends Error{constructor(t){super(t),this.name="DecoratorException"}}function s(t){return function(e,r,o,...s){if(void 0===r){if(n(e)){if(!("class"in t))throw new Error("Decorator cannot be applied to a class");return t.class?.(e)}}else if("object"==typeof e&&["string","symbol"].includes(typeof r)){if(!o)throw new Error("Decorator cannot be applied to a field");if("object"==typeof o&&"configurable"in o){if("get"in o||"set"in o){if(!("getter"in t)&&!("setter"in t))throw new Error("Decorator cannot be applied to a getter or setter");if("getter"in t){const e=t.getter?.(o.get,r);e&&(o.get=e)}if("setter"in t){const e=t.setter?.(o.set,r);e&&(o.set=e)}return o}if("function"==typeof o.value){if(!("method"in t))throw new Error("Decorator cannot be applied to a method");const e=t.method?.(o.value,r);return e&&(o.value=e),o}}}if(!("default"in t))throw new Error("Decorator do not have a default implementation");return t.default.call(this,e,r,o,...s)}}function i(t){return function(e,n,...r){if(!n?.kind||"string"!=typeof n.kind){if(!("default"in t))throw new Error("Decorator do not have a default implementation");return t.default.call(this,e,n,...r)}switch(n.kind){case"class":if(!("class"in t))throw new Error("Decorator cannot be applied to a class");return t.class?.(e);case"field":throw new Error("Decorator cannot be applied to a field");case"getter":if(!("getter"in t))throw new Error("Decorator cannot be applied to a getter");return t.getter?.(e,n.name);case"setter":if(!("setter"in t))throw new Error("Decorator cannot be applied to a setter");return t.setter?.(e,n.name);case"method":if(!("method"in t))throw new Error("Decorator cannot be applied to a method");return t.method?.(e,n.name);case"accessor":{if(!("getter"in t)&&!("setter"in t))throw new Error("Decorator cannot be applied to a getter or setter");const r={};if("getter"in t){const o=t.getter?.(e.get,n.name);o&&(r.get=o)}if("setter"in t){const o=t.setter?.(e.set,n.name);o&&(r.set=o)}return r}}}}const c=t=>(e,n,...r)=>{const o=function(t,e){return"object"==typeof e&&null!==e&&"string"==typeof e.kind?"modern":"legacy"}(0,n,r[0]);return"modern"===o?i(t)(e,n,...r):s(t)(e,n,...r)},a=new FinalizationRegistry(t=>t()),l=Symbol("destructor"),h=Symbol("allocated");class u extends Error{static throw(t){return()=>{throw new u(t)}}constructor(t){super(`Object is destroyed. ${t}`),this.name="DestroyedAccessError"}}const f={[Symbol.toStringTag]:"MutTs Destroyable",get:u.throw("Cannot access destroyed object"),set:u.throw("Cannot access destroyed object")};const d=c({setter:(t,e)=>function(n){return this[h][e]=n,t.call(this,n)}});function p(t,e,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(t):r?r.value:e.get(t)}var y,g;"function"==typeof SuppressedError&&SuppressedError;y=new WeakMap,g=new WeakMap;const b=Symbol("getAt"),m=Symbol("setAt");function w(t,e){t&&"function"!=typeof t&&(e=t,t=void 0),t||(t=class{}),e||(e={get(t){if("function"!=typeof this[b])throw new Error("Indexable class must have an [getAt] method");return this[b](t)},set(t,e){if("function"!=typeof this[m])throw new Error("Indexable class has read-only numeric index access");this[m](t,e)}});class n extends t{}return Object.setPrototypeOf(n.prototype,new Proxy(t.prototype,{[Symbol.toStringTag]:"MutTs Indexable",get(t,n,r){if(n in t){const e=Object.getOwnPropertyDescriptor(t,n)?.get;return e?e.call(r):t[n]}if("string"==typeof n){if("length"===n&&e.getLength)return e.getLength.call(r);const t=Number(n);if(!Number.isNaN(t))return e.get.call(r,t)}},set(t,n,r,o){if(n in t){const e=Object.getOwnPropertyDescriptor(t,n)?.set;return e?e.call(o,r):t[n]=r,!0}if("string"==typeof n){if("length"===n&&e.setLength)return e.setLength.call(o,r),!0;const t=Number(n);if(!Number.isNaN(t)){if(!e.set)throw new Error("Indexable class has read-only numeric index access");return e.set.call(o,t,r),!0}}return Object.defineProperty(o,n,{value:r,writable:!0,enumerable:!0,configurable:!0}),!0}})),n}const v=new WeakMap,S=new WeakMap,j=new WeakMap,x=new WeakMap,O=new WeakSet,E=new WeakMap,k=new WeakMap,M=new WeakSet,D=Symbol("absent");function*R(t){let e=t.next();for(;!e.done;)yield ht(e.value),e=t.next()}function*W(t){let e=t.next();for(;!e.done;){const[n,r]=e.value;yield[ht(n),ht(r)],e=t.next()}}const P=new WeakMap,T={objectToProxy:S,proxyToObject:j,effectToReactiveObjects:v,watchers:P,objectParents:x,objectsWithDeepWatchers:O,deepWatchers:E,effectToDeepWatchedObjects:k,nonReactiveObjects:M},z=Symbol("native-reactive"),A=Symbol("non-reactive"),N=Symbol("unreactive-properties"),C=Symbol("prototype-forwarding"),I=Symbol("all-props"),$=Symbol("root-function");function L(t,e){return Object.defineProperty(t,$,{value:F(e),writable:!1})}function F(t){return t?.[$]||t}class B extends Error{constructor(t){super(t),this.name="ReactiveError"}}const K={enter:t=>{},leave:t=>{},chain:(t,e)=>{},maxEffectChain:100,maxDeepWatchDepth:100,instanceMembers:!0,warn:(...t)=>{}};function U(t,...e){for(const n of e)for(const e of n){const n=t.get(e);if(n)for(const t of Array.from(n))Z(t)}}function G(t,e,n){V(t,e,[n])}function V(t,e,n){!function(t,e){t=ut(t);const n={},r=H(t);r&&Object.assign(r,{evolution:e,next:n});q.set(t,n)}(t=ut(t),e);const r=P.get(t);r&&(n?U(r,[I],n):U(r,r.keys())),O.has(t)&&st(t)}const q=new WeakMap;function H(t){t=ut(t);let e=q.get(t);return e||(e={},q.set(t,e)),e}function J(t,e=I){if(t=ut(t),Q&&("symbol"!=typeof e||e===I)){let n=P.get(t);n||(n=new Map,P.set(t,n));let r=n.get(e);r||(r=new Set,n.set(e,r)),r.add(Q);let o=v.get(Q);o||(o=new Set,v.set(Q,o)),o.add(t)}}let Q,X,Y;function Z(t,e){const n=F(t);if(K?.chain(F(t),F(Q)),Y){if(Y.set(n,t),e)try{return t()}finally{Y.delete(n)}}else{const e=[];Y=new Map([[n,t]]);const r={};try{for(;Y.size;){if(e.length>K.maxEffectChain)throw new B("[reactive] Max effect chain reached");const[t,n]=Y.entries().next().value;e.push(t);const o=n();"value"in r||(r.value=o),Y.delete(t)}return r.value}finally{Y=void 0}}}const _=c({method:t=>function(...e){return Z(L(()=>t.apply(this,e),t),"immediate")},default:t=>function(...e){return Z(L(()=>t.apply(this,e),t),"immediate")}});function tt(t,e,n){if(F(t)===F(Q))return e();const r=Q,o=X;Q=t,n||(X=t);try{return e()}finally{Q=r,X=o}}function et(t,e,n){let r=x.get(t);r||(r=new Set,x.set(t,r)),r.add({parent:e,prop:n})}function nt(t,e,n){const r=x.get(t);r&&(r.delete({parent:e,prop:n}),0===r.size&&x.delete(t))}function rt(t){return O.has(t)||ot(t)}function ot(t){const e=x.get(t);if(!e)return!1;for(const{parent:t}of e){if(O.has(t))return!0;if(ot(t))return!0}return!1}function st(t,e){const n=x.get(t);if(n)for(const{parent:t}of n){const e=E.get(t);if(e)for(const t of e)Z(t);st(t)}}const it={[Symbol.toStringTag]:"MutTs Reactive",get(t,e,n){if(e===A)return!1;if(t[N]?.has(e)||"symbol"==typeof e)return Reflect.get(t,e,n);K.instanceMembers&&!Object.hasOwn(n,e)&&Reflect.has(n,e)||J(t,e);const r=Reflect.get(t,e,n);if("object"==typeof r&&null!==r){const n=ht(r);return rt(t)&&et(n,t,e),n}return r},set(t,e,n,r){if(t[N]?.has(e))return Reflect.set(t,e,n,r);const o=C in t&&t[C]instanceof Array&&(!Number.isNaN(Number(e))||"length"===e),s=ut(n);if(o)return t[e]=s,!0;const i=Reflect.has(r,e)?Reflect.get(t,e,r):D;return function(t,e,n,r){O.has(t)&&("object"==typeof n&&null!==n&&nt(n,t,e),"object"==typeof r&&null!==r)&&et(ht(r),t,e)}(t,e,i,s),i!==s&&(Reflect.set(t,e,s,r),G(t,{type:i!==D?"set":"add",prop:e},e)),!0},deleteProperty(t,e){if(!Object.hasOwn(t,e))return!1;const n=t[e];return O.has(t)&&"object"==typeof n&&null!==n&&nt(n,t,e),delete t[e],G(t,{type:"del",prop:e},e),O.has(t)&&st(t),!0},getPrototypeOf:t=>C in t?t[C]:Object.getPrototypeOf(t),setPrototypeOf:(t,e)=>!(C in t)&&(Object.setPrototypeOf(t,e),!0),ownKeys:t=>(J(t,I),Reflect.ownKeys(t))},ct=new WeakSet;class at{constructor(){return ct.has(new.target)?ht(this):this}}function lt(t){if(!t||"object"!=typeof t)return t;const e=t;if(j.has(e)||bt(e))return e;if(S.has(e))return S.get(e);const n=!(z in e)||e instanceof e[z]?e:new e[z](e);n!==e&&j.set(n,e);const r=new Proxy(n,it);return S.set(e,r),j.set(r,e),r}const ht=c({class(t){if(t.prototype instanceof at)return ct.add(t),t;class e extends t{constructor(...n){return super(...n),new.target===e||ct.has(new.target)||K.warn(`${t.name} has been inherited by ${this.constructor.name} that is not reactive.\n@reactive decorator must be applied to the leaf class OR classes have to extend ReactiveBase.`),ht(this)}}return Object.defineProperty(e,"name",{value:`Reactive<${t.name}>`}),e},get:t=>lt(t),default:lt});function ut(t){return j.get(t)??t}function ft(t){tt(void 0,t,!0)}const dt=new WeakMap,pt=new FinalizationRegistry(t=>t());function yt(t,...e){let n=null;const r=L(t=>tt(s,t),t);let o=!1;function s(){n?.(),K.enter(t);const i=tt(o?void 0:s,()=>t(r,...e));K.leave(t),n=()=>{n=null,i?.();const t=v.get(s);if(t){for(const e of t){const t=P.get(e);if(t){for(const[e,n]of t.entries())n.delete(s),0===n.size&&t.delete(e);0===t.size&&P.delete(e)}}v.delete(s)}}}L(s,t),Z(s,"immediate");const i=()=>{if(o)return;o=!0,n?.();const t=dt.get(s);if(t){for(const e of t)e();dt.delete(s)}pt.unregister(i)};if(!X){const t=()=>i();return pt.register(t,i,t),t}let c=dt.get(X);c||(c=new Set,dt.set(X,c));const a=X,l=()=>{c.delete(l),0===c.size&&dt.delete(a),i()};return c.add(l),l}const gt=new Set;function bt(t){return null===t||"object"!=typeof t||(!!M.has(t)||(!!t[A]||!!Array.from(gt).some(e=>e(t))))}function mt(...t){for(const e of t)e&&(e.prototype[A]=!0);return t[0]}function wt(t,e){t.prototype[z]=e,mt(e)}function vt(t,e,{immediate:n=!1}={}){if(null==t)return;if("object"!=typeof t)throw new Error("Target of deep watching must be an object");const r=L(()=>e(t),e);return yt(()=>{O.add(t);let o=k.get(r);o||(o=new Set,k.set(r,o)),o.add(t);const s=new WeakSet;return function t(e,n=0){if(!(s.has(e)||!function(t){return null!==t&&"object"==typeof t}(e)||n>K.maxDeepWatchDepth||bt(e))){s.add(e),O.add(e),o.add(e);for(const r in ut(e))if(Object.hasOwn(e,r)){const o=e[r];t("object"==typeof o&&null!==o?ht(o):o,n+1)}if(Array.isArray(e)||e instanceof Array){const r=e.length;for(let o=0;o<r;o++){const r=e[o];t("object"==typeof r&&null!==r?ht(r):r,n+1)}}else if(e instanceof Set)for(const r of e){t("object"==typeof r&&null!==r?ht(r):r,n+1)}else if(e instanceof Map)for(const[r,o]of e){t("object"==typeof o&&null!==o?ht(o):o,n+1)}}}(t),n&&e(t),n=!0,()=>{const t=k.get(r);if(t){for(const e of t){const t=E.get(e);t?(t.delete(r),0===t.size&&(E.delete(e),O.delete(e))):O.delete(e)}k.delete(r)}}})}let St;mt(Date,RegExp,Error,Promise,Function),"undefined"!=typeof window&&function(...t){for(const e of t){try{Object.defineProperty(e,A,{value:!0,writable:!1,enumerable:!1,configurable:!1})}catch{}A in e||M.add(e)}t[0]}(window,document),"undefined"!=typeof Element&&mt(Element,Node);const jt=new WeakMap;function xt(t){const e=F(t);let n=[];if(J(jt,e),jt.has(e))return jt.get(e);let r=!1;const o=yt(L(s=>{if(r)return;const i=St;if(jt.has(e)){for(const t of n)t();n=[],jt.delete(e),G(jt,{type:"invalidate",prop:e},e),o(),r=!0}else try{St=n,jt.set(e,t(s))}finally{St=i}},t));return jt.get(e)}const Ot=c({getter(t,e){const n=new WeakMap;return function(){return n.has(this)||n.set(this,r(()=>t.call(this),`${String(this.constructor.name)}.${String(e)}`)),xt(n.get(this))}},default:t=>xt(t)}),Et=Symbol("unset-yet");function kt(t){if(bt(t=ut(t)))return t;try{Object.defineProperty(t,A,{value:!0,writable:!1,enumerable:!1,configurable:!0})}catch{}A in t||M.add(t);for(const e in t)kt(t[e]);return t}const Mt=c({class(t){mt(t)},default:function(t,...e){return"object"==typeof t?kt(t):n=>{n.prototype[N]=new Set(n.prototype[N]||[]),n.prototype[N].add(t);for(const t of e)n.prototype[N].add(t);return n}}});Object.assign(T,{computedCache:jt});const Dt=Symbol("native"),Rt=Array.isArray;Array.isArray=t=>Rt(t)||t instanceof Array&&Dt in t;class Wt{}function*Pt(t,{length:e=!0}={}){yield t,e&&(yield"length")}function*Tt(t,e,{length:n=!1}={}){const r=Math.min(t,e),o=Math.max(t,e);for(let t=r;t<=o;t++)yield t;n&&(yield"length")}class zt extends(w(Wt,{get(t){return J(this[Dt],t),ht(this[Dt][t])},set(t,e){const n=t>=this[Dt].length;this[Dt][t]=e,V(this[Dt],{type:"bunch",method:"set"},Pt(t,{length:n}))},getLength(){return J(this[Dt],"length"),this[Dt].length},setLength(t){const e=this[Dt].length;try{this[Dt].length=t}finally{V(this[Dt],{type:"set",prop:"length"},Tt(e,t,{length:!0}))}}})){constructor(t){super(),Object.defineProperties(this,{[Dt]:{value:t},[C]:{value:t}})}at(t){const e=t<0?this[Dt].length+t:t;if(J(this,e),!(e<0||e>=this[Dt].length))return ht(this[Dt][e])}push(...t){const e=this[Dt].length;try{return this[Dt].push(...t)}finally{V(this,{type:"bunch",method:"push"},Tt(e,e+t.length-1,{length:!0}))}}pop(){if(0!==this[Dt].length)try{return ht(this[Dt].pop())}finally{V(this,{type:"bunch",method:"pop"},Pt(this[Dt].length))}}shift(){if(0!==this[Dt].length)try{return ht(this[Dt].shift())}finally{V(this,{type:"bunch",method:"shift"},Tt(0,this[Dt].length+1,{length:!0}))}}unshift(...t){try{return this[Dt].unshift(...t)}finally{V(this,{type:"bunch",method:"unshift"},Tt(0,this[Dt].length-t.length,{length:!0}))}}splice(t,e,...n){const r=this[Dt].length;void 0===e&&(e=r-t);try{return ht(void 0===e?this[Dt].splice(t):this[Dt].splice(t,e,...n))}finally{V(this,{type:"bunch",method:"splice"},e===n.length?Tt(t,t+e):Tt(t,r+Math.max(n.length-e,0),{length:!0}))}}reverse(){try{return this[Dt].reverse()}finally{V(this,{type:"bunch",method:"reverse"},Tt(0,this[Dt].length-1))}}sort(t){try{return this[Dt].sort(t)}finally{V(this,{type:"bunch",method:"sort"},Tt(0,this[Dt].length-1))}}fill(t,e,n){try{return void 0===e?this[Dt].fill(t):void 0===n?this[Dt].fill(t,e):this[Dt].fill(t,e,n)}finally{V(this,{type:"bunch",method:"fill"},Tt(0,this[Dt].length-1))}}copyWithin(t,e,n){try{return void 0===n?this[Dt].copyWithin(t,e):this[Dt].copyWithin(t,e,n)}finally{V(this,{type:"bunch",method:"copyWithin"},Tt(0,this[Dt].length-1))}}toReversed(){return J(this),ht(this[Dt].toReversed())}toSorted(t){return J(this),ht(this[Dt].toSorted(t))}toSpliced(t,e,...n){return J(this),void 0===e?this[Dt].toSpliced(t):this[Dt].toSpliced(t,e,...n)}with(t,e){return J(this),ht(this[Dt].with(t,e))}entries(){return J(this),W(this[Dt].entries())}keys(){return J(this),this[Dt].keys()}values(){return J(this),R(this[Dt].values())}[Symbol.iterator](){J(this);const t=this[Dt][Symbol.iterator]();return{next(){const e=t.next();return e.done?e:{value:ht(e.value),done:!1}}}}indexOf(t,e){return J(this),this[Dt].indexOf(t,e)}lastIndexOf(t,e){return J(this),this[Dt].lastIndexOf(t,e)}includes(t,e){return J(this),this[Dt].includes(t,e)}find(t,e){return J(this),ht(this[Dt].find(t,e))}findIndex(t,e){return J(this),this[Dt].findIndex(t,e)}flat(){return J(this),ht(this[Dt].flat())}flatMap(t,e){return J(this),ht(this[Dt].flatMap(t,e))}filter(t,e){return J(this),ht(this[Dt].filter(t,e))}map(t,e){return J(this),ht(this[Dt].map(t,e))}reduce(t,e){J(this);const n=void 0===e?this[Dt].reduce(t):this[Dt].reduce(t,e);return ht(n)}reduceRight(t,e){J(this);const n=void 0!==e?this[Dt].reduceRight(t,e):this[Dt].reduceRight(t);return ht(n)}slice(t,e){for(const n of Tt(t||0,e||this[Dt].length-1))J(this,n);return void 0===t?this[Dt].slice():void 0===e?this[Dt].slice(t):this[Dt].slice(t,e)}concat(...t){return J(this),ht(this[Dt].concat(...t))}join(t){return J(this),this[Dt].join(t)}forEach(t,e){J(this),this[Dt].forEach(t,e)}every(t,e){return J(this),this[Dt].every(t,e)}some(t,e){return J(this),this[Dt].some(t,e)}}const At=Symbol("native");class Nt{constructor(t){Object.defineProperties(this,{[At]:{value:t},[C]:{value:t},content:{value:Symbol("content")},[Symbol.toStringTag]:{value:"ReactiveMap"}})}get size(){return J(this,"size"),this[At].size}clear(){const t=this[At].size>0;if(this[At].clear(),t){const t={type:"bunch",method:"clear"};G(this,t,"size"),V(this.content,t)}}entries(){return J(this.content),W(this[At].entries())}forEach(t,e){J(this.content),this[At].forEach(t,e)}keys(){return J(this.content),this[At].keys()}values(){return J(this.content),R(this[At].values())}[Symbol.iterator](){J(this.content);const t=this[At][Symbol.iterator]();return{next(){const e=t.next();return e.done?e:{value:[e.value[0],ht(e.value[1])],done:!1}}}}delete(t){const e=this[At].has(t),n=this[At].delete(t);if(e){const e={type:"del",prop:t};G(this.content,e,t),G(this,e,"size")}return n}get(t){return J(this.content,t),ht(this[At].get(t))}has(t){return J(this.content,t),this[At].has(t)}set(t,e){const n=this[At].has(t),r=this[At].get(t),o=ht(e);if(this[At].set(t,o),!n||r!==o){const e={type:n?"set":"add",prop:t};G(this.content,e,t),G(this,e,"size")}return this}}const Ct=Symbol("native");class It{constructor(t){Object.defineProperties(this,{[Ct]:{value:t},[C]:{value:t},content:{value:Symbol("content")},[Symbol.toStringTag]:{value:"ReactiveSet"}})}get size(){return J(this,"size"),this[Ct].size}add(t){const e=this[Ct].has(t),n=ht(t);if(this[Ct].add(n),!e){const t={type:"add",prop:n};G(this.content,t,n),G(this,t,"size")}return this}clear(){const t=this[Ct].size>0;if(this[Ct].clear(),t){const t={type:"bunch",method:"clear"};G(this,t,"size"),V(this.content,t)}}delete(t){const e=this[Ct].has(t),n=this[Ct].delete(t);if(e){const e={type:"del",prop:t};G(this.content,e,t),G(this,e,"size")}return n}has(t){return J(this.content,t),this[Ct].has(t)}entries(){return J(this.content),W(this[Ct].entries())}forEach(t,e){J(this.content),this[Ct].forEach(t,e)}keys(){return J(this.content),R(this[Ct].keys())}values(){return J(this.content),R(this[Ct].values())}[Symbol.iterator](){J(this.content);const t=this[Ct][Symbol.iterator]();return{next(){const e=t.next();return e.done?e:{value:ht(e.value),done:!1}}}}}wt(WeakMap,class{constructor(t){Object.defineProperties(this,{[At]:{value:t},[C]:{value:t},content:{value:Symbol("content")},[Symbol.toStringTag]:{value:"ReactiveWeakMap"}})}delete(t){const e=this[At].has(t),n=this[At].delete(t);return e&&G(this.content,{type:"del",prop:t},t),n}get(t){return J(this.content,t),ht(this[At].get(t))}has(t){return J(this.content,t),this[At].has(t)}set(t,e){return G(this.content,{type:this[At].has(t)?"set":"add",prop:t},t),this[At].set(t,e),this}}),wt(Map,Nt),wt(WeakSet,class{constructor(t){Object.defineProperties(this,{[Ct]:{value:t},[C]:{value:t},content:{value:Symbol("content")},[Symbol.toStringTag]:{value:"ReactiveWeakSet"}})}add(t){const e=this[Ct].has(t);return this[Ct].add(t),e||G(this.content,{type:"add",prop:t},t),this}delete(t){const e=this[Ct].has(t),n=this[Ct].delete(t);return e&&G(this.content,{type:"del",prop:t},t),n}has(t){return J(this.content,t),this[Ct].has(t)}}),wt(Set,It),wt(Array,zt);const $t=[],Lt=c({getter:(t,e)=>function(){const n=$t.findIndex(t=>t.object===this&&t.prop===e);if(n>-1)throw new Error(`Circular dependency detected: ${$t.slice(n).map(t=>`${t.object.constructor.name}.${String(t.prop)}`).join(" -> ")} -> again`);$t.push({object:this,prop:e});try{const n=t.call(this);return Ft(this,e,n),n}finally{$t.pop()}}});function Ft(t,e,n){Object.defineProperty(t,e,{value:n})}const Bt=Object.assign(c({method:(t,e)=>function(...n){return Bt.warn(this,e),t.apply(this,n)},getter:(t,e)=>function(){return Bt.warn(this,e),t.call(this)},setter:(t,e)=>function(n){return Bt.warn(this,e),t.call(this,n)},class:t=>class extends t{constructor(...t){super(...t),Bt.warn(this,"constructor")}},default:t=>c({method:(e,n)=>function(...r){return Bt.warn(this,n,t),e.apply(this,r)},getter:(e,n)=>function(){return Bt.warn(this,n,t),e.call(this)},setter:(e,n)=>function(r){return Bt.warn(this,n,t),e.call(this,r)},class:e=>class extends e{constructor(...e){super(...e),Bt.warn(this,"constructor",t)}}})}),{warn:(t,e,n)=>{}});t.DecoratorError=o,t.Destroyable=function(t,e){var n;return t&&"function"!=typeof t&&(e=t,t=void 0),t||(t=class{}),n=class extends t{static destroy(t){const e=n.destructors.get(t);if(!e)return!1;a.unregister(t),n.destructors.delete(t),Object.setPrototypeOf(t,new Proxy({},f));for(const e of Object.getOwnPropertyNames(t))delete t[e];return e(),!0}static isDestroyable(t){return n.destructors.has(t)}constructor(...t){super(...t);const r={};this[h]=r;const o=e?.destructor??this[l];if(!o)throw new u("Destructor is not defined");function s(){o(r)}n.destructors.set(this,s),a.register(this,s,this)}},n.destructors=new WeakMap,n},t.DestructionError=u,t.Eventful=class{constructor(){y.set(this,new Map),g.set(this,[])}hook(t){return p(this,g,"f").includes(t)||p(this,g,"f").push(t),()=>{p(this,g,"f").splice(p(this,g,"f").indexOf(t),1)}}on(t,e){if("object"==typeof t)for(const e of Object.keys(t))this.on(e,t[e]);else if(void 0!==e){let n=p(this,y,"f").get(t);n||(n=[],p(this,y,"f").set(t,n)),n.push(e)}return()=>this.off(t,e)}off(t,e){if("object"==typeof t)for(const e of Object.keys(t))this.off(e,t[e]);else if(null!=e){const n=p(this,y,"f").get(t);n&&p(this,y,"f").set(t,n.filter(t=>t!==e))}else p(this,y,"f").delete(t)}emit(t,...e){const n=p(this,y,"f").get(t);if(n)for(const t of n)t.apply(this,e);for(const n of p(this,g,"f"))n.call(this,t,...e)}},t.Indexable=w,t.ReactiveBase=at,t.ReactiveError=B,t.allocated=d,t.allocatedValues=h,t.atomic=_,t.cache=Ft,t.cached=Lt,t.callOnGC=function(t){let e=!1;const n=()=>{e||(e=!0,t())};return a.register(n,t,t),n},t.computed=Ot,t.debounce=function(t){return c({method(e,n){let r=null;return function(...n){r&&clearTimeout(r),r=setTimeout(()=>{e.apply(this,n),r=null},t)}}})},t.decorator=c,t.deprecated=Bt,t.describe=function(t){return(...e)=>n=>class extends n{constructor(...n){super(...n);for(const n of e)Object.defineProperty(this,n,{...Object.getOwnPropertyDescriptor(this,n),...t})}}},t.destructor=l,t.effect=yt,t.getAt=b,t.getState=H,t.immutables=gt,t.invalidateComputed=function(t,e=!0){St?St.push(t):e&&K.warn("Using `invalidateComputed` outside of a computed property")},t.isCached=function(t,e){return!!Object.getOwnPropertyDescriptor(t,e)},t.isConstructor=n,t.isNonReactive=bt,t.isReactive=function(t){return j.has(t)},t.legacyDecorator=s,t.modernDecorator=i,t.profileInfo=T,t.reactive=ht,t.reactiveOptions=K,t.renamed=r,t.setAt=m,t.throttle=function(t){return c({method(e,n){let r=0,o=null;return function(...n){const s=Date.now();if(s-r>=t)return o&&(clearTimeout(o),o=null),r=s,e.apply(this,n);if(!o){const i=t-(s-r),c=[...n];o=setTimeout(()=>{r=Date.now(),e.apply(this,c),o=null},i)}}}})},t.unreactive=Mt,t.untracked=ft,t.unwrap=ut,t.watch=function(t,e,n={}){return"function"==typeof t?function(t,e,{immediate:n=!1,deep:r=!1}={}){let o,s=Et;const i=yt(L(i=>{const c=t(i);s!==c&&ft(L(()=>{s===Et?n&&e(c):e(c,s),s=c,r&&(o&&o(),o=vt(c,L(t=>e(t,t),e)))},e))},t));return()=>{i(),o&&o()}}(t,e,n):"object"==typeof t?function(t,e,{immediate:n=!1,deep:r=!1}={}){return r?vt(t,e,{immediate:n}):yt(L(()=>{J(t),n&&ft(()=>e(t)),n=!0},e))}(t,e,n):(()=>{throw new Error("watch: value must be a function or an object")})()},t.zip=function(...t){if(!t.length)return[];const e=Math.min(...t.map(t=>t.length)),n=[];for(let r=0;r<e;r++){const e=t.map(t=>t[r]);n.push(e)}return n}});
2
2
  //# sourceMappingURL=mutts.umd.min.js.map