import{$ as e,A as t,B as n,C as r,D as i,E as a,F as o,G as s,H as c,I as l,J as u,K as d,M as f,N as p,O as m,P as h,Q as g,R as _,T as v,U as y,V as b,W as x,X as S,Y as C,Z as w,j as T,k as E,n as D,nf as O,of as k,r as A,rf as ee,t as j,w as M,yl as te,z as ne}from"./messages-CIE1P6Ia.js";import{a as N,f as re}from"./auth-store-BeA1erEm.js";import{t as ie}from"./useNavigate-C5YEhTcX.js";import{i as P,t as F}from"./button-DPKsOYfN.js";import{a as I,i as L,n as R,r as z,t as B}from"./select-enFb_iQj.js";import{t as V}from"./createLucideIcon-BXOf0WMH.js";import{t as ae}from"./arrow-left-D3A52CCl.js";import{t as H}from"./check-DEsrGU9-.js";import{n as oe,t as se}from"./radio-group-mxeTRMb0.js";import{n as ce,t as le}from"./copy-to-clipboard-CvHNuxB8.js";import{t as U}from"./loader-circle-CAWAMWy3.js";import{t as ue}from"./triangle-alert-egU1X4up.js";import{t as de}from"./x-tS4qX1rL.js";import{n as fe}from"./dist-B1rrci-H.js";import{t as pe}from"./_trade_id-Bu8hRvDt.js";import{a as me,c as he,d as ge,f as W,h as G,i as _e,l as ve,m as ye,n as be,o as xe,p as Se,r as Ce,s as we,u as Te}from"./checkout-model-CxAw66kk.js";var Ee=V(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),De=V(`file-x`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m14.5 12.5-5 5`,key:`b62r18`}],[`path`,{d:`m9.5 12.5 5 5`,key:`1rk7el`}]]),Oe=V(`link`,[[`path`,{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`,key:`1cjeqo`}],[`path`,{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`,key:`19qd67`}]]),ke=V(`timer`,[[`line`,{x1:`10`,x2:`14`,y1:`2`,y2:`2`,key:`14vaq8`}],[`line`,{x1:`12`,x2:`15`,y1:`14`,y2:`11`,key:`17fdiu`}],[`circle`,{cx:`12`,cy:`14`,r:`8`,key:`1e1u0o`}]]),Ae=k(le(),1),K=k(ee()),je=Object.defineProperty,q=Object.getOwnPropertySymbols,Me=Object.prototype.hasOwnProperty,Ne=Object.prototype.propertyIsEnumerable,Pe=(e,t,n)=>t in e?je(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Fe=(e,t)=>{for(var n in t||={})Me.call(t,n)&&Pe(e,n,t[n]);if(q)for(var n of q(t))Ne.call(t,n)&&Pe(e,n,t[n]);return e},Ie=(e,t)=>{var n={};for(var r in e)Me.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&q)for(var r of q(e))t.indexOf(r)<0&&Ne.call(e,r)&&(n[r]=e[r]);return n},J;(e=>{let t=class t{constructor(e,n,r,a){if(this.version=e,this.errorCorrectionLevel=n,this.modules=[],this.isFunction=[],et.MAX_VERSION)throw RangeError(`Version value out of range`);if(a<-1||a>7)throw RangeError(`Mask value out of range`);this.size=e*4+17;let o=[];for(let e=0;e7)throw RangeError(`Invalid value`);let u,d;for(u=a;;u++){let n=t.getNumDataCodewords(u,r)*8,i=o.getTotalBits(e,u);if(i<=n){d=i;break}if(u>=s)throw RangeError(`Data too long`)}for(let e of[t.Ecc.MEDIUM,t.Ecc.QUARTILE,t.Ecc.HIGH])l&&d<=t.getNumDataCodewords(u,e)*8&&(r=e);let f=[];for(let t of e){n(t.mode.modeBits,4,f),n(t.numChars,t.mode.numCharCountBits(u),f);for(let e of t.getData())f.push(e)}i(f.length==d);let p=t.getNumDataCodewords(u,r)*8;i(f.length<=p),n(0,Math.min(4,p-f.length),f),n(0,(8-f.length%8)%8,f),i(f.length%8==0);for(let e=236;f.lengthm[t>>>3]|=e<<7-(t&7)),new t(u,r,m,c)}getModule(e,t){return 0<=e&&e>>9)*1335;let a=(t<<10|n)^21522;i(a>>>15==0);for(let e=0;e<=5;e++)this.setFunctionModule(8,e,r(a,e));this.setFunctionModule(8,7,r(a,6)),this.setFunctionModule(8,8,r(a,7)),this.setFunctionModule(7,8,r(a,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,r(a,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,r(a,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,r(a,e));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;let t=this.version<<12|e;i(t>>>18==0);for(let e=0;e<18;e++){let n=r(t,e),i=this.size-11+e%3,a=Math.floor(e/3);this.setFunctionModule(i,a,n),this.setFunctionModule(a,i,n)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){let i=Math.max(Math.abs(r),Math.abs(n)),a=e+r,o=t+n;0<=a&&a{(e!=l-o||n>=c)&&f.push(t[e])});return i(f.length==s),f}drawCodewords(e){if(e.length!=Math.floor(t.getNumRawDataModules(this.version)/8))throw RangeError(`Invalid argument`);let n=0;for(let t=this.size-1;t>=1;t-=2){t==6&&(t=5);for(let i=0;i>>3],7-(n&7)),n++)}}i(n==e.length*8)}applyMask(e){if(e<0||e>7)throw RangeError(`Mask value out of range`);for(let t=0;t5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[n][o],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[o][n],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;ne+ +!!t,n);let r=this.size*this.size,a=Math.ceil(Math.abs(n*20-r*10)/r)-1;return i(0<=a&&a<=9),e+=a*t.PENALTY_N4,i(0<=e&&e<=2568888),e}getAlignmentPatternPositions(){if(this.version==1)return[];{let e=Math.floor(this.version/7)+2,t=this.version==32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,n=[6];for(let r=this.size-7;n.lengtht.MAX_VERSION)throw RangeError(`Version number out of range`);let n=(16*e+128)*e+64;if(e>=2){let t=Math.floor(e/7)+2;n-=(25*t-10)*t-55,e>=7&&(n-=36)}return i(208<=n&&n<=29648),n}static getNumDataCodewords(e,n){return Math.floor(t.getNumRawDataModules(e)/8)-t.ECC_CODEWORDS_PER_BLOCK[n.ordinal][e]*t.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][e]}static reedSolomonComputeDivisor(e){if(e<1||e>255)throw RangeError(`Degree out of range`);let n=[];for(let t=0;t0);for(let i of e){let e=i^r.shift();r.push(0),n.forEach((n,i)=>r[i]^=t.reedSolomonMultiply(n,e))}return r}static reedSolomonMultiply(e,t){if(e>>>8||t>>>8)throw RangeError(`Byte out of range`);let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(t>>>r&1)*e;return i(n>>>8==0),n}finderPenaltyCountPatterns(e){let t=e[1];i(t<=this.size*3);let n=t>0&&e[2]==t&&e[3]==t*3&&e[4]==t&&e[5]==t;return(n&&e[0]>=t*4&&e[6]>=t?1:0)+(n&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,n){return e&&(this.finderPenaltyAddHistory(t,n),t=0),t+=this.size,this.finderPenaltyAddHistory(t,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(e,t){t[0]==0&&(e+=this.size),t.pop(),t.unshift(e)}};t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],t.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=t;function n(e,t,n){if(t<0||t>31||e>>>t)throw RangeError(`Value out of range`);for(let r=t-1;r>=0;r--)n.push(e>>>r&1)}function r(e,t){return(e>>>t&1)!=0}function i(e){if(!e)throw Error(`Assertion error`)}let a=class e{constructor(e,t,n){if(this.mode=e,this.numChars=t,this.bitData=n,t<0)throw RangeError(`Invalid argument`);this.bitData=n.slice()}static makeBytes(t){let r=[];for(let e of t)n(e,8,r);return new e(e.Mode.BYTE,t.length,r)}static makeNumeric(t){if(!e.isNumeric(t))throw RangeError(`String contains non-numeric characters`);let r=[];for(let e=0;e=1<{(e=>{let t=class{constructor(e,t){this.ordinal=e,this.formatBits=t}};t.LOW=new t(0,1),t.MEDIUM=new t(1,0),t.QUARTILE=new t(2,3),t.HIGH=new t(3,2),e.Ecc=t})(e.QrCode||={})})(J||={}),(e=>{(e=>{let t=class{constructor(e,t){this.modeBits=e,this.numBitsCharCount=t}numCharCountBits(e){return this.numBitsCharCount[Math.floor((e+7)/17)]}};t.NUMERIC=new t(1,[10,12,14]),t.ALPHANUMERIC=new t(2,[9,11,13]),t.BYTE=new t(4,[8,16,16]),t.KANJI=new t(8,[8,10,12]),t.ECI=new t(7,[0,0,0]),e.Mode=t})(e.QrSegment||={})})(J||={});var Y=J,Le={L:Y.QrCode.Ecc.LOW,M:Y.QrCode.Ecc.MEDIUM,Q:Y.QrCode.Ecc.QUARTILE,H:Y.QrCode.Ecc.HIGH},Re=128,ze=`L`,Be=`#FFFFFF`,Ve=`#000000`,He=!1,Ue=1,We=4,Ge=0,Ke=.1;function qe(e,t=0){let n=[];return e.forEach(function(e,r){let i=null;e.forEach(function(a,o){if(!a&&i!==null){n.push(`M${i+t} ${r+t}h${o-i}v1H${i+t}z`),i=null;return}if(o===e.length-1){if(!a)return;i===null?n.push(`M${o+t},${r+t} h1v1H${o+t}z`):n.push(`M${i+t},${r+t} h${o+1-i}v1H${i+t}z`);return}a&&i===null&&(i=o)})}),n.join(``)}function Je(e,t){return e.slice().map((e,n)=>n=t.y+t.h?e:e.map((e,n)=>n=t.x+t.w?e:!1))}function Ye(e,t,n,r){if(r==null)return null;let i=e.length+n*2,a=Math.floor(t*Ke),o=i/t,s=(r.width||a)*o,c=(r.height||a)*o,l=r.x==null?e.length/2-s/2:r.x*o,u=r.y==null?e.length/2-c/2:r.y*o,d=r.opacity==null?1:r.opacity,f=null;if(r.excavate){let e=Math.floor(l),t=Math.floor(u);f={x:e,y:t,w:Math.ceil(s+l-e),h:Math.ceil(c+u-t)}}let p=r.crossOrigin;return{x:l,y:u,h:c,w:s,excavation:f,opacity:d,crossOrigin:p}}function Xe(e,t){return t==null?e?We:Ge:Math.max(Math.floor(t),0)}function Ze({value:e,level:t,minVersion:n,includeMargin:r,marginSize:i,imageSettings:a,size:o,boostLevel:s}){let c=K.useMemo(()=>{let r=(Array.isArray(e)?e:[e]).reduce((e,t)=>(e.push(...Y.QrSegment.makeSegments(t)),e),[]);return Y.QrCode.encodeSegments(r,Le[t],n,void 0,void 0,s)},[e,t,n,s]),{cells:l,margin:u,numCells:d,calculatedImageSettings:f}=K.useMemo(()=>{let e=c.getModules(),t=Xe(r,i);return{cells:e,margin:t,numCells:e.length+t*2,calculatedImageSettings:Ye(e,o,t,a)}},[c,o,a,r,i]);return{qrcode:c,margin:u,cells:l,numCells:d,calculatedImageSettings:f}}var Qe=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),$e=K.forwardRef(function(e,t){let n=e,{value:r,size:i=Re,level:a=ze,bgColor:o=Be,fgColor:s=Ve,includeMargin:c=He,minVersion:l=Ue,boostLevel:u,marginSize:d,imageSettings:f}=n,p=Ie(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`marginSize`,`imageSettings`]),{style:m}=p,h=Ie(p,[`style`]),g=f?.src,_=K.useRef(null),v=K.useRef(null),y=K.useCallback(e=>{_.current=e,typeof t==`function`?t(e):t&&(t.current=e)},[t]),[b,x]=K.useState(!1),{margin:S,cells:C,numCells:w,calculatedImageSettings:T}=Ze({value:r,level:a,minVersion:l,boostLevel:u,includeMargin:c,marginSize:d,imageSettings:f,size:i});K.useEffect(()=>{if(_.current!=null){let e=_.current,t=e.getContext(`2d`);if(!t)return;let n=C,r=v.current,a=T!=null&&r!==null&&r.complete&&r.naturalHeight!==0&&r.naturalWidth!==0;a&&T.excavation!=null&&(n=Je(C,T.excavation));let c=window.devicePixelRatio||1;e.height=e.width=i*c;let l=i/w*c;t.scale(l,l),t.fillStyle=o,t.fillRect(0,0,w,w),t.fillStyle=s,Qe?t.fill(new Path2D(qe(n,S))):C.forEach(function(e,n){e.forEach(function(e,r){e&&t.fillRect(r+S,n+S,1,1)})}),T&&(t.globalAlpha=T.opacity),a&&t.drawImage(r,T.x+S,T.y+S,T.w,T.h)}}),K.useEffect(()=>{x(!1)},[g]);let E=Fe({height:i,width:i},m),D=null;return g!=null&&(D=K.createElement(`img`,{src:g,key:g,style:{display:`none`},onLoad:()=>{x(!0)},ref:v,crossOrigin:T?.crossOrigin})),K.createElement(K.Fragment,null,K.createElement(`canvas`,Fe({style:E,height:i,width:i,ref:y,role:`img`},h)),D)});$e.displayName=`QRCodeCanvas`;var et=K.forwardRef(function(e,t){let n=e,{value:r,size:i=Re,level:a=ze,bgColor:o=Be,fgColor:s=Ve,includeMargin:c=He,minVersion:l=Ue,boostLevel:u,title:d,marginSize:f,imageSettings:p}=n,m=Ie(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`title`,`marginSize`,`imageSettings`]),{margin:h,cells:g,numCells:_,calculatedImageSettings:v}=Ze({value:r,level:a,minVersion:l,boostLevel:u,includeMargin:c,marginSize:f,imageSettings:p,size:i}),y=g,b=null;p!=null&&v!=null&&(v.excavation!=null&&(y=Je(g,v.excavation)),b=K.createElement(`image`,{href:p.src,height:v.h,width:v.w,x:v.x+h,y:v.y+h,preserveAspectRatio:`none`,opacity:v.opacity,crossOrigin:v.crossOrigin}));let x=qe(y,h);return K.createElement(`svg`,Fe({height:i,width:i,viewBox:`0 0 ${_} ${_}`,ref:t,role:`img`},m),!!d&&K.createElement(`title`,null,d),K.createElement(`path`,{fill:o,d:`M0,0 h${_}v${_}H0z`,shapeRendering:`crispEdges`}),K.createElement(`path`,{fill:s,d:x,shapeRendering:`crispEdges`}),b)});et.displayName=`QRCodeSVG`;var X=O(),tt=1400,nt=`https://cdn.jsdmirror.com/gh/atomiclabs/cryptocurrency-icons@1a63530/128/color/`,rt={OkPay:{aliases:[`okpay`],bg:`hsla(148,71%,36%,0.16)`,color:`hsla(148,71%,42%,1)`,icon:`okpay.jpg`,label:`OkPay`},Ethereum:{aliases:[`evm`,`eth`,`ethereum`],bg:`hsla(0,0%,55%,0.16)`,color:`hsla(0,0%,68%,1)`,icon:`ethereum`,label:`Ethereum`},Solana:{aliases:[`sol`,`solana`],bg:`hsla(256,85%,65%,0.16)`,color:`hsla(256,85%,72%,1)`,icon:`solana`,label:`Solana`},BSC:{aliases:[`bsc`,`bnb`],bg:`hsla(46,91%,49%,0.16)`,color:`hsla(46,91%,55%,1)`,icon:`bsc`,label:`BSC`},Arbitrum:{aliases:[`arbitrum`,`arb`],bg:`hsla(202,100%,54%,0.16)`,color:`hsla(202,100%,64%,1)`,icon:`arbitrum`,label:`Arbitrum`},TRON:{aliases:[`tron`,`trx`],bg:`hsla(350,100%,47%,0.14)`,color:`hsla(350,100%,62%,1)`,icon:`tron`,label:`TRON`},Polygon:{aliases:[`polygon`,`matic`,`pol`],bg:`hsla(263,73%,56%,0.16)`,color:`hsla(263,73%,68%,1)`,icon:`polygon`,label:`Polygon`},Base:{aliases:[`base`],bg:`hsla(240,100%,61%,0.16)`,color:`hsla(240,100%,72%,1)`,icon:`base`,label:`Base`},OP:{aliases:[`op`,`optimism`],bg:`hsla(353,99%,51%,0.16)`,color:`hsla(353,99%,64%,1)`,icon:`op`,label:`OP`},HyperEVM:{aliases:[`hyperevm`,`hyperliquid`,`hype`],bg:`hsla(166,94%,79%,0.15)`,color:`hsla(166,94%,72%,1)`,icon:`hyperevm`,label:`HyperEVM`},Plasma:{aliases:[`plasma`,`xpl`],bg:`hsla(166,64%,32%,0.16)`,color:`hsla(166,64%,55%,1)`,icon:`plasma`,label:`Plasma`},Bitcoin:{aliases:[`bitcoin`,`btc`],bg:`hsla(33,93%,54%,0.16)`,color:`hsla(33,93%,60%,1)`,icon:`bitcoin`,label:`Bitcoin`},Binance:{aliases:[`binance`,`bnb_chain`],bg:`hsla(46,91%,49%,0.16)`,color:`hsla(46,91%,55%,1)`,icon:`binance`,label:`Binance`}};function it(e){let t=String(e??``).trim().toLowerCase();return Object.values(rt).find(e=>e.label.toLowerCase()===t||e.aliases.includes(t))??null}function at(e){let t=it(e);return t?.icon?t.icon.includes(`.`)?`/images/${t.icon}`:`/images/chains/${t.icon}.png`:null}function ot(e){return it(e)?.label??e??`--`}function st(e){let t=Math.floor(e/3600),n=Math.floor(e%3600/60),r=e%60,i=e=>String(e).padStart(2,`0`);return t>0?`${i(t)}:${i(n)}:${i(r)}`:`${i(n)}:${i(r)}`}function ct({network:e}){let t=at(e);return(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[t?(0,X.jsx)(`img`,{alt:``,className:`size-4 rounded-full`,height:16,src:t,width:16}):null,(0,X.jsx)(`span`,{className:`truncate`,children:ot(e)})]})}function lt({token:e}){return(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,X.jsx)(`img`,{alt:``,className:P(`size-4 rounded-full`),height:16,src:`${nt}${e.toLowerCase()}.png`,width:16}),(0,X.jsx)(`span`,{className:`truncate`,children:e})]})}function ut({className:e,onClick:t}){let[n,r]=(0,K.useState)(!1),i=(0,K.useRef)(void 0);return(0,K.useEffect)(()=>()=>{i.current!==void 0&&window.clearTimeout(i.current)},[]),(0,X.jsx)(F,{className:P(`mb-0.5 shrink-0`,e),onClick:()=>{if(i.current!==void 0&&window.clearTimeout(i.current),t()===!1){r(!1);return}r(!0),i.current=window.setTimeout(()=>{r(!1),i.current=void 0},tt)},size:`icon-sm`,type:`button`,variant:`secondary`,children:n?(0,X.jsx)(H,{className:`text-emerald-600 dark:text-emerald-400`}):(0,X.jsx)(ce,{})})}function dt({className:e,disabled:t,onClick:n}){return(0,X.jsxs)(F,{className:`min-h-18 w-full justify-start rounded-2xl border border-border bg-card/40 px-4 py-3 text-left hover:bg-accent/45 dark:bg-white/[0.03] dark:hover:bg-white/[0.06] ${e??``}`,disabled:t,onClick:n,type:`button`,variant:`ghost`,children:[(0,X.jsx)(`img`,{alt:``,className:`size-10 shrink-0 rounded-lg`,height:40,src:`/images/okpay.jpg`,width:40}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`span`,{className:`block truncate font-semibold text-base text-foreground`,children:A()}),(0,X.jsx)(`span`,{className:`mt-1 block truncate font-normal text-muted-foreground text-xs`,children:D()})]}),t?(0,X.jsx)(U,{className:`size-5 shrink-0 animate-spin text-muted-foreground`}):null]})}var ft=2*Math.PI*20;function pt({onCopyAddress:e,onOkpayConfirm:t,onTransferred:n,order:i,paymentMethod:a,remaining:o,showOkpay:s,submitting:c,timeColor:l,timerRatio:u,verifying:d}){let f=i?.receive_address??``,p=i?.payment_url;return a===`okpay`||String(i?.network??``)===`okpay`||p&&!f?(0,X.jsxs)(`section`,{className:`w-full pb-4`,children:[(0,X.jsxs)(`div`,{className:`mb-4 w-full rounded-2xl border bg-card px-5 py-5 text-card-foreground shadow-md`,children:[(0,X.jsx)(`p`,{className:`mb-2 font-semibold text-sm`,children:j()}),p?(0,X.jsx)(`p`,{className:`break-all text-muted-foreground text-sm`,children:p}):null]}),p?(0,X.jsxs)(F,{className:`h-12 w-full rounded-xl text-base`,onClick:()=>{window.open(p,`okpay_checkout`,`popup,width=480,height=720`)},type:`button`,children:[(0,X.jsx)(Ee,{}),A()]}):null]}):(0,X.jsxs)(`section`,{className:`w-full pb-4`,children:[(0,X.jsxs)(`div`,{className:`mb-4 w-full overflow-hidden rounded-2xl border bg-card px-5 pt-5 pb-0 text-card-foreground shadow-md`,children:[(0,X.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,X.jsx)(`p`,{className:`font-semibold text-sm`,children:h()}),(0,X.jsxs)(`div`,{className:`relative size-10 shrink-0`,children:[(0,X.jsxs)(`svg`,{"aria-hidden":`true`,className:`absolute inset-0 size-10`,viewBox:`0 0 48 48`,children:[(0,X.jsx)(`circle`,{className:`text-border`,cx:`24`,cy:`24`,fill:`none`,r:`20`,stroke:`currentColor`,strokeWidth:`3`}),(0,X.jsx)(`circle`,{cx:`24`,cy:`24`,fill:`none`,r:`20`,stroke:l,strokeDasharray:ft,strokeDashoffset:ft*(1-u),strokeLinecap:`round`,strokeWidth:`3`,style:{transform:`rotate(-90deg)`,transformOrigin:`50% 50%`}})]}),(0,X.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,X.jsx)(ke,{className:`size-4 text-muted-foreground`})})]})]}),(0,X.jsx)(`p`,{className:`mb-4 text-center font-bold font-mono text-3xl leading-none`,style:{color:l},children:st(o)}),(0,X.jsx)(`div`,{className:`mb-4 flex justify-center`,children:(0,X.jsx)(`div`,{className:`rounded-xl border bg-white p-3.5 shadow-md`,children:f?(0,X.jsx)(et,{bgColor:`#ffffff`,fgColor:`#111111`,level:`M`,size:120,value:f}):(0,X.jsx)(`div`,{className:`flex size-30 items-center justify-center text-muted-foreground text-xs`,children:`--`})})}),(0,X.jsxs)(`div`,{className:`-mx-5 flex w-[calc(100%+2.5rem)] items-start gap-3 border-border/50 border-t px-5 py-3.5`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`p`,{className:`mb-0.5 font-semibold text-muted-foreground text-xs uppercase tracking-wider`,children:_()}),(0,X.jsx)(`p`,{className:`break-all font-medium text-card-foreground text-sm leading-relaxed`,children:i?.receive_address??`--`})]}),(0,X.jsx)(ut,{className:`mt-0.5`,onClick:e})]})]}),(0,X.jsxs)(F,{className:`mb-3 h-12 w-full rounded-xl text-base`,disabled:d,onClick:n,type:`button`,children:[d?(0,X.jsx)(U,{className:`animate-spin`}):(0,X.jsx)(H,{}),d?r():M()]}),s?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`mb-3 flex items-center gap-3`,children:[(0,X.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,X.jsx)(`span`,{className:`font-medium text-muted-foreground text-xs uppercase`,children:`or`}),(0,X.jsx)(`div`,{className:`h-px flex-1 bg-border`})]}),(0,X.jsx)(dt,{className:`mb-3`,disabled:c,onClick:t})]}):null,(0,X.jsxs)(`div`,{className:`flex items-center justify-center gap-1.5 py-1 text-muted-foreground`,children:[(0,X.jsx)(U,{className:`size-3.5 animate-spin`}),(0,X.jsx)(`span`,{className:`text-xs`,children:w()})]})]})}function mt({onSelectChain:e,onSelectOkpay:n,showChain:r,showOkpay:i}){return(0,X.jsxs)(`section`,{className:`w-full pb-4`,children:[(0,X.jsx)(`p`,{className:`mb-3 font-semibold text-base`,children:T()}),(0,X.jsxs)(`div`,{className:`space-y-3`,children:[r?(0,X.jsxs)(F,{className:`min-h-18 w-full justify-start rounded-2xl border border-border bg-card/40 px-4 py-3 text-left hover:bg-accent/45 dark:bg-white/[0.03] dark:hover:bg-white/[0.06]`,onClick:e,type:`button`,variant:`ghost`,children:[(0,X.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center rounded-lg bg-foreground/10 text-foreground`,children:(0,X.jsx)(Oe,{className:`size-5`})}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`span`,{className:`block truncate font-semibold text-base text-foreground`,children:t()}),(0,X.jsx)(`span`,{className:`mt-1 block truncate font-normal text-muted-foreground text-xs`,children:E()})]})]}):null,i?(0,X.jsx)(dt,{onClick:n}):null]})]})}function ht({onBack:e,networkOptions:t,onConfirm:n,onNetworkChange:r,onTokenChange:i,paymentMethod:a,selectedNetwork:o,selectedOption:s,selectedToken:c,showBack:l=!0,submitting:d,tokenOptions:m}){let h=a!==`okpay`,_=a===`okpay`,v=h?f():p();return(0,X.jsxs)(`section`,{className:`w-full pb-4`,children:[(0,X.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[l?(0,X.jsx)(F,{"aria-label":g(),className:`size-8 rounded-full`,onClick:e,size:`icon-sm`,type:`button`,variant:`ghost`,children:(0,X.jsx)(ae,{})}):null,(0,X.jsx)(`p`,{className:`font-semibold text-base`,children:v})]}),(0,X.jsxs)(`div`,{className:`mb-4 flex gap-2`,children:[h?(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`p`,{className:`mb-1.5 font-semibold text-muted-foreground text-xs uppercase tracking-wider`,children:y()}),(0,X.jsxs)(B,{disabled:t.length===0,onValueChange:r,value:o,children:[(0,X.jsx)(L,{className:`h-12.5 w-full rounded-xl bg-card`,children:(0,X.jsx)(I,{placeholder:(0,X.jsx)(ct,{network:o})})}),(0,X.jsx)(R,{position:`popper`,children:t.map(e=>(0,X.jsx)(z,{value:e,children:(0,X.jsx)(ct,{network:e})},e))})]})]}):null,(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`p`,{className:`mb-1.5 font-semibold text-muted-foreground text-xs uppercase tracking-wider`,children:u()}),_?(0,X.jsx)(se,{className:`grid grid-cols-2 gap-2`,onValueChange:i,value:c,children:m.map(e=>(0,X.jsxs)(`label`,{className:`flex h-12.5 cursor-pointer items-center gap-3 rounded-xl border bg-card px-3 transition-colors hover:bg-accent/50 has-[[data-state=checked]]:border-primary has-[[data-state=checked]]:bg-primary/5`,htmlFor:`okpay-token-${e.toLowerCase()}`,children:[(0,X.jsx)(oe,{id:`okpay-token-${e.toLowerCase()}`,value:e}),(0,X.jsx)(lt,{token:e})]},e))}):(0,X.jsxs)(B,{disabled:m.length===0,onValueChange:i,value:c,children:[(0,X.jsx)(L,{className:`h-12.5 w-full rounded-xl bg-card`,children:(0,X.jsx)(I,{placeholder:(0,X.jsx)(lt,{token:c})})}),(0,X.jsx)(R,{position:`popper`,children:m.map(e=>(0,X.jsx)(z,{value:e,children:(0,X.jsx)(lt,{token:e})},e))})]})]})]}),(0,X.jsx)(F,{className:`h-12 w-full rounded-xl text-base`,disabled:d||!s,onClick:n,type:`button`,children:S()})]})}function Z({children:e,description:t,icon:n,title:r}){return(0,X.jsxs)(`section`,{"aria-live":`polite`,className:`flex min-h-96 w-full flex-col items-center justify-center rounded-2xl border bg-card px-6 py-10 text-center text-card-foreground shadow-md`,role:`status`,children:[(0,X.jsx)(`div`,{className:`mb-6 flex size-20 items-center justify-center rounded-full bg-muted`,children:n}),(0,X.jsx)(`p`,{className:`mb-2 font-bold text-xl`,children:r}),(0,X.jsx)(`p`,{className:`mb-6 text-muted-foreground text-sm`,children:t}),e]})}function gt(){return(0,X.jsx)(Z,{description:w(),icon:(0,X.jsx)(U,{className:`size-8 animate-spin text-muted-foreground`}),title:x()})}function _t({redirecting:e}){return(0,X.jsx)(Z,{description:e?l():i(),icon:(0,X.jsx)(H,{className:`size-10 text-green-500`}),title:m(),children:e?(0,X.jsx)(U,{className:`size-6 animate-spin text-muted-foreground`}):null})}function vt({onBack:e}){return(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsx)(Z,{description:s(),icon:(0,X.jsx)(de,{className:`size-10 text-destructive`}),title:d()}),(0,X.jsx)(F,{className:`h-12 w-full rounded-xl`,onClick:e,type:`button`,variant:`outline`,children:g()})]})}function yt({onBack:e,onRetry:t}){return(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsx)(Z,{description:v(),icon:(0,X.jsx)(ue,{className:`size-10 text-orange-500`}),title:a()}),(0,X.jsxs)(`div`,{className:`flex gap-3`,children:[(0,X.jsx)(F,{className:`h-12 flex-1 rounded-xl`,onClick:e,type:`button`,variant:`outline`,children:g()}),(0,X.jsx)(F,{className:`h-12 flex-1 rounded-xl`,onClick:t,type:`button`,children:o()})]})]})}function bt({onBack:e}){return(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsx)(Z,{description:b(),icon:(0,X.jsx)(De,{className:`size-10 text-muted-foreground`}),title:c()}),(0,X.jsx)(F,{className:`h-12 w-full rounded-xl`,onClick:e,type:`button`,variant:`outline`,children:g()})]})}function xt({networkOptions:e,onBack:t,onConfirmSelection:n,onCopyAddress:r,onNetworkChange:i,onOkpayConfirm:a,onRetry:o,onReturnToMethods:s,onSelectChainPayment:c,onSelectOkpayPayment:l,onTokenChange:u,onTransferred:d,order:f,panel:p,remaining:m,selectedPaymentMethod:h,selectedNetwork:g,selectedOption:_,selectedToken:v,showChainPayment:y,showOkpay:b,showReturnToMethods:x,submitting:S,timeColor:C,timerRatio:w,tokenOptions:T,verifying:E}){switch(p){case`loading`:return(0,X.jsx)(gt,{});case`method`:return(0,X.jsx)(mt,{onSelectChain:c,onSelectOkpay:l,showChain:y,showOkpay:b});case`select`:return(0,X.jsx)(ht,{networkOptions:e,onBack:s,onConfirm:n,onNetworkChange:i,onTokenChange:u,paymentMethod:h,selectedNetwork:g,selectedOption:_,selectedToken:v,showBack:x,submitting:S,tokenOptions:T});case`payment`:return(0,X.jsx)(pt,{onCopyAddress:r,onOkpayConfirm:a,onTransferred:d,order:f,paymentMethod:h,remaining:m,showOkpay:!1,submitting:S,timeColor:C,timerRatio:w,verifying:E});case`success`:return(0,X.jsx)(_t,{redirecting:!!f?.redirect_url});case`expired`:return(0,X.jsx)(vt,{onBack:t});case`timeout`:return(0,X.jsx)(yt,{onBack:t,onRetry:o});case`not-found`:return(0,X.jsx)(bt,{onBack:t});default:return null}}function St({activeNetwork:t,amountMode:r,onCopyAmount:i,order:a,tradeId:o}){let s=at(t),c=it(t),l=r===`payment`?wt(a):Ct(a),u=r===`payment`?e():n(),d=r===`payment`&&!!t,f=r===`payment`;return(0,X.jsxs)(`section`,{className:`mb-4 w-full rounded-2xl border bg-card px-6 pt-6 pb-5 text-card-foreground shadow-md`,children:[(0,X.jsx)(`p`,{className:`mb-1 font-medium text-muted-foreground text-sm`,children:u}),(0,X.jsxs)(`div`,{className:`flex items-end justify-between gap-3`,children:[(0,X.jsx)(`span`,{className:`wrap-break-word min-w-0 font-bold font-nunito text-4xl leading-none`,children:l}),(0,X.jsx)(ut,{onClick:i})]}),d?(0,X.jsxs)(`div`,{className:`mt-2 flex items-center gap-1.5`,children:[s?(0,X.jsx)(`img`,{alt:``,className:`size-4 rounded-full`,height:16,src:s,width:16}):null,(0,X.jsx)(`span`,{className:`rounded-full px-2 py-0.5 font-semibold text-xs`,style:{background:c?.bg,color:c?.color},children:ot(t)})]}):null,(0,X.jsx)(`div`,{className:`mt-3 border-border/50 border-t pt-3`,children:(0,X.jsx)(`table`,{className:`w-full border-separate border-spacing-y-1 text-muted-foreground text-sm`,children:(0,X.jsxs)(`tbody`,{children:[f?(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`td`,{className:`w-px whitespace-nowrap pr-3`,children:n()}),(0,X.jsx)(`td`,{className:`break-all font-medium text-card-foreground`,children:Ct(a)})]}):null,(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`td`,{className:`w-px whitespace-nowrap pr-3`,children:ne()}),(0,X.jsx)(`td`,{className:`break-all font-medium text-card-foreground`,children:a?.trade_id??o})]})]})})})]})}function Ct(e){return e?.amount==null?`--`:`${e.amount} ${e.currency??``}`.trim()}function wt(e){let t=e?.actual_amount??e?.amount,n=e?.actual_amount==null?e?.currency:e?.token;return t==null?`--`:`${t} ${n??``}`.trim()}function Tt(e){return e===`payment`||e===`success`||e===`expired`?3:e===`select`?2:+(e===`method`)}function Et({panel:e}){let t=Tt(e);return(0,X.jsx)(`div`,{className:`mb-4 flex w-full items-center gap-2`,children:[1,2,3].map(e=>(0,X.jsx)(`div`,{className:`h-1 flex-1 overflow-hidden rounded-full bg-foreground/10`,children:(0,X.jsx)(`div`,{className:P(`h-full rounded-full bg-foreground transition-all`,t>=e?`w-full`:`w-0`)})},e))})}var Q=new Set,$,Dt=Date.now();function Ot(e){return Dt=Date.now(),Q.add(e),$===void 0&&($=window.setInterval(()=>{Dt=Date.now();for(let e of Q)e()},1e3)),()=>{Q.delete(e),Q.size===0&&$!==void 0&&(window.clearInterval($),$=void 0)}}function kt(){return Dt}function At(e){return(0,K.useSyncExternalStore)(e?Ot:()=>()=>void 0,kt,kt)}function jt({tradeId:e}){let t=ie(),n=N.useQuery(`get`,`/pay/checkout-counter-resp/{trade_id}`,{params:{path:{trade_id:e}}},{retry:!1}),r=(0,K.useMemo)(()=>{let e=G(n.data);return e?Te(e):void 0},[n.data]),i=N.useMutation(`post`,`/pay/switch-network`),[a,o]=(0,K.useState)(),[s,c]=(0,K.useState)(),[l,u]=(0,K.useState)(),[d,f]=(0,K.useState)(null),p=s??r,m=!!(p?.payment_url||ve(p?.is_selected)&&p?.receive_address),h=!!(p?.trade_id&&!m),g=N.useQuery(`get`,`/payments/gmpay/v1/config`,void 0,{enabled:!!p?.trade_id,retry:!1}),_=(0,K.useMemo)(()=>G(g.data),[g.data]),v=(0,K.useMemo)(()=>h?ye(_).filter(e=>!W(e.network,`okpay`)):[],[h,_]),y=(0,K.useMemo)(()=>v.filter(e=>W(e.network,`tron`)&&[`trx`,`usdt`].includes(String(e.token).toLowerCase())),[v]),b=v.length>0,x=!!(_?.okpay?.enabled&&y.length),S=Number(b)+Number(x),w;S===1&&(w=b?`chain`:`okpay`);let T=l??w,E=(0,K.useMemo)(()=>T===`okpay`?y:T===`chain`?v:[],[T,y,v]),D=(0,K.useMemo)(()=>we(E,p,{network:_?.epay?.default_network,token:_?.epay?.default_token}),[E,p,_]),O=d??D,k=O?.network??p?.network??``,A=O?.token??p?.token??``,ee=(0,K.useMemo)(()=>{if(T===`okpay`&&_?.okpay?.enabled&&W(k,`tron`)&&[`trx`,`usdt`].includes(String(A).toLowerCase()))return{network:`okpay`,token:A.toUpperCase()}},[T,_,k,A]),j=(0,K.useMemo)(()=>ge(p?.expiration_time),[p?.expiration_time]),M=(0,K.useMemo)(()=>ge(p?.created_at),[p?.created_at]),ne=M&&j&&M{if(a)return a;if(n.isPending)return`loading`;if(I){let e=he(I);return Ce.includes(e??0)?`not-found`:`timeout`}if(!p?.trade_id)return`not-found`;if(F<=0&&j)return`expired`;if(!h)return`payment`;if(g.isPending)return`loading`;if(L){let e=he(L);return Ce.includes(e??0)?`not-found`:`timeout`}return T?`select`:`method`},[T,j,h,p,I,n.isPending,F,L,g.isPending,a]),z=N.useQuery(`get`,`/pay/check-status/{trade_id}`,{params:{path:{trade_id:p?.trade_id??``}}},{enabled:R===`payment`&&!!p?.trade_id,refetchInterval:({state:e})=>R===`payment`&&e.fetchFailureCount<5?_e:!1,retry:!1}),B=G(z.data)?.status,V=(0,K.useMemo)(()=>R===`payment`?B===2?`success`:B===3?`expired`:z.failureCount>=5?`timeout`:R:R,[R,B,z.failureCount]);re({queryKey:[`checkout-redirect`,p?.trade_id,p?.redirect_url],queryFn:async({signal:e})=>(await xe(me,e),window.location.href=p?.redirect_url,!0),enabled:V===`success`&&!!p?.redirect_url,retry:!1});let ae=(0,K.useMemo)(()=>Array.from(new Set(E.map(e=>e.network))).filter(Boolean),[E]),H=(0,K.useMemo)(()=>Array.from(new Set(E.filter(e=>W(e.network,k)).map(e=>e.token))),[E,k]),oe=ne>0?Math.max(0,Math.min(1,F/ne)):0,se=Se(oe),ce=V===`method`||V===`select`||!m?`order`:`payment`,le=e=>e==null||e===``?!1:(0,Ae.default)(String(e))?(fe.success(C()),!0):(fe.error(te()),!1),U=(e,t)=>{if(t&&!t.closed){t.location.href=e,t.focus();return}window.open(e,`okpay_checkout`,`popup,width=480,height=720`)},ue=async(e,n)=>{if(!p?.trade_id)return;let r=W(e.network,`okpay`);try{let a=G(await i.mutateAsync({body:{trade_id:p.trade_id,network:e.network.toLowerCase(),token:e.token.toLowerCase()}}));if(!a)throw Error(be);let s=Te(a);if(c({...p,...s,is_selected:s.is_selected??!0,network:s.network??e.network,token:s.token??e.token}),r&&s.payment_url){U(s.payment_url,n);return}n?.close(),s.trade_id&&s.trade_id!==p.trade_id&&t({params:{trade_id:s.trade_id},replace:!0,to:`/cashier/$trade_id`}).catch(()=>void 0),o(void 0)}catch(e){n?.close();let t=he(e);Ce.includes(t??0)?o(`not-found`):t===10010?o(`expired`):fe.error(e instanceof Error?e.message:be)}},de=async()=>{if(T===`okpay`){await pe();return}O&&await ue(O)},pe=async()=>{ee&&await ue(ee,window.open(`about:blank`,`okpay_checkout`,`popup,width=480,height=720`))};return(0,X.jsxs)(`main`,{className:`flex flex-1 flex-col justify-center`,children:[V===`not-found`?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Et,{panel:V}),(0,X.jsx)(St,{activeNetwork:p?.network??k,amountMode:ce,onCopyAmount:()=>le(ce===`payment`?p?.actual_amount??p?.amount:p?.amount),order:p,tradeId:e})]}),(0,X.jsx)(xt,{networkOptions:ae,onBack:()=>{if(p?.redirect_url){window.location.href=p.redirect_url;return}if(document.referrer){window.location.href=document.referrer;return}history.back()},onConfirmSelection:de,onCopyAddress:()=>le(p?.receive_address),onNetworkChange:e=>{f(E.find(t=>W(t.network,e))??null)},onOkpayConfirm:pe,onRetry:()=>{if(o(void 0),p?.trade_id&&p.receive_address){z.refetch();return}n.refetch(),(h||g.isError)&&g.refetch()},onReturnToMethods:()=>{u(void 0),f(null)},onSelectChainPayment:()=>{u(`chain`),f(null)},onSelectOkpayPayment:()=>{u(`okpay`),f(y[0]??null)},onTokenChange:e=>{f(E.find(t=>W(t.network,k)&&W(t.token,e))??null)},onTransferred:()=>{p?.trade_id&&z.refetch()},order:p,panel:V,remaining:F,selectedNetwork:k,selectedOption:O??void 0,selectedPaymentMethod:T,selectedToken:A,showChainPayment:b,showOkpay:x,showReturnToMethods:S>1,submitting:i.isPending,timeColor:se,timerRatio:oe,tokenOptions:H,verifying:z.isFetching})]})}function Mt(){let{trade_id:e}=pe.useParams();return(0,X.jsx)(jt,{tradeId:e},e)}export{Mt as component};