import{I as r,b as t,d as e,e as o,f as n,g as i,h as c,i as a}from"./index-d9fc8538.js";import s,{forwardRef as u,createElement as m,useRef as d}from"react";import f from"./request-28cb3179.js";import"react-dom";import"stream";import"string_decoder";import"events";import"timers";import"util";import"url";import"http";import"https";import"buffer";import"path";import"querystring";import"assert";import"os";import"fs";import"child_process";import"antd";import"crypto";var p={icon:{tag:"svg",attrs:{viewBox:"0 0 1024 1024",focusable:"false"},children:[{tag:"path",attrs:{d:"M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 00-94.3-139.9 437.71 437.71 0 00-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z"}}]},name:"loading",theme:"outlined"},l=function(e,o){return m(r,t(t({},e),{},{ref:o,icon:p}))};l.displayName="LoadingOutlined";var v=u(l),h=function(r){return function(t){var u=t.onSuccess,m=t.onError,f=t.onBeforeClick;t.loadingText;var p=e(t,["onSuccess","onError","onBeforeClick","loadingText"]),l=d(null),h=d(!1);return s.createElement(r,o({},p,{onSuccess:function(r){if(h.current){if(h.current=!1,l.current.destroy(),!r||!/\/\//.test(r.data))return console.error('下载接口返回数据错误，请返回形如 { "success": true, "data": "下载链接" } 的结果'),void(m&&m(new Error("下载接口错误，请联系管理员")));window.location.href=r.data,a.success("下载链接获取成功，即将下载",2),u&&u(r.data)}},onError:function(r){h.current=!1,l.current.destroy(),m&&m(r)},onBeforeClick:function(r){return void 0===r&&(r={}),n(void 0,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return f?[4,f(r)]:[3,2];case 1:e.sent(),e.label=2;case 2:return t=r.terminate,h.current=!0,l.current=c.info({content:"正在导出中，请稍候…",icon:s.createElement(v,null),onOk:function(r){c.confirm({okText:"确认",cancelText:"取消",content:"您确定要取消下载吗？",onOk:function(){r(),t()}}),h.current=!1},okText:"取消下载"}),[2]}}))}))}}))}},g=h(f);export default g;export{h as downloadButtonHOC};
