import{o as e}from"./chunk-jRWAZmH_.js";import{n as t}from"./jsx-runtime-CEixWuwE.js";import{$n as n,er as r,ot as i,st as a}from"./axios-BAZB3l2q.js";import{n as o,t as s}from"./slicedToArray-BQ1tPSGY.js";import{n as c,t as l}from"./button-BwrlrBF7.js";r(),o(),i();var u=e(t());function d(e){return!!(e&&e.then)}var f=function(e){var t=u.useRef(!1),r=u.useRef(null),i=s(a(!1),2),o=i[0],f=i[1],p=e.close,m=function(){p?.apply(void 0,arguments)};u.useEffect(function(){var t=null;return e.autoFocus&&(t=setTimeout(function(){var e;(e=r.current)==null||e.focus()})),function(){t&&clearTimeout(t)}},[]);var h=function(e){d(e)&&(f(!0),e.then(function(){f(!1,!0),m.apply(void 0,arguments),t.current=!1},function(e){return f(!1,!0),t.current=!1,Promise.reject(e)}))},g=function(n){var r=e.actionFn;if(!t.current){if(t.current=!0,!r){m();return}var i;if(e.emitEvent){if(i=r(n),e.quitOnNullishReturnValue&&!d(i)){t.current=!1,m(n);return}}else if(r.length)i=r(p),t.current=!1;else if(i=r(),!i){m();return}h(i)}},_=e.type,v=e.children,y=e.prefixCls,b=e.buttonProps;return u.createElement(l,n({},c(_),{onClick:g,loading:o,prefixCls:y},b,{ref:r}),v)};export{f as t};