import{_ as t,c as e,j as r,w as n,s as o,d as i,p as a,e as s,i as c,f as u,g as l,n as d,h as m}from"./index-d9fc8538.js";import p,{useState as f,useRef as h,useMemo as v,useEffect as w}from"react";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 g={dev:{qrApi:"//aly-test.api-auth.xiaoyuanhao.com"},test:{qrApi:"//aly-test.api-auth.xiaoyuanhao.com"},production:{qrApi:"//auth.xiaoyuanhao.com"}}[(document.querySelector('meta[name="x-server-env"]')||{content:"dev"}).content],b=e(r("isVisible","toggleVis",!1),n,(function(t){return function(e){var r=e.onBeforeClick,n=e.onSuccess,o=e.onError,b=e.request;e.loadingText;var q=e.buttonProps;e.onClick;var y=i(e,["onBeforeClick","onSuccess","onError","request","loadingText","buttonProps","onClick"]),S=y.toggleVisibility,C=y.isVisible,x=y.isBatch,O=void 0!==x&&x,P=y.confirmBeforeClick,k=y.qrBeforeClick,E=void 0!==k&&k,N=y.qrUniqueId,U=f(!1),B=U[0],J=U[1],L=a(window.location.search).requestParams,I=void 0===L?null:L,T=h(!1),A=function(t){J(t),T.current=t},V=window.location.href,j=v((function(){if(!b)return null;var t=b.params,e=i(b,["params"]);return JSON.stringify(P?s({idList:null==t?void 0:t.idList},(null==t?void 0:t.otherCommonParams)||{}):e)}),[b]);w((function(){var t,e;if(I&&O&&E&&(!N||N&&JSON.parse(decodeURI(I)).qrUniqueId===N))if(null==V?void 0:V.includes("errorMsg")){var r=null===(e=null===(t=decodeURIComponent(window.location.search))||void 0===t?void 0:t.split("&")[1])||void 0===e?void 0:e.split("=")[1];c.error(r||"扫码验证失败",5),window.history.replaceState(null,"",V.split("?")[0])}else F()}),[I]);var R=function(){var t,e=b.params,r=i(b,["params"]);return P?(null===(t=null==e?void 0:e.idList)||void 0===t?void 0:t.length)>0?e:I&&JSON.parse(I)||(null==e?void 0:e.otherCommonParams)||{}:r&&Object.values(null==r?void 0:r.search).filter((function(t){return!!t})).length>0?r||{}:I&&JSON.parse(I)||{}},_=function(){A(!1),S()},F=function(){return u(void 0,void 0,void 0,(function(){var t,e,a,m,p,f,h,v,w;return l(this,(function(g){switch(g.label){case 0:if(T.current)return[2];g.label=1;case 1:if(g.trys.push([1,7,,8]),t=b.url,e=b.params,a=b.method,m=b.formatter,p=b.tableSource,f=i(b,["url","params","method","formatter","tableSource"]),h=function(){return u(void 0,void 0,void 0,(function(){return l(this,(function(t){switch(t.label){case 0:return function(){var t,e=b.params;return!P||!I||(null===(t=null==e?void 0:e.idList)||void 0===t?void 0:t.length)>0&&JSON.stringify(null==I?void 0:I.idList)!==JSON.stringify(null==e?void 0:e.idList)}()?[4,r&&r({terminate:function(){A(!1)}})]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}}))}))},v={},!m||p)return[3,5];g.label=2;case 2:return g.trys.push([2,4,,5]),[4,m(e)];case 3:return v=g.sent(),[3,5];case 4:return w=g.sent(),console.warn("请求中断："+w.message),[2];case 5:return E?(u(void 0,void 0,void 0,(function(){var t;return l(this,(function(e){switch(e.label){case 0:return[4,d.request("/backend/loginUser/scan",{method:"GET"})];case 1:return t=e.sent().data,[2,new Promise((function(e){e(t)}))]}}))})).then((function(e){return u(void 0,void 0,void 0,(function(){return l(this,(function(r){switch(r.label){case 0:return e?[3,1]:(S(),[3,3]);case 1:return[4,h()];case 2:r.sent(),A(!0),d.request(t,s({method:a||"POST",data:s(s(s({},R()),v||{}),{batch:!0}),showError:!0},R())).then((function(t){T.current&&(A(!1),c.success("操作成功",1,(function(){n&&n(t);var e=window.location.href;window.history.replaceState(null,"",e.split("?")[0])})))})).catch((function(t){A(!1),o&&o(t)})),r.label=3;case 3:return[2]}}))}))})),[2]):[4,h()];case 6:return g.sent(),A(!0),d.request(t,s({method:a||"POST",data:s(s({},e||{}),v||{}),showError:!0},f)).then((function(t){T.current&&(A(!1),c.success("操作成功",1,(function(){n&&n(t)})))})).catch((function(t){A(!1),o&&o(t)})),[3,8];case 7:return g.sent(),A(!1),[3,8];case 8:return[2]}}))}))};return p.createElement(p.Fragment,null,p.createElement(t,s({},y,{buttonProps:s(s({},q||{}),{loading:B}),onClick:F})),C&&p.createElement(m,{className:"qr-button-modal-dialog",title:"验证管理员身份",visible:C,onCancel:_,onOk:_},p.createElement("iframe",{title:"iframe",className:"iframe-wrapper",src:g.qrApi+"/xyhauth/autologin?state=pc&sourceUrl="+V.split("?")[0]+"?requestParams="+window.encodeURIComponent(j),style:{height:"100%",width:"100%"},name:"mapFrame",scrolling:"no",frameBorder:"0"})))}}),o),q=b(t);export default q;export{b as requestHoc};
