import{r as t,cW as g}from"./index-CCv_8omK.js";function m(){var n=t.useRef(!1),r=t.useCallback(function(){return n.current},[]);return t.useEffect(function(){return n.current=!0,function(){n.current=!1}},[]),r}function b(n,r,u){r===void 0&&(r=[]),u===void 0&&(u={loading:!1});var a=t.useRef(0),c=m(),s=t.useState(u),l=s[0],o=s[1],d=t.useCallback(function(){for(var i=[],f=0;f<arguments.length;f++)i[f]=arguments[f];var v=++a.current;return l.loading||o(function(e){return g(g({},e),{loading:!0})}),n.apply(void 0,i).then(function(e){return c()&&v===a.current&&o({value:e,loading:!1}),e},function(e){return c()&&v===a.current&&o({error:e,loading:!1}),e})},r);return[l,d]}function y(n,r){r===void 0&&(r=[]);var u=b(n,r,{loading:!0}),a=u[0],c=u[1];return t.useEffect(function(){c()},[c]),a}export{y as u};
