react-hooks-global-states 7.0.12 → 7.0.14

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.
package/GlobalStore.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ActionCollectionConfig, StateSetter, GlobalStoreCallbacks, ActionCollectionResult, MetadataSetter, UseHookConfig, StateGetter, SelectorCallback, SubscriberParameters, MetadataGetter, StateHook, BaseMetadata, StateChanges, StoreTools, ObservableFragment } from './types';
1
+ import type { ActionCollectionConfig, StateSetter, GlobalStoreCallbacks, ActionCollectionResult, MetadataSetter, UseHookConfig, StateGetter, SelectorCallback, SubscriberParameters, MetadataGetter, StateHook, BaseMetadata, StateChanges, StoreTools, ObservableFragment } from './types';
2
2
  import { UniqueSymbol } from './uniqueSymbol';
3
3
  /**
4
4
  * The GlobalStore class is the main class of the library and it is used to create a GlobalStore instances
package/GlobalStore.js CHANGED
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react")):"function"==typeof define&&define.amd?define(["react"],e):"object"==typeof exports?exports["react-hooks-global-states"]=e(require("react")):t["react-hooks-global-states"]=e(t.react)}(this,(t=>(()=>{var e={748:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.generateStackHash=void 0;e.generateStackHash=function(t){if(!t.trim())return"unknown";t=t.replace(/\s/g,"");for(var e=2166136261,r=0;r<t.length;r++)e^=t.charCodeAt(r),e*=16777619,e&=4294967295;return function(t){for(var e="";t>0;)e="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[t%62]+e,t=Math.floor(t/62);return e||"0"}(e>>>0)},e.default=e.generateStackHash},143:(t,e,r)=>{"use strict";function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}Object.defineProperty(e,"__esModule",{value:!0}),e.isRecord=void 0;var o=r(125);e.isRecord=function(t){return!(0,o.isNil)(t)&&"object"===n(t)},e.default=e.isRecord},561:(t,e,r)=>{"use strict";function n(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],s=!0,c=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);s=!0);}catch(t){c=!0,o=t}finally{try{if(!s&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return u}}(t,e)||i(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=i(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,u=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return u=t.done,t},e:function(t){s=!0,a=t},f:function(){try{u||null==r.return||r.return()}finally{if(s)throw a}}}}function i(t,e){if(t){if("string"==typeof t)return a(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?a(t,e):void 0}}function a(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function u(t){return u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(t)}Object.defineProperty(e,"__esModule",{value:!0}),e.shallowCompare=void 0;var s=r(416),c=r(231),l=r(125),f=r(143);e.shallowCompare=function(t,e){if(t===e)return!0;var r=u(t),i=u(e);if(r!==i)return!1;if((0,l.isNil)(t)||(0,l.isNil)(e)||(0,s.isPrimitive)(t)&&(0,s.isPrimitive)(e)||(0,c.isDate)(t)&&(0,c.isDate)(e)||"function"===r&&"function"===i)return t===e;if(Array.isArray(t)){var a=t,d=e;if(a.length!==d.length)return!1;for(var p=0;p<a.length;p++){if(a[p]!==d[p])return!1}}if(t instanceof Map){var v=t,h=e;if(v.size!==h.size)return!1;var b,y=o(v);try{for(y.s();!(b=y.n()).done;){var g=n(b.value,2),m=g[0];if(g[1]!==h.get(m))return!1}}catch(t){y.e(t)}finally{y.f()}}if(t instanceof Set){var S=t,w=e;if(S.size!==w.size)return!1;var O,_=o(S);try{for(_.s();!(O=_.n()).done;){var E=O.value;if(!w.has(E))return!1}}catch(t){_.e(t)}finally{_.f()}}if(!(0,f.isRecord)(t)||!(0,f.isRecord)(e))return t===e;var A=Object.keys(t),j=Object.keys(e);if(A.length!==j.length)return!1;for(var k=0,x=A;k<x.length;k++){var C=x[k];if(t[C]!==e[C])return!1}return!0},e.default=e.shallowCompare},400:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.throwWrongKeyOnActionCollectionConfig=void 0;e.throwWrongKeyOnActionCollectionConfig=function(t){throw new Error("[WRONG CONFIGURATION!]: Every key inside the storeActionsConfig must be a higher order function that returns a function \n[".concat(t,"]: key is not a valid function, try something like this: \n{\n\n ").concat(t,": (param) => ({ setState, getState, setMetadata, getMetadata, actions }) => {\n\n setState((state) => ({ ...state, ...param }))\n\n }\n\n}\n"))},e.default=e.throwWrongKeyOnActionCollectionConfig},157:(t,e)=>{"use strict";var r;Object.defineProperty(e,"__esModule",{value:!0}),e.uniqueId=void 0,e.uniqueId=(r=0,function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return r===Number.MAX_SAFE_INTEGER&&(r=0),t+Date.now().toString(36)+(r++).toString(36)}),e.default=e.uniqueId},605:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.uniqueSymbol=void 0,e.uniqueSymbol=Symbol("unique"),e.default=e.uniqueSymbol},231:function(t){t.exports=(()=>{"use strict";var t={};return(()=>{var e=t;Object.defineProperty(e,"__esModule",{value:!0}),e.isDate=void 0,e.isDate=function(t){return t instanceof Date}})(),t})()},244:function(t){t.exports=(()=>{"use strict";var t={};return(()=>{var e=t;Object.defineProperty(e,"__esModule",{value:!0}),e.isFunction=void 0,e.isFunction=function(t){return"function"==typeof t||t instanceof Function}})(),t})()},125:function(t){t.exports=(()=>{"use strict";var t={};return(()=>{var e=t;Object.defineProperty(e,"__esModule",{value:!0}),e.isNil=void 0,e.isNil=function(t){return null==t}})(),t})()},416:function(t){t.exports=(()=>{"use strict";var t={112:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isBoolean=void 0,e.isBoolean=function(t){return"boolean"==typeof t}},243:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isNil=void 0,e.isNil=function(t){return null==t}},11:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isNumber=void 0,e.isNumber=function(t){return"number"==typeof t}},671:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isString=void 0,e.isString=function(t){return"string"==typeof t}}},e={};function r(n){var o=e[n];if(void 0!==o)return o.exports;var i=e[n]={exports:{}};return t[n](i,i.exports,r),i.exports}var n={};return(()=>{var t=n;function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},e(t)}Object.defineProperty(t,"__esModule",{value:!0}),t.isPrimitive=void 0;var o=r(112),i=r(243),a=r(11),u=r(671);t.isPrimitive=function(t){return(0,i.isNil)(t)||(0,a.isNumber)(t)||(0,o.isBoolean)(t)||(0,u.isString)(t)||"symbol"===e(t)}})(),n})()},281:function(t){t.exports=(()=>{"use strict";var t={};return(()=>{var e=t;Object.defineProperty(e,"__esModule",{value:!0}),e.isString=void 0,e.isString=function(t){return"string"==typeof t}})(),t})()},156:e=>{"use strict";e.exports=t}},r={};function n(t){var o=r[t];if(void 0!==o)return o.exports;var i=r[t]={exports:{}};return e[t].call(i.exports,i,i.exports,n),i.exports}var o={};return(()=>{"use strict";var t=o;function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},e(t)}function r(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],s=!0,c=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);s=!0);}catch(t){c=!0,o=t}finally{try{if(!s&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return u}}(t,e)||i(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(t,e){if(t){if("string"==typeof t)return a(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?a(t,e):void 0}}function a(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function u(){u=function(){return t};var t={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",s=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function l(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var i=e&&e.prototype instanceof v?e:v,a=Object.create(i.prototype),u=new k(n||[]);return o(a,"_invoke",{value:_(t,r,u)}),a}function d(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=f;var p={};function v(){}function h(){}function b(){}var y={};l(y,a,(function(){return this}));var g=Object.getPrototypeOf,m=g&&g(g(x([])));m&&m!==r&&n.call(m,a)&&(y=m);var S=b.prototype=v.prototype=Object.create(y);function w(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,r){function i(o,a,u,s){var c=d(t[o],t,a);if("throw"!==c.type){var l=c.arg,f=l.value;return f&&"object"==e(f)&&n.call(f,"__await")?r.resolve(f.__await).then((function(t){i("next",t,u,s)}),(function(t){i("throw",t,u,s)})):r.resolve(f).then((function(t){l.value=t,u(l)}),(function(t){return i("throw",t,u,s)}))}s(c.arg)}var a;o(this,"_invoke",{value:function(t,e){function n(){return new r((function(r,n){i(t,e,r,n)}))}return a=a?a.then(n,n):n()}})}function _(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return C()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var u=E(a,r);if(u){if(u===p)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var s=d(t,e,r);if("normal"===s.type){if(n=r.done?"completed":"suspendedYield",s.arg===p)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(n="completed",r.method="throw",r.arg=s.arg)}}}function E(t,e){var r=e.method,n=t.iterator[r];if(void 0===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=void 0,E(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),p;var o=d(n,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,p;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,p):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,p)}function A(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function j(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function x(t){if(t){var e=t[a];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,o=function e(){for(;++r<t.length;)if(n.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:C}}function C(){return{value:void 0,done:!0}}return h.prototype=b,o(S,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:h,configurable:!0}),h.displayName=l(b,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,l(t,c,"GeneratorFunction")),t.prototype=Object.create(S),t},t.awrap=function(t){return{__await:t}},w(O.prototype),l(O.prototype,s,(function(){return this})),t.AsyncIterator=O,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new O(f(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},w(S),l(S,c,"Generator"),l(S,a,(function(){return this})),l(S,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},t.values=x,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(j),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return r(i.catchLoc,!0);if(this.prev<i.finallyLoc)return r(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return r(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return r(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,p):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),p},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),j(r),p}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;j(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:x(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),p}},t}function s(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,c(n.key),n)}}function c(t){var r=function(t,r){if("object"!==e(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var o=n.call(t,r||"default");if("object"!==e(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}(t,"string");return"symbol"===e(r)?r:String(r)}var l=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function a(t){try{s(n.next(t))}catch(t){i(t)}}function u(t){try{s(n.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,u)}s((n=n.apply(t,e||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.GlobalStore=void 0;var f=n(156),d=n(244),p=n(125),v=n(281),h=n(143),b=n(561),y=n(400),g=n(157),m=n(605),S=n(748),w=globalThis;!function(){if(!w.REACT_GLOBAL_STATE_HOOK_DEBUG&&!(0,p.isNil)(w.sessionStorage)){try{if(!w.sessionStorage.getItem("REACT_GLOBAL_STATE_HOOK_DEBUG"))return}catch(t){return}w.REACT_GLOBAL_STATE_TEMP_HOOKS=new Map,setTimeout((function(){w.REACT_GLOBAL_STATE_TEMP_HOOKS=null}),6e4)}}();var O=function(){function t(e){var n,o=this,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{metadata:{}};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.wasDisposed=!1,this.actionsConfig=null,this.callbacks=null,this.actions=null,this.subscribers=new Map,this.initialize=function(){return l(o,void 0,void 0,u().mark((function t(){var e,r,n,o,i,a;return u().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(Object.keys(null!==(e=this.actionsConfig)&&void 0!==e?e:{}).length>0&&(this.actions=this.getStoreActionsMap()),n=this.onInit,o=null!==(r=this.callbacks)&&void 0!==r?r:{},i=o.onInit,n||i){t.next=6;break}return t.abrupt("return");case 6:a=this.getConfigCallbackParam(),null==n||n(a),(0,p.isNil)(i)||null==i||i(a);case 9:case"end":return t.stop()}}),t,this)})))},this.executeSetStateForSubscriber=function(t,e){var r,n,i=t.selector,a=t.callback,u=t.currentState,s=t.config;if(!e.forceUpdate&&(null!==(r=null==s?void 0:s.isEqualRoot)&&void 0!==r?r:function(t,e){return t===e})(e.currentRootState,e.newRootState))return{didUpdate:!1};var c=i?i(e.newRootState):e.newRootState;return!e.forceUpdate&&(null!==(n=null==s?void 0:s.isEqual)&&void 0!==n?n:function(t,e){return t===e})(u,c)?{didUpdate:!1}:(o.partialUpdateSubscription(t.subscriptionId,{currentState:c}),a({state:c},{identifier:e.identifier}),{didUpdate:!0})},this.setState=function(t,e){var r=t.state,n=e.forceUpdate,a=e.identifier,u=o.stateWrapper.state;if(n||u!==r){o.stateWrapper={state:r};var s,c={forceUpdate:n,newRootState:r,currentRootState:u,identifier:a},l=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=i(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,u=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return u=t.done,t},e:function(t){s=!0,a=t},f:function(){try{u||null==r.return||r.return()}finally{if(s)throw a}}}}(o.subscribers.values());try{for(l.s();!(s=l.n()).done;){var f=s.value;o.executeSetStateForSubscriber(f,c)}}catch(t){l.e(t)}finally{l.f()}}},this.setMetadata=function(t){var e=(0,d.isFunction)(t)?t(o.metadata):t;o.metadata=e},this.getMetadata=function(){return o.metadata},this.getState=function(t,e,r){var n;if(!t)return o.stateWrapper.state;var i=(0,d.isFunction)(e),a=i?t:void 0,u=i?e:t,s=null!==(n=i?r:e)&&void 0!==n?n:void 0,c=a?a(o.stateWrapper.state):o.stateWrapper.state;(null==s?void 0:s.skipFirst)||u(c);var l=(0,g.uniqueId)("gs:");return o.setOrUpdateSubscription({subscriptionId:l,selector:a,config:s,currentState:c,callback:function(t){var e=t.state;return u(e)},isSetStateCallback:!1}),function(){o.subscribers.delete(l)}},this.getConfigCallbackParam=function(){var t=o.setMetadata,e=o.getMetadata,r=o.getState,n=o.actions;return{setMetadata:t,getMetadata:e,getState:r,setState:o.setStateWrapper,actions:n}},this.lastSubscriptionId=null,this.setOrUpdateSubscription=function(t){var e=t.subscriptionId;if(!e)return{isNewSubscription:!1};var r=o.subscribers.get(e);return(0,h.isRecord)(r)?(Object.assign(r,t),{isNewSubscription:!1}):(o.executeOnSubscribed(),o.subscribers.set(e,t),o.lastSubscriptionId=e,{isNewSubscription:!0})},this.partialUpdateSubscription=function(t,e){var r=o.subscribers.get(t);(0,h.isRecord)(r)&&Object.assign(r,e)},this.executeOnSubscribed=function(){var t,e=o.onSubscribed,r=null===(t=o.callbacks)||void 0===t?void 0:t.onSubscribed;if(e||r){var n=o.getConfigCallbackParam();null==e||e(n),null==r||r(n)}},this.getHook=function(){var t=function(t){var e,n,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(o.wasDisposed)throw new Error("The global state was disposed");var a=Array.isArray(i)?{dependencies:i}:null!=i?i:{},u=(0,f.useRef)({subscriptionId:null,tempInitialRootState:o.stateWrapper.state}),s=function(){return t?{state:t(o.stateWrapper.state)}:o.stateWrapper},c=r((0,f.useState)(s),2),l=c[0],d=c[1];(0,f.useEffect)((function(){if(!(0,p.isNil)(u.current)){(0,p.isNil)(u.current.subscriptionId)&&(u.current.subscriptionId=(0,g.uniqueId)("ss:"));var e=u.current.subscriptionId,r={subscriptionId:e,currentState:l.state,selector:t,config:a,callback:d,isSetStateCallback:!0};return o.setOrUpdateSubscription(r).isNewSubscription&&(o.executeSetStateForSubscriber(r,{forceUpdate:!1,newRootState:o.stateWrapper.state,currentRootState:u.current.tempInitialRootState===m.uniqueSymbol?o.stateWrapper.state:u.current.tempInitialRootState,identifier:"on mount state update"}),u.current.tempInitialRootState=m.uniqueSymbol),function(){o.subscribers.delete(e)}}}),[]);var h=(0,v.isString)(null===(e=u.current)||void 0===e?void 0:e.subscriptionId)?u.current.subscriptionId:"",b=o.subscribers.get(h),y=(null!==(n=null==b?void 0:b.config)&&void 0!==n?n:{dependencies:a.dependencies}).dependencies;return o.partialUpdateSubscription(h,{currentState:l.state,selector:t,config:a,callback:d}),[o.computeSelectedState({selector:t,subscriptionId:h,config:a,currentDependencies:y,computeChildState:s,stateWrapperRef:l}),o.getStateOrchestrator(),o.metadata]};return t.stateControls=o.stateControls,t.createSelectorHook=o.createSelectorHook,t.createObservable=o.createObservable,t.removeSubscriptions=o.removeSubscriptions,t.dispose=o.dispose,t},this.computeSelectedState=function(t){var e=t.selector,r=t.subscriptionId,n=t.config,i=t.currentDependencies,a=t.computeChildState,u=t.stateWrapperRef;if(!e||!r)return u.state;var s=n.dependencies;if(i===s)return u.state;if((null==i?void 0:i.length)===(null==s?void 0:s.length)&&(0,b.shallowCompare)(i,s))return u.state;var c=a().state;return o.partialUpdateSubscription(r,{currentState:c}),u.state=c,c},this.createSelectorHook=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=n.isEqualRoot,a=n.isEqual,u=n.name,s=r(o.stateControls(),3),c=s[0],l=s[1],f=s[2],p=c(),v=(null!=e?e:function(t){return t})(p),h=new t(v,{name:null!=u?u:(0,g.uniqueId)("sh:")}),b=r(h.stateControls(),2),y=b[0],m=b[1],S=c((function(t){if(!(null!=i?i:Object.is)(p,t)){p=t;var r=e(t);(null!=a?a:Object.is)(v,r)||(v=r,m(r))}}),{skipFirst:!0}),w=h.getHook(),O=function(t,e){return[r((0,d.isFunction)(t)?w(t,e):w(),1)[0],l,f]};return O.stateControls=function(){return[y,l,f]},O.createSelectorHook=o.createSelectorHook.bind(O),O.createObservable=o.createObservable.bind(O),O.removeSubscriptions=function(){S(),h.removeSubscriptions()},O.dispose=function(){O.removeSubscriptions(),h.dispose()},O},this.stateControls=function(){var t=o.getStateOrchestrator(),e=o.getMetadata;return[o.getState,t,e]},this.getStateOrchestrator=function(){return o.actions?o.actions:o.setStateWrapper},this.setStateWrapper=function(t){var e,r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=n.forceUpdate,a=n.identifier,u=o.stateWrapper.state,s=(0,d.isFunction)(t)?t(u):t;if(i||o.stateWrapper.state!==s){var c=o.setMetadata,l=o.getMetadata,f=o.getState,p=o.actions,v={setMetadata:c,getMetadata:l,setState:o.setState,getState:f,actions:p,previousState:u,state:s,identifier:a},h=o.computePreventStateChange,b=null===(e=o.callbacks)||void 0===e?void 0:e.computePreventStateChange;if(h||b)if((null==h?void 0:h(v))||(null==b?void 0:b(v)))return;o.setState({state:s},{forceUpdate:i,identifier:a});var y=o.onStateChanged,g=null===(r=o.callbacks)||void 0===r?void 0:r.onStateChanged;(y||g)&&(null==y||y(v),null==g||g(v))}},this.getStoreActionsMap=function(){if(!(0,h.isRecord)(o.actionsConfig))return null;var t=o.actionsConfig,e=o.setMetadata,r=o.setStateWrapper,n=o.getState,i=o.getMetadata,a=Object.keys(t).reduce((function(o,u){var s,l,f;return Object.assign(o,(s={},f=function(){for(var o=t[u],s=arguments.length,c=new Array(s),l=0;l<s;l++)c[l]=arguments[l];var f=o.apply(a,c);return"function"!=typeof f&&(0,y.throwWrongKeyOnActionCollectionConfig)(u),f.call(a,{setState:r,getState:n,setMetadata:e,getMetadata:i,actions:a})},(l=c(l=u))in s?Object.defineProperty(s,l,{value:f,enumerable:!0,configurable:!0,writable:!0}):s[l]=f,s)),o}),{});return a},this.removeSubscriptions=function(){o.subscribers.clear()},this.dispose=function(){o.wasDisposed=!0,o.removeSubscriptions(),o._name="",o.actionsConfig=null,o.callbacks=null,o.metadata={},o.actions=null,o.subscribers.clear(),o.stateWrapper={state:null}};var s=a.metadata,O=a.callbacks,_=a.actions,E=a.name;this.stateWrapper={state:e},this._name=null!=E?E:(0,g.uniqueId)("gs:"),this.metadata=null!=s?s:{},this.callbacks=null!=O?O:null,this.actionsConfig=null!=_?_:null;var A="";if((w.REACT_GLOBAL_STATE_HOOK_DEBUG||w.REACT_GLOBAL_STATE_TEMP_HOOKS)&&(A=(0,S.generateStackHash)(null!==(n=(new Error).stack)&&void 0!==n?n:"")),w.REACT_GLOBAL_STATE_HOOK_DEBUG)w.REACT_GLOBAL_STATE_HOOK_DEBUG(this,a,A);else if(w.REACT_GLOBAL_STATE_TEMP_HOOKS){var j=void 0!==globalThis.WeakRef?new globalThis.WeakRef(this):this,k=void 0!==globalThis.WeakRef?new globalThis.WeakRef(a):a;w.REACT_GLOBAL_STATE_TEMP_HOOKS.set(A,[j,k])}this.constructor!==t||this.initialize()}var e,n,o;return e=t,n=[{key:"createObservable",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=e.isEqualRoot,o=e.isEqual,i=e.name,a=r(this.stateControls(),1)[0],u=[],s=a(),c=(null!=t?t:function(t){return t})(a()),l=a((function(e){if(!(null!=n?n:Object.is)(s,e)){s=e;var r=t(e);(null!=o?o:Object.is)(c,r)||(c=r,u.forEach((function(t){return t()})))}}),{skipFirst:!0}),f=function(t,e,r){var n;if(!t)return c;var o=(0,d.isFunction)(e),i=o?t:void 0,a=o?e:t,s=null!==(n=o?r:e)&&void 0!==n?n:void 0,l=function(){return a(i?i(c):c)};(null==s?void 0:s.skipFirst)||l();var f=function(){l()};return u.push(f),function(){u.splice(u.indexOf(f),1)}};return f._name=null!=i?i:(0,g.uniqueId)("ob:"),f.createObservable=this.createObservable.bind(f),f.removeSubscriptions=function(){u.forEach((function(t){return t()})),u.length=0,l()},f.stateControls=function(){return[f]},f}}],n&&s(e.prototype,n),o&&s(e,o),Object.defineProperty(e,"prototype",{writable:!1}),t}();t.GlobalStore=O,t.default=O})(),o})()));
1
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("./generateStackHash.js"),require("./isRecord.js"),require("./shallowCompare.js"),require("./throwWrongKeyOnActionCollectionConfig.js"),require("./uniqueId.js"),require("./uniqueSymbol.js"),require("react")):"function"==typeof define&&define.amd?define(["./generateStackHash.js","./isRecord.js","./shallowCompare.js","./throwWrongKeyOnActionCollectionConfig.js","./uniqueId.js","./uniqueSymbol.js","react"],e):"object"==typeof exports?exports["react-hooks-global-states"]=e(require("./generateStackHash.js"),require("./isRecord.js"),require("./shallowCompare.js"),require("./throwWrongKeyOnActionCollectionConfig.js"),require("./uniqueId.js"),require("./uniqueSymbol.js"),require("react")):t["react-hooks-global-states"]=e(t["./generateStackHash.js"],t["./isRecord.js"],t["./shallowCompare.js"],t["./throwWrongKeyOnActionCollectionConfig.js"],t["./uniqueId.js"],t["./uniqueSymbol.js"],t.react)}(this,((t,e,r,n,i,o,a)=>(()=>{var s={244:function(t){t.exports=(()=>{"use strict";var t={};return(()=>{var e=t;Object.defineProperty(e,"__esModule",{value:!0}),e.isFunction=void 0,e.isFunction=function(t){return"function"==typeof t||t instanceof Function}})(),t})()},125:function(t){t.exports=(()=>{"use strict";var t={};return(()=>{var e=t;Object.defineProperty(e,"__esModule",{value:!0}),e.isNil=void 0,e.isNil=function(t){return null==t}})(),t})()},281:function(t){t.exports=(()=>{"use strict";var t={};return(()=>{var e=t;Object.defineProperty(e,"__esModule",{value:!0}),e.isString=void 0,e.isString=function(t){return"string"==typeof t}})(),t})()},109:e=>{"use strict";e.exports=t},664:t=>{"use strict";t.exports=e},682:t=>{"use strict";t.exports=r},286:t=>{"use strict";t.exports=n},865:t=>{"use strict";t.exports=i},69:t=>{"use strict";t.exports=o},156:t=>{"use strict";t.exports=a}},u={};function c(t){var e=u[t];if(void 0!==e)return e.exports;var r=u[t]={exports:{}};return s[t].call(r.exports,r,r.exports,c),r.exports}var l={};return(()=>{"use strict";var t=l;function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},e(t)}function r(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,i,o,a,s=[],u=!0,c=!1;try{if(o=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=o.call(r)).done)&&(s.push(n.value),s.length!==e);u=!0);}catch(t){c=!0,i=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw i}}return s}}(t,e)||n(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(t,e){if(t){if("string"==typeof t)return i(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i(t,e):void 0}}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function o(){o=function(){return t};var t={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},s=a.iterator||"@@iterator",u=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function l(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var o=e&&e.prototype instanceof h?e:h,a=Object.create(o.prototype),s=new C(n||[]);return i(a,"_invoke",{value:E(t,r,s)}),a}function p(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=f;var d={};function h(){}function v(){}function b(){}var g={};l(g,s,(function(){return this}));var y=Object.getPrototypeOf,S=y&&y(y(k([])));S&&S!==r&&n.call(S,s)&&(g=S);var m=b.prototype=h.prototype=Object.create(g);function w(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,r){function o(i,a,s,u){var c=p(t[i],t,a);if("throw"!==c.type){var l=c.arg,f=l.value;return f&&"object"==e(f)&&n.call(f,"__await")?r.resolve(f.__await).then((function(t){o("next",t,s,u)}),(function(t){o("throw",t,s,u)})):r.resolve(f).then((function(t){l.value=t,s(l)}),(function(t){return o("throw",t,s,u)}))}u(c.arg)}var a;i(this,"_invoke",{value:function(t,e){function n(){return new r((function(r,n){o(t,e,r,n)}))}return a=a?a.then(n,n):n()}})}function E(t,e,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return T()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=_(a,r);if(s){if(s===d)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=p(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===d)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}function _(t,e){var r=e.method,n=t.iterator[r];if(void 0===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=void 0,_(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),d;var i=p(n,t.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,d;var o=i.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,d):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,d)}function j(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function x(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function C(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(j,this),this.reset(!0)}function k(t){if(t){var e=t[s];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,i=function e(){for(;++r<t.length;)if(n.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:T}}function T(){return{value:void 0,done:!0}}return v.prototype=b,i(m,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:v,configurable:!0}),v.displayName=l(b,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,l(t,c,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},w(O.prototype),l(O.prototype,u,(function(){return this})),t.AsyncIterator=O,t.async=function(e,r,n,i,o){void 0===o&&(o=Promise);var a=new O(f(e,r,n,i),o);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},w(m),l(m,c,"Generator"),l(m,s,(function(){return this})),l(m,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},t.values=k,C.prototype={constructor:C,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var s=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(s&&u){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,d):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),d},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),x(r),d}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;x(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:k(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),d}},t}function a(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,s(n.key),n)}}function s(t){var r=function(t,r){if("object"!==e(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,r||"default");if("object"!==e(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}(t,"string");return"symbol"===e(r)?r:String(r)}var u=function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function a(t){try{u(n.next(t))}catch(t){o(t)}}function s(t){try{u(n.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}u((n=n.apply(t,e||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.GlobalStore=void 0;var f=c(156),p=c(244),d=c(125),h=c(281),v=c(664),b=c(682),g=c(286),y=c(865),S=c(69),m=c(109),w=globalThis;!function(){if(!w.REACT_GLOBAL_STATE_HOOK_DEBUG&&!(0,d.isNil)(w.sessionStorage)){try{if(!w.sessionStorage.getItem("REACT_GLOBAL_STATE_HOOK_DEBUG"))return}catch(t){return}w.REACT_GLOBAL_STATE_TEMP_HOOKS=new Map,setTimeout((function(){w.REACT_GLOBAL_STATE_TEMP_HOOKS=null}),6e4)}}();var O=function(){function t(e){var i,a=this,c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{metadata:{}};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.wasDisposed=!1,this.actionsConfig=null,this.callbacks=null,this.actions=null,this.subscribers=new Map,this.initialize=function(){return u(a,void 0,void 0,o().mark((function t(){var e,r,n,i,a,s;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(Object.keys(null!==(e=this.actionsConfig)&&void 0!==e?e:{}).length>0&&(this.actions=this.getStoreActionsMap()),n=this.onInit,i=null!==(r=this.callbacks)&&void 0!==r?r:{},a=i.onInit,n||a){t.next=6;break}return t.abrupt("return");case 6:s=this.getConfigCallbackParam(),null==n||n(s),(0,d.isNil)(a)||null==a||a(s);case 9:case"end":return t.stop()}}),t,this)})))},this.executeSetStateForSubscriber=function(t,e){var r,n,i=t.selector,o=t.callback,s=t.currentState,u=t.config;if(!e.forceUpdate&&(null!==(r=null==u?void 0:u.isEqualRoot)&&void 0!==r?r:function(t,e){return t===e})(e.currentRootState,e.newRootState))return{didUpdate:!1};var c=i?i(e.newRootState):e.newRootState;return!e.forceUpdate&&(null!==(n=null==u?void 0:u.isEqual)&&void 0!==n?n:function(t,e){return t===e})(s,c)?{didUpdate:!1}:(a.partialUpdateSubscription(t.subscriptionId,{currentState:c}),o({state:c},{identifier:e.identifier}),{didUpdate:!0})},this.setState=function(t,e){var r=t.state,i=e.forceUpdate,o=e.identifier,s=a.stateWrapper.state;if(i||s!==r){a.stateWrapper={state:r};var u,c={forceUpdate:i,newRootState:r,currentRootState:s,identifier:o},l=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=n(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var i=0,o=function(){};return{s:o,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){u=!0,a=t},f:function(){try{s||null==r.return||r.return()}finally{if(u)throw a}}}}(a.subscribers.values());try{for(l.s();!(u=l.n()).done;){var f=u.value;a.executeSetStateForSubscriber(f,c)}}catch(t){l.e(t)}finally{l.f()}}},this.setMetadata=function(t){var e=(0,p.isFunction)(t)?t(a.metadata):t;a.metadata=e},this.getMetadata=function(){return a.metadata},this.getState=function(t,e,r){var n;if(!t)return a.stateWrapper.state;var i=(0,p.isFunction)(e),o=i?t:void 0,s=i?e:t,u=null!==(n=i?r:e)&&void 0!==n?n:void 0,c=o?o(a.stateWrapper.state):a.stateWrapper.state;(null==u?void 0:u.skipFirst)||s(c);var l=(0,y.uniqueId)("gs:");return a.setOrUpdateSubscription({subscriptionId:l,selector:o,config:u,currentState:c,callback:function(t){var e=t.state;return s(e)},isSetStateCallback:!1}),function(){a.subscribers.delete(l)}},this.getConfigCallbackParam=function(){var t=a.setMetadata,e=a.getMetadata,r=a.getState,n=a.actions;return{setMetadata:t,getMetadata:e,getState:r,setState:a.setStateWrapper,actions:n}},this.lastSubscriptionId=null,this.setOrUpdateSubscription=function(t){var e=t.subscriptionId;if(!e)return{isNewSubscription:!1};var r=a.subscribers.get(e);return(0,v.isRecord)(r)?(Object.assign(r,t),{isNewSubscription:!1}):(a.executeOnSubscribed(),a.subscribers.set(e,t),a.lastSubscriptionId=e,{isNewSubscription:!0})},this.partialUpdateSubscription=function(t,e){var r=a.subscribers.get(t);(0,v.isRecord)(r)&&Object.assign(r,e)},this.executeOnSubscribed=function(){var t,e=a.onSubscribed,r=null===(t=a.callbacks)||void 0===t?void 0:t.onSubscribed;if(e||r){var n=a.getConfigCallbackParam();null==e||e(n),null==r||r(n)}},this.getHook=function(){var t=function(t){var e,n,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(a.wasDisposed)throw new Error("The global state was disposed");var o=Array.isArray(i)?{dependencies:i}:null!=i?i:{},s=(0,f.useRef)({subscriptionId:null,tempInitialRootState:a.stateWrapper.state}),u=function(){return t?{state:t(a.stateWrapper.state)}:a.stateWrapper},c=r((0,f.useState)(u),2),l=c[0],p=c[1];(0,f.useEffect)((function(){if(!(0,d.isNil)(s.current)){(0,d.isNil)(s.current.subscriptionId)&&(s.current.subscriptionId=(0,y.uniqueId)("ss:"));var e=s.current.subscriptionId,r={subscriptionId:e,currentState:l.state,selector:t,config:o,callback:p,isSetStateCallback:!0};return a.setOrUpdateSubscription(r).isNewSubscription&&(a.executeSetStateForSubscriber(r,{forceUpdate:!1,newRootState:a.stateWrapper.state,currentRootState:s.current.tempInitialRootState===S.uniqueSymbol?a.stateWrapper.state:s.current.tempInitialRootState,identifier:"on mount state update"}),s.current.tempInitialRootState=S.uniqueSymbol),function(){a.subscribers.delete(e)}}}),[]);var v=(0,h.isString)(null===(e=s.current)||void 0===e?void 0:e.subscriptionId)?s.current.subscriptionId:"",b=a.subscribers.get(v),g=(null!==(n=null==b?void 0:b.config)&&void 0!==n?n:{dependencies:o.dependencies}).dependencies;return a.partialUpdateSubscription(v,{currentState:l.state,selector:t,config:o,callback:p}),[a.computeSelectedState({selector:t,subscriptionId:v,config:o,currentDependencies:g,computeChildState:u,stateWrapperRef:l}),a.getStateOrchestrator(),a.metadata]};return t.stateControls=a.stateControls,t.createSelectorHook=a.createSelectorHook,t.createObservable=a.createObservable,t.removeSubscriptions=a.removeSubscriptions,t.dispose=a.dispose,t},this.computeSelectedState=function(t){var e=t.selector,r=t.subscriptionId,n=t.config,i=t.currentDependencies,o=t.computeChildState,s=t.stateWrapperRef;if(!e||!r)return s.state;var u=n.dependencies;if(i===u)return s.state;if((null==i?void 0:i.length)===(null==u?void 0:u.length)&&(0,b.shallowCompare)(i,u))return s.state;var c=o().state;return a.partialUpdateSubscription(r,{currentState:c}),s.state=c,c},this.createSelectorHook=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=n.isEqualRoot,o=n.isEqual,s=n.name,u=r(a.stateControls(),3),c=u[0],l=u[1],f=u[2],d=c(),h=(null!=e?e:function(t){return t})(d),v=new t(h,{name:null!=s?s:(0,y.uniqueId)("sh:")}),b=r(v.stateControls(),2),g=b[0],S=b[1],m=c((function(t){if(!(null!=i?i:Object.is)(d,t)){d=t;var r=e(t);(null!=o?o:Object.is)(h,r)||(h=r,S(r))}}),{skipFirst:!0}),w=v.getHook(),O=function(t,e){return[r((0,p.isFunction)(t)?w(t,e):w(),1)[0],l,f]};return O.stateControls=function(){return[g,l,f]},O.createSelectorHook=a.createSelectorHook.bind(O),O.createObservable=a.createObservable.bind(O),O.removeSubscriptions=function(){m(),v.removeSubscriptions()},O.dispose=function(){O.removeSubscriptions(),v.dispose()},O},this.stateControls=function(){var t=a.getStateOrchestrator(),e=a.getMetadata;return[a.getState,t,e]},this.getStateOrchestrator=function(){return a.actions?a.actions:a.setStateWrapper},this.setStateWrapper=function(t){var e,r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=n.forceUpdate,o=n.identifier,s=a.stateWrapper.state,u=(0,p.isFunction)(t)?t(s):t;if(i||a.stateWrapper.state!==u){var c=a.setMetadata,l=a.getMetadata,f=a.getState,d=a.actions,h={setMetadata:c,getMetadata:l,setState:a.setState,getState:f,actions:d,previousState:s,state:u,identifier:o},v=a.computePreventStateChange,b=null===(e=a.callbacks)||void 0===e?void 0:e.computePreventStateChange;if(v||b)if((null==v?void 0:v(h))||(null==b?void 0:b(h)))return;a.setState({state:u},{forceUpdate:i,identifier:o});var g=a.onStateChanged,y=null===(r=a.callbacks)||void 0===r?void 0:r.onStateChanged;(g||y)&&(null==g||g(h),null==y||y(h))}},this.getStoreActionsMap=function(){if(!(0,v.isRecord)(a.actionsConfig))return null;var t=a.actionsConfig,e=a.setMetadata,r=a.setStateWrapper,n=a.getState,i=a.getMetadata,o=Object.keys(t).reduce((function(a,u){var c,l,f;return Object.assign(a,(c={},f=function(){for(var a=t[u],s=arguments.length,c=new Array(s),l=0;l<s;l++)c[l]=arguments[l];var f=a.apply(o,c);return"function"!=typeof f&&(0,g.throwWrongKeyOnActionCollectionConfig)(u),f.call(o,{setState:r,getState:n,setMetadata:e,getMetadata:i,actions:o})},(l=s(l=u))in c?Object.defineProperty(c,l,{value:f,enumerable:!0,configurable:!0,writable:!0}):c[l]=f,c)),a}),{});return o},this.removeSubscriptions=function(){a.subscribers.clear()},this.dispose=function(){a.wasDisposed=!0,a.removeSubscriptions(),a._name="",a.actionsConfig=null,a.callbacks=null,a.metadata={},a.actions=null,a.subscribers.clear(),a.stateWrapper={state:null}};var l=c.metadata,O=c.callbacks,E=c.actions,_=c.name;this.stateWrapper={state:e},this._name=null!=_?_:(0,y.uniqueId)("gs:"),this.metadata=null!=l?l:{},this.callbacks=null!=O?O:null,this.actionsConfig=null!=E?E:null;var j="";if((w.REACT_GLOBAL_STATE_HOOK_DEBUG||w.REACT_GLOBAL_STATE_TEMP_HOOKS)&&(j=(0,m.generateStackHash)(null!==(i=(new Error).stack)&&void 0!==i?i:"")),w.REACT_GLOBAL_STATE_HOOK_DEBUG)w.REACT_GLOBAL_STATE_HOOK_DEBUG(this,c,j);else if(w.REACT_GLOBAL_STATE_TEMP_HOOKS){var x=void 0!==globalThis.WeakRef?new globalThis.WeakRef(this):this,C=void 0!==globalThis.WeakRef?new globalThis.WeakRef(c):c;w.REACT_GLOBAL_STATE_TEMP_HOOKS.set(j,[x,C])}this.constructor!==t||this.initialize()}var e,i,c;return e=t,i=[{key:"createObservable",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=e.isEqualRoot,i=e.isEqual,o=e.name,a=r(this.stateControls(),1)[0],s=[],u=a(),c=(null!=t?t:function(t){return t})(a()),l=a((function(e){if(!(null!=n?n:Object.is)(u,e)){u=e;var r=t(e);(null!=i?i:Object.is)(c,r)||(c=r,s.forEach((function(t){return t()})))}}),{skipFirst:!0}),f=function(t,e,r){var n;if(!t)return c;var i=(0,p.isFunction)(e),o=i?t:void 0,a=i?e:t,u=null!==(n=i?r:e)&&void 0!==n?n:void 0,l=function(){return a(o?o(c):c)};(null==u?void 0:u.skipFirst)||l();var f=function(){l()};return s.push(f),function(){s.splice(s.indexOf(f),1)}};return f._name=null!=o?o:(0,y.uniqueId)("ob:"),f.createObservable=this.createObservable.bind(f),f.removeSubscriptions=function(){s.forEach((function(t){return t()})),s.length=0,l()},f.stateControls=function(){return[f]},f}}],i&&a(e.prototype,i),c&&a(e,c),Object.defineProperty(e,"prototype",{writable:!1}),t}();t.GlobalStore=O,t.default=O})(),l})()));
@@ -1,4 +1,4 @@
1
- import { ActionCollectionConfig, StoreTools, BaseMetadata, StateChanges } from './types';
1
+ import type { ActionCollectionConfig, StoreTools, BaseMetadata, StateChanges } from './types';
2
2
  import { GlobalStore } from './GlobalStore';
3
3
  /**
4
4
  * @description
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react")):"function"==typeof define&&define.amd?define(["react"],e):"object"==typeof exports?exports["react-hooks-global-states"]=e(require("react")):t["react-hooks-global-states"]=e(t.react)}(this,(t=>(()=>{var e={774:(t,e,r)=>{"use strict";function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function o(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],c=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);c=!0);}catch(t){s=!0,o=t}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return u}}(t,e)||i(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(t,e){if(t){if("string"==typeof t)return a(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?a(t,e):void 0}}function a(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function u(){u=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function l(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var i=e&&e.prototype instanceof v?e:v,a=Object.create(i.prototype),u=new x(n||[]);return o(a,"_invoke",{value:_(t,r,u)}),a}function p(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=f;var d={};function v(){}function b(){}function h(){}var y={};l(y,a,(function(){return this}));var m=Object.getPrototypeOf,g=m&&m(m(k([])));g&&g!==e&&r.call(g,a)&&(y=g);var S=h.prototype=v.prototype=Object.create(y);function O(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){function i(o,a,u,c){var s=p(t[o],t,a);if("throw"!==s.type){var l=s.arg,f=l.value;return f&&"object"==n(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){i("next",t,u,c)}),(function(t){i("throw",t,u,c)})):e.resolve(f).then((function(t){l.value=t,u(l)}),(function(t){return i("throw",t,u,c)}))}c(s.arg)}var a;o(this,"_invoke",{value:function(t,r){function n(){return new e((function(e,n){i(t,r,e,n)}))}return a=a?a.then(n,n):n()}})}function _(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return C()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var u=E(a,r);if(u){if(u===d)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=p(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===d)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}function E(t,e){var r=e.method,n=t.iterator[r];if(void 0===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=void 0,E(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),d;var o=p(n,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,d;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,d):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,d)}function j(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function A(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function x(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(j,this),this.reset(!0)}function k(t){if(t){var e=t[a];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,o=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:C}}function C(){return{value:void 0,done:!0}}return b.prototype=h,o(S,"constructor",{value:h,configurable:!0}),o(h,"constructor",{value:b,configurable:!0}),b.displayName=l(h,s,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===b||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,h):(t.__proto__=h,l(t,s,"GeneratorFunction")),t.prototype=Object.create(S),t},t.awrap=function(t){return{__await:t}},O(w.prototype),l(w.prototype,c,(function(){return this})),t.AsyncIterator=w,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new w(f(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},O(S),l(S,s,"Generator"),l(S,a,(function(){return this})),l(S,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},t.values=k,x.prototype={constructor:x,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(A),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var u=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(u&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,d):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),d},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),A(r),d}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;A(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:k(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),d}},t}function c(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,s(n.key),n)}}function s(t){var e=function(t,e){if("object"!==n(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var o=r.call(t,e||"default");if("object"!==n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"===n(e)?e:String(e)}var l=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function a(t){try{c(n.next(t))}catch(t){i(t)}}function u(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,u)}c((n=n.apply(t,e||[])).next())}))};Object.defineProperty(e,"__esModule",{value:!0}),e.GlobalStore=void 0;var f=r(156),p=r(244),d=r(125),v=r(281),b=r(143),h=r(561),y=r(400),m=r(157),g=r(605),S=r(748),O=globalThis;!function(){if(!O.REACT_GLOBAL_STATE_HOOK_DEBUG&&!(0,d.isNil)(O.sessionStorage)){try{if(!O.sessionStorage.getItem("REACT_GLOBAL_STATE_HOOK_DEBUG"))return}catch(t){return}O.REACT_GLOBAL_STATE_TEMP_HOOKS=new Map,setTimeout((function(){O.REACT_GLOBAL_STATE_TEMP_HOOKS=null}),6e4)}}();var w=function(){function t(e){var r,n=this,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{metadata:{}};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.wasDisposed=!1,this.actionsConfig=null,this.callbacks=null,this.actions=null,this.subscribers=new Map,this.initialize=function(){return l(n,void 0,void 0,u().mark((function t(){var e,r,n,o,i,a;return u().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(Object.keys(null!==(e=this.actionsConfig)&&void 0!==e?e:{}).length>0&&(this.actions=this.getStoreActionsMap()),n=this.onInit,o=null!==(r=this.callbacks)&&void 0!==r?r:{},i=o.onInit,n||i){t.next=6;break}return t.abrupt("return");case 6:a=this.getConfigCallbackParam(),null==n||n(a),(0,d.isNil)(i)||null==i||i(a);case 9:case"end":return t.stop()}}),t,this)})))},this.executeSetStateForSubscriber=function(t,e){var r,o,i=t.selector,a=t.callback,u=t.currentState,c=t.config;if(!e.forceUpdate&&(null!==(r=null==c?void 0:c.isEqualRoot)&&void 0!==r?r:function(t,e){return t===e})(e.currentRootState,e.newRootState))return{didUpdate:!1};var s=i?i(e.newRootState):e.newRootState;return!e.forceUpdate&&(null!==(o=null==c?void 0:c.isEqual)&&void 0!==o?o:function(t,e){return t===e})(u,s)?{didUpdate:!1}:(n.partialUpdateSubscription(t.subscriptionId,{currentState:s}),a({state:s},{identifier:e.identifier}),{didUpdate:!0})},this.setState=function(t,e){var r=t.state,o=e.forceUpdate,a=e.identifier,u=n.stateWrapper.state;if(o||u!==r){n.stateWrapper={state:r};var c,s={forceUpdate:o,newRootState:r,currentRootState:u,identifier:a},l=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=i(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,u=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return u=t.done,t},e:function(t){c=!0,a=t},f:function(){try{u||null==r.return||r.return()}finally{if(c)throw a}}}}(n.subscribers.values());try{for(l.s();!(c=l.n()).done;){var f=c.value;n.executeSetStateForSubscriber(f,s)}}catch(t){l.e(t)}finally{l.f()}}},this.setMetadata=function(t){var e=(0,p.isFunction)(t)?t(n.metadata):t;n.metadata=e},this.getMetadata=function(){return n.metadata},this.getState=function(t,e,r){var o;if(!t)return n.stateWrapper.state;var i=(0,p.isFunction)(e),a=i?t:void 0,u=i?e:t,c=null!==(o=i?r:e)&&void 0!==o?o:void 0,s=a?a(n.stateWrapper.state):n.stateWrapper.state;(null==c?void 0:c.skipFirst)||u(s);var l=(0,m.uniqueId)("gs:");return n.setOrUpdateSubscription({subscriptionId:l,selector:a,config:c,currentState:s,callback:function(t){var e=t.state;return u(e)},isSetStateCallback:!1}),function(){n.subscribers.delete(l)}},this.getConfigCallbackParam=function(){var t=n.setMetadata,e=n.getMetadata,r=n.getState,o=n.actions;return{setMetadata:t,getMetadata:e,getState:r,setState:n.setStateWrapper,actions:o}},this.lastSubscriptionId=null,this.setOrUpdateSubscription=function(t){var e=t.subscriptionId;if(!e)return{isNewSubscription:!1};var r=n.subscribers.get(e);return(0,b.isRecord)(r)?(Object.assign(r,t),{isNewSubscription:!1}):(n.executeOnSubscribed(),n.subscribers.set(e,t),n.lastSubscriptionId=e,{isNewSubscription:!0})},this.partialUpdateSubscription=function(t,e){var r=n.subscribers.get(t);(0,b.isRecord)(r)&&Object.assign(r,e)},this.executeOnSubscribed=function(){var t,e=n.onSubscribed,r=null===(t=n.callbacks)||void 0===t?void 0:t.onSubscribed;if(e||r){var o=n.getConfigCallbackParam();null==e||e(o),null==r||r(o)}},this.getHook=function(){var t=function(t){var e,r,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(n.wasDisposed)throw new Error("The global state was disposed");var a=Array.isArray(i)?{dependencies:i}:null!=i?i:{},u=(0,f.useRef)({subscriptionId:null,tempInitialRootState:n.stateWrapper.state}),c=function(){return t?{state:t(n.stateWrapper.state)}:n.stateWrapper},s=o((0,f.useState)(c),2),l=s[0],p=s[1];(0,f.useEffect)((function(){if(!(0,d.isNil)(u.current)){(0,d.isNil)(u.current.subscriptionId)&&(u.current.subscriptionId=(0,m.uniqueId)("ss:"));var e=u.current.subscriptionId,r={subscriptionId:e,currentState:l.state,selector:t,config:a,callback:p,isSetStateCallback:!0};return n.setOrUpdateSubscription(r).isNewSubscription&&(n.executeSetStateForSubscriber(r,{forceUpdate:!1,newRootState:n.stateWrapper.state,currentRootState:u.current.tempInitialRootState===g.uniqueSymbol?n.stateWrapper.state:u.current.tempInitialRootState,identifier:"on mount state update"}),u.current.tempInitialRootState=g.uniqueSymbol),function(){n.subscribers.delete(e)}}}),[]);var b=(0,v.isString)(null===(e=u.current)||void 0===e?void 0:e.subscriptionId)?u.current.subscriptionId:"",h=n.subscribers.get(b),y=(null!==(r=null==h?void 0:h.config)&&void 0!==r?r:{dependencies:a.dependencies}).dependencies;return n.partialUpdateSubscription(b,{currentState:l.state,selector:t,config:a,callback:p}),[n.computeSelectedState({selector:t,subscriptionId:b,config:a,currentDependencies:y,computeChildState:c,stateWrapperRef:l}),n.getStateOrchestrator(),n.metadata]};return t.stateControls=n.stateControls,t.createSelectorHook=n.createSelectorHook,t.createObservable=n.createObservable,t.removeSubscriptions=n.removeSubscriptions,t.dispose=n.dispose,t},this.computeSelectedState=function(t){var e=t.selector,r=t.subscriptionId,o=t.config,i=t.currentDependencies,a=t.computeChildState,u=t.stateWrapperRef;if(!e||!r)return u.state;var c=o.dependencies;if(i===c)return u.state;if((null==i?void 0:i.length)===(null==c?void 0:c.length)&&(0,h.shallowCompare)(i,c))return u.state;var s=a().state;return n.partialUpdateSubscription(r,{currentState:s}),u.state=s,s},this.createSelectorHook=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=r.isEqualRoot,a=r.isEqual,u=r.name,c=o(n.stateControls(),3),s=c[0],l=c[1],f=c[2],d=s(),v=(null!=e?e:function(t){return t})(d),b=new t(v,{name:null!=u?u:(0,m.uniqueId)("sh:")}),h=o(b.stateControls(),2),y=h[0],g=h[1],S=s((function(t){if(!(null!=i?i:Object.is)(d,t)){d=t;var r=e(t);(null!=a?a:Object.is)(v,r)||(v=r,g(r))}}),{skipFirst:!0}),O=b.getHook(),w=function(t,e){return[o((0,p.isFunction)(t)?O(t,e):O(),1)[0],l,f]};return w.stateControls=function(){return[y,l,f]},w.createSelectorHook=n.createSelectorHook.bind(w),w.createObservable=n.createObservable.bind(w),w.removeSubscriptions=function(){S(),b.removeSubscriptions()},w.dispose=function(){w.removeSubscriptions(),b.dispose()},w},this.stateControls=function(){var t=n.getStateOrchestrator(),e=n.getMetadata;return[n.getState,t,e]},this.getStateOrchestrator=function(){return n.actions?n.actions:n.setStateWrapper},this.setStateWrapper=function(t){var e,r,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=o.forceUpdate,a=o.identifier,u=n.stateWrapper.state,c=(0,p.isFunction)(t)?t(u):t;if(i||n.stateWrapper.state!==c){var s=n.setMetadata,l=n.getMetadata,f=n.getState,d=n.actions,v={setMetadata:s,getMetadata:l,setState:n.setState,getState:f,actions:d,previousState:u,state:c,identifier:a},b=n.computePreventStateChange,h=null===(e=n.callbacks)||void 0===e?void 0:e.computePreventStateChange;if(b||h)if((null==b?void 0:b(v))||(null==h?void 0:h(v)))return;n.setState({state:c},{forceUpdate:i,identifier:a});var y=n.onStateChanged,m=null===(r=n.callbacks)||void 0===r?void 0:r.onStateChanged;(y||m)&&(null==y||y(v),null==m||m(v))}},this.getStoreActionsMap=function(){if(!(0,b.isRecord)(n.actionsConfig))return null;var t=n.actionsConfig,e=n.setMetadata,r=n.setStateWrapper,o=n.getState,i=n.getMetadata,a=Object.keys(t).reduce((function(n,u){var c,l,f;return Object.assign(n,(c={},f=function(){for(var n=t[u],c=arguments.length,s=new Array(c),l=0;l<c;l++)s[l]=arguments[l];var f=n.apply(a,s);return"function"!=typeof f&&(0,y.throwWrongKeyOnActionCollectionConfig)(u),f.call(a,{setState:r,getState:o,setMetadata:e,getMetadata:i,actions:a})},(l=s(l=u))in c?Object.defineProperty(c,l,{value:f,enumerable:!0,configurable:!0,writable:!0}):c[l]=f,c)),n}),{});return a},this.removeSubscriptions=function(){n.subscribers.clear()},this.dispose=function(){n.wasDisposed=!0,n.removeSubscriptions(),n._name="",n.actionsConfig=null,n.callbacks=null,n.metadata={},n.actions=null,n.subscribers.clear(),n.stateWrapper={state:null}};var c=a.metadata,w=a.callbacks,_=a.actions,E=a.name;this.stateWrapper={state:e},this._name=null!=E?E:(0,m.uniqueId)("gs:"),this.metadata=null!=c?c:{},this.callbacks=null!=w?w:null,this.actionsConfig=null!=_?_:null;var j="";if((O.REACT_GLOBAL_STATE_HOOK_DEBUG||O.REACT_GLOBAL_STATE_TEMP_HOOKS)&&(j=(0,S.generateStackHash)(null!==(r=(new Error).stack)&&void 0!==r?r:"")),O.REACT_GLOBAL_STATE_HOOK_DEBUG)O.REACT_GLOBAL_STATE_HOOK_DEBUG(this,a,j);else if(O.REACT_GLOBAL_STATE_TEMP_HOOKS){var A=void 0!==globalThis.WeakRef?new globalThis.WeakRef(this):this,x=void 0!==globalThis.WeakRef?new globalThis.WeakRef(a):a;O.REACT_GLOBAL_STATE_TEMP_HOOKS.set(j,[A,x])}this.constructor!==t||this.initialize()}var e,r,n;return e=t,r=[{key:"createObservable",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=e.isEqualRoot,n=e.isEqual,i=e.name,a=o(this.stateControls(),1)[0],u=[],c=a(),s=(null!=t?t:function(t){return t})(a()),l=a((function(e){if(!(null!=r?r:Object.is)(c,e)){c=e;var o=t(e);(null!=n?n:Object.is)(s,o)||(s=o,u.forEach((function(t){return t()})))}}),{skipFirst:!0}),f=function(t,e,r){var n;if(!t)return s;var o=(0,p.isFunction)(e),i=o?t:void 0,a=o?e:t,c=null!==(n=o?r:e)&&void 0!==n?n:void 0,l=function(){return a(i?i(s):s)};(null==c?void 0:c.skipFirst)||l();var f=function(){l()};return u.push(f),function(){u.splice(u.indexOf(f),1)}};return f._name=null!=i?i:(0,m.uniqueId)("ob:"),f.createObservable=this.createObservable.bind(f),f.removeSubscriptions=function(){u.forEach((function(t){return t()})),u.length=0,l()},f.stateControls=function(){return[f]},f}}],r&&c(e.prototype,r),n&&c(e,n),Object.defineProperty(e,"prototype",{writable:!1}),t}();e.GlobalStore=w,e.default=w},748:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.generateStackHash=void 0;e.generateStackHash=function(t){if(!t.trim())return"unknown";t=t.replace(/\s/g,"");for(var e=2166136261,r=0;r<t.length;r++)e^=t.charCodeAt(r),e*=16777619,e&=4294967295;return function(t){for(var e="";t>0;)e="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[t%62]+e,t=Math.floor(t/62);return e||"0"}(e>>>0)},e.default=e.generateStackHash},143:(t,e,r)=>{"use strict";function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}Object.defineProperty(e,"__esModule",{value:!0}),e.isRecord=void 0;var o=r(125);e.isRecord=function(t){return!(0,o.isNil)(t)&&"object"===n(t)},e.default=e.isRecord},561:(t,e,r)=>{"use strict";function n(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],c=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);c=!0);}catch(t){s=!0,o=t}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return u}}(t,e)||i(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=i(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,u=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return u=t.done,t},e:function(t){c=!0,a=t},f:function(){try{u||null==r.return||r.return()}finally{if(c)throw a}}}}function i(t,e){if(t){if("string"==typeof t)return a(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?a(t,e):void 0}}function a(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function u(t){return u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(t)}Object.defineProperty(e,"__esModule",{value:!0}),e.shallowCompare=void 0;var c=r(416),s=r(231),l=r(125),f=r(143);e.shallowCompare=function(t,e){if(t===e)return!0;var r=u(t),i=u(e);if(r!==i)return!1;if((0,l.isNil)(t)||(0,l.isNil)(e)||(0,c.isPrimitive)(t)&&(0,c.isPrimitive)(e)||(0,s.isDate)(t)&&(0,s.isDate)(e)||"function"===r&&"function"===i)return t===e;if(Array.isArray(t)){var a=t,p=e;if(a.length!==p.length)return!1;for(var d=0;d<a.length;d++){if(a[d]!==p[d])return!1}}if(t instanceof Map){var v=t,b=e;if(v.size!==b.size)return!1;var h,y=o(v);try{for(y.s();!(h=y.n()).done;){var m=n(h.value,2),g=m[0];if(m[1]!==b.get(g))return!1}}catch(t){y.e(t)}finally{y.f()}}if(t instanceof Set){var S=t,O=e;if(S.size!==O.size)return!1;var w,_=o(S);try{for(_.s();!(w=_.n()).done;){var E=w.value;if(!O.has(E))return!1}}catch(t){_.e(t)}finally{_.f()}}if(!(0,f.isRecord)(t)||!(0,f.isRecord)(e))return t===e;var j=Object.keys(t),A=Object.keys(e);if(j.length!==A.length)return!1;for(var x=0,k=j;x<k.length;x++){var C=k[x];if(t[C]!==e[C])return!1}return!0},e.default=e.shallowCompare},400:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.throwWrongKeyOnActionCollectionConfig=void 0;e.throwWrongKeyOnActionCollectionConfig=function(t){throw new Error("[WRONG CONFIGURATION!]: Every key inside the storeActionsConfig must be a higher order function that returns a function \n[".concat(t,"]: key is not a valid function, try something like this: \n{\n\n ").concat(t,": (param) => ({ setState, getState, setMetadata, getMetadata, actions }) => {\n\n setState((state) => ({ ...state, ...param }))\n\n }\n\n}\n"))},e.default=e.throwWrongKeyOnActionCollectionConfig},157:(t,e)=>{"use strict";var r;Object.defineProperty(e,"__esModule",{value:!0}),e.uniqueId=void 0,e.uniqueId=(r=0,function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return r===Number.MAX_SAFE_INTEGER&&(r=0),t+Date.now().toString(36)+(r++).toString(36)}),e.default=e.uniqueId},605:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.uniqueSymbol=void 0,e.uniqueSymbol=Symbol("unique"),e.default=e.uniqueSymbol},231:function(t){t.exports=(()=>{"use strict";var t={};return(()=>{var e=t;Object.defineProperty(e,"__esModule",{value:!0}),e.isDate=void 0,e.isDate=function(t){return t instanceof Date}})(),t})()},244:function(t){t.exports=(()=>{"use strict";var t={};return(()=>{var e=t;Object.defineProperty(e,"__esModule",{value:!0}),e.isFunction=void 0,e.isFunction=function(t){return"function"==typeof t||t instanceof Function}})(),t})()},125:function(t){t.exports=(()=>{"use strict";var t={};return(()=>{var e=t;Object.defineProperty(e,"__esModule",{value:!0}),e.isNil=void 0,e.isNil=function(t){return null==t}})(),t})()},416:function(t){t.exports=(()=>{"use strict";var t={112:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isBoolean=void 0,e.isBoolean=function(t){return"boolean"==typeof t}},243:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isNil=void 0,e.isNil=function(t){return null==t}},11:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isNumber=void 0,e.isNumber=function(t){return"number"==typeof t}},671:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isString=void 0,e.isString=function(t){return"string"==typeof t}}},e={};function r(n){var o=e[n];if(void 0!==o)return o.exports;var i=e[n]={exports:{}};return t[n](i,i.exports,r),i.exports}var n={};return(()=>{var t=n;function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},e(t)}Object.defineProperty(t,"__esModule",{value:!0}),t.isPrimitive=void 0;var o=r(112),i=r(243),a=r(11),u=r(671);t.isPrimitive=function(t){return(0,i.isNil)(t)||(0,a.isNumber)(t)||(0,o.isBoolean)(t)||(0,u.isString)(t)||"symbol"===e(t)}})(),n})()},281:function(t){t.exports=(()=>{"use strict";var t={};return(()=>{var e=t;Object.defineProperty(e,"__esModule",{value:!0}),e.isString=void 0,e.isString=function(t){return"string"==typeof t}})(),t})()},156:e=>{"use strict";e.exports=t}},r={};function n(t){var o=r[t];if(void 0!==o)return o.exports;var i=r[t]={exports:{}};return e[t].call(i.exports,i,i.exports,n),i.exports}var o={};return(()=>{"use strict";var t=o;function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},e(t)}function r(t,r){for(var n=0;n<r.length;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,(i=o.key,a=void 0,a=function(t,r){if("object"!==e(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var o=n.call(t,r||"default");if("object"!==e(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}(i,"string"),"symbol"===e(a)?a:String(a)),o)}var i,a}function i(t,e){return i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},i(t,e)}function a(t){var r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,o=u(t);if(r){var i=u(this).constructor;n=Reflect.construct(o,arguments,i)}else n=o.apply(this,arguments);return function(t,r){if(r&&("object"===e(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(this,n)}}function u(t){return u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},u(t)}Object.defineProperty(t,"__esModule",{value:!0}),t.GlobalStoreAbstract=void 0;var c=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&i(t,e)}(c,t);var e,n,o,u=a(c);function c(){var t;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,c),(t=u.apply(this,arguments)).onInit=function(e){t.onInitialize(e)},t.onStateChanged=function(e){t.onChange(e)},t}return e=c,n&&r(e.prototype,n),o&&r(e,o),Object.defineProperty(e,"prototype",{writable:!1}),e}(n(774).GlobalStore);t.GlobalStoreAbstract=c,t.default=c})(),o})()));
1
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("./GlobalStore.js")):"function"==typeof define&&define.amd?define(["./GlobalStore.js"],e):"object"==typeof exports?exports["react-hooks-global-states"]=e(require("./GlobalStore.js")):t["react-hooks-global-states"]=e(t["./GlobalStore.js"])}(this,(t=>(()=>{"use strict";var e={352:e=>{e.exports=t}},r={};function o(t){var n=r[t];if(void 0!==n)return n.exports;var i=r[t]={exports:{}};return e[t](i,i.exports,o),i.exports}var n={};return(()=>{var t=n;function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},e(t)}function r(t,r){for(var o=0;o<r.length;o++){var n=r[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,(i=n.key,u=void 0,u=function(t,r){if("object"!==e(t)||null===t)return t;var o=t[Symbol.toPrimitive];if(void 0!==o){var n=o.call(t,r||"default");if("object"!==e(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}(i,"string"),"symbol"===e(u)?u:String(u)),n)}var i,u}function i(t,e){return i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},i(t,e)}function u(t){var r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var o,n=c(t);if(r){var i=c(this).constructor;o=Reflect.construct(n,arguments,i)}else o=n.apply(this,arguments);return function(t,r){if(r&&("object"===e(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(this,o)}}function c(t){return c=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},c(t)}Object.defineProperty(t,"__esModule",{value:!0}),t.GlobalStoreAbstract=void 0;var f=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&i(t,e)}(f,t);var e,o,n,c=u(f);function f(){var t;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,f),(t=c.apply(this,arguments)).onInit=function(e){t.onInitialize(e)},t.onStateChanged=function(e){t.onChange(e)},t}return e=f,o&&r(e.prototype,o),n&&r(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}(o(352).GlobalStore);t.GlobalStoreAbstract=f,t.default=f})(),n})()));
package/bundle.js CHANGED
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react")):"function"==typeof define&&define.amd?define(["react"],e):"object"==typeof exports?exports["react-hooks-global-states"]=e(require("react")):t["react-hooks-global-states"]=e(t.react)}(this,(t=>(()=>{var e={774:(t,e,r)=>{"use strict";function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function o(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],c=!0,l=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);c=!0);}catch(t){l=!0,o=t}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(l)throw o}}return u}}(t,e)||i(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(t,e){if(t){if("string"==typeof t)return a(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?a(t,e):void 0}}function a(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function u(){u=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",l=i.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var i=e&&e.prototype instanceof v?e:v,a=Object.create(i.prototype),u=new A(n||[]);return o(a,"_invoke",{value:_(t,r,u)}),a}function d(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=f;var p={};function v(){}function b(){}function y(){}var h={};s(h,a,(function(){return this}));var m=Object.getPrototypeOf,g=m&&m(m(P([])));g&&g!==e&&r.call(g,a)&&(h=g);var S=y.prototype=v.prototype=Object.create(h);function O(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){function i(o,a,u,c){var l=d(t[o],t,a);if("throw"!==l.type){var s=l.arg,f=s.value;return f&&"object"==n(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){i("next",t,u,c)}),(function(t){i("throw",t,u,c)})):e.resolve(f).then((function(t){s.value=t,u(s)}),(function(t){return i("throw",t,u,c)}))}c(l.arg)}var a;o(this,"_invoke",{value:function(t,r){function n(){return new e((function(e,n){i(t,r,e,n)}))}return a=a?a.then(n,n):n()}})}function _(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return x()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var u=j(a,r);if(u){if(u===p)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=d(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===p)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}function j(t,e){var r=e.method,n=t.iterator[r];if(void 0===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=void 0,j(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),p;var o=d(n,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,p;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,p):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,p)}function C(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function E(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function A(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(C,this),this.reset(!0)}function P(t){if(t){var e=t[a];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,o=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:x}}function x(){return{value:void 0,done:!0}}return b.prototype=y,o(S,"constructor",{value:y,configurable:!0}),o(y,"constructor",{value:b,configurable:!0}),b.displayName=s(y,l,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===b||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,y):(t.__proto__=y,s(t,l,"GeneratorFunction")),t.prototype=Object.create(S),t},t.awrap=function(t){return{__await:t}},O(w.prototype),s(w.prototype,c,(function(){return this})),t.AsyncIterator=w,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new w(f(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},O(S),s(S,l,"Generator"),s(S,a,(function(){return this})),s(S,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},t.values=P,A.prototype={constructor:A,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var u=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(u&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,p):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),p},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),E(r),p}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;E(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:P(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),p}},t}function c(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,l(n.key),n)}}function l(t){var e=function(t,e){if("object"!==n(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var o=r.call(t,e||"default");if("object"!==n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"===n(e)?e:String(e)}var s=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function a(t){try{c(n.next(t))}catch(t){i(t)}}function u(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,u)}c((n=n.apply(t,e||[])).next())}))};Object.defineProperty(e,"__esModule",{value:!0}),e.GlobalStore=void 0;var f=r(156),d=r(244),p=r(125),v=r(281),b=r(143),y=r(561),h=r(400),m=r(157),g=r(605),S=r(748),O=globalThis;!function(){if(!O.REACT_GLOBAL_STATE_HOOK_DEBUG&&!(0,p.isNil)(O.sessionStorage)){try{if(!O.sessionStorage.getItem("REACT_GLOBAL_STATE_HOOK_DEBUG"))return}catch(t){return}O.REACT_GLOBAL_STATE_TEMP_HOOKS=new Map,setTimeout((function(){O.REACT_GLOBAL_STATE_TEMP_HOOKS=null}),6e4)}}();var w=function(){function t(e){var r,n=this,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{metadata:{}};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.wasDisposed=!1,this.actionsConfig=null,this.callbacks=null,this.actions=null,this.subscribers=new Map,this.initialize=function(){return s(n,void 0,void 0,u().mark((function t(){var e,r,n,o,i,a;return u().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(Object.keys(null!==(e=this.actionsConfig)&&void 0!==e?e:{}).length>0&&(this.actions=this.getStoreActionsMap()),n=this.onInit,o=null!==(r=this.callbacks)&&void 0!==r?r:{},i=o.onInit,n||i){t.next=6;break}return t.abrupt("return");case 6:a=this.getConfigCallbackParam(),null==n||n(a),(0,p.isNil)(i)||null==i||i(a);case 9:case"end":return t.stop()}}),t,this)})))},this.executeSetStateForSubscriber=function(t,e){var r,o,i=t.selector,a=t.callback,u=t.currentState,c=t.config;if(!e.forceUpdate&&(null!==(r=null==c?void 0:c.isEqualRoot)&&void 0!==r?r:function(t,e){return t===e})(e.currentRootState,e.newRootState))return{didUpdate:!1};var l=i?i(e.newRootState):e.newRootState;return!e.forceUpdate&&(null!==(o=null==c?void 0:c.isEqual)&&void 0!==o?o:function(t,e){return t===e})(u,l)?{didUpdate:!1}:(n.partialUpdateSubscription(t.subscriptionId,{currentState:l}),a({state:l},{identifier:e.identifier}),{didUpdate:!0})},this.setState=function(t,e){var r=t.state,o=e.forceUpdate,a=e.identifier,u=n.stateWrapper.state;if(o||u!==r){n.stateWrapper={state:r};var c,l={forceUpdate:o,newRootState:r,currentRootState:u,identifier:a},s=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=i(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,u=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return u=t.done,t},e:function(t){c=!0,a=t},f:function(){try{u||null==r.return||r.return()}finally{if(c)throw a}}}}(n.subscribers.values());try{for(s.s();!(c=s.n()).done;){var f=c.value;n.executeSetStateForSubscriber(f,l)}}catch(t){s.e(t)}finally{s.f()}}},this.setMetadata=function(t){var e=(0,d.isFunction)(t)?t(n.metadata):t;n.metadata=e},this.getMetadata=function(){return n.metadata},this.getState=function(t,e,r){var o;if(!t)return n.stateWrapper.state;var i=(0,d.isFunction)(e),a=i?t:void 0,u=i?e:t,c=null!==(o=i?r:e)&&void 0!==o?o:void 0,l=a?a(n.stateWrapper.state):n.stateWrapper.state;(null==c?void 0:c.skipFirst)||u(l);var s=(0,m.uniqueId)("gs:");return n.setOrUpdateSubscription({subscriptionId:s,selector:a,config:c,currentState:l,callback:function(t){var e=t.state;return u(e)},isSetStateCallback:!1}),function(){n.subscribers.delete(s)}},this.getConfigCallbackParam=function(){var t=n.setMetadata,e=n.getMetadata,r=n.getState,o=n.actions;return{setMetadata:t,getMetadata:e,getState:r,setState:n.setStateWrapper,actions:o}},this.lastSubscriptionId=null,this.setOrUpdateSubscription=function(t){var e=t.subscriptionId;if(!e)return{isNewSubscription:!1};var r=n.subscribers.get(e);return(0,b.isRecord)(r)?(Object.assign(r,t),{isNewSubscription:!1}):(n.executeOnSubscribed(),n.subscribers.set(e,t),n.lastSubscriptionId=e,{isNewSubscription:!0})},this.partialUpdateSubscription=function(t,e){var r=n.subscribers.get(t);(0,b.isRecord)(r)&&Object.assign(r,e)},this.executeOnSubscribed=function(){var t,e=n.onSubscribed,r=null===(t=n.callbacks)||void 0===t?void 0:t.onSubscribed;if(e||r){var o=n.getConfigCallbackParam();null==e||e(o),null==r||r(o)}},this.getHook=function(){var t=function(t){var e,r,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(n.wasDisposed)throw new Error("The global state was disposed");var a=Array.isArray(i)?{dependencies:i}:null!=i?i:{},u=(0,f.useRef)({subscriptionId:null,tempInitialRootState:n.stateWrapper.state}),c=function(){return t?{state:t(n.stateWrapper.state)}:n.stateWrapper},l=o((0,f.useState)(c),2),s=l[0],d=l[1];(0,f.useEffect)((function(){if(!(0,p.isNil)(u.current)){(0,p.isNil)(u.current.subscriptionId)&&(u.current.subscriptionId=(0,m.uniqueId)("ss:"));var e=u.current.subscriptionId,r={subscriptionId:e,currentState:s.state,selector:t,config:a,callback:d,isSetStateCallback:!0};return n.setOrUpdateSubscription(r).isNewSubscription&&(n.executeSetStateForSubscriber(r,{forceUpdate:!1,newRootState:n.stateWrapper.state,currentRootState:u.current.tempInitialRootState===g.uniqueSymbol?n.stateWrapper.state:u.current.tempInitialRootState,identifier:"on mount state update"}),u.current.tempInitialRootState=g.uniqueSymbol),function(){n.subscribers.delete(e)}}}),[]);var b=(0,v.isString)(null===(e=u.current)||void 0===e?void 0:e.subscriptionId)?u.current.subscriptionId:"",y=n.subscribers.get(b),h=(null!==(r=null==y?void 0:y.config)&&void 0!==r?r:{dependencies:a.dependencies}).dependencies;return n.partialUpdateSubscription(b,{currentState:s.state,selector:t,config:a,callback:d}),[n.computeSelectedState({selector:t,subscriptionId:b,config:a,currentDependencies:h,computeChildState:c,stateWrapperRef:s}),n.getStateOrchestrator(),n.metadata]};return t.stateControls=n.stateControls,t.createSelectorHook=n.createSelectorHook,t.createObservable=n.createObservable,t.removeSubscriptions=n.removeSubscriptions,t.dispose=n.dispose,t},this.computeSelectedState=function(t){var e=t.selector,r=t.subscriptionId,o=t.config,i=t.currentDependencies,a=t.computeChildState,u=t.stateWrapperRef;if(!e||!r)return u.state;var c=o.dependencies;if(i===c)return u.state;if((null==i?void 0:i.length)===(null==c?void 0:c.length)&&(0,y.shallowCompare)(i,c))return u.state;var l=a().state;return n.partialUpdateSubscription(r,{currentState:l}),u.state=l,l},this.createSelectorHook=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=r.isEqualRoot,a=r.isEqual,u=r.name,c=o(n.stateControls(),3),l=c[0],s=c[1],f=c[2],p=l(),v=(null!=e?e:function(t){return t})(p),b=new t(v,{name:null!=u?u:(0,m.uniqueId)("sh:")}),y=o(b.stateControls(),2),h=y[0],g=y[1],S=l((function(t){if(!(null!=i?i:Object.is)(p,t)){p=t;var r=e(t);(null!=a?a:Object.is)(v,r)||(v=r,g(r))}}),{skipFirst:!0}),O=b.getHook(),w=function(t,e){return[o((0,d.isFunction)(t)?O(t,e):O(),1)[0],s,f]};return w.stateControls=function(){return[h,s,f]},w.createSelectorHook=n.createSelectorHook.bind(w),w.createObservable=n.createObservable.bind(w),w.removeSubscriptions=function(){S(),b.removeSubscriptions()},w.dispose=function(){w.removeSubscriptions(),b.dispose()},w},this.stateControls=function(){var t=n.getStateOrchestrator(),e=n.getMetadata;return[n.getState,t,e]},this.getStateOrchestrator=function(){return n.actions?n.actions:n.setStateWrapper},this.setStateWrapper=function(t){var e,r,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=o.forceUpdate,a=o.identifier,u=n.stateWrapper.state,c=(0,d.isFunction)(t)?t(u):t;if(i||n.stateWrapper.state!==c){var l=n.setMetadata,s=n.getMetadata,f=n.getState,p=n.actions,v={setMetadata:l,getMetadata:s,setState:n.setState,getState:f,actions:p,previousState:u,state:c,identifier:a},b=n.computePreventStateChange,y=null===(e=n.callbacks)||void 0===e?void 0:e.computePreventStateChange;if(b||y)if((null==b?void 0:b(v))||(null==y?void 0:y(v)))return;n.setState({state:c},{forceUpdate:i,identifier:a});var h=n.onStateChanged,m=null===(r=n.callbacks)||void 0===r?void 0:r.onStateChanged;(h||m)&&(null==h||h(v),null==m||m(v))}},this.getStoreActionsMap=function(){if(!(0,b.isRecord)(n.actionsConfig))return null;var t=n.actionsConfig,e=n.setMetadata,r=n.setStateWrapper,o=n.getState,i=n.getMetadata,a=Object.keys(t).reduce((function(n,u){var c,s,f;return Object.assign(n,(c={},f=function(){for(var n=t[u],c=arguments.length,l=new Array(c),s=0;s<c;s++)l[s]=arguments[s];var f=n.apply(a,l);return"function"!=typeof f&&(0,h.throwWrongKeyOnActionCollectionConfig)(u),f.call(a,{setState:r,getState:o,setMetadata:e,getMetadata:i,actions:a})},(s=l(s=u))in c?Object.defineProperty(c,s,{value:f,enumerable:!0,configurable:!0,writable:!0}):c[s]=f,c)),n}),{});return a},this.removeSubscriptions=function(){n.subscribers.clear()},this.dispose=function(){n.wasDisposed=!0,n.removeSubscriptions(),n._name="",n.actionsConfig=null,n.callbacks=null,n.metadata={},n.actions=null,n.subscribers.clear(),n.stateWrapper={state:null}};var c=a.metadata,w=a.callbacks,_=a.actions,j=a.name;this.stateWrapper={state:e},this._name=null!=j?j:(0,m.uniqueId)("gs:"),this.metadata=null!=c?c:{},this.callbacks=null!=w?w:null,this.actionsConfig=null!=_?_:null;var C="";if((O.REACT_GLOBAL_STATE_HOOK_DEBUG||O.REACT_GLOBAL_STATE_TEMP_HOOKS)&&(C=(0,S.generateStackHash)(null!==(r=(new Error).stack)&&void 0!==r?r:"")),O.REACT_GLOBAL_STATE_HOOK_DEBUG)O.REACT_GLOBAL_STATE_HOOK_DEBUG(this,a,C);else if(O.REACT_GLOBAL_STATE_TEMP_HOOKS){var E=void 0!==globalThis.WeakRef?new globalThis.WeakRef(this):this,A=void 0!==globalThis.WeakRef?new globalThis.WeakRef(a):a;O.REACT_GLOBAL_STATE_TEMP_HOOKS.set(C,[E,A])}this.constructor!==t||this.initialize()}var e,r,n;return e=t,r=[{key:"createObservable",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=e.isEqualRoot,n=e.isEqual,i=e.name,a=o(this.stateControls(),1)[0],u=[],c=a(),l=(null!=t?t:function(t){return t})(a()),s=a((function(e){if(!(null!=r?r:Object.is)(c,e)){c=e;var o=t(e);(null!=n?n:Object.is)(l,o)||(l=o,u.forEach((function(t){return t()})))}}),{skipFirst:!0}),f=function(t,e,r){var n;if(!t)return l;var o=(0,d.isFunction)(e),i=o?t:void 0,a=o?e:t,c=null!==(n=o?r:e)&&void 0!==n?n:void 0,s=function(){return a(i?i(l):l)};(null==c?void 0:c.skipFirst)||s();var f=function(){s()};return u.push(f),function(){u.splice(u.indexOf(f),1)}};return f._name=null!=i?i:(0,m.uniqueId)("ob:"),f.createObservable=this.createObservable.bind(f),f.removeSubscriptions=function(){u.forEach((function(t){return t()})),u.length=0,s()},f.stateControls=function(){return[f]},f}}],r&&c(e.prototype,r),n&&c(e,n),Object.defineProperty(e,"prototype",{writable:!1}),t}();e.GlobalStore=w,e.default=w},195:(t,e,r)=>{"use strict";function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function o(t,e){for(var r=0;r<e.length;r++){var o=e[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,(i=o.key,a=void 0,a=function(t,e){if("object"!==n(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var o=r.call(t,e||"default");if("object"!==n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(i,"string"),"symbol"===n(a)?a:String(a)),o)}var i,a}function i(t,e){return i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},i(t,e)}function a(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,o=u(t);if(e){var i=u(this).constructor;r=Reflect.construct(o,arguments,i)}else r=o.apply(this,arguments);return function(t,e){if(e&&("object"===n(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(this,r)}}function u(t){return u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},u(t)}Object.defineProperty(e,"__esModule",{value:!0}),e.GlobalStoreAbstract=void 0;var c=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&i(t,e)}(c,t);var e,r,n,u=a(c);function c(){var t;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,c),(t=u.apply(this,arguments)).onInit=function(e){t.onInitialize(e)},t.onStateChanged=function(e){t.onChange(e)},t}return e=c,r&&o(e.prototype,r),n&&o(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}(r(774).GlobalStore);e.GlobalStoreAbstract=c,e.default=c},564:(t,e,r)=>{"use strict";function n(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],c=!0,l=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);c=!0);}catch(t){l=!0,o=t}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(l)throw o}}return u}}(t,e)||function(t,e){if(!t)return;if("string"==typeof t)return o(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return o(t,e)}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}Object.defineProperty(e,"__esModule",{value:!0}),e.createContext=void 0;var i=r(156),a=r(774),u=r(244),c=r(125),l=r(965);e.createContext=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=(0,i.createContext)(null),o=function(){var t=(0,i.useContext)(r);if(!t)throw new Error("ContextHook must be used within a ContextProvider");return t()};o.createSelectorHook=function(t,e){return function(){var o=(0,i.useContext)(r);if((0,c.isNil)(o))throw new Error("SelectorHook must be used within a ContextProvider");return n((0,l.useStableState)((function(){return o.createSelectorHook(t,e)}),(function(t){return t.removeSubscriptions()}),[o]),1)[0].value.apply(void 0,arguments)}};var s=function(){var t=(0,i.useContext)(r);if((0,c.isNil)(t))throw new Error("useStateControls must be used within a ContextProvider");return t.stateControls()},f=function(t,e){var n=(0,i.useContext)(r);if((0,c.isNil)(n))throw new Error("useObservableBuilder must be used within a ContextProvider");return n.createObservable(t,e)};return o.stateControls=function(){return[s,f]},[o,function(o){var s=o.children,f=o.value,d=o.ref,p=n((0,l.useStableState)((function(){var r,n=function(){return(0,u.isFunction)(t)?t():t},o=(0,c.isNil)(f)?n():(0,u.isFunction)(f)?f(n()):f,i=new a.GlobalStore(o,Object.assign(Object.assign({},e),{metadata:null!==(r=(0,u.isFunction)(e.metadata)?e.metadata():e.metadata)&&void 0!==r?r:{}})),l=i.getHook();return{store:i,parentHook:l}}),(function(t){var e,r,n,o;t.store.dispose(),null===(r=null===(e=p.value.store.callbacks)||void 0===e?void 0:e.onUnMount)||void 0===r||r.call(e),null===(o=(n=p.value.store).__onUnMountContext)||void 0===o||o.call(n,p.value.store,p.value.parentHook)}),[]),1)[0];return(0,i.useImperativeHandle)(d,(function(){return d?p.value.store.getConfigCallbackParam():{}}),[p.value.store,d]),(0,i.createElement)(r.Provider,{value:p.value.parentHook},s)}]},e.default=e.createContext},362:(t,e,r)=>{"use strict";var n=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r};Object.defineProperty(e,"__esModule",{value:!0}),e.createCustomGlobalState=void 0;var o=r(196);e.createCustomGlobalState=function(t){var e=t.onInitialize,r=t.onChange;return function(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=i.callbacks,u=n(i,["callbacks"]);return(0,o.createGlobalState)(t,Object.assign(Object.assign({},u),{callbacks:Object.assign(Object.assign({},null!=a?a:{}),{onInit:function(t){var r;null==e||e(t,null==u?void 0:u.config),null===(r=null==a?void 0:a.onInit)||void 0===r||r.call(a,t)},onStateChanged:function(t){var e;null==r||r(t,null==u?void 0:u.config),null===(e=null==a?void 0:a.onStateChanged)||void 0===e||e.call(a,t)}})}))}},e.default=e.createCustomGlobalState},196:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.createGlobalState=void 0;var n=r(774);e.createGlobalState=function(t,e){return new n.GlobalStore(t,e).getHook()},e.default=e.createGlobalState},17:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.debounce=void 0;e.debounce=function(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return function(){for(var n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];e&&clearTimeout(e),e=setTimeout((function(){t.apply(void 0,o)}),r)}},e.default=e.debounce},748:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.generateStackHash=void 0;e.generateStackHash=function(t){if(!t.trim())return"unknown";t=t.replace(/\s/g,"");for(var e=2166136261,r=0;r<t.length;r++)e^=t.charCodeAt(r),e*=16777619,e&=4294967295;return function(t){for(var e="";t>0;)e="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[t%62]+e,t=Math.floor(t/62);return e||"0"}(e>>>0)},e.default=e.generateStackHash},143:(t,e,r)=>{"use strict";function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}Object.defineProperty(e,"__esModule",{value:!0}),e.isRecord=void 0;var o=r(125);e.isRecord=function(t){return!(0,o.isNil)(t)&&"object"===n(t)},e.default=e.isRecord},561:(t,e,r)=>{"use strict";function n(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],c=!0,l=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);c=!0);}catch(t){l=!0,o=t}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(l)throw o}}return u}}(t,e)||i(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=i(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,u=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return u=t.done,t},e:function(t){c=!0,a=t},f:function(){try{u||null==r.return||r.return()}finally{if(c)throw a}}}}function i(t,e){if(t){if("string"==typeof t)return a(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?a(t,e):void 0}}function a(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function u(t){return u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(t)}Object.defineProperty(e,"__esModule",{value:!0}),e.shallowCompare=void 0;var c=r(416),l=r(231),s=r(125),f=r(143);e.shallowCompare=function(t,e){if(t===e)return!0;var r=u(t),i=u(e);if(r!==i)return!1;if((0,s.isNil)(t)||(0,s.isNil)(e)||(0,c.isPrimitive)(t)&&(0,c.isPrimitive)(e)||(0,l.isDate)(t)&&(0,l.isDate)(e)||"function"===r&&"function"===i)return t===e;if(Array.isArray(t)){var a=t,d=e;if(a.length!==d.length)return!1;for(var p=0;p<a.length;p++){if(a[p]!==d[p])return!1}}if(t instanceof Map){var v=t,b=e;if(v.size!==b.size)return!1;var y,h=o(v);try{for(h.s();!(y=h.n()).done;){var m=n(y.value,2),g=m[0];if(m[1]!==b.get(g))return!1}}catch(t){h.e(t)}finally{h.f()}}if(t instanceof Set){var S=t,O=e;if(S.size!==O.size)return!1;var w,_=o(S);try{for(_.s();!(w=_.n()).done;){var j=w.value;if(!O.has(j))return!1}}catch(t){_.e(t)}finally{_.f()}}if(!(0,f.isRecord)(t)||!(0,f.isRecord)(e))return t===e;var C=Object.keys(t),E=Object.keys(e);if(C.length!==E.length)return!1;for(var A=0,P=C;A<P.length;A++){var x=P[A];if(t[x]!==e[x])return!1}return!0},e.default=e.shallowCompare},400:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.throwWrongKeyOnActionCollectionConfig=void 0;e.throwWrongKeyOnActionCollectionConfig=function(t){throw new Error("[WRONG CONFIGURATION!]: Every key inside the storeActionsConfig must be a higher order function that returns a function \n[".concat(t,"]: key is not a valid function, try something like this: \n{\n\n ").concat(t,": (param) => ({ setState, getState, setMetadata, getMetadata, actions }) => {\n\n setState((state) => ({ ...state, ...param }))\n\n }\n\n}\n"))},e.default=e.throwWrongKeyOnActionCollectionConfig},157:(t,e)=>{"use strict";var r;Object.defineProperty(e,"__esModule",{value:!0}),e.uniqueId=void 0,e.uniqueId=(r=0,function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return r===Number.MAX_SAFE_INTEGER&&(r=0),t+Date.now().toString(36)+(r++).toString(36)}),e.default=e.uniqueId},605:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.uniqueSymbol=void 0,e.uniqueSymbol=Symbol("unique"),e.default=e.uniqueSymbol},965:(t,e,r)=>{"use strict";function n(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],c=!0,l=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);c=!0);}catch(t){l=!0,o=t}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(l)throw o}}return u}}(t,e)||function(t,e){if(!t)return;if("string"==typeof t)return o(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return o(t,e)}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}Object.defineProperty(e,"__esModule",{value:!0}),e.useStableState=void 0;var i=r(156),a=r(244),u=r(125),c=r(561),l=r(156),s=r(156);e.useStableState=function(t){var e=(0,a.isFunction)(arguments.length<=1?void 0:arguments[1])?arguments.length<=1?void 0:arguments[1]:void 0,r=e?arguments.length<=2?void 0:arguments[2]:arguments.length<=1?void 0:arguments[1],o=(0,i.useRef)({builder:null,cleanup:e,dependencies:r}),f=(0,a.isFunction)(t)?t:function(){return t},d=n((0,l.useState)((function(){return{value:f()}})),2),p=d[0],v=d[1],b=(0,u.isNil)(o.current.builder),y=(0,u.isNil)(r)||!(0,c.shallowCompare)(o.current.dependencies,r);!b&&y&&(p.value=f()),o.current.dependencies=r,o.current.builder=f,o.current.cleanup=e;var h=(0,s.useCallback)((function(){v({value:o.current.builder()})}),[]);return(0,i.useEffect)((function(){return function(){o.current.cleanup&&o.current.cleanup(p.value)}}),[]),[p,h]},e.default=e.useStableState},231:function(t){t.exports=(()=>{"use strict";var t={};return(()=>{var e=t;Object.defineProperty(e,"__esModule",{value:!0}),e.isDate=void 0,e.isDate=function(t){return t instanceof Date}})(),t})()},244:function(t){t.exports=(()=>{"use strict";var t={};return(()=>{var e=t;Object.defineProperty(e,"__esModule",{value:!0}),e.isFunction=void 0,e.isFunction=function(t){return"function"==typeof t||t instanceof Function}})(),t})()},125:function(t){t.exports=(()=>{"use strict";var t={};return(()=>{var e=t;Object.defineProperty(e,"__esModule",{value:!0}),e.isNil=void 0,e.isNil=function(t){return null==t}})(),t})()},416:function(t){t.exports=(()=>{"use strict";var t={112:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isBoolean=void 0,e.isBoolean=function(t){return"boolean"==typeof t}},243:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isNil=void 0,e.isNil=function(t){return null==t}},11:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isNumber=void 0,e.isNumber=function(t){return"number"==typeof t}},671:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isString=void 0,e.isString=function(t){return"string"==typeof t}}},e={};function r(n){var o=e[n];if(void 0!==o)return o.exports;var i=e[n]={exports:{}};return t[n](i,i.exports,r),i.exports}var n={};return(()=>{var t=n;function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},e(t)}Object.defineProperty(t,"__esModule",{value:!0}),t.isPrimitive=void 0;var o=r(112),i=r(243),a=r(11),u=r(671);t.isPrimitive=function(t){return(0,i.isNil)(t)||(0,a.isNumber)(t)||(0,o.isBoolean)(t)||(0,u.isString)(t)||"symbol"===e(t)}})(),n})()},281:function(t){t.exports=(()=>{"use strict";var t={};return(()=>{var e=t;Object.defineProperty(e,"__esModule",{value:!0}),e.isString=void 0,e.isString=function(t){return"string"==typeof t}})(),t})()},156:e=>{"use strict";e.exports=t}},r={};function n(t){var o=r[t];if(void 0!==o)return o.exports;var i=r[t]={exports:{}};return e[t].call(i.exports,i,i.exports,n),i.exports}var o={};return(()=>{"use strict";var t=o;Object.defineProperty(t,"__esModule",{value:!0}),t.generateStackHash=t.createContext=t.useStableState=t.uniqueSymbol=t.isRecord=t.throwWrongKeyOnActionCollectionConfig=t.uniqueId=t.debounce=t.shallowCompare=t.createCustomGlobalState=t.createGlobalState=t.GlobalStoreAbstract=t.GlobalStore=void 0;var e=n(774);Object.defineProperty(t,"GlobalStore",{enumerable:!0,get:function(){return e.GlobalStore}});var r=n(195);Object.defineProperty(t,"GlobalStoreAbstract",{enumerable:!0,get:function(){return r.GlobalStoreAbstract}});var i=n(196);Object.defineProperty(t,"createGlobalState",{enumerable:!0,get:function(){return i.createGlobalState}});var a=n(362);Object.defineProperty(t,"createCustomGlobalState",{enumerable:!0,get:function(){return a.createCustomGlobalState}});var u=n(561);Object.defineProperty(t,"shallowCompare",{enumerable:!0,get:function(){return u.shallowCompare}});var c=n(17);Object.defineProperty(t,"debounce",{enumerable:!0,get:function(){return c.debounce}});var l=n(157);Object.defineProperty(t,"uniqueId",{enumerable:!0,get:function(){return l.uniqueId}});var s=n(400);Object.defineProperty(t,"throwWrongKeyOnActionCollectionConfig",{enumerable:!0,get:function(){return s.throwWrongKeyOnActionCollectionConfig}});var f=n(143);Object.defineProperty(t,"isRecord",{enumerable:!0,get:function(){return f.isRecord}});var d=n(605);Object.defineProperty(t,"uniqueSymbol",{enumerable:!0,get:function(){return d.uniqueSymbol}});var p=n(965);Object.defineProperty(t,"useStableState",{enumerable:!0,get:function(){return p.useStableState}});var v=n(564);Object.defineProperty(t,"createContext",{enumerable:!0,get:function(){return v.createContext}});var b=n(748);Object.defineProperty(t,"generateStackHash",{enumerable:!0,get:function(){return b.generateStackHash}})})(),o})()));
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("./GlobalStore.js"),require("./GlobalStoreAbstract.js"),require("./createContext.js"),require("./createCustomGlobalState.js"),require("./createGlobalState.js"),require("./generateStackHash.js"),require("./isRecord.js"),require("./shallowCompare.js"),require("./src/debounce.ts"),require("./throwWrongKeyOnActionCollectionConfig.js"),require("./uniqueId.js"),require("./uniqueSymbol.js"),require("./useStableState.js")):"function"==typeof define&&define.amd?define(["./GlobalStore.js","./GlobalStoreAbstract.js","./createContext.js","./createCustomGlobalState.js","./createGlobalState.js","./generateStackHash.js","./isRecord.js","./shallowCompare.js","./src/debounce.ts","./throwWrongKeyOnActionCollectionConfig.js","./uniqueId.js","./uniqueSymbol.js","./useStableState.js"],t):"object"==typeof exports?exports["react-hooks-global-states"]=t(require("./GlobalStore.js"),require("./GlobalStoreAbstract.js"),require("./createContext.js"),require("./createCustomGlobalState.js"),require("./createGlobalState.js"),require("./generateStackHash.js"),require("./isRecord.js"),require("./shallowCompare.js"),require("./src/debounce.ts"),require("./throwWrongKeyOnActionCollectionConfig.js"),require("./uniqueId.js"),require("./uniqueSymbol.js"),require("./useStableState.js")):e["react-hooks-global-states"]=t(e["./GlobalStore.js"],e["./GlobalStoreAbstract.js"],e["./createContext.js"],e["./createCustomGlobalState.js"],e["./createGlobalState.js"],e["./generateStackHash.js"],e["./isRecord.js"],e["./shallowCompare.js"],e["./src/debounce.ts"],e["./throwWrongKeyOnActionCollectionConfig.js"],e["./uniqueId.js"],e["./uniqueSymbol.js"],e["./useStableState.js"])}(this,((e,t,r,o,a,n,s,u,l,i,c,b,j)=>(()=>{"use strict";var S={352:t=>{t.exports=e},674:e=>{e.exports=t},104:e=>{e.exports=r},842:e=>{e.exports=o},963:e=>{e.exports=a},109:e=>{e.exports=n},664:e=>{e.exports=s},682:e=>{e.exports=u},297:e=>{e.exports=l},286:e=>{e.exports=i},865:e=>{e.exports=c},69:e=>{e.exports=b},503:e=>{e.exports=j}},p={};function f(e){var t=p[e];if(void 0!==t)return t.exports;var r=p[e]={exports:{}};return S[e](r,r.exports,f),r.exports}var d={};return(()=>{var e=d;Object.defineProperty(e,"__esModule",{value:!0}),e.generateStackHash=e.createContext=e.useStableState=e.uniqueSymbol=e.isRecord=e.throwWrongKeyOnActionCollectionConfig=e.uniqueId=e.debounce=e.shallowCompare=e.createCustomGlobalState=e.createGlobalState=e.GlobalStoreAbstract=e.GlobalStore=void 0;var t=f(352);Object.defineProperty(e,"GlobalStore",{enumerable:!0,get:function(){return t.GlobalStore}});var r=f(674);Object.defineProperty(e,"GlobalStoreAbstract",{enumerable:!0,get:function(){return r.GlobalStoreAbstract}});var o=f(963);Object.defineProperty(e,"createGlobalState",{enumerable:!0,get:function(){return o.createGlobalState}});var a=f(842);Object.defineProperty(e,"createCustomGlobalState",{enumerable:!0,get:function(){return a.createCustomGlobalState}});var n=f(682);Object.defineProperty(e,"shallowCompare",{enumerable:!0,get:function(){return n.shallowCompare}});var s=f(297);Object.defineProperty(e,"debounce",{enumerable:!0,get:function(){return s.debounce}});var u=f(865);Object.defineProperty(e,"uniqueId",{enumerable:!0,get:function(){return u.uniqueId}});var l=f(286);Object.defineProperty(e,"throwWrongKeyOnActionCollectionConfig",{enumerable:!0,get:function(){return l.throwWrongKeyOnActionCollectionConfig}});var i=f(664);Object.defineProperty(e,"isRecord",{enumerable:!0,get:function(){return i.isRecord}});var c=f(69);Object.defineProperty(e,"uniqueSymbol",{enumerable:!0,get:function(){return c.uniqueSymbol}});var b=f(503);Object.defineProperty(e,"useStableState",{enumerable:!0,get:function(){return b.useStableState}});var j=f(104);Object.defineProperty(e,"createContext",{enumerable:!0,get:function(){return j.createContext}});var S=f(109);Object.defineProperty(e,"generateStackHash",{enumerable:!0,get:function(){return S.generateStackHash}})})(),d})()));
@@ -1,5 +1,5 @@
1
- import { PropsWithChildren } from 'react';
2
- import { ActionCollectionConfig, StateSetter, ActionCollectionResult, StateGetter, BaseMetadata, MetadataSetter, GlobalStoreCallbacks, UseHookConfig, ObservableFragment, MetadataGetter } from './types';
1
+ import { type PropsWithChildren } from 'react';
2
+ import type { ActionCollectionConfig, StateSetter, ActionCollectionResult, StateGetter, BaseMetadata, MetadataSetter, GlobalStoreCallbacks, UseHookConfig, ObservableFragment, MetadataGetter } from './types';
3
3
  export type ContextProviderAPI<State, Metadata extends BaseMetadata | unknown> = {
4
4
  setMetadata: MetadataSetter<Metadata>;
5
5
  setState: StateSetter<State>;
package/createContext.js CHANGED
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react")):"function"==typeof define&&define.amd?define(["react"],e):"object"==typeof exports?exports["react-hooks-global-states"]=e(require("react")):t["react-hooks-global-states"]=e(t.react)}(this,(t=>{return e={774:(t,e,r)=>{"use strict";function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function o(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],c=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);c=!0);}catch(t){s=!0,o=t}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return u}}(t,e)||i(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(t,e){if(t){if("string"==typeof t)return a(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?a(t,e):void 0}}function a(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function u(){u=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function l(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var i=e&&e.prototype instanceof p?e:p,a=Object.create(i.prototype),u=new j(n||[]);return o(a,"_invoke",{value:_(t,r,u)}),a}function d(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=f;var v={};function p(){}function h(){}function b(){}var y={};l(y,a,(function(){return this}));var m=Object.getPrototypeOf,g=m&&m(m(x([])));g&&g!==e&&r.call(g,a)&&(y=g);var S=b.prototype=p.prototype=Object.create(y);function w(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function i(o,a,u,c){var s=d(t[o],t,a);if("throw"!==s.type){var l=s.arg,f=l.value;return f&&"object"==n(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){i("next",t,u,c)}),(function(t){i("throw",t,u,c)})):e.resolve(f).then((function(t){l.value=t,u(l)}),(function(t){return i("throw",t,u,c)}))}c(s.arg)}var a;o(this,"_invoke",{value:function(t,r){function n(){return new e((function(e,n){i(t,r,e,n)}))}return a=a?a.then(n,n):n()}})}function _(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var u=E(a,r);if(u){if(u===v)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=d(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===v)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}function E(t,e){var r=e.method,n=t.iterator[r];if(void 0===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=void 0,E(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),v;var o=d(n,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,v;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,v):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,v)}function C(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function A(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(C,this),this.reset(!0)}function x(t){if(t){var e=t[a];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,o=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:k}}function k(){return{value:void 0,done:!0}}return h.prototype=b,o(S,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:h,configurable:!0}),h.displayName=l(b,s,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,l(t,s,"GeneratorFunction")),t.prototype=Object.create(S),t},t.awrap=function(t){return{__await:t}},w(O.prototype),l(O.prototype,c,(function(){return this})),t.AsyncIterator=O,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new O(f(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},w(S),l(S,s,"Generator"),l(S,a,(function(){return this})),l(S,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},t.values=x,j.prototype={constructor:j,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(A),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var u=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(u&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,v):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),A(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;A(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:x(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),v}},t}function c(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,s(n.key),n)}}function s(t){var e=function(t,e){if("object"!==n(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var o=r.call(t,e||"default");if("object"!==n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"===n(e)?e:String(e)}var l=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function a(t){try{c(n.next(t))}catch(t){i(t)}}function u(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,u)}c((n=n.apply(t,e||[])).next())}))};Object.defineProperty(e,"__esModule",{value:!0}),e.GlobalStore=void 0;var f=r(156),d=r(244),v=r(125),p=r(281),h=r(143),b=r(561),y=r(400),m=r(157),g=r(605),S=r(748),w=globalThis;!function(){if(!w.REACT_GLOBAL_STATE_HOOK_DEBUG&&!(0,v.isNil)(w.sessionStorage)){try{if(!w.sessionStorage.getItem("REACT_GLOBAL_STATE_HOOK_DEBUG"))return}catch(t){return}w.REACT_GLOBAL_STATE_TEMP_HOOKS=new Map,setTimeout((function(){w.REACT_GLOBAL_STATE_TEMP_HOOKS=null}),6e4)}}();var O=function(){function t(e){var r,n=this,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{metadata:{}};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.wasDisposed=!1,this.actionsConfig=null,this.callbacks=null,this.actions=null,this.subscribers=new Map,this.initialize=function(){return l(n,void 0,void 0,u().mark((function t(){var e,r,n,o,i,a;return u().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(Object.keys(null!==(e=this.actionsConfig)&&void 0!==e?e:{}).length>0&&(this.actions=this.getStoreActionsMap()),n=this.onInit,o=null!==(r=this.callbacks)&&void 0!==r?r:{},i=o.onInit,n||i){t.next=6;break}return t.abrupt("return");case 6:a=this.getConfigCallbackParam(),null==n||n(a),(0,v.isNil)(i)||null==i||i(a);case 9:case"end":return t.stop()}}),t,this)})))},this.executeSetStateForSubscriber=function(t,e){var r,o,i=t.selector,a=t.callback,u=t.currentState,c=t.config;if(!e.forceUpdate&&(null!==(r=null==c?void 0:c.isEqualRoot)&&void 0!==r?r:function(t,e){return t===e})(e.currentRootState,e.newRootState))return{didUpdate:!1};var s=i?i(e.newRootState):e.newRootState;return!e.forceUpdate&&(null!==(o=null==c?void 0:c.isEqual)&&void 0!==o?o:function(t,e){return t===e})(u,s)?{didUpdate:!1}:(n.partialUpdateSubscription(t.subscriptionId,{currentState:s}),a({state:s},{identifier:e.identifier}),{didUpdate:!0})},this.setState=function(t,e){var r=t.state,o=e.forceUpdate,a=e.identifier,u=n.stateWrapper.state;if(o||u!==r){n.stateWrapper={state:r};var c,s={forceUpdate:o,newRootState:r,currentRootState:u,identifier:a},l=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=i(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,u=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return u=t.done,t},e:function(t){c=!0,a=t},f:function(){try{u||null==r.return||r.return()}finally{if(c)throw a}}}}(n.subscribers.values());try{for(l.s();!(c=l.n()).done;){var f=c.value;n.executeSetStateForSubscriber(f,s)}}catch(t){l.e(t)}finally{l.f()}}},this.setMetadata=function(t){var e=(0,d.isFunction)(t)?t(n.metadata):t;n.metadata=e},this.getMetadata=function(){return n.metadata},this.getState=function(t,e,r){var o;if(!t)return n.stateWrapper.state;var i=(0,d.isFunction)(e),a=i?t:void 0,u=i?e:t,c=null!==(o=i?r:e)&&void 0!==o?o:void 0,s=a?a(n.stateWrapper.state):n.stateWrapper.state;(null==c?void 0:c.skipFirst)||u(s);var l=(0,m.uniqueId)("gs:");return n.setOrUpdateSubscription({subscriptionId:l,selector:a,config:c,currentState:s,callback:function(t){var e=t.state;return u(e)},isSetStateCallback:!1}),function(){n.subscribers.delete(l)}},this.getConfigCallbackParam=function(){var t=n.setMetadata,e=n.getMetadata,r=n.getState,o=n.actions;return{setMetadata:t,getMetadata:e,getState:r,setState:n.setStateWrapper,actions:o}},this.lastSubscriptionId=null,this.setOrUpdateSubscription=function(t){var e=t.subscriptionId;if(!e)return{isNewSubscription:!1};var r=n.subscribers.get(e);return(0,h.isRecord)(r)?(Object.assign(r,t),{isNewSubscription:!1}):(n.executeOnSubscribed(),n.subscribers.set(e,t),n.lastSubscriptionId=e,{isNewSubscription:!0})},this.partialUpdateSubscription=function(t,e){var r=n.subscribers.get(t);(0,h.isRecord)(r)&&Object.assign(r,e)},this.executeOnSubscribed=function(){var t,e=n.onSubscribed,r=null===(t=n.callbacks)||void 0===t?void 0:t.onSubscribed;if(e||r){var o=n.getConfigCallbackParam();null==e||e(o),null==r||r(o)}},this.getHook=function(){var t=function(t){var e,r,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(n.wasDisposed)throw new Error("The global state was disposed");var a=Array.isArray(i)?{dependencies:i}:null!=i?i:{},u=(0,f.useRef)({subscriptionId:null,tempInitialRootState:n.stateWrapper.state}),c=function(){return t?{state:t(n.stateWrapper.state)}:n.stateWrapper},s=o((0,f.useState)(c),2),l=s[0],d=s[1];(0,f.useEffect)((function(){if(!(0,v.isNil)(u.current)){(0,v.isNil)(u.current.subscriptionId)&&(u.current.subscriptionId=(0,m.uniqueId)("ss:"));var e=u.current.subscriptionId,r={subscriptionId:e,currentState:l.state,selector:t,config:a,callback:d,isSetStateCallback:!0};return n.setOrUpdateSubscription(r).isNewSubscription&&(n.executeSetStateForSubscriber(r,{forceUpdate:!1,newRootState:n.stateWrapper.state,currentRootState:u.current.tempInitialRootState===g.uniqueSymbol?n.stateWrapper.state:u.current.tempInitialRootState,identifier:"on mount state update"}),u.current.tempInitialRootState=g.uniqueSymbol),function(){n.subscribers.delete(e)}}}),[]);var h=(0,p.isString)(null===(e=u.current)||void 0===e?void 0:e.subscriptionId)?u.current.subscriptionId:"",b=n.subscribers.get(h),y=(null!==(r=null==b?void 0:b.config)&&void 0!==r?r:{dependencies:a.dependencies}).dependencies;return n.partialUpdateSubscription(h,{currentState:l.state,selector:t,config:a,callback:d}),[n.computeSelectedState({selector:t,subscriptionId:h,config:a,currentDependencies:y,computeChildState:c,stateWrapperRef:l}),n.getStateOrchestrator(),n.metadata]};return t.stateControls=n.stateControls,t.createSelectorHook=n.createSelectorHook,t.createObservable=n.createObservable,t.removeSubscriptions=n.removeSubscriptions,t.dispose=n.dispose,t},this.computeSelectedState=function(t){var e=t.selector,r=t.subscriptionId,o=t.config,i=t.currentDependencies,a=t.computeChildState,u=t.stateWrapperRef;if(!e||!r)return u.state;var c=o.dependencies;if(i===c)return u.state;if((null==i?void 0:i.length)===(null==c?void 0:c.length)&&(0,b.shallowCompare)(i,c))return u.state;var s=a().state;return n.partialUpdateSubscription(r,{currentState:s}),u.state=s,s},this.createSelectorHook=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=r.isEqualRoot,a=r.isEqual,u=r.name,c=o(n.stateControls(),3),s=c[0],l=c[1],f=c[2],v=s(),p=(null!=e?e:function(t){return t})(v),h=new t(p,{name:null!=u?u:(0,m.uniqueId)("sh:")}),b=o(h.stateControls(),2),y=b[0],g=b[1],S=s((function(t){if(!(null!=i?i:Object.is)(v,t)){v=t;var r=e(t);(null!=a?a:Object.is)(p,r)||(p=r,g(r))}}),{skipFirst:!0}),w=h.getHook(),O=function(t,e){return[o((0,d.isFunction)(t)?w(t,e):w(),1)[0],l,f]};return O.stateControls=function(){return[y,l,f]},O.createSelectorHook=n.createSelectorHook.bind(O),O.createObservable=n.createObservable.bind(O),O.removeSubscriptions=function(){S(),h.removeSubscriptions()},O.dispose=function(){O.removeSubscriptions(),h.dispose()},O},this.stateControls=function(){var t=n.getStateOrchestrator(),e=n.getMetadata;return[n.getState,t,e]},this.getStateOrchestrator=function(){return n.actions?n.actions:n.setStateWrapper},this.setStateWrapper=function(t){var e,r,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=o.forceUpdate,a=o.identifier,u=n.stateWrapper.state,c=(0,d.isFunction)(t)?t(u):t;if(i||n.stateWrapper.state!==c){var s=n.setMetadata,l=n.getMetadata,f=n.getState,v=n.actions,p={setMetadata:s,getMetadata:l,setState:n.setState,getState:f,actions:v,previousState:u,state:c,identifier:a},h=n.computePreventStateChange,b=null===(e=n.callbacks)||void 0===e?void 0:e.computePreventStateChange;if((h||b)&&((null==h?void 0:h(p))||(null==b?void 0:b(p))))return;n.setState({state:c},{forceUpdate:i,identifier:a});var y=n.onStateChanged,m=null===(r=n.callbacks)||void 0===r?void 0:r.onStateChanged;(y||m)&&(null==y||y(p),null==m||m(p))}},this.getStoreActionsMap=function(){if(!(0,h.isRecord)(n.actionsConfig))return null;var t=n.actionsConfig,e=n.setMetadata,r=n.setStateWrapper,o=n.getState,i=n.getMetadata,a=Object.keys(t).reduce((function(n,u){var c,l,f;return Object.assign(n,(c={},f=function(){for(var n=t[u],c=arguments.length,s=new Array(c),l=0;l<c;l++)s[l]=arguments[l];var f=n.apply(a,s);return"function"!=typeof f&&(0,y.throwWrongKeyOnActionCollectionConfig)(u),f.call(a,{setState:r,getState:o,setMetadata:e,getMetadata:i,actions:a})},(l=s(l=u))in c?Object.defineProperty(c,l,{value:f,enumerable:!0,configurable:!0,writable:!0}):c[l]=f,c)),n}),{});return a},this.removeSubscriptions=function(){n.subscribers.clear()},this.dispose=function(){n.wasDisposed=!0,n.removeSubscriptions(),n._name="",n.actionsConfig=null,n.callbacks=null,n.metadata={},n.actions=null,n.subscribers.clear(),n.stateWrapper={state:null}};var c=a.metadata,O=a.callbacks,_=a.actions,E=a.name;this.stateWrapper={state:e},this._name=null!=E?E:(0,m.uniqueId)("gs:"),this.metadata=null!=c?c:{},this.callbacks=null!=O?O:null,this.actionsConfig=null!=_?_:null;var C="";if((w.REACT_GLOBAL_STATE_HOOK_DEBUG||w.REACT_GLOBAL_STATE_TEMP_HOOKS)&&(C=(0,S.generateStackHash)(null!==(r=(new Error).stack)&&void 0!==r?r:"")),w.REACT_GLOBAL_STATE_HOOK_DEBUG)w.REACT_GLOBAL_STATE_HOOK_DEBUG(this,a,C);else if(w.REACT_GLOBAL_STATE_TEMP_HOOKS){var A=void 0!==globalThis.WeakRef?new globalThis.WeakRef(this):this,j=void 0!==globalThis.WeakRef?new globalThis.WeakRef(a):a;w.REACT_GLOBAL_STATE_TEMP_HOOKS.set(C,[A,j])}this.constructor!==t||this.initialize()}var e,r,n;return e=t,r=[{key:"createObservable",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=e.isEqualRoot,n=e.isEqual,i=e.name,a=o(this.stateControls(),1)[0],u=[],c=a(),s=(null!=t?t:function(t){return t})(a()),l=a((function(e){if(!(null!=r?r:Object.is)(c,e)){c=e;var o=t(e);(null!=n?n:Object.is)(s,o)||(s=o,u.forEach((function(t){return t()})))}}),{skipFirst:!0}),f=function(t,e,r){var n;if(!t)return s;var o=(0,d.isFunction)(e),i=o?t:void 0,a=o?e:t,c=null!==(n=o?r:e)&&void 0!==n?n:void 0,l=function(){return a(i?i(s):s)};(null==c?void 0:c.skipFirst)||l();var f=function(){l()};return u.push(f),function(){u.splice(u.indexOf(f),1)}};return f._name=null!=i?i:(0,m.uniqueId)("ob:"),f.createObservable=this.createObservable.bind(f),f.removeSubscriptions=function(){u.forEach((function(t){return t()})),u.length=0,l()},f.stateControls=function(){return[f]},f}}],r&&c(e.prototype,r),n&&c(e,n),Object.defineProperty(e,"prototype",{writable:!1}),t}();e.GlobalStore=O,e.default=O},564:(t,e,r)=>{"use strict";function n(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],c=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);c=!0);}catch(t){s=!0,o=t}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return u}}(t,e)||function(t,e){if(t){if("string"==typeof t)return o(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}Object.defineProperty(e,"__esModule",{value:!0}),e.createContext=void 0;var i=r(156),a=r(774),u=r(244),c=r(125),s=r(965);e.createContext=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=(0,i.createContext)(null),o=function(){var t=(0,i.useContext)(r);if(!t)throw new Error("ContextHook must be used within a ContextProvider");return t()};o.createSelectorHook=function(t,e){return function(){var o=(0,i.useContext)(r);if((0,c.isNil)(o))throw new Error("SelectorHook must be used within a ContextProvider");return n((0,s.useStableState)((function(){return o.createSelectorHook(t,e)}),(function(t){return t.removeSubscriptions()}),[o]),1)[0].value.apply(void 0,arguments)}};var l=function(){var t=(0,i.useContext)(r);if((0,c.isNil)(t))throw new Error("useStateControls must be used within a ContextProvider");return t.stateControls()},f=function(t,e){var n=(0,i.useContext)(r);if((0,c.isNil)(n))throw new Error("useObservableBuilder must be used within a ContextProvider");return n.createObservable(t,e)};return o.stateControls=function(){return[l,f]},[o,function(o){var l=o.children,f=o.value,d=o.ref,v=n((0,s.useStableState)((function(){var r,n=function(){return(0,u.isFunction)(t)?t():t},o=(0,c.isNil)(f)?n():(0,u.isFunction)(f)?f(n()):f,i=new a.GlobalStore(o,Object.assign(Object.assign({},e),{metadata:null!==(r=(0,u.isFunction)(e.metadata)?e.metadata():e.metadata)&&void 0!==r?r:{}})),s=i.getHook();return{store:i,parentHook:s}}),(function(t){var e,r,n,o;t.store.dispose(),null===(r=null===(e=v.value.store.callbacks)||void 0===e?void 0:e.onUnMount)||void 0===r||r.call(e),null===(o=(n=v.value.store).__onUnMountContext)||void 0===o||o.call(n,v.value.store,v.value.parentHook)}),[]),1)[0];return(0,i.useImperativeHandle)(d,(function(){return d?v.value.store.getConfigCallbackParam():{}}),[v.value.store,d]),(0,i.createElement)(r.Provider,{value:v.value.parentHook},l)}]},e.default=e.createContext},748:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.generateStackHash=void 0,e.generateStackHash=function(t){if(!t.trim())return"unknown";t=t.replace(/\s/g,"");for(var e=2166136261,r=0;r<t.length;r++)e^=t.charCodeAt(r),e*=16777619,e&=4294967295;return function(t){for(var e="";t>0;)e="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[t%62]+e,t=Math.floor(t/62);return e||"0"}(e>>>0)},e.default=e.generateStackHash},143:(t,e,r)=>{"use strict";function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}Object.defineProperty(e,"__esModule",{value:!0}),e.isRecord=void 0;var o=r(125);e.isRecord=function(t){return!(0,o.isNil)(t)&&"object"===n(t)},e.default=e.isRecord},561:(t,e,r)=>{"use strict";function n(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],c=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);c=!0);}catch(t){s=!0,o=t}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return u}}(t,e)||i(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=i(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,u=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return u=t.done,t},e:function(t){c=!0,a=t},f:function(){try{u||null==r.return||r.return()}finally{if(c)throw a}}}}function i(t,e){if(t){if("string"==typeof t)return a(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?a(t,e):void 0}}function a(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function u(t){return u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(t)}Object.defineProperty(e,"__esModule",{value:!0}),e.shallowCompare=void 0;var c=r(416),s=r(231),l=r(125),f=r(143);e.shallowCompare=function(t,e){if(t===e)return!0;var r=u(t),i=u(e);if(r!==i)return!1;if((0,l.isNil)(t)||(0,l.isNil)(e)||(0,c.isPrimitive)(t)&&(0,c.isPrimitive)(e)||(0,s.isDate)(t)&&(0,s.isDate)(e)||"function"===r&&"function"===i)return t===e;if(Array.isArray(t)){var a=t,d=e;if(a.length!==d.length)return!1;for(var v=0;v<a.length;v++)if(a[v]!==d[v])return!1}if(t instanceof Map){var p=t,h=e;if(p.size!==h.size)return!1;var b,y=o(p);try{for(y.s();!(b=y.n()).done;){var m=n(b.value,2),g=m[0];if(m[1]!==h.get(g))return!1}}catch(t){y.e(t)}finally{y.f()}}if(t instanceof Set){var S=t,w=e;if(S.size!==w.size)return!1;var O,_=o(S);try{for(_.s();!(O=_.n()).done;){var E=O.value;if(!w.has(E))return!1}}catch(t){_.e(t)}finally{_.f()}}if(!(0,f.isRecord)(t)||!(0,f.isRecord)(e))return t===e;var C=Object.keys(t),A=Object.keys(e);if(C.length!==A.length)return!1;for(var j=0,x=C;j<x.length;j++){var k=x[j];if(t[k]!==e[k])return!1}return!0},e.default=e.shallowCompare},400:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.throwWrongKeyOnActionCollectionConfig=void 0,e.throwWrongKeyOnActionCollectionConfig=function(t){throw new Error("[WRONG CONFIGURATION!]: Every key inside the storeActionsConfig must be a higher order function that returns a function \n[".concat(t,"]: key is not a valid function, try something like this: \n{\n\n ").concat(t,": (param) => ({ setState, getState, setMetadata, getMetadata, actions }) => {\n\n setState((state) => ({ ...state, ...param }))\n\n }\n\n}\n"))},e.default=e.throwWrongKeyOnActionCollectionConfig},157:(t,e)=>{"use strict";var r;Object.defineProperty(e,"__esModule",{value:!0}),e.uniqueId=void 0,e.uniqueId=(r=0,function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return r===Number.MAX_SAFE_INTEGER&&(r=0),t+Date.now().toString(36)+(r++).toString(36)}),e.default=e.uniqueId},605:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.uniqueSymbol=void 0,e.uniqueSymbol=Symbol("unique"),e.default=e.uniqueSymbol},965:(t,e,r)=>{"use strict";function n(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],c=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);c=!0);}catch(t){s=!0,o=t}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return u}}(t,e)||function(t,e){if(t){if("string"==typeof t)return o(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}Object.defineProperty(e,"__esModule",{value:!0}),e.useStableState=void 0;var i=r(156),a=r(244),u=r(125),c=r(561),s=r(156),l=r(156);e.useStableState=function(t){var e=(0,a.isFunction)(arguments.length<=1?void 0:arguments[1])?arguments.length<=1?void 0:arguments[1]:void 0,r=e?arguments.length<=2?void 0:arguments[2]:arguments.length<=1?void 0:arguments[1],o=(0,i.useRef)({builder:null,cleanup:e,dependencies:r}),f=(0,a.isFunction)(t)?t:function(){return t},d=n((0,s.useState)((function(){return{value:f()}})),2),v=d[0],p=d[1],h=(0,u.isNil)(o.current.builder),b=(0,u.isNil)(r)||!(0,c.shallowCompare)(o.current.dependencies,r);!h&&b&&(v.value=f()),o.current.dependencies=r,o.current.builder=f,o.current.cleanup=e;var y=(0,l.useCallback)((function(){p({value:o.current.builder()})}),[]);return(0,i.useEffect)((function(){return function(){o.current.cleanup&&o.current.cleanup(v.value)}}),[]),[v,y]},e.default=e.useStableState},231:function(t){t.exports=(()=>{"use strict";var t={};return(()=>{var e=t;Object.defineProperty(e,"__esModule",{value:!0}),e.isDate=void 0,e.isDate=function(t){return t instanceof Date}})(),t})()},244:function(t){t.exports=(()=>{"use strict";var t={};return(()=>{var e=t;Object.defineProperty(e,"__esModule",{value:!0}),e.isFunction=void 0,e.isFunction=function(t){return"function"==typeof t||t instanceof Function}})(),t})()},125:function(t){t.exports=(()=>{"use strict";var t={};return(()=>{var e=t;Object.defineProperty(e,"__esModule",{value:!0}),e.isNil=void 0,e.isNil=function(t){return null==t}})(),t})()},416:function(t){t.exports=(()=>{"use strict";var t={112:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isBoolean=void 0,e.isBoolean=function(t){return"boolean"==typeof t}},243:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isNil=void 0,e.isNil=function(t){return null==t}},11:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isNumber=void 0,e.isNumber=function(t){return"number"==typeof t}},671:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isString=void 0,e.isString=function(t){return"string"==typeof t}}},e={};function r(n){var o=e[n];if(void 0!==o)return o.exports;var i=e[n]={exports:{}};return t[n](i,i.exports,r),i.exports}var n={};return(()=>{var t=n;function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},e(t)}Object.defineProperty(t,"__esModule",{value:!0}),t.isPrimitive=void 0;var o=r(112),i=r(243),a=r(11),u=r(671);t.isPrimitive=function(t){return(0,i.isNil)(t)||(0,a.isNumber)(t)||(0,o.isBoolean)(t)||(0,u.isString)(t)||"symbol"===e(t)}})(),n})()},281:function(t){t.exports=(()=>{"use strict";var t={};return(()=>{var e=t;Object.defineProperty(e,"__esModule",{value:!0}),e.isString=void 0,e.isString=function(t){return"string"==typeof t}})(),t})()},156:e=>{"use strict";e.exports=t}},r={},function t(n){var o=r[n];if(void 0!==o)return o.exports;var i=r[n]={exports:{}};return e[n].call(i.exports,i,i.exports,t),i.exports}(564);var e,r}));
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("./GlobalStore.js"),require("./useStableState.js"),require("react")):"function"==typeof define&&define.amd?define(["./GlobalStore.js","./useStableState.js","react"],t):"object"==typeof exports?exports["react-hooks-global-states"]=t(require("./GlobalStore.js"),require("./useStableState.js"),require("react")):e["react-hooks-global-states"]=t(e["./GlobalStore.js"],e["./useStableState.js"],e.react)}(this,((e,t,r)=>{return o={564:(e,t,r)=>{"use strict";function o(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o,n,u,a,i=[],l=!0,s=!1;try{if(u=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;l=!1}else for(;!(l=(o=u.call(r)).done)&&(i.push(o.value),i.length!==t);l=!0);}catch(e){s=!0,n=e}finally{try{if(!l&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw n}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return n(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,o=new Array(t);r<t;r++)o[r]=e[r];return o}Object.defineProperty(t,"__esModule",{value:!0}),t.createContext=void 0;var u=r(156),a=r(352),i=r(244),l=r(125),s=r(503);t.createContext=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=(0,u.createContext)(null),n=function(){var e=(0,u.useContext)(r);if(!e)throw new Error("ContextHook must be used within a ContextProvider");return e()};n.createSelectorHook=function(e,t){return function(){var n=(0,u.useContext)(r);if((0,l.isNil)(n))throw new Error("SelectorHook must be used within a ContextProvider");return o((0,s.useStableState)((function(){return n.createSelectorHook(e,t)}),(function(e){return e.removeSubscriptions()}),[n]),1)[0].value.apply(void 0,arguments)}};var c=function(){var e=(0,u.useContext)(r);if((0,l.isNil)(e))throw new Error("useStateControls must be used within a ContextProvider");return e.stateControls()},f=function(e,t){var o=(0,u.useContext)(r);if((0,l.isNil)(o))throw new Error("useObservableBuilder must be used within a ContextProvider");return o.createObservable(e,t)};return n.stateControls=function(){return[c,f]},[n,function(n){var c=n.children,f=n.value,v=n.ref,d=o((0,s.useStableState)((function(){var r,o=function(){return(0,i.isFunction)(e)?e():e},n=(0,l.isNil)(f)?o():(0,i.isFunction)(f)?f(o()):f,u=new a.GlobalStore(n,Object.assign(Object.assign({},t),{metadata:null!==(r=(0,i.isFunction)(t.metadata)?t.metadata():t.metadata)&&void 0!==r?r:{}})),s=u.getHook();return{store:u,parentHook:s}}),(function(e){var t,r,o,n;e.store.dispose(),null===(r=null===(t=d.value.store.callbacks)||void 0===t?void 0:t.onUnMount)||void 0===r||r.call(t),null===(n=(o=d.value.store).__onUnMountContext)||void 0===n||n.call(o,d.value.store,d.value.parentHook)}),[]),1)[0];return(0,u.useImperativeHandle)(v,(function(){return v?d.value.store.getConfigCallbackParam():{}}),[d.value.store,v]),(0,u.createElement)(r.Provider,{value:d.value.parentHook},c)}]},t.default=t.createContext},244:function(e){e.exports=(()=>{"use strict";var e={};return(()=>{var t=e;Object.defineProperty(t,"__esModule",{value:!0}),t.isFunction=void 0,t.isFunction=function(e){return"function"==typeof e||e instanceof Function}})(),e})()},125:function(e){e.exports=(()=>{"use strict";var e={};return(()=>{var t=e;Object.defineProperty(t,"__esModule",{value:!0}),t.isNil=void 0,t.isNil=function(e){return null==e}})(),e})()},352:t=>{"use strict";t.exports=e},503:e=>{"use strict";e.exports=t},156:e=>{"use strict";e.exports=r}},n={},function e(t){var r=n[t];if(void 0!==r)return r.exports;var u=n[t]={exports:{}};return o[t].call(u.exports,u,u.exports,e),u.exports}(564);var o,n}));
@@ -1,4 +1,4 @@
1
- import { ActionCollectionConfig, StateSetter, ActionCollectionResult, StateHook, CustomGlobalHookBuilderParams, BaseMetadata, GlobalStoreCallbacks } from './types';
1
+ import type { ActionCollectionConfig, StateSetter, ActionCollectionResult, StateHook, CustomGlobalHookBuilderParams, BaseMetadata, GlobalStoreCallbacks } from './types';
2
2
  export interface CustomCreateGlobalState<TCustomConfig extends BaseMetadata | unknown, InheritMetadata extends BaseMetadata | unknown = BaseMetadata> {
3
3
  <State>(state: State): StateHook<State, StateSetter<State>, BaseMetadata>;
4
4
  <State, Metadata extends BaseMetadata | unknown, ActionsConfig extends ActionCollectionConfig<State, InheritMetadata & Metadata> | null | {}, PublicStateMutator = keyof ActionsConfig extends never | undefined ? StateSetter<State> : ActionCollectionResult<State, InheritMetadata & Metadata, NonNullable<ActionsConfig>>>(state: State, args: {
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react")):"function"==typeof define&&define.amd?define(["react"],e):"object"==typeof exports?exports["react-hooks-global-states"]=e(require("react")):t["react-hooks-global-states"]=e(t.react)}(this,(t=>{return e={774:(t,e,r)=>{"use strict";function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function o(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],s=!0,c=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);s=!0);}catch(t){c=!0,o=t}finally{try{if(!s&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return u}}(t,e)||i(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(t,e){if(t){if("string"==typeof t)return a(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?a(t,e):void 0}}function a(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function u(){u=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",s=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function l(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var i=e&&e.prototype instanceof v?e:v,a=Object.create(i.prototype),u=new k(n||[]);return o(a,"_invoke",{value:_(t,r,u)}),a}function d(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=f;var p={};function v(){}function h(){}function b(){}var y={};l(y,a,(function(){return this}));var g=Object.getPrototypeOf,m=g&&g(g(C([])));m&&m!==e&&r.call(m,a)&&(y=m);var S=b.prototype=v.prototype=Object.create(y);function O(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){function i(o,a,u,s){var c=d(t[o],t,a);if("throw"!==c.type){var l=c.arg,f=l.value;return f&&"object"==n(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){i("next",t,u,s)}),(function(t){i("throw",t,u,s)})):e.resolve(f).then((function(t){l.value=t,u(l)}),(function(t){return i("throw",t,u,s)}))}s(c.arg)}var a;o(this,"_invoke",{value:function(t,r){function n(){return new e((function(e,n){i(t,r,e,n)}))}return a=a?a.then(n,n):n()}})}function _(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var u=E(a,r);if(u){if(u===p)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var s=d(t,e,r);if("normal"===s.type){if(n=r.done?"completed":"suspendedYield",s.arg===p)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(n="completed",r.method="throw",r.arg=s.arg)}}}function E(t,e){var r=e.method,n=t.iterator[r];if(void 0===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=void 0,E(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),p;var o=d(n,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,p;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,p):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,p)}function j(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function A(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(j,this),this.reset(!0)}function C(t){if(t){var e=t[a];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,o=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:x}}function x(){return{value:void 0,done:!0}}return h.prototype=b,o(S,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:h,configurable:!0}),h.displayName=l(b,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,l(t,c,"GeneratorFunction")),t.prototype=Object.create(S),t},t.awrap=function(t){return{__await:t}},O(w.prototype),l(w.prototype,s,(function(){return this})),t.AsyncIterator=w,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new w(f(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},O(S),l(S,c,"Generator"),l(S,a,(function(){return this})),l(S,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},t.values=C,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(A),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var u=r.call(i,"catchLoc"),s=r.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,p):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),p},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),A(r),p}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;A(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:C(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),p}},t}function s(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,c(n.key),n)}}function c(t){var e=function(t,e){if("object"!==n(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var o=r.call(t,e||"default");if("object"!==n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"===n(e)?e:String(e)}var l=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function a(t){try{s(n.next(t))}catch(t){i(t)}}function u(t){try{s(n.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,u)}s((n=n.apply(t,e||[])).next())}))};Object.defineProperty(e,"__esModule",{value:!0}),e.GlobalStore=void 0;var f=r(156),d=r(244),p=r(125),v=r(281),h=r(143),b=r(561),y=r(400),g=r(157),m=r(605),S=r(748),O=globalThis;!function(){if(!O.REACT_GLOBAL_STATE_HOOK_DEBUG&&!(0,p.isNil)(O.sessionStorage)){try{if(!O.sessionStorage.getItem("REACT_GLOBAL_STATE_HOOK_DEBUG"))return}catch(t){return}O.REACT_GLOBAL_STATE_TEMP_HOOKS=new Map,setTimeout((function(){O.REACT_GLOBAL_STATE_TEMP_HOOKS=null}),6e4)}}();var w=function(){function t(e){var r,n=this,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{metadata:{}};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.wasDisposed=!1,this.actionsConfig=null,this.callbacks=null,this.actions=null,this.subscribers=new Map,this.initialize=function(){return l(n,void 0,void 0,u().mark((function t(){var e,r,n,o,i,a;return u().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(Object.keys(null!==(e=this.actionsConfig)&&void 0!==e?e:{}).length>0&&(this.actions=this.getStoreActionsMap()),n=this.onInit,o=null!==(r=this.callbacks)&&void 0!==r?r:{},i=o.onInit,n||i){t.next=6;break}return t.abrupt("return");case 6:a=this.getConfigCallbackParam(),null==n||n(a),(0,p.isNil)(i)||null==i||i(a);case 9:case"end":return t.stop()}}),t,this)})))},this.executeSetStateForSubscriber=function(t,e){var r,o,i=t.selector,a=t.callback,u=t.currentState,s=t.config;if(!e.forceUpdate&&(null!==(r=null==s?void 0:s.isEqualRoot)&&void 0!==r?r:function(t,e){return t===e})(e.currentRootState,e.newRootState))return{didUpdate:!1};var c=i?i(e.newRootState):e.newRootState;return!e.forceUpdate&&(null!==(o=null==s?void 0:s.isEqual)&&void 0!==o?o:function(t,e){return t===e})(u,c)?{didUpdate:!1}:(n.partialUpdateSubscription(t.subscriptionId,{currentState:c}),a({state:c},{identifier:e.identifier}),{didUpdate:!0})},this.setState=function(t,e){var r=t.state,o=e.forceUpdate,a=e.identifier,u=n.stateWrapper.state;if(o||u!==r){n.stateWrapper={state:r};var s,c={forceUpdate:o,newRootState:r,currentRootState:u,identifier:a},l=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=i(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,u=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return u=t.done,t},e:function(t){s=!0,a=t},f:function(){try{u||null==r.return||r.return()}finally{if(s)throw a}}}}(n.subscribers.values());try{for(l.s();!(s=l.n()).done;){var f=s.value;n.executeSetStateForSubscriber(f,c)}}catch(t){l.e(t)}finally{l.f()}}},this.setMetadata=function(t){var e=(0,d.isFunction)(t)?t(n.metadata):t;n.metadata=e},this.getMetadata=function(){return n.metadata},this.getState=function(t,e,r){var o;if(!t)return n.stateWrapper.state;var i=(0,d.isFunction)(e),a=i?t:void 0,u=i?e:t,s=null!==(o=i?r:e)&&void 0!==o?o:void 0,c=a?a(n.stateWrapper.state):n.stateWrapper.state;(null==s?void 0:s.skipFirst)||u(c);var l=(0,g.uniqueId)("gs:");return n.setOrUpdateSubscription({subscriptionId:l,selector:a,config:s,currentState:c,callback:function(t){var e=t.state;return u(e)},isSetStateCallback:!1}),function(){n.subscribers.delete(l)}},this.getConfigCallbackParam=function(){var t=n.setMetadata,e=n.getMetadata,r=n.getState,o=n.actions;return{setMetadata:t,getMetadata:e,getState:r,setState:n.setStateWrapper,actions:o}},this.lastSubscriptionId=null,this.setOrUpdateSubscription=function(t){var e=t.subscriptionId;if(!e)return{isNewSubscription:!1};var r=n.subscribers.get(e);return(0,h.isRecord)(r)?(Object.assign(r,t),{isNewSubscription:!1}):(n.executeOnSubscribed(),n.subscribers.set(e,t),n.lastSubscriptionId=e,{isNewSubscription:!0})},this.partialUpdateSubscription=function(t,e){var r=n.subscribers.get(t);(0,h.isRecord)(r)&&Object.assign(r,e)},this.executeOnSubscribed=function(){var t,e=n.onSubscribed,r=null===(t=n.callbacks)||void 0===t?void 0:t.onSubscribed;if(e||r){var o=n.getConfigCallbackParam();null==e||e(o),null==r||r(o)}},this.getHook=function(){var t=function(t){var e,r,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(n.wasDisposed)throw new Error("The global state was disposed");var a=Array.isArray(i)?{dependencies:i}:null!=i?i:{},u=(0,f.useRef)({subscriptionId:null,tempInitialRootState:n.stateWrapper.state}),s=function(){return t?{state:t(n.stateWrapper.state)}:n.stateWrapper},c=o((0,f.useState)(s),2),l=c[0],d=c[1];(0,f.useEffect)((function(){if(!(0,p.isNil)(u.current)){(0,p.isNil)(u.current.subscriptionId)&&(u.current.subscriptionId=(0,g.uniqueId)("ss:"));var e=u.current.subscriptionId,r={subscriptionId:e,currentState:l.state,selector:t,config:a,callback:d,isSetStateCallback:!0};return n.setOrUpdateSubscription(r).isNewSubscription&&(n.executeSetStateForSubscriber(r,{forceUpdate:!1,newRootState:n.stateWrapper.state,currentRootState:u.current.tempInitialRootState===m.uniqueSymbol?n.stateWrapper.state:u.current.tempInitialRootState,identifier:"on mount state update"}),u.current.tempInitialRootState=m.uniqueSymbol),function(){n.subscribers.delete(e)}}}),[]);var h=(0,v.isString)(null===(e=u.current)||void 0===e?void 0:e.subscriptionId)?u.current.subscriptionId:"",b=n.subscribers.get(h),y=(null!==(r=null==b?void 0:b.config)&&void 0!==r?r:{dependencies:a.dependencies}).dependencies;return n.partialUpdateSubscription(h,{currentState:l.state,selector:t,config:a,callback:d}),[n.computeSelectedState({selector:t,subscriptionId:h,config:a,currentDependencies:y,computeChildState:s,stateWrapperRef:l}),n.getStateOrchestrator(),n.metadata]};return t.stateControls=n.stateControls,t.createSelectorHook=n.createSelectorHook,t.createObservable=n.createObservable,t.removeSubscriptions=n.removeSubscriptions,t.dispose=n.dispose,t},this.computeSelectedState=function(t){var e=t.selector,r=t.subscriptionId,o=t.config,i=t.currentDependencies,a=t.computeChildState,u=t.stateWrapperRef;if(!e||!r)return u.state;var s=o.dependencies;if(i===s)return u.state;if((null==i?void 0:i.length)===(null==s?void 0:s.length)&&(0,b.shallowCompare)(i,s))return u.state;var c=a().state;return n.partialUpdateSubscription(r,{currentState:c}),u.state=c,c},this.createSelectorHook=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=r.isEqualRoot,a=r.isEqual,u=r.name,s=o(n.stateControls(),3),c=s[0],l=s[1],f=s[2],p=c(),v=(null!=e?e:function(t){return t})(p),h=new t(v,{name:null!=u?u:(0,g.uniqueId)("sh:")}),b=o(h.stateControls(),2),y=b[0],m=b[1],S=c((function(t){if(!(null!=i?i:Object.is)(p,t)){p=t;var r=e(t);(null!=a?a:Object.is)(v,r)||(v=r,m(r))}}),{skipFirst:!0}),O=h.getHook(),w=function(t,e){return[o((0,d.isFunction)(t)?O(t,e):O(),1)[0],l,f]};return w.stateControls=function(){return[y,l,f]},w.createSelectorHook=n.createSelectorHook.bind(w),w.createObservable=n.createObservable.bind(w),w.removeSubscriptions=function(){S(),h.removeSubscriptions()},w.dispose=function(){w.removeSubscriptions(),h.dispose()},w},this.stateControls=function(){var t=n.getStateOrchestrator(),e=n.getMetadata;return[n.getState,t,e]},this.getStateOrchestrator=function(){return n.actions?n.actions:n.setStateWrapper},this.setStateWrapper=function(t){var e,r,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=o.forceUpdate,a=o.identifier,u=n.stateWrapper.state,s=(0,d.isFunction)(t)?t(u):t;if(i||n.stateWrapper.state!==s){var c=n.setMetadata,l=n.getMetadata,f=n.getState,p=n.actions,v={setMetadata:c,getMetadata:l,setState:n.setState,getState:f,actions:p,previousState:u,state:s,identifier:a},h=n.computePreventStateChange,b=null===(e=n.callbacks)||void 0===e?void 0:e.computePreventStateChange;if((h||b)&&((null==h?void 0:h(v))||(null==b?void 0:b(v))))return;n.setState({state:s},{forceUpdate:i,identifier:a});var y=n.onStateChanged,g=null===(r=n.callbacks)||void 0===r?void 0:r.onStateChanged;(y||g)&&(null==y||y(v),null==g||g(v))}},this.getStoreActionsMap=function(){if(!(0,h.isRecord)(n.actionsConfig))return null;var t=n.actionsConfig,e=n.setMetadata,r=n.setStateWrapper,o=n.getState,i=n.getMetadata,a=Object.keys(t).reduce((function(n,u){var s,l,f;return Object.assign(n,(s={},f=function(){for(var n=t[u],s=arguments.length,c=new Array(s),l=0;l<s;l++)c[l]=arguments[l];var f=n.apply(a,c);return"function"!=typeof f&&(0,y.throwWrongKeyOnActionCollectionConfig)(u),f.call(a,{setState:r,getState:o,setMetadata:e,getMetadata:i,actions:a})},(l=c(l=u))in s?Object.defineProperty(s,l,{value:f,enumerable:!0,configurable:!0,writable:!0}):s[l]=f,s)),n}),{});return a},this.removeSubscriptions=function(){n.subscribers.clear()},this.dispose=function(){n.wasDisposed=!0,n.removeSubscriptions(),n._name="",n.actionsConfig=null,n.callbacks=null,n.metadata={},n.actions=null,n.subscribers.clear(),n.stateWrapper={state:null}};var s=a.metadata,w=a.callbacks,_=a.actions,E=a.name;this.stateWrapper={state:e},this._name=null!=E?E:(0,g.uniqueId)("gs:"),this.metadata=null!=s?s:{},this.callbacks=null!=w?w:null,this.actionsConfig=null!=_?_:null;var j="";if((O.REACT_GLOBAL_STATE_HOOK_DEBUG||O.REACT_GLOBAL_STATE_TEMP_HOOKS)&&(j=(0,S.generateStackHash)(null!==(r=(new Error).stack)&&void 0!==r?r:"")),O.REACT_GLOBAL_STATE_HOOK_DEBUG)O.REACT_GLOBAL_STATE_HOOK_DEBUG(this,a,j);else if(O.REACT_GLOBAL_STATE_TEMP_HOOKS){var A=void 0!==globalThis.WeakRef?new globalThis.WeakRef(this):this,k=void 0!==globalThis.WeakRef?new globalThis.WeakRef(a):a;O.REACT_GLOBAL_STATE_TEMP_HOOKS.set(j,[A,k])}this.constructor!==t||this.initialize()}var e,r,n;return e=t,r=[{key:"createObservable",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=e.isEqualRoot,n=e.isEqual,i=e.name,a=o(this.stateControls(),1)[0],u=[],s=a(),c=(null!=t?t:function(t){return t})(a()),l=a((function(e){if(!(null!=r?r:Object.is)(s,e)){s=e;var o=t(e);(null!=n?n:Object.is)(c,o)||(c=o,u.forEach((function(t){return t()})))}}),{skipFirst:!0}),f=function(t,e,r){var n;if(!t)return c;var o=(0,d.isFunction)(e),i=o?t:void 0,a=o?e:t,s=null!==(n=o?r:e)&&void 0!==n?n:void 0,l=function(){return a(i?i(c):c)};(null==s?void 0:s.skipFirst)||l();var f=function(){l()};return u.push(f),function(){u.splice(u.indexOf(f),1)}};return f._name=null!=i?i:(0,g.uniqueId)("ob:"),f.createObservable=this.createObservable.bind(f),f.removeSubscriptions=function(){u.forEach((function(t){return t()})),u.length=0,l()},f.stateControls=function(){return[f]},f}}],r&&s(e.prototype,r),n&&s(e,n),Object.defineProperty(e,"prototype",{writable:!1}),t}();e.GlobalStore=w,e.default=w},362:(t,e,r)=>{"use strict";var n=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r};Object.defineProperty(e,"__esModule",{value:!0}),e.createCustomGlobalState=void 0;var o=r(196);e.createCustomGlobalState=function(t){var e=t.onInitialize,r=t.onChange;return function(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=i.callbacks,u=n(i,["callbacks"]);return(0,o.createGlobalState)(t,Object.assign(Object.assign({},u),{callbacks:Object.assign(Object.assign({},null!=a?a:{}),{onInit:function(t){var r;null==e||e(t,null==u?void 0:u.config),null===(r=null==a?void 0:a.onInit)||void 0===r||r.call(a,t)},onStateChanged:function(t){var e;null==r||r(t,null==u?void 0:u.config),null===(e=null==a?void 0:a.onStateChanged)||void 0===e||e.call(a,t)}})}))}},e.default=e.createCustomGlobalState},196:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.createGlobalState=void 0;var n=r(774);e.createGlobalState=function(t,e){return new n.GlobalStore(t,e).getHook()},e.default=e.createGlobalState},748:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.generateStackHash=void 0,e.generateStackHash=function(t){if(!t.trim())return"unknown";t=t.replace(/\s/g,"");for(var e=2166136261,r=0;r<t.length;r++)e^=t.charCodeAt(r),e*=16777619,e&=4294967295;return function(t){for(var e="";t>0;)e="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[t%62]+e,t=Math.floor(t/62);return e||"0"}(e>>>0)},e.default=e.generateStackHash},143:(t,e,r)=>{"use strict";function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}Object.defineProperty(e,"__esModule",{value:!0}),e.isRecord=void 0;var o=r(125);e.isRecord=function(t){return!(0,o.isNil)(t)&&"object"===n(t)},e.default=e.isRecord},561:(t,e,r)=>{"use strict";function n(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],s=!0,c=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);s=!0);}catch(t){c=!0,o=t}finally{try{if(!s&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return u}}(t,e)||i(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=i(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,u=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return u=t.done,t},e:function(t){s=!0,a=t},f:function(){try{u||null==r.return||r.return()}finally{if(s)throw a}}}}function i(t,e){if(t){if("string"==typeof t)return a(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?a(t,e):void 0}}function a(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function u(t){return u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(t)}Object.defineProperty(e,"__esModule",{value:!0}),e.shallowCompare=void 0;var s=r(416),c=r(231),l=r(125),f=r(143);e.shallowCompare=function(t,e){if(t===e)return!0;var r=u(t),i=u(e);if(r!==i)return!1;if((0,l.isNil)(t)||(0,l.isNil)(e)||(0,s.isPrimitive)(t)&&(0,s.isPrimitive)(e)||(0,c.isDate)(t)&&(0,c.isDate)(e)||"function"===r&&"function"===i)return t===e;if(Array.isArray(t)){var a=t,d=e;if(a.length!==d.length)return!1;for(var p=0;p<a.length;p++)if(a[p]!==d[p])return!1}if(t instanceof Map){var v=t,h=e;if(v.size!==h.size)return!1;var b,y=o(v);try{for(y.s();!(b=y.n()).done;){var g=n(b.value,2),m=g[0];if(g[1]!==h.get(m))return!1}}catch(t){y.e(t)}finally{y.f()}}if(t instanceof Set){var S=t,O=e;if(S.size!==O.size)return!1;var w,_=o(S);try{for(_.s();!(w=_.n()).done;){var E=w.value;if(!O.has(E))return!1}}catch(t){_.e(t)}finally{_.f()}}if(!(0,f.isRecord)(t)||!(0,f.isRecord)(e))return t===e;var j=Object.keys(t),A=Object.keys(e);if(j.length!==A.length)return!1;for(var k=0,C=j;k<C.length;k++){var x=C[k];if(t[x]!==e[x])return!1}return!0},e.default=e.shallowCompare},400:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.throwWrongKeyOnActionCollectionConfig=void 0,e.throwWrongKeyOnActionCollectionConfig=function(t){throw new Error("[WRONG CONFIGURATION!]: Every key inside the storeActionsConfig must be a higher order function that returns a function \n[".concat(t,"]: key is not a valid function, try something like this: \n{\n\n ").concat(t,": (param) => ({ setState, getState, setMetadata, getMetadata, actions }) => {\n\n setState((state) => ({ ...state, ...param }))\n\n }\n\n}\n"))},e.default=e.throwWrongKeyOnActionCollectionConfig},157:(t,e)=>{"use strict";var r;Object.defineProperty(e,"__esModule",{value:!0}),e.uniqueId=void 0,e.uniqueId=(r=0,function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return r===Number.MAX_SAFE_INTEGER&&(r=0),t+Date.now().toString(36)+(r++).toString(36)}),e.default=e.uniqueId},605:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.uniqueSymbol=void 0,e.uniqueSymbol=Symbol("unique"),e.default=e.uniqueSymbol},231:function(t){t.exports=(()=>{"use strict";var t={};return(()=>{var e=t;Object.defineProperty(e,"__esModule",{value:!0}),e.isDate=void 0,e.isDate=function(t){return t instanceof Date}})(),t})()},244:function(t){t.exports=(()=>{"use strict";var t={};return(()=>{var e=t;Object.defineProperty(e,"__esModule",{value:!0}),e.isFunction=void 0,e.isFunction=function(t){return"function"==typeof t||t instanceof Function}})(),t})()},125:function(t){t.exports=(()=>{"use strict";var t={};return(()=>{var e=t;Object.defineProperty(e,"__esModule",{value:!0}),e.isNil=void 0,e.isNil=function(t){return null==t}})(),t})()},416:function(t){t.exports=(()=>{"use strict";var t={112:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isBoolean=void 0,e.isBoolean=function(t){return"boolean"==typeof t}},243:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isNil=void 0,e.isNil=function(t){return null==t}},11:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isNumber=void 0,e.isNumber=function(t){return"number"==typeof t}},671:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isString=void 0,e.isString=function(t){return"string"==typeof t}}},e={};function r(n){var o=e[n];if(void 0!==o)return o.exports;var i=e[n]={exports:{}};return t[n](i,i.exports,r),i.exports}var n={};return(()=>{var t=n;function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},e(t)}Object.defineProperty(t,"__esModule",{value:!0}),t.isPrimitive=void 0;var o=r(112),i=r(243),a=r(11),u=r(671);t.isPrimitive=function(t){return(0,i.isNil)(t)||(0,a.isNumber)(t)||(0,o.isBoolean)(t)||(0,u.isString)(t)||"symbol"===e(t)}})(),n})()},281:function(t){t.exports=(()=>{"use strict";var t={};return(()=>{var e=t;Object.defineProperty(e,"__esModule",{value:!0}),e.isString=void 0,e.isString=function(t){return"string"==typeof t}})(),t})()},156:e=>{"use strict";e.exports=t}},r={},function t(n){var o=r[n];if(void 0!==o)return o.exports;var i=r[n]={exports:{}};return e[n].call(i.exports,i,i.exports,t),i.exports}(362);var e,r}));
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("./createGlobalState.js")):"function"==typeof define&&define.amd?define(["./createGlobalState.js"],t):"object"==typeof exports?exports["react-hooks-global-states"]=t(require("./createGlobalState.js")):e["react-hooks-global-states"]=t(e["./createGlobalState.js"])}(this,(e=>(()=>{"use strict";var t={362:(e,t,o)=>{var a=function(e,t){var o={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(o[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var l=0;for(a=Object.getOwnPropertySymbols(e);l<a.length;l++)t.indexOf(a[l])<0&&Object.prototype.propertyIsEnumerable.call(e,a[l])&&(o[a[l]]=e[a[l]])}return o};Object.defineProperty(t,"__esModule",{value:!0}),t.createCustomGlobalState=void 0;var l=o(963);t.createCustomGlobalState=function(e){var t=e.onInitialize,o=e.onChange;return function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=n.callbacks,c=a(n,["callbacks"]);return(0,l.createGlobalState)(e,Object.assign(Object.assign({},c),{callbacks:Object.assign(Object.assign({},null!=r?r:{}),{onInit:function(e){var o;null==t||t(e,null==c?void 0:c.config),null===(o=null==r?void 0:r.onInit)||void 0===o||o.call(r,e)},onStateChanged:function(e){var t;null==o||o(e,null==c?void 0:c.config),null===(t=null==r?void 0:r.onStateChanged)||void 0===t||t.call(r,e)}})}))}},t.default=t.createCustomGlobalState},963:t=>{t.exports=e}},o={};var a=function e(a){var l=o[a];if(void 0!==l)return l.exports;var n=o[a]={exports:{}};return t[a](n,n.exports,e),n.exports}(362);return a})()));
@@ -1,4 +1,4 @@
1
- import { ActionCollectionConfig, StateSetter, ActionCollectionResult, StateHook, BaseMetadata, GlobalStoreCallbacks } from './types';
1
+ import type { ActionCollectionConfig, StateSetter, ActionCollectionResult, StateHook, BaseMetadata, GlobalStoreCallbacks } from './types';
2
2
  export interface CreateGlobalState {
3
3
  <State>(state: State): StateHook<State, StateSetter<State>, BaseMetadata>;
4
4
  <State, Metadata extends BaseMetadata | unknown, ActionsConfig extends ActionCollectionConfig<State, Metadata> | null | {}, PublicStateMutator = keyof ActionsConfig extends never | undefined ? StateSetter<State> : ActionCollectionResult<State, Metadata, NonNullable<ActionsConfig>>>(state: State, args: {
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react")):"function"==typeof define&&define.amd?define(["react"],e):"object"==typeof exports?exports["react-hooks-global-states"]=e(require("react")):t["react-hooks-global-states"]=e(t.react)}(this,(t=>{return e={774:(t,e,r)=>{"use strict";function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function o(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],s=!0,c=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);s=!0);}catch(t){c=!0,o=t}finally{try{if(!s&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return u}}(t,e)||i(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(t,e){if(t){if("string"==typeof t)return a(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?a(t,e):void 0}}function a(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function u(){u=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",s=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function l(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var i=e&&e.prototype instanceof v?e:v,a=Object.create(i.prototype),u=new k(n||[]);return o(a,"_invoke",{value:_(t,r,u)}),a}function d(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=f;var p={};function v(){}function h(){}function b(){}var y={};l(y,a,(function(){return this}));var g=Object.getPrototypeOf,m=g&&g(g(x([])));m&&m!==e&&r.call(m,a)&&(y=m);var S=b.prototype=v.prototype=Object.create(y);function w(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function i(o,a,u,s){var c=d(t[o],t,a);if("throw"!==c.type){var l=c.arg,f=l.value;return f&&"object"==n(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){i("next",t,u,s)}),(function(t){i("throw",t,u,s)})):e.resolve(f).then((function(t){l.value=t,u(l)}),(function(t){return i("throw",t,u,s)}))}s(c.arg)}var a;o(this,"_invoke",{value:function(t,r){function n(){return new e((function(e,n){i(t,r,e,n)}))}return a=a?a.then(n,n):n()}})}function _(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var u=E(a,r);if(u){if(u===p)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var s=d(t,e,r);if("normal"===s.type){if(n=r.done?"completed":"suspendedYield",s.arg===p)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(n="completed",r.method="throw",r.arg=s.arg)}}}function E(t,e){var r=e.method,n=t.iterator[r];if(void 0===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=void 0,E(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),p;var o=d(n,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,p;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,p):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,p)}function A(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function j(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function x(t){if(t){var e=t[a];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,o=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:C}}function C(){return{value:void 0,done:!0}}return h.prototype=b,o(S,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:h,configurable:!0}),h.displayName=l(b,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,l(t,c,"GeneratorFunction")),t.prototype=Object.create(S),t},t.awrap=function(t){return{__await:t}},w(O.prototype),l(O.prototype,s,(function(){return this})),t.AsyncIterator=O,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new O(f(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},w(S),l(S,c,"Generator"),l(S,a,(function(){return this})),l(S,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},t.values=x,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(j),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var u=r.call(i,"catchLoc"),s=r.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,p):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),p},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),j(r),p}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;j(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:x(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),p}},t}function s(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,c(n.key),n)}}function c(t){var e=function(t,e){if("object"!==n(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var o=r.call(t,e||"default");if("object"!==n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"===n(e)?e:String(e)}var l=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function a(t){try{s(n.next(t))}catch(t){i(t)}}function u(t){try{s(n.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,u)}s((n=n.apply(t,e||[])).next())}))};Object.defineProperty(e,"__esModule",{value:!0}),e.GlobalStore=void 0;var f=r(156),d=r(244),p=r(125),v=r(281),h=r(143),b=r(561),y=r(400),g=r(157),m=r(605),S=r(748),w=globalThis;!function(){if(!w.REACT_GLOBAL_STATE_HOOK_DEBUG&&!(0,p.isNil)(w.sessionStorage)){try{if(!w.sessionStorage.getItem("REACT_GLOBAL_STATE_HOOK_DEBUG"))return}catch(t){return}w.REACT_GLOBAL_STATE_TEMP_HOOKS=new Map,setTimeout((function(){w.REACT_GLOBAL_STATE_TEMP_HOOKS=null}),6e4)}}();var O=function(){function t(e){var r,n=this,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{metadata:{}};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.wasDisposed=!1,this.actionsConfig=null,this.callbacks=null,this.actions=null,this.subscribers=new Map,this.initialize=function(){return l(n,void 0,void 0,u().mark((function t(){var e,r,n,o,i,a;return u().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(Object.keys(null!==(e=this.actionsConfig)&&void 0!==e?e:{}).length>0&&(this.actions=this.getStoreActionsMap()),n=this.onInit,o=null!==(r=this.callbacks)&&void 0!==r?r:{},i=o.onInit,n||i){t.next=6;break}return t.abrupt("return");case 6:a=this.getConfigCallbackParam(),null==n||n(a),(0,p.isNil)(i)||null==i||i(a);case 9:case"end":return t.stop()}}),t,this)})))},this.executeSetStateForSubscriber=function(t,e){var r,o,i=t.selector,a=t.callback,u=t.currentState,s=t.config;if(!e.forceUpdate&&(null!==(r=null==s?void 0:s.isEqualRoot)&&void 0!==r?r:function(t,e){return t===e})(e.currentRootState,e.newRootState))return{didUpdate:!1};var c=i?i(e.newRootState):e.newRootState;return!e.forceUpdate&&(null!==(o=null==s?void 0:s.isEqual)&&void 0!==o?o:function(t,e){return t===e})(u,c)?{didUpdate:!1}:(n.partialUpdateSubscription(t.subscriptionId,{currentState:c}),a({state:c},{identifier:e.identifier}),{didUpdate:!0})},this.setState=function(t,e){var r=t.state,o=e.forceUpdate,a=e.identifier,u=n.stateWrapper.state;if(o||u!==r){n.stateWrapper={state:r};var s,c={forceUpdate:o,newRootState:r,currentRootState:u,identifier:a},l=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=i(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,u=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return u=t.done,t},e:function(t){s=!0,a=t},f:function(){try{u||null==r.return||r.return()}finally{if(s)throw a}}}}(n.subscribers.values());try{for(l.s();!(s=l.n()).done;){var f=s.value;n.executeSetStateForSubscriber(f,c)}}catch(t){l.e(t)}finally{l.f()}}},this.setMetadata=function(t){var e=(0,d.isFunction)(t)?t(n.metadata):t;n.metadata=e},this.getMetadata=function(){return n.metadata},this.getState=function(t,e,r){var o;if(!t)return n.stateWrapper.state;var i=(0,d.isFunction)(e),a=i?t:void 0,u=i?e:t,s=null!==(o=i?r:e)&&void 0!==o?o:void 0,c=a?a(n.stateWrapper.state):n.stateWrapper.state;(null==s?void 0:s.skipFirst)||u(c);var l=(0,g.uniqueId)("gs:");return n.setOrUpdateSubscription({subscriptionId:l,selector:a,config:s,currentState:c,callback:function(t){var e=t.state;return u(e)},isSetStateCallback:!1}),function(){n.subscribers.delete(l)}},this.getConfigCallbackParam=function(){var t=n.setMetadata,e=n.getMetadata,r=n.getState,o=n.actions;return{setMetadata:t,getMetadata:e,getState:r,setState:n.setStateWrapper,actions:o}},this.lastSubscriptionId=null,this.setOrUpdateSubscription=function(t){var e=t.subscriptionId;if(!e)return{isNewSubscription:!1};var r=n.subscribers.get(e);return(0,h.isRecord)(r)?(Object.assign(r,t),{isNewSubscription:!1}):(n.executeOnSubscribed(),n.subscribers.set(e,t),n.lastSubscriptionId=e,{isNewSubscription:!0})},this.partialUpdateSubscription=function(t,e){var r=n.subscribers.get(t);(0,h.isRecord)(r)&&Object.assign(r,e)},this.executeOnSubscribed=function(){var t,e=n.onSubscribed,r=null===(t=n.callbacks)||void 0===t?void 0:t.onSubscribed;if(e||r){var o=n.getConfigCallbackParam();null==e||e(o),null==r||r(o)}},this.getHook=function(){var t=function(t){var e,r,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(n.wasDisposed)throw new Error("The global state was disposed");var a=Array.isArray(i)?{dependencies:i}:null!=i?i:{},u=(0,f.useRef)({subscriptionId:null,tempInitialRootState:n.stateWrapper.state}),s=function(){return t?{state:t(n.stateWrapper.state)}:n.stateWrapper},c=o((0,f.useState)(s),2),l=c[0],d=c[1];(0,f.useEffect)((function(){if(!(0,p.isNil)(u.current)){(0,p.isNil)(u.current.subscriptionId)&&(u.current.subscriptionId=(0,g.uniqueId)("ss:"));var e=u.current.subscriptionId,r={subscriptionId:e,currentState:l.state,selector:t,config:a,callback:d,isSetStateCallback:!0};return n.setOrUpdateSubscription(r).isNewSubscription&&(n.executeSetStateForSubscriber(r,{forceUpdate:!1,newRootState:n.stateWrapper.state,currentRootState:u.current.tempInitialRootState===m.uniqueSymbol?n.stateWrapper.state:u.current.tempInitialRootState,identifier:"on mount state update"}),u.current.tempInitialRootState=m.uniqueSymbol),function(){n.subscribers.delete(e)}}}),[]);var h=(0,v.isString)(null===(e=u.current)||void 0===e?void 0:e.subscriptionId)?u.current.subscriptionId:"",b=n.subscribers.get(h),y=(null!==(r=null==b?void 0:b.config)&&void 0!==r?r:{dependencies:a.dependencies}).dependencies;return n.partialUpdateSubscription(h,{currentState:l.state,selector:t,config:a,callback:d}),[n.computeSelectedState({selector:t,subscriptionId:h,config:a,currentDependencies:y,computeChildState:s,stateWrapperRef:l}),n.getStateOrchestrator(),n.metadata]};return t.stateControls=n.stateControls,t.createSelectorHook=n.createSelectorHook,t.createObservable=n.createObservable,t.removeSubscriptions=n.removeSubscriptions,t.dispose=n.dispose,t},this.computeSelectedState=function(t){var e=t.selector,r=t.subscriptionId,o=t.config,i=t.currentDependencies,a=t.computeChildState,u=t.stateWrapperRef;if(!e||!r)return u.state;var s=o.dependencies;if(i===s)return u.state;if((null==i?void 0:i.length)===(null==s?void 0:s.length)&&(0,b.shallowCompare)(i,s))return u.state;var c=a().state;return n.partialUpdateSubscription(r,{currentState:c}),u.state=c,c},this.createSelectorHook=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=r.isEqualRoot,a=r.isEqual,u=r.name,s=o(n.stateControls(),3),c=s[0],l=s[1],f=s[2],p=c(),v=(null!=e?e:function(t){return t})(p),h=new t(v,{name:null!=u?u:(0,g.uniqueId)("sh:")}),b=o(h.stateControls(),2),y=b[0],m=b[1],S=c((function(t){if(!(null!=i?i:Object.is)(p,t)){p=t;var r=e(t);(null!=a?a:Object.is)(v,r)||(v=r,m(r))}}),{skipFirst:!0}),w=h.getHook(),O=function(t,e){return[o((0,d.isFunction)(t)?w(t,e):w(),1)[0],l,f]};return O.stateControls=function(){return[y,l,f]},O.createSelectorHook=n.createSelectorHook.bind(O),O.createObservable=n.createObservable.bind(O),O.removeSubscriptions=function(){S(),h.removeSubscriptions()},O.dispose=function(){O.removeSubscriptions(),h.dispose()},O},this.stateControls=function(){var t=n.getStateOrchestrator(),e=n.getMetadata;return[n.getState,t,e]},this.getStateOrchestrator=function(){return n.actions?n.actions:n.setStateWrapper},this.setStateWrapper=function(t){var e,r,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=o.forceUpdate,a=o.identifier,u=n.stateWrapper.state,s=(0,d.isFunction)(t)?t(u):t;if(i||n.stateWrapper.state!==s){var c=n.setMetadata,l=n.getMetadata,f=n.getState,p=n.actions,v={setMetadata:c,getMetadata:l,setState:n.setState,getState:f,actions:p,previousState:u,state:s,identifier:a},h=n.computePreventStateChange,b=null===(e=n.callbacks)||void 0===e?void 0:e.computePreventStateChange;if((h||b)&&((null==h?void 0:h(v))||(null==b?void 0:b(v))))return;n.setState({state:s},{forceUpdate:i,identifier:a});var y=n.onStateChanged,g=null===(r=n.callbacks)||void 0===r?void 0:r.onStateChanged;(y||g)&&(null==y||y(v),null==g||g(v))}},this.getStoreActionsMap=function(){if(!(0,h.isRecord)(n.actionsConfig))return null;var t=n.actionsConfig,e=n.setMetadata,r=n.setStateWrapper,o=n.getState,i=n.getMetadata,a=Object.keys(t).reduce((function(n,u){var s,l,f;return Object.assign(n,(s={},f=function(){for(var n=t[u],s=arguments.length,c=new Array(s),l=0;l<s;l++)c[l]=arguments[l];var f=n.apply(a,c);return"function"!=typeof f&&(0,y.throwWrongKeyOnActionCollectionConfig)(u),f.call(a,{setState:r,getState:o,setMetadata:e,getMetadata:i,actions:a})},(l=c(l=u))in s?Object.defineProperty(s,l,{value:f,enumerable:!0,configurable:!0,writable:!0}):s[l]=f,s)),n}),{});return a},this.removeSubscriptions=function(){n.subscribers.clear()},this.dispose=function(){n.wasDisposed=!0,n.removeSubscriptions(),n._name="",n.actionsConfig=null,n.callbacks=null,n.metadata={},n.actions=null,n.subscribers.clear(),n.stateWrapper={state:null}};var s=a.metadata,O=a.callbacks,_=a.actions,E=a.name;this.stateWrapper={state:e},this._name=null!=E?E:(0,g.uniqueId)("gs:"),this.metadata=null!=s?s:{},this.callbacks=null!=O?O:null,this.actionsConfig=null!=_?_:null;var A="";if((w.REACT_GLOBAL_STATE_HOOK_DEBUG||w.REACT_GLOBAL_STATE_TEMP_HOOKS)&&(A=(0,S.generateStackHash)(null!==(r=(new Error).stack)&&void 0!==r?r:"")),w.REACT_GLOBAL_STATE_HOOK_DEBUG)w.REACT_GLOBAL_STATE_HOOK_DEBUG(this,a,A);else if(w.REACT_GLOBAL_STATE_TEMP_HOOKS){var j=void 0!==globalThis.WeakRef?new globalThis.WeakRef(this):this,k=void 0!==globalThis.WeakRef?new globalThis.WeakRef(a):a;w.REACT_GLOBAL_STATE_TEMP_HOOKS.set(A,[j,k])}this.constructor!==t||this.initialize()}var e,r,n;return e=t,r=[{key:"createObservable",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=e.isEqualRoot,n=e.isEqual,i=e.name,a=o(this.stateControls(),1)[0],u=[],s=a(),c=(null!=t?t:function(t){return t})(a()),l=a((function(e){if(!(null!=r?r:Object.is)(s,e)){s=e;var o=t(e);(null!=n?n:Object.is)(c,o)||(c=o,u.forEach((function(t){return t()})))}}),{skipFirst:!0}),f=function(t,e,r){var n;if(!t)return c;var o=(0,d.isFunction)(e),i=o?t:void 0,a=o?e:t,s=null!==(n=o?r:e)&&void 0!==n?n:void 0,l=function(){return a(i?i(c):c)};(null==s?void 0:s.skipFirst)||l();var f=function(){l()};return u.push(f),function(){u.splice(u.indexOf(f),1)}};return f._name=null!=i?i:(0,g.uniqueId)("ob:"),f.createObservable=this.createObservable.bind(f),f.removeSubscriptions=function(){u.forEach((function(t){return t()})),u.length=0,l()},f.stateControls=function(){return[f]},f}}],r&&s(e.prototype,r),n&&s(e,n),Object.defineProperty(e,"prototype",{writable:!1}),t}();e.GlobalStore=O,e.default=O},196:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.createGlobalState=void 0;var n=r(774);e.createGlobalState=function(t,e){return new n.GlobalStore(t,e).getHook()},e.default=e.createGlobalState},748:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.generateStackHash=void 0,e.generateStackHash=function(t){if(!t.trim())return"unknown";t=t.replace(/\s/g,"");for(var e=2166136261,r=0;r<t.length;r++)e^=t.charCodeAt(r),e*=16777619,e&=4294967295;return function(t){for(var e="";t>0;)e="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[t%62]+e,t=Math.floor(t/62);return e||"0"}(e>>>0)},e.default=e.generateStackHash},143:(t,e,r)=>{"use strict";function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}Object.defineProperty(e,"__esModule",{value:!0}),e.isRecord=void 0;var o=r(125);e.isRecord=function(t){return!(0,o.isNil)(t)&&"object"===n(t)},e.default=e.isRecord},561:(t,e,r)=>{"use strict";function n(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],s=!0,c=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);s=!0);}catch(t){c=!0,o=t}finally{try{if(!s&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return u}}(t,e)||i(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=i(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,u=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return u=t.done,t},e:function(t){s=!0,a=t},f:function(){try{u||null==r.return||r.return()}finally{if(s)throw a}}}}function i(t,e){if(t){if("string"==typeof t)return a(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?a(t,e):void 0}}function a(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function u(t){return u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(t)}Object.defineProperty(e,"__esModule",{value:!0}),e.shallowCompare=void 0;var s=r(416),c=r(231),l=r(125),f=r(143);e.shallowCompare=function(t,e){if(t===e)return!0;var r=u(t),i=u(e);if(r!==i)return!1;if((0,l.isNil)(t)||(0,l.isNil)(e)||(0,s.isPrimitive)(t)&&(0,s.isPrimitive)(e)||(0,c.isDate)(t)&&(0,c.isDate)(e)||"function"===r&&"function"===i)return t===e;if(Array.isArray(t)){var a=t,d=e;if(a.length!==d.length)return!1;for(var p=0;p<a.length;p++)if(a[p]!==d[p])return!1}if(t instanceof Map){var v=t,h=e;if(v.size!==h.size)return!1;var b,y=o(v);try{for(y.s();!(b=y.n()).done;){var g=n(b.value,2),m=g[0];if(g[1]!==h.get(m))return!1}}catch(t){y.e(t)}finally{y.f()}}if(t instanceof Set){var S=t,w=e;if(S.size!==w.size)return!1;var O,_=o(S);try{for(_.s();!(O=_.n()).done;){var E=O.value;if(!w.has(E))return!1}}catch(t){_.e(t)}finally{_.f()}}if(!(0,f.isRecord)(t)||!(0,f.isRecord)(e))return t===e;var A=Object.keys(t),j=Object.keys(e);if(A.length!==j.length)return!1;for(var k=0,x=A;k<x.length;k++){var C=x[k];if(t[C]!==e[C])return!1}return!0},e.default=e.shallowCompare},400:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.throwWrongKeyOnActionCollectionConfig=void 0,e.throwWrongKeyOnActionCollectionConfig=function(t){throw new Error("[WRONG CONFIGURATION!]: Every key inside the storeActionsConfig must be a higher order function that returns a function \n[".concat(t,"]: key is not a valid function, try something like this: \n{\n\n ").concat(t,": (param) => ({ setState, getState, setMetadata, getMetadata, actions }) => {\n\n setState((state) => ({ ...state, ...param }))\n\n }\n\n}\n"))},e.default=e.throwWrongKeyOnActionCollectionConfig},157:(t,e)=>{"use strict";var r;Object.defineProperty(e,"__esModule",{value:!0}),e.uniqueId=void 0,e.uniqueId=(r=0,function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return r===Number.MAX_SAFE_INTEGER&&(r=0),t+Date.now().toString(36)+(r++).toString(36)}),e.default=e.uniqueId},605:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.uniqueSymbol=void 0,e.uniqueSymbol=Symbol("unique"),e.default=e.uniqueSymbol},231:function(t){t.exports=(()=>{"use strict";var t={};return(()=>{var e=t;Object.defineProperty(e,"__esModule",{value:!0}),e.isDate=void 0,e.isDate=function(t){return t instanceof Date}})(),t})()},244:function(t){t.exports=(()=>{"use strict";var t={};return(()=>{var e=t;Object.defineProperty(e,"__esModule",{value:!0}),e.isFunction=void 0,e.isFunction=function(t){return"function"==typeof t||t instanceof Function}})(),t})()},125:function(t){t.exports=(()=>{"use strict";var t={};return(()=>{var e=t;Object.defineProperty(e,"__esModule",{value:!0}),e.isNil=void 0,e.isNil=function(t){return null==t}})(),t})()},416:function(t){t.exports=(()=>{"use strict";var t={112:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isBoolean=void 0,e.isBoolean=function(t){return"boolean"==typeof t}},243:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isNil=void 0,e.isNil=function(t){return null==t}},11:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isNumber=void 0,e.isNumber=function(t){return"number"==typeof t}},671:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isString=void 0,e.isString=function(t){return"string"==typeof t}}},e={};function r(n){var o=e[n];if(void 0!==o)return o.exports;var i=e[n]={exports:{}};return t[n](i,i.exports,r),i.exports}var n={};return(()=>{var t=n;function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},e(t)}Object.defineProperty(t,"__esModule",{value:!0}),t.isPrimitive=void 0;var o=r(112),i=r(243),a=r(11),u=r(671);t.isPrimitive=function(t){return(0,i.isNil)(t)||(0,a.isNumber)(t)||(0,o.isBoolean)(t)||(0,u.isString)(t)||"symbol"===e(t)}})(),n})()},281:function(t){t.exports=(()=>{"use strict";var t={};return(()=>{var e=t;Object.defineProperty(e,"__esModule",{value:!0}),e.isString=void 0,e.isString=function(t){return"string"==typeof t}})(),t})()},156:e=>{"use strict";e.exports=t}},r={},function t(n){var o=r[n];if(void 0!==o)return o.exports;var i=r[n]={exports:{}};return e[n].call(i.exports,i,i.exports,t),i.exports}(196);var e,r}));
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("./GlobalStore.js")):"function"==typeof define&&define.amd?define(["./GlobalStore.js"],t):"object"==typeof exports?exports["react-hooks-global-states"]=t(require("./GlobalStore.js")):e["react-hooks-global-states"]=t(e["./GlobalStore.js"])}(this,(e=>(()=>{"use strict";var t={196:(e,t,o)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createGlobalState=void 0;var r=o(352);t.createGlobalState=function(e,t){return new r.GlobalStore(e,t).getHook()},t.default=t.createGlobalState},352:t=>{t.exports=e}},o={};var r=function e(r){var a=o[r];if(void 0!==a)return a.exports;var l=o[r]={exports:{}};return t[r](l,l.exports,e),l.exports}(196);return r})()));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-hooks-global-states",
3
- "version": "7.0.12",
3
+ "version": "7.0.14",
4
4
  "description": "This is a package to easily handling global-state across your react-components using hooks.",
5
5
  "main": "./bundle.js",
6
6
  "types": "./index.d.ts",
@@ -90,7 +90,7 @@
90
90
  "test:debug": "node --inspect-brk node_modules/.bin/jest --watch --runInBand",
91
91
  "test:quick": "jest --maxWorkers=4 -c --no-watchman -u",
92
92
  "test:coverage": "jest --maxWorkers=4 -c --colors --no-watchman --verbose --coverage",
93
- "build": "webpack --config webpack.config.js",
93
+ "build": "yarn clean && webpack --config webpack.config.js",
94
94
  "prepare": "npm run build",
95
95
  "version": "npm run format && git add -A src",
96
96
  "postversion": "git push && git push --tags",
package/shallowCompare.js CHANGED
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["react-hooks-global-states"]=t():e["react-hooks-global-states"]=t()}(this,(()=>{return e={143:(e,t,r)=>{"use strict";function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.isRecord=void 0;var o=r(125);t.isRecord=function(e){return!(0,o.isNil)(e)&&"object"===n(e)},t.default=t.isRecord},561:(e,t,r)=>{"use strict";function n(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,u,f=[],l=!0,a=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;l=!1}else for(;!(l=(n=i.call(r)).done)&&(f.push(n.value),f.length!==t);l=!0);}catch(e){a=!0,o=e}finally{try{if(!l&&null!=r.return&&(u=r.return(),Object(u)!==u))return}finally{if(a)throw o}}return f}}(e,t)||i(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=i(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var u,f=!0,l=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return f=e.done,e},e:function(e){l=!0,u=e},f:function(){try{f||null==r.return||r.return()}finally{if(l)throw u}}}}function i(e,t){if(e){if("string"==typeof e)return u(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?u(e,t):void 0}}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function f(e){return f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},f(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.shallowCompare=void 0;var l=r(416),a=r(231),s=r(125),c=r(143);t.shallowCompare=function(e,t){if(e===t)return!0;var r=f(e),i=f(t);if(r!==i)return!1;if((0,s.isNil)(e)||(0,s.isNil)(t)||(0,l.isPrimitive)(e)&&(0,l.isPrimitive)(t)||(0,a.isDate)(e)&&(0,a.isDate)(t)||"function"===r&&"function"===i)return e===t;if(Array.isArray(e)){var u=e,y=t;if(u.length!==y.length)return!1;for(var p=0;p<u.length;p++)if(u[p]!==y[p])return!1}if(e instanceof Map){var v=e,b=t;if(v.size!==b.size)return!1;var d,m=o(v);try{for(m.s();!(d=m.n()).done;){var h=n(d.value,2),S=h[0];if(h[1]!==b.get(S))return!1}}catch(e){m.e(e)}finally{m.f()}}if(e instanceof Set){var g=e,j=t;if(g.size!==j.size)return!1;var x,_=o(g);try{for(_.s();!(x=_.n()).done;){var O=x.value;if(!j.has(O))return!1}}catch(e){_.e(e)}finally{_.f()}}if(!(0,c.isRecord)(e)||!(0,c.isRecord)(t))return e===t;var P=Object.keys(e),w=Object.keys(t);if(P.length!==w.length)return!1;for(var M=0,N=P;M<N.length;M++){var A=N[M];if(e[A]!==t[A])return!1}return!0},t.default=t.shallowCompare},231:function(e){e.exports=(()=>{"use strict";var e={};return(()=>{var t=e;Object.defineProperty(t,"__esModule",{value:!0}),t.isDate=void 0,t.isDate=function(e){return e instanceof Date}})(),e})()},125:function(e){e.exports=(()=>{"use strict";var e={};return(()=>{var t=e;Object.defineProperty(t,"__esModule",{value:!0}),t.isNil=void 0,t.isNil=function(e){return null==e}})(),e})()},416:function(e){e.exports=(()=>{"use strict";var e={112:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isBoolean=void 0,t.isBoolean=function(e){return"boolean"==typeof e}},243:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isNil=void 0,t.isNil=function(e){return null==e}},11:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isNumber=void 0,t.isNumber=function(e){return"number"==typeof e}},671:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isString=void 0,t.isString=function(e){return"string"==typeof e}}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return e[n](i,i.exports,r),i.exports}var n={};return(()=>{var e=n;function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},t(e)}Object.defineProperty(e,"__esModule",{value:!0}),e.isPrimitive=void 0;var o=r(112),i=r(243),u=r(11),f=r(671);e.isPrimitive=function(e){return(0,i.isNil)(e)||(0,u.isNumber)(e)||(0,o.isBoolean)(e)||(0,f.isString)(e)||"symbol"===t(e)}})(),n})()}},t={},function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return e[n].call(i.exports,i,i.exports,r),i.exports}(561);var e,t}));
1
+ !function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r(require("./isRecord.js")):"function"==typeof define&&define.amd?define(["./isRecord.js"],r):"object"==typeof exports?exports["react-hooks-global-states"]=r(require("./isRecord.js")):e["react-hooks-global-states"]=r(e["./isRecord.js"])}(this,(e=>{return r={561:(e,r,t)=>{"use strict";function n(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,r){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var n,o,i,u,a=[],f=!0,l=!1;try{if(i=(t=t.call(e)).next,0===r){if(Object(t)!==t)return;f=!1}else for(;!(f=(n=i.call(t)).done)&&(a.push(n.value),a.length!==r);f=!0);}catch(e){l=!0,o=e}finally{try{if(!f&&null!=t.return&&(u=t.return(),Object(u)!==u))return}finally{if(l)throw o}}return a}}(e,r)||i(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e,r){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=i(e))||r&&e&&"number"==typeof e.length){t&&(e=t);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var u,a=!0,f=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return a=e.done,e},e:function(e){f=!0,u=e},f:function(){try{a||null==t.return||t.return()}finally{if(f)throw u}}}}function i(e,r){if(e){if("string"==typeof e)return u(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?u(e,r):void 0}}function u(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function a(e){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a(e)}Object.defineProperty(r,"__esModule",{value:!0}),r.shallowCompare=void 0;var f=t(416),l=t(231),s=t(125),c=t(664);r.shallowCompare=function(e,r){if(e===r)return!0;var t=a(e),i=a(r);if(t!==i)return!1;if((0,s.isNil)(e)||(0,s.isNil)(r)||(0,f.isPrimitive)(e)&&(0,f.isPrimitive)(r)||(0,l.isDate)(e)&&(0,l.isDate)(r)||"function"===t&&"function"===i)return e===r;if(Array.isArray(e)){var u=e,y=r;if(u.length!==y.length)return!1;for(var v=0;v<u.length;v++)if(u[v]!==y[v])return!1}if(e instanceof Map){var p=e,d=r;if(p.size!==d.size)return!1;var b,m=o(p);try{for(m.s();!(b=m.n()).done;){var h=n(b.value,2),j=h[0];if(h[1]!==d.get(j))return!1}}catch(e){m.e(e)}finally{m.f()}}if(e instanceof Set){var S=e,g=r;if(S.size!==g.size)return!1;var x,_=o(S);try{for(_.s();!(x=_.n()).done;){var O=x.value;if(!g.has(O))return!1}}catch(e){_.e(e)}finally{_.f()}}if(!(0,c.isRecord)(e)||!(0,c.isRecord)(r))return e===r;var P=Object.keys(e),w=Object.keys(r);if(P.length!==w.length)return!1;for(var A=0,M=P;A<M.length;A++){var N=M[A];if(e[N]!==r[N])return!1}return!0},r.default=r.shallowCompare},231:function(e){e.exports=(()=>{"use strict";var e={};return(()=>{var r=e;Object.defineProperty(r,"__esModule",{value:!0}),r.isDate=void 0,r.isDate=function(e){return e instanceof Date}})(),e})()},125:function(e){e.exports=(()=>{"use strict";var e={};return(()=>{var r=e;Object.defineProperty(r,"__esModule",{value:!0}),r.isNil=void 0,r.isNil=function(e){return null==e}})(),e})()},416:function(e){e.exports=(()=>{"use strict";var e={112:(e,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.isBoolean=void 0,r.isBoolean=function(e){return"boolean"==typeof e}},243:(e,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.isNil=void 0,r.isNil=function(e){return null==e}},11:(e,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.isNumber=void 0,r.isNumber=function(e){return"number"==typeof e}},671:(e,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.isString=void 0,r.isString=function(e){return"string"==typeof e}}},r={};function t(n){var o=r[n];if(void 0!==o)return o.exports;var i=r[n]={exports:{}};return e[n](i,i.exports,t),i.exports}var n={};return(()=>{var e=n;function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}Object.defineProperty(e,"__esModule",{value:!0}),e.isPrimitive=void 0;var o=t(112),i=t(243),u=t(11),a=t(671);e.isPrimitive=function(e){return(0,i.isNil)(e)||(0,u.isNumber)(e)||(0,o.isBoolean)(e)||(0,a.isString)(e)||"symbol"===r(e)}})(),n})()},664:r=>{"use strict";r.exports=e}},t={},function e(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return r[n].call(i.exports,i,i.exports,e),i.exports}(561);var r,t}));
package/useStableState.js CHANGED
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):"object"==typeof exports?exports["react-hooks-global-states"]=t(require("react")):e["react-hooks-global-states"]=t(e.react)}(this,(e=>{return t={143:(e,t,r)=>{"use strict";function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.isRecord=void 0;var o=r(125);t.isRecord=function(e){return!(0,o.isNil)(e)&&"object"===n(e)},t.default=t.isRecord},561:(e,t,r)=>{"use strict";function n(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,u,l=[],a=!0,f=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;a=!1}else for(;!(a=(n=i.call(r)).done)&&(l.push(n.value),l.length!==t);a=!0);}catch(e){f=!0,o=e}finally{try{if(!a&&null!=r.return&&(u=r.return(),Object(u)!==u))return}finally{if(f)throw o}}return l}}(e,t)||i(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=i(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var u,l=!0,a=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return l=e.done,e},e:function(e){a=!0,u=e},f:function(){try{l||null==r.return||r.return()}finally{if(a)throw u}}}}function i(e,t){if(e){if("string"==typeof e)return u(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?u(e,t):void 0}}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function l(e){return l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},l(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.shallowCompare=void 0;var a=r(416),f=r(231),c=r(125),s=r(143);t.shallowCompare=function(e,t){if(e===t)return!0;var r=l(e),i=l(t);if(r!==i)return!1;if((0,c.isNil)(e)||(0,c.isNil)(t)||(0,a.isPrimitive)(e)&&(0,a.isPrimitive)(t)||(0,f.isDate)(e)&&(0,f.isDate)(t)||"function"===r&&"function"===i)return e===t;if(Array.isArray(e)){var u=e,y=t;if(u.length!==y.length)return!1;for(var v=0;v<u.length;v++)if(u[v]!==y[v])return!1}if(e instanceof Map){var d=e,p=t;if(d.size!==p.size)return!1;var b,m=o(d);try{for(m.s();!(b=m.n()).done;){var h=n(b.value,2),S=h[0];if(h[1]!==p.get(S))return!1}}catch(e){m.e(e)}finally{m.f()}}if(e instanceof Set){var g=e,j=t;if(g.size!==j.size)return!1;var _,x=o(g);try{for(x.s();!(_=x.n()).done;){var O=_.value;if(!j.has(O))return!1}}catch(e){x.e(e)}finally{x.f()}}if(!(0,s.isRecord)(e)||!(0,s.isRecord)(t))return e===t;var w=Object.keys(e),A=Object.keys(t);if(w.length!==A.length)return!1;for(var P=0,M=w;P<M.length;P++){var N=M[P];if(e[N]!==t[N])return!1}return!0},t.default=t.shallowCompare},965:(e,t,r)=>{"use strict";function n(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,u,l=[],a=!0,f=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;a=!1}else for(;!(a=(n=i.call(r)).done)&&(l.push(n.value),l.length!==t);a=!0);}catch(e){f=!0,o=e}finally{try{if(!a&&null!=r.return&&(u=r.return(),Object(u)!==u))return}finally{if(f)throw o}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return o(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}Object.defineProperty(t,"__esModule",{value:!0}),t.useStableState=void 0;var i=r(156),u=r(244),l=r(125),a=r(561),f=r(156),c=r(156);t.useStableState=function(e){var t=(0,u.isFunction)(arguments.length<=1?void 0:arguments[1])?arguments.length<=1?void 0:arguments[1]:void 0,r=t?arguments.length<=2?void 0:arguments[2]:arguments.length<=1?void 0:arguments[1],o=(0,i.useRef)({builder:null,cleanup:t,dependencies:r}),s=(0,u.isFunction)(e)?e:function(){return e},y=n((0,f.useState)((function(){return{value:s()}})),2),v=y[0],d=y[1],p=(0,l.isNil)(o.current.builder),b=(0,l.isNil)(r)||!(0,a.shallowCompare)(o.current.dependencies,r);!p&&b&&(v.value=s()),o.current.dependencies=r,o.current.builder=s,o.current.cleanup=t;var m=(0,c.useCallback)((function(){d({value:o.current.builder()})}),[]);return(0,i.useEffect)((function(){return function(){o.current.cleanup&&o.current.cleanup(v.value)}}),[]),[v,m]},t.default=t.useStableState},231:function(e){e.exports=(()=>{"use strict";var e={};return(()=>{var t=e;Object.defineProperty(t,"__esModule",{value:!0}),t.isDate=void 0,t.isDate=function(e){return e instanceof Date}})(),e})()},244:function(e){e.exports=(()=>{"use strict";var e={};return(()=>{var t=e;Object.defineProperty(t,"__esModule",{value:!0}),t.isFunction=void 0,t.isFunction=function(e){return"function"==typeof e||e instanceof Function}})(),e})()},125:function(e){e.exports=(()=>{"use strict";var e={};return(()=>{var t=e;Object.defineProperty(t,"__esModule",{value:!0}),t.isNil=void 0,t.isNil=function(e){return null==e}})(),e})()},416:function(e){e.exports=(()=>{"use strict";var e={112:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isBoolean=void 0,t.isBoolean=function(e){return"boolean"==typeof e}},243:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isNil=void 0,t.isNil=function(e){return null==e}},11:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isNumber=void 0,t.isNumber=function(e){return"number"==typeof e}},671:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isString=void 0,t.isString=function(e){return"string"==typeof e}}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return e[n](i,i.exports,r),i.exports}var n={};return(()=>{var e=n;function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},t(e)}Object.defineProperty(e,"__esModule",{value:!0}),e.isPrimitive=void 0;var o=r(112),i=r(243),u=r(11),l=r(671);e.isPrimitive=function(e){return(0,i.isNil)(e)||(0,u.isNumber)(e)||(0,o.isBoolean)(e)||(0,l.isString)(e)||"symbol"===t(e)}})(),n})()},156:t=>{"use strict";t.exports=e}},r={},function e(n){var o=r[n];if(void 0!==o)return o.exports;var i=r[n]={exports:{}};return t[n].call(i.exports,i,i.exports,e),i.exports}(965);var t,r}));
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("./shallowCompare.js"),require("react")):"function"==typeof define&&define.amd?define(["./shallowCompare.js","react"],t):"object"==typeof exports?exports["react-hooks-global-states"]=t(require("./shallowCompare.js"),require("react")):e["react-hooks-global-states"]=t(e["./shallowCompare.js"],e.react)}(this,((e,t)=>{return r={965:(e,t,r)=>{"use strict";function n(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,u,i,l=[],a=!0,c=!1;try{if(u=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;a=!1}else for(;!(a=(n=u.call(r)).done)&&(l.push(n.value),l.length!==t);a=!0);}catch(e){c=!0,o=e}finally{try{if(!a&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(c)throw o}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return o(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}Object.defineProperty(t,"__esModule",{value:!0}),t.useStableState=void 0;var u=r(156),i=r(244),l=r(125),a=r(682),c=r(156),s=r(156);t.useStableState=function(e){var t=(0,i.isFunction)(arguments.length<=1?void 0:arguments[1])?arguments.length<=1?void 0:arguments[1]:void 0,r=t?arguments.length<=2?void 0:arguments[2]:arguments.length<=1?void 0:arguments[1],o=(0,u.useRef)({builder:null,cleanup:t,dependencies:r}),f=(0,i.isFunction)(e)?e:function(){return e},p=n((0,c.useState)((function(){return{value:f()}})),2),d=p[0],v=p[1],b=(0,l.isNil)(o.current.builder),y=(0,l.isNil)(r)||!(0,a.shallowCompare)(o.current.dependencies,r);!b&&y&&(d.value=f()),o.current.dependencies=r,o.current.builder=f,o.current.cleanup=t;var h=(0,s.useCallback)((function(){v({value:o.current.builder()})}),[]);return(0,u.useEffect)((function(){return function(){o.current.cleanup&&o.current.cleanup(d.value)}}),[]),[d,h]},t.default=t.useStableState},244:function(e){e.exports=(()=>{"use strict";var e={};return(()=>{var t=e;Object.defineProperty(t,"__esModule",{value:!0}),t.isFunction=void 0,t.isFunction=function(e){return"function"==typeof e||e instanceof Function}})(),e})()},125:function(e){e.exports=(()=>{"use strict";var e={};return(()=>{var t=e;Object.defineProperty(t,"__esModule",{value:!0}),t.isNil=void 0,t.isNil=function(e){return null==e}})(),e})()},682:t=>{"use strict";t.exports=e},156:e=>{"use strict";e.exports=t}},n={},function e(t){var o=n[t];if(void 0!==o)return o.exports;var u=n[t]={exports:{}};return r[t].call(u.exports,u,u.exports,e),u.exports}(965);var r,n}));
package/webpack.config.js CHANGED
@@ -22,6 +22,20 @@ module.exports = {
22
22
  },
23
23
  externals: {
24
24
  react: 'react',
25
+ './createContext': './createContext.js',
26
+ './GlobalStore': './GlobalStore.js',
27
+ './GlobalStoreAbstract': './GlobalStoreAbstract.js',
28
+ './createCustomGlobalState': './createCustomGlobalState.js',
29
+ './createGlobalState': './createGlobalState.js',
30
+ './types': './types.js',
31
+ './debounce': './src/debounce.ts',
32
+ './isRecord': './isRecord.js',
33
+ './shallowCompare': './shallowCompare.js',
34
+ './throwWrongKeyOnActionCollectionConfig': './throwWrongKeyOnActionCollectionConfig.js',
35
+ './uniqueId': './uniqueId.js',
36
+ './uniqueSymbol': './uniqueSymbol.js',
37
+ './useStableState': './useStableState.js',
38
+ './generateStackHash': './generateStackHash.js',
25
39
  },
26
40
  output: {
27
41
  path: path.resolve(__dirname),