New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@better-typed/react-hyper-fetch

Package Overview
Dependencies
Maintainers
2
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@better-typed/react-hyper-fetch - npm Package Compare versions

Comparing version 0.0.22 to 0.0.23

2

dist/index.cjs.js

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("@better-typed/react-lifecycle-hooks"),t=require("@better-typed/hyper-fetch");function n(e,r,t,n,a,i,o){try{var s=e[i](o),u=s.value}catch(e){return void t(e)}s.done?r(u):Promise.resolve(u).then(n,a)}function a(e){return function(){var r=this,t=arguments;return new Promise((function(a,i){var o=e.apply(r,t);function s(e){n(o,a,i,s,u,"next",e)}function u(e){n(o,a,i,s,u,"throw",e)}s(void 0)}))}}function i(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 o(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,a,i=[],o=!0,s=!1;try{for(t=t.call(e);!(o=(n=t.next()).done)&&(i.push(n.value),!r||i.length!==r);o=!0);}catch(e){s=!0,a=e}finally{try{o||null==t.return||t.return()}finally{if(s)throw a}}return i}}(e,r)||function(e,r){if(e){if("string"==typeof e)return i(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)?i(e,r):void 0}}(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.")}()}var s=Object.prototype,u=s.hasOwnProperty,c="function"==typeof Symbol?Symbol:{},l=c.iterator||"@@iterator",d=c.asyncIterator||"@@asyncIterator",f=c.toStringTag||"@@toStringTag";function h(e,r,t,n){var a=r&&r.prototype instanceof m?r:m,i=Object.create(a.prototype),o=new T(n||[]);return i._invoke=function(e,r,t){var n="suspendedStart";return function(a,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===a)throw i;return P()}for(t.method=a,t.arg=i;;){var o=t.delegate;if(o){var s=k(o,t);if(s){if(s===v)continue;return s}}if("next"===t.method)t.sent=t._sent=t.arg;else if("throw"===t.method){if("suspendedStart"===n)throw n="completed",t.arg;t.dispatchException(t.arg)}else"return"===t.method&&t.abrupt("return",t.arg);n="executing";var u=p(e,r,t);if("normal"===u.type){if(n=t.done?"completed":"suspendedYield",u.arg===v)continue;return{value:u.arg,done:t.done}}"throw"===u.type&&(n="completed",t.method="throw",t.arg=u.arg)}}}(e,t,o),i}function p(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}var v={};function m(){}function g(){}function y(){}var b={};b[l]=function(){return this};var w=Object.getPrototypeOf,O=w&&w(w(F([])));O&&O!==s&&u.call(O,l)&&(b=O);var x=y.prototype=m.prototype=Object.create(b);function R(e){["next","throw","return"].forEach((function(r){e[r]=function(e){return this._invoke(r,e)}}))}function E(e){var r="function"==typeof e&&e.constructor;return!!r&&(r===g||"GeneratorFunction"===(r.displayName||r.name))}function D(e,r){function t(n,a,i,o){var s=p(e[n],e,a);if("throw"!==s.type){var c=s.arg,l=c.value;return l&&"object"==typeof l&&u.call(l,"__await")?r.resolve(l.__await).then((function(e){t("next",e,i,o)}),(function(e){t("throw",e,i,o)})):r.resolve(l).then((function(e){c.value=e,i(c)}),(function(e){return t("throw",e,i,o)}))}o(s.arg)}var n;this._invoke=function(e,a){function i(){return new r((function(r,n){t(e,a,r,n)}))}return n=n?n.then(i,i):i()}}function k(e,r){var t=e.iterator[r.method];if(undefined===t){if(r.delegate=null,"throw"===r.method){if(e.iterator.return&&(r.method="return",r.arg=undefined,k(e,r),"throw"===r.method))return v;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return v}var n=p(t,e.iterator,r.arg);if("throw"===n.type)return r.method="throw",r.arg=n.arg,r.delegate=null,v;var a=n.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=undefined),r.delegate=null,v):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function S(e){var r={tryLoc:e[0]};1 in e&&(r.catchLoc=e[1]),2 in e&&(r.finallyLoc=e[2],r.afterLoc=e[3]),this.tryEntries.push(r)}function j(e){var r=e.completion||{};r.type="normal",delete r.arg,e.completion=r}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function F(e){if(e){var r=e[l];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var t=-1,n=function r(){for(;++t<e.length;)if(u.call(e,t))return r.value=e[t],r.done=!1,r;return r.value=undefined,r.done=!0,r};return n.next=n}}return{next:P}}function P(){return{value:undefined,done:!0}}g.prototype=x.constructor=y,y.constructor=g,y[f]=g.displayName="GeneratorFunction",R(D.prototype),D.prototype[d]=function(){return this},R(x),x[f]="Generator",x[l]=function(){return this},x.toString=function(){return"[object Generator]"},T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=undefined,this.done=!1,this.delegate=null,this.method="next",this.arg=undefined,this.tryEntries.forEach(j),!e)for(var r in this)"t"===r.charAt(0)&&u.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=undefined)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function t(t,n){return i.type="throw",i.arg=e,r.next=t,n&&(r.method="next",r.arg=undefined),!!n}for(var n=this.tryEntries.length-1;n>=0;--n){var a=this.tryEntries[n],i=a.completion;if("root"===a.tryLoc)return t("end");if(a.tryLoc<=this.prev){var o=u.call(a,"catchLoc"),s=u.call(a,"finallyLoc");if(o&&s){if(this.prev<a.catchLoc)return t(a.catchLoc,!0);if(this.prev<a.finallyLoc)return t(a.finallyLoc)}else if(o){if(this.prev<a.catchLoc)return t(a.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return t(a.finallyLoc)}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&u.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var a=n;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=r&&r<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=e,i.arg=r,a?(this.method="next",this.next=a.finallyLoc,v):this.complete(i)},complete:function(e,r){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&r&&(this.next=r),v},finish:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.finallyLoc===e)return this.complete(t.completion,t.afterLoc),j(t),v}},catch:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.tryLoc===e){var n=t.completion;if("throw"===n.type){var a=n.arg;j(t)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,t){return this.delegate={iterator:F(e),resultName:r,nextLoc:t},"next"===this.method&&(this.arg=undefined),v}};var L={wrap:h,isGeneratorFunction:E,AsyncIterator:D,mark:function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,y):(e.__proto__=y,f in e||(e[f]="GeneratorFunction")),e.prototype=Object.create(x),e},awrap:function(e){return{__await:e}},async:function(e,r,t,n,a){void 0===a&&(a=Promise);var i=new D(h(e,r,t,n),a);return E(r)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},keys:function(e){var r=[];for(var t in e)r.push(t);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}},values:F};function M(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}var q=(e,r,t)=>{if(r&&e&&t&&+e.timestamp+t>+new Date)return e},_=(e,r)=>!r||!!e&&+new Date>+r+e,K={data:null,error:null,loading:!1,status:null,refreshError:null,retryError:null,isRefreshed:!1,retries:0,timestamp:null,isOnline:!0,isFocused:!0};function I(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function A(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?I(Object(t),!0).forEach((function(r){M(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):I(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}var C=(e,r)=>{var t,n,a,i;return A(A({},K),{},{data:(null==r||null===(t=r.response)||void 0===t?void 0:t[0])||K.data,error:(null==r||null===(n=r.response)||void 0===n?void 0:n[1])||K.error,status:(null==r||null===(a=r.response)||void 0===a?void 0:a[2])||K.status,retries:(null==r?void 0:r.retries)||K.retries,timestamp:(i=(null==r?void 0:r.timestamp)||K.timestamp,i?new Date(i):null),isOnline:e.builder.appManager.isOnline,isFocused:e.builder.appManager.isFocused,loading:!!e.builder.fetchQueue.get(e.queueKey)||K.loading})};function U(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function B(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?U(Object(t),!0).forEach((function(r){M(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):U(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}var N=(t,n)=>{var i=t.builder,s=t.cache,u=t.cacheKey,c=t.cacheTime,l=o(e.useState(!1),2),d=l[0],f=l[1],h=o(e.useState(+new Date),2)[1],p=e.useRef(C(t,(e=>e?{response:e,retries:0,timestamp:+new Date,isRefreshed:!1}:null)(n))),v=e.useRef([]),m=e=>{v.current.find((r=>e.includes(r)))&&h(+new Date)};r.useDidMount((()=>{(function(){var e=a(L.mark((function e(){var r,a,o,l;return L.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i.cache.get(u);case 2:r=e.sent,a=q(r,s,c),o=_(c,null==a?void 0:a.timestamp),l=o?(d=n)?{response:d,retries:0,timestamp:+new Date,isRefreshed:!1}:null:a,p.current=C(t,l),f(!0),h(+new Date);case 9:case"end":return e.stop()}var d}),e)})));return function(){return e.apply(this,arguments)}})()()})),r.useDidMount((()=>{var e=i.appManager.events.onFocus((()=>{p.current.isFocused=!0,m(["isFocused"])})),r=i.appManager.events.onBlur((()=>{p.current.isFocused=!1,m(["isFocused"])})),t=i.appManager.events.onOnline((()=>{p.current.isOnline=!0,m(["isOnline"])})),n=i.appManager.events.onOffline((()=>{p.current.isOnline=!1,m(["isOnline"])}));return()=>{e(),r(),t(),n()}}));var g,y,b,w,O,x,R,E,D,k,S={setCacheData:(k=a(L.mark((function e(r){var t,n=arguments;return L.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n.length>1&&void 0!==n[1]&&!n[1]){e.next=6;break}return e.next=4,i.cache.set(B({cache:s,cacheKey:u},r));case 4:e.next=9;break;case 6:t={data:r.response[0],error:r.response[1],status:r.response[2],retries:r.retries,timestamp:new Date(r.timestamp),retryError:r.retryError,refreshError:r.refreshError,isRefreshed:r.isRefreshed,loading:!1},p.current=B(B({},p.current),t),m(Object.keys(t));case 9:case"end":return e.stop()}}),e)}))),function(e){return k.apply(this,arguments)}),setData:(D=a(L.mark((function e(r){var t,n=arguments;return L.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n.length>1&&void 0!==n[1]&&!n[1]){e.next=7;break}return t=p.current,e.next=5,i.cache.set({cache:s,cacheKey:u,response:[r,t.error,t.status],retries:t.retries,isRefreshed:t.isRefreshed});case 5:e.next=9;break;case 7:p.current.data=r,m(["data"]);case 9:case"end":return e.stop()}}),e)}))),function(e){return D.apply(this,arguments)}),setError:(E=a(L.mark((function e(r){var t,n=arguments;return L.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n.length>1&&void 0!==n[1]&&!n[1]){e.next=7;break}return t=p.current,e.next=5,i.cache.set({cache:s,cacheKey:u,response:[t.data,r,t.status],retries:t.retries,isRefreshed:t.isRefreshed});case 5:e.next=9;break;case 7:p.current.error=r,m(["error"]);case 9:case"end":return e.stop()}}),e)}))),function(e){return E.apply(this,arguments)}),setLoading:(R=a(L.mark((function e(r){var t=arguments;return L.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t.length>1&&void 0!==t[1]&&!t[1]?(p.current.loading=r,m(["loading"])):i.fetchQueue.events.setLoading(u,{isLoading:r,isRetry:!1});case 2:case"end":return e.stop()}}),e)}))),function(e){return R.apply(this,arguments)}),setStatus:(x=a(L.mark((function e(r){var t,n=arguments;return L.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n.length>1&&void 0!==n[1]&&!n[1]){e.next=7;break}return t=p.current,e.next=5,i.cache.set({cache:s,cacheKey:u,response:[t.data,t.error,r],retries:t.retries,isRefreshed:t.isRefreshed});case 5:e.next=9;break;case 7:p.current.status=r,m(["status"]);case 9:case"end":return e.stop()}}),e)}))),function(e){return x.apply(this,arguments)}),setRefreshed:(O=a(L.mark((function e(r){var t,n=arguments;return L.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n.length>1&&void 0!==n[1]&&!n[1]){e.next=7;break}return t=p.current,e.next=5,i.cache.set({cache:s,cacheKey:u,response:[t.data,t.error,t.status],retries:t.retries,isRefreshed:r});case 5:e.next=9;break;case 7:p.current.isRefreshed=r,m(["isRefreshed"]);case 9:case"end":return e.stop()}}),e)}))),function(e){return O.apply(this,arguments)}),setRefreshError:(w=a(L.mark((function e(r){var t,n=arguments;return L.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n.length>1&&void 0!==n[1]&&!n[1]){e.next=7;break}return t=p.current,e.next=5,i.cache.set({cache:s,cacheKey:u,response:[t.data,r,t.status],retries:t.retries,isRefreshed:!0});case 5:e.next=9;break;case 7:p.current.refreshError=r,m(["refreshError"]);case 9:case"end":return e.stop()}}),e)}))),function(e){return w.apply(this,arguments)}),setRetryError:(b=a(L.mark((function e(r){var t,n=arguments;return L.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n.length>1&&void 0!==n[1]&&!n[1]){e.next=7;break}return t=p.current,e.next=5,i.cache.set({cache:s,cacheKey:u,response:[t.data,r,t.status],retries:t.retries,isRefreshed:!0});case 5:e.next=9;break;case 7:p.current.retryError=r,m(["retryError"]);case 9:case"end":return e.stop()}}),e)}))),function(e){return b.apply(this,arguments)}),setRetries:(y=a(L.mark((function e(r){var t,n=arguments;return L.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n.length>1&&void 0!==n[1]&&!n[1]){e.next=7;break}return t=p.current,e.next=5,i.cache.set({cache:s,cacheKey:u,response:[t.data,t.error,t.status],retries:r,isRefreshed:t.isRefreshed});case 5:e.next=9;break;case 7:p.current.retries=r,m(["retries"]);case 9:case"end":return e.stop()}}),e)}))),function(e){return y.apply(this,arguments)}),setTimestamp:(g=a(L.mark((function e(r){var t,n=arguments;return L.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n.length>1&&void 0!==n[1]&&!n[1]){e.next=7;break}return t=p.current,e.next=5,i.cache.set({cache:s,cacheKey:u,response:[t.data,t.error,t.status],retries:t.retries,isRefreshed:t.isRefreshed,timestamp:r?+r:void 0});case 5:e.next=9;break;case 7:p.current.timestamp=r,m(["timestamp"]);case 9:case"end":return e.stop()}}),e)}))),function(e){return g.apply(this,arguments)})};return[p.current,S,e=>{v.current.push(e)},d]},G=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:600,n=e.useRef({time:t,timer:null});n.current.time=t;var a=()=>{n.current.timer&&clearTimeout(n.current.timer),n.current.timer=null},i=e=>{a(),n.current.timer=setTimeout((()=>{n.current.timer=null,e()}),n.current.time)};return r.useWillUnmount(a),{debounce:i,resetDebounce:a,active:!!n.current.timer}},Q=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:600,n=e.useRef({time:t,timer:null});n.current.time=t;var a=()=>{n.current.timer&&clearInterval(n.current.timer),n.current.timer=null},i=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;a(),n.current.timer=setInterval((()=>{e()}),r<=0?n.current.time:r)};return r.useWillUnmount(a),{interval:i,resetInterval:a,active:!!n.current.timer}},W={dependencies:[],disabled:!1,dependencyTracking:!0,cacheOnMount:!0,revalidateOnMount:!0,initialData:null,refresh:!1,refreshTime:t.DateInterval.hour,refreshBlurred:!1,refreshOnTabBlur:!1,refreshOnTabFocus:!1,refreshOnReconnect:!1,cancelable:!1,debounce:!1,debounceTime:400,deepCompareFn:void 0,responseDataModifierFn:null,shouldThrow:!1},Y={disabled:!1,dependencyTracking:!0,cacheOnMount:!0,initialData:null,debounce:!1,debounceTime:400,suspense:!1,shouldThrow:!1,responseDataModifierFn:null,invalidate:[]};exports.useFetch=function(n){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:W,s=i.dependencies,u=void 0===s?W.dependencies:s,c=i.disabled,l=void 0===c?W.disabled:c,d=i.dependencyTracking,f=void 0===d?W.dependencyTracking:d,h=i.revalidateOnMount,p=void 0===h?W.revalidateOnMount:h,v=i.initialData,m=void 0===v?W.initialData:v,g=i.refresh,y=void 0===g?W.refresh:g,b=i.refreshTime,w=void 0===b?W.refreshTime:b,O=i.refreshBlurred,x=void 0===O?W.refreshBlurred:O,R=i.refreshOnTabBlur,E=void 0===R?W.refreshOnTabBlur:R,D=i.refreshOnTabFocus,k=void 0===D?W.refreshOnTabFocus:D,S=i.refreshOnReconnect,j=void 0===S?W.refreshOnReconnect:S,T=i.debounce,F=void 0===T?W.debounce:T,P=i.debounceTime,M=void 0===P?W.debounceTime:P,q=i.responseDataModifierFn,K=void 0===q?W.responseDataModifierFn:q,I=i.shouldThrow,A=void 0===I?W.shouldThrow:I,C=n.cacheTime,U=n.cacheKey,B=n.queueKey,Y=n.builder,$=G(M),z=Q(w),H=Y.cache,J=Y.fetchQueue,V=Y.appManager,X=Y.commandManager,Z=Y.loggerManager,ee=e.useRef(Z.init("useFetch")).current,re=N(n,m),te=o(re,4),ne=te[0],ae=te[1],ie=te[2],oe=te[3],se=e.useRef(null),ue=e.useRef(null),ce=e.useRef(null),le=e.useRef(null),de=e.useRef(null),fe=e.useRef(null),he=e.useRef(null),pe=e.useRef(null),ve=()=>{l?ee.debug("Cannot add to fetch queue",{disabled:l}):(ee.debug("Adding request to fetch queue"),J.add(n))},me=()=>{z.resetInterval();var e=ne.timestamp,r=e?Math.max(+e+w-+new Date,w):w;y&&(ee.debug("Starting refresh counter, request will be send in ".concat(r,"ms")),z.interval(a(L.mark((function e(){var r,t,a;return L.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,J.get(B);case 2:r=e.sent,t=!n.builder.appManager.isFocused,a=t&&x||n.builder.appManager.isFocused,!!!r.requests.length&&a&&(ee.info("Performing refresh request"),ve(),z.resetInterval());case 8:case"end":return e.stop()}}),e)}))),r))},ge=e=>{if(e){var r,t,n;if(e[0])null==ue||null===(t=ue.current)||void 0===t||t.call(ue,e[0]);if(e[1])if(null==ce||null===(n=ce.current)||void 0===n||n.call(ce,e[1]),A)throw{message:"Fetching Error.",error:e[1]};null==le||null===(r=le.current)||void 0===r||r.call(le,e)}},ye=e=>{ae.setCacheData(e,!1),ge(e.response)},be=(e,r)=>{ae.setRefreshed(e,!1),ae.setTimestamp(new Date(r),!1),ge([ne.data,ne.error,ne.status])},we=e=>{var r,t=e.isLoading,n=e.isRetry;ae.setLoading(t,!1),null===(r=se.current)||void 0===r||r.call(se,{isRetry:n})},Oe=()=>{ve()},xe=e=>{e&&"string"==typeof e?n.builder.cache.events.revalidate(e):e&&e instanceof t.FetchCommand?n.builder.cache.events.revalidate(t.getCommandKey(e)):Oe()},Re=e=>{var r;null==he||null===(r=he.current)||void 0===r||r.call(he,e)},Ee=e=>{var r;null==pe||null===(r=pe.current)||void 0===r||r.call(pe,e)},De=e=>{var r;null==de||null===(r=de.current)||void 0===r||r.call(de,e)},ke=e=>{var r;null==de||null===(r=de.current)||void 0===r||r.call(de,e)},Se=()=>{var e=V.events.onFocus((()=>k&&ve())),r=V.events.onBlur((()=>E&&ve())),t=V.events.onOnline((()=>j&&ve())),n=X.events.onDownloadProgress(B,Re),a=X.events.onUploadProgress(B,Ee),i=X.events.onRequestStart(B,De),o=X.events.onResponseStart(B,ke),s=J.events.getLoading(B,we),u=H.events.get(U,ye),c=H.events.getEqualData(U,be),l=H.events.onRevalidate(U,Oe);return()=>{e(),r(),t(),n(),a(),i(),o(),s(),u(),c(),l()}},je=()=>K&&ne.data?K(ne.data):ne.data,Te=()=>{f||Object.keys(ne).forEach((e=>ie(e)))};return r.useDidMount((()=>((p||_(C,ne.timestamp))&&ve(),Te(),Se()))),r.useDidUpdate((()=>{oe&&ge([ne.data,ne.error,ne.status])}),[oe],!0),r.useDidUpdate((()=>{!J.requestCount&&F?$.debounce((()=>ve())):ve()}),[...u,l]),r.useDidUpdate((()=>{me()}),[y,w,ne.timestamp],!0),{get data(){return ie("data"),je()},get error(){return ie("error"),ne.error},get loading(){return ie("loading"),ne.loading},get status(){return ie("status"),ne.status},get retryError(){return ie("retryError"),ne.retryError},get refreshError(){return ie("refreshError"),ne.refreshError},get isRefreshed(){return ie("isRefreshed"),ne.isRefreshed},get retries(){return ie("retries"),ne.retries},get timestamp(){return ie("timestamp"),ne.timestamp},get isOnline(){return ie("isOnline"),ne.isOnline},get isFocused(){return ie("isFocused"),ne.isFocused},get isStale(){return _(C,ne.timestamp)},actions:ae,onRequest:e=>{se.current=e},onSuccess:e=>{ue.current=e},onError:e=>{ce.current=e},onFinished:e=>{le.current=e},onRequestStart:e=>{de.current=e},onResponseStart:e=>{fe.current=e},onDownloadProgress:e=>{he.current=e},onUploadProgress:e=>{pe.current=e},isRefreshingError:!!ne.error&&ne.isRefreshed,isDebouncing:$.active,refresh:xe}},exports.useSubmit=function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Y,a=n.disabled,i=void 0===a?Y.disabled:a,s=n.dependencyTracking,u=void 0===s?Y.dependencyTracking:s,c=n.initialData,l=void 0===c?Y.initialData:c,d=n.shouldThrow,f=void 0===d?Y.shouldThrow:d,h=n.responseDataModifierFn,p=void 0===h?Y.responseDataModifierFn:h,v=t.cacheTime,m=t.cacheKey,g=t.queueKey,y=t.builder,b=y.cache,w=y.submitQueue,O=y.commandManager,x=y.loggerManager,R=e.useRef(x.init("useSubmit")).current,E=N(t,l),D=o(E,3),k=D[0],S=D[1],j=D[2],T=e.useRef(null),F=e.useRef(null),P=e.useRef(null),L=e.useRef(null),M=e.useRef(null),q=e.useRef(null),K=e.useRef(null),I=e.useRef(null),A=function(){var e=t,r=arguments.length<=0?void 0:arguments[0];null!=r&&r.data&&(e=e.setData(r.data)),null!=r&&r.params&&(e=e.setParams(r.params)),null!=r&&r.queryParams&&(e=e.setQueryParams(r.queryParams)),i?R.debug("Cannot add to submit queue",{disabled:i,options:r}):(R.debug("Adding request to submit queue",{disabled:i,options:r}),w.add(e))},C=e=>{if(e){var r,t,n;if(e[0])null==F||null===(t=F.current)||void 0===t||t.call(F,e[0]);if(e[1])if(null==P||null===(n=P.current)||void 0===n||n.call(P,e[1]),f)throw{message:"Fetching Error.",error:e[1]};null==L||null===(r=L.current)||void 0===r||r.call(L,e)}},U=e=>{S.setCacheData(e,!1),C(e.response)},B=(e,r)=>{S.setRefreshed(e,!1),S.setTimestamp(new Date(r),!1),C([k.data,k.error,k.status])},G=e=>{var r,t=e.isLoading,n=e.isRetry;S.setLoading(t,!1),null===(r=T.current)||void 0===r||r.call(T,{isRetry:n})},Q=e=>{var r;null==K||null===(r=K.current)||void 0===r||r.call(K,e)},W=e=>{var r;null==I||null===(r=I.current)||void 0===r||r.call(I,e)},$=e=>{var r;null==M||null===(r=M.current)||void 0===r||r.call(M,e)},z=e=>{var r;null==M||null===(r=M.current)||void 0===r||r.call(M,e)},H=()=>{var e=O.events.onDownloadProgress(g,Q),r=O.events.onUploadProgress(g,W),t=O.events.onRequestStart(g,$),n=O.events.onResponseStart(g,z),a=w.events.getLoading(g,G),i=b.events.get(g,U),o=b.events.getEqualData(m,B);return()=>{e(),r(),t(),n(),a(),i(),o()}},J=()=>p&&k.data?p(k.data):k.data,V=()=>{u||Object.keys(k).forEach((e=>j(e)))};return r.useDidMount((()=>(V(),H()))),{submit:A,get data(){return j("data"),J()},get error(){return j("error"),k.error},get submitting(){return j("loading"),k.loading},get status(){return j("status"),k.status},get retryError(){return j("retryError"),k.retryError},get retries(){return j("retries"),k.retries},get timestamp(){return j("timestamp"),k.timestamp},get isOnline(){return j("isOnline"),k.isOnline},get isFocused(){return j("isFocused"),k.isFocused},get isStale(){return _(v,k.timestamp)},actions:S,isDebouncing:!1,isRefreshed:!1,onSubmitRequest:e=>{T.current=e},onSubmitSuccess:e=>{F.current=e},onSubmitError:e=>{P.current=e},onSubmitFinished:e=>{L.current=e},onSubmitRequestStart:e=>{M.current=e},onSubmitResponseStart:e=>{q.current=e},onSubmitDownloadProgress:e=>{K.current=e},onSubmitUploadProgress:e=>{I.current=e}}};
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("@better-typed/react-lifecycle-hooks"),t=require("@better-typed/hyper-fetch");function n(e,r,t,n,a,i,o){try{var s=e[i](o),u=s.value}catch(e){return void t(e)}s.done?r(u):Promise.resolve(u).then(n,a)}function a(e){return function(){var r=this,t=arguments;return new Promise((function(a,i){var o=e.apply(r,t);function s(e){n(o,a,i,s,u,"next",e)}function u(e){n(o,a,i,s,u,"throw",e)}s(void 0)}))}}function i(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 o(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,a,i=[],o=!0,s=!1;try{for(t=t.call(e);!(o=(n=t.next()).done)&&(i.push(n.value),!r||i.length!==r);o=!0);}catch(e){s=!0,a=e}finally{try{o||null==t.return||t.return()}finally{if(s)throw a}}return i}}(e,r)||function(e,r){if(e){if("string"==typeof e)return i(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)?i(e,r):void 0}}(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.")}()}var s=Object.prototype,u=s.hasOwnProperty,c="function"==typeof Symbol?Symbol:{},l=c.iterator||"@@iterator",d=c.asyncIterator||"@@asyncIterator",f=c.toStringTag||"@@toStringTag";function h(e,r,t,n){var a=r&&r.prototype instanceof m?r:m,i=Object.create(a.prototype),o=new T(n||[]);return i._invoke=function(e,r,t){var n="suspendedStart";return function(a,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===a)throw i;return P()}for(t.method=a,t.arg=i;;){var o=t.delegate;if(o){var s=k(o,t);if(s){if(s===v)continue;return s}}if("next"===t.method)t.sent=t._sent=t.arg;else if("throw"===t.method){if("suspendedStart"===n)throw n="completed",t.arg;t.dispatchException(t.arg)}else"return"===t.method&&t.abrupt("return",t.arg);n="executing";var u=p(e,r,t);if("normal"===u.type){if(n=t.done?"completed":"suspendedYield",u.arg===v)continue;return{value:u.arg,done:t.done}}"throw"===u.type&&(n="completed",t.method="throw",t.arg=u.arg)}}}(e,t,o),i}function p(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}var v={};function m(){}function g(){}function y(){}var b={};b[l]=function(){return this};var w=Object.getPrototypeOf,O=w&&w(w(F([])));O&&O!==s&&u.call(O,l)&&(b=O);var x=y.prototype=m.prototype=Object.create(b);function R(e){["next","throw","return"].forEach((function(r){e[r]=function(e){return this._invoke(r,e)}}))}function E(e){var r="function"==typeof e&&e.constructor;return!!r&&(r===g||"GeneratorFunction"===(r.displayName||r.name))}function D(e,r){function t(n,a,i,o){var s=p(e[n],e,a);if("throw"!==s.type){var c=s.arg,l=c.value;return l&&"object"==typeof l&&u.call(l,"__await")?r.resolve(l.__await).then((function(e){t("next",e,i,o)}),(function(e){t("throw",e,i,o)})):r.resolve(l).then((function(e){c.value=e,i(c)}),(function(e){return t("throw",e,i,o)}))}o(s.arg)}var n;this._invoke=function(e,a){function i(){return new r((function(r,n){t(e,a,r,n)}))}return n=n?n.then(i,i):i()}}function k(e,r){var t=e.iterator[r.method];if(undefined===t){if(r.delegate=null,"throw"===r.method){if(e.iterator.return&&(r.method="return",r.arg=undefined,k(e,r),"throw"===r.method))return v;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return v}var n=p(t,e.iterator,r.arg);if("throw"===n.type)return r.method="throw",r.arg=n.arg,r.delegate=null,v;var a=n.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=undefined),r.delegate=null,v):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function S(e){var r={tryLoc:e[0]};1 in e&&(r.catchLoc=e[1]),2 in e&&(r.finallyLoc=e[2],r.afterLoc=e[3]),this.tryEntries.push(r)}function j(e){var r=e.completion||{};r.type="normal",delete r.arg,e.completion=r}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function F(e){if(e){var r=e[l];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var t=-1,n=function r(){for(;++t<e.length;)if(u.call(e,t))return r.value=e[t],r.done=!1,r;return r.value=undefined,r.done=!0,r};return n.next=n}}return{next:P}}function P(){return{value:undefined,done:!0}}g.prototype=x.constructor=y,y.constructor=g,y[f]=g.displayName="GeneratorFunction",R(D.prototype),D.prototype[d]=function(){return this},R(x),x[f]="Generator",x[l]=function(){return this},x.toString=function(){return"[object Generator]"},T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=undefined,this.done=!1,this.delegate=null,this.method="next",this.arg=undefined,this.tryEntries.forEach(j),!e)for(var r in this)"t"===r.charAt(0)&&u.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=undefined)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function t(t,n){return i.type="throw",i.arg=e,r.next=t,n&&(r.method="next",r.arg=undefined),!!n}for(var n=this.tryEntries.length-1;n>=0;--n){var a=this.tryEntries[n],i=a.completion;if("root"===a.tryLoc)return t("end");if(a.tryLoc<=this.prev){var o=u.call(a,"catchLoc"),s=u.call(a,"finallyLoc");if(o&&s){if(this.prev<a.catchLoc)return t(a.catchLoc,!0);if(this.prev<a.finallyLoc)return t(a.finallyLoc)}else if(o){if(this.prev<a.catchLoc)return t(a.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return t(a.finallyLoc)}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&u.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var a=n;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=r&&r<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=e,i.arg=r,a?(this.method="next",this.next=a.finallyLoc,v):this.complete(i)},complete:function(e,r){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&r&&(this.next=r),v},finish:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.finallyLoc===e)return this.complete(t.completion,t.afterLoc),j(t),v}},catch:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.tryLoc===e){var n=t.completion;if("throw"===n.type){var a=n.arg;j(t)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,t){return this.delegate={iterator:F(e),resultName:r,nextLoc:t},"next"===this.method&&(this.arg=undefined),v}};var L={wrap:h,isGeneratorFunction:E,AsyncIterator:D,mark:function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,y):(e.__proto__=y,f in e||(e[f]="GeneratorFunction")),e.prototype=Object.create(x),e},awrap:function(e){return{__await:e}},async:function(e,r,t,n,a){void 0===a&&(a=Promise);var i=new D(h(e,r,t,n),a);return E(r)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},keys:function(e){var r=[];for(var t in e)r.push(t);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}},values:F};function M(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}var q=(e,r,t)=>{if(r&&e&&t&&+e.timestamp+t>+new Date)return e},_=(e,r)=>!r||!!e&&+new Date>+r+e,K={data:null,error:null,loading:!1,status:null,refreshError:null,retryError:null,isRefreshed:!1,retries:0,timestamp:null,isOnline:!0,isFocused:!0};function I(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function A(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?I(Object(t),!0).forEach((function(r){M(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):I(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}var C=(e,r)=>{var t,n,a,i;return A(A({},K),{},{data:(null==r||null===(t=r.response)||void 0===t?void 0:t[0])||K.data,error:(null==r||null===(n=r.response)||void 0===n?void 0:n[1])||K.error,status:(null==r||null===(a=r.response)||void 0===a?void 0:a[2])||K.status,retries:(null==r?void 0:r.retries)||K.retries,timestamp:(i=(null==r?void 0:r.timestamp)||K.timestamp,i?new Date(i):null),isOnline:e.builder.appManager.isOnline,isFocused:e.builder.appManager.isFocused,loading:!!e.builder.fetchQueue.get(e.queueKey)||K.loading})};function U(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function B(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?U(Object(t),!0).forEach((function(r){M(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):U(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}var N=(t,n)=>{var i=t.builder,s=t.cache,u=t.cacheKey,c=t.cacheTime,l=o(e.useState(!1),2),d=l[0],f=l[1],h=o(e.useState(+new Date),2)[1],p=e.useRef(C(t,(e=>e?{response:e,retries:0,timestamp:+new Date,isRefreshed:!1}:null)(n))),v=e.useRef([]),m=e=>{v.current.find((r=>e.includes(r)))&&h(+new Date)};r.useDidMount((()=>{(function(){var e=a(L.mark((function e(){var r,a,o,l;return L.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i.cache.get(u);case 2:r=e.sent,a=q(r,s,c),o=_(c,null==a?void 0:a.timestamp),l=o?(d=n)?{response:d,retries:0,timestamp:+new Date,isRefreshed:!1}:null:a,p.current=C(t,l),f(!0),h(+new Date);case 9:case"end":return e.stop()}var d}),e)})));return function(){return e.apply(this,arguments)}})()()})),r.useDidMount((()=>{var e=i.appManager.events.onFocus((()=>{p.current.isFocused=!0,m(["isFocused"])})),r=i.appManager.events.onBlur((()=>{p.current.isFocused=!1,m(["isFocused"])})),t=i.appManager.events.onOnline((()=>{p.current.isOnline=!0,m(["isOnline"])})),n=i.appManager.events.onOffline((()=>{p.current.isOnline=!1,m(["isOnline"])}));return()=>{e(),r(),t(),n()}}));var g,y,b,w,O,x,R,E,D,k,S={setCacheData:(k=a(L.mark((function e(r){var t,n=arguments;return L.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n.length>1&&void 0!==n[1]&&!n[1]){e.next=6;break}return e.next=4,i.cache.set(B({cache:s,cacheKey:u},r));case 4:e.next=9;break;case 6:t={data:r.response[0],error:r.response[1],status:r.response[2],retries:r.retries,timestamp:new Date(r.timestamp),retryError:r.retryError,refreshError:r.refreshError,isRefreshed:r.isRefreshed,loading:!1},p.current=B(B({},p.current),t),m(Object.keys(t));case 9:case"end":return e.stop()}}),e)}))),function(e){return k.apply(this,arguments)}),setData:(D=a(L.mark((function e(r){var t,n=arguments;return L.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n.length>1&&void 0!==n[1]&&!n[1]){e.next=7;break}return t=p.current,e.next=5,i.cache.set({cache:s,cacheKey:u,response:[r,t.error,t.status],retries:t.retries,isRefreshed:t.isRefreshed});case 5:e.next=9;break;case 7:p.current.data=r,m(["data"]);case 9:case"end":return e.stop()}}),e)}))),function(e){return D.apply(this,arguments)}),setError:(E=a(L.mark((function e(r){var t,n=arguments;return L.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n.length>1&&void 0!==n[1]&&!n[1]){e.next=7;break}return t=p.current,e.next=5,i.cache.set({cache:s,cacheKey:u,response:[t.data,r,t.status],retries:t.retries,isRefreshed:t.isRefreshed});case 5:e.next=9;break;case 7:p.current.error=r,m(["error"]);case 9:case"end":return e.stop()}}),e)}))),function(e){return E.apply(this,arguments)}),setLoading:(R=a(L.mark((function e(r){var t=arguments;return L.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t.length>1&&void 0!==t[1]&&!t[1]?(p.current.loading=r,m(["loading"])):i.fetchQueue.events.setLoading(u,{isLoading:r,isRetry:!1});case 2:case"end":return e.stop()}}),e)}))),function(e){return R.apply(this,arguments)}),setStatus:(x=a(L.mark((function e(r){var t,n=arguments;return L.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n.length>1&&void 0!==n[1]&&!n[1]){e.next=7;break}return t=p.current,e.next=5,i.cache.set({cache:s,cacheKey:u,response:[t.data,t.error,r],retries:t.retries,isRefreshed:t.isRefreshed});case 5:e.next=9;break;case 7:p.current.status=r,m(["status"]);case 9:case"end":return e.stop()}}),e)}))),function(e){return x.apply(this,arguments)}),setRefreshed:(O=a(L.mark((function e(r){var t,n=arguments;return L.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n.length>1&&void 0!==n[1]&&!n[1]){e.next=7;break}return t=p.current,e.next=5,i.cache.set({cache:s,cacheKey:u,response:[t.data,t.error,t.status],retries:t.retries,isRefreshed:r});case 5:e.next=9;break;case 7:p.current.isRefreshed=r,m(["isRefreshed"]);case 9:case"end":return e.stop()}}),e)}))),function(e){return O.apply(this,arguments)}),setRefreshError:(w=a(L.mark((function e(r){var t,n=arguments;return L.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n.length>1&&void 0!==n[1]&&!n[1]){e.next=7;break}return t=p.current,e.next=5,i.cache.set({cache:s,cacheKey:u,response:[t.data,r,t.status],retries:t.retries,isRefreshed:!0});case 5:e.next=9;break;case 7:p.current.refreshError=r,m(["refreshError"]);case 9:case"end":return e.stop()}}),e)}))),function(e){return w.apply(this,arguments)}),setRetryError:(b=a(L.mark((function e(r){var t,n=arguments;return L.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n.length>1&&void 0!==n[1]&&!n[1]){e.next=7;break}return t=p.current,e.next=5,i.cache.set({cache:s,cacheKey:u,response:[t.data,r,t.status],retries:t.retries,isRefreshed:!0});case 5:e.next=9;break;case 7:p.current.retryError=r,m(["retryError"]);case 9:case"end":return e.stop()}}),e)}))),function(e){return b.apply(this,arguments)}),setRetries:(y=a(L.mark((function e(r){var t,n=arguments;return L.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n.length>1&&void 0!==n[1]&&!n[1]){e.next=7;break}return t=p.current,e.next=5,i.cache.set({cache:s,cacheKey:u,response:[t.data,t.error,t.status],retries:r,isRefreshed:t.isRefreshed});case 5:e.next=9;break;case 7:p.current.retries=r,m(["retries"]);case 9:case"end":return e.stop()}}),e)}))),function(e){return y.apply(this,arguments)}),setTimestamp:(g=a(L.mark((function e(r){var t,n=arguments;return L.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n.length>1&&void 0!==n[1]&&!n[1]){e.next=7;break}return t=p.current,e.next=5,i.cache.set({cache:s,cacheKey:u,response:[t.data,t.error,t.status],retries:t.retries,isRefreshed:t.isRefreshed,timestamp:r?+r:void 0});case 5:e.next=9;break;case 7:p.current.timestamp=r,m(["timestamp"]);case 9:case"end":return e.stop()}}),e)}))),function(e){return g.apply(this,arguments)})};return[p.current,S,e=>{v.current.push(e)},d]},G=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:600,n=e.useRef({time:t,timer:null});n.current.time=t;var a=()=>{n.current.timer&&clearTimeout(n.current.timer),n.current.timer=null},i=e=>{a(),n.current.timer=setTimeout((()=>{n.current.timer=null,e()}),n.current.time)};return r.useWillUnmount(a),{debounce:i,resetDebounce:a,active:!!n.current.timer}},Q=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:600,n=e.useRef({time:t,timer:null});n.current.time=t;var a=()=>{n.current.timer&&clearInterval(n.current.timer),n.current.timer=null},i=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;a(),n.current.timer=setInterval((()=>{e()}),r<=0?n.current.time:r)};return r.useWillUnmount(a),{interval:i,resetInterval:a,active:!!n.current.timer}},W={dependencies:[],disabled:!1,dependencyTracking:!0,cacheOnMount:!0,revalidateOnMount:!0,initialData:null,refresh:!1,refreshTime:t.DateInterval.hour,refreshBlurred:!1,refreshOnTabBlur:!1,refreshOnTabFocus:!1,refreshOnReconnect:!1,cancelable:!1,debounce:!1,debounceTime:400,deepCompareFn:void 0,responseDataModifierFn:null,shouldThrow:!1},Y={disabled:!1,dependencyTracking:!0,cacheOnMount:!0,initialData:null,debounce:!1,debounceTime:400,suspense:!1,shouldThrow:!1,responseDataModifierFn:null,invalidate:[]};exports.useFetch=function(n){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:W,s=i.dependencies,u=void 0===s?W.dependencies:s,c=i.disabled,l=void 0===c?W.disabled:c,d=i.dependencyTracking,f=void 0===d?W.dependencyTracking:d,h=i.revalidateOnMount,p=void 0===h?W.revalidateOnMount:h,v=i.initialData,m=void 0===v?W.initialData:v,g=i.refresh,y=void 0===g?W.refresh:g,b=i.refreshTime,w=void 0===b?W.refreshTime:b,O=i.refreshBlurred,x=void 0===O?W.refreshBlurred:O,R=i.refreshOnTabBlur,E=void 0===R?W.refreshOnTabBlur:R,D=i.refreshOnTabFocus,k=void 0===D?W.refreshOnTabFocus:D,S=i.refreshOnReconnect,j=void 0===S?W.refreshOnReconnect:S,T=i.debounce,F=void 0===T?W.debounce:T,P=i.debounceTime,M=void 0===P?W.debounceTime:P,q=i.responseDataModifierFn,K=void 0===q?W.responseDataModifierFn:q,I=i.shouldThrow,A=void 0===I?W.shouldThrow:I,C=n.cacheTime,U=n.cacheKey,B=n.queueKey,Y=n.builder,$=G(M),z=Q(w),H=Y.cache,J=Y.fetchQueue,V=Y.appManager,X=Y.commandManager,Z=Y.loggerManager,ee=e.useRef(Z.init("useFetch")).current,re=N(n,m),te=o(re,4),ne=te[0],ae=te[1],ie=te[2],oe=te[3],se=e.useRef(null),ue=e.useRef(null),ce=e.useRef(null),le=e.useRef(null),de=e.useRef(null),fe=e.useRef(null),he=e.useRef(null),pe=e.useRef(null),ve=()=>{l?ee.debug("Cannot add to fetch queue",{disabled:l}):(ee.debug("Adding request to fetch queue"),J.add(n))},me=()=>{z.resetInterval();var e=ne.timestamp,r=e?Math.max(+e+w-+new Date,w):w;y&&(ee.debug("Starting refresh counter, request will be send in ".concat(r,"ms")),z.interval(a(L.mark((function e(){var r,t,a;return L.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,J.get(B);case 2:r=e.sent,t=!n.builder.appManager.isFocused,a=t&&x||n.builder.appManager.isFocused,!!!r.requests.length&&a&&(ee.info("Performing refresh request"),ve(),z.resetInterval());case 8:case"end":return e.stop()}}),e)}))),r))},ge=e=>{if(e){var r,t,n;if(e[0])null==ue||null===(t=ue.current)||void 0===t||t.call(ue,e[0]);if(e[1])if(null==ce||null===(n=ce.current)||void 0===n||n.call(ce,e[1]),A)throw{message:"Fetching Error.",error:e[1]};null==le||null===(r=le.current)||void 0===r||r.call(le,e)}},ye=e=>{ge(e.response),ae.setCacheData(e,!1)},be=(e,r)=>{ge([ne.data,ne.error,ne.status]),ae.setRefreshed(e,!1),ae.setTimestamp(new Date(r),!1)},we=e=>{var r,t=e.isLoading,n=e.isRetry;ae.setLoading(t,!1),null===(r=se.current)||void 0===r||r.call(se,{isRetry:n})},Oe=()=>{ve()},xe=e=>{e&&"string"==typeof e?n.builder.cache.events.revalidate(e):e&&e instanceof t.FetchCommand?n.builder.cache.events.revalidate(t.getCommandKey(e)):Oe()},Re=e=>{var r;null==he||null===(r=he.current)||void 0===r||r.call(he,e)},Ee=e=>{var r;null==pe||null===(r=pe.current)||void 0===r||r.call(pe,e)},De=e=>{var r;null==de||null===(r=de.current)||void 0===r||r.call(de,e)},ke=e=>{var r;null==de||null===(r=de.current)||void 0===r||r.call(de,e)},Se=()=>{var e=V.events.onFocus((()=>k&&ve())),r=V.events.onBlur((()=>E&&ve())),t=V.events.onOnline((()=>j&&ve())),n=X.events.onDownloadProgress(B,Re),a=X.events.onUploadProgress(B,Ee),i=X.events.onRequestStart(B,De),o=X.events.onResponseStart(B,ke),s=J.events.getLoading(B,we),u=H.events.get(U,ye),c=H.events.getEqualData(U,be),l=H.events.onRevalidate(U,Oe);return()=>{e(),r(),t(),n(),a(),i(),o(),s(),u(),c(),l()}},je=()=>K&&ne.data?K(ne.data):ne.data,Te=()=>{f||Object.keys(ne).forEach((e=>ie(e)))};return r.useDidMount((()=>((p||_(C,ne.timestamp))&&ve(),Te(),Se()))),r.useDidUpdate((()=>{oe&&ge([ne.data,ne.error,ne.status])}),[oe],!0),r.useDidUpdate((()=>{!J.requestCount&&F?$.debounce((()=>ve())):ve()}),[...u,l]),r.useDidUpdate((()=>{me()}),[y,w,ne.timestamp],!0),{get data(){return ie("data"),je()},get error(){return ie("error"),ne.error},get loading(){return ie("loading"),ne.loading},get status(){return ie("status"),ne.status},get retryError(){return ie("retryError"),ne.retryError},get refreshError(){return ie("refreshError"),ne.refreshError},get isRefreshed(){return ie("isRefreshed"),ne.isRefreshed},get retries(){return ie("retries"),ne.retries},get timestamp(){return ie("timestamp"),ne.timestamp},get isOnline(){return ie("isOnline"),ne.isOnline},get isFocused(){return ie("isFocused"),ne.isFocused},get isStale(){return _(C,ne.timestamp)},actions:ae,onRequest:e=>{se.current=e},onSuccess:e=>{ue.current=e},onError:e=>{ce.current=e},onFinished:e=>{le.current=e},onRequestStart:e=>{de.current=e},onResponseStart:e=>{fe.current=e},onDownloadProgress:e=>{he.current=e},onUploadProgress:e=>{pe.current=e},isRefreshingError:!!ne.error&&ne.isRefreshed,isDebouncing:$.active,refresh:xe}},exports.useSubmit=function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Y,a=n.disabled,i=void 0===a?Y.disabled:a,s=n.dependencyTracking,u=void 0===s?Y.dependencyTracking:s,c=n.initialData,l=void 0===c?Y.initialData:c,d=n.shouldThrow,f=void 0===d?Y.shouldThrow:d,h=n.responseDataModifierFn,p=void 0===h?Y.responseDataModifierFn:h,v=t.cacheTime,m=t.cacheKey,g=t.queueKey,y=t.builder,b=y.cache,w=y.submitQueue,O=y.commandManager,x=y.loggerManager,R=e.useRef(x.init("useSubmit")).current,E=N(t,l),D=o(E,3),k=D[0],S=D[1],j=D[2],T=e.useRef(null),F=e.useRef(null),P=e.useRef(null),L=e.useRef(null),M=e.useRef(null),q=e.useRef(null),K=e.useRef(null),I=e.useRef(null),A=function(){var e=t,r=arguments.length<=0?void 0:arguments[0];null!=r&&r.data&&(e=e.setData(r.data)),null!=r&&r.params&&(e=e.setParams(r.params)),null!=r&&r.queryParams&&(e=e.setQueryParams(r.queryParams)),i?R.debug("Cannot add to submit queue",{disabled:i,options:r}):(R.debug("Adding request to submit queue",{disabled:i,options:r}),w.add(e))},C=e=>{if(e){var r,t,n;if(e[0])null==F||null===(t=F.current)||void 0===t||t.call(F,e[0]);if(e[1])if(null==P||null===(n=P.current)||void 0===n||n.call(P,e[1]),f)throw{message:"Fetching Error.",error:e[1]};null==L||null===(r=L.current)||void 0===r||r.call(L,e)}},U=e=>{S.setCacheData(e,!1),C(e.response)},B=(e,r)=>{S.setRefreshed(e,!1),S.setTimestamp(new Date(r),!1),C([k.data,k.error,k.status])},G=e=>{var r,t=e.isLoading,n=e.isRetry;S.setLoading(t,!1),null===(r=T.current)||void 0===r||r.call(T,{isRetry:n})},Q=e=>{var r;null==K||null===(r=K.current)||void 0===r||r.call(K,e)},W=e=>{var r;null==I||null===(r=I.current)||void 0===r||r.call(I,e)},$=e=>{var r;null==M||null===(r=M.current)||void 0===r||r.call(M,e)},z=e=>{var r;null==M||null===(r=M.current)||void 0===r||r.call(M,e)},H=()=>{var e=O.events.onDownloadProgress(g,Q),r=O.events.onUploadProgress(g,W),t=O.events.onRequestStart(g,$),n=O.events.onResponseStart(g,z),a=w.events.getLoading(g,G),i=b.events.get(g,U),o=b.events.getEqualData(m,B);return()=>{e(),r(),t(),n(),a(),i(),o()}},J=()=>p&&k.data?p(k.data):k.data,V=()=>{u||Object.keys(k).forEach((e=>j(e)))};return r.useDidMount((()=>(V(),H()))),{submit:A,get data(){return j("data"),J()},get error(){return j("error"),k.error},get submitting(){return j("loading"),k.loading},get status(){return j("status"),k.status},get retryError(){return j("retryError"),k.retryError},get retries(){return j("retries"),k.retries},get timestamp(){return j("timestamp"),k.timestamp},get isOnline(){return j("isOnline"),k.isOnline},get isFocused(){return j("isFocused"),k.isFocused},get isStale(){return _(v,k.timestamp)},actions:S,isDebouncing:!1,isRefreshed:!1,onSubmitRequest:e=>{T.current=e},onSubmitSuccess:e=>{F.current=e},onSubmitError:e=>{P.current=e},onSubmitFinished:e=>{L.current=e},onSubmitRequestStart:e=>{M.current=e},onSubmitResponseStart:e=>{q.current=e},onSubmitDownloadProgress:e=>{K.current=e},onSubmitUploadProgress:e=>{I.current=e}}};
//# sourceMappingURL=index.cjs.js.map

@@ -1,2 +0,2 @@

import{useState as e,useRef as r}from"react";import{useDidMount as t,useWillUnmount as n,useDidUpdate as a}from"@better-typed/react-lifecycle-hooks";import{DateInterval as i,FetchCommand as o,getCommandKey as s}from"@better-typed/hyper-fetch";function u(e,r,t,n,a,i,o){try{var s=e[i](o),u=s.value}catch(e){return void t(e)}s.done?r(u):Promise.resolve(u).then(n,a)}function c(e){return function(){var r=this,t=arguments;return new Promise((function(n,a){var i=e.apply(r,t);function o(e){u(i,n,a,o,s,"next",e)}function s(e){u(i,n,a,o,s,"throw",e)}o(void 0)}))}}function l(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 d(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,a,i=[],o=!0,s=!1;try{for(t=t.call(e);!(o=(n=t.next()).done)&&(i.push(n.value),!r||i.length!==r);o=!0);}catch(e){s=!0,a=e}finally{try{o||null==t.return||t.return()}finally{if(s)throw a}}return i}}(e,r)||function(e,r){if(e){if("string"==typeof e)return l(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)?l(e,r):void 0}}(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.")}()}var f=Object.prototype,h=f.hasOwnProperty,p="function"==typeof Symbol?Symbol:{},v=p.iterator||"@@iterator",m=p.asyncIterator||"@@asyncIterator",g=p.toStringTag||"@@toStringTag";function y(e,r,t,n){var a=r&&r.prototype instanceof O?r:O,i=Object.create(a.prototype),o=new q(n||[]);return i._invoke=function(e,r,t){var n="suspendedStart";return function(a,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===a)throw i;return _()}for(t.method=a,t.arg=i;;){var o=t.delegate;if(o){var s=P(o,t);if(s){if(s===w)continue;return s}}if("next"===t.method)t.sent=t._sent=t.arg;else if("throw"===t.method){if("suspendedStart"===n)throw n="completed",t.arg;t.dispatchException(t.arg)}else"return"===t.method&&t.abrupt("return",t.arg);n="executing";var u=b(e,r,t);if("normal"===u.type){if(n=t.done?"completed":"suspendedYield",u.arg===w)continue;return{value:u.arg,done:t.done}}"throw"===u.type&&(n="completed",t.method="throw",t.arg=u.arg)}}}(e,t,o),i}function b(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}var w={};function O(){}function x(){}function E(){}var R={};R[v]=function(){return this};var k=Object.getPrototypeOf,D=k&&k(k(K([])));D&&D!==f&&h.call(D,v)&&(R=D);var j=E.prototype=O.prototype=Object.create(R);function S(e){["next","throw","return"].forEach((function(r){e[r]=function(e){return this._invoke(r,e)}}))}function T(e){var r="function"==typeof e&&e.constructor;return!!r&&(r===x||"GeneratorFunction"===(r.displayName||r.name))}function L(e,r){function t(n,a,i,o){var s=b(e[n],e,a);if("throw"!==s.type){var u=s.arg,c=u.value;return c&&"object"==typeof c&&h.call(c,"__await")?r.resolve(c.__await).then((function(e){t("next",e,i,o)}),(function(e){t("throw",e,i,o)})):r.resolve(c).then((function(e){u.value=e,i(u)}),(function(e){return t("throw",e,i,o)}))}o(s.arg)}var n;this._invoke=function(e,a){function i(){return new r((function(r,n){t(e,a,r,n)}))}return n=n?n.then(i,i):i()}}function P(e,r){var t=e.iterator[r.method];if(undefined===t){if(r.delegate=null,"throw"===r.method){if(e.iterator.return&&(r.method="return",r.arg=undefined,P(e,r),"throw"===r.method))return w;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return w}var n=b(t,e.iterator,r.arg);if("throw"===n.type)return r.method="throw",r.arg=n.arg,r.delegate=null,w;var a=n.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=undefined),r.delegate=null,w):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,w)}function F(e){var r={tryLoc:e[0]};1 in e&&(r.catchLoc=e[1]),2 in e&&(r.finallyLoc=e[2],r.afterLoc=e[3]),this.tryEntries.push(r)}function M(e){var r=e.completion||{};r.type="normal",delete r.arg,e.completion=r}function q(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(F,this),this.reset(!0)}function K(e){if(e){var r=e[v];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var t=-1,n=function r(){for(;++t<e.length;)if(h.call(e,t))return r.value=e[t],r.done=!1,r;return r.value=undefined,r.done=!0,r};return n.next=n}}return{next:_}}function _(){return{value:undefined,done:!0}}x.prototype=j.constructor=E,E.constructor=x,E[g]=x.displayName="GeneratorFunction",S(L.prototype),L.prototype[m]=function(){return this},S(j),j[g]="Generator",j[v]=function(){return this},j.toString=function(){return"[object Generator]"},q.prototype={constructor:q,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=undefined,this.done=!1,this.delegate=null,this.method="next",this.arg=undefined,this.tryEntries.forEach(M),!e)for(var r in this)"t"===r.charAt(0)&&h.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=undefined)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function t(t,n){return i.type="throw",i.arg=e,r.next=t,n&&(r.method="next",r.arg=undefined),!!n}for(var n=this.tryEntries.length-1;n>=0;--n){var a=this.tryEntries[n],i=a.completion;if("root"===a.tryLoc)return t("end");if(a.tryLoc<=this.prev){var o=h.call(a,"catchLoc"),s=h.call(a,"finallyLoc");if(o&&s){if(this.prev<a.catchLoc)return t(a.catchLoc,!0);if(this.prev<a.finallyLoc)return t(a.finallyLoc)}else if(o){if(this.prev<a.catchLoc)return t(a.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return t(a.finallyLoc)}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&h.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var a=n;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=r&&r<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=e,i.arg=r,a?(this.method="next",this.next=a.finallyLoc,w):this.complete(i)},complete:function(e,r){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&r&&(this.next=r),w},finish:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.finallyLoc===e)return this.complete(t.completion,t.afterLoc),M(t),w}},catch:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.tryLoc===e){var n=t.completion;if("throw"===n.type){var a=n.arg;M(t)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,t){return this.delegate={iterator:K(e),resultName:r,nextLoc:t},"next"===this.method&&(this.arg=undefined),w}};var I={wrap:y,isGeneratorFunction:T,AsyncIterator:L,mark:function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,E):(e.__proto__=E,g in e||(e[g]="GeneratorFunction")),e.prototype=Object.create(j),e},awrap:function(e){return{__await:e}},async:function(e,r,t,n,a){void 0===a&&(a=Promise);var i=new L(y(e,r,t,n),a);return T(r)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},keys:function(e){var r=[];for(var t in e)r.push(t);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}},values:K};function A(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}var B=(e,r,t)=>{if(r&&e&&t&&+e.timestamp+t>+new Date)return e},C=(e,r)=>!r||!!e&&+new Date>+r+e,N={data:null,error:null,loading:!1,status:null,refreshError:null,retryError:null,isRefreshed:!1,retries:0,timestamp:null,isOnline:!0,isFocused:!0};function G(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function Q(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?G(Object(t),!0).forEach((function(r){A(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):G(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}var U=(e,r)=>{var t,n,a,i;return Q(Q({},N),{},{data:(null==r||null===(t=r.response)||void 0===t?void 0:t[0])||N.data,error:(null==r||null===(n=r.response)||void 0===n?void 0:n[1])||N.error,status:(null==r||null===(a=r.response)||void 0===a?void 0:a[2])||N.status,retries:(null==r?void 0:r.retries)||N.retries,timestamp:(i=(null==r?void 0:r.timestamp)||N.timestamp,i?new Date(i):null),isOnline:e.builder.appManager.isOnline,isFocused:e.builder.appManager.isFocused,loading:!!e.builder.fetchQueue.get(e.queueKey)||N.loading})};function Y(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function $(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?Y(Object(t),!0).forEach((function(r){A(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):Y(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}var z=(n,a)=>{var i=n.builder,o=n.cache,s=n.cacheKey,u=n.cacheTime,l=d(e(!1),2),f=l[0],h=l[1],p=d(e(+new Date),2)[1],v=r(U(n,(e=>e?{response:e,retries:0,timestamp:+new Date,isRefreshed:!1}:null)(a))),m=r([]),g=e=>{m.current.find((r=>e.includes(r)))&&p(+new Date)};t((()=>{(function(){var e=c(I.mark((function e(){var r,t,c,l;return I.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i.cache.get(s);case 2:r=e.sent,t=B(r,o,u),c=C(u,null==t?void 0:t.timestamp),l=c?(d=a)?{response:d,retries:0,timestamp:+new Date,isRefreshed:!1}:null:t,v.current=U(n,l),h(!0),p(+new Date);case 9:case"end":return e.stop()}var d}),e)})));return function(){return e.apply(this,arguments)}})()()})),t((()=>{var e=i.appManager.events.onFocus((()=>{v.current.isFocused=!0,g(["isFocused"])})),r=i.appManager.events.onBlur((()=>{v.current.isFocused=!1,g(["isFocused"])})),t=i.appManager.events.onOnline((()=>{v.current.isOnline=!0,g(["isOnline"])})),n=i.appManager.events.onOffline((()=>{v.current.isOnline=!1,g(["isOnline"])}));return()=>{e(),r(),t(),n()}}));var y,b,w,O,x,E,R,k,D,j,S={setCacheData:(j=c(I.mark((function e(r){var t,n=arguments;return I.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n.length>1&&void 0!==n[1]&&!n[1]){e.next=6;break}return e.next=4,i.cache.set($({cache:o,cacheKey:s},r));case 4:e.next=9;break;case 6:t={data:r.response[0],error:r.response[1],status:r.response[2],retries:r.retries,timestamp:new Date(r.timestamp),retryError:r.retryError,refreshError:r.refreshError,isRefreshed:r.isRefreshed,loading:!1},v.current=$($({},v.current),t),g(Object.keys(t));case 9:case"end":return e.stop()}}),e)}))),function(e){return j.apply(this,arguments)}),setData:(D=c(I.mark((function e(r){var t,n=arguments;return I.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n.length>1&&void 0!==n[1]&&!n[1]){e.next=7;break}return t=v.current,e.next=5,i.cache.set({cache:o,cacheKey:s,response:[r,t.error,t.status],retries:t.retries,isRefreshed:t.isRefreshed});case 5:e.next=9;break;case 7:v.current.data=r,g(["data"]);case 9:case"end":return e.stop()}}),e)}))),function(e){return D.apply(this,arguments)}),setError:(k=c(I.mark((function e(r){var t,n=arguments;return I.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n.length>1&&void 0!==n[1]&&!n[1]){e.next=7;break}return t=v.current,e.next=5,i.cache.set({cache:o,cacheKey:s,response:[t.data,r,t.status],retries:t.retries,isRefreshed:t.isRefreshed});case 5:e.next=9;break;case 7:v.current.error=r,g(["error"]);case 9:case"end":return e.stop()}}),e)}))),function(e){return k.apply(this,arguments)}),setLoading:(R=c(I.mark((function e(r){var t=arguments;return I.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t.length>1&&void 0!==t[1]&&!t[1]?(v.current.loading=r,g(["loading"])):i.fetchQueue.events.setLoading(s,{isLoading:r,isRetry:!1});case 2:case"end":return e.stop()}}),e)}))),function(e){return R.apply(this,arguments)}),setStatus:(E=c(I.mark((function e(r){var t,n=arguments;return I.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n.length>1&&void 0!==n[1]&&!n[1]){e.next=7;break}return t=v.current,e.next=5,i.cache.set({cache:o,cacheKey:s,response:[t.data,t.error,r],retries:t.retries,isRefreshed:t.isRefreshed});case 5:e.next=9;break;case 7:v.current.status=r,g(["status"]);case 9:case"end":return e.stop()}}),e)}))),function(e){return E.apply(this,arguments)}),setRefreshed:(x=c(I.mark((function e(r){var t,n=arguments;return I.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n.length>1&&void 0!==n[1]&&!n[1]){e.next=7;break}return t=v.current,e.next=5,i.cache.set({cache:o,cacheKey:s,response:[t.data,t.error,t.status],retries:t.retries,isRefreshed:r});case 5:e.next=9;break;case 7:v.current.isRefreshed=r,g(["isRefreshed"]);case 9:case"end":return e.stop()}}),e)}))),function(e){return x.apply(this,arguments)}),setRefreshError:(O=c(I.mark((function e(r){var t,n=arguments;return I.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n.length>1&&void 0!==n[1]&&!n[1]){e.next=7;break}return t=v.current,e.next=5,i.cache.set({cache:o,cacheKey:s,response:[t.data,r,t.status],retries:t.retries,isRefreshed:!0});case 5:e.next=9;break;case 7:v.current.refreshError=r,g(["refreshError"]);case 9:case"end":return e.stop()}}),e)}))),function(e){return O.apply(this,arguments)}),setRetryError:(w=c(I.mark((function e(r){var t,n=arguments;return I.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n.length>1&&void 0!==n[1]&&!n[1]){e.next=7;break}return t=v.current,e.next=5,i.cache.set({cache:o,cacheKey:s,response:[t.data,r,t.status],retries:t.retries,isRefreshed:!0});case 5:e.next=9;break;case 7:v.current.retryError=r,g(["retryError"]);case 9:case"end":return e.stop()}}),e)}))),function(e){return w.apply(this,arguments)}),setRetries:(b=c(I.mark((function e(r){var t,n=arguments;return I.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n.length>1&&void 0!==n[1]&&!n[1]){e.next=7;break}return t=v.current,e.next=5,i.cache.set({cache:o,cacheKey:s,response:[t.data,t.error,t.status],retries:r,isRefreshed:t.isRefreshed});case 5:e.next=9;break;case 7:v.current.retries=r,g(["retries"]);case 9:case"end":return e.stop()}}),e)}))),function(e){return b.apply(this,arguments)}),setTimestamp:(y=c(I.mark((function e(r){var t,n=arguments;return I.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n.length>1&&void 0!==n[1]&&!n[1]){e.next=7;break}return t=v.current,e.next=5,i.cache.set({cache:o,cacheKey:s,response:[t.data,t.error,t.status],retries:t.retries,isRefreshed:t.isRefreshed,timestamp:r?+r:void 0});case 5:e.next=9;break;case 7:v.current.timestamp=r,g(["timestamp"]);case 9:case"end":return e.stop()}}),e)}))),function(e){return y.apply(this,arguments)})};return[v.current,S,e=>{m.current.push(e)},f]},H=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:600,t=r({time:e,timer:null});t.current.time=e;var a=()=>{t.current.timer&&clearTimeout(t.current.timer),t.current.timer=null},i=e=>{a(),t.current.timer=setTimeout((()=>{t.current.timer=null,e()}),t.current.time)};return n(a),{debounce:i,resetDebounce:a,active:!!t.current.timer}},J=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:600,t=r({time:e,timer:null});t.current.time=e;var a=()=>{t.current.timer&&clearInterval(t.current.timer),t.current.timer=null},i=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;a(),t.current.timer=setInterval((()=>{e()}),r<=0?t.current.time:r)};return n(a),{interval:i,resetInterval:a,active:!!t.current.timer}},V={dependencies:[],disabled:!1,dependencyTracking:!0,cacheOnMount:!0,revalidateOnMount:!0,initialData:null,refresh:!1,refreshTime:i.hour,refreshBlurred:!1,refreshOnTabBlur:!1,refreshOnTabFocus:!1,refreshOnReconnect:!1,cancelable:!1,debounce:!1,debounceTime:400,deepCompareFn:void 0,responseDataModifierFn:null,shouldThrow:!1},W=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:V,i=n.dependencies,u=void 0===i?V.dependencies:i,l=n.disabled,f=void 0===l?V.disabled:l,h=n.dependencyTracking,p=void 0===h?V.dependencyTracking:h,v=n.revalidateOnMount,m=void 0===v?V.revalidateOnMount:v,g=n.initialData,y=void 0===g?V.initialData:g,b=n.refresh,w=void 0===b?V.refresh:b,O=n.refreshTime,x=void 0===O?V.refreshTime:O,E=n.refreshBlurred,R=void 0===E?V.refreshBlurred:E,k=n.refreshOnTabBlur,D=void 0===k?V.refreshOnTabBlur:k,j=n.refreshOnTabFocus,S=void 0===j?V.refreshOnTabFocus:j,T=n.refreshOnReconnect,L=void 0===T?V.refreshOnReconnect:T,P=n.debounce,F=void 0===P?V.debounce:P,M=n.debounceTime,q=void 0===M?V.debounceTime:M,K=n.responseDataModifierFn,_=void 0===K?V.responseDataModifierFn:K,A=n.shouldThrow,B=void 0===A?V.shouldThrow:A,N=e.cacheTime,G=e.cacheKey,Q=e.queueKey,U=e.builder,Y=H(q),$=J(x),W=U.cache,X=U.fetchQueue,Z=U.appManager,ee=U.commandManager,re=U.loggerManager,te=r(re.init("useFetch")).current,ne=z(e,y),ae=d(ne,4),ie=ae[0],oe=ae[1],se=ae[2],ue=ae[3],ce=r(null),le=r(null),de=r(null),fe=r(null),he=r(null),pe=r(null),ve=r(null),me=r(null),ge=()=>{f?te.debug("Cannot add to fetch queue",{disabled:f}):(te.debug("Adding request to fetch queue"),X.add(e))},ye=()=>{$.resetInterval();var r=ie.timestamp,t=r?Math.max(+r+x-+new Date,x):x;w&&(te.debug("Starting refresh counter, request will be send in ".concat(t,"ms")),$.interval(c(I.mark((function r(){var t,n,a;return I.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,X.get(Q);case 2:t=r.sent,n=!e.builder.appManager.isFocused,a=n&&R||e.builder.appManager.isFocused,!!!t.requests.length&&a&&(te.info("Performing refresh request"),ge(),$.resetInterval());case 8:case"end":return r.stop()}}),r)}))),t))},be=e=>{if(e){var r,t,n;if(e[0])null==le||null===(t=le.current)||void 0===t||t.call(le,e[0]);if(e[1])if(null==de||null===(n=de.current)||void 0===n||n.call(de,e[1]),B)throw{message:"Fetching Error.",error:e[1]};null==fe||null===(r=fe.current)||void 0===r||r.call(fe,e)}},we=e=>{oe.setCacheData(e,!1),be(e.response)},Oe=(e,r)=>{oe.setRefreshed(e,!1),oe.setTimestamp(new Date(r),!1),be([ie.data,ie.error,ie.status])},xe=e=>{var r,t=e.isLoading,n=e.isRetry;oe.setLoading(t,!1),null===(r=ce.current)||void 0===r||r.call(ce,{isRetry:n})},Ee=()=>{ge()},Re=r=>{r&&"string"==typeof r?e.builder.cache.events.revalidate(r):r&&r instanceof o?e.builder.cache.events.revalidate(s(r)):Ee()},ke=e=>{var r;null==ve||null===(r=ve.current)||void 0===r||r.call(ve,e)},De=e=>{var r;null==me||null===(r=me.current)||void 0===r||r.call(me,e)},je=e=>{var r;null==he||null===(r=he.current)||void 0===r||r.call(he,e)},Se=e=>{var r;null==he||null===(r=he.current)||void 0===r||r.call(he,e)},Te=()=>{var e=Z.events.onFocus((()=>S&&ge())),r=Z.events.onBlur((()=>D&&ge())),t=Z.events.onOnline((()=>L&&ge())),n=ee.events.onDownloadProgress(Q,ke),a=ee.events.onUploadProgress(Q,De),i=ee.events.onRequestStart(Q,je),o=ee.events.onResponseStart(Q,Se),s=X.events.getLoading(Q,xe),u=W.events.get(G,we),c=W.events.getEqualData(G,Oe),l=W.events.onRevalidate(G,Ee);return()=>{e(),r(),t(),n(),a(),i(),o(),s(),u(),c(),l()}},Le=()=>_&&ie.data?_(ie.data):ie.data,Pe=()=>{p||Object.keys(ie).forEach((e=>se(e)))};return t((()=>((m||C(N,ie.timestamp))&&ge(),Pe(),Te()))),a((()=>{ue&&be([ie.data,ie.error,ie.status])}),[ue],!0),a((()=>{!X.requestCount&&F?Y.debounce((()=>ge())):ge()}),[...u,f]),a((()=>{ye()}),[w,x,ie.timestamp],!0),{get data(){return se("data"),Le()},get error(){return se("error"),ie.error},get loading(){return se("loading"),ie.loading},get status(){return se("status"),ie.status},get retryError(){return se("retryError"),ie.retryError},get refreshError(){return se("refreshError"),ie.refreshError},get isRefreshed(){return se("isRefreshed"),ie.isRefreshed},get retries(){return se("retries"),ie.retries},get timestamp(){return se("timestamp"),ie.timestamp},get isOnline(){return se("isOnline"),ie.isOnline},get isFocused(){return se("isFocused"),ie.isFocused},get isStale(){return C(N,ie.timestamp)},actions:oe,onRequest:e=>{ce.current=e},onSuccess:e=>{le.current=e},onError:e=>{de.current=e},onFinished:e=>{fe.current=e},onRequestStart:e=>{he.current=e},onResponseStart:e=>{pe.current=e},onDownloadProgress:e=>{ve.current=e},onUploadProgress:e=>{me.current=e},isRefreshingError:!!ie.error&&ie.isRefreshed,isDebouncing:Y.active,refresh:Re}},X={disabled:!1,dependencyTracking:!0,cacheOnMount:!0,initialData:null,debounce:!1,debounceTime:400,suspense:!1,shouldThrow:!1,responseDataModifierFn:null,invalidate:[]},Z=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:X,a=n.disabled,i=void 0===a?X.disabled:a,o=n.dependencyTracking,s=void 0===o?X.dependencyTracking:o,u=n.initialData,c=void 0===u?X.initialData:u,l=n.shouldThrow,f=void 0===l?X.shouldThrow:l,h=n.responseDataModifierFn,p=void 0===h?X.responseDataModifierFn:h,v=e.cacheTime,m=e.cacheKey,g=e.queueKey,y=e.builder,b=y.cache,w=y.submitQueue,O=y.commandManager,x=y.loggerManager,E=r(x.init("useSubmit")).current,R=z(e,c),k=d(R,3),D=k[0],j=k[1],S=k[2],T=r(null),L=r(null),P=r(null),F=r(null),M=r(null),q=r(null),K=r(null),_=r(null),I=function(){var r=e,t=arguments.length<=0?void 0:arguments[0];null!=t&&t.data&&(r=r.setData(t.data)),null!=t&&t.params&&(r=r.setParams(t.params)),null!=t&&t.queryParams&&(r=r.setQueryParams(t.queryParams)),i?E.debug("Cannot add to submit queue",{disabled:i,options:t}):(E.debug("Adding request to submit queue",{disabled:i,options:t}),w.add(r))},A=e=>{if(e){var r,t,n;if(e[0])null==L||null===(t=L.current)||void 0===t||t.call(L,e[0]);if(e[1])if(null==P||null===(n=P.current)||void 0===n||n.call(P,e[1]),f)throw{message:"Fetching Error.",error:e[1]};null==F||null===(r=F.current)||void 0===r||r.call(F,e)}},B=e=>{j.setCacheData(e,!1),A(e.response)},N=(e,r)=>{j.setRefreshed(e,!1),j.setTimestamp(new Date(r),!1),A([D.data,D.error,D.status])},G=e=>{var r,t=e.isLoading,n=e.isRetry;j.setLoading(t,!1),null===(r=T.current)||void 0===r||r.call(T,{isRetry:n})},Q=e=>{var r;null==K||null===(r=K.current)||void 0===r||r.call(K,e)},U=e=>{var r;null==_||null===(r=_.current)||void 0===r||r.call(_,e)},Y=e=>{var r;null==M||null===(r=M.current)||void 0===r||r.call(M,e)},$=e=>{var r;null==M||null===(r=M.current)||void 0===r||r.call(M,e)},H=()=>{var e=O.events.onDownloadProgress(g,Q),r=O.events.onUploadProgress(g,U),t=O.events.onRequestStart(g,Y),n=O.events.onResponseStart(g,$),a=w.events.getLoading(g,G),i=b.events.get(g,B),o=b.events.getEqualData(m,N);return()=>{e(),r(),t(),n(),a(),i(),o()}},J=()=>p&&D.data?p(D.data):D.data,V=()=>{s||Object.keys(D).forEach((e=>S(e)))};return t((()=>(V(),H()))),{submit:I,get data(){return S("data"),J()},get error(){return S("error"),D.error},get submitting(){return S("loading"),D.loading},get status(){return S("status"),D.status},get retryError(){return S("retryError"),D.retryError},get retries(){return S("retries"),D.retries},get timestamp(){return S("timestamp"),D.timestamp},get isOnline(){return S("isOnline"),D.isOnline},get isFocused(){return S("isFocused"),D.isFocused},get isStale(){return C(v,D.timestamp)},actions:j,isDebouncing:!1,isRefreshed:!1,onSubmitRequest:e=>{T.current=e},onSubmitSuccess:e=>{L.current=e},onSubmitError:e=>{P.current=e},onSubmitFinished:e=>{F.current=e},onSubmitRequestStart:e=>{M.current=e},onSubmitResponseStart:e=>{q.current=e},onSubmitDownloadProgress:e=>{K.current=e},onSubmitUploadProgress:e=>{_.current=e}}};export{W as useFetch,Z as useSubmit};
import{useState as e,useRef as r}from"react";import{useDidMount as t,useWillUnmount as n,useDidUpdate as a}from"@better-typed/react-lifecycle-hooks";import{DateInterval as i,FetchCommand as o,getCommandKey as s}from"@better-typed/hyper-fetch";function u(e,r,t,n,a,i,o){try{var s=e[i](o),u=s.value}catch(e){return void t(e)}s.done?r(u):Promise.resolve(u).then(n,a)}function c(e){return function(){var r=this,t=arguments;return new Promise((function(n,a){var i=e.apply(r,t);function o(e){u(i,n,a,o,s,"next",e)}function s(e){u(i,n,a,o,s,"throw",e)}o(void 0)}))}}function l(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 d(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,a,i=[],o=!0,s=!1;try{for(t=t.call(e);!(o=(n=t.next()).done)&&(i.push(n.value),!r||i.length!==r);o=!0);}catch(e){s=!0,a=e}finally{try{o||null==t.return||t.return()}finally{if(s)throw a}}return i}}(e,r)||function(e,r){if(e){if("string"==typeof e)return l(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)?l(e,r):void 0}}(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.")}()}var f=Object.prototype,h=f.hasOwnProperty,p="function"==typeof Symbol?Symbol:{},v=p.iterator||"@@iterator",m=p.asyncIterator||"@@asyncIterator",g=p.toStringTag||"@@toStringTag";function y(e,r,t,n){var a=r&&r.prototype instanceof O?r:O,i=Object.create(a.prototype),o=new q(n||[]);return i._invoke=function(e,r,t){var n="suspendedStart";return function(a,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===a)throw i;return _()}for(t.method=a,t.arg=i;;){var o=t.delegate;if(o){var s=P(o,t);if(s){if(s===w)continue;return s}}if("next"===t.method)t.sent=t._sent=t.arg;else if("throw"===t.method){if("suspendedStart"===n)throw n="completed",t.arg;t.dispatchException(t.arg)}else"return"===t.method&&t.abrupt("return",t.arg);n="executing";var u=b(e,r,t);if("normal"===u.type){if(n=t.done?"completed":"suspendedYield",u.arg===w)continue;return{value:u.arg,done:t.done}}"throw"===u.type&&(n="completed",t.method="throw",t.arg=u.arg)}}}(e,t,o),i}function b(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}var w={};function O(){}function x(){}function E(){}var R={};R[v]=function(){return this};var k=Object.getPrototypeOf,D=k&&k(k(K([])));D&&D!==f&&h.call(D,v)&&(R=D);var j=E.prototype=O.prototype=Object.create(R);function S(e){["next","throw","return"].forEach((function(r){e[r]=function(e){return this._invoke(r,e)}}))}function T(e){var r="function"==typeof e&&e.constructor;return!!r&&(r===x||"GeneratorFunction"===(r.displayName||r.name))}function L(e,r){function t(n,a,i,o){var s=b(e[n],e,a);if("throw"!==s.type){var u=s.arg,c=u.value;return c&&"object"==typeof c&&h.call(c,"__await")?r.resolve(c.__await).then((function(e){t("next",e,i,o)}),(function(e){t("throw",e,i,o)})):r.resolve(c).then((function(e){u.value=e,i(u)}),(function(e){return t("throw",e,i,o)}))}o(s.arg)}var n;this._invoke=function(e,a){function i(){return new r((function(r,n){t(e,a,r,n)}))}return n=n?n.then(i,i):i()}}function P(e,r){var t=e.iterator[r.method];if(undefined===t){if(r.delegate=null,"throw"===r.method){if(e.iterator.return&&(r.method="return",r.arg=undefined,P(e,r),"throw"===r.method))return w;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return w}var n=b(t,e.iterator,r.arg);if("throw"===n.type)return r.method="throw",r.arg=n.arg,r.delegate=null,w;var a=n.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=undefined),r.delegate=null,w):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,w)}function F(e){var r={tryLoc:e[0]};1 in e&&(r.catchLoc=e[1]),2 in e&&(r.finallyLoc=e[2],r.afterLoc=e[3]),this.tryEntries.push(r)}function M(e){var r=e.completion||{};r.type="normal",delete r.arg,e.completion=r}function q(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(F,this),this.reset(!0)}function K(e){if(e){var r=e[v];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var t=-1,n=function r(){for(;++t<e.length;)if(h.call(e,t))return r.value=e[t],r.done=!1,r;return r.value=undefined,r.done=!0,r};return n.next=n}}return{next:_}}function _(){return{value:undefined,done:!0}}x.prototype=j.constructor=E,E.constructor=x,E[g]=x.displayName="GeneratorFunction",S(L.prototype),L.prototype[m]=function(){return this},S(j),j[g]="Generator",j[v]=function(){return this},j.toString=function(){return"[object Generator]"},q.prototype={constructor:q,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=undefined,this.done=!1,this.delegate=null,this.method="next",this.arg=undefined,this.tryEntries.forEach(M),!e)for(var r in this)"t"===r.charAt(0)&&h.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=undefined)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function t(t,n){return i.type="throw",i.arg=e,r.next=t,n&&(r.method="next",r.arg=undefined),!!n}for(var n=this.tryEntries.length-1;n>=0;--n){var a=this.tryEntries[n],i=a.completion;if("root"===a.tryLoc)return t("end");if(a.tryLoc<=this.prev){var o=h.call(a,"catchLoc"),s=h.call(a,"finallyLoc");if(o&&s){if(this.prev<a.catchLoc)return t(a.catchLoc,!0);if(this.prev<a.finallyLoc)return t(a.finallyLoc)}else if(o){if(this.prev<a.catchLoc)return t(a.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return t(a.finallyLoc)}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&h.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var a=n;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=r&&r<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=e,i.arg=r,a?(this.method="next",this.next=a.finallyLoc,w):this.complete(i)},complete:function(e,r){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&r&&(this.next=r),w},finish:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.finallyLoc===e)return this.complete(t.completion,t.afterLoc),M(t),w}},catch:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.tryLoc===e){var n=t.completion;if("throw"===n.type){var a=n.arg;M(t)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,t){return this.delegate={iterator:K(e),resultName:r,nextLoc:t},"next"===this.method&&(this.arg=undefined),w}};var I={wrap:y,isGeneratorFunction:T,AsyncIterator:L,mark:function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,E):(e.__proto__=E,g in e||(e[g]="GeneratorFunction")),e.prototype=Object.create(j),e},awrap:function(e){return{__await:e}},async:function(e,r,t,n,a){void 0===a&&(a=Promise);var i=new L(y(e,r,t,n),a);return T(r)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},keys:function(e){var r=[];for(var t in e)r.push(t);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}},values:K};function A(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}var B=(e,r,t)=>{if(r&&e&&t&&+e.timestamp+t>+new Date)return e},C=(e,r)=>!r||!!e&&+new Date>+r+e,N={data:null,error:null,loading:!1,status:null,refreshError:null,retryError:null,isRefreshed:!1,retries:0,timestamp:null,isOnline:!0,isFocused:!0};function G(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function Q(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?G(Object(t),!0).forEach((function(r){A(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):G(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}var U=(e,r)=>{var t,n,a,i;return Q(Q({},N),{},{data:(null==r||null===(t=r.response)||void 0===t?void 0:t[0])||N.data,error:(null==r||null===(n=r.response)||void 0===n?void 0:n[1])||N.error,status:(null==r||null===(a=r.response)||void 0===a?void 0:a[2])||N.status,retries:(null==r?void 0:r.retries)||N.retries,timestamp:(i=(null==r?void 0:r.timestamp)||N.timestamp,i?new Date(i):null),isOnline:e.builder.appManager.isOnline,isFocused:e.builder.appManager.isFocused,loading:!!e.builder.fetchQueue.get(e.queueKey)||N.loading})};function Y(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function $(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?Y(Object(t),!0).forEach((function(r){A(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):Y(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}var z=(n,a)=>{var i=n.builder,o=n.cache,s=n.cacheKey,u=n.cacheTime,l=d(e(!1),2),f=l[0],h=l[1],p=d(e(+new Date),2)[1],v=r(U(n,(e=>e?{response:e,retries:0,timestamp:+new Date,isRefreshed:!1}:null)(a))),m=r([]),g=e=>{m.current.find((r=>e.includes(r)))&&p(+new Date)};t((()=>{(function(){var e=c(I.mark((function e(){var r,t,c,l;return I.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i.cache.get(s);case 2:r=e.sent,t=B(r,o,u),c=C(u,null==t?void 0:t.timestamp),l=c?(d=a)?{response:d,retries:0,timestamp:+new Date,isRefreshed:!1}:null:t,v.current=U(n,l),h(!0),p(+new Date);case 9:case"end":return e.stop()}var d}),e)})));return function(){return e.apply(this,arguments)}})()()})),t((()=>{var e=i.appManager.events.onFocus((()=>{v.current.isFocused=!0,g(["isFocused"])})),r=i.appManager.events.onBlur((()=>{v.current.isFocused=!1,g(["isFocused"])})),t=i.appManager.events.onOnline((()=>{v.current.isOnline=!0,g(["isOnline"])})),n=i.appManager.events.onOffline((()=>{v.current.isOnline=!1,g(["isOnline"])}));return()=>{e(),r(),t(),n()}}));var y,b,w,O,x,E,R,k,D,j,S={setCacheData:(j=c(I.mark((function e(r){var t,n=arguments;return I.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n.length>1&&void 0!==n[1]&&!n[1]){e.next=6;break}return e.next=4,i.cache.set($({cache:o,cacheKey:s},r));case 4:e.next=9;break;case 6:t={data:r.response[0],error:r.response[1],status:r.response[2],retries:r.retries,timestamp:new Date(r.timestamp),retryError:r.retryError,refreshError:r.refreshError,isRefreshed:r.isRefreshed,loading:!1},v.current=$($({},v.current),t),g(Object.keys(t));case 9:case"end":return e.stop()}}),e)}))),function(e){return j.apply(this,arguments)}),setData:(D=c(I.mark((function e(r){var t,n=arguments;return I.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n.length>1&&void 0!==n[1]&&!n[1]){e.next=7;break}return t=v.current,e.next=5,i.cache.set({cache:o,cacheKey:s,response:[r,t.error,t.status],retries:t.retries,isRefreshed:t.isRefreshed});case 5:e.next=9;break;case 7:v.current.data=r,g(["data"]);case 9:case"end":return e.stop()}}),e)}))),function(e){return D.apply(this,arguments)}),setError:(k=c(I.mark((function e(r){var t,n=arguments;return I.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n.length>1&&void 0!==n[1]&&!n[1]){e.next=7;break}return t=v.current,e.next=5,i.cache.set({cache:o,cacheKey:s,response:[t.data,r,t.status],retries:t.retries,isRefreshed:t.isRefreshed});case 5:e.next=9;break;case 7:v.current.error=r,g(["error"]);case 9:case"end":return e.stop()}}),e)}))),function(e){return k.apply(this,arguments)}),setLoading:(R=c(I.mark((function e(r){var t=arguments;return I.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t.length>1&&void 0!==t[1]&&!t[1]?(v.current.loading=r,g(["loading"])):i.fetchQueue.events.setLoading(s,{isLoading:r,isRetry:!1});case 2:case"end":return e.stop()}}),e)}))),function(e){return R.apply(this,arguments)}),setStatus:(E=c(I.mark((function e(r){var t,n=arguments;return I.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n.length>1&&void 0!==n[1]&&!n[1]){e.next=7;break}return t=v.current,e.next=5,i.cache.set({cache:o,cacheKey:s,response:[t.data,t.error,r],retries:t.retries,isRefreshed:t.isRefreshed});case 5:e.next=9;break;case 7:v.current.status=r,g(["status"]);case 9:case"end":return e.stop()}}),e)}))),function(e){return E.apply(this,arguments)}),setRefreshed:(x=c(I.mark((function e(r){var t,n=arguments;return I.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n.length>1&&void 0!==n[1]&&!n[1]){e.next=7;break}return t=v.current,e.next=5,i.cache.set({cache:o,cacheKey:s,response:[t.data,t.error,t.status],retries:t.retries,isRefreshed:r});case 5:e.next=9;break;case 7:v.current.isRefreshed=r,g(["isRefreshed"]);case 9:case"end":return e.stop()}}),e)}))),function(e){return x.apply(this,arguments)}),setRefreshError:(O=c(I.mark((function e(r){var t,n=arguments;return I.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n.length>1&&void 0!==n[1]&&!n[1]){e.next=7;break}return t=v.current,e.next=5,i.cache.set({cache:o,cacheKey:s,response:[t.data,r,t.status],retries:t.retries,isRefreshed:!0});case 5:e.next=9;break;case 7:v.current.refreshError=r,g(["refreshError"]);case 9:case"end":return e.stop()}}),e)}))),function(e){return O.apply(this,arguments)}),setRetryError:(w=c(I.mark((function e(r){var t,n=arguments;return I.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n.length>1&&void 0!==n[1]&&!n[1]){e.next=7;break}return t=v.current,e.next=5,i.cache.set({cache:o,cacheKey:s,response:[t.data,r,t.status],retries:t.retries,isRefreshed:!0});case 5:e.next=9;break;case 7:v.current.retryError=r,g(["retryError"]);case 9:case"end":return e.stop()}}),e)}))),function(e){return w.apply(this,arguments)}),setRetries:(b=c(I.mark((function e(r){var t,n=arguments;return I.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n.length>1&&void 0!==n[1]&&!n[1]){e.next=7;break}return t=v.current,e.next=5,i.cache.set({cache:o,cacheKey:s,response:[t.data,t.error,t.status],retries:r,isRefreshed:t.isRefreshed});case 5:e.next=9;break;case 7:v.current.retries=r,g(["retries"]);case 9:case"end":return e.stop()}}),e)}))),function(e){return b.apply(this,arguments)}),setTimestamp:(y=c(I.mark((function e(r){var t,n=arguments;return I.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n.length>1&&void 0!==n[1]&&!n[1]){e.next=7;break}return t=v.current,e.next=5,i.cache.set({cache:o,cacheKey:s,response:[t.data,t.error,t.status],retries:t.retries,isRefreshed:t.isRefreshed,timestamp:r?+r:void 0});case 5:e.next=9;break;case 7:v.current.timestamp=r,g(["timestamp"]);case 9:case"end":return e.stop()}}),e)}))),function(e){return y.apply(this,arguments)})};return[v.current,S,e=>{m.current.push(e)},f]},H=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:600,t=r({time:e,timer:null});t.current.time=e;var a=()=>{t.current.timer&&clearTimeout(t.current.timer),t.current.timer=null},i=e=>{a(),t.current.timer=setTimeout((()=>{t.current.timer=null,e()}),t.current.time)};return n(a),{debounce:i,resetDebounce:a,active:!!t.current.timer}},J=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:600,t=r({time:e,timer:null});t.current.time=e;var a=()=>{t.current.timer&&clearInterval(t.current.timer),t.current.timer=null},i=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;a(),t.current.timer=setInterval((()=>{e()}),r<=0?t.current.time:r)};return n(a),{interval:i,resetInterval:a,active:!!t.current.timer}},V={dependencies:[],disabled:!1,dependencyTracking:!0,cacheOnMount:!0,revalidateOnMount:!0,initialData:null,refresh:!1,refreshTime:i.hour,refreshBlurred:!1,refreshOnTabBlur:!1,refreshOnTabFocus:!1,refreshOnReconnect:!1,cancelable:!1,debounce:!1,debounceTime:400,deepCompareFn:void 0,responseDataModifierFn:null,shouldThrow:!1},W=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:V,i=n.dependencies,u=void 0===i?V.dependencies:i,l=n.disabled,f=void 0===l?V.disabled:l,h=n.dependencyTracking,p=void 0===h?V.dependencyTracking:h,v=n.revalidateOnMount,m=void 0===v?V.revalidateOnMount:v,g=n.initialData,y=void 0===g?V.initialData:g,b=n.refresh,w=void 0===b?V.refresh:b,O=n.refreshTime,x=void 0===O?V.refreshTime:O,E=n.refreshBlurred,R=void 0===E?V.refreshBlurred:E,k=n.refreshOnTabBlur,D=void 0===k?V.refreshOnTabBlur:k,j=n.refreshOnTabFocus,S=void 0===j?V.refreshOnTabFocus:j,T=n.refreshOnReconnect,L=void 0===T?V.refreshOnReconnect:T,P=n.debounce,F=void 0===P?V.debounce:P,M=n.debounceTime,q=void 0===M?V.debounceTime:M,K=n.responseDataModifierFn,_=void 0===K?V.responseDataModifierFn:K,A=n.shouldThrow,B=void 0===A?V.shouldThrow:A,N=e.cacheTime,G=e.cacheKey,Q=e.queueKey,U=e.builder,Y=H(q),$=J(x),W=U.cache,X=U.fetchQueue,Z=U.appManager,ee=U.commandManager,re=U.loggerManager,te=r(re.init("useFetch")).current,ne=z(e,y),ae=d(ne,4),ie=ae[0],oe=ae[1],se=ae[2],ue=ae[3],ce=r(null),le=r(null),de=r(null),fe=r(null),he=r(null),pe=r(null),ve=r(null),me=r(null),ge=()=>{f?te.debug("Cannot add to fetch queue",{disabled:f}):(te.debug("Adding request to fetch queue"),X.add(e))},ye=()=>{$.resetInterval();var r=ie.timestamp,t=r?Math.max(+r+x-+new Date,x):x;w&&(te.debug("Starting refresh counter, request will be send in ".concat(t,"ms")),$.interval(c(I.mark((function r(){var t,n,a;return I.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,X.get(Q);case 2:t=r.sent,n=!e.builder.appManager.isFocused,a=n&&R||e.builder.appManager.isFocused,!!!t.requests.length&&a&&(te.info("Performing refresh request"),ge(),$.resetInterval());case 8:case"end":return r.stop()}}),r)}))),t))},be=e=>{if(e){var r,t,n;if(e[0])null==le||null===(t=le.current)||void 0===t||t.call(le,e[0]);if(e[1])if(null==de||null===(n=de.current)||void 0===n||n.call(de,e[1]),B)throw{message:"Fetching Error.",error:e[1]};null==fe||null===(r=fe.current)||void 0===r||r.call(fe,e)}},we=e=>{be(e.response),oe.setCacheData(e,!1)},Oe=(e,r)=>{be([ie.data,ie.error,ie.status]),oe.setRefreshed(e,!1),oe.setTimestamp(new Date(r),!1)},xe=e=>{var r,t=e.isLoading,n=e.isRetry;oe.setLoading(t,!1),null===(r=ce.current)||void 0===r||r.call(ce,{isRetry:n})},Ee=()=>{ge()},Re=r=>{r&&"string"==typeof r?e.builder.cache.events.revalidate(r):r&&r instanceof o?e.builder.cache.events.revalidate(s(r)):Ee()},ke=e=>{var r;null==ve||null===(r=ve.current)||void 0===r||r.call(ve,e)},De=e=>{var r;null==me||null===(r=me.current)||void 0===r||r.call(me,e)},je=e=>{var r;null==he||null===(r=he.current)||void 0===r||r.call(he,e)},Se=e=>{var r;null==he||null===(r=he.current)||void 0===r||r.call(he,e)},Te=()=>{var e=Z.events.onFocus((()=>S&&ge())),r=Z.events.onBlur((()=>D&&ge())),t=Z.events.onOnline((()=>L&&ge())),n=ee.events.onDownloadProgress(Q,ke),a=ee.events.onUploadProgress(Q,De),i=ee.events.onRequestStart(Q,je),o=ee.events.onResponseStart(Q,Se),s=X.events.getLoading(Q,xe),u=W.events.get(G,we),c=W.events.getEqualData(G,Oe),l=W.events.onRevalidate(G,Ee);return()=>{e(),r(),t(),n(),a(),i(),o(),s(),u(),c(),l()}},Le=()=>_&&ie.data?_(ie.data):ie.data,Pe=()=>{p||Object.keys(ie).forEach((e=>se(e)))};return t((()=>((m||C(N,ie.timestamp))&&ge(),Pe(),Te()))),a((()=>{ue&&be([ie.data,ie.error,ie.status])}),[ue],!0),a((()=>{!X.requestCount&&F?Y.debounce((()=>ge())):ge()}),[...u,f]),a((()=>{ye()}),[w,x,ie.timestamp],!0),{get data(){return se("data"),Le()},get error(){return se("error"),ie.error},get loading(){return se("loading"),ie.loading},get status(){return se("status"),ie.status},get retryError(){return se("retryError"),ie.retryError},get refreshError(){return se("refreshError"),ie.refreshError},get isRefreshed(){return se("isRefreshed"),ie.isRefreshed},get retries(){return se("retries"),ie.retries},get timestamp(){return se("timestamp"),ie.timestamp},get isOnline(){return se("isOnline"),ie.isOnline},get isFocused(){return se("isFocused"),ie.isFocused},get isStale(){return C(N,ie.timestamp)},actions:oe,onRequest:e=>{ce.current=e},onSuccess:e=>{le.current=e},onError:e=>{de.current=e},onFinished:e=>{fe.current=e},onRequestStart:e=>{he.current=e},onResponseStart:e=>{pe.current=e},onDownloadProgress:e=>{ve.current=e},onUploadProgress:e=>{me.current=e},isRefreshingError:!!ie.error&&ie.isRefreshed,isDebouncing:Y.active,refresh:Re}},X={disabled:!1,dependencyTracking:!0,cacheOnMount:!0,initialData:null,debounce:!1,debounceTime:400,suspense:!1,shouldThrow:!1,responseDataModifierFn:null,invalidate:[]},Z=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:X,a=n.disabled,i=void 0===a?X.disabled:a,o=n.dependencyTracking,s=void 0===o?X.dependencyTracking:o,u=n.initialData,c=void 0===u?X.initialData:u,l=n.shouldThrow,f=void 0===l?X.shouldThrow:l,h=n.responseDataModifierFn,p=void 0===h?X.responseDataModifierFn:h,v=e.cacheTime,m=e.cacheKey,g=e.queueKey,y=e.builder,b=y.cache,w=y.submitQueue,O=y.commandManager,x=y.loggerManager,E=r(x.init("useSubmit")).current,R=z(e,c),k=d(R,3),D=k[0],j=k[1],S=k[2],T=r(null),L=r(null),P=r(null),F=r(null),M=r(null),q=r(null),K=r(null),_=r(null),I=function(){var r=e,t=arguments.length<=0?void 0:arguments[0];null!=t&&t.data&&(r=r.setData(t.data)),null!=t&&t.params&&(r=r.setParams(t.params)),null!=t&&t.queryParams&&(r=r.setQueryParams(t.queryParams)),i?E.debug("Cannot add to submit queue",{disabled:i,options:t}):(E.debug("Adding request to submit queue",{disabled:i,options:t}),w.add(r))},A=e=>{if(e){var r,t,n;if(e[0])null==L||null===(t=L.current)||void 0===t||t.call(L,e[0]);if(e[1])if(null==P||null===(n=P.current)||void 0===n||n.call(P,e[1]),f)throw{message:"Fetching Error.",error:e[1]};null==F||null===(r=F.current)||void 0===r||r.call(F,e)}},B=e=>{j.setCacheData(e,!1),A(e.response)},N=(e,r)=>{j.setRefreshed(e,!1),j.setTimestamp(new Date(r),!1),A([D.data,D.error,D.status])},G=e=>{var r,t=e.isLoading,n=e.isRetry;j.setLoading(t,!1),null===(r=T.current)||void 0===r||r.call(T,{isRetry:n})},Q=e=>{var r;null==K||null===(r=K.current)||void 0===r||r.call(K,e)},U=e=>{var r;null==_||null===(r=_.current)||void 0===r||r.call(_,e)},Y=e=>{var r;null==M||null===(r=M.current)||void 0===r||r.call(M,e)},$=e=>{var r;null==M||null===(r=M.current)||void 0===r||r.call(M,e)},H=()=>{var e=O.events.onDownloadProgress(g,Q),r=O.events.onUploadProgress(g,U),t=O.events.onRequestStart(g,Y),n=O.events.onResponseStart(g,$),a=w.events.getLoading(g,G),i=b.events.get(g,B),o=b.events.getEqualData(m,N);return()=>{e(),r(),t(),n(),a(),i(),o()}},J=()=>p&&D.data?p(D.data):D.data,V=()=>{s||Object.keys(D).forEach((e=>S(e)))};return t((()=>(V(),H()))),{submit:I,get data(){return S("data"),J()},get error(){return S("error"),D.error},get submitting(){return S("loading"),D.loading},get status(){return S("status"),D.status},get retryError(){return S("retryError"),D.retryError},get retries(){return S("retries"),D.retries},get timestamp(){return S("timestamp"),D.timestamp},get isOnline(){return S("isOnline"),D.isOnline},get isFocused(){return S("isFocused"),D.isFocused},get isStale(){return C(v,D.timestamp)},actions:j,isDebouncing:!1,isRefreshed:!1,onSubmitRequest:e=>{T.current=e},onSubmitSuccess:e=>{L.current=e},onSubmitError:e=>{P.current=e},onSubmitFinished:e=>{F.current=e},onSubmitRequestStart:e=>{M.current=e},onSubmitResponseStart:e=>{q.current=e},onSubmitDownloadProgress:e=>{K.current=e},onSubmitUploadProgress:e=>{_.current=e}}};export{W as useFetch,Z as useSubmit};
//# sourceMappingURL=index.esm.js.map

@@ -131,10 +131,10 @@ import { useRef } from "react";

const handleGetCacheData = (cacheData: CacheValueType<ExtractResponse<T>, ExtractError<T>>) => {
handleCallbacks(cacheData.response);
actions.setCacheData(cacheData, false);
handleCallbacks(cacheData.response);
};
const handleGetEqualCacheUpdate = (isRefreshed: boolean, timestamp: number) => {
handleCallbacks([state.data, state.error, state.status]);
actions.setRefreshed(isRefreshed, false);
actions.setTimestamp(new Date(timestamp), false);
handleCallbacks([state.data, state.error, state.status]);
};

@@ -141,0 +141,0 @@

{
"name": "@better-typed/react-hyper-fetch",
"version": "0.0.22",
"version": "0.0.23",
"private": false,

@@ -5,0 +5,0 @@ "description": "React hooks and utils for the hyper-fetch",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc