best-unit 1.4.5 → 1.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/best-unit.cjs
CHANGED
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
padding: 4px;
|
|
43
43
|
color: ${i.closeColor};
|
|
44
44
|
font-size: 12px;
|
|
45
|
-
`,l.onclick=()=>{document.body.removeChild(a)},a.appendChild(l)}document.body.appendChild(a),o!==0&&setTimeout(()=>{document.body.contains(a)&&document.body.removeChild(a)},o||3e3)}success(t){this.show("success",t)}error(t){this.show("error",t)}warning(t){this.show("warning",t)}info(t){this.show("info",t)}}const Xe=new xo;function So(e={}){const t=JSON.parse(sessionStorage.getItem("fund_unit_params")||"{}");console.log("fundUnitParams",t);const{env:n}=t;let r;switch(n){case X.DEV:case X.DEVELOPMENT:r="/api";break;case X.TEST:r="https://fund.bestfulfill.tech/api/sdk";break;case X.PROD:case X.PRODUCTION:default:r="https://fund.bestfulfill.com/api/sdk";break}const{baseURL:o=r,timeout:s=1e4,onError:i}=e,a=R.create({baseURL:o,timeout:s});return a.interceptors.request.use(u=>{const{token:l,locale:f}=t;return u.headers={...u.headers,Authorization:l,"x-locale":f===Pe.ZH?"zh-CN":"en-US"},u}),a.interceptors.response.use(u=>{if(u.data&&u.data.code===0)return u.data;const l=u.data?.msg||u.data?.message||"未知错误";return Xe.error(l),i&&i(l,u),Promise.reject(u.data||{message:"未知错误"})},u=>{const l=u.response?.data?.msg||u.response?.data?.message||u.message||"网络请求失败";return Xe.error(l),i&&i(l,u),Promise.reject(u)}),a}let xe=null;function te(){return xe||(xe=So()),xe}function Lo(){xe=null}function vn(){const e=JSON.parse(sessionStorage.getItem("fund_unit_params")||"{}");return te().get("/balance",{params:{merchant_id:e.merchantId,biz_type:e.bizType,fund_balance_id:e.fundBalanceId}}).then(t=>{const n=t.data,r={fundBalanceId:n.fund_balance_id,merchantId:n.merchant_id,bizType:n.biz_type,currency:n.currency,totalAmount:n.total_amount,frozenAmount:n.frozen_amount,creditLimit:n.credit_config?.credit_limit,creditUsed:n.credit_used,isCredit:!!n.credit_config,availableAmount:n.available_amount,currBalance:n.curr_balance,pendingAmount:n.pending_amount,status:n.status,createdAt:n.created_at};return sessionStorage.setItem("balanceData",JSON.stringify(r)),r})}const wo=async()=>te().get("/all-dicts",{}).then(e=>(sessionStorage.setItem("all_dicts",JSON.stringify(e.data)),e.data||{})),Ao=async(e,t)=>te().post("/oss/upload",e,{headers:{"Content-Type":"multipart/form-data"},onUploadProgress:n=>{if(n.total){const r=Math.round(n.loaded*100/n.total);t&&t(r)}}}).then(n=>n.data?.url||""),Eo=async e=>{const t=JSON.parse(sessionStorage.getItem("fund_unit_params")||"{}"),n={merchant_id:Number(t.merchantId),biz_type:t.bizType,fund_balance_id:t.fundBalanceId,source_operator:t.userId?String(t.userId):void 0,transfer_no:e.transferNo,transfer_channel:e.transferChannel,voucher_urls:e.voucherUrls};return te().post("/offline/recharge/create",n,{})},vo=async e=>{const t=JSON.parse(sessionStorage.getItem("fund_unit_params")||"{}"),n={merchant_id:Number(t.merchantId),biz_type:t.bizType,fund_balance_id:t.fundBalanceId,source_operator:t.userId?String(t.userId):void 0,amount:e.amount,currency:e.currency,recharge_channel:e.rechargeChannel,return_url:window.location.href};return te().post("/online/recharge/create",n,{}).then(r=>r.data.redirect_url)},ko=async e=>te().get("/calc-payment-amount",{params:e}).then(t=>{const n=t.data;return{paymentAmount:n.payment_amount,fee:n.fee,currency:n.currency}});async function To(){let e=JSON.parse(sessionStorage.getItem("balanceData")||"{}");return e&&Object.keys(e).length>0||(e=await vn()),e}function Co(e){const{merchant_id:t,biz_type:n,fund_balance_id:r,user_id:o,theme:s=N.WHITE,locale:i=Pe.ZH,env:a,size:u,themeConfig:l}=e;console.log(e,"InitParams1111");const f="Bearer "+e.token;return sessionStorage.setItem("fund_unit_params",JSON.stringify({merchantId:t,bizType:n,fundBalanceId:r,userId:o,token:f,theme:s,locale:i,env:a,size:u,themeConfig:l})),Lo(),wo(),{token:f,merchantId:t,bizType:n,fundBalanceId:r,userId:o,theme:s,locale:i,env:a,size:u}}function k(e){const t=JSON.parse(sessionStorage.getItem("fund_unit_params")||"{}");if(!e)return t;if(Array.isArray(e)){const n={};return e.forEach(r=>{n[r]=t[r]}),n}return t[e]}function kn(){const e=new CustomEvent("refresh-balance",{detail:{},bubbles:!0,composed:!0});
|
|
45
|
+
`,l.onclick=()=>{document.body.removeChild(a)},a.appendChild(l)}document.body.appendChild(a),o!==0&&setTimeout(()=>{document.body.contains(a)&&document.body.removeChild(a)},o||3e3)}success(t){this.show("success",t)}error(t){this.show("error",t)}warning(t){this.show("warning",t)}info(t){this.show("info",t)}}const Xe=new xo;function So(e={}){const t=JSON.parse(sessionStorage.getItem("fund_unit_params")||"{}");console.log("fundUnitParams",t);const{env:n}=t;let r;switch(n){case X.DEV:case X.DEVELOPMENT:r="/api";break;case X.TEST:r="https://fund.bestfulfill.tech/api/sdk";break;case X.PROD:case X.PRODUCTION:default:r="https://fund.bestfulfill.com/api/sdk";break}const{baseURL:o=r,timeout:s=1e4,onError:i}=e,a=R.create({baseURL:o,timeout:s});return a.interceptors.request.use(u=>{const{token:l,locale:f}=t;return u.headers={...u.headers,Authorization:l,"x-locale":f===Pe.ZH?"zh-CN":"en-US"},u}),a.interceptors.response.use(u=>{if(u.data&&u.data.code===0)return u.data;const l=u.data?.msg||u.data?.message||"未知错误";return Xe.error(l),i&&i(l,u),Promise.reject(u.data||{message:"未知错误"})},u=>{const l=u.response?.data?.msg||u.response?.data?.message||u.message||"网络请求失败";return Xe.error(l),i&&i(l,u),Promise.reject(u)}),a}let xe=null;function te(){return xe||(xe=So()),xe}function Lo(){xe=null}function vn(){const e=JSON.parse(sessionStorage.getItem("fund_unit_params")||"{}");return te().get("/balance",{params:{merchant_id:e.merchantId,biz_type:e.bizType,fund_balance_id:e.fundBalanceId}}).then(t=>{const n=t.data,r={fundBalanceId:n.fund_balance_id,merchantId:n.merchant_id,bizType:n.biz_type,currency:n.currency,totalAmount:n.total_amount,frozenAmount:n.frozen_amount,creditLimit:n.credit_config?.credit_limit,creditUsed:n.credit_used,isCredit:!!n.credit_config,availableAmount:n.available_amount,currBalance:n.curr_balance,pendingAmount:n.pending_amount,status:n.status,createdAt:n.created_at};return sessionStorage.setItem("balanceData",JSON.stringify(r)),r})}const wo=async()=>te().get("/all-dicts",{}).then(e=>(sessionStorage.setItem("all_dicts",JSON.stringify(e.data)),e.data||{})),Ao=async(e,t)=>te().post("/oss/upload",e,{headers:{"Content-Type":"multipart/form-data"},onUploadProgress:n=>{if(n.total){const r=Math.round(n.loaded*100/n.total);t&&t(r)}}}).then(n=>n.data?.url||""),Eo=async e=>{const t=JSON.parse(sessionStorage.getItem("fund_unit_params")||"{}"),n={merchant_id:Number(t.merchantId),biz_type:t.bizType,fund_balance_id:t.fundBalanceId,source_operator:t.userId?String(t.userId):void 0,transfer_no:e.transferNo,transfer_channel:e.transferChannel,voucher_urls:e.voucherUrls};return te().post("/offline/recharge/create",n,{})},vo=async e=>{const t=JSON.parse(sessionStorage.getItem("fund_unit_params")||"{}"),n={merchant_id:Number(t.merchantId),biz_type:t.bizType,fund_balance_id:t.fundBalanceId,source_operator:t.userId?String(t.userId):void 0,amount:e.amount,currency:e.currency,recharge_channel:e.rechargeChannel,return_url:window.location.href};return te().post("/online/recharge/create",n,{}).then(r=>r.data.redirect_url)},ko=async e=>te().get("/calc-payment-amount",{params:e}).then(t=>{const n=t.data;return{paymentAmount:n.payment_amount,fee:n.fee,currency:n.currency}});async function To(){let e=JSON.parse(sessionStorage.getItem("balanceData")||"{}");return e&&Object.keys(e).length>0||(e=await vn()),e}function Co(e){const{merchant_id:t,biz_type:n,fund_balance_id:r,user_id:o,theme:s=N.WHITE,locale:i=Pe.ZH,env:a,size:u,themeConfig:l}=e;console.log(e,"InitParams1111");const f="Bearer "+e.token;return sessionStorage.setItem("fund_unit_params",JSON.stringify({merchantId:t,bizType:n,fundBalanceId:r,userId:o,token:f,theme:s,locale:i,env:a,size:u,themeConfig:l})),Lo(),wo(),{token:f,merchantId:t,bizType:n,fundBalanceId:r,userId:o,theme:s,locale:i,env:a,size:u}}function k(e){const t=JSON.parse(sessionStorage.getItem("fund_unit_params")||"{}");if(!e)return t;if(Array.isArray(e)){const n={};return e.forEach(r=>{n[r]=t[r]}),n}return t[e]}function kn(){console.log("refreshBalance");const e=new CustomEvent("refresh-balance",{detail:{},bubbles:!0,composed:!0});window.dispatchEvent(e)}const Mo={"/api":{target:"https://fund.bestfulfill.tech/api/sdk",changeOrigin:!0,rewrite:e=>e.replace(/^\/api/,""),secure:!1}};function Ro(){const e=k("size");return{white:{background:"#1890ff",color:"#fff",border:"none",borderRadius:6,padding:e===d.SMALL?"6px 10px":"8px 16px",cursor:"pointer",fontSize:e===d.SMALL?12:16,fontWeight:600},dark:{background:"#00E8C6",color:"#fff",border:"none",borderRadius:6,padding:e===d.SMALL?"6px 10px":"8px 16px",cursor:"pointer",fontSize:e===d.SMALL?12:16,fontWeight:600}}}function Bo(e){const t=k("theme"),n=k("themeConfig"),r=t===N.WHITE,o=Ro();let s=e;return!s&&n&&(s=(r?n.white:n.dark)?.color),r?{...o.white,background:s||o.white.background}:{...o.dark,background:s||o.dark.background}}function Tn({onClick:e,color:t,children:n}){const r=Bo(t);return h("button",{style:r,onClick:e,type:"button",children:n})}const Fo={"额外费用说明:您的地区、币种、支付卡类型等因素可能会导致手续费的变动,最终手续费以官方为准。":"额外费用说明:您的地区、币种、支付卡类型等因素可能会导致手续费的变动,最终手续费以官方为准。","手续费约为:":"手续费约为:",确定:"确定",提交成功:"提交成功",余额详情:"余额详情",真实金额:"真实金额",冻结金额:"冻结金额",信用额度:"信用额度",已用额度:"已用额度",可用余额:"可用余额",暂无数据:"暂无数据","金额需在1到999999.99之间":"金额需在1到999999.99之间","充值 / 转账":"充值 / 转账",在线充值:"在线充值",线下转账:"线下转账",充值币种:"充值币种",充值金额:"充值金额",支付平台:"支付平台",请选择充值币种:"请选择充值币种",请输入充值金额:"请输入充值金额",请选择支付平台:"请选择支付平台","需要收取手续费,实际支付金额约为:":"需要收取手续费,实际支付金额约为:","提交失败,请重试":"提交失败,请重试","提交中...":"提交中...",去支付:"去支付",取消:"取消",关闭:"关闭",第三方支付平台:"第三方支付平台",交易ID:"交易ID",请输入转账交易ID:"请输入转账交易ID",上传文件:"上传文件",请上传转账凭证:"请上传转账凭证","加载中...":"加载中...",错误:"错误",成功:"成功",必填:"必填","充值/转账":"充值/转账",切换为暗黑主题:"切换为暗黑主题",切换为白色主题:"切换为白色主题",点击或拖拽文件到此处上传:"点击或拖拽文件到此处上传","支持 JPG、PNG、PDF 格式,单个文件不超过 20MB,最多上传":"支持 JPG、PNG、PDF 格式,单个文件不超过 20MB,最多上传",个文件:"个文件","正在上传...":"正在上传...",已上传:"已上传",移除:"移除"};function Oo(e){return Fo[e]||e}const Po={"额外费用说明:您的地区、币种、支付卡类型等因素可能会导致手续费的变动,最终手续费以官方为准。":"Additional note: Your region, currency, and card type may affect the processing fee; the final fee is determined by the provider.","手续费约为:":"Fee approximately: ",确定:"Confirm",提交成功:"Submit Success",余额详情:"Balance Details",真实金额:"Real Balance",冻结金额:"Frozen Amount",信用额度:"Credit Limit",已用额度:"Credit Used",可用余额:"Available Balance",暂无数据:"No Data","金额需在1到999999.99之间":"Amount must be between 1 and 999999.99","充值 / 转账":"Recharge / Transfer",在线充值:"Online Recharge",线下转账:"Offline Transfer",充值币种:"Recharge Currency",充值金额:"Recharge Amount",支付平台:"Payment Platform",请选择充值币种:"Please select recharge currency",请输入充值金额:"Please enter recharge amount",请选择支付平台:"Please select payment platform","需要收取手续费,实际支付金额约为:":"requires a handling fee, the actual payment amount is approximately: ","提交失败,请重试":"Submit failed, please try again","提交中...":"Submitting...",去支付:"Go to Pay",取消:"Cancel",关闭:"Close",第三方支付平台:"Third-party Payment Platform",交易ID:"Transaction ID",请输入转账交易ID:"Please enter transfer transaction ID",上传文件:"Upload Files",请上传转账凭证:"Please upload transfer voucher","加载中...":"Loading...",错误:"Error",成功:"Success",必填:"Required","充值/转账":"Recharge/Transfer",切换为暗黑主题:"Switch to Dark Theme",切换为白色主题:"Switch to Light Theme",点击或拖拽文件到此处上传:"Click or drag files here to upload","支持 JPG、PNG、PDF 格式,单个文件不超过 20MB,最多上传":"Supports JPG, PNG, PDF formats, single file not exceeding 20MB, maximum",个文件:"files can be uploaded","正在上传...":"Uploading...",已上传:"Uploaded",移除:"Remove"};function Do(e){return Po[e]||e}function Io(){return JSON.parse(sessionStorage.getItem("fund_unit_params")||"{}").locale||Pe.ZH}function L(e){return Io()==="zh"?Oo(e):Do(e)}const Ot={white:{trigger:{background:"#fff",color:"#222",border:"1px solid #d9d9d9"},triggerDisabled:{background:"#f5f5f5",color:"#bfbfbf",border:"1px solid #f0f0f0"},triggerError:{background:"#fff",color:"#222",border:"1px solid #ff4d4f"},dropdown:{background:"#fff",border:"1px solid #d9d9d9",color:"#222"},option:(e,t,n)=>({color:t?"#bfbfbf":e?"#1890ff":"#222",background:e?"#e6f7ff":n&&!t||t?"#f5f5f5":"#fff"}),placeholder:{color:"#bfbfbf"},scrollbarThumb:"#e5e5e5",scrollbarTrack:"#f5f5f5",boxShadow:"0 2px 8px rgba(0,0,0,0.08)"},dark:{trigger:{background:"#23262F",color:"#fff",border:"1px solid #374151"},triggerDisabled:{background:"#23262F",color:"#666",border:"1px solid #374151"},triggerError:{background:"#23262F",color:"#fff",border:"1px solid #ff4d4f"},dropdown:{background:"#23262F",border:"1px solid #374151",color:"#fff"},option:(e,t,n)=>({color:t?"#666":e?"#00E8C6":"#fff",background:e?"#23262F":n&&!t?"#333843":"#23262F"}),placeholder:{color:"#666"},scrollbarThumb:"#444C5C",scrollbarTrack:"#23262F",boxShadow:"0 2px 8px rgba(0,0,0,0.32)"}};function No(){const e=k("theme"),t=k("themeConfig"),n=e===N.WHITE,r=n?Ot.white:Ot.dark;if(t){const o=n?t.white:t.dark;if(o?.color)return{...r,option:(s,i,a)=>({...r.option(s,i,a),color:i?r.option(s,i,a).color:s?o.color:r.option(s,i,a).color})}}return r}const Ze=({value:e,onChange:t,options:n,placeholder:r,style:o,error:s,disabled:i,dropdownStyle:a,className:u,dropdownClassName:l,children:f})=>{const[c,x]=O(!1),_=Ee(null),[m,b]=O(null),g=No(),y=k("size");le(()=>{if(!c)return;const w=E=>{_.current&&!_.current.contains(E.target)&&x(!1)};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[c]);const S=n.find(w=>w.value===e),v=()=>s?g.triggerError:i?g.triggerDisabled:g.trigger;return h("div",{ref:_,className:u,style:{position:"relative",...o},children:[h("style",{children:`
|
|
46
46
|
.custom-select-dropdown {
|
|
47
47
|
scrollbar-width: thin;
|
|
48
48
|
scrollbar-color: ${g.scrollbarThumb} ${g.scrollbarTrack};
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
.custom-select-dropdown::-webkit-scrollbar-track {
|
|
58
58
|
background: ${g.scrollbarTrack};
|
|
59
59
|
}
|
|
60
|
-
`}),h("div",{onClick:()=>!i&&x(w=>!w),style:{minHeight:y===d.SMALL?32:40,borderRadius:6,display:"flex",alignItems:"center",padding:y===d.SMALL?"0 10px":"0 12px",fontSize:y===d.SMALL?12:15,cursor:i?"not-allowed":"pointer",boxSizing:"border-box",transition:"border 0.2s",opacity:i?.6:1,width:"100%",...v(),...o},tabIndex:0,children:[h("span",{style:{flex:1},children:S?S.label:h("span",{style:g.placeholder,children:r||"请选择"})}),h("span",{style:{marginLeft:8,display:"flex",alignItems:"center"},children:h("svg",{width:y===d.SMALL?16:20,height:y===d.SMALL?16:20,viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:h("path",{d:"M6 8L10 12L14 8",stroke:"#bfbfbf","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"})})})]}),c&&!i&&h("div",{className:`custom-select-dropdown${l?" "+l:""}`,style:{position:"absolute",left:0,right:0,top:y===d.SMALL?32:44,zIndex:10,borderRadius:6,boxShadow:g.boxShadow,maxHeight:y===d.SMALL?160:220,overflowY:"auto",...g.dropdown,...a},children:[n.length===0&&h("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:y===d.SMALL?80:120,width:"100%",userSelect:"none"},children:[h("svg",{width:y===d.SMALL?48:64,height:y===d.SMALL?32:41,viewBox:"0 0 64 41",xmlns:"http://www.w3.org/2000/svg",children:[h("title",{children:L("暂无数据")}),h("g",{transform:"translate(0 1)",fill:"none",fillRule:"evenodd",children:[h("ellipse",{fill:"#f5f5f5",cx:"32",cy:"33",rx:"32",ry:"7"}),h("g",{fillRule:"nonzero",stroke:"#d9d9d9",children:[h("path",{d:"M55 12.76L44.854 1.258C44.367.474 43.656 0 42.907 0H21.093c-.749 0-1.46.474-1.947 1.257L9 12.761V22h46v-9.24z"}),h("path",{d:"M41.613 15.931c0-1.605.994-2.93 2.227-2.931H55v18.137C55 33.26 53.68 35 52.05 35h-40.1C10.32 35 9 33.259 9 31.137V13h11.16c1.233 0 2.227 1.323 2.227 2.928v.022c0 1.605 1.005 2.901 2.237 2.901h14.752c1.232 0 2.237-1.308 2.237-2.913v-.007z",fill:"#fafafa"})]})]})]}),h("div",{style:{marginTop:8,color:"#bfbfbf",fontSize:y===d.SMALL?12:15},children:L("暂无数据")})]}),n.map((w,E)=>h("div",{onClick:()=>{w.disabled||(x(!1),t?.(w.value))},onMouseEnter:()=>b(E),onMouseLeave:()=>b(null),style:{padding:y===d.SMALL?"6px 10px":"10px 16px",fontSize:y===d.SMALL?12:15,cursor:w.disabled?"not-allowed":"pointer",fontWeight:e===w.value?600:400,opacity:w.disabled?.6:1,...g.option(e===w.value,!!w.disabled,m===E)},children:w.label},w.value))]}),f]})};function zo(){const e=k("size");return{white:{label:{marginBottom:e===d.SMALL?6:8,fontSize:e===d.SMALL?12:14,color:"#222",textAlign:"left",display:"block"},input:{width:"100%",padding:e===d.SMALL?"8px 10px":"10px 12px",borderRadius:6,boxSizing:"border-box",border:"1px solid #E5E6EB",background:"#fff",color:"#222",fontSize:e===d.SMALL?12:15,outline:"none",marginBottom:0},inputError:{border:"1px solid #ff4d4f"},selectError:{border:"1px solid #ff4d4f"},error:{color:"#ff4d4f",fontSize:e===d.SMALL?12:13,marginTop:e===d.SMALL?2:4,textAlign:"left"},buttonCancel:{background:"#fff",color:"#222",border:"1px solid #E5E6EB",borderRadius:6,padding:e===d.SMALL?"6px 16px":"8px 24px",fontSize:e===d.SMALL?12:15,cursor:"pointer"},buttonSubmit:{background:"#1890ff",color:"#fff",border:"none",borderRadius:6,padding:e===d.SMALL?"6px 16px":"8px 24px",fontSize:e===d.SMALL?12:15,cursor:"pointer",fontWeight:600},feeTip:{marginBottom:24,padding:e===d.SMALL?"8px 10px":"12px 16px",background:"#f6ffed",border:"1px solid #b7eb8f",borderRadius:6,fontSize:e===d.SMALL?12:14,color:"#52c41a"},feeDetailBox:{marginTop:e===d.SMALL?8:10,marginBottom:e===d.SMALL?16:20,padding:e===d.SMALL?"8px 10px":"12px 16px",background:"#fff",border:"1px solid #E5E6EB",borderRadius:6},feeDetailTitle:{fontSize:e===d.SMALL?12:14,color:"#222",fontWeight:600,marginBottom:e===d.SMALL?6:8},feeAmount:{color:"#F53F3F",marginLeft:4},feeDetailDesc:{fontSize:e===d.SMALL?12:13,color:"#6b7280",lineHeight:1.5}},dark:{label:{marginBottom:e===d.SMALL?6:8,fontSize:e===d.SMALL?12:14,color:"#fff",textAlign:"left",display:"block"},input:{width:"100%",padding:e===d.SMALL?"8px 10px":"10px 12px",borderRadius:6,boxSizing:"border-box",border:"1px solid #374151",background:"#23262F",color:"#fff",fontSize:e===d.SMALL?12:15,outline:"none",marginBottom:0},inputError:{border:"1px solid #ff4d4f"},selectError:{border:"1px solid #ff4d4f"},error:{color:"#ff4d4f",fontSize:e===d.SMALL?12:13,marginTop:e===d.SMALL?2:4,textAlign:"left"},buttonCancel:{background:"#23262F",color:"#fff",border:"none",borderRadius:6,padding:e===d.SMALL?"6px 16px":"8px 24px",fontSize:e===d.SMALL?12:15,cursor:"pointer"},buttonSubmit:{background:"#00E8C6",color:"#fff",border:"none",borderRadius:6,padding:e===d.SMALL?"6px 16px":"8px 24px",fontSize:e===d.SMALL?12:15,cursor:"pointer",fontWeight:600},feeTip:{marginBottom:e===d.SMALL?16:24,padding:e===d.SMALL?"8px 10px":"12px 16px",background:"#1a1a1a",border:"1px solid #333",borderRadius:6,fontSize:e===d.SMALL?12:14,color:"#52c41a"},feeDetailBox:{marginTop:e===d.SMALL?8:10,marginBottom:e===d.SMALL?16:20,padding:e===d.SMALL?"8px 10px":"12px 16px",background:"#23262F",border:"1px solid #374151",borderRadius:6},feeDetailTitle:{fontSize:e===d.SMALL?12:14,color:"#fff",fontWeight:600,marginBottom:e===d.SMALL?6:8},feeAmount:{color:"#FF6B6B",marginLeft:4},feeDetailDesc:{fontSize:e===d.SMALL?12:13,color:"#B5B8BE",lineHeight:1.5}}}}function Uo(){const e=k("theme"),t=k("themeConfig"),n=e===N.WHITE,r=zo(),o=n?r.white:r.dark;if(t){const s=n?t.white:t.dark;if(s?.color)return{...o,buttonSubmit:{...o.buttonSubmit,background:s.color}}}return o}function Ho(e){return e=e.replace(/[^\d.]/g,""),e=e.replace(/\.(?=.*\.)/g,""),e=e.replace(/^(\d+)(\.\d{0,2})?.*$/,"$1$2"),e=e.replace(/^0+(\d)/,"$1"),e.startsWith(".")&&(e="0"+e),e}function jo(e){if(!e)return"";const t=parseFloat(e);return isNaN(t)?"":t.toFixed(2)}const $o=({formState:e,setFormState:t,onClose:n,loading:r})=>{const o=JSON.parse(sessionStorage.getItem("all_dicts")||"{}"),s=o?.currency||[],i=o?.channel?.filter(m=>m.payment_support)||[],[a,u]=O(""),[l,f]=O(""),[c,x]=O(!1),_=Uo();return le(()=>{e.currency&&e.amount&&e.rechargeChannel?ko({channel:e.rechargeChannel,amount:e.amount,currency:e.currency}).then(m=>{u(m.paymentAmount),f(m.fee),x(!0)}).catch(m=>{console.error("计算支付金额失败:",m),x(!1)}):x(!1)},[e.currency,e.amount,e.rechargeChannel]),h(K,{children:[h("div",{style:{marginBottom:18},children:[h("div",{style:_.label,children:[h("span",{style:{color:"#F53F3F"},children:"*"})," ",L("充值币种")]}),h(Ze,{value:e.currency,onChange:m=>{t(b=>({...b,currency:m}))},options:s?.map(m=>({value:m.value,label:m.label})),placeholder:L("请选择充值币种")})]}),h("div",{style:{marginBottom:18},children:[h("div",{style:_.label,children:[h("span",{style:{color:"#F53F3F"},children:"*"})," ",L("充值金额")]}),h("input",{type:"text",placeholder:L("请输入充值金额"),value:e.amount,onInput:m=>{let b=m.target.value;b=Ho(b);let g="";if(b&&!b.endsWith(".")){let y=parseFloat(b);if(!isNaN(y)&&(y<1&&(y=1),y>999999.99&&(y=999999.99),b=y.toString(),/\./.test(m.target.value))){const S=m.target.value.split(".")[1];S!==void 0&&S.length>0&&(b=y.toFixed(Math.min(S.length,2)))}}t(y=>({...y,amount:b,amountError:g}))},onBlur:m=>{let b=m.target.value;b=jo(b),t(g=>({...g,amount:b,amountError:""}))},style:{..._.input,...e.amountError?_.inputError:{}}}),e.amountError&&h("div",{style:_.error,children:e.amountError})]}),h("div",{style:{marginBottom:24},children:[h("div",{style:_.label,children:[h("span",{style:{color:"#F53F3F"},children:"*"})," ",L("支付平台")]}),h(Ze,{value:e.rechargeChannel,onChange:m=>{t(b=>({...b,rechargeChannel:m,rechargeChannelError:m?"":b.rechargeChannelError}))},options:i?.map(m=>({value:m.value,label:m.label})),placeholder:L("请选择支付平台")}),e.rechargeChannelError&&h("div",{style:_.error,children:e.rechargeChannelError})]}),c&&a&&h("div",{style:_.feeTip,children:[i.find(m=>m.value===e.rechargeChannel)?.label||e.rechargeChannel,L("需要收取手续费,实际支付金额约为:"),"$",a]}),c&&a&&h("div",{style:_.feeDetailBox,children:[h("div",{style:_.feeDetailTitle,children:[L("手续费约为:"),h("span",{style:_.feeAmount,children:["$",l]})]}),h("div",{style:_.feeDetailDesc,children:L("额外费用说明:您的地区、币种、支付卡类型等因素可能会导致手续费的变动,最终手续费以官方为准。")})]}),e.error&&h("div",{style:{color:"#ff4d4f",marginBottom:12},children:e.error}),h("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:[h("button",{type:"button",onClick:n,style:_.buttonCancel,children:L("取消")}),h("button",{type:"submit",disabled:r,style:_.buttonSubmit,children:L(r?"提交中...":"去支付")})]})]})};function Wo(){const e=k("size");return{white:{container:{border:"1px dashed #E5E6EB",borderRadius:8,background:"#FCFCFD",padding:e===d.SMALL?16:24,textAlign:"center",cursor:"pointer",minHeight:e===d.SMALL?80:120,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:"#999",fontSize:e===d.SMALL?12:15},fileItem:{display:"flex",alignItems:"center",background:"#F7F8FA",borderRadius:8,padding:e===d.SMALL?"8px 10px":"12px 16px",marginBottom:8,fontSize:e===d.SMALL?12:15,color:"#222",justifyContent:"space-between"},removeBtn:{background:"#FF4D4F",color:"#fff",border:"none",borderRadius:6,padding:e===d.SMALL?"6px 10px":"4px 14px",fontSize:e===d.SMALL?12:15,marginLeft:e===d.SMALL?8:16,cursor:"pointer"}},dark:{container:{border:"1.5px dashed #444C5C",borderRadius:8,background:"#181A20",padding:e===d.SMALL?16:24,textAlign:"center",cursor:"pointer",minHeight:e===d.SMALL?80:120,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:"#999",fontSize:e===d.SMALL?12:15},fileItem:{display:"flex",alignItems:"center",background:"#23262F",borderRadius:8,padding:e===d.SMALL?"8px 10px":"12px 16px",marginBottom:8,fontSize:e===d.SMALL?12:15,color:"#fff",justifyContent:"space-between"},removeBtn:{background:"#FF4D4F",color:"#fff",border:"none",borderRadius:6,padding:e===d.SMALL?"6px 10px":"4px 14px",fontSize:e===d.SMALL?12:15,marginLeft:e===d.SMALL?8:16,cursor:"pointer"}}}}function qo(){const t=k("theme")===N.WHITE,n=Wo();return t?n.white:n.dark}const Jo=({value:e=[],onChange:t,maxCount:n=10,accept:r=".jpg,.jpeg,.png,.pdf",multiple:o=!0,disabled:s=!1})=>{const i=k("size"),a=Ee(null),[u,l]=O(!1),[f,c]=O(0),x=qo(),_=async b=>{const g=Array.from(b.target.files).slice(0,n);if(!g.length)return;l(!0);const y=[];for(let S=0;S<g.length;S++){c(0);const v=new FormData;v.append("file",g[S]);try{const w=await Ao(v,E=>c(E));w&&y.push(w)}catch{}}l(!1),c(0),t?.([...e,...y]),a.current&&(a.current.value="")},m=b=>{const g=e.filter((y,S)=>S!==b);t?.(g)};return h("div",{children:[h("div",{style:{...x.container,cursor:s?"not-allowed":x.container.cursor,opacity:s?.6:1},onClick:()=>!s&&a.current?.click(),children:[h("div",{style:{fontSize:i===d.SMALL?32:48,marginBottom:i===d.SMALL?8:12},children:"📁"}),h("div",{style:{color:"#222",fontSize:i===d.SMALL?12:15,marginBottom:i===d.SMALL?4:8},children:L("点击或拖拽文件到此处上传")}),h("div",{style:{color:"#999",fontSize:i===d.SMALL?12:13},children:[L("支持 JPG、PNG、PDF 格式,单个文件不超过 20MB,最多上传")," ",n," ",L("个文件")]}),h("input",{ref:a,type:"file",multiple:o,accept:r,style:{display:"none"},onChange:_,disabled:s}),u&&h("div",{style:{marginTop:i===d.SMALL?8:12,color:"#1677ff"},children:[L("正在上传...")," ",f,"%"]})]}),e&&e.length>0&&h("div",{style:{marginTop:i===d.SMALL?8:12},children:e.map((b,g)=>h("div",{style:x.fileItem,children:[h("div",{style:{display:"flex",alignItems:"center",flex:1},children:h("span",{style:{fontWeight:500,wordBreak:"break-all"},children:b.split("/").pop()})}),h("button",{type:"button",onClick:y=>{y.stopPropagation(),m(g)},style:x.removeBtn,disabled:s,children:L("移除")})]},b))})]})};function Vo(){const e=k("size");return{white:{label:{marginBottom:e===d.SMALL?6:8,fontSize:e===d.SMALL?12:14,color:"#222",textAlign:"left",display:"block"},input:{width:"100%",padding:e===d.SMALL?"8px 10px":"10px 12px",borderRadius:6,boxSizing:"border-box",border:"1px solid #E5E6EB",background:"#fff",color:"#222",fontSize:e===d.SMALL?12:15,outline:"none",marginBottom:0},inputError:{border:"1px solid #ff4d4f"},select:{width:"100%",padding:e===d.SMALL?"8px 10px":"10px 12px",borderRadius:6,border:"1px solid #E5E6EB",background:"#fff",color:"#222",fontSize:e===d.SMALL?12:15,outline:"none"},selectError:{border:"1px solid #ff4d4f"},upload:{border:"1px dashed #E5E6EB",borderRadius:8,background:"#FCFCFD",padding:e===d.SMALL?12:24,textAlign:"center",cursor:"pointer",minHeight:e===d.SMALL?100:120,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:"#999",fontSize:e===d.SMALL?12:15},uploadError:{border:"1px dashed #ff4d4f"},fileItem:{display:"flex",alignItems:"center",background:"#F7F8FA",borderRadius:8,padding:e===d.SMALL?"8px 10px":"12px 16px",marginBottom:e===d.SMALL?6:8,fontSize:e===d.SMALL?12:15,color:"#222",justifyContent:"space-between"},buttonCancel:{background:"#fff",color:"#222",border:"1px solid #E5E6EB",borderRadius:6,padding:e===d.SMALL?"6px 18px":"8px 24px",cursor:"pointer"},buttonSubmit:{background:"#1890ff",color:"#fff",border:"none",borderRadius:6,padding:e===d.SMALL?"6px 18px":"8px 24px",cursor:"pointer",fontWeight:600},removeBtn:{background:"#FF4D4F",color:"#fff",border:"none",borderRadius:6,padding:e===d.SMALL?"6px 18px":"4px 14px",fontSize:e===d.SMALL?12:15,marginLeft:e===d.SMALL?8:16,cursor:"pointer"},error:{color:"#ff4d4f",fontSize:e===d.SMALL?12:13,marginTop:e===d.SMALL?2:4,textAlign:"left"}},dark:{label:{marginBottom:e===d.SMALL?4:8,fontSize:e===d.SMALL?12:14,color:"#fff",textAlign:"left",display:"block"},input:{width:"100%",padding:e===d.SMALL?"8px 10px":"10px 12px",borderRadius:6,boxSizing:"border-box",border:"1px solid #374151",background:"#23262F",color:"#fff",fontSize:e===d.SMALL?12:15,outline:"none",marginBottom:0},inputError:{border:"1px solid #ff4d4f"},select:{width:"100%",padding:e===d.SMALL?"8px 10px":"10px 12px",borderRadius:6,border:"1px solid #374151",background:"#23262F",color:"#fff",fontSize:e===d.SMALL?12:15,outline:"none"},selectError:{border:"1px solid #ff4d4f"},upload:{border:"1px dashed #374151",borderRadius:8,background:"#181A20",padding:e===d.SMALL?12:24,textAlign:"center",cursor:"pointer",minHeight:e===d.SMALL?100:120,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:"#999",fontSize:e===d.SMALL?12:14},uploadError:{border:"1px dashed #ff4d4f"},fileItem:{display:"flex",alignItems:"center",background:"#23262F",borderRadius:8,padding:e===d.SMALL?"8px 10px":"12px 16px",marginBottom:e===d.SMALL?6:8,fontSize:e===d.SMALL?12:15,color:"#fff",justifyContent:"space-between"},buttonCancel:{background:"#23262F",color:"#fff",border:"none",borderRadius:6,padding:e===d.SMALL?"6px 18px":"8px 24px",fontSize:e===d.SMALL?12:15,cursor:"pointer"},buttonSubmit:{background:"#00E8C6",color:"#fff",border:"none",borderRadius:6,padding:e===d.SMALL?"6px 18px":"8px 24px",fontSize:e===d.SMALL?12:14,cursor:"pointer",fontWeight:600},removeBtn:{background:"#FF4D4F",color:"#fff",border:"none",borderRadius:6,padding:e===d.SMALL?"6px 18px":"4px 14px",fontSize:e===d.SMALL?12:15,marginLeft:e===d.SMALL?8:16,cursor:"pointer"},error:{color:"#ff4d4f",fontSize:e===d.SMALL?12:13,marginTop:e===d.SMALL?2:4,textAlign:"left"}}}}function Go(){const e=k("theme"),t=k("themeConfig"),n=e===N.WHITE,r=Vo(),o=n?r.white:r.dark;if(console.log(t,"themeConfig"),t){const s=n?t.white:t.dark;if(s?.color)return{...o,buttonSubmit:{...o.buttonSubmit,background:s.color}}}return o}const Ko=({formState:e,setFormState:t,onClose:n,loading:r})=>{const o=JSON.parse(sessionStorage.getItem("all_dicts")||"{}");console.log(o,"allDicts");const s=o?.channel||[],i=Go();return h("form",{onSubmit:async u=>{u.preventDefault();let l=!0;t(f=>({...f,platformError:"",transactionIdError:"",filesError:""})),e.platform||(t(f=>({...f,platformError:L("请选择支付平台")})),l=!1),e.transactionId.trim()||(t(f=>({...f,transactionIdError:L("请输入转账交易ID")})),l=!1),(!e.files||e.files.length===0)&&(t(f=>({...f,filesError:L("请上传转账凭证")})),l=!1),l&&(await Eo({transferChannel:e.platform,transferNo:e.transactionId,voucherUrls:e.files}),n(),Xe.success(L("提交成功")))},children:[h("div",{style:{marginBottom:18},children:[h("div",{style:i.label,children:[h("span",{style:{color:"#F53F3F"},children:"*"})," ",L("第三方支付平台")]}),h(Ze,{value:e.platform,onChange:u=>{t(l=>({...l,platform:u,platformError:u?"":l.platformError}))},options:[...s?.map(u=>({value:u.value,label:u.label}))],placeholder:L("请选择支付平台")}),e.platformError&&h("div",{style:i.error,children:e.platformError})]}),h("div",{style:{marginBottom:18},children:[h("div",{style:i.label,children:[h("span",{style:{color:"#F53F3F"},children:"*"})," ",L("交易ID")]}),h("input",{type:"text",placeholder:L("请输入转账交易ID"),value:e.transactionId,maxLength:200,onInput:u=>{let l=u.target.value;l.length>200&&(l=l.slice(0,200)),t(f=>({...f,transactionId:l,transactionIdError:l?"":f.transactionIdError}))},style:{...i.input,...e.transactionIdError?i.inputError:{}}}),e.transactionIdError&&h("div",{style:i.error,children:e.transactionIdError})]}),h("div",{style:{marginBottom:24},children:[h("div",{style:i.label,children:[h("span",{style:{color:"#F53F3F"},children:"*"})," ",L("上传文件")]}),h(Jo,{value:e.files,onChange:u=>t(l=>({...l,files:u,filesError:""})),maxCount:10,accept:".jpg,.jpeg,.png,.pdf",multiple:!0}),e.filesError&&h("div",{style:i.error,children:e.filesError})]}),h("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:[h("button",{type:"button",onClick:n,style:i.buttonCancel,children:L("取消")}),h("button",{type:"submit",disabled:r,style:i.buttonSubmit,children:L("确定")})]})]})};function Xo(){const e=k("size");return{white:{mask:"rgba(0, 0, 0, 0.45)",modalBg:"#fff",modalColor:"#222",modalBoxShadow:"0 6px 16px rgba(0, 0, 0, 0.12)",closeBtn:{position:"absolute",top:"16px",right:"16px",background:"none",border:"none",fontSize:e===d.SMALL?16:24,cursor:"pointer",color:"#999",padding:"0",width:e===d.SMALL?16:24,height:e===d.SMALL?16:24,display:"flex",alignItems:"center",justifyContent:"center"},title:{fontSize:e===d.SMALL?16:18,fontWeight:"600",marginBottom:e===d.SMALL?16:24,color:"#222"},tabBtn:(t,n)=>({flex:1,padding:e===d.SMALL?"8px 10px":"12px 16px",background:t?"#1890ff":"transparent",color:t?"#fff":"#666",border:"1px solid #d9d9d9",borderRight:n?"none":"1px solid #d9d9d9",cursor:"pointer",fontSize:e===d.SMALL?12:14,fontWeight:t?"600":"400",borderRadius:n?"6px 0 0 6px":"0 6px 6px 0"})},dark:{mask:"rgba(0, 0, 0, 0.65)",modalBg:"#23262F",modalColor:"#F5F6FA",modalBoxShadow:"0 6px 16px rgba(0,0,0,0.32)",closeBtn:{position:"absolute",top:e===d.SMALL?"12px":"16px",right:e===d.SMALL?"12px":"16px",background:"none",border:"none",fontSize:e===d.SMALL?16:24,cursor:"pointer",color:"#B5B8BE",padding:"0",width:e===d.SMALL?16:24,height:e===d.SMALL?16:24,display:"flex",alignItems:"center",justifyContent:"center"},title:{fontSize:e===d.SMALL?16:18,fontWeight:"600",marginBottom:e===d.SMALL?16:24,color:"#F5F6FA"},tabBtn:(t,n)=>({flex:1,padding:e===d.SMALL?"8px 10px":"12px 16px",background:t?"#00E8C6":"transparent",color:t?"#fff":"#B5B8BE",border:"1px solid #444C5C",borderRight:n?"none":"1px solid #444C5C",cursor:"pointer",fontSize:e===d.SMALL?12:14,fontWeight:t?"600":"400",borderRadius:n?"6px 0 0 6px":"0 6px 6px 0"})}}}function Zo(){const t=k("theme")===N.WHITE,n=Xo();return t?n.white:n.dark}const pe=k("size");function Yo({visible:e,onClose:t,title:n,children:r,width:o=pe===d.SMALL?300:400,maxWidth:s=pe===d.SMALL?300:400,showClose:i=!0,maskClosable:a=!0}){const[u,l]=O(!1),f=Zo(),c=_=>{_.target===_.currentTarget?l(!0):l(!1)},x=_=>{_.target===_.currentTarget&&u&&a&&t(),l(!1)};return e?h("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,background:f.mask,display:"flex",alignItems:"center",justifyContent:"center",zIndex:9999},onMouseDown:c,onMouseUp:x,children:h("div",{style:{background:f.modalBg,padding:pe===d.SMALL?24:32,borderRadius:pe===d.SMALL?8:12,minWidth:o,maxWidth:s,color:f.modalColor,boxShadow:f.modalBoxShadow,position:"relative"},onClick:_=>_.stopPropagation(),children:[i&&h("button",{type:"button",onClick:t,style:f.closeBtn,"aria-label":"关闭",children:"×"}),n&&h("div",{style:f.title,children:n}),r]})}):null}function Qo(){const e=k("size");return{white:{tabBtn:(t,n)=>({flex:1,background:t?"#fff":"#F7F8FA",color:t?"#1890ff":"#222",border:"1px solid #F0F1F3",borderRadius:n?"8px 0 0 8px":"0 8px 8px 0",fontWeight:500,fontSize:e===d.SMALL?12:16,height:e===d.SMALL?32:48,boxShadow:t?"0 2px 8px 0 rgba(20,20,20,0.04)":"none",outline:"none",cursor:"pointer"})},dark:{tabBtn:(t,n)=>({flex:1,background:t?"#23262F":"#181A20",color:t?"#00E8C6":"#fff",border:"1px solid #444C5C",borderRadius:n?"8px 0 0 8px":"0 8px 8px 0",fontWeight:500,fontSize:e===d.SMALL?12:16,height:e===d.SMALL?32:48,boxShadow:t?"0 2px 8px 0 rgba(20,20,20,0.10)":"none",outline:"none",cursor:"pointer"})}}}function ei(){const e=k("theme"),t=k("themeConfig"),n=e===N.WHITE,r=Qo(),o=n?r.white:r.dark;if(t){const s=n?t.white:t.dark;if(s?.color)return{...o,tabBtn:(i,a)=>({...o.tabBtn(i,a),color:i?s.color:o.tabBtn(i,a).color})}}return o}const ti=k("size");function ni({visible:e,onClose:t,onSubmit:n}){const[r,o]=O({amount:"",rechargeChannel:"",currency:"USD",loading:!1,error:"",amountError:"",rechargeChannelError:"",currencyError:""}),[s,i]=O({platform:"",transactionId:"",files:[],platformError:"",transactionIdError:"",filesError:"",loading:!1}),[a,u]=O("online"),l=ei();le(()=>{e||(u("online"),o({amount:"",rechargeChannel:"",currency:"USD",loading:!1,error:"",amountError:"",rechargeChannelError:"",currencyError:""}),i({platform:"",transactionId:"",files:[],platformError:"",transactionIdError:"",filesError:"",loading:!1}))},[e]);const f=async c=>{c.preventDefault();let x=!0;if(o(_=>({..._,amountError:"",rechargeChannelError:""})),r.amount.trim()||(o(_=>({..._,amountError:L("请输入充值金额")})),x=!1),r.rechargeChannel||(o(_=>({..._,rechargeChannelError:L("请选择支付平台")})),x=!1),!!x){o(_=>({..._,loading:!0,error:""}));try{await n({amount:r.amount,rechargeChannel:r.rechargeChannel,currency:r.currency}),t()}catch{o(_=>({..._,error:L("提交失败,请重试")}))}finally{o(_=>({..._,loading:!1}))}}};return h(Yo,{visible:e,onClose:t,title:L("充值 / 转账"),children:[h("div",{style:{display:"flex",marginBottom:ti===d.SMALL?16:28},children:[h("button",{type:"button",onClick:()=>u("online"),style:l.tabBtn(a==="online",!0),children:L("在线充值")}),h("button",{type:"button",onClick:()=>u("offline"),style:l.tabBtn(a==="offline",!1),children:L("线下转账")})]}),h("div",{style:{display:a==="online"?"block":"none"},children:h("form",{onSubmit:f,children:h($o,{formState:r,setFormState:o,onClose:t,loading:r.loading})})}),h("div",{style:{display:a==="offline"?"block":"none"},children:h(Ko,{formState:s,setFormState:i,onClose:t,loading:s.loading})})]})}function st(){return(st=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}var ri=["context","children"];function oi(e){this.getChildContext=function(){return e.context};var t=e.children,n=function(r,o){if(r==null)return{};var s,i,a={},u=Object.keys(r);for(i=0;i<u.length;i++)o.indexOf(s=u[i])>=0||(a[s]=r[s]);return a}(e,ri);return Ln(t,n)}function ii(){var e=new CustomEvent("_preact",{detail:{},bubbles:!0,cancelable:!0});this.dispatchEvent(e),this._vdom=Z(oi,st({},this._props,{context:e.detail.context}),function t(n,r){if(n.nodeType===3)return n.data;if(n.nodeType!==1)return null;var o=[],s={},i=0,a=n.attributes,u=n.childNodes;for(i=a.length;i--;)a[i].name!=="slot"&&(s[a[i].name]=a[i].value,s[Cn(a[i].name)]=a[i].value);for(i=u.length;i--;){var l=t(u[i],null),f=u[i].slot;f?s[f]=Z(Pt,{name:f},l):o[i]=l}var c=r?Z(Pt,null,o):o;return Z(r||n.nodeName.toLowerCase(),s,c)}(this,this._vdomComponent)),(this.hasAttribute("hydrate")?Sn:Oe)(this._vdom,this._root)}function Cn(e){return e.replace(/-(\w)/g,function(t,n){return n?n.toUpperCase():""})}function si(e,t,n){if(this._vdom){var r={};r[e]=n=n??void 0,r[Cn(e)]=n,this._vdom=Ln(this._vdom,r),Oe(this._vdom,this._root)}}function ai(){Oe(this._vdom=null,this._root)}function Pt(e,t){var n=this;return Z("slot",st({},e,{ref:function(r){r?(n.ref=r,n._listener||(n._listener=function(o){o.stopPropagation(),o.detail.context=t},r.addEventListener("_preact",n._listener))):n.ref.removeEventListener("_preact",n._listener)}}))}function at(e,t,n,r){function o(){var s=Reflect.construct(HTMLElement,[],o);return s._vdomComponent=e,s._root=r&&r.shadow?s.attachShadow({mode:r.mode||"open"}):s,s}return(o.prototype=Object.create(HTMLElement.prototype)).constructor=o,o.prototype.connectedCallback=ii,o.prototype.attributeChangedCallback=si,o.prototype.disconnectedCallback=ai,n=n||e.observedAttributes||Object.keys(e.propTypes||{}),o.observedAttributes=n,n.forEach(function(s){Object.defineProperty(o.prototype,s,{get:function(){return this._vdom.props[s]},set:function(i){this._vdom?this.attributeChangedCallback(s,null,i):(this._props||(this._props={}),this._props[s]=i,this.connectedCallback());var a=typeof i;i!=null&&a!=="string"&&a!=="boolean"&&a!=="number"||this.setAttribute(s,i)}})}),customElements.define(t||e.tagName||e.displayName||e.name,o)}function li(){const[e,t]=O(!1),n=async r=>{const o=await vo({amount:r.amount,currency:r.currency,rechargeChannel:r.rechargeChannel});window.open(o,"_blank")};return h("div",{children:[h(Tn,{onClick:()=>t(!0),children:L("充值/转账")}),h(ni,{visible:e,onClose:()=>t(!1),onSubmit:n})]})}at(li,"best-recharge",["theme"],{shadow:!1});const Dt={white:{popover:{background:"#fff",color:"#222",boxShadow:"0 4px 16px rgba(0,0,0,0.12)",border:"none"},arrow:{top:"#fff",bottom:"#fff",left:"#fff",right:"#fff"}},dark:{popover:{background:"#23262F",color:"#fff",boxShadow:"0 4px 16px rgba(0,0,0,0.32)",border:"1px solid #444C5C"},arrow:{top:"#23262F",bottom:"#23262F",left:"#23262F",right:"#23262F"}}};function ci(){return k("theme")===N.WHITE?Dt.white:Dt.dark}const ui=({popover:e,children:t,popoverWidth:n,popoverMinWidth:r,offsetY:o,offsetX:s,popoverPosition:i="top"})=>{const a=k("size"),u=n??(a===d.SMALL?200:300),l=r??(a===d.SMALL?150:200),f=o??(a===d.SMALL?8:16),c=s??(a===d.SMALL?8:16),[x,_]=O(!1),[m,b]=O(i),g=Ee(null),y=Ee(null),S=ci(),v=()=>{if(y.current&&(clearTimeout(y.current),y.current=null),i==="top"||i==="bottom")if(g.current){const I=g.current.getBoundingClientRect();i==="top"&&I.top<100?b("bottom"):i==="bottom"&&window.innerHeight-I.bottom<100?b("top"):b(i)}else b(i);else b(i);_(!0)},w=()=>{y.current=window.setTimeout(()=>{_(!1)},120)};let E={position:"absolute",zIndex:999,borderRadius:6,fontSize:a===d.SMALL?12:15,minWidth:l,width:u,padding:a===d.SMALL?"6px 12px":"8px 14px",pointerEvents:"auto",textAlign:"center",animation:"fadeInUp 0.3s",...S.popover},C={position:"absolute",zIndex:11,width:0,height:0};return m==="top"?(E={...E,left:"50%",top:-48,transform:"translateX(-50%)"},C={...C,left:"50%",bottom:-8,transform:"translateX(-50%)",borderLeft:"8px solid transparent",borderRight:"8px solid transparent",borderTop:`8px solid ${S.arrow.top}`}):m==="bottom"?(E={...E,left:"50%",top:"100%",marginTop:f,transform:"translateX(-50%)"},C={...C,left:"50%",top:-8,transform:"translateX(-50%)",borderLeft:"8px solid transparent",borderRight:"8px solid transparent",borderBottom:`8px solid ${S.arrow.bottom}`}):m==="leftTop"?(E={...E,right:"100%",top:0,marginRight:c,transform:"none"},C={...C,right:-8,top:a===d.SMALL?8:12,borderTop:"8px solid transparent",borderBottom:"8px solid transparent",borderLeft:`8px solid ${S.arrow.left}`}):m==="rightTop"&&(E={...E,left:"100%",top:0,marginLeft:c,transform:"translateY(0)"},C={...C,left:-8,top:12,borderTop:"8px solid transparent",borderBottom:"8px solid transparent",borderRight:`8px solid ${S.arrow.right}`}),h("div",{ref:g,style:{position:"relative",display:"inline-block"},onMouseEnter:v,onMouseLeave:w,children:[t,x&&h("div",{style:E,onMouseEnter:v,onMouseLeave:w,children:[e,h("div",{style:C})]})]})};function di(){const e=k("size");return{white:{popoverTitle:{fontSize:e===d.SMALL?12:16,fontWeight:600,color:"#222",marginBottom:e===d.SMALL?12:16,textAlign:"center"},detailRow:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:e===d.SMALL?"6px 0":"8px 0",borderBottom:"1px solid #e5e7eb",fontSize:e===d.SMALL?12:15},detailLabel:{display:"flex",alignItems:"center",color:"#6b7280",fontWeight:500},detailDot:t=>({display:"inline-block",width:e===d.SMALL?6:8,height:e===d.SMALL?6:8,borderRadius:"50%",background:t,marginRight:e===d.SMALL?6:8}),detailValue:t=>({color:t,fontWeight:600,fontSize:e===d.SMALL?12:15}),main:{fontSize:e===d.SMALL?18:24,fontWeight:800,color:"#111827",display:"inline-block"},currency:{fontSize:e===d.SMALL?16:18,color:"#6b7280",marginLeft:e===d.SMALL?6:8,fontWeight:600}},dark:{popoverTitle:{fontSize:e===d.SMALL?14:16,fontWeight:600,color:"#fff",marginBottom:e===d.SMALL?14:16,textAlign:"center"},detailRow:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:e===d.SMALL?"6px 0":"8px 0",borderBottom:"1px solid #374151",fontSize:e===d.SMALL?12:15},detailLabel:{display:"flex",alignItems:"center",color:"#B5B8BE",fontWeight:500},detailDot:t=>({display:"inline-block",width:e===d.SMALL?6:8,height:e===d.SMALL?6:8,borderRadius:"50%",background:t,marginRight:e===d.SMALL?6:8}),detailValue:t=>({color:t,fontWeight:600,fontSize:e===d.SMALL?12:15}),main:{fontSize:e===d.SMALL?18:24,fontWeight:800,color:"#fff",display:"inline-block"},currency:{fontSize:e===d.SMALL?16:18,color:"#B5B8BE",marginLeft:e===d.SMALL?6:8,fontWeight:600}}}}function fi(){const t=k("theme")===N.WHITE,n=di();return t?n.white:n.dark}function It(e){return e.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}function pi(e){const[t,n]=O({currBalance:0,currency:"USD",details:[]}),r=async()=>{try{const i=await vn(),a=[{label:"",value:i.totalAmount,color:"#15b36b",dot:"#15b36b"},{label:"",value:i.frozenAmount,color:"#f59e0b",dot:"#f59e0b"},...i.isCredit?[{label:"",value:i.creditLimit,color:"#1890ff",dot:"#1890ff"},{label:"",value:i.creditUsed,color:"#ff0000",dot:"#ff0000"}]:[],{label:"",value:i.availableAmount,color:"#1890ff",dot:"#15b36b"}],u={currBalance:i.currBalance,currency:"USD",symbol:"$",details:a};n(u)}catch(i){console.error("获取余额失败:",i)}};le(()=>{r()},[]),le(()=>{const i=()=>{console.log("handleRefreshBalance"),r()};return document.addEventListener("refresh-balance",i),()=>{document.removeEventListener("refresh-balance",i)}},[]);const o=fi(),s=[{label:L("真实金额"),value:t.details[0]?.value||0,color:"#15b36b",dot:"#15b36b"},{label:L("冻结金额"),value:t.details[1]?.value||0,color:"#f59e0b",dot:"#f59e0b"},...t.details.length>4?[{label:L("信用额度"),value:t.details[2]?.value||0,color:"#1890ff",dot:"#1890ff"},{label:L("已用额度"),value:t.details[3]?.value||0,color:"#ff0000",dot:"#ff0000"}]:[],{label:L("可用余额"),value:t.details[4]?.value||0,color:"#1890ff",dot:"#15b36b"}];return h(ui,{popover:h(K,{children:[h("div",{style:o.popoverTitle,children:L("余额详情")}),s.map(i=>h("div",{style:o.detailRow,children:[h("span",{style:o.detailLabel,children:[h("span",{style:o.detailDot(i.dot)}),i.label]}),h("span",{style:o.detailValue(i.color),children:It(i.value)})]},i.label))]}),popoverPosition:e.popoverPosition||"bottom",children:h("div",{style:o.main,children:[It(t.currBalance),h("span",{style:o.currency,children:t.currency})]})})}at(pi,"best-statistical-balance");const he={white:{background:"#1890ff",color:"#fff",border:"none",borderRadius:6,cursor:"pointer",fontWeight:600,transition:"all 0.2s ease"},dark:{background:"#00E8C6",color:"#fff",border:"none",borderRadius:6,cursor:"pointer",fontWeight:600,transition:"all 0.2s ease"}};function hi(e){return k("theme")===N.WHITE?{...he.white,background:e||he.white.background}:{...he.dark,background:e||he.dark.background}}function mi(e){switch(e){case"small":return{fontSize:"12px",gap:"2px"};case"large":return{fontSize:"18px",gap:"6px"};default:return{fontSize:"14px",gap:"4px"}}}function _i({color:e,size:t="medium",children:n}){const[r,o]=O(!1),s=hi(e),i=mi(t),a={...s,...i,display:"flex",alignItems:"center"};return h(K,{children:[h("style",{children:`
|
|
60
|
+
`}),h("div",{onClick:()=>!i&&x(w=>!w),style:{minHeight:y===d.SMALL?32:40,borderRadius:6,display:"flex",alignItems:"center",padding:y===d.SMALL?"0 10px":"0 12px",fontSize:y===d.SMALL?12:15,cursor:i?"not-allowed":"pointer",boxSizing:"border-box",transition:"border 0.2s",opacity:i?.6:1,width:"100%",...v(),...o},tabIndex:0,children:[h("span",{style:{flex:1},children:S?S.label:h("span",{style:g.placeholder,children:r||"请选择"})}),h("span",{style:{marginLeft:8,display:"flex",alignItems:"center"},children:h("svg",{width:y===d.SMALL?16:20,height:y===d.SMALL?16:20,viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:h("path",{d:"M6 8L10 12L14 8",stroke:"#bfbfbf","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"})})})]}),c&&!i&&h("div",{className:`custom-select-dropdown${l?" "+l:""}`,style:{position:"absolute",left:0,right:0,top:y===d.SMALL?32:44,zIndex:10,borderRadius:6,boxShadow:g.boxShadow,maxHeight:y===d.SMALL?160:220,overflowY:"auto",...g.dropdown,...a},children:[n.length===0&&h("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:y===d.SMALL?80:120,width:"100%",userSelect:"none"},children:[h("svg",{width:y===d.SMALL?48:64,height:y===d.SMALL?32:41,viewBox:"0 0 64 41",xmlns:"http://www.w3.org/2000/svg",children:[h("title",{children:L("暂无数据")}),h("g",{transform:"translate(0 1)",fill:"none",fillRule:"evenodd",children:[h("ellipse",{fill:"#f5f5f5",cx:"32",cy:"33",rx:"32",ry:"7"}),h("g",{fillRule:"nonzero",stroke:"#d9d9d9",children:[h("path",{d:"M55 12.76L44.854 1.258C44.367.474 43.656 0 42.907 0H21.093c-.749 0-1.46.474-1.947 1.257L9 12.761V22h46v-9.24z"}),h("path",{d:"M41.613 15.931c0-1.605.994-2.93 2.227-2.931H55v18.137C55 33.26 53.68 35 52.05 35h-40.1C10.32 35 9 33.259 9 31.137V13h11.16c1.233 0 2.227 1.323 2.227 2.928v.022c0 1.605 1.005 2.901 2.237 2.901h14.752c1.232 0 2.237-1.308 2.237-2.913v-.007z",fill:"#fafafa"})]})]})]}),h("div",{style:{marginTop:8,color:"#bfbfbf",fontSize:y===d.SMALL?12:15},children:L("暂无数据")})]}),n.map((w,E)=>h("div",{onClick:()=>{w.disabled||(x(!1),t?.(w.value))},onMouseEnter:()=>b(E),onMouseLeave:()=>b(null),style:{padding:y===d.SMALL?"6px 10px":"10px 16px",fontSize:y===d.SMALL?12:15,cursor:w.disabled?"not-allowed":"pointer",fontWeight:e===w.value?600:400,opacity:w.disabled?.6:1,...g.option(e===w.value,!!w.disabled,m===E)},children:w.label},w.value))]}),f]})};function zo(){const e=k("size");return{white:{label:{marginBottom:e===d.SMALL?6:8,fontSize:e===d.SMALL?12:14,color:"#222",textAlign:"left",display:"block"},input:{width:"100%",padding:e===d.SMALL?"8px 10px":"10px 12px",borderRadius:6,boxSizing:"border-box",border:"1px solid #E5E6EB",background:"#fff",color:"#222",fontSize:e===d.SMALL?12:15,outline:"none",marginBottom:0},inputError:{border:"1px solid #ff4d4f"},selectError:{border:"1px solid #ff4d4f"},error:{color:"#ff4d4f",fontSize:e===d.SMALL?12:13,marginTop:e===d.SMALL?2:4,textAlign:"left"},buttonCancel:{background:"#fff",color:"#222",border:"1px solid #E5E6EB",borderRadius:6,padding:e===d.SMALL?"6px 16px":"8px 24px",fontSize:e===d.SMALL?12:15,cursor:"pointer"},buttonSubmit:{background:"#1890ff",color:"#fff",border:"none",borderRadius:6,padding:e===d.SMALL?"6px 16px":"8px 24px",fontSize:e===d.SMALL?12:15,cursor:"pointer",fontWeight:600},feeTip:{marginBottom:24,padding:e===d.SMALL?"8px 10px":"12px 16px",background:"#f6ffed",border:"1px solid #b7eb8f",borderRadius:6,fontSize:e===d.SMALL?12:14,color:"#52c41a"},feeDetailBox:{marginTop:e===d.SMALL?8:10,marginBottom:e===d.SMALL?16:20,padding:e===d.SMALL?"8px 10px":"12px 16px",background:"#fff",border:"1px solid #E5E6EB",borderRadius:6},feeDetailTitle:{fontSize:e===d.SMALL?12:14,color:"#222",fontWeight:600,marginBottom:e===d.SMALL?6:8},feeAmount:{color:"#F53F3F",marginLeft:4},feeDetailDesc:{fontSize:e===d.SMALL?12:13,color:"#6b7280",lineHeight:1.5}},dark:{label:{marginBottom:e===d.SMALL?6:8,fontSize:e===d.SMALL?12:14,color:"#fff",textAlign:"left",display:"block"},input:{width:"100%",padding:e===d.SMALL?"8px 10px":"10px 12px",borderRadius:6,boxSizing:"border-box",border:"1px solid #374151",background:"#23262F",color:"#fff",fontSize:e===d.SMALL?12:15,outline:"none",marginBottom:0},inputError:{border:"1px solid #ff4d4f"},selectError:{border:"1px solid #ff4d4f"},error:{color:"#ff4d4f",fontSize:e===d.SMALL?12:13,marginTop:e===d.SMALL?2:4,textAlign:"left"},buttonCancel:{background:"#23262F",color:"#fff",border:"none",borderRadius:6,padding:e===d.SMALL?"6px 16px":"8px 24px",fontSize:e===d.SMALL?12:15,cursor:"pointer"},buttonSubmit:{background:"#00E8C6",color:"#fff",border:"none",borderRadius:6,padding:e===d.SMALL?"6px 16px":"8px 24px",fontSize:e===d.SMALL?12:15,cursor:"pointer",fontWeight:600},feeTip:{marginBottom:e===d.SMALL?16:24,padding:e===d.SMALL?"8px 10px":"12px 16px",background:"#1a1a1a",border:"1px solid #333",borderRadius:6,fontSize:e===d.SMALL?12:14,color:"#52c41a"},feeDetailBox:{marginTop:e===d.SMALL?8:10,marginBottom:e===d.SMALL?16:20,padding:e===d.SMALL?"8px 10px":"12px 16px",background:"#23262F",border:"1px solid #374151",borderRadius:6},feeDetailTitle:{fontSize:e===d.SMALL?12:14,color:"#fff",fontWeight:600,marginBottom:e===d.SMALL?6:8},feeAmount:{color:"#FF6B6B",marginLeft:4},feeDetailDesc:{fontSize:e===d.SMALL?12:13,color:"#B5B8BE",lineHeight:1.5}}}}function Uo(){const e=k("theme"),t=k("themeConfig"),n=e===N.WHITE,r=zo(),o=n?r.white:r.dark;if(t){const s=n?t.white:t.dark;if(s?.color)return{...o,buttonSubmit:{...o.buttonSubmit,background:s.color}}}return o}function Ho(e){return e=e.replace(/[^\d.]/g,""),e=e.replace(/\.(?=.*\.)/g,""),e=e.replace(/^(\d+)(\.\d{0,2})?.*$/,"$1$2"),e=e.replace(/^0+(\d)/,"$1"),e.startsWith(".")&&(e="0"+e),e}function jo(e){if(!e)return"";const t=parseFloat(e);return isNaN(t)?"":t.toFixed(2)}const $o=({formState:e,setFormState:t,onClose:n,loading:r})=>{const o=JSON.parse(sessionStorage.getItem("all_dicts")||"{}"),s=o?.currency||[],i=o?.channel?.filter(m=>m.payment_support)||[],[a,u]=O(""),[l,f]=O(""),[c,x]=O(!1),_=Uo();return le(()=>{e.currency&&e.amount&&e.rechargeChannel?ko({channel:e.rechargeChannel,amount:e.amount,currency:e.currency}).then(m=>{u(m.paymentAmount),f(m.fee),x(!0)}).catch(m=>{console.error("计算支付金额失败:",m),x(!1)}):x(!1)},[e.currency,e.amount,e.rechargeChannel]),h(K,{children:[h("div",{style:{marginBottom:18},children:[h("div",{style:_.label,children:[h("span",{style:{color:"#F53F3F"},children:"*"})," ",L("充值币种")]}),h(Ze,{value:e.currency,onChange:m=>{t(b=>({...b,currency:m}))},options:s?.map(m=>({value:m.value,label:m.label})),placeholder:L("请选择充值币种")})]}),h("div",{style:{marginBottom:18},children:[h("div",{style:_.label,children:[h("span",{style:{color:"#F53F3F"},children:"*"})," ",L("充值金额")]}),h("input",{type:"text",placeholder:L("请输入充值金额"),value:e.amount,onInput:m=>{let b=m.target.value;b=Ho(b);let g="";if(b&&!b.endsWith(".")){let y=parseFloat(b);if(!isNaN(y)&&(y<1&&(y=1),y>999999.99&&(y=999999.99),b=y.toString(),/\./.test(m.target.value))){const S=m.target.value.split(".")[1];S!==void 0&&S.length>0&&(b=y.toFixed(Math.min(S.length,2)))}}t(y=>({...y,amount:b,amountError:g}))},onBlur:m=>{let b=m.target.value;b=jo(b),t(g=>({...g,amount:b,amountError:""}))},style:{..._.input,...e.amountError?_.inputError:{}}}),e.amountError&&h("div",{style:_.error,children:e.amountError})]}),h("div",{style:{marginBottom:24},children:[h("div",{style:_.label,children:[h("span",{style:{color:"#F53F3F"},children:"*"})," ",L("支付平台")]}),h(Ze,{value:e.rechargeChannel,onChange:m=>{t(b=>({...b,rechargeChannel:m,rechargeChannelError:m?"":b.rechargeChannelError}))},options:i?.map(m=>({value:m.value,label:m.label})),placeholder:L("请选择支付平台")}),e.rechargeChannelError&&h("div",{style:_.error,children:e.rechargeChannelError})]}),c&&a&&h("div",{style:_.feeTip,children:[i.find(m=>m.value===e.rechargeChannel)?.label||e.rechargeChannel,L("需要收取手续费,实际支付金额约为:"),"$",a]}),c&&a&&h("div",{style:_.feeDetailBox,children:[h("div",{style:_.feeDetailTitle,children:[L("手续费约为:"),h("span",{style:_.feeAmount,children:["$",l]})]}),h("div",{style:_.feeDetailDesc,children:L("额外费用说明:您的地区、币种、支付卡类型等因素可能会导致手续费的变动,最终手续费以官方为准。")})]}),e.error&&h("div",{style:{color:"#ff4d4f",marginBottom:12},children:e.error}),h("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:[h("button",{type:"button",onClick:n,style:_.buttonCancel,children:L("取消")}),h("button",{type:"submit",disabled:r,style:_.buttonSubmit,children:L(r?"提交中...":"去支付")})]})]})};function Wo(){const e=k("size");return{white:{container:{border:"1px dashed #E5E6EB",borderRadius:8,background:"#FCFCFD",padding:e===d.SMALL?16:24,textAlign:"center",cursor:"pointer",minHeight:e===d.SMALL?80:120,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:"#999",fontSize:e===d.SMALL?12:15},fileItem:{display:"flex",alignItems:"center",background:"#F7F8FA",borderRadius:8,padding:e===d.SMALL?"8px 10px":"12px 16px",marginBottom:8,fontSize:e===d.SMALL?12:15,color:"#222",justifyContent:"space-between"},removeBtn:{background:"#FF4D4F",color:"#fff",border:"none",borderRadius:6,padding:e===d.SMALL?"6px 10px":"4px 14px",fontSize:e===d.SMALL?12:15,marginLeft:e===d.SMALL?8:16,cursor:"pointer"}},dark:{container:{border:"1.5px dashed #444C5C",borderRadius:8,background:"#181A20",padding:e===d.SMALL?16:24,textAlign:"center",cursor:"pointer",minHeight:e===d.SMALL?80:120,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:"#999",fontSize:e===d.SMALL?12:15},fileItem:{display:"flex",alignItems:"center",background:"#23262F",borderRadius:8,padding:e===d.SMALL?"8px 10px":"12px 16px",marginBottom:8,fontSize:e===d.SMALL?12:15,color:"#fff",justifyContent:"space-between"},removeBtn:{background:"#FF4D4F",color:"#fff",border:"none",borderRadius:6,padding:e===d.SMALL?"6px 10px":"4px 14px",fontSize:e===d.SMALL?12:15,marginLeft:e===d.SMALL?8:16,cursor:"pointer"}}}}function qo(){const t=k("theme")===N.WHITE,n=Wo();return t?n.white:n.dark}const Jo=({value:e=[],onChange:t,maxCount:n=10,accept:r=".jpg,.jpeg,.png,.pdf",multiple:o=!0,disabled:s=!1})=>{const i=k("size"),a=Ee(null),[u,l]=O(!1),[f,c]=O(0),x=qo(),_=async b=>{const g=Array.from(b.target.files).slice(0,n);if(!g.length)return;l(!0);const y=[];for(let S=0;S<g.length;S++){c(0);const v=new FormData;v.append("file",g[S]);try{const w=await Ao(v,E=>c(E));w&&y.push(w)}catch{}}l(!1),c(0),t?.([...e,...y]),a.current&&(a.current.value="")},m=b=>{const g=e.filter((y,S)=>S!==b);t?.(g)};return h("div",{children:[h("div",{style:{...x.container,cursor:s?"not-allowed":x.container.cursor,opacity:s?.6:1},onClick:()=>!s&&a.current?.click(),children:[h("div",{style:{fontSize:i===d.SMALL?32:48,marginBottom:i===d.SMALL?8:12},children:"📁"}),h("div",{style:{color:"#222",fontSize:i===d.SMALL?12:15,marginBottom:i===d.SMALL?4:8},children:L("点击或拖拽文件到此处上传")}),h("div",{style:{color:"#999",fontSize:i===d.SMALL?12:13},children:[L("支持 JPG、PNG、PDF 格式,单个文件不超过 20MB,最多上传")," ",n," ",L("个文件")]}),h("input",{ref:a,type:"file",multiple:o,accept:r,style:{display:"none"},onChange:_,disabled:s}),u&&h("div",{style:{marginTop:i===d.SMALL?8:12,color:"#1677ff"},children:[L("正在上传...")," ",f,"%"]})]}),e&&e.length>0&&h("div",{style:{marginTop:i===d.SMALL?8:12},children:e.map((b,g)=>h("div",{style:x.fileItem,children:[h("div",{style:{display:"flex",alignItems:"center",flex:1},children:h("span",{style:{fontWeight:500,wordBreak:"break-all"},children:b.split("/").pop()})}),h("button",{type:"button",onClick:y=>{y.stopPropagation(),m(g)},style:x.removeBtn,disabled:s,children:L("移除")})]},b))})]})};function Vo(){const e=k("size");return{white:{label:{marginBottom:e===d.SMALL?6:8,fontSize:e===d.SMALL?12:14,color:"#222",textAlign:"left",display:"block"},input:{width:"100%",padding:e===d.SMALL?"8px 10px":"10px 12px",borderRadius:6,boxSizing:"border-box",border:"1px solid #E5E6EB",background:"#fff",color:"#222",fontSize:e===d.SMALL?12:15,outline:"none",marginBottom:0},inputError:{border:"1px solid #ff4d4f"},select:{width:"100%",padding:e===d.SMALL?"8px 10px":"10px 12px",borderRadius:6,border:"1px solid #E5E6EB",background:"#fff",color:"#222",fontSize:e===d.SMALL?12:15,outline:"none"},selectError:{border:"1px solid #ff4d4f"},upload:{border:"1px dashed #E5E6EB",borderRadius:8,background:"#FCFCFD",padding:e===d.SMALL?12:24,textAlign:"center",cursor:"pointer",minHeight:e===d.SMALL?100:120,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:"#999",fontSize:e===d.SMALL?12:15},uploadError:{border:"1px dashed #ff4d4f"},fileItem:{display:"flex",alignItems:"center",background:"#F7F8FA",borderRadius:8,padding:e===d.SMALL?"8px 10px":"12px 16px",marginBottom:e===d.SMALL?6:8,fontSize:e===d.SMALL?12:15,color:"#222",justifyContent:"space-between"},buttonCancel:{background:"#fff",color:"#222",border:"1px solid #E5E6EB",borderRadius:6,padding:e===d.SMALL?"6px 18px":"8px 24px",cursor:"pointer"},buttonSubmit:{background:"#1890ff",color:"#fff",border:"none",borderRadius:6,padding:e===d.SMALL?"6px 18px":"8px 24px",cursor:"pointer",fontWeight:600},removeBtn:{background:"#FF4D4F",color:"#fff",border:"none",borderRadius:6,padding:e===d.SMALL?"6px 18px":"4px 14px",fontSize:e===d.SMALL?12:15,marginLeft:e===d.SMALL?8:16,cursor:"pointer"},error:{color:"#ff4d4f",fontSize:e===d.SMALL?12:13,marginTop:e===d.SMALL?2:4,textAlign:"left"}},dark:{label:{marginBottom:e===d.SMALL?4:8,fontSize:e===d.SMALL?12:14,color:"#fff",textAlign:"left",display:"block"},input:{width:"100%",padding:e===d.SMALL?"8px 10px":"10px 12px",borderRadius:6,boxSizing:"border-box",border:"1px solid #374151",background:"#23262F",color:"#fff",fontSize:e===d.SMALL?12:15,outline:"none",marginBottom:0},inputError:{border:"1px solid #ff4d4f"},select:{width:"100%",padding:e===d.SMALL?"8px 10px":"10px 12px",borderRadius:6,border:"1px solid #374151",background:"#23262F",color:"#fff",fontSize:e===d.SMALL?12:15,outline:"none"},selectError:{border:"1px solid #ff4d4f"},upload:{border:"1px dashed #374151",borderRadius:8,background:"#181A20",padding:e===d.SMALL?12:24,textAlign:"center",cursor:"pointer",minHeight:e===d.SMALL?100:120,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:"#999",fontSize:e===d.SMALL?12:14},uploadError:{border:"1px dashed #ff4d4f"},fileItem:{display:"flex",alignItems:"center",background:"#23262F",borderRadius:8,padding:e===d.SMALL?"8px 10px":"12px 16px",marginBottom:e===d.SMALL?6:8,fontSize:e===d.SMALL?12:15,color:"#fff",justifyContent:"space-between"},buttonCancel:{background:"#23262F",color:"#fff",border:"none",borderRadius:6,padding:e===d.SMALL?"6px 18px":"8px 24px",fontSize:e===d.SMALL?12:15,cursor:"pointer"},buttonSubmit:{background:"#00E8C6",color:"#fff",border:"none",borderRadius:6,padding:e===d.SMALL?"6px 18px":"8px 24px",fontSize:e===d.SMALL?12:14,cursor:"pointer",fontWeight:600},removeBtn:{background:"#FF4D4F",color:"#fff",border:"none",borderRadius:6,padding:e===d.SMALL?"6px 18px":"4px 14px",fontSize:e===d.SMALL?12:15,marginLeft:e===d.SMALL?8:16,cursor:"pointer"},error:{color:"#ff4d4f",fontSize:e===d.SMALL?12:13,marginTop:e===d.SMALL?2:4,textAlign:"left"}}}}function Go(){const e=k("theme"),t=k("themeConfig"),n=e===N.WHITE,r=Vo(),o=n?r.white:r.dark;if(console.log(t,"themeConfig"),t){const s=n?t.white:t.dark;if(s?.color)return{...o,buttonSubmit:{...o.buttonSubmit,background:s.color}}}return o}const Ko=({formState:e,setFormState:t,onClose:n,loading:r})=>{const o=JSON.parse(sessionStorage.getItem("all_dicts")||"{}");console.log(o,"allDicts");const s=o?.channel||[],i=Go();return h("form",{onSubmit:async u=>{u.preventDefault();let l=!0;t(f=>({...f,platformError:"",transactionIdError:"",filesError:""})),e.platform||(t(f=>({...f,platformError:L("请选择支付平台")})),l=!1),e.transactionId.trim()||(t(f=>({...f,transactionIdError:L("请输入转账交易ID")})),l=!1),(!e.files||e.files.length===0)&&(t(f=>({...f,filesError:L("请上传转账凭证")})),l=!1),l&&(await Eo({transferChannel:e.platform,transferNo:e.transactionId,voucherUrls:e.files}),n(),Xe.success(L("提交成功")))},children:[h("div",{style:{marginBottom:18},children:[h("div",{style:i.label,children:[h("span",{style:{color:"#F53F3F"},children:"*"})," ",L("第三方支付平台")]}),h(Ze,{value:e.platform,onChange:u=>{t(l=>({...l,platform:u,platformError:u?"":l.platformError}))},options:[...s?.map(u=>({value:u.value,label:u.label}))],placeholder:L("请选择支付平台")}),e.platformError&&h("div",{style:i.error,children:e.platformError})]}),h("div",{style:{marginBottom:18},children:[h("div",{style:i.label,children:[h("span",{style:{color:"#F53F3F"},children:"*"})," ",L("交易ID")]}),h("input",{type:"text",placeholder:L("请输入转账交易ID"),value:e.transactionId,maxLength:200,onInput:u=>{let l=u.target.value;l.length>200&&(l=l.slice(0,200)),t(f=>({...f,transactionId:l,transactionIdError:l?"":f.transactionIdError}))},style:{...i.input,...e.transactionIdError?i.inputError:{}}}),e.transactionIdError&&h("div",{style:i.error,children:e.transactionIdError})]}),h("div",{style:{marginBottom:24},children:[h("div",{style:i.label,children:[h("span",{style:{color:"#F53F3F"},children:"*"})," ",L("上传文件")]}),h(Jo,{value:e.files,onChange:u=>t(l=>({...l,files:u,filesError:""})),maxCount:10,accept:".jpg,.jpeg,.png,.pdf",multiple:!0}),e.filesError&&h("div",{style:i.error,children:e.filesError})]}),h("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:[h("button",{type:"button",onClick:n,style:i.buttonCancel,children:L("取消")}),h("button",{type:"submit",disabled:r,style:i.buttonSubmit,children:L("确定")})]})]})};function Xo(){const e=k("size");return{white:{mask:"rgba(0, 0, 0, 0.45)",modalBg:"#fff",modalColor:"#222",modalBoxShadow:"0 6px 16px rgba(0, 0, 0, 0.12)",closeBtn:{position:"absolute",top:"16px",right:"16px",background:"none",border:"none",fontSize:e===d.SMALL?16:24,cursor:"pointer",color:"#999",padding:"0",width:e===d.SMALL?16:24,height:e===d.SMALL?16:24,display:"flex",alignItems:"center",justifyContent:"center"},title:{fontSize:e===d.SMALL?16:18,fontWeight:"600",marginBottom:e===d.SMALL?16:24,color:"#222"},tabBtn:(t,n)=>({flex:1,padding:e===d.SMALL?"8px 10px":"12px 16px",background:t?"#1890ff":"transparent",color:t?"#fff":"#666",border:"1px solid #d9d9d9",borderRight:n?"none":"1px solid #d9d9d9",cursor:"pointer",fontSize:e===d.SMALL?12:14,fontWeight:t?"600":"400",borderRadius:n?"6px 0 0 6px":"0 6px 6px 0"})},dark:{mask:"rgba(0, 0, 0, 0.65)",modalBg:"#23262F",modalColor:"#F5F6FA",modalBoxShadow:"0 6px 16px rgba(0,0,0,0.32)",closeBtn:{position:"absolute",top:e===d.SMALL?"12px":"16px",right:e===d.SMALL?"12px":"16px",background:"none",border:"none",fontSize:e===d.SMALL?16:24,cursor:"pointer",color:"#B5B8BE",padding:"0",width:e===d.SMALL?16:24,height:e===d.SMALL?16:24,display:"flex",alignItems:"center",justifyContent:"center"},title:{fontSize:e===d.SMALL?16:18,fontWeight:"600",marginBottom:e===d.SMALL?16:24,color:"#F5F6FA"},tabBtn:(t,n)=>({flex:1,padding:e===d.SMALL?"8px 10px":"12px 16px",background:t?"#00E8C6":"transparent",color:t?"#fff":"#B5B8BE",border:"1px solid #444C5C",borderRight:n?"none":"1px solid #444C5C",cursor:"pointer",fontSize:e===d.SMALL?12:14,fontWeight:t?"600":"400",borderRadius:n?"6px 0 0 6px":"0 6px 6px 0"})}}}function Zo(){const t=k("theme")===N.WHITE,n=Xo();return t?n.white:n.dark}const pe=k("size");function Yo({visible:e,onClose:t,title:n,children:r,width:o=pe===d.SMALL?300:400,maxWidth:s=pe===d.SMALL?300:400,showClose:i=!0,maskClosable:a=!0}){const[u,l]=O(!1),f=Zo(),c=_=>{_.target===_.currentTarget?l(!0):l(!1)},x=_=>{_.target===_.currentTarget&&u&&a&&t(),l(!1)};return e?h("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,background:f.mask,display:"flex",alignItems:"center",justifyContent:"center",zIndex:9999},onMouseDown:c,onMouseUp:x,children:h("div",{style:{background:f.modalBg,padding:pe===d.SMALL?24:32,borderRadius:pe===d.SMALL?8:12,minWidth:o,maxWidth:s,color:f.modalColor,boxShadow:f.modalBoxShadow,position:"relative"},onClick:_=>_.stopPropagation(),children:[i&&h("button",{type:"button",onClick:t,style:f.closeBtn,"aria-label":"关闭",children:"×"}),n&&h("div",{style:f.title,children:n}),r]})}):null}function Qo(){const e=k("size");return{white:{tabBtn:(t,n)=>({flex:1,background:t?"#fff":"#F7F8FA",color:t?"#1890ff":"#222",border:"1px solid #F0F1F3",borderRadius:n?"8px 0 0 8px":"0 8px 8px 0",fontWeight:500,fontSize:e===d.SMALL?12:16,height:e===d.SMALL?32:48,boxShadow:t?"0 2px 8px 0 rgba(20,20,20,0.04)":"none",outline:"none",cursor:"pointer"})},dark:{tabBtn:(t,n)=>({flex:1,background:t?"#23262F":"#181A20",color:t?"#00E8C6":"#fff",border:"1px solid #444C5C",borderRadius:n?"8px 0 0 8px":"0 8px 8px 0",fontWeight:500,fontSize:e===d.SMALL?12:16,height:e===d.SMALL?32:48,boxShadow:t?"0 2px 8px 0 rgba(20,20,20,0.10)":"none",outline:"none",cursor:"pointer"})}}}function ei(){const e=k("theme"),t=k("themeConfig"),n=e===N.WHITE,r=Qo(),o=n?r.white:r.dark;if(t){const s=n?t.white:t.dark;if(s?.color)return{...o,tabBtn:(i,a)=>({...o.tabBtn(i,a),color:i?s.color:o.tabBtn(i,a).color})}}return o}const ti=k("size");function ni({visible:e,onClose:t,onSubmit:n}){const[r,o]=O({amount:"",rechargeChannel:"",currency:"USD",loading:!1,error:"",amountError:"",rechargeChannelError:"",currencyError:""}),[s,i]=O({platform:"",transactionId:"",files:[],platformError:"",transactionIdError:"",filesError:"",loading:!1}),[a,u]=O("online"),l=ei();le(()=>{e||(u("online"),o({amount:"",rechargeChannel:"",currency:"USD",loading:!1,error:"",amountError:"",rechargeChannelError:"",currencyError:""}),i({platform:"",transactionId:"",files:[],platformError:"",transactionIdError:"",filesError:"",loading:!1}))},[e]);const f=async c=>{c.preventDefault();let x=!0;if(o(_=>({..._,amountError:"",rechargeChannelError:""})),r.amount.trim()||(o(_=>({..._,amountError:L("请输入充值金额")})),x=!1),r.rechargeChannel||(o(_=>({..._,rechargeChannelError:L("请选择支付平台")})),x=!1),!!x){o(_=>({..._,loading:!0,error:""}));try{await n({amount:r.amount,rechargeChannel:r.rechargeChannel,currency:r.currency}),t()}catch{o(_=>({..._,error:L("提交失败,请重试")}))}finally{o(_=>({..._,loading:!1}))}}};return h(Yo,{visible:e,onClose:t,title:L("充值 / 转账"),children:[h("div",{style:{display:"flex",marginBottom:ti===d.SMALL?16:28},children:[h("button",{type:"button",onClick:()=>u("online"),style:l.tabBtn(a==="online",!0),children:L("在线充值")}),h("button",{type:"button",onClick:()=>u("offline"),style:l.tabBtn(a==="offline",!1),children:L("线下转账")})]}),h("div",{style:{display:a==="online"?"block":"none"},children:h("form",{onSubmit:f,children:h($o,{formState:r,setFormState:o,onClose:t,loading:r.loading})})}),h("div",{style:{display:a==="offline"?"block":"none"},children:h(Ko,{formState:s,setFormState:i,onClose:t,loading:s.loading})})]})}function st(){return(st=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}var ri=["context","children"];function oi(e){this.getChildContext=function(){return e.context};var t=e.children,n=function(r,o){if(r==null)return{};var s,i,a={},u=Object.keys(r);for(i=0;i<u.length;i++)o.indexOf(s=u[i])>=0||(a[s]=r[s]);return a}(e,ri);return Ln(t,n)}function ii(){var e=new CustomEvent("_preact",{detail:{},bubbles:!0,cancelable:!0});this.dispatchEvent(e),this._vdom=Z(oi,st({},this._props,{context:e.detail.context}),function t(n,r){if(n.nodeType===3)return n.data;if(n.nodeType!==1)return null;var o=[],s={},i=0,a=n.attributes,u=n.childNodes;for(i=a.length;i--;)a[i].name!=="slot"&&(s[a[i].name]=a[i].value,s[Cn(a[i].name)]=a[i].value);for(i=u.length;i--;){var l=t(u[i],null),f=u[i].slot;f?s[f]=Z(Pt,{name:f},l):o[i]=l}var c=r?Z(Pt,null,o):o;return Z(r||n.nodeName.toLowerCase(),s,c)}(this,this._vdomComponent)),(this.hasAttribute("hydrate")?Sn:Oe)(this._vdom,this._root)}function Cn(e){return e.replace(/-(\w)/g,function(t,n){return n?n.toUpperCase():""})}function si(e,t,n){if(this._vdom){var r={};r[e]=n=n??void 0,r[Cn(e)]=n,this._vdom=Ln(this._vdom,r),Oe(this._vdom,this._root)}}function ai(){Oe(this._vdom=null,this._root)}function Pt(e,t){var n=this;return Z("slot",st({},e,{ref:function(r){r?(n.ref=r,n._listener||(n._listener=function(o){o.stopPropagation(),o.detail.context=t},r.addEventListener("_preact",n._listener))):n.ref.removeEventListener("_preact",n._listener)}}))}function at(e,t,n,r){function o(){var s=Reflect.construct(HTMLElement,[],o);return s._vdomComponent=e,s._root=r&&r.shadow?s.attachShadow({mode:r.mode||"open"}):s,s}return(o.prototype=Object.create(HTMLElement.prototype)).constructor=o,o.prototype.connectedCallback=ii,o.prototype.attributeChangedCallback=si,o.prototype.disconnectedCallback=ai,n=n||e.observedAttributes||Object.keys(e.propTypes||{}),o.observedAttributes=n,n.forEach(function(s){Object.defineProperty(o.prototype,s,{get:function(){return this._vdom.props[s]},set:function(i){this._vdom?this.attributeChangedCallback(s,null,i):(this._props||(this._props={}),this._props[s]=i,this.connectedCallback());var a=typeof i;i!=null&&a!=="string"&&a!=="boolean"&&a!=="number"||this.setAttribute(s,i)}})}),customElements.define(t||e.tagName||e.displayName||e.name,o)}function li(){const[e,t]=O(!1),n=async r=>{const o=await vo({amount:r.amount,currency:r.currency,rechargeChannel:r.rechargeChannel});window.open(o,"_blank")};return h("div",{children:[h(Tn,{onClick:()=>t(!0),children:L("充值/转账")}),h(ni,{visible:e,onClose:()=>t(!1),onSubmit:n})]})}at(li,"best-recharge",["theme"],{shadow:!1});const Dt={white:{popover:{background:"#fff",color:"#222",boxShadow:"0 4px 16px rgba(0,0,0,0.12)",border:"none"},arrow:{top:"#fff",bottom:"#fff",left:"#fff",right:"#fff"}},dark:{popover:{background:"#23262F",color:"#fff",boxShadow:"0 4px 16px rgba(0,0,0,0.32)",border:"1px solid #444C5C"},arrow:{top:"#23262F",bottom:"#23262F",left:"#23262F",right:"#23262F"}}};function ci(){return k("theme")===N.WHITE?Dt.white:Dt.dark}const ui=({popover:e,children:t,popoverWidth:n,popoverMinWidth:r,offsetY:o,offsetX:s,popoverPosition:i="top"})=>{const a=k("size"),u=n??(a===d.SMALL?200:300),l=r??(a===d.SMALL?150:200),f=o??(a===d.SMALL?8:16),c=s??(a===d.SMALL?8:16),[x,_]=O(!1),[m,b]=O(i),g=Ee(null),y=Ee(null),S=ci(),v=()=>{if(y.current&&(clearTimeout(y.current),y.current=null),i==="top"||i==="bottom")if(g.current){const I=g.current.getBoundingClientRect();i==="top"&&I.top<100?b("bottom"):i==="bottom"&&window.innerHeight-I.bottom<100?b("top"):b(i)}else b(i);else b(i);_(!0)},w=()=>{y.current=window.setTimeout(()=>{_(!1)},120)};let E={position:"absolute",zIndex:999,borderRadius:6,fontSize:a===d.SMALL?12:15,minWidth:l,width:u,padding:a===d.SMALL?"6px 12px":"8px 14px",pointerEvents:"auto",textAlign:"center",animation:"fadeInUp 0.3s",...S.popover},C={position:"absolute",zIndex:11,width:0,height:0};return m==="top"?(E={...E,left:"50%",top:-48,transform:"translateX(-50%)"},C={...C,left:"50%",bottom:-8,transform:"translateX(-50%)",borderLeft:"8px solid transparent",borderRight:"8px solid transparent",borderTop:`8px solid ${S.arrow.top}`}):m==="bottom"?(E={...E,left:"50%",top:"100%",marginTop:f,transform:"translateX(-50%)"},C={...C,left:"50%",top:-8,transform:"translateX(-50%)",borderLeft:"8px solid transparent",borderRight:"8px solid transparent",borderBottom:`8px solid ${S.arrow.bottom}`}):m==="leftTop"?(E={...E,right:"100%",top:0,marginRight:c,transform:"none"},C={...C,right:-8,top:a===d.SMALL?8:12,borderTop:"8px solid transparent",borderBottom:"8px solid transparent",borderLeft:`8px solid ${S.arrow.left}`}):m==="rightTop"&&(E={...E,left:"100%",top:0,marginLeft:c,transform:"translateY(0)"},C={...C,left:-8,top:12,borderTop:"8px solid transparent",borderBottom:"8px solid transparent",borderRight:`8px solid ${S.arrow.right}`}),h("div",{ref:g,style:{position:"relative",display:"inline-block"},onMouseEnter:v,onMouseLeave:w,children:[t,x&&h("div",{style:E,onMouseEnter:v,onMouseLeave:w,children:[e,h("div",{style:C})]})]})};function di(){const e=k("size");return{white:{popoverTitle:{fontSize:e===d.SMALL?12:16,fontWeight:600,color:"#222",marginBottom:e===d.SMALL?12:16,textAlign:"center"},detailRow:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:e===d.SMALL?"6px 0":"8px 0",borderBottom:"1px solid #e5e7eb",fontSize:e===d.SMALL?12:15},detailLabel:{display:"flex",alignItems:"center",color:"#6b7280",fontWeight:500},detailDot:t=>({display:"inline-block",width:e===d.SMALL?6:8,height:e===d.SMALL?6:8,borderRadius:"50%",background:t,marginRight:e===d.SMALL?6:8}),detailValue:t=>({color:t,fontWeight:600,fontSize:e===d.SMALL?12:15}),main:{fontSize:e===d.SMALL?18:24,fontWeight:800,color:"#111827",display:"inline-block"},currency:{fontSize:e===d.SMALL?16:18,color:"#6b7280",marginLeft:e===d.SMALL?6:8,fontWeight:600}},dark:{popoverTitle:{fontSize:e===d.SMALL?14:16,fontWeight:600,color:"#fff",marginBottom:e===d.SMALL?14:16,textAlign:"center"},detailRow:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:e===d.SMALL?"6px 0":"8px 0",borderBottom:"1px solid #374151",fontSize:e===d.SMALL?12:15},detailLabel:{display:"flex",alignItems:"center",color:"#B5B8BE",fontWeight:500},detailDot:t=>({display:"inline-block",width:e===d.SMALL?6:8,height:e===d.SMALL?6:8,borderRadius:"50%",background:t,marginRight:e===d.SMALL?6:8}),detailValue:t=>({color:t,fontWeight:600,fontSize:e===d.SMALL?12:15}),main:{fontSize:e===d.SMALL?18:24,fontWeight:800,color:"#fff",display:"inline-block"},currency:{fontSize:e===d.SMALL?16:18,color:"#B5B8BE",marginLeft:e===d.SMALL?6:8,fontWeight:600}}}}function fi(){const t=k("theme")===N.WHITE,n=di();return t?n.white:n.dark}function It(e){return e.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}function pi(e){const[t,n]=O({currBalance:0,currency:"USD",details:[]}),r=async()=>{try{const i=await vn(),a=[{label:"",value:i.totalAmount,color:"#15b36b",dot:"#15b36b"},{label:"",value:i.frozenAmount,color:"#f59e0b",dot:"#f59e0b"},...i.isCredit?[{label:"",value:i.creditLimit,color:"#1890ff",dot:"#1890ff"},{label:"",value:i.creditUsed,color:"#ff0000",dot:"#ff0000"}]:[],{label:"",value:i.availableAmount,color:"#1890ff",dot:"#15b36b"}],u={currBalance:i.currBalance,currency:"USD",symbol:"$",details:a};n(u)}catch(i){console.error("获取余额失败:",i)}};le(()=>{r()},[]),le(()=>{const i=()=>{console.log("handleRefreshBalance"),r()};return window.addEventListener("refresh-balance",i),()=>{window.removeEventListener("refresh-balance",i)}},[]);const o=fi(),s=[{label:L("真实金额"),value:t.details[0]?.value||0,color:"#15b36b",dot:"#15b36b"},{label:L("冻结金额"),value:t.details[1]?.value||0,color:"#f59e0b",dot:"#f59e0b"},...t.details.length>4?[{label:L("信用额度"),value:t.details[2]?.value||0,color:"#1890ff",dot:"#1890ff"},{label:L("已用额度"),value:t.details[3]?.value||0,color:"#ff0000",dot:"#ff0000"}]:[],{label:L("可用余额"),value:t.details[4]?.value||0,color:"#1890ff",dot:"#15b36b"}];return h(ui,{popover:h(K,{children:[h("div",{style:o.popoverTitle,children:L("余额详情")}),s.map(i=>h("div",{style:o.detailRow,children:[h("span",{style:o.detailLabel,children:[h("span",{style:o.detailDot(i.dot)}),i.label]}),h("span",{style:o.detailValue(i.color),children:It(i.value)})]},i.label))]}),popoverPosition:e.popoverPosition||"bottom",children:h("div",{style:o.main,children:[It(t.currBalance),h("span",{style:o.currency,children:t.currency})]})})}at(pi,"best-statistical-balance");const he={white:{background:"#1890ff",color:"#fff",border:"none",borderRadius:6,cursor:"pointer",fontWeight:600,transition:"all 0.2s ease"},dark:{background:"#00E8C6",color:"#fff",border:"none",borderRadius:6,cursor:"pointer",fontWeight:600,transition:"all 0.2s ease"}};function hi(e){return k("theme")===N.WHITE?{...he.white,background:e||he.white.background}:{...he.dark,background:e||he.dark.background}}function mi(e){switch(e){case"small":return{fontSize:"12px",gap:"2px"};case"large":return{fontSize:"18px",gap:"6px"};default:return{fontSize:"14px",gap:"4px"}}}function _i({color:e,size:t="medium",children:n}){const[r,o]=O(!1),s=hi(e),i=mi(t),a={...s,...i,display:"flex",alignItems:"center"};return h(K,{children:[h("style",{children:`
|
|
61
61
|
@keyframes spin {
|
|
62
62
|
from {
|
|
63
63
|
transform: rotate(0deg);
|
package/dist/best-unit.js
CHANGED
|
@@ -2392,12 +2392,13 @@ function k(e) {
|
|
|
2392
2392
|
return t[e];
|
|
2393
2393
|
}
|
|
2394
2394
|
function Eo() {
|
|
2395
|
+
console.log("refreshBalance");
|
|
2395
2396
|
const e = new CustomEvent("refresh-balance", {
|
|
2396
2397
|
detail: {},
|
|
2397
2398
|
bubbles: !0,
|
|
2398
2399
|
composed: !0
|
|
2399
2400
|
});
|
|
2400
|
-
|
|
2401
|
+
window.dispatchEvent(e);
|
|
2401
2402
|
}
|
|
2402
2403
|
const Oi = {
|
|
2403
2404
|
"/api": {
|
|
@@ -4454,11 +4455,11 @@ function li(e) {
|
|
|
4454
4455
|
const i = () => {
|
|
4455
4456
|
console.log("handleRefreshBalance"), r();
|
|
4456
4457
|
};
|
|
4457
|
-
return
|
|
4458
|
+
return window.addEventListener(
|
|
4458
4459
|
"refresh-balance",
|
|
4459
4460
|
i
|
|
4460
4461
|
), () => {
|
|
4461
|
-
|
|
4462
|
+
window.removeEventListener(
|
|
4462
4463
|
"refresh-balance",
|
|
4463
4464
|
i
|
|
4464
4465
|
);
|
package/package.json
CHANGED
|
@@ -100,14 +100,14 @@ function StatisticalBalance(props: { popoverPosition?: PopoverPosition }) {
|
|
|
100
100
|
};
|
|
101
101
|
|
|
102
102
|
// 添加事件监听器
|
|
103
|
-
|
|
103
|
+
window.addEventListener(
|
|
104
104
|
"refresh-balance",
|
|
105
105
|
handleRefreshBalance as EventListener
|
|
106
106
|
);
|
|
107
107
|
|
|
108
108
|
// 清理函数
|
|
109
109
|
return () => {
|
|
110
|
-
|
|
110
|
+
window.removeEventListener(
|
|
111
111
|
"refresh-balance",
|
|
112
112
|
handleRefreshBalance as EventListener
|
|
113
113
|
);
|
|
@@ -121,6 +121,7 @@ export function getInitParams<T = InitParams>(key?: string | string[]): T {
|
|
|
121
121
|
* 触发余额刷新事件
|
|
122
122
|
*/
|
|
123
123
|
export function refreshBalance() {
|
|
124
|
+
console.log("refreshBalance");
|
|
124
125
|
const refreshEvent = new CustomEvent("refresh-balance", {
|
|
125
126
|
detail: {},
|
|
126
127
|
bubbles: true,
|
|
@@ -128,5 +129,5 @@ export function refreshBalance() {
|
|
|
128
129
|
});
|
|
129
130
|
|
|
130
131
|
// 从document开始分发事件
|
|
131
|
-
|
|
132
|
+
window.dispatchEvent(refreshEvent);
|
|
132
133
|
}
|