import{r as e,s as t}from"./rolldown-runtime-C5c2KzVm.js";import{$P as n}from"./lucide-C4oWPzu4.js";import{p as r,t as i}from"./utils-Bs-0X7qI.js";import{r as a}from"./bundle-mjs-C4g7ASB5.js";import{l as o,m as s}from"./web-C56Kq6kn.js";import{m as c}from"./chunk-LFPYN7LY-Bb6SdmrV.js";import{n as l}from"./payconfig.constant-DWaejGty.js";var u=r(),d=a(),f=e=>{let t=(0,u.c)(11),{color:n,speed:r,className:a}=e,o=n===void 0?`var(--primary)`:n,s=r===void 0?.8:r,c;t[0]===a?c=t[1]:(c=i(`three-body relative inline-block size-10`,a),t[0]=a,t[1]=c);let l=`${s}s`,f;t[2]!==o||t[3]!==l?(f={"--uib-color":o,"--uib-speed":l},t[2]=o,t[3]=l,t[4]=f):f=t[4];let p=f,m,h,g;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,d.jsx)(`div`,{className:`three-body__dot absolute h-full w-[30%]`}),h=(0,d.jsx)(`div`,{className:`three-body__dot absolute h-full w-[30%]`}),g=(0,d.jsx)(`div`,{className:`three-body__dot absolute h-full w-[30%]`}),t[5]=m,t[6]=h,t[7]=g):(m=t[5],h=t[6],g=t[7]);let _;return t[8]!==c||t[9]!==p?(_=(0,d.jsxs)(`div`,{className:c,style:p,children:[m,h,g]}),t[8]=c,t[9]=p,t[10]=_):_=t[10],_},p=e({default:()=>_}),m=t(n(),1),h=`buildingai:alipay-payment-success`,g=`success`;function _(){let[e]=c(),t=(0,m.useRef)(!1),n=e.get(`payFrom`),r=e.get(`payOrderId`)??``,i=e.get(`payOrderNo`)??``,a=e.get(`payType`)??String(l.ALIPAY),u=n===`recharge`,p=n===`membership`,_=o(r,{enabled:u&&!!r,refetchInterval:e=>e.state.data?.payStatus===1||e.state.data?.payState===1?!1:2e3,refetchIntervalInBackground:!0,refetchOnWindowFocus:!1}),v=s(r,{enabled:p&&!!r,refetchInterval:e=>e.state.data?.payStatus===1||e.state.data?.payState===1?!1:2e3,refetchIntervalInBackground:!0,refetchOnWindowFocus:!1}),y=(0,m.useMemo)(()=>{if(u)return _.data;if(p)return v.data},[p,u,v.data,_.data]),b=y?.payStatus===1||y?.payState===1;(0,m.useEffect)(()=>{if(t.current||!b||typeof window>`u`)return;t.current=!0;let e={type:h,payFrom:n,payType:a,orderId:r,orderNo:i,status:g};try{window.opener?.postMessage(e,window.location.origin),window.opener?.focus?.()}catch(e){console.error(`Failed to notify opener about Alipay success:`,e)}window.setTimeout(()=>{window.close()},200)},[b,r,i,n,a]);let x=n?b?`支付成功，正在关闭窗口…`:u?`正在确认充值支付结果…`:`正在确认会员支付结果…`:`正在确认支付结果…`,S=!n||!r||a!==String(l.ALIPAY);return(0,d.jsx)(`div`,{className:`bg-background flex min-h-screen w-full items-center justify-center p-6`,children:(0,d.jsxs)(`div`,{className:`bg-card text-card-foreground flex w-full max-w-sm flex-col items-center gap-4 rounded-2xl border p-6 shadow-sm`,children:[(0,d.jsx)(f,{className:`text-primary size-10`}),(0,d.jsxs)(`div`,{className:`space-y-2 text-center`,children:[(0,d.jsx)(`p`,{className:`text-base font-medium`,children:S?`支付回跳参数异常`:x}),(0,d.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:S?`请返回系统重新发起支付`:`请不要关闭当前页面，系统正在自动处理支付结果。`})]}),b&&(0,d.jsx)(`p`,{className:`text-sm text-green-600 dark:text-green-400`,children:`支付已完成，窗口即将自动关闭`})]})})}export{p as n,f as r,_ as t};