UNPKG

react-native-global-state-hooks

Version:

This is a package to easily handling global-state across your react-native-components No-redux... The library now includes @react-native-async-storage/async-storage to persist your state across sessions... if you want to keep using the old version without

1 lines 32.2 kB
var t,e;t=this,e=(t,e,r,n,o,i,a)=>(()=>{var u={38:e=>{"use strict";e.exports=t},155:t=>{"use strict";t.exports=e},237:function(t,e,r){var n;n=(t,e,r,n)=>(()=>{"use strict";var o={38:e=>{e.exports=t},487:t=>{t.exports=e},773:t=>{t.exports=r},955:t=>{t.exports=n},973:(t,e,r)=>{function n(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=o(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}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 o(t,e){if(t){if("string"==typeof t)return i(t,e);var r={}.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=Array(e);r<e;r++)n[r]=t[r];return n}function a(t){return a="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},a(t)}Object.defineProperty(e,"__esModule",{value:!0}),e.isEqualObject=e.isEqualSet=e.isEqualMap=e.isEqualArray=e.canCheckSimpleEquality=e.isSet=e.isMap=e.isArray=e.shallowCompare=void 0;var u=r(955),c=r(38),s=r(773),l=r(487);e.shallowCompare=function(t,r){return!(t!==r)||((0,e.canCheckSimpleEquality)(t,r)?t===r:(0,e.isArray)(t)&&(0,e.isArray)(r)?(0,e.isEqualArray)(t,r):(0,e.isMap)(t)&&(0,e.isMap)(r)?(0,e.isEqualMap)(t,r):(0,e.isSet)(t)&&(0,e.isSet)(r)?(0,e.isEqualSet)(t,r):(0,l.isRecord)(t)&&(0,l.isRecord)(r)?(0,e.isEqualObject)(t,r):t===r)},e.isArray=function(t){return Array.isArray(t)},e.isMap=function(t){return t instanceof Map},e.isSet=function(t){return t instanceof Set},e.canCheckSimpleEquality=function(t,e){var r=a(t),n=a(e);return r!==n||(0,s.isNil)(t)||(0,s.isNil)(e)||(0,u.isPrimitive)(t)&&(0,u.isPrimitive)(e)||(0,c.isDate)(t)&&(0,c.isDate)(e)||"function"===r&&"function"===n},e.isEqualArray=function(t,e){if(t.length!==e.length)return!1;for(var r=0;r<t.length;r+=1)if(t[r]!==e[r])return!1;return!0},e.isEqualMap=function(t,e){if(t.size!==e.size)return!1;var r,i,a=n(t);try{for(a.s();!(r=a.n()).done;){var u=function(t){if(Array.isArray(t))return t}(i=r.value)||function(t){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var r,n,o,i,a=[],u=!0,c=!1;try{for(o=(e=e.call(t)).next;!(u=(r=o.call(e)).done)&&(a.push(r.value),2!==a.length);u=!0);}catch(t){c=!0,n=t}finally{try{if(!u&&null!=e.return&&(i=e.return(),Object(i)!==i))return}finally{if(c)throw n}}return a}}(i)||o(i,2)||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.")}(),c=u[0];if(u[1]!==e.get(c))return!1}}catch(t){a.e(t)}finally{a.f()}return!0},e.isEqualSet=function(t,e){if(t.size!==e.size)return!1;var r,o=n(t);try{for(o.s();!(r=o.n()).done;){var i=r.value;if(!e.has(i))return!1}}catch(t){o.e(t)}finally{o.f()}return!0},e.isEqualObject=function(t,e){var r=Object.keys(t),n=Object.keys(e);if(r.length!==n.length)return!1;for(var o=0,i=r;o<i.length;o++){var a=i[o];if(t[a]!==e[a])return!1}return!0},e.default=e.shallowCompare}},i={};return function t(e){var r=i[e];if(void 0!==r)return r.exports;var n=i[e]={exports:{}};return o[e](n,n.exports,t),n.exports}(973)})(),t.exports=n(r(38),r(947),r(773),r(955))},316:function(t,e,r){var n;n=(t,e,r,n,o,i,a)=>(()=>{"use strict";var u={78:e=>{e.exports=t},155:t=>{t.exports=e},361:t=>{t.exports=r},487:t=>{t.exports=n},506:t=>{t.exports=o},673:t=>{t.exports=i},773:t=>{t.exports=a},811:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0});var r=globalThis;r.isDevToolsPresent=Boolean(r.REACT_GLOBAL_STATE_HOOK_DEBUG),e.default=r}},c={};function s(t){var e=c[t];if(void 0!==e)return e.exports;var r=c[t]={exports:{}};return u[t](r,r.exports,s),r.exports}var l={};return(()=>{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){if(t){if("string"==typeof t)return n(t,e);var r={}.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)?n(t,e):void 0}}function n(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function o(){o=function(){return r};var t,r={},n=Object.prototype,i=n.hasOwnProperty,a=Object.defineProperty||function(t,e,r){t[e]=r.value},u="function"==typeof Symbol?Symbol:{},c=u.iterator||"@@iterator",s=u.asyncIterator||"@@asyncIterator",l=u.toStringTag||"@@toStringTag";function f(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{f({},"")}catch(t){f=function(t,e,r){return t[e]=r}}function p(t,e,r,n){var o=e&&e.prototype instanceof m?e:m,i=Object.create(o.prototype),u=new q(n||[]);return a(i,"_invoke",{value:k(t,r,u)}),i}function y(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}r.wrap=p;var d="suspendedStart",v="suspendedYield",b="executing",h="completed",g={};function m(){}function S(){}function w(){}var j={};f(j,c,function(){return this});var O=Object.getPrototypeOf,x=O&&O(O(I([])));x&&x!==n&&i.call(x,c)&&(j=x);var E=w.prototype=m.prototype=Object.create(j);function _(t){["next","throw","return"].forEach(function(e){f(t,e,function(t){return this._invoke(e,t)})})}function A(t,r){function n(o,a,u,c){var s=y(t[o],t,a);if("throw"!==s.type){var l=s.arg,f=l.value;return f&&"object"==e(f)&&i.call(f,"__await")?r.resolve(f.__await).then(function(t){n("next",t,u,c)},function(t){n("throw",t,u,c)}):r.resolve(f).then(function(t){l.value=t,u(l)},function(t){return n("throw",t,u,c)})}c(s.arg)}var o;a(this,"_invoke",{value:function(t,e){function i(){return new r(function(r,o){n(t,e,r,o)})}return o=o?o.then(i,i):i()}})}function k(e,r,n){var o=d;return function(i,a){if(o===b)throw Error("Generator is already running");if(o===h){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var u=n.delegate;if(u){var c=P(u,n);if(c){if(c===g)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===d)throw o=h,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=b;var s=y(e,r,n);if("normal"===s.type){if(o=n.done?h:v,s.arg===g)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=h,n.method="throw",n.arg=s.arg)}}}function P(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,P(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var i=y(o,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,g;var a=i.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,g):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}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 M(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function q(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(C,this),this.reset(!0)}function I(r){if(r||""===r){var n=r[c];if(n)return n.call(r);if("function"==typeof r.next)return r;if(!isNaN(r.length)){var o=-1,a=function e(){for(;++o<r.length;)if(i.call(r,o))return e.value=r[o],e.done=!1,e;return e.value=t,e.done=!0,e};return a.next=a}}throw new TypeError(e(r)+" is not iterable")}return S.prototype=w,a(E,"constructor",{value:w,configurable:!0}),a(w,"constructor",{value:S,configurable:!0}),S.displayName=f(w,l,"GeneratorFunction"),r.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===S||"GeneratorFunction"===(e.displayName||e.name))},r.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,f(t,l,"GeneratorFunction")),t.prototype=Object.create(E),t},r.awrap=function(t){return{__await:t}},_(A.prototype),f(A.prototype,s,function(){return this}),r.AsyncIterator=A,r.async=function(t,e,n,o,i){void 0===i&&(i=Promise);var a=new A(p(t,e,n,o),i);return r.isGeneratorFunction(e)?a:a.next().then(function(t){return t.done?t.value:a.next()})},_(E),f(E,l,"Generator"),f(E,c,function(){return this}),f(E,"toString",function(){return"[object Generator]"}),r.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}},r.values=I,q.prototype={constructor:q,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(M),!e)for(var r in this)"t"===r.charAt(0)&&i.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function n(n,o){return u.type="throw",u.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],u=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var c=i.call(a,"catchLoc"),s=i.call(a,"finallyLoc");if(c&&s){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&i.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;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,g):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),g},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),M(r),g}},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;M(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:I(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),g}},r}function i(t){var r=function(t){if("object"!=e(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=e(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==e(r)?r:r+""}Object.defineProperty(t,"__esModule",{value:!0}),t.GlobalStore=void 0,t.createObservable=g,t.createSelectorHook=m;var a,u=s(155),c=s(506),f=s(773),p=s(487),y=s(673),d=s(361),v=s(78),b=(a=s(811))&&a.__esModule?a:{default:a},h=function(t){return Object.defineProperty(t,"prototype",{writable:!1}),t}(function t(e){var n,a,s=this,l=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.actionsConfig=null,this.callbacks=null,this.actions=null,this.subscribers=new Set,this.initialize=function(){return t=s,e=void 0,r=o().mark(function t(){var e,r,n,i,a,u,c;return o().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(r=this.getStoreActionsMap(),n=r.actions,i=r.storeTools,this.actions=n,this.storeTools=i,this.use=this.getMainHook(),a=this.onInit,u=null!==(e=this.callbacks)&&void 0!==e?e:{},c=u.onInit,a||c){t.next=8;break}return t.abrupt("return");case 8:null==a||a(i),(0,f.isNil)(c)||null==c||c(i);case 10:case"end":return t.stop()}},t,this)}),new(e||(e=Promise))(function(n,o){function i(t){try{u(r.next(t))}catch(t){o(t)}}function a(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var r;t.done?n(t.value):(r=t.value,r instanceof e?r:new e(function(t){t(r)})).then(i,a)}u((r=r.apply(t,[])).next())});var t,e,r},this.executeSetStateForSubscriber=function(t,e){var r,n,o,i=t.selector,a=t.callback,u=t.currentState,c=t.getConfig,l=null!==(r=null==c?void 0:c())&&void 0!==r?r:{};if(!e.forceUpdate&&(null!==(n=null==l?void 0:l.isEqualRoot)&&void 0!==n?n:function(t,e){return t===e})(e.currentState,e.newState))return{didUpdate:!1};var f=i?i(e.newState):e.newState;return!e.forceUpdate&&(null!==(o=null==l?void 0:l.isEqual)&&void 0!==o?o:function(t,e){return t===e})(u,f)?{didUpdate:!1}:(s.partialUpdateSubscription(t,{currentState:f}),a({state:f},{identifier:e.identifier}),{didUpdate:!0})},this.setSubscribersState=function(t,e){var n=e.forceUpdate,o=e.identifier,i=s.state;if(n||i!==t){s.state=t;var a,u={forceUpdate:n,newState:t,currentState:i,identifier:o},c=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=r(t))){e&&(t=e);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 i,a=!0,u=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(u)throw i}}}}(s.subscribers.values());try{for(c.s();!(a=c.n()).done;){var l=a.value;s.executeSetStateForSubscriber(l,u)}}catch(t){c.e(t)}finally{c.f()}}},this.setMetadata=function(t){var e=(0,c.isFunction)(t)?t(s.metadata):t;s.metadata=e},this.getMetadata=function(){return s.metadata},this.getState=function(){return s.state},this.subscribe=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];var n,o=e[0],i=e[1],a=e[2],u=(0,c.isFunction)(i),l=u?o:void 0,f=u?i:o,p=null!==(n=u?a:i)&&void 0!==n?n:void 0,y=l?l(s.state):s.state;(null==p?void 0:p.skipFirst)||f(y);var d={selector:l,getConfig:function(){return p},currentState:y,callback:function(t){var e=t.state;return f(e)}};return s.subscribeCallback(d),function(){s.subscribers.delete(d)}},this.subscribeCallback=function(t){return s.executeOnSubscribed(t),s.subscribers.add(t),function(){s.subscribers.delete(t)}},this.partialUpdateSubscription=function(t,e){(0,p.isRecord)(t)&&Object.assign(t,e)},this.executeOnSubscribed=function(t){var e,r=s.onSubscribed,n=null===(e=s.callbacks)||void 0===e?void 0:e.onSubscribed;(r||n)&&(null==r||r(s.storeTools,t),null==n||n(s.storeTools,t))},this.getMainHook=function(){var t=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=(0,y.isArray)(e)?{dependencies:e}:null!=e?e:{},n=(0,u.useRef)({selector:t,config:r}),o=n.current.config.dependencies;n.current.selector=t,n.current.config=r;var i=(0,u.useMemo)(function(){var t=function(t){var e=n.current.selector;return(0,c.isFunction)(e)?e(t):t},e={currentState:t(s.state),selector:t,getConfig:function(){return n.current.config},callback:function(){throw new Error("Callback not set")}},r=function(){return e.currentState};return{subscribe:function(t){return e.callback=t,s.subscribeCallback(e)},getSnapshot:r,getServerSnapshot:r,subscription:e}},[]),a=i.subscribe,l=i.getSnapshot,f=i.getServerSnapshot,p=i.subscription;return(0,u.useSyncExternalStore)(a,l,f),[s.computeSelectedState({subscription:p,currentDependencies:o}),s.getStateOrchestrator(),s.metadata]},e=s.setMetadata,r=s.getMetadata,n=s.actions,o=s.actions?null:s.setState.bind(s),i=s,a={actions:n,createObservable:s.createObservable.bind(i),createSelectorHook:s.createSelectorHook.bind(i),dispose:s.dispose.bind(s),getMetadata:r,getState:s.getState.bind(s),setMetadata:e,setState:o,subscribe:s.subscribe.bind(s),use:t,select:function(){return t.apply(void 0,arguments)[0]}};return Object.assign(t,a),t},this.computeSelectedState=function(t){var e,r=t.subscription,n=t.currentDependencies;if(!r.selector)return r.currentState;var o=(null!==(e=r.getConfig())&&void 0!==e?e:{}).dependencies;return n===o||(null==n?void 0:n.length)===(null==o?void 0:o.length)&&(0,y.shallowCompare)(n,o)||s.partialUpdateSubscription(r,{currentState:r.selector(s.state)}),r.currentState},this.createSelectorHook=m,this.createObservable=g,this.getStateOrchestrator=function(){return s.actions?s.actions:s.setState},this.setState=function(t){var e,r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=n.forceUpdate,i=n.identifier,a=s.state,u=(0,c.isFunction)(t)?t(a):t;if(o||s.state!==u){var l=s.setMetadata,f=s.getMetadata,p=s.getState,y=s.actions,d={setMetadata:l,getMetadata:f,setState:s.setSubscribersState,getState:p,actions:y,previousState:a,state:u,identifier:i},v=s.computePreventStateChange,b=null===(e=s.callbacks)||void 0===e?void 0:e.computePreventStateChange;if((v||b)&&((null==v?void 0:v(d))||(null==b?void 0:b(d))))return;s.setSubscribersState(u,{forceUpdate:o,identifier:i});var h=s.onStateChanged,g=null===(r=s.callbacks)||void 0===r?void 0:r.onStateChanged;(h||g)&&(null==h||h(d),null==g||g(d))}},this.getStoreActionsMap=function(){var t=s.actionsConfig,e=s.getMetadata,r=s.getState,n={setMetadata:s.setMetadata,getMetadata:e,getState:r,setState:s.setState,subscribe:s.subscribe,actions:null};if(!(0,p.isRecord)(t))return{actions:null,storeTools:n};var o={};n.actions=o;for(var a=Object.keys(t),u=function(){var e,r,a,u=l[c];Object.assign(o,(e={},a=function(){for(var e=t[u],r=arguments.length,i=new Array(r),a=0;a<r;a++)i[a]=arguments[a];var c=e.apply(o,i);return"function"!=typeof c&&(0,d.throwWrongKeyOnActionCollectionConfig)(u),c.call(o,n)},(r=i(r=u))in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e))},c=0,l=a;c<l.length;c++)u();return{actions:o,storeTools:n}},this.removeSubscriptions=function(){s.subscribers.clear()},this.dispose=function(){s.removeSubscriptions(),s._name="",s.actionsConfig=null,s.callbacks=null,s.metadata={},s.actions=null,s.state=Object.create(null)};var h=l.metadata,S=l.callbacks,w=l.actions,j=l.name;if(this.state=e,this._name=null!=j?j:(0,v.uniqueId)("gs:"),this.metadata=null!=h?h:{},this.callbacks=null!=S?S:null,this.actionsConfig=null!=w?w:null,b.default.isDevToolsPresent){var O=null!==(n=(new Error).stack)&&void 0!==n?n:"";null===(a=b.default.REACT_GLOBAL_STATE_HOOK_DEBUG)||void 0===a||a.call(b.default,this,l,O)}this.constructor!==t||this.initialize()});function g(t,e){var r=null==e?void 0:e.name,n=null==e?void 0:e.isEqualRoot,o=null==e?void 0:e.isEqual,i=this.getState(),a=(null!=t?t:function(t){return t})(i),u=new h(a,{name:null!=r?r:(0,v.uniqueId)("sh:")}),c=this.subscribe(function(e){if(!(null!=n?n:Object.is)(i,e)){i=e;var r=t(e);(null!=o?o:Object.is)(a,r)||(a=r,u.setState(r))}},{skipFirst:!0}),s=u.subscribe.bind(u),l={getState:u.getState.bind(u),subscribe:u.subscribe.bind(u),createSelectorHook:m.bind(s),createObservable:g.bind(s),dispose:function(){c(),u.dispose()}};return Object.assign(s,l),s}function m(t,e){var n=null==e?void 0:e.name,o=null==e?void 0:e.isEqualRoot,i=null==e?void 0:e.isEqual,a=this.getState(),u=(null!=t?t:function(t){return t})(a),c=new h(u,{name:null!=n?n:(0,v.uniqueId)("sh:")}),s=this.subscribe(function(e){if(!(null!=o?o:Object.is)(a,e)){a=e;var r=t(e);(null!=i?i:Object.is)(u,r)||(u=r,c.setState(r))}},{skipFirst:!0}),l=function(){return(t=c.use.apply(c,arguments),function(t){if(Array.isArray(t))return t}(t)||function(t){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var r,n,o,i,a=[],u=!0,c=!1;try{for(o=(e=e.call(t)).next;!(u=(r=o.call(e)).done)&&(a.push(r.value),1!==a.length);u=!0);}catch(t){c=!0,n=t}finally{try{if(!u&&null!=e.return&&(i=e.return(),Object(i)!==i))return}finally{if(c)throw n}}return a}}(t)||r(t,1)||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.")}())[0];var t},f={getState:function(){return c.getState()},subscribe:c.subscribe.bind(c),createSelectorHook:m.bind(l),createObservable:g.bind(l),dispose:function(){s(),c.dispose()}};return Object.assign(l,f),l}t.GlobalStore=h,t.default=h})(),l})(),t.exports=n(r(920),r(155),r(365),r(947),r(506),r(237),r(773))},318:(t,e,r)=>{var n;n=t=>(()=>{"use strict";var e={778:e=>{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](i,i.exports,n),i.exports}var o={};return(()=>{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(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(r=function(){return!!t})()}function i(t){return i=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},i(t)}function a(t,e){return a=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},a(t,e)}Object.defineProperty(t,"__esModule",{value:!0}),t.GlobalStoreAbstract=void 0;var u=function(t){function n(){var t;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,n),(t=function(t,n,o){return n=i(n),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)}(t,r()?Reflect.construct(n,o||[],i(t).constructor):n.apply(t,o))}(this,n,arguments)).onInit=function(e){t.onInitialize(e)},t.onStateChanged=function(e){t.onChange(e)},t}return 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&&a(t,e)}(n,t),o=n,Object.defineProperty(o,"prototype",{writable:!1}),o;var o}(n(778).GlobalStore);t.GlobalStoreAbstract=u,t.default=u})(),o})(),t.exports=n(r(316))},365:t=>{var e;e=()=>(()=>{"use strict";var t,e={};return t=e,Object.defineProperty(t,"__esModule",{value:!0}),t.throwWrongKeyOnActionCollectionConfig=void 0,t.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"))},t.default=t.throwWrongKeyOnActionCollectionConfig,e})(),t.exports=e()},506:t=>{"use strict";t.exports=r},512:t=>{"use strict";t.exports=n},773:t=>{"use strict";t.exports=o},868:t=>{"use strict";t.exports=i},920:t=>{var e;e=()=>(()=>{"use strict";var t,e,r={};return t=r,Object.defineProperty(t,"__esModule",{value:!0}),t.uniqueId=void 0,t.uniqueId=(e=0,function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return e===Number.MAX_SAFE_INTEGER&&(e=0),t+Date.now().toString(36)+(e++).toString(36)}),t.default=t.uniqueId,r})(),t.exports=e()},947:(t,e,r)=>{var n;n=t=>(()=>{"use strict";var e={35:(t,e,r)=>{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(773);e.isRecord=function(t){return!(0,o.isNil)(t)&&"object"===n(t)},e.default=e.isRecord},773:e=>{e.exports=t}},r={};return 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}(35)})(),t.exports=n(r(773))},955:t=>{"use strict";t.exports=a}},c={};function s(t){var e=c[t];if(void 0!==e)return e.exports;var r=c[t]={exports:{}};return u[t].call(r.exports,r,r.exports,s),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(){var t,e,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",a=o.toStringTag||"@@toStringTag";function u(r,o,i,a){var u=o&&o.prototype instanceof s?o:s,l=Object.create(u.prototype);return n(l,"_invoke",function(r,n,o){var i,a,u,s=0,l=o||[],f=!1,p={p:0,n:0,v:t,a:y,f:y.bind(t,4),d:function(e,r){return i=e,a=0,u=t,p.n=r,c}};function y(r,n){for(a=r,u=n,e=0;!f&&s&&!o&&e<l.length;e++){var o,i=l[e],y=p.p,d=i[2];r>3?(o=d===n)&&(u=i[(a=i[4])?5:(a=3,3)],i[4]=i[5]=t):i[0]<=y&&((o=r<2&&y<i[1])?(a=0,p.v=n,p.n=i[1]):y<d&&(o=r<3||i[0]>n||n>d)&&(i[4]=r,i[5]=n,p.n=d,a=0))}if(o||r>1)return c;throw f=!0,n}return function(o,l,d){if(s>1)throw TypeError("Generator is already running");for(f&&1===l&&y(l,d),a=l,u=d;(e=a<2?t:u)||!f;){i||(a?a<3?(a>1&&(p.n=-1),y(a,u)):p.n=u:p.v=u);try{if(s=2,i){if(a||(o="next"),e=i[o]){if(!(e=e.call(i,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,a<2&&(a=0)}else 1===a&&(e=i.return)&&e.call(i),a<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),a=1);i=t}else if((e=(f=p.n<0)?u:r.call(n,p))!==c)break}catch(e){i=t,a=1,u=e}finally{s=1}}return{value:e,done:f}}}(r,i,a),!0),l}var c={};function s(){}function l(){}function f(){}e=Object.getPrototypeOf;var p=[][i]?e(e([][i]())):(n(e={},i,function(){return this}),e),y=f.prototype=s.prototype=Object.create(p);function d(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,f):(t.__proto__=f,n(t,a,"GeneratorFunction")),t.prototype=Object.create(y),t}return l.prototype=f,n(y,"constructor",f),n(f,"constructor",l),l.displayName="GeneratorFunction",n(f,a,"GeneratorFunction"),n(y),n(y,a,"Generator"),n(y,i,function(){return this}),n(y,"toString",function(){return"[object Generator]"}),(r=function(){return{w:u,m:d}})()}function n(t,e,r,o){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}n=function(t,e,r,o){if(e)i?i(t,e,{value:r,enumerable:!o,configurable:!o,writable:!o}):t[e]=r;else{var a=function(e,r){n(t,e,function(t){return this._invoke(e,r,t)})};a("next",0),a("throw",1),a("return",2)}},n(t,e,r,o)}function o(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)}function i(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(i=function(){return!!t})()}function a(t){return a=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},a(t)}function u(t,e){return u=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},u(t,e)}Object.defineProperty(t,"__esModule",{value:!0}),t.GlobalStore=void 0;var c=s(318),f=s(512),p=s(868),y=function(t){function e(t){var n,u,c,s,l,y=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{metadata:{}};return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),c=this,l=[t,y],s=a(s=e),(n=o(c,i()?Reflect.construct(s,l||[],a(c).constructor):s.apply(c,l))).asyncStorage=null,n.getMetadata=function(){var t,e;return(null===(t=n.asyncStorage)||void 0===t?void 0:t.key)?Object.assign({isAsyncStorageReady:!1,asyncStorageKey:n.asyncStorage.key},null!==(e=n.metadata)&&void 0!==e?e:{}):n.metadata},n._onInitialize=function(t){return o=n,i=[t],u=function(t){var n=this,o=t.setState,i=t.getState,a=t.setMetadata;return r().m(function t(){var u;return r().w(function(t){for(;;)switch(t.n){case 0:if(e.isAsyncStorageAvailable(n.asyncStorage)){t.n=1;break}return t.a(2);case 1:return a(function(t){return Object.assign(Object.assign({},null!=t?t:{}),{isAsyncStorageReady:!1})}),t.n=2,(0,f.getAsyncStorageItem)(n.asyncStorage);case 2:u=t.v,a(function(t){return Object.assign(Object.assign({},null!=t?t:{}),{isAsyncStorageReady:!0})}),null===u&&(u=i(),(0,p.setAsyncStorageItem)(u,n.asyncStorage)),o(u,{forceUpdate:!0});case 3:return t.a(2)}},t)})()},new((a=void 0)||(a=Promise))(function(t,e){function r(t){try{c(u.next(t))}catch(t){e(t)}}function n(t){try{c(u.throw(t))}catch(t){e(t)}}function c(e){var o;e.done?t(e.value):(o=e.value,o instanceof a?o:new a(function(t){t(o)})).then(r,n)}c((u=u.apply(o,i||[])).next())});var o,i,a,u},n._onChange=function(t){var r=t.getState;e.isAsyncStorageAvailable(n.asyncStorage)&&(0,p.setAsyncStorageItem)(r(),n.asyncStorage)},n.onInitialize=null,n.onChange=null,n.onInit=function(t){var e;null===(e=n._onInitialize)||void 0===e||e.call(n,t)},n.onStateChanged=function(t){var e;null===(e=n._onChange)||void 0===e||e.call(n,t)},n.asyncStorage=null!==(u=y.asyncStorage)&&void 0!==u?u:null,n.setMetadata(function(t){var e,r;return Object.assign(Object.assign({},null!=t?t:{}),{isAsyncStorageReady:!1,asyncStorageKey:null!==(r=null===(e=n.asyncStorage)||void 0===e?void 0:e.key)&&void 0!==r?r:null})}),n.constructor!==e?o(n):(n.initialize(),n)}return 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&&u(t,e)}(e,t),n=e,Object.defineProperty(n,"prototype",{writable:!1}),n;var n}(c.GlobalStoreAbstract);t.GlobalStore=y,y.isAsyncStorageAvailable=function(t){return Boolean(null==t?void 0:t.key)},t.default=y})(),l})(),"object"==typeof exports&&"object"==typeof module?module.exports=e(require("json-storage-formatter/isDate"),require("react"),require("json-storage-formatter/isFunction"),require("./getAsyncStorageItem.js"),require("json-storage-formatter/isNil"),require("./setAsyncStorageItem.js"),require("json-storage-formatter/isPrimitive")):"function"==typeof define&&define.amd?define(["json-storage-formatter/isDate","react","json-storage-formatter/isFunction","./getAsyncStorageItem.js","json-storage-formatter/isNil","./setAsyncStorageItem.js","json-storage-formatter/isPrimitive"],e):"object"==typeof exports?exports["react-native-global-state-hooks"]=e(require("json-storage-formatter/isDate"),require("react"),require("json-storage-formatter/isFunction"),require("./getAsyncStorageItem.js"),require("json-storage-formatter/isNil"),require("./setAsyncStorageItem.js"),require("json-storage-formatter/isPrimitive")):t["react-native-global-state-hooks"]=e(t["json-storage-formatter/isDate"],t.react,t["json-storage-formatter/isFunction"],t["./getAsyncStorageItem.js"],t["json-storage-formatter/isNil"],t["./setAsyncStorageItem.js"],t["json-storage-formatter/isPrimitive"]);