import r from"@babel/runtime/helpers/asyncToGenerator";import e from"@babel/runtime/helpers/slicedToArray";import t from"@babel/runtime/regenerator";import{identity as n,debounce as a,isEqual as o}from"lodash";import{useState as i,useRef as l,useCallback as s}from"react";function u(u){var c=u.loadFn,p=u.getDataFromResponseFn,m=void 0===p?n((function(r){return r})):p,d=u.initialLoading,f=void 0===d||d,v=u.initialData,b=void 0===v?null:v,h=i(f),g=e(h,2),x=g[0],y=g[1],D=i(b),w=e(D,2),F=w[0],L=w[1],k=i(null),A=e(k,2),T=A[0],G=A[1],I=l(null),R=s(a(r(t.mark((function r(){var e,n,a,i,l=arguments;return t.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:for(y(!0),r.prev=1,e=l.length,n=new Array(e),a=0;a<e;a++)n[a]=l[a];return I.current=n,r.next=6,c.apply(void 0,n);case 6:i=r.sent,o(I.current,n)&&L(m(i)),r.next=14;break;case 10:r.prev=10,r.t0=r.catch(1),G(r.t0),console.error(r.t0);case 14:return r.prev=14,y(!1),r.finish(14);case 17:case"end":return r.stop()}}),r,null,[[1,10,14,17]])}))),500),[m,c]);return{isLoading:x,data:F,error:T,loadData:R,setData:L,setIsLoading:y}}export{u as default};
