@orderly.network/affiliate 2.8.1 → 2.8.2

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/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var ui$1 = require('@orderly.network/ui');
3
+ var ui = require('@orderly.network/ui');
4
4
  var i18n = require('@orderly.network/i18n');
5
5
  var jsxRuntime = require('react/jsx-runtime');
6
6
  var react = require('react');
@@ -13,13 +13,4076 @@ var chart = require('@orderly.network/chart');
13
13
  var uiConnector = require('@orderly.network/ui-connector');
14
14
  var uiScaffold = require('@orderly.network/ui-scaffold');
15
15
 
16
- var xi=Object.defineProperty;var pi=(e,t)=>{for(var r in t)xi(e,r,{get:t[r],enumerable:true});};var ni={};pi(ni,{AffiliatePage:()=>Me,DashboardPage:()=>ai,HomePage:()=>Re,TraderPage:()=>Ie});var mt=e=>{let{size:t=16,className:r,...n}=e;return jsxRuntime.jsxs("svg",{width:t,height:t,viewBox:"0 0 16 16",fill:"#fff",fillOpacity:".98",xmlns:"http://www.w3.org/2000/svg",className:e.className,...n,children:[jsxRuntime.jsx("path",{d:"M8 1.302c-3.683 0-6.655 2.985-6.667 6.667-.013 3.676 2.987 6.68 6.666 6.687s6.674-3.037 6.667-6.687c-.007-3.682-2.985-6.667-6.667-6.667m0 1.333a5.333 5.333 0 0 1 5.333 5.334c0 1.5-.625 2.852-1.622 3.821-.49-1.062-1.545-1.821-2.753-1.821H7.04c-1.207 0-2.259.75-2.75 1.812A5.3 5.3 0 0 1 2.666 7.97a5.333 5.333 0 0 1 5.333-5.334M8 3.97a2.667 2.667 0 1 0 0 5.333A2.667 2.667 0 0 0 8 3.97"}),jsxRuntime.jsx("path",{d:"M16 12.667a3.333 3.333 0 1 1-6.667 0 3.333 3.333 0 0 1 6.667 0",fill:"#1828C3"}),jsxRuntime.jsx("path",{d:"M11.917 11.433a.917.917 0 0 0-.917.917c0 .53.302 1.031.802 1.49a4.6 4.6 0 0 0 .713.53l.068.043c.05.027.117.027.167 0l.068-.042q.08-.05.177-.115c.182-.123.366-.26.536-.416.5-.459.802-.96.802-1.49a.917.917 0 0 0-.917-.917.97.97 0 0 0-.744.386.95.95 0 0 0-.756-.386"})]})};var dt=e=>{let{size:t=16,className:r,...n}=e;return jsxRuntime.jsxs("svg",{width:t,height:t,viewBox:"0 0 16 16",fill:"white",fillOpacity:"0.36",xmlns:"http://www.w3.org/2000/svg",className:e.className,...n,children:[jsxRuntime.jsx("path",{d:"M7.99929 1.30212C4.31735 1.30212 1.34509 4.28679 1.33262 7.96878C1.32015 11.6454 4.32042 14.6488 7.99929 14.6561C11.6782 14.6634 14.6726 11.6194 14.666 7.96878C14.6593 4.28679 11.6812 1.30212 7.99929 1.30212ZM7.99929 2.63546C10.9448 2.63546 13.3326 5.02345 13.3326 7.96878C13.3326 9.46878 12.7078 10.8208 11.7112 11.7901C11.2202 10.7281 10.1656 9.96878 8.95762 9.96878C8.71802 9.96878 7.28042 9.96878 7.04095 9.96878C5.83369 9.96878 4.78215 10.7188 4.29095 11.7814C3.29429 10.8121 2.66595 9.46878 2.66595 7.96878C2.66595 5.02345 5.05375 2.63546 7.99929 2.63546ZM7.99929 3.96879C6.52649 3.96879 5.33255 5.16279 5.33262 6.63545C5.33262 8.10812 6.52649 9.30212 7.99929 9.30212C9.47202 9.30212 10.666 8.10812 10.666 6.63545C10.666 5.16279 9.47202 3.96879 7.99929 3.96879Z"}),jsxRuntime.jsx("path",{d:"M16 12.6667C16 14.5076 14.5076 16 12.6666 16C10.8257 16 9.33331 14.5076 9.33331 12.6667C9.33331 10.8257 10.8257 9.33333 12.6666 9.33333C14.5076 9.33333 16 10.8257 16 12.6667Z",fill:"#005A4F"}),jsxRuntime.jsx("path",{d:"M14.3325 13.3345C14.3325 13.2918 14.3182 13.2473 14.2857 13.2147L13.6658 12.6002L13.4315 12.8345L13.7595 13.1678H11.3325C11.2405 13.1678 11.1658 13.2425 11.1658 13.3345C11.1658 13.4265 11.2405 13.5012 11.3325 13.5012H13.7595L13.4315 13.8345L13.6658 14.0688L14.2857 13.4543C14.3182 13.4217 14.3325 13.3772 14.3325 13.3345ZM14.1658 12.0012C14.1658 11.9092 14.0912 11.8345 13.9992 11.8345H11.572L11.9002 11.5012L11.6658 11.2668L11.046 11.8813C10.981 11.9465 10.981 12.0558 11.046 12.121L11.6658 12.7355L11.9002 12.5012L11.572 12.1678H13.9992C14.0912 12.1678 14.1658 12.0932 14.1658 12.0012Z",fill:"white",fillOpacity:"0.98"})]})};var xe=(r=>(r.affiliate="affiliate",r.trader="trader",r))(xe||{}),xt=react.createContext({}),y=()=>react.useContext(xt);var Rs=e=>{let{becomeAnAffiliateUrl:t="https://orderly.network/",learnAffiliateUrl:r="https://orderly.network/",referralLinkUrl:n="https://orderly.network/",chartConfig:o,overwrite:i,children:a,splashPage:f,onBecomeAnAffiliate:s,bindReferralCodeState:p,onLearnAffiliate:m,showReferralPage:u}=e,{state:l}=hooks.useAccount(),{data:x,mutate:g,isLoading:d}=hooks.usePrivateQuery("/v1/referral/info",{revalidateOnFocus:true,errorRetryCount:3,...hooks.noCacheConfig}),{data:c,mutate:T}=hooks.usePrivateQuery("/v1/referral/auto_referral/progress",{revalidateOnFocus:true,errorRetryCount:2,formatter:O=>({code:O.auto_referral_code,requireVolume:O.required_volume,completedVolume:O.completed_volume})}),[H,ne]=react.useState(d);react.useEffect(()=>{ne(true);},[d]);let{data:z,mutate:M}=hooks.useDaily({startDate:dateFns.subDays(new Date,1),endDate:dateFns.subDays(new Date,90)}),{data:D,mutate:k}=hooks.usePrivateQuery("/v1/volume/user/stats",{revalidateOnFocus:true}),le=react.useMemo(()=>(x?.referrer_info?.referral_codes?.length||0)>0,[x?.referrer_info]),de=react.useMemo(()=>(x?.referee_info?.referer_code?.length||0)>0,[x?.referee_info]),X=react.useMemo(()=>{let O={};if(z&&z.length>0){let Be=dateFns.format(new Date,"yyyy-MM-dd"),Mr=z.findIndex(di=>di.date===Be),Lr=0;Mr!==-1&&(Lr=z[Mr].perp_volume),O["1d_volume"]=Lr;}return D&&(O["7d_volume"]=D.perp_volume_last_7_days,O["30d_volume"]=D.perp_volume_last_30_days,O.all_volume=D.perp_volume_ltd),O},[z,D]);react.useEffect(()=>{(le||de)&&ne(false);},[le,de]);let W=hooks.useMemoizedFn(()=>{k(),M(),g(),T();});react.useEffect(()=>{let Be=new URLSearchParams(window.location.search).get("ref");Be&&localStorage.setItem("referral_code",Be);},[]);let[Ar,mi]=react.useState("affiliate"),{wrongNetwork:Dr,disabledConnect:Fr}=reactApp.useAppContext(),_r=react.useRef(types.AccountStatusEnum.NotConnected),ft=react.useRef(null);react.useEffect(()=>(_r.current!==l.status&&(_r.current=l.status,ft.current=setTimeout(()=>{W();},1e3)),()=>{ft.current&&clearTimeout(ft.current);}),[W,l.status]);let ci=react.useMemo(()=>({generateCode:c,showHome:H,referralInfo:x,isAffiliate:le,isTrader:de,tab:Ar,becomeAnAffiliateUrl:t,learnAffiliateUrl:r,referralLinkUrl:n,userVolume:X,dailyVolume:z,chartConfig:o,overwrite:i,isLoading:d,wrongNetwork:Dr,disabledConnect:Fr,setShowHome:ne,setTab:mi,mutate:W,onBecomeAnAffiliate:s,bindReferralCodeState:p,onLearnAffiliate:m,showReferralPage:u,splashPage:f}),[t,o,z,x,Fr,c,le,d,de,r,i,n,H,Ar,X,Dr,s,p,m,u,f,W]);return jsxRuntime.jsx(xt.Provider,{value:ci,children:a})};var K=e=>jsxRuntime.jsxs("svg",{width:"21",height:"20",viewBox:"0 0 21 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e.className,children:[jsxRuntime.jsxs("g",{clipPath:"url(#a)",children:[jsxRuntime.jsx("path",{d:"M10.5 20c5.542 0 10-4.458 10-10s-4.458-10-10-10S.5 4.458.5 10s4.458 10 10 10",fill:"#2775CA"}),jsxRuntime.jsx("path",{d:"M13.5 11.473c0-1.452-.94-1.95-2.82-2.158-1.344-.166-1.613-.498-1.613-1.078s.448-.955 1.343-.955c.806 0 1.254.25 1.478.872.045.124.18.207.313.207h.717c.179 0 .313-.125.313-.29v-.042c-.179-.913-.985-1.618-2.015-1.701v-.996c0-.166-.134-.29-.358-.332h-.671c-.18 0-.314.124-.359.332v.954c-1.343.166-2.194.996-2.194 2.034 0 1.369.896 1.908 2.776 2.116 1.254.207 1.657.456 1.657 1.12s-.627 1.12-1.477 1.12c-1.165 0-1.568-.456-1.702-1.078a.32.32 0 0 0-.313-.25h-.762c-.179 0-.313.125-.313.291v.042c.179 1.037.895 1.784 2.373 1.991v.996c0 .166.134.29.358.332h.672c.18 0 .313-.124.358-.332v-.996c1.344-.207 2.239-1.079 2.239-2.199",fill:"#fff",fillOpacity:".98"}),jsxRuntime.jsx("path",{d:"M8.24 16.57c-3.458-1.215-5.23-4.986-3.945-8.324.665-1.821 2.127-3.208 3.944-3.859.178-.086.266-.216.266-.433v-.607c0-.174-.088-.304-.266-.347-.044 0-.133 0-.177.043-4.21 1.3-6.516 5.68-5.186 9.798.798 2.428 2.704 4.292 5.186 5.072.177.087.355 0 .4-.173.043-.043.043-.087.043-.173v-.608c0-.13-.133-.303-.266-.39m4.698-13.527c-.178-.086-.355 0-.4.174-.043.043-.043.086-.043.173v.607c0 .174.133.347.266.434 3.457 1.213 5.23 4.985 3.944 8.323-.664 1.821-2.127 3.209-3.944 3.859-.178.086-.266.216-.266.433v.607c0 .174.088.304.266.347.044 0 .133 0 .177-.043 4.21-1.3 6.515-5.68 5.186-9.798-.798-2.471-2.748-4.335-5.186-5.116",fill:"#fff",fillOpacity:".98"})]}),jsxRuntime.jsx("defs",{children:jsxRuntime.jsx("clipPath",{id:"a",children:jsxRuntime.jsx("path",{fill:"#fff",d:"M.5 0h20v20H.5z"})})})]});var bt=e=>{let{t}=i18n.useTranslation();return jsxRuntime.jsxs(ui$1.Flex,{id:"oui-affiliate-affiliate-summary",r:"2xl",p:6,width:"100%",height:"100%",gap:4,direction:"column",className:"oui-bg-base-9",children:[jsxRuntime.jsx(Fi,{...e}),jsxRuntime.jsx(_i,{...e}),jsxRuntime.jsxs(ui$1.Flex,{direction:"column",width:"100%",gap:2,children:[jsxRuntime.jsx(gt,{title:`${t("affiliate.referralVol")} (USDC)`,value:e.referralVol,dp:2,...e}),jsxRuntime.jsx(gt,{title:t("affiliate.referees"),value:e.referees,dp:0,...e}),jsxRuntime.jsx(gt,{title:t("affiliate.summary.refereesTraded"),value:e.refereesTades,dp:0,...e})]})]})},Fi=e=>{let{t}=i18n.useTranslation();return jsxRuntime.jsxs(ui$1.Flex,{direction:"row",justify:"between",width:"100%",children:[jsxRuntime.jsx(ui$1.Text,{className:"oui-text-lg",children:t("affiliate.summary")}),jsxRuntime.jsx("div",{className:"oui-min-w-14",children:jsxRuntime.jsx(ui$1.Select.options,{size:"xs",value:e.period,onValueChange:e.onPeriodChange,options:e.periodTypes})})]})},_i=e=>{let{t}=i18n.useTranslation();return jsxRuntime.jsxs(ui$1.Flex,{gradient:"primary",angle:180,r:"xl",py:4,px:6,width:"100%",direction:"column",gap:3,height:"100%",className:"oui-max-h-[104px]",children:[jsxRuntime.jsx(ui$1.Text,{intensity:54,className:"oui-text-base 2xl:oui-text-lg",children:`${t("affiliate.commission")} (USDC)`}),jsxRuntime.jsxs(ui$1.Flex,{direction:"row",gap:3,className:"oui-text-xl md:oui-text-2xl xl:oui-text-3xl",children:[jsxRuntime.jsx(K,{className:"md:oui-w-[24px] md:oui-h-[24px] lg:oui-w-[28px] lg:oui-h-[28px] "}),jsxRuntime.jsx(ui$1.Text,{children:utils.commifyOptional(e.commission,{fix:2,fallback:"0"})})]})]})},gt=e=>jsxRuntime.jsxs(ui$1.Flex,{direction:"row",justify:"between",width:"100%",children:[jsxRuntime.jsx(ui$1.Text,{intensity:54,className:"oui-text-2xs md:oui-text-xs xl:oui-text-sm",children:e.title}),jsxRuntime.jsx(ui$1.Text,{className:"oui-text-xs md:oui-text-sm xl:oui-text-base",children:utils.commifyOptional(e.value,{fix:e.dp,fallback:"0"})})]});var Ct=()=>{let{t:e}=i18n.useTranslation(),[t,r]=react.useState("All"),n=[{label:e("common.all"),value:"All"},{label:e("common.select.1d"),value:"1D"},{label:e("common.select.7d"),value:"7D"},{label:e("common.select.30d"),value:"30D"}],{referralInfo:o}=y(),i=react.useMemo(()=>{if(!o||!o.referrer_info)return 0;switch(t){case "All":return o.referrer_info.total_referrer_rebate;case "1D":return o.referrer_info["1d_referrer_rebate"];case "7D":return o.referrer_info["7d_referrer_rebate"];case "30D":return o.referrer_info["30d_referrer_rebate"]}},[o,t]),a=react.useMemo(()=>{if(!o||!o.referrer_info)return 0;switch(t){case "All":return o.referrer_info.total_referee_volume;case "1D":return o.referrer_info["1d_referee_volume"];case "7D":return o.referrer_info["7d_referee_volume"];case "30D":return o.referrer_info["30d_referee_volume"]}},[o,t]),f=react.useMemo(()=>{if(!o||!o.referrer_info)return 0;switch(t){case "All":return o.referrer_info.total_invites;case "1D":return o.referrer_info["1d_invites"];case "7D":return o.referrer_info["7d_invites"];case "30D":return o.referrer_info["30d_invites"]}},[o,t]),s=react.useMemo(()=>{if(!o||!o.referrer_info)return 0;switch(t){case "All":return o.referrer_info.total_traded;case "1D":return o.referrer_info["1d_traded"];case "7D":return o.referrer_info["7d_traded"];case "30D":return o.referrer_info["30d_traded"]}},[o,t]);return {period:t,periodTypes:n,onPeriodChange:m=>{r(m);},commission:i,referralVol:a,referees:f,refereesTades:s}};var Oe=()=>{let e=Ct();return jsxRuntime.jsx(bt,{...e})};var Wr=e=>{let{text:t,visibleCount:r}=e,n=react.useRef(null),o=react.useRef(null),i=react.useRef(void 0);function a(m,u){let x=document.createElement("canvas").getContext("2d"),g=m;if(x&&g){let d=getComputedStyle(g).font;return d.length===0&&(d=[getComputedStyle(g).fontWeight,getComputedStyle(g).fontSize,getComputedStyle(g).fontFamily].join(" ")),x.font=d,x.letterSpacing=getComputedStyle(g).letterSpacing,x.measureText(u).width}}let[f,s]=react.useState(0);react.useEffect(()=>{let m=()=>{if(e.visibleCount===void 0&&n.current&&o.current){let u=n.current.clientWidth;if(u==i.current)return;i.current=u;let l=o.current,x=t,g=Math.ceil(a(l,"...")||0),d=u-g,c=0;for(;c<t.length&&!((a(l,Vi(t,c++))||d)<=d););s(x.length-c);}};return i.current=void 0,m(),window.addEventListener("resize",m),()=>{i.current=void 0,window.removeEventListener("resize",m);}},[t,o]);let p=react.useMemo(()=>{if(f+1>=t.length)return t;let m=r||f,u=t.slice(0,Math.ceil(m/2)),l=t.slice(t.length-Math.floor(m/2),t.length);return `${u}...${l}`},[t,r,f]);return jsxRuntime.jsxs("div",{ref:n,className:ui$1.cn("oui-relative oui-w-full oui-text-end",e.className),children:[jsxRuntime.jsx("div",{className:ui$1.cn("oui-hidden oui-whitespace-nowrap oui-absolute oui-top-0 oui-bottom-0 oui-right-0 oui-left-0"),children:jsxRuntime.jsx("span",{ref:o,children:t})}),jsxRuntime.jsx("span",{children:p})]})},Vi=(e,t)=>{let r=Math.floor(e.length/2-(t>0?t/2:1)),n=e.slice(0,r),o=e.slice(r+t);return n+o};var Rt=e=>{let{t}=i18n.useTranslation();return jsxRuntime.jsxs(ui$1.Flex,{id:"oui-affiliate-affiliate-referralLink",r:"2xl",p:6,width:"100%",gap:4,direction:"column",className:"oui-bg-base-9",children:[jsxRuntime.jsx($i,{...e}),jsxRuntime.jsxs(ui$1.Flex,{width:"100%",className:"oui-flex oui-flex-col 3xl:oui-flex-row",gap:4,children:[jsxRuntime.jsx("div",{className:"oui-w-full 3xl:oui-w-1/3",children:jsxRuntime.jsx(qi,{...e})}),jsxRuntime.jsxs(ui$1.Flex,{direction:"column",width:"100%",className:"3xl:oui-w-2/3 3xl:oui-gap-2",children:[jsxRuntime.jsx(Or,{title:t("affiliate.referralCode"),value:e.refCode,...e}),jsxRuntime.jsx(Or,{title:t("affiliate.referralLink"),value:e.refLink,...e})]})]})]})},$i=e=>{let{t}=i18n.useTranslation();return jsxRuntime.jsx(ui$1.Flex,{direction:"row",justify:"between",width:"100%",children:jsxRuntime.jsx(ui$1.Text,{className:"oui-text-lg",children:t("affiliate.referralLink")})})},qi=e=>{let{t}=i18n.useTranslation(),r=(n,o,i,a,f)=>{let s="oui-text-lg md:oui-text-xl lg:oui-text-2xl xl:oui-text-3xl";return jsxRuntime.jsxs(ui$1.Flex,{direction:"column",itemAlign:"start",className:a,children:[jsxRuntime.jsx(ui$1.Flex,{direction:"row",gap:2,children:jsxRuntime.jsx(Gi,{title:n,tooltip:f})}),i?jsxRuntime.jsx(ui$1.Text.gradient,{color:"brand",className:s,children:o}):jsxRuntime.jsx(ui$1.Text,{className:s,children:o})]})};return jsxRuntime.jsxs(ui$1.Flex,{direction:"row",width:"100%",children:[r(t("affiliate.referralLink.earn"),e.earn||"-",true,"oui-flex-1",jsxRuntime.jsxs("span",{children:[jsxRuntime.jsx(ui$1.Text.gradient,{color:"brand",children:e.earn||"-"})," ",t("affiliate.referralLink.earn.tooltip",{brokerName:e.brokerName})]})),r(t("affiliate.referralLink.share"),e.share||"-",false,"oui-flex-1",jsxRuntime.jsx(i18n.Trans,{i18nKey:"affiliate.referralLink.share.tooltip",values:{value:e.share||"-",brokerName:e.brokerName},components:[jsxRuntime.jsx(ui$1.Text.gradient,{color:"brand"})]}))]})},Or=e=>{let{title:t,value:r="-"}=e;return jsxRuntime.jsxs(ui$1.Flex,{r:"xl",p:3,gap:4,direction:"row",width:"100%",className:"oui-bg-base-8",children:[jsxRuntime.jsx(ui$1.Text,{className:"oui-text-base-contrast-54 oui-flex-shrink oui-text-2xs md:oui-text-xs xl:oui-text-sm",children:t}),jsxRuntime.jsxs(ui$1.Flex,{direction:"row",justify:"end",gap:2,className:"oui-flex-1 oui-text-xs md:oui-text-sm xl:oui-text-base",children:[jsxRuntime.jsx(Wr,{text:r}),jsxRuntime.jsx("button",{className:"oui-cursor-pointer oui-text-sm oui-flex-shrink",onClick:()=>{navigator.clipboard.writeText(r),e.onCopy?.(r);},children:jsxRuntime.jsx(ui$1.CopyIcon,{size:12,color:"white",className:"oui-w-[13px] oui-h-[13px] md:oui-w-[14px] md:oui-h-[14px] xl:oui-w-4 xl:oui-h-4"})})]})]})},Gi=e=>jsxRuntime.jsx(ui$1.Tooltip,{content:e.tooltip,className:"oui-max-w-[200px]",children:jsxRuntime.jsx("div",{onClick:()=>{ui$1.modal.alert({title:e.title,message:jsxRuntime.jsx("div",{className:"oui-text-base-contrast/30 oui-space-y-3 oui-text-xs desktop:oui-text-xs",children:e.tooltip})});},children:jsxRuntime.jsxs(ui$1.Flex,{direction:"column",children:[jsxRuntime.jsx(ui$1.Text,{intensity:54,className:"oui-text-2xs md:oui-text-xs xl:oui-text-sm",children:e.title}),jsxRuntime.jsx(ui$1.Divider,{className:"oui-w-full",lineStyle:"dotted",intensity:16})]})})});function Ue(e,t,r){try{let n=new URL(e),o=new URLSearchParams(n.search);return o.set(t,r),n.search=o.toString(),n.toString()}catch{return e}}async function Tt(e){try{await navigator.clipboard.writeText(e),ui$1.toast.success(i18n.i18n.t("common.copy.copied"));}catch{ui$1.toast.success(i18n.i18n.t("common.copy.failed"));}}function qr(e){if(e===void 0)return "";let t=dateFns.toDate(e),r=Qr(t);return dateFns.format(r,"yyyy-MM-dd HH:mm:ss 'UTC'")}function Gr(e){if(e===void 0)return;let t=dateFns.toDate(e),r=Qr(t);return dateFns.format(r,"yyyy-MM-dd")}function Zr(e,t){return e&&t&&e.toISOString().substring(0,10)===t.toISOString().substring(0,10)}function Qr(e){return new Date(e.toUTCString())}var St=()=>{let{t:e}=i18n.useTranslation(),t=x=>{ui$1.toast.success(e("common.copy.copied"));},{referralInfo:r,referralLinkUrl:n,overwrite:o}=y(),[i,a]=hooks.useLocalStorage("orderly_referral_codes",[]),f=react.useMemo(()=>{if(!r?.referrer_info?.referral_codes)return [];let x=[...r?.referrer_info?.referral_codes],g=[];for(let d=0;d<i.length;d++){let c=i[d],T=x.findIndex(H=>H.code===c);T!==-1&&(g.push({...x[T]}),x.splice(T,1));}return [...g,...x]},[r?.referrer_info?.referral_codes,i]),s=react.useMemo(()=>{if(f.length!==0)return f[0]},[f]),p=react.useMemo(()=>s?.code,[s]),m=react.useMemo(()=>s?Ue(n,"ref",s.code):"",[s]),u=react.useMemo(()=>`${new utils.Decimal(s?.referrer_rebate_rate||"0").mul(100).toDecimalPlaces(0,utils.Decimal.ROUND_DOWN).toString()}%`,[s?.referrer_rebate_rate]),l=react.useMemo(()=>`${new utils.Decimal(s?.referee_rebate_rate||"0").mul(100).toDecimalPlaces(0,utils.Decimal.ROUND_DOWN).toString()}%`,[s?.referee_rebate_rate]);return {onCopy:t,refLink:m,refCode:p,share:l,earn:u,brokerName:o?.brokerName??o?.shortBrokerName}};var He=()=>{let e=St();return jsxRuntime.jsx(Rt,{...e})};var At=e=>jsxRuntime.jsxs(ui$1.Flex,{id:"oui-affiliate-affiliate-titleStatistic",r:"2xl",p:6,width:"100%",gap:4,direction:"column",className:"oui-bg-base-9",children:[jsxRuntime.jsx(ra,{...e}),jsxRuntime.jsx(ui$1.Flex,{className:"oui-h-[170px] 2xl:oui-h-[196px] oui-w-full oui-flex oui-flex-row oui-items-stretch",children:jsxRuntime.jsx(chart.VolBarChart,{data:e.dataSource||types.EMPTY_LIST,colors:{fill:"rgba(0, 180, 158, 1)"},className:"oui-w-full oui-flex-1",tooltip:{rm:utils.Decimal.ROUND_DOWN,dp:e.volType==="Commission"?6:2}})})]}),ra=e=>{let{t}=i18n.useTranslation();return jsxRuntime.jsxs(ui$1.Flex,{direction:"row",justify:"between",width:"100%",children:[jsxRuntime.jsx(ui$1.Text,{className:"oui-text-lg",children:t("affiliate.statistics")}),jsxRuntime.jsxs(ui$1.Flex,{direction:"row",gap:2,className:"oui-min-w-14",children:[jsxRuntime.jsx(ui$1.Select.options,{size:"xs",value:e.period,onValueChange:e.onPeriodChange,options:e.periodTypes}),jsxRuntime.jsx(ui$1.Select.options,{size:"xs",value:e.volType,onValueChange:e.onVolTypeChange,options:e.volTypes})]})]})};function qe(e,t){let r=Date(),n=new Array(e).fill(0).map((i,a)=>({date:dateFns.format(dateFns.subDays(r,a+1),"yyyy-MM-dd"),volume:0,opacity:0})).reverse(),o=t?.reduce((i,a)=>(i[a.date]=a,i),{});for(let i=0;i<n.length;i++){let a=n[i],f=o?.[a.date];f&&(n[i]={...f,opacity:f.volume>0?1:0});}return n}var Dt=()=>{let{t:e}=i18n.useTranslation(),[t,r]=react.useState("7"),n=[{label:e("common.select.7d"),value:"7"},{label:e("common.select.30d"),value:"30"},{label:e("common.select.90d"),value:"90"}],o=l=>{r(l);},[i,a]=react.useState("Commission"),f=[{label:e("affiliate.commission"),value:"Commission"},{label:e("affiliate.referralVol"),value:"ref"}],s=l=>{a(l);},p=react.useMemo(()=>t==="7"?{startDate:dateFns.subDays(new Date,7),endDate:dateFns.subDays(new Date,1)}:t==="30"?{startDate:dateFns.subDays(new Date,30),endDate:dateFns.subDays(new Date,1)}:t==="90"?{startDate:dateFns.subDays(new Date,90),endDate:dateFns.subDays(new Date,1)}:{startDate:dateFns.subDays(new Date,7),endDate:dateFns.subDays(new Date,1)},[t]),[m]=hooks.useReferralRebateSummary({startDate:dateFns.format(p.startDate,"yyyy-MM-dd"),endDate:dateFns.format(p.endDate,"yyyy-MM-dd"),size:Number(t)}),u=react.useMemo(()=>(m?.map(l=>({date:l.date,volume:i==="Commission"?l.referral_rebate:l.volume}))||[]).reverse(),[m,i]);return {period:t,periodTypes:n,onPeriodChange:o,volType:i,volTypes:f,onVolTypeChange:s,dataSource:qe(Number(t),u)}};var Ge=()=>{let e=Dt();return jsxRuntime.jsx(At,{...e})};var De=e=>{let{className:t,...r}=e;return jsxRuntime.jsx("svg",{width:"12",height:"13",viewBox:"0 0 12 13",xmlns:"http://www.w3.org/2000/svg",fill:"white",fillOpacity:"0.36",className:t,...r,children:jsxRuntime.jsx("path",{d:"M8.49773 1.47656C8.36523 1.47656 8.23223 1.52357 8.13823 1.61707C7.86023 1.89507 6.85973 2.89558 6.63773 3.11808L2.13523 7.62059L1.63473 8.12059C1.56523 8.19059 1.52923 8.28958 1.50973 8.38658L1.00973 10.8881C0.939727 11.2381 1.23773 11.5361 1.58773 11.4666C1.90073 11.4036 3.77673 11.0286 4.08923 10.9661C4.18623 10.9466 4.28523 10.9106 4.35523 10.8411L4.85523 10.3406L9.35773 5.83808C9.58023 5.61608 10.5807 4.61506 10.8587 4.33756C10.9522 4.24356 10.9992 4.11056 10.9992 3.97806C10.9992 3.15956 10.7907 2.57456 10.3582 2.13306C9.92173 1.68756 9.33873 1.47656 8.49773 1.47656ZM8.69473 2.48606C9.14623 2.51256 9.43873 2.61608 9.63923 2.82108C9.84423 3.03008 9.97373 3.32008 10.0017 3.76258C9.72773 4.03608 9.32673 4.43106 8.99823 4.75956C8.60173 4.36306 8.11273 3.87407 7.71623 3.47757C8.04523 3.14907 8.42123 2.75956 8.69473 2.48606ZM6.99723 4.19657L8.27923 5.47858L4.49573 9.26207L3.21373 7.98009L6.99723 4.19657ZM2.49473 8.69908L3.77673 9.98107L3.72973 10.0281C3.39973 10.0941 2.73323 10.2336 2.11923 10.3566L2.44773 8.74608L2.49473 8.69908Z"})})};var to=e=>jsxRuntime.jsx("button",{children:jsxRuntime.jsx(De,{className:" oui-mt-px oui-cursor-pointer oui-fill-base-contrast-36 hover:oui-fill-base-contrast-80",fillOpacity:1,fill:"currentColor",onClick:e.onClick})});var Ft=e=>jsxRuntime.jsx("button",{onClick:t=>{e?.onClick?.(!e.pinned);},children:e.pinned===false?jsxRuntime.jsx(fa,{size:e.size,fillOpacity:1,className:"orderly-fill-primary-darken hover:orderly-fill-primary-darken/80"}):jsxRuntime.jsx(sa,{size:e.size,fillOpacity:1,className:"orderly-fill-base-contrast-36 hover:orderly-fill-base-contrast"})}),sa=e=>{let{size:t=12}=e;return jsxRuntime.jsx("svg",{width:t,height:t,viewBox:"0 0 16 16",fill:"#608CFF",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{d:"M10.008 1.302a.74.74 0 0 0-.486.215c-1.033.988-1.349 1.815-.972 2.947-.88.675-1.437.841-2.536.841-1.503 0-2.484.181-3.152.848v.021a1.583 1.583 0 0 0 0 2.249l1.867 1.881-3.181 3.18c-.26.26-.28.696-.02.956.261.26.699.26.959 0l3.193-3.193 1.87 1.86a1.585 1.585 0 0 0 2.25 0h.02c.668-.667.854-1.522.854-3.144 0-1.03.212-1.758.853-2.523 1.232.361 1.95.015 2.96-.995a.68.68 0 0 0 .188-.479c0-.234-.06-.594-.209-1.041a5.34 5.34 0 0 0-1.312-2.103A5.35 5.35 0 0 0 11.05 1.51c-.448-.149-.808-.208-1.042-.208"})})},fa=e=>{let{size:t=12}=e;return jsxRuntime.jsx("svg",{width:t,height:t,viewBox:"0 0 16 16",fill:"#fff",fillOpacity:".36",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{d:"M10.008 1.302a.74.74 0 0 0-.486.215c-1.033.988-1.349 1.815-.972 2.947-.88.675-1.437.841-2.536.841-1.503 0-2.484.181-3.152.848v.021a1.583 1.583 0 0 0 0 2.249l1.867 1.881-3.181 3.18c-.26.26-.28.696-.02.956.261.26.699.26.959 0l3.193-3.193 1.87 1.86a1.585 1.585 0 0 0 2.25 0h.02c.668-.667.854-1.522.854-3.144 0-1.03.212-1.758.853-2.523 1.232.361 1.95.015 2.96-.995a.68.68 0 0 0 .188-.479c0-.234-.06-.594-.209-1.041a5.34 5.34 0 0 0-1.312-2.103A5.35 5.35 0 0 0 11.05 1.51c-.448-.149-.808-.208-1.042-.208m.258 1.37c.708.131 1.421.6 1.93 1.108.507.507.94 1.13 1.119 1.944-.636.61-1.026.659-1.662.324a.67.67 0 0 0-.779.116c-1.214 1.213-1.533 2.314-1.533 3.8 0 1.293-.076 1.774-.48 2.207-.113.123-.27.104-.374 0L3.799 7.486a.24.24 0 0 1-.017-.34c.239-.29.769-.514 2.226-.514 1.742.001 2.668-.447 3.812-1.52a.67.67 0 0 0 .125-.77c-.343-.685-.29-1.046.321-1.67"})})};var Mt=e=>{let t=hooks.useMediaQuery("(max-width: 767px)");return jsxRuntime.jsxs(ui$1.Flex,{r:"2xl",p:6,width:"100%",gap:4,direction:"column",className:"oui-h-full oui-bg-base-9 oui-p-6 oui-tabular-nums",children:[jsxRuntime.jsx(ga,{...e}),jsxRuntime.jsxs("div",{className:"oui-flex oui-w-full oui-flex-col 2xl:oui-h-full",children:[jsxRuntime.jsx(ui$1.Divider,{}),t?jsxRuntime.jsx(ha,{...e}):jsxRuntime.jsx(Ca,{...e})]})]})},ga=e=>{let{t}=i18n.useTranslation();return jsxRuntime.jsxs(ui$1.Flex,{direction:"row",justify:"between",width:"100%",children:[jsxRuntime.jsx(ui$1.Text,{className:"oui-text-lg",children:t("affiliate.referralCodes")}),jsxRuntime.jsxs("div",{className:"oui-text-2xs md:oui-text-xs xl:oui-text-sm",children:[jsxRuntime.jsx(ui$1.Text,{className:"oui-text-base-contrast-54",children:`${t("affiliate.referralCodes.remaining")}: `}),jsxRuntime.jsx(ui$1.Text,{className:"oui-text-primary-light",children:e.codes?.length||"--"})]})]})},ha=e=>jsxRuntime.jsx(ui$1.ListView,{dataSource:e.codes,className:"oui-max-h-[240px] oui-w-full",renderItem:(t,r)=>jsxRuntime.jsxs(ui$1.Flex,{direction:"column",children:[jsxRuntime.jsx(ba,{data:t,editRate:e.editRate,copyLink:e.copyLink,copyCode:e.copyCode,setPinCode:e.setPinCode,editCode:e.editCode},r),jsxRuntime.jsx(ui$1.Divider,{className:"oui-mt-3 oui-w-full"})]})}),Fe=e=>{let{title:t,copyable:r,value:n,align:o,className:i,editRate:a,onCopy:f}=e;return jsxRuntime.jsx(ui$1.Statistic,{id:"oui-affiliate-affiliate-referralCodes",className:ui$1.cn("oui-flex-1",i),label:jsxRuntime.jsx(ui$1.Text,{className:"oui-text-2xs oui-text-base-contrast-36",children:t}),align:o,children:jsxRuntime.jsxs(ui$1.Flex,{direction:"row",gap:1,children:[jsxRuntime.jsx(ui$1.Text.formatted,{copyable:r,onCopy:()=>{f?.();},className:"oui-mt-[6px] oui-text-sm oui-text-base-contrast-80",children:n}),a&&jsxRuntime.jsx(De,{className:"oui-mt-px oui-cursor-pointer oui-fill-white/[.36] hover:oui-fill-white/80",fillOpacity:1,fill:"currentColor",onClick:()=>a()})]})})},ba=e=>{let{data:t,setPinCode:r,copyLink:n,editRate:o,editCode:i}=e,{t:a}=i18n.useTranslation();return jsxRuntime.jsxs(ui$1.Flex,{gap:3,direction:"column",className:"oui-w-full",children:[jsxRuntime.jsxs(ui$1.Flex,{direction:"row",justify:"between",itemAlign:"stretch",width:"100%",children:[jsxRuntime.jsx(Fe,{title:a("affiliate.referralCode"),value:t.code,copyable:true,onCopy:()=>{e.copyCode?.(t.code);},editRate:()=>{i(t);}}),jsxRuntime.jsx(Fe,{title:a("affiliate.referralCodes.column.you&Referee"),value:ao(t),align:"end",editRate:()=>{o(t);}}),jsxRuntime.jsx(Fe,{title:a("affiliate.referralCodes.column.referees&Traders"),value:we(t),align:"end",className:"oui-hidden md:oui-flex"})]}),jsxRuntime.jsxs(ui$1.Flex,{direction:"row",justify:"between",itemAlign:"stretch",width:"100%",className:"md:oui-hidden",children:[jsxRuntime.jsx(Fe,{title:a("affiliate.referees"),value:we(t).split("/")?.[0],align:"start"}),jsxRuntime.jsx(Fe,{title:a("affiliate.referralCodes.column.traders"),value:we(t).split("/")?.[1],align:"end"})]}),jsxRuntime.jsxs(ui$1.Flex,{direction:"row",justify:"between",itemAlign:"stretch",width:"100%",children:[jsxRuntime.jsx(Ft,{pinned:t.isPined||false,onClick:f=>{r(t.code,!f);}}),jsxRuntime.jsx(ui$1.Button,{variant:"outlined",size:"xs",className:"oui-px-[20px]",onClick:f=>{n(t.code);},children:a("affiliate.referralCodes.copyLink")})]})]},t.code)},Ca=e=>{let{t}=i18n.useTranslation(),r=hooks.useMediaQuery("(min-width: 1024px)"),n=react.useMemo(()=>{let o=[{title:t("affiliate.referralCode"),dataIndex:"code",width:r?115:120,className:"!oui-px-0",render:(i,a)=>jsxRuntime.jsxs(ui$1.Flex,{direction:"row",itemAlign:"center",gap:1,children:[jsxRuntime.jsx(Ft,{size:12,pinned:a.isPined||false,onClick:f=>{e.setPinCode(a.code,!f);}}),jsxRuntime.jsx(ui$1.Text.formatted,{suffix:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[a.isAutoGenerated&&a.total_invites<1&&jsxRuntime.jsx(to,{onClick:()=>e.editCode?.(a)}),jsxRuntime.jsx(ui$1.CopyIcon,{className:"oui-cursor-pointer",size:12,color:"white",onClick:()=>e.copyCode?.(a.code)})]}),copyable:true,onCopy:()=>{e.copyCode?.(a.code);},children:i})]})},{title:t("affiliate.referralCodes.column.you&Referee"),dataIndex:"dffd",width:120,className:"oui-pr-0",render:(i,a)=>jsxRuntime.jsxs(ui$1.Flex,{direction:"row",itemAlign:"center",gap:1,children:[ao(a),jsxRuntime.jsx(De,{className:"oui-mt-[6px] oui-cursor-pointer oui-fill-white/[.36] hover:oui-fill-white/80",fillOpacity:1,fill:"currentColor",onClick:f=>e.editRate?.(a)})]})}];return r?(o.push({title:t("affiliate.referees"),dataIndex:"referee_rebate_rate",width:65,className:"oui-pr-0",render:(i,a)=>we(a).split("/")[0]}),o.push({title:t("affiliate.referralCodes.column.traders"),dataIndex:"referrer_rebate_rate",width:65,className:"oui-pr-0",render:(i,a)=>we(a).split("/")[1]})):o.push({title:t("affiliate.referralCodes.column.referees&Traders"),dataIndex:"total_invites/total_traded",width:120,fixed:"left",render:(i,a)=>we(a)}),o.push({dataIndex:"link",align:"right",width:74,className:"!oui-px-0",render:(i,a)=>jsxRuntime.jsx(ui$1.Button,{variant:"outlined",size:"sm",className:"oui-px-5",onClick:f=>{e?.copyLink?.(a.code);},children:t("affiliate.referralCodes.copyLink")})}),o},[r,t]);return jsxRuntime.jsx(ui$1.DataTable,{bordered:true,columns:n,dataSource:e.codes,classNames:{header:"oui-px-0",root:"2xl:oui-flex-1 2xl:oui-max-h-[230px] 3xl:oui-max-h-[300px]"},onRow:o=>({className:"oui-h-[45px]"})})},ao=e=>{let t=new utils.Decimal(e.referee_rebate_rate).mul(100).toFixed(1,utils.Decimal.ROUND_DOWN).toString();return `${new utils.Decimal(e.referrer_rebate_rate).mul(100).toFixed(1,utils.Decimal.ROUND_DOWN).toString()}% / ${t}%`},we=e=>`${e.total_invites} / ${e.total_traded}`;var xo=ui$1.modal.create(e=>{let{t}=i18n.useTranslation(),{visible:r,onOpenChange:n}=ui$1.useModal(),[o,i]=react.useState(""),[a,f]=react.useState({length:false,format:false}),[s,{error:p,isMutating:m}]=hooks.useMutation("/v1/referral/edit_referral_code","POST");return react.useEffect(()=>{i(e.code.code);},[e.code]),react.useEffect(()=>{let u=o.toUpperCase(),l={length:false,format:false};(u.length<4||u.length>10)&&(l.length=true),/^[A-Z0-9]+$/.test(u)||(l.format=true),f(l);},[o]),jsxRuntime.jsxs(ui$1.SimpleDialog,{classNames:{content:"oui-max-w-[360px]"},title:jsxRuntime.jsx("div",{children:t("affiliate.referralCode.editCodeModal.title")}),open:r,onOpenChange:n,actions:{primary:{loading:m,disabled:a.length||a.format,label:t("common.confirm"),onClick:async()=>{try{let u=await s({current_referral_code:e.code.code,new_referral_code:o.toUpperCase()});if(u.success){ui$1.toast.success(t("affiliate.referralCode.editCodeModal.success")),e.successCallback(),n(!1);return}ui$1.toast.error(u.message);}catch{}}}},children:[jsxRuntime.jsx("div",{className:"oui-mb-6 oui-text-xs oui-text-base-contrast-54",children:t("affiliate.referralCode.editCodeModal.description")}),jsxRuntime.jsx(ui$1.TextField,{placeholder:"",fullWidth:true,label:t("affiliate.referralCode.editCodeModal.label"),onClean:()=>{i("");},value:o,onChange:u=>{let l=u.target.value.toUpperCase().replace(/[^A-Z0-9]/g,"");i(l);},formatters:[ui$1.inputFormatter.createRegexInputFormatter(u=>String(u).replace(/[a-z]/g,l=>l.toUpperCase())),ui$1.inputFormatter.createRegexInputFormatter(/[^A-Z0-9]/g)],classNames:{label:"oui-text-base-contrast-54 oui-text-xs",input:"placeholder:oui-text-base-contrast-20 placeholder:oui-text-sm"},maxLength:10,minLength:4,autoComplete:"off",helpText:""}),jsxRuntime.jsxs(ui$1.Flex,{direction:"column",justify:"center",itemAlign:"start",gap:1,className:"oui-mt-3",children:[jsxRuntime.jsx(ui$1.Text,{className:ui$1.cn("oui-ml-4 oui-list-item oui-list-outside oui-list-disc oui-text-xs oui-text-base-contrast-36 marker:oui-text-3xs",a.length?"oui-text-danger":"oui-text-success"),children:t("affiliate.referralCode.editCodeModal.helpText.length")}),jsxRuntime.jsx(ui$1.Text,{className:ui$1.cn("oui-ml-4 oui-list-item oui-list-outside oui-list-disc oui-text-xs oui-text-base-contrast-36 marker:oui-text-3xs","oui-text-success"),children:t("affiliate.referralCode.editCodeModal.helpText.format")})]})]})});var yo=ui$1.modal.create(e=>{let{code:t,mutate:r}=e,{visible:n,hide:o,resolve:i,reject:a,onOpenChange:f}=ui$1.useModal(),s=new utils.Decimal(t.max_rebate_rate).mul(100),[p,m]=react.useState(`${new utils.Decimal(t.referee_rebate_rate).mul(100)}`),[u,l]=react.useState(`${new utils.Decimal(t.referrer_rebate_rate).mul(100)}`),[x,g]=react.useState(false),d=react.useRef(null),{t:c}=i18n.useTranslation();react.useEffect(()=>{d?.current&&(d.current.focus(),d.current.setSelectionRange(d.current.value.length,d.current.value.length));},[d]),react.useEffect(()=>{m(`${new utils.Decimal(t.referee_rebate_rate).mul(100)}`),l(`${new utils.Decimal(t.referrer_rebate_rate).mul(100)}`);},[t]);let[T,{error:H,isMutating:ne}]=hooks.useMutation("/v1/referral/edit_split","POST"),z=async()=>{try{let M=Number.parseFloat(p),D=Number.parseFloat(u);await T({referral_code:t.code,referee_rebate_rate:M/100,referrer_rebate_rate:D/100}),ui$1.toast.success(c("affiliate.referralRate.editRateModal.success")),r(),o();}catch(M){ui$1.toast.error(M?.message||M||"");}};return jsxRuntime.jsx(ui$1.Dialog,{open:n,onOpenChange:f,children:jsxRuntime.jsxs(ui$1.DialogContent,{className:"oui-px-6 oui-max-w-[320px] oui-bg-base-8 oui-shadow-[0px_12px_20px_0px_rgba(0,0,0,0.25)]",closable:true,children:[jsxRuntime.jsxs(ui$1.DialogTitle,{children:[jsxRuntime.jsx("div",{className:"oui-my-3",children:c("affiliate.referralRate.editRateModal.title")}),jsxRuntime.jsx(ui$1.Divider,{})]}),jsxRuntime.jsxs("div",{className:"oui-mt-3 oui-h-full oui-flex oui-flex-col oui-justify-end",children:[jsxRuntime.jsx("div",{className:"oui-text-xs oui-text-base-contrast-54",children:c("affiliate.referralRate.editRateModal.description")}),jsxRuntime.jsxs("div",{className:"oui-text-xs oui-text-base-contrast-80 oui-mt-2 oui-flex",children:[c("affiliate.referralRate.editRateModal.label"),jsxRuntime.jsx("div",{className:"oui-text-warning-darken oui-pl-1",children:`${new utils.Decimal(t.max_rebate_rate).mul(100).toFixed(0,utils.Decimal.ROUND_DOWN)}%`})]}),jsxRuntime.jsx("div",{className:"oui-text-2xs oui-mt-6 oui-text-base-contrast-80",children:c("affiliate.referralRate.editRateModal.label.you")}),jsxRuntime.jsx(ui$1.Input,{ref:d,containerClassName:"oui-h-[40px] oui-mt-3 oui-bg-base-700 oui-outline oui-outline-1 oui-outline-base-contrast-12 focus-within:oui-outline-primary-darken",placeholder:"Enter code",type:"text",inputMode:"decimal",autoComplete:"off",value:u,onChange:M=>{let D=hooks.cleanStringStyle(M.target.value),k=Number.parseFloat(D);l(D),Number.isNaN(k)?(m(""),l("")):(m(`${Co(new utils.Decimal(0),s.sub(k))}`),g(s.sub(k)<new utils.Decimal(0)));},suffix:jsxRuntime.jsx("div",{className:"oui-px-3 oui-text-base-contrast-54 oui-text-base",children:"%"}),color:x?"danger":void 0}),jsxRuntime.jsx("div",{className:"oui-text-2xs oui-mt-6 oui-text-base-contrast-80",children:c("affiliate.referralRate.editRateModal.label.referee")}),jsxRuntime.jsx(ui$1.Input,{containerClassName:"oui-h-[40px] oui-mt-3 oui-bg-base-700 oui-outline oui-outline-1 oui-outline-base-contrast-12 focus-within:oui-outline-primary-darken",placeholder:"Enter code",type:"text",inputMode:"decimal",autoComplete:"off",autoFocus:false,value:p,onChange:M=>{let D=hooks.cleanStringStyle(M.target.value),k=Number.parseFloat(D);m(D),Number.isNaN(k)?(m(""),l("")):(l(`${Co(new utils.Decimal(0),s.sub(k))}`),g(s.sub(k)<new utils.Decimal(0)));},suffix:jsxRuntime.jsx("div",{className:"oui-px-3 oui-text-base-contrast-54 oui-text-base",children:"%"}),color:x?"danger":void 0}),x&&jsxRuntime.jsx("div",{className:"oui-text-danger oui-text-xs oui-mt-8 oui-text-center oui-px-4",children:c("affiliate.referralRate.editRateModal.helpText.max")}),jsxRuntime.jsx(ui$1.Flex,{width:"100%",justify:"center",children:jsxRuntime.jsx(ui$1.Button,{id:"referral_bind_referral_code_btn",disabled:p.length===0||u.length===0||x,loading:ne,className:ui$1.cn("oui-mt-8 oui-mb-4 oui-w-[154px]",x&&"oui-mt-3"),onClick:M=>{M.stopPropagation(),z();},children:c("common.confirm")})})]})]})})});function Co(e,t){return e>t?e:t}var Pt=()=>{let{referralInfo:e,referralLinkUrl:t,mutate:r,generateCode:n}=y(),o=l=>{Tt(Ue(t,"ref",l));},i=l=>{Tt(l);},a=l=>{ui$1.modal.show(yo,{code:{...l},mutate:r});},f=l=>{ui$1.modal.show(xo,{code:{...l},successCallback:()=>{r();}});},[s,p]=hooks.useLocalStorage("orderly_referral_codes",[]),m=(l,x)=>{if(x){let g=s.findIndex(d=>d===l);g!==-1&&s.splice(g,1);}else s.splice(0,0,l);s.length>6&&s.splice(s.length-1,1),p([...s]);},u=react.useMemo(()=>{if(!e?.referrer_info?.referral_codes)return;let l=e?.referrer_info?.referral_codes?.map(g=>(n&&n.code===g.code&&(g.isAutoGenerated=true),g)),x=[];for(let g=0;g<s.length;g++){let d=s[g],c=l.findIndex(T=>T.code===d);c!==-1&&(x.push({...l[c],isPined:true}),l.splice(c,1));}return [...x,...l]},[e?.referrer_info?.referral_codes,s,n]);return {copyCode:i,copyLink:o,editRate:a,editCode:f,setPinCode:m,codes:u}};var Ye=()=>{let e=Pt();return jsxRuntime.jsx(Mt,{...e})};var kt=e=>{let{t}=i18n.useTranslation();return jsxRuntime.jsx(ui$1.Flex,{id:"oui-affiliate-affiliate-commissionAndReferees",r:"2xl",p:6,width:"100%",gap:4,direction:"column",className:"oui-bg-base-9 oui-tabular-nums",children:jsxRuntime.jsxs(ui$1.Tabs,{defaultValue:"account",className:"oui-w-full",variant:"contained",children:[jsxRuntime.jsx(ui$1.TabPanel,{value:"account",title:t("affiliate.commission"),children:jsxRuntime.jsx(Qa,{...e})}),jsxRuntime.jsx(ui$1.TabPanel,{value:"password",title:t("affiliate.myReferees"),children:jsxRuntime.jsx(Ya,{...e})})]})})},q=e=>{let{title:t,value:r,align:n,className:o,rule:i,formatString:a,prefix:f}=e;return jsxRuntime.jsx(ui$1.Statistic,{className:ui$1.cn("oui-flex-1",o),label:jsxRuntime.jsx(ui$1.Text,{className:"oui-text-base-contrast-36 oui-text-2xs",children:t}),align:n,children:jsxRuntime.jsx(ui$1.Text.formatted,{rule:i||"",formatString:a,prefix:f,className:"oui-text-base-contrast-80 oui-text-sm oui-mt-[6px]",children:r})})},Qa=e=>{let{t}=i18n.useTranslation(),r=hooks.useMediaQuery("(max-width: 767px)"),n=react.useMemo(()=>[{title:`${t("affiliate.commission")} (USDC)`,dataIndex:"referral_rebate",render:a=>jsxRuntime.jsx(ui$1.Text,{children:utils.commifyOptional(a,{fix:6,fallback:"0",padEnd:true,prefix:"$"})}),width:216},{title:`${t("affiliate.referralVol")} (USDC)`,dataIndex:"volume",render:a=>jsxRuntime.jsx(ui$1.Text,{children:utils.commifyOptional(a,{fix:2,fallback:"0",padEnd:true,prefix:"$"})}),width:216},{title:t("affiliate.commission.column.activeUsers"),dataIndex:"daily_traded_referral",render:a=>jsxRuntime.jsx(ui$1.Text,{children:a}),width:216},{title:t("common.date"),dataIndex:"date",render:a=>Gr(a),width:216}],[t]),o=react.useMemo(()=>r?jsxRuntime.jsx(ui$1.ListView,{className:"oui-max-h-[200px] oui-w-full",dataSource:e.commission.data,loadMore:e.commission.loadMore,isLoading:e.commission.isLoading,renderItem:i=>jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs(ui$1.Flex,{direction:"row",width:"100%",children:[jsxRuntime.jsx(q,{title:t("affiliate.commission"),value:utils.commifyOptional(i.referral_rebate,{fix:6,fallback:"0",padEnd:true}),prefix:"$"}),jsxRuntime.jsx(q,{title:t("affiliate.referralVol"),value:utils.commifyOptional(i.volume,{fix:2,fallback:"0",padEnd:true}),prefix:"$"}),jsxRuntime.jsx(q,{title:t("affiliate.commission.column.activeUsers"),value:i.daily_traded_referral}),jsxRuntime.jsx(q,{title:t("common.date"),value:i.date,rule:"date",formatString:"yyyy-MM-dd",align:"end"})]}),jsxRuntime.jsx(ui$1.Divider,{className:"oui-mt-3 oui-w-full"})]})}):jsxRuntime.jsx(uiConnector.AuthGuardDataTable,{bordered:true,columns:n,loading:e.commission.isLoading,ignoreLoadingCheck:true,dataSource:e.commission.data,pagination:e.commission.pagination,onRow:i=>({className:"oui-h-[41px]"})}),[r,e.commission]);return jsxRuntime.jsxs(ui$1.Flex,{direction:"column",width:"100%",justify:"start",itemAlign:"start",children:[jsxRuntime.jsx(Xa,{value:e.commission.dateRange,setValue:e.commission.setDateRange}),o]})},Ya=e=>{let{t}=i18n.useTranslation(),r=hooks.useMediaQuery("(max-width: 767px)"),n=react.useMemo(()=>[{title:t("affiliate.referees.column.refereeAddress"),dataIndex:"user_address",render:a=>jsxRuntime.jsx(ui$1.Text.formatted,{rule:"address",children:a}),className:"oui-w-1/5"},{title:t("affiliate.referralCode"),dataIndex:"referral_code",className:"oui-w-1/5"},{title:`${t("affiliate.referees.column.totalCommission")} (USDC)`,dataIndex:"referral_rebate",render:a=>jsxRuntime.jsx(ui$1.Text,{children:utils.commifyOptional(a,{fix:6,prefix:"$",padEnd:true})}),className:"oui-w-1/5"},{title:`${t("affiliate.referees.column.totalVol")} (USDC)`,dataIndex:"volume",render:a=>jsxRuntime.jsx(ui$1.Text,{children:utils.commifyOptional(a,{fix:2,prefix:"$",padEnd:true})}),className:"oui-w-1/5"},{title:t("affiliate.referees.column.invitationTime"),dataIndex:"code_binding_time",render:a=>jsxRuntime.jsx(ui$1.Text.formatted,{rule:"date",formatString:"yyyy-MM-dd",children:a}),className:"oui-w-1/5"}],[t]),o=react.useMemo(()=>r?jsxRuntime.jsx(ui$1.ListView,{className:"oui-w-full oui-max-h-[200px]",dataSource:e.referees.data,loadMore:e.referees.loadMore,isLoading:e.referees.isLoading,renderItem:(i,a)=>jsxRuntime.jsxs(ui$1.Flex,{direction:"column",gap:3,className:"oui-border-b-2 oui-border-line-6 oui-pb-3",children:[jsxRuntime.jsxs(ui$1.Flex,{direction:"row",width:"100%",children:[jsxRuntime.jsx(q,{title:t("affiliate.referralCode"),value:i.referral_code}),jsxRuntime.jsx(q,{title:`${t("affiliate.referees.column.totalCommission")} (USDC)`,value:utils.commifyOptional(i.referral_rebate,{fix:6,prefix:"$",padEnd:true}),className:"oui-min-w-[102px]"}),jsxRuntime.jsx(q,{title:t("affiliate.referees.column.totalVol"),value:utils.commifyOptional(i.volume,{fix:2,prefix:"$",padEnd:true}),align:"end"})]}),jsxRuntime.jsxs(ui$1.Flex,{direction:"row",pt:3,gap:3,width:"100%",children:[jsxRuntime.jsx(q,{title:t("affiliate.referees.column.refereeAddress"),value:i.user_address,rule:"address"}),jsxRuntime.jsx(q,{title:t("affiliate.referees.column.invitationTime"),value:i.code_binding_time,align:"end",rule:"date",formatString:"yyyy-MM-dd"})]})]},a)}):jsxRuntime.jsx(uiConnector.AuthGuardDataTable,{bordered:true,loading:e.referees.isLoading,ignoreLoadingCheck:true,columns:n,dataSource:e.referees.data,pagination:e.referees.pagination,onRow:i=>({className:"oui-h-[41px]"})}),[r,e.referees]);return jsxRuntime.jsx(ui$1.Flex,{direction:"column",width:"100%",justify:"start",itemAlign:"start",children:o})},Xa=e=>jsxRuntime.jsx(ui$1.Flex,{width:"100%",height:49,className:"oui-border-b oui-border-line-6",children:jsxRuntime.jsx("div",{children:jsxRuntime.jsx(ui$1.DatePicker.range,{size:"xs",value:e.value,onChange:t=>{e.setValue(t);},max:90,disabled:{after:new Date}})})});var Bt=()=>{let e=ja(),t=en();return {commission:e,referees:t}},ja=()=>{let[e,t]=react.useState({from:dateFns.subDays(new Date,90),to:dateFns.subDays(new Date,1)}),r=hooks.useMediaQuery("(max-width: 767px)"),{page:n,pageSize:o,setPage:i,parsePagination:a}=ui$1.usePagination(),[f,{refresh:s,isLoading:p,loadMore:m,meta:u}]=hooks.useReferralRebateSummary({startDate:e?.from!==void 0?dateFns.format(e.from,"yyyy-MM-dd"):void 0,endDate:e?.to!==void 0?dateFns.format(e.to,"yyyy-MM-dd"):void 0,size:o,page:r?void 0:n});react.useEffect(()=>{s();},[e]);let l=react.useMemo(()=>a(u),[a,u]);return react.useEffect(()=>{i(1);},[e]),{data:f||void 0,pagination:l,dateRange:e,setDateRange:t,isLoading:p,loadMore:m}},en=()=>{let[e,t]=react.useState({from:dateFns.subDays(new Date,90),to:dateFns.subDays(new Date,1)}),r=hooks.useMediaQuery("(max-width: 767px)"),{page:n,pageSize:o,setPage:i,parsePagination:a}=ui$1.usePagination(),[f,{refresh:s,isLoading:p,loadMore:m,meta:u}]=hooks.useRefereeInfo({startDate:e?.from!==void 0?dateFns.format(e.from,"yyyy-MM-dd"):void 0,endDate:e?.to!==void 0?dateFns.format(e.to,"yyyy-MM-dd"):void 0,size:o,page:r?void 0:n,sort:"descending_code_binding_time"});react.useEffect(()=>{s();},[e]);let l=react.useMemo(()=>a(u),[a,u]);return react.useEffect(()=>{i(1);},[e]),{data:f||void 0,pagination:l,dateRange:e,setDateRange:t,isLoading:p,loadMore:m}};var Vt=()=>{let e=Bt();return jsxRuntime.jsx(kt,{...e})};var Me=()=>jsxRuntime.jsxs(ui$1.Flex,{id:"oui-affiliate-affiliate-page",className:ui$1.cn("oui-h-lvw","oui-font-semibold"),direction:"column",gap:4,children:[jsxRuntime.jsx(an,{}),jsxRuntime.jsx(Vt,{})]}),an=()=>hooks.useMediaQuery("(max-width: 1279px)")?jsxRuntime.jsx(nn,{}):jsxRuntime.jsx(ln,{}),nn=()=>jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"oui-flex oui-flex-col xl:oui-flex-row oui-gap-4 oui-w-full",children:[jsxRuntime.jsx(Oe,{}),jsxRuntime.jsx(He,{})]}),jsxRuntime.jsx(Ge,{}),jsxRuntime.jsx(Ye,{})]}),ln=()=>jsxRuntime.jsxs(ui$1.Flex,{direction:"row",itemAlign:"stretch",gap:4,children:[jsxRuntime.jsxs(ui$1.Flex,{direction:"column",gap:4,className:"oui-flex-1 oui-w-1/2",children:[jsxRuntime.jsx("div",{className:"oui-flex-1 oui-h-full oui-w-full",children:jsxRuntime.jsx(Oe,{})}),jsxRuntime.jsx(Ge,{})]}),jsxRuntime.jsxs(ui$1.Flex,{direction:"column",gap:4,className:"oui-w-1/2",children:[jsxRuntime.jsx(He,{}),jsxRuntime.jsx("div",{className:"oui-flex-1",children:jsxRuntime.jsx(Ye,{})})]})]});var Ot=e=>{let{t}=i18n.useTranslation(),{generateCode:r}=y(),n=react.useMemo(()=>r?r.requireVolume>0?{title:t("affiliate.process.step1.volumeGt0.title",{requireVolume:r.requireVolume}),desc:t("affiliate.process.step1.volumeGt0.description",{volume:utils.commify(r.completedVolume??0,2),requireVolume:utils.commify(r.requireVolume)})}:{title:t("affiliate.process.step1.volumeEq0.title"),desc:t("affiliate.process.step1.volumeEq0.description")}:{title:t("affiliate.process.step1.title"),desc:t("affiliate.process.step1.description")},[r,t]);return typeof e.overwrite=="function"?e.overwrite?.(e.state):jsxRuntime.jsxs(ui$1.Flex,{id:"oui-affiliate-home-becomeAffiliate",direction:"column",gap:6,p:6,itemAlign:"center",r:"2xl",className:"oui-bg-base-9",width:"100%",children:[jsxRuntime.jsx(ui$1.Text,{children:t("affiliate.process.title")}),jsxRuntime.jsxs(ui$1.Flex,{className:"oui-flex oui-flex-col oui-gap-3 lg:oui-w-full lg:oui-flex-row lg:oui-items-stretch",children:[jsxRuntime.jsx(zt,{icon:jsxRuntime.jsx(mn,{}),title:n.title,content:n.desc}),jsxRuntime.jsx("div",{className:"oui-shrink lg:oui-flex lg:-oui-rotate-90 lg:oui-flex-row lg:oui-items-center lg:oui-justify-center",children:jsxRuntime.jsx(Lo,{})}),jsxRuntime.jsx(zt,{icon:jsxRuntime.jsx(cn,{}),title:t("affiliate.process.step2.title"),content:t("affiliate.process.step2.description")}),jsxRuntime.jsx("div",{className:"oui-shrink lg:oui-flex lg:-oui-rotate-90 lg:oui-flex-row lg:oui-items-center lg:oui-justify-center",children:jsxRuntime.jsx(Lo,{})}),jsxRuntime.jsx(zt,{icon:jsxRuntime.jsx(dn,{}),title:t("affiliate.process.step3.title"),content:t("affiliate.process.step3.description")})]})]})},zt=e=>jsxRuntime.jsxs(ui$1.Flex,{className:ui$1.cn("oui-flex oui-flex-row oui-gap-3","lg:oui-flex-1 lg:oui-flex-col lg:oui-gap-[6px]"),width:"100%",children:[jsxRuntime.jsx("div",{className:"oui-shrink-0",children:e.icon}),jsxRuntime.jsxs(ui$1.Flex,{className:ui$1.cn("oui-flex oui-flex-col oui-items-start oui-h-full oui-justify-between","lg:oui-items-center lg:oui-justify-start"),children:[jsxRuntime.jsx(ui$1.Text,{className:"oui-text-sm md:oui-text-base 2xl:oui-text-lg lg:oui-text-center",children:e.title}),jsxRuntime.jsx(ui$1.Text,{className:"oui-text-2xs oui-text-base-contrast-36 lg:oui-text-center",children:e.content})]})]}),mn=()=>jsxRuntime.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"lg:oui-w-[64px] lg:oui-h-[64px] 2xl:oui-w-[80px] 2xl:oui-h-[80px]",children:[jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M24.941 5.4h-6.682a.6.6 0 0 0-.593.509l-.462 3a.6.6 0 0 0 .593.691h7.606a.6.6 0 0 0 .593-.691l-.462-3a.6.6 0 0 0-.593-.509m-6.682-1.8a2.4 2.4 0 0 0-2.372 2.035l-.462 3a2.4 2.4 0 0 0 2.372 2.765h7.606a2.4 2.4 0 0 0 2.372-2.765l-.462-3A2.4 2.4 0 0 0 24.941 3.6z",fill:"#fff",fillOpacity:".36"}),jsxRuntime.jsx("path",{d:"M32.721 28.2c.924-1.6 3.233-1.6 4.157 0l7.275 12.6c.924 1.6-.231 3.6-2.079 3.6H27.525c-1.848 0-3.002-2-2.078-3.6z",fill:"#335FFC"}),jsxRuntime.jsx("path",{d:"M33.492 38.12H31.56c-.252 0-.426-.276-.336-.535l1.92-5.53a.4.4 0 0 1 .132-.185.34.34 0 0 1 .204-.07h3.24c.255 0 .43.284.333.544l-1.118 3.011h2.104c.31 0 .475.4.27.656l-5.158 6.453c-.251.313-.716.041-.619-.362z",fill:"#fff",fillOpacity:".98"}),jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M14.4 16.8v2.4h2.4v-2.4zM13.2 15a.6.6 0 0 0-.6.6v4.8a.6.6 0 0 0 .6.6H18a.6.6 0 0 0 .6-.6v-4.8a.6.6 0 0 0-.6-.6z",fill:"#fff",fillOpacity:".36"}),jsxRuntime.jsx("path",{d:"M20.4 16.2a.6.6 0 0 1 .6-.6h2.4a.6.6 0 0 1 .6.6v.6a.6.6 0 0 1-.6.6H21a.6.6 0 0 1-.6-.6zm0 3a.6.6 0 0 1 .6-.6h9a.6.6 0 0 1 .6.6v.6a.6.6 0 0 1-.6.6h-9a.6.6 0 0 1-.6-.6zm-7.8 5.4a.6.6 0 0 1 .6-.6H30a.6.6 0 0 1 .6.6v.6a.6.6 0 0 1-.6.6H13.2a.6.6 0 0 1-.6-.6zm0 3.6a.6.6 0 0 1 .6-.6H30a.6.6 0 0 1 .6.6v.6a.6.6 0 0 1-.6.6H13.2a.6.6 0 0 1-.6-.6zm0 3.6a.6.6 0 0 1 .6-.6h9a.6.6 0 0 1 .6.6v.6a.6.6 0 0 1-.6.6h-9a.6.6 0 0 1-.6-.6z",fill:"#fff",fillOpacity:".36"}),jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M15.739 6.6H10.2A2.4 2.4 0 0 0 7.8 9v30a2.4 2.4 0 0 0 2.4 2.4h13.84l1.014-1.8H10.2a.6.6 0 0 1-.6-.6V9a.6.6 0 0 1 .6-.6h5.262zm12 1.8H33a.6.6 0 0 1 .6.6v16.47a2.8 2.8 0 0 1 1.8-.205V9A2.4 2.4 0 0 0 33 6.6h-5.538z",fill:"#fff",fillOpacity:".36"})]}),cn=()=>jsxRuntime.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"lg:oui-w-[64px] lg:oui-h-[64px] 2xl:oui-w-[80px] 2xl:oui-h-[80px]",children:[jsxRuntime.jsx("path",{d:"M24 33a9 9 0 1 1-18 0 9 9 0 0 1 18 0",fill:"#335FFC"}),jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M15 32.4a1.8 1.8 0 1 0 0-3.6 1.8 1.8 0 0 0 0 3.6m0 1.8a3.6 3.6 0 1 0 0-7.2 3.6 3.6 0 0 0 0 7.2m-6.578 4.942A4.8 4.8 0 0 1 13.2 34.8h3.6a4.8 4.8 0 0 1 4.778 4.342 9 9 0 0 1-1.778 1.473V39.6a3 3 0 0 0-3-3h-3.6a3 3 0 0 0-3 3v1.015a9 9 0 0 1-1.778-1.473",fill:"#fff",fillOpacity:".98"}),jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M16.2 12a4.2 4.2 0 1 1-8.4 0 4.2 4.2 0 0 1 8.4 0m1.8 0c0 1.37-.459 2.632-1.231 3.642l2.308 2.308a7.76 7.76 0 0 1 4.023-1.7v-.764A3.602 3.602 0 0 1 24 8.4a3.6 3.6 0 0 1 .9 7.087v.764c1.48.17 2.833.754 3.942 1.633l2.326-2.326a6 6 0 1 1 1.273 1.273l-2.326 2.326a7.76 7.76 0 0 1 1.634 3.943h.764a3.602 3.602 0 0 1 7.087.9 3.6 3.6 0 0 1-7.087.9h-.764a7.76 7.76 0 0 1-1.699 4.023l2.308 2.308a6 6 0 1 1-1.25 1.295l-2.347-2.347a7.8 7.8 0 0 1-3.05 1.433 11 11 0 0 0-.377-1.76 6 6 0 1 0-7.185-7.185q-.855-.261-1.76-.379a7.8 7.8 0 0 1 1.432-3.049l-2.347-2.347A6 6 0 1 1 18 12m7.8 0a1.8 1.8 0 1 1-3.6 0 1.8 1.8 0 0 1 3.6 0M36 25.8a1.8 1.8 0 1 0 0-3.6 1.8 1.8 0 0 0 0 3.6m0-9.6a4.2 4.2 0 1 0 0-8.4 4.2 4.2 0 0 0 0 8.4M40.2 36a4.2 4.2 0 1 1-8.4 0 4.2 4.2 0 0 1 8.4 0",fill:"#fff",fillOpacity:".36"})]}),dn=()=>jsxRuntime.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"lg:oui-w-[64px] lg:oui-h-[64px] 2xl:oui-w-[80px] 2xl:oui-h-[80px]",children:[jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M24 24a2.4 2.4 0 1 0 0-4.8 2.4 2.4 0 0 0 0 4.8m0 1.8a4.2 4.2 0 1 0 0-8.4 4.2 4.2 0 0 0 0 8.4",fill:"#fff",fillOpacity:".36"}),jsxRuntime.jsx("path",{d:"M45 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0",fill:"#335FFC"}),jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M35.1 6.6a.9.9 0 1 1 1.8 0v.437A3 3 0 0 1 39 9.9h-1.8a1.2 1.2 0 1 0-1.2 1.2 3 3 0 0 1 .9 5.863v.437a.9.9 0 0 1-1.8 0v-.437A3 3 0 0 1 33 14.1h1.8a1.2 1.2 0 1 0 1.2-1.2 3 3 0 0 1-.9-5.863z",fill:"#fff",fillOpacity:".98"}),jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M40.2 23.7a.9.9 0 0 1 1.8 0v.6q0 .045-.004.086c-.197 9.351-7.525 16.948-16.765 17.573l1.205 1.205a.9.9 0 1 1-1.272 1.272l-2.7-2.7a.9.9 0 0 1 0-1.272l2.7-2.7a.9.9 0 1 1 1.272 1.272l-1.11 1.11c8.325-.674 14.87-7.642 14.874-16.14zM21.564 4.836a.9.9 0 1 1 1.272-1.272l2.7 2.7a.9.9 0 0 1 0 1.272l-2.7 2.7a.9.9 0 1 1-1.272-1.272l1.11-1.11C14.347 8.528 7.8 15.5 7.8 24v.3a.9.9 0 1 1-1.8 0v-.6l.004-.086C6.201 14.263 13.53 6.666 22.77 6.042z",fill:"#fff",fillOpacity:".36"}),jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M24 11.4q.615 0 1.213.058a11 11 0 0 0 .061 1.816Q24.647 13.2 24 13.2c-5.965 0-10.8 4.835-10.8 10.8 0 2.898 1.142 5.53 3 7.47a4.8 4.8 0 0 1 4.8-4.79h6a4.8 4.8 0 0 1 4.8 4.789c1.858-1.94 3-4.572 3-7.47q0-.647-.074-1.274a11 11 0 0 0 1.816.06q.057.6.058 1.214c0 6.959-5.641 12.6-12.6 12.6S11.4 30.959 11.4 24 17.041 11.4 24 11.4m6 21.581v-1.5a3 3 0 0 0-3-3h-6a3 3 0 0 0-3 3v1.5a10.75 10.75 0 0 0 6 1.819c2.22 0 4.284-.67 6-1.819",fill:"#fff",fillOpacity:".36"})]}),Lo=()=>jsxRuntime.jsx("svg",{width:"17",height:"16",viewBox:"0 0 17 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{d:"M8.5048 4.00806C8.8728 4.00806 9.1708 4.30626 9.1708 4.67406C9.1708 4.99259 9.1708 8.71739 9.1708 9.71072L11.1688 7.73339L12.1055 8.67005L8.98346 11.8127C8.85346 11.9434 8.6788 12.0081 8.50413 12.0081C8.33013 12.0081 8.15612 11.9427 8.02612 11.8127L4.90413 8.67005L5.8408 7.73339L7.83881 9.71072C7.83881 8.71739 7.83881 4.99259 7.83881 4.67406C7.83881 4.30626 8.1368 4.00806 8.5048 4.00806Z",fill:"#608CFF"})});var Ut=()=>{let e=y();return {overwrite:e.overwrite?.ref?.step,state:e}};var Et=()=>{let e=Ut();return jsxRuntime.jsx(Ot,{...e})};var Ht=()=>{let{t:e}=i18n.useTranslation();return jsxRuntime.jsx("div",{id:"oui-affiliate-home-title",className:"oui-text-center oui-text-3xl oui-font-bold md:oui-text-3xl lg:oui-text-4xl xl:oui-text-5xl",children:e("affiliate.page.title")})};var $t=()=>jsxRuntime.jsx(Ht,{});var qt=e=>{let{t}=i18n.useTranslation();return jsxRuntime.jsxs(ui$1.Flex,{id:"oui-affiliate-home-subtitle",direction:"column",className:"oui-text-sm md:oui-text-base xl:oui-text-lg oui-text-base-contrast-80 oui-text-center",gap:3,children:[jsxRuntime.jsx(ui$1.Text,{children:t("affiliate.page.subTitle")}),jsxRuntime.jsxs(ui$1.Flex,{direction:"row",gap:1,className:"oui-text-primary-light oui-fill-primary-light hover:oui-text-primary-darken oui-cursor-pointer oui-text-2xs md:oui-text-xs xl:oui-text-sm",onClick:r=>{e.onLearnAffiliate?e.onLearnAffiliate?.():e.learnAffiliateUrl&&window.open(e.learnAffiliateUrl,"_blank");},children:[jsxRuntime.jsx(ui$1.Text,{children:t("affiliate.page.learnMore")}),jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{d:"M4.008 7.995c0-.368.298-.666.666-.666H9.71L7.733 5.331l.937-.936 3.143 3.122c.13.13.195.304.195.479a.67.67 0 0 1-.195.478L8.67 11.596l-.937-.937 1.978-1.998H4.674a.666.666 0 0 1-.666-.666"})})]})]})};var Gt=()=>{let e=y(),{onLearnAffiliate:t,learnAffiliateUrl:r}=e;return {onLearnAffiliate:t,learnAffiliateUrl:r}};var Zt=()=>{let e=Gt();return jsxRuntime.jsx(qt,{...e})};var Qt=e=>e.overwriteTop!==void 0?e.overwriteTop?.(e.state):jsxRuntime.jsxs(ui$1.Flex,{id:"oui-affiliate-home-top",direction:"column",gap:6,children:[jsxRuntime.jsx($t,{}),jsxRuntime.jsx(Zt,{})]});var Yt=()=>{let e=y();return {overwriteTop:e.overwrite?.ref?.top,state:e}};var Xt=()=>{let e=Yt();return jsxRuntime.jsx(Qt,{...e})};var ot=e=>jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"white",fillOpacity:"0.98",xmlns:"http://www.w3.org/2000/svg",className:e.className,children:jsxRuntime.jsx("path",{d:"M4.00806 7.9952C4.00806 7.6272 4.30626 7.3292 4.67406 7.3292C4.99259 7.3292 8.71739 7.3292 9.71072 7.3292L7.73339 5.3312L8.67005 4.39453L11.8127 7.51654C11.9434 7.64654 12.0081 7.8212 12.0081 7.99587C12.0081 8.16987 11.9427 8.34388 11.8127 8.47388L8.67005 11.5959L7.73339 10.6592L9.71072 8.66119C8.71739 8.66119 4.99259 8.66119 4.67406 8.66119C4.30626 8.66119 4.00806 8.3632 4.00806 7.9952Z"})});var Jt=e=>{let{t}=i18n.useTranslation();return jsxRuntime.jsxs(ui$1.Flex,{id:"oui-affiliate-home-asTrader",gradient:"success",r:"2xl",p:6,gap:6,direction:"column",angle:180,width:"100%",justify:"between",children:[jsxRuntime.jsxs(ui$1.Flex,{height:80,direction:"row",gap:3,itemAlign:"start",width:"100%",justify:"between",children:[jsxRuntime.jsxs(ui$1.Flex,{direction:"column",itemAlign:"start",justify:"between",className:"oui-h-full",children:[jsxRuntime.jsx(ui$1.Text,{className:"oui-text-lg md:oui-text-xl lg:oui-text-2xl xl:oui-text-3xl",children:e.isTrader?t("affiliate.trader"):t("affiliate.asTrader.title")}),jsxRuntime.jsx(ui$1.Text,{className:ui$1.cn("oui-text-xs oui-text-base-contrast-54 md:oui-text-sm 2xl:oui-text-base",e.isTrader&&"oui-hidden"),children:t("affiliate.asTrader.description")})]}),jsxRuntime.jsx("div",{className:"oui-shrink-0",children:jsxRuntime.jsx(In,{})})]}),jsxRuntime.jsx(kn,{...e})]})},In=()=>jsxRuntime.jsxs("svg",{width:"72",height:"72",viewBox:"0 0 90 90",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"xl:oui-size-[90px] ",children:[jsxRuntime.jsx("path",{d:"M44.996 7.324c-20.71 0-37.43 16.79-37.5 37.5-.07 20.682 16.806 37.575 37.5 37.617 20.694.04 37.537-17.082 37.5-37.617-.037-20.71-16.79-37.5-37.5-37.5m0 7.5c16.569 0 30 13.433 30 30 0 8.438-3.514 16.043-9.12 21.495-2.762-5.973-8.694-10.245-15.49-10.245h-10.78c-6.791 0-12.706 4.22-15.47 10.197-5.606-5.453-9.14-13.01-9.14-21.447 0-16.567 13.431-30 30-30m0 7.5c-8.284 0-15 6.717-15 15s6.716 15 15 15 15-6.716 15-15-6.716-15-15-15",fill:"#fff",fillOpacity:".2"}),jsxRuntime.jsx("path",{d:"M90 71.25C90 81.605 81.605 90 71.25 90S52.5 81.605 52.5 71.25 60.895 52.5 71.25 52.5 90 60.895 90 71.25",fill:"#005A4F"}),jsxRuntime.jsx("path",{d:"M80.62 75.007c0-.24-.08-.49-.263-.675l-3.487-3.456-1.318 1.318 1.845 1.875H63.745a.938.938 0 0 0 0 1.875h13.652l-1.845 1.875 1.318 1.318 3.487-3.456a.95.95 0 0 0 .263-.674m-.937-7.5a.94.94 0 0 0-.938-.938H65.093l1.846-1.875-1.319-1.318-3.486 3.456a.966.966 0 0 0 0 1.349l3.486 3.456 1.319-1.318-1.846-1.875h13.652c.518 0 .938-.42.938-.937",fill:"#fff",fillOpacity:".98"})]}),kn=e=>{let{t}=i18n.useTranslation();return jsxRuntime.jsx(ui$1.Flex,{direction:"row",justify:"between",width:"100%",itemAlign:"end",children:(()=>{if(e.isTrader&&!e.wrongNetwork){let n=e.referralInfo?.referee_info?.total_referee_rebate;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(ui$1.Flex,{direction:"column",itemAlign:"start",gap:2,children:[jsxRuntime.jsxs(ui$1.Text,{className:"oui-text-2xs md:oui-text-xs xl:oui-text-sm",children:[t("affiliate.commission")," ",jsxRuntime.jsx(ui$1.Text,{intensity:36,children:"(USDC)"})]}),jsxRuntime.jsxs(ui$1.Flex,{direction:"row",gap:1,children:[jsxRuntime.jsx(K,{}),jsxRuntime.jsx(ui$1.Text,{className:"oui-text-base md:oui-text-lg lg:oui-text-xl xl:oui-text-2xl",children:utils.commifyOptional(n,{fix:2,fallback:"0"})})]})]}),jsxRuntime.jsxs(ui$1.Flex,{direction:"row",gap:1,justify:"end",itemAlign:"center",className:"oui-cursor-pointer",onClick:e?.onEnterTraderPage,children:[jsxRuntime.jsx(ui$1.Text,{className:"oui-text-sm md:oui-text-base xl:oui-text-lg",children:t("affiliate.enter")}),jsxRuntime.jsx(ot,{className:"md:oui-size-[18px] lg:oui-size-[20px] xl:oui-size-[24px]"})]})]})}return jsxRuntime.jsx(Bn,{...e})})()})},Bn=e=>{let{t}=i18n.useTranslation();return jsxRuntime.jsxs(ui$1.Dialog,{open:e.open,onOpenChange:e.setOpen,children:[jsxRuntime.jsx(ui$1.DialogTrigger,{children:jsxRuntime.jsx(ui$1.Button,{variant:"contained",color:"light",children:t("affiliate.asTrader.button")})}),jsxRuntime.jsxs(ui$1.DialogContent,{className:"oui-w-[320px] oui-font-semibold",children:[jsxRuntime.jsx(ui$1.DialogHeader,{children:jsxRuntime.jsx(ui$1.DialogTitle,{children:t("affiliate.referralCode.dialog.title")})}),jsxRuntime.jsx(ui$1.Divider,{}),jsxRuntime.jsxs(ui$1.DialogBody,{children:[jsxRuntime.jsx(ui$1.Text,{size:"sm",intensity:54,children:t("affiliate.referralCode.dialog.description")}),jsxRuntime.jsx(ui$1.TextField,{className:"oui-mt-4 oui-w-full",placeholder:t("affiliate.referralCode"),value:e.code,onChange:r=>{let n=r.target.value.toUpperCase().replace(/[^A-Z0-9]/g,"");e.setCode(n);},formatters:[ui$1.inputFormatter.createRegexInputFormatter(r=>String(r).replace(/[a-z]/g,n=>n.toUpperCase())),ui$1.inputFormatter.createRegexInputFormatter(/[^A-Z0-9]/g)],onClean:()=>{e.setCode("");},label:t("affiliate.referralCode.label"),classNames:{label:"oui-text-2xs oui-text-base-contrast-54"},helpText:!e.isExist&&!e.isLoading&&e.code.length>0?t("affiliate.referralCode.notExist"):void 0,color:!e.isExist&&!e.isLoading&&e.code.length>0?"danger":void 0}),jsxRuntime.jsxs(ui$1.Flex,{direction:"column",gapY:3,mt:6,children:[e.warningMessage&&jsxRuntime.jsx(ui$1.Text,{size:"2xs",className:"oui-text-warning-darken",children:e.warningMessage}),jsxRuntime.jsx(uiConnector.AuthGuard,{buttonProps:{size:"md",fullWidth:true},children:jsxRuntime.jsx(ui$1.Button,{variant:"contained",color:"primary",size:"md",className:"oui-px-[40px]",fullWidth:true,disabled:e.code.length<4||!e.isExist,onClick:r=>{r.stopPropagation(),e.onClickConfirm();},children:t("common.confirm")})})]})]})]})]})};var tr=()=>{let{t:e}=i18n.useTranslation(),{isTrader:t,referralInfo:r,setShowHome:n,bindReferralCodeState:o,setTab:i,mutate:a}=y(),{wrongNetwork:f,disabledConnect:s}=reactApp.useAppContext(),{state:p}=hooks.useAccount(),m=()=>{i("trader"),n(false);},[u,l]=react.useState(""),[x,g]=react.useState(false),{isExist:d,error:c,isLoading:T}=hooks.useCheckReferralCode(u),H=()=>{g(false);},[ne,{error:z,isMutating:M}]=hooks.useMutation("/v1/referral/bind","POST"),D=async()=>{try{await ne({referral_code:u}),ui$1.toast.success(e("affiliate.referralCode.bound")),a(),o?o(!0,null,H,{tab:1}):H();}catch(X){let W=`${X}`;"message"in X&&(W=X.message),W==="referral code not exist"&&(W=e("affiliate.referralCode.notExist")),o?(ui$1.toast.error(W),o(false,X,H,{})):ui$1.toast.error(W);}},{isMobile:k}=ui$1.useScreen(),le=uiConnector.useAuthStatus(),de=react.useMemo(()=>({[uiConnector.AuthStatusEnum.ConnectWallet]:e("affiliate.connectWallet.tooltip"),[uiConnector.AuthStatusEnum.CreateAccount]:e("affiliate.createAccount.tooltip"),[uiConnector.AuthStatusEnum.WrongNetwork]:e("connector.wrongNetwork.tooltip")})[le],[le]);return {isTrader:t,isLoading:T,referralInfo:r,onEnterTraderPage:m,code:u,setCode:l,open:x,setOpen:g,onClickConfirm:D,isExist:d,wrongNetwork:f,isMobile:k,warningMessage:de}};var rr=()=>{let e=tr();return jsxRuntime.jsx(Jt,{...e})};var or=e=>{let{t}=i18n.useTranslation();return jsxRuntime.jsxs(ui$1.Flex,{id:"oui-affiliate-home-asAnAffiliate",gradient:"primary",r:"2xl",p:6,gap:6,direction:"column",angle:180,width:"100%",justify:"between",children:[jsxRuntime.jsxs(ui$1.Flex,{direction:"row",gap:3,itemAlign:"start",width:"100%",justify:"between",children:[jsxRuntime.jsxs(ui$1.Flex,{direction:"column",itemAlign:"start",justify:"between",className:"oui-h-full",children:[jsxRuntime.jsx(ui$1.Text,{className:"oui-text-lg md:oui-text-xl lg:oui-text-2xl xl:oui-text-3xl",children:e.isAffiliate?t("common.affiliate"):t("affiliate.asAffiliate.title")}),jsxRuntime.jsx(ui$1.Text,{className:ui$1.cn("oui-text-xs oui-text-base-contrast-54 md:oui-text-sm 2xl:oui-text-base",e.isAffiliate&&"oui-hidden"),children:t("affiliate.asAffiliate.description")})]}),jsxRuntime.jsx("div",{className:"oui-shrink-0",children:jsxRuntime.jsx(Xn,{})})]}),jsxRuntime.jsx(Kn,{...e})]})},Xn=()=>jsxRuntime.jsxs("svg",{width:"72",height:"72",viewBox:"0 0 72 72",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"xl:oui-size-[90px]",children:[jsxRuntime.jsx("path",{d:"M35.997 5.86c-16.569 0-29.944 13.43-30 30-.056 16.545 13.445 30.06 30 30.093s30.03-13.665 30-30.093c-.03-16.57-13.432-30-30-30m0 6c13.255 0 24 10.746 24 24 0 6.75-2.812 12.834-7.297 17.196-2.209-4.78-6.955-8.196-12.39-8.196h-8.626c-5.432 0-10.164 3.375-12.375 8.157-4.485-4.362-7.312-10.407-7.312-17.157 0-13.254 10.745-24 24-24m0 6c-6.628 0-12 5.373-12 12s5.372 12 12 12c6.627 0 12-5.373 12-12s-5.373-12-12-12",fill:"#fff",fillOpacity:".2"}),jsxRuntime.jsx("path",{d:"M72 57c0 8.284-6.716 15-15 15s-15-6.716-15-15 6.716-15 15-15 15 6.716 15 15",fill:"#1828C3"}),jsxRuntime.jsx("path",{d:"M53.624 51.45a4.125 4.125 0 0 0-4.125 4.125c0 2.388 1.36 4.641 3.61 6.703a21 21 0 0 0 2.414 1.875c.287.194.556.37.797.516.147.089.243.154.304.187a.79.79 0 0 0 .75 0c.061-.033.158-.098.305-.187.24-.147.51-.322.797-.516a21 21 0 0 0 2.414-1.875c2.25-2.062 3.61-4.315 3.61-6.703a4.125 4.125 0 0 0-4.126-4.125c-1.294 0-2.557.705-3.351 1.734-.775-1.047-2.034-1.734-3.399-1.734",fill:"#fff",fillOpacity:".98"})]}),Kn=e=>{let{t}=i18n.useTranslation();return jsxRuntime.jsx(ui$1.Flex,{direction:"row",justify:"between",width:"100%",itemAlign:"end",children:(()=>{if(e.isAffiliate&&!e.wrongNetwork){let n=e.referralInfo?.referrer_info?.total_referrer_rebate;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(ui$1.Flex,{direction:"column",itemAlign:"start",gap:2,children:[jsxRuntime.jsxs(ui$1.Text,{className:"oui-text-2xs md:oui-text-xs xl:oui-text-sm",children:[t("affiliate.commission")," ",jsxRuntime.jsx(ui$1.Text,{intensity:36,children:"(USDC)"})]}),jsxRuntime.jsxs(ui$1.Flex,{direction:"row",gap:1,children:[jsxRuntime.jsx(K,{}),jsxRuntime.jsx(ui$1.Text,{className:"oui-text-base md:oui-text-lg lg:oui-text-xl xl:oui-text-2xl",children:utils.commifyOptional(n,{fix:2,fallback:"0"})})]})]}),jsxRuntime.jsxs(ui$1.Flex,{direction:"row",gap:1,justify:"end",itemAlign:"center",className:"oui-cursor-pointer",onClick:e.onEnterAffiliatePage,children:[jsxRuntime.jsx(ui$1.Text,{className:"oui-text-sm md:oui-text-base xl:oui-text-lg",children:t("affiliate.enter")}),jsxRuntime.jsx(ot,{className:"md:oui-size-[18px] lg:oui-size-[20px] xl:oui-size-[24px]"})]})]})}return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ui$1.Button,{variant:"contained",color:"light",onClick:e.becomeAnAffiliate,children:t("affiliate.asAffiliate.button")}),jsxRuntime.jsxs(ui$1.Flex,{direction:"column",justify:"between",className:"oui-h-full",itemAlign:"end",children:[jsxRuntime.jsx(ui$1.Text,{className:"oui-text-base md:oui-text-lg lg:oui-text-xl 2xl:oui-text-2xl",children:t("affiliate.upTo")}),jsxRuntime.jsx(ui$1.Text,{className:"oui-text-2xs oui-text-base-contrast-54 md:oui-text-xs 2xl:oui-text-sm",children:t("affiliate.commission")})]})]})})()})};var ir=()=>{let{isAffiliate:e,isLoading:t,referralInfo:r,becomeAnAffiliateUrl:n,setShowHome:o,setTab:i}=y(),{wrongNetwork:a}=reactApp.useAppContext(),f=()=>{window.open(n,"_blank");},s=()=>{i("affiliate"),o(false);},{isMobile:p}=ui$1.useScreen();return {isAffiliate:e,isLoading:t,referralInfo:r,onEnterAffiliatePage:s,becomeAnAffiliate:f,wrongNetwork:a,isMobile:p}};var ar=()=>{let e=ir();return jsxRuntime.jsx(or,{...e})};var nr=e=>typeof e.overwrite=="function"?e.overwrite?.(e.state):jsxRuntime.jsxs(ui$1.Flex,{id:"oui-affiliate-home-card",className:"oui-flex oui-w-full oui-flex-col oui-items-stretch oui-gap-6 xl:oui-flex-row xl:oui-gap-[36px]",children:[jsxRuntime.jsx(ar,{}),jsxRuntime.jsx(rr,{})]});var lr=()=>{let e=y();return {overwrite:e.overwrite?.ref?.card,state:e}};var sr=()=>{let e=lr();return jsxRuntime.jsx(nr,{...e})};var Re=()=>jsxRuntime.jsxs(ui$1.Flex,{id:"oui-affiliate-home-page",className:ui$1.cn("oui-h-lvw ","oui-font-semibold"),direction:"column",gap:4,children:[jsxRuntime.jsx(Xt,{}),jsxRuntime.jsx(sr,{}),jsxRuntime.jsx(Et,{})]});var ur=e=>{let{t}=i18n.useTranslation();return jsxRuntime.jsxs(ui$1.Flex,{id:"oui-affiliate-trader-summary",r:"2xl",p:6,width:"100%",height:"100%",gap:4,direction:"column",className:"oui-bg-base-9 xl:oui-flex-1",children:[jsxRuntime.jsx(fl,{...e}),jsxRuntime.jsx(qo,{className:"md:oui-hidden",...e}),jsxRuntime.jsxs(ui$1.Flex,{direction:"column",gap:3,width:"100%",className:"md:oui-mt-3",children:[jsxRuntime.jsx(ul,{...e}),jsxRuntime.jsx(ml,{...e})]}),jsxRuntime.jsx(cl,{title:`${t("affiliate.trader.tradingVol")} (USDC)`,...e})]})},fl=e=>{let{t}=i18n.useTranslation();return jsxRuntime.jsxs(ui$1.Flex,{direction:"row",width:"100%",gap:3,children:[jsxRuntime.jsxs(ui$1.Flex,{direction:"row",gap:3,className:"oui-flex-1",children:[jsxRuntime.jsx(ui$1.Text,{className:"oui-text-lg",children:t("affiliate.trader.yourReferrer")}),jsxRuntime.jsx(ui$1.Button,{color:"secondary",size:"sm",className:"oui-text-primary-light oui-text-2xs md:oui-text-xs 2xl:oui-text-sm oui-bg-base-6",children:e.code})]}),jsxRuntime.jsx(qo,{className:"oui-hidden md:oui-flex md:oui-flex-shrink md:oui-w-fit",...e})]})},qo=e=>{let{t}=i18n.useTranslation();return jsxRuntime.jsxs(ui$1.Flex,{direction:"row",width:"100%",gap:2,className:e.className,children:[jsxRuntime.jsx(ui$1.Text,{intensity:54,className:"oui-text-sm md:oui-text-base 2xl:oui-text-lg",children:`${t("affiliate.trader.rebate")}:`}),jsxRuntime.jsx(ui$1.Text.gradient,{color:"brand",className:"oui-text-lg md:oui-text-xl 2xl:oui-text-2xl",children:e.rebateText})]})},ul=e=>{let{t}=i18n.useTranslation();return jsxRuntime.jsxs(ui$1.Flex,{direction:"row",width:"100%",justify:"between",gap:3,children:[jsxRuntime.jsx(ui$1.Text,{className:"oui-text-sm",children:t("affiliate.summary")}),jsxRuntime.jsx("div",{children:jsxRuntime.jsx(ui$1.Select.options,{size:"xs",value:e.period,onValueChange:e.onPeriodChange,options:e.periodTypes})})]})},ml=e=>{let{t}=i18n.useTranslation();return jsxRuntime.jsxs(ui$1.Flex,{gradient:"success",angle:180,r:"xl",py:4,px:6,width:"100%",direction:"column",gap:3,children:[jsxRuntime.jsx(ui$1.Text,{intensity:54,className:"oui-text-base 2xl:oui-text-lg",children:`${t("affiliate.trader.rebates")} (USDC)`}),jsxRuntime.jsxs(ui$1.Flex,{direction:"row",gap:3,className:"oui-text-xl md:oui-text-2xl xl:oui-text-3xl",children:[jsxRuntime.jsx(K,{className:"md:oui-w-[24px] md:oui-h-[24px] lg:oui-w-[28px] lg:oui-h-[28px] "}),jsxRuntime.jsx(ui$1.Text,{children:utils.commifyOptional(e.rebates,{fix:2,fallback:"0"})})]})]})},cl=e=>jsxRuntime.jsxs(ui$1.Flex,{direction:"row",justify:"between",width:"100%",children:[jsxRuntime.jsx(ui$1.Text,{intensity:54,className:"oui-text-2xs md:oui-text-xs xl:oui-text-sm",children:e.title}),jsxRuntime.jsx(ui$1.Text,{className:"oui-text-xs md:oui-text-sm xl:oui-text-base",children:utils.commifyOptional(e.vol,{fix:2,fallback:"0"})})]});var cr=()=>{let{t:e}=i18n.useTranslation(),[t,r]=react.useState("All"),n=[{label:e("common.all"),value:"All"},{label:e("common.select.1d"),value:"1D"},{label:e("common.select.7d"),value:"7D"},{label:e("common.select.30d"),value:"30D"}],{referralInfo:o,userVolume:i}=y(),a=react.useMemo(()=>{if(!o)return 0;switch(t){case "All":return o.referee_info.total_referee_rebate;case "1D":return o.referee_info["1d_referee_rebate"];case "7D":return o.referee_info["7d_referee_rebate"];case "30D":return o.referee_info["30d_referee_rebate"]}},[o,t]),f=react.useMemo(()=>{if(i)switch(t){case "All":return i.all_volume;case "1D":return i["1d_volume"];case "7D":return i["7d_volume"];case "30D":return i["30d_volume"]}},[i,t]),s=o?.referee_info?.referer_code,p=o?.referee_info?.referee_rebate_rate,m=react.useMemo(()=>p?new utils.Decimal(p).mul(100).toDecimalPlaces(2,utils.Decimal.ROUND_DOWN).toString()+"%":"-",[p]);return {period:t,periodTypes:n,onPeriodChange:l=>{r(l);},rebates:a,vol:f,rebateText:m,code:s}};var dr=()=>{let e=cr();return jsxRuntime.jsx(ur,{...e})};var pr=e=>jsxRuntime.jsxs(ui$1.Flex,{id:"oui-affiliate-trader-titleStatistic",r:"2xl",p:6,width:"100%",gap:4,direction:"column",className:"oui-bg-base-9 xl:oui-flex-1",children:[jsxRuntime.jsx(yl,{...e}),jsxRuntime.jsx(ui$1.Flex,{className:"oui-min-h-[170px] oui-h-full oui-w-full oui-flex oui-flex-row oui-items-stretch",children:jsxRuntime.jsx(chart.VolBarChart,{data:e.dataSource,colors:{fill:"rgba(0, 180, 158, 1)"},className:"oui-w-full oui-flex-1",tooltip:{rm:utils.Decimal.ROUND_DOWN,dp:e.volType==="volume"?2:6}})})]}),yl=e=>{let{t}=i18n.useTranslation();return jsxRuntime.jsxs(ui$1.Flex,{direction:"row",justify:"between",width:"100%",children:[jsxRuntime.jsx(ui$1.Text,{className:"oui-text-lg",children:t("affiliate.statistics")}),jsxRuntime.jsxs(ui$1.Flex,{direction:"row",gap:2,className:"oui-min-w-14",children:[jsxRuntime.jsx(ui$1.Select.options,{size:"xs",value:e.period,onValueChange:e.onPeriodChange,options:e.periodTypes}),jsxRuntime.jsx(ui$1.Select.options,{size:"xs",value:e.volType,onValueChange:e.onVolTypeChange,options:e.volTypes})]})]})};var gr=()=>{let{t:e}=i18n.useTranslation(),[t,r]=react.useState("7"),n=[{label:e("common.select.7d"),value:"7"},{label:e("common.select.30d"),value:"30"},{label:e("common.select.90d"),value:"90"}],o=d=>{r(d);},[i,a]=react.useState("rebate"),f=[{label:e("affiliate.trader.rebate"),value:"rebate"},{label:e("common.volume"),value:"volume"}],s=d=>{a(d);},p=react.useMemo(()=>t==="7"?{startDate:dateFns.subDays(new Date,7),endDate:dateFns.subDays(new Date,1)}:t==="30"?{startDate:dateFns.subDays(new Date,30),endDate:dateFns.subDays(new Date,1)}:t==="90"?{startDate:dateFns.subDays(new Date,90),endDate:dateFns.subDays(new Date,1)}:{startDate:dateFns.subDays(new Date,7),endDate:dateFns.subDays(new Date,1)},[t]),{data:m,mutate:u}=hooks.useRefereeRebateSummary(p),{dailyVolume:l,chartConfig:x}=y(),g=react.useMemo(()=>i==="rebate"?(m||[]).map(c=>({date:c.date,volume:c.referee_rebate})).reverse():i==="volume"?l?.filter(d=>d.date>dateFns.format(dateFns.subDays(Date(),Number(t)+1),"yyyy-MM-dd")).map(d=>({date:d.date,volume:d.perp_volume}))||[]:[],[m,l,i]);return {period:t,periodTypes:n,onPeriodChange:o,volType:i,volTypes:f,onVolTypeChange:s,dataSource:qe(Number(t),g)}};var hr=()=>{let e=gr();return jsxRuntime.jsx(pr,{...e})};var yr=e=>jsxRuntime.jsxs(ui$1.Flex,{id:"oui-affiliate-trader-rebates",r:"2xl",p:6,width:"100%",gap:4,direction:"column",className:"oui-bg-base-9 oui-tabular-nums",children:[jsxRuntime.jsx(_l,{...e}),jsxRuntime.jsx(ui$1.Flex,{width:"100%",className:"oui-border-y-2 oui-border-line-6",height:49,direction:"row",itemAlign:"center",children:jsxRuntime.jsx("div",{children:jsxRuntime.jsx(ui$1.DatePicker.range,{size:"xs",value:e.dateRange,onChange:t=>{e.setDateRange(t);},max:90,disabled:{after:new Date}})})}),jsxRuntime.jsx(Ml,{...e})]}),_l=e=>{let{t}=i18n.useTranslation();return jsxRuntime.jsxs(ui$1.Flex,{direction:"row",justify:"between",width:"100%",children:[jsxRuntime.jsx(ui$1.Text,{className:"oui-text-lg",children:t("affiliate.trader.myRebates")}),jsxRuntime.jsx(ui$1.Text,{intensity:36,className:"oui-text-2xs",children:e.displayDate})]})},Ml=e=>{let{t}=i18n.useTranslation(),r=hooks.useMediaQuery("(max-width: 767px)"),n=[{title:`${t("affiliate.trader.rebates")} (USDC)`,dataIndex:"referee_rebate",render:o=>jsxRuntime.jsx(ui$1.Text,{children:utils.commifyOptional(o,{fix:6,fallback:"0",padEnd:true,prefix:"$"})}),width:127},{title:`${t("affiliate.trader.tradingVol")} (USDC)`,dataIndex:"vol",render:o=>utils.commifyOptional(o,{fix:2,fallback:"0",padEnd:true,prefix:"$"}),width:127},{title:t("common.date"),dataIndex:"date",render:o=>jsxRuntime.jsx(ui$1.Text.formatted,{formatString:"yyyy-MM-dd",children:o}),width:127}];return r?jsxRuntime.jsx(ui$1.ListView,{dataSource:e.dataSource,className:"oui-h-[197px] oui-w-full",renderItem:(o,i)=>jsxRuntime.jsx(Ll,{item:o})}):jsxRuntime.jsx(uiConnector.AuthGuardDataTable,{bordered:true,loading:e.isLoading,columns:n,dataSource:e.dataSource,ignoreLoadingCheck:true,onRow:o=>({className:"oui-h-[41px]"}),pagination:e.pagination,manualPagination:false})},Ll=e=>{let{t}=i18n.useTranslation();return jsxRuntime.jsxs(ui$1.Flex,{direction:"column",width:"100%",children:[jsxRuntime.jsxs(ui$1.Flex,{width:"100%",gap:1,children:[jsxRuntime.jsx(ui$1.Statistic,{label:`${t("affiliate.trader.rebates")} (USDC)`,className:"oui-text-xs oui-text-base-contrast-54 oui-flex-1 oui-min-w-[105px]",children:jsxRuntime.jsx(ui$1.Text,{size:"sm",intensity:80,children:utils.commifyOptional(e.item.referee_rebate,{fix:6,fallback:"0",padEnd:true,prefix:"$"})})}),jsxRuntime.jsx(ui$1.Statistic,{label:`${t("affiliate.trader.tradingVol")} (USDC)`,className:"oui-text-xs oui-text-base-contrast-54 oui-flex-shrink",children:jsxRuntime.jsx(ui$1.Text,{size:"sm",intensity:80,children:utils.commifyOptional(e.item.vol,{fix:2,fallback:"0",padEnd:true,prefix:"$"})})}),jsxRuntime.jsx(ui$1.Statistic,{label:t("common.date"),className:"oui-text-xs oui-text-base-contrast-54 oui-flex-1",align:"end",children:jsxRuntime.jsx(ui$1.Text.formatted,{size:"sm",intensity:80,formatString:"yyyy-MM-dd",children:e.item.date})})]}),jsxRuntime.jsx(ui$1.Divider,{className:"oui-w-full oui-mt-3"})]})};var wr=()=>{let[e,t]=react.useState({from:dateFns.subDays(new Date,90),to:dateFns.subDays(new Date,1)}),{data:r,mutate:n,isLoading:o}=hooks.useRefereeRebateSummary({startDate:e?.from,endDate:e?.to}),{data:i,mutate:a}=hooks.useDaily({startDate:e?.to,endDate:e?.from}),f=react.useMemo(()=>typeof r>"u"?[]:r.map(u=>{let l=u.date,x=i?.filter(g=>Zr(dateFns.toDate(l),dateFns.toDate(g.date)))?.[0];return x?{...u,vol:x.perp_volume}:u}),[r,i]),s;(f?.length||0)>0&&(s=qr(f?.[0].date));let{pagination:p,setPage:m}=ui$1.usePagination();return react.useEffect(()=>{m(1);},[e]),{dateRange:e,setDateRange:t,displayDate:s,dataSource:f,pagination:p,isLoading:o}};var vr=()=>{let e=wr();return jsxRuntime.jsx(yr,{...e})};var Ie=()=>jsxRuntime.jsxs(ui$1.Flex,{id:"oui-affiliate-trader-page",className:ui$1.cn("oui-h-lvw oui-w-full","oui-font-semibold"),direction:"column",gap:4,children:[jsxRuntime.jsxs(ui$1.Flex,{width:"100%",gap:4,className:"oui-flex oui-flex-col xl:oui-flex-row xl:oui-items-stretch",children:[jsxRuntime.jsx(dr,{}),jsxRuntime.jsx(hr,{})]}),jsxRuntime.jsx(vr,{})]});var Tr=e=>{let{t}=i18n.useTranslation(),r=()=>{if(e.isAffiliate&&!e.isTrader)return jsxRuntime.jsxs(ui$1.Button,{variant:"contained",color:"success",size:"sm",className:"oui-px-2 oui-flex oui-gap-1",style:{position:"absolute",top:"50%",right:"24px",transform:"translateY(-50%)"},onClick:n=>{e.anATrader();},children:[jsxRuntime.jsx(dt,{}),jsxRuntime.jsx(ui$1.Text,{children:t("affiliate.asTrader.title")})]});if(!e.isAffiliate&&e.isTrader)return jsxRuntime.jsxs(ui$1.Button,{variant:"contained",color:"primary",size:"sm",className:"oui-px-2 oui-flex oui-gap-1",style:{position:"absolute",top:"50%",right:"24px",transform:"translateY(-50%)"},onClick:n=>{e.anAnAffiliate();},children:[jsxRuntime.jsx(mt,{}),jsxRuntime.jsx(ui$1.Text,{children:t("affiliate.asAffiliate.title")})]})};return e.isLoading?jsxRuntime.jsx("div",{className:ui$1.cn("oui-max-w-[960px]",e.classNames?.loadding),children:e.splashPage?.()||jsxRuntime.jsx(Re,{})}):!e.isAffiliate&&!e.isTrader||e.showHome?jsxRuntime.jsx("div",{className:ui$1.cn("oui-max-w-[960px]",e?.classNames?.home),children:jsxRuntime.jsx(Re,{})}):jsxRuntime.jsxs(ui$1.TabsBase,{id:"oui-affiliate-dashboard-tab",value:e.tab,onValueChange:n=>{e.setTab(n);},className:ui$1.cn("oui-w-full",e.classNames?.dashboard),children:[jsxRuntime.jsxs(ui$1.TabsList,{className:ui$1.cn("oui-px-6 oui-flex oui-flex-row oui-justify-start oui-h-[44px] oui-relative oui-items-end","oui-text-base md:oui-text-lg","oui-rounded-xl oui-bg-base-9","oui-border oui-border-line-6",e.isAffiliate&&e.isTrader&&"oui-justify-center"),children:[e.isAffiliate&&jsxRuntime.jsx(ui$1.TabsTrigger,{id:"oui-affiliate-dashboard-tab-affiliate",value:"affiliate",children:jsxRuntime.jsxs(ui$1.Flex,{direction:"row",gap:1,mb:2,children:[jsxRuntime.jsx(mt,{fillOpacity:1,fill:"currentColor",className:e.tab==="affiliate"?"oui-fill-white/[.98]":"oui-fill-white/[.36]"}),jsxRuntime.jsx(ui$1.Text,{children:t("common.affiliate")})]})}),e.isTrader&&jsxRuntime.jsx(ui$1.TabsTrigger,{id:"oui-affiliate-dashboard-tab-trader",value:"trader",children:jsxRuntime.jsxs(ui$1.Flex,{direction:"row",gap:1,mb:2,children:[jsxRuntime.jsx(dt,{fillOpacity:1,fill:"currentColor",className:e.tab==="trader"?"oui-fill-white/[.98]":"oui-fill-white/[.36]"}),jsxRuntime.jsx(ui$1.Text,{children:t("affiliate.trader")})]})}),r()]}),e.isAffiliate&&jsxRuntime.jsx(ui$1.TabsContent,{value:"affiliate",className:"oui-mt-4",children:jsxRuntime.jsx(Me,{})}),e.isTrader&&jsxRuntime.jsx(ui$1.TabsContent,{value:"trader",className:"oui-mt-4",children:jsxRuntime.jsx(Ie,{})})]})};var Sr=()=>{let{isAffiliate:e,isTrader:t,isLoading:r,splashPage:n,showHome:o,setShowHome:i,tab:a,setTab:f}=y(),[s,p]=hooks.useLocalStorage("orderly_affiliate_dashboard_tab","affiliate"),m=()=>{let T=(typeof window<"u"?new URLSearchParams(window.location.search).get("tab"):null)||s||a;return e&&t?T||"affiliate":e&&!t?"affiliate":!e&&t?"trader":"affiliate"},[u,l]=react.useState(m());return react.useEffect(()=>{if(r)return;let c=m(),T=typeof window<"u"?new URLSearchParams(window.location.search).get("tab"):null;c!==u&&(l(c),f(c)),(T||s!==c)&&p(c);},[e,t,r,s]),{setTab:c=>{l(typeof c=="function"?c(u):c),f(c);let T=typeof c=="function"?c(u):c;p(T);},tab:u,isAffiliate:e,isTrader:t,isLoading:r,anAnAffiliate:()=>{i(true);},anATrader:()=>{i(true);},splashPage:n,showHome:o,setShowHome:i}};var Nr=e=>{let t=Sr();return jsxRuntime.jsx(Tr,{classNames:e.classNames,...t})};var ai=e=>{let{classNames:t={}}=e,{root:r,...n}=t;return jsxRuntime.jsx("div",{id:"oui-affiliate-dashboard-page",className:ui$1.cn("oui-w-full oui-tracking-tight",r),children:jsxRuntime.jsx(Nr,{classNames:n})})};var si=e=>{let{...t}=e;return jsxRuntime.jsx(uiScaffold.Scaffold,{leftSidebar:jsxRuntime.jsx(Kl,{...t}),children:jsxRuntime.jsx(ui$1.Box,{mx:3,my:6,children:e.children})})},Kl=e=>jsxRuntime.jsx(ui$1.Box,{p:4,m:3,border:true,borderColor:8,r:"xl",children:jsxRuntime.jsx(uiScaffold.SideBar,{...e})});var ui=()=>{let[e,t]=react.useState("/"),{t:r}=i18n.useTranslation();return {items:react.useMemo(()=>[{name:r("common.trading"),href:"/",icon:jsxRuntime.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsx("path",{d:"M4.883 1.5c-.166.01-.393.076-.515.173a2 2 0 0 0-.18.173L.918 6.553a.86.86 0 0 0-.168.475c0 .339.232.543.232.543l7.374 8.633c.005.006.269.301.644.296s.64-.29.644-.296l7.402-8.663s.204-.269.204-.513-.196-.517-.196-.517L13.82 1.848c-.023-.032-.076-.021-.103-.049-.033-.038-.037-.091-.077-.124-.123-.097-.267-.106-.413-.123-.04-.005-.063-.049-.103-.049h-.078zm1.745 1.582h4.744L9 5.795zm-1.675.542 2.294 2.615H3.122zm8.094 0 1.831 2.615h-4.125zM3.328 7.818h4.847v5.672zm6.497 0h4.847c-1.151 1.345-3.422 4.007-4.847 5.672z",fill:"url(#a)"}),jsxRuntime.jsx("defs",{children:jsxRuntime.jsxs("linearGradient",{id:"a",x1:"17.25",y1:"9",x2:".75",y2:"9",gradientUnits:"userSpaceOnUse",children:[jsxRuntime.jsx("stop",{stopColor:"rgb(var(--oui-gradient-brand-end))"}),jsxRuntime.jsx("stop",{offset:"1",stopColor:"rgb(var(--oui-gradient-brand-start))"})]})})]})},{name:r("common.affiliate"),href:"/affiliate",icon:jsxRuntime.jsx("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.625 4.95c0-.746.604-1.35 1.35-1.35h4.05c.746 0 1.35.604 1.35 1.35v4.62L9 12.195 5.625 9.57zm8.624 3.163-.524.407v-.96l.074.05c.193.128.346.302.45.502m-4.42 5.148L14.4 9.705v3.345a1.35 1.35 0 0 1-1.35 1.35h-8.1a1.35 1.35 0 0 1-1.35-1.35V9.705l4.571 3.556c.488.379 1.17.379 1.658 0M4.275 8.52l-.524-.407c.104-.2.257-.374.45-.503l.074-.049zm0-2.581V4.95a2.7 2.7 0 0 1 2.7-2.7h4.05a2.7 2.7 0 0 1 2.7 2.7v.989l.823.548a2.7 2.7 0 0 1 1.202 2.247v4.316a2.7 2.7 0 0 1-2.7 2.7h-8.1a2.7 2.7 0 0 1-2.7-2.7V8.734a2.7 2.7 0 0 1 1.202-2.247zM9 6.089l.111-.118.005-.005a1.08 1.08 0 0 1 1.58.004 1.223 1.223 0 0 1 0 1.668l-1.515 1.62-.004.004c-.1.102-.26.1-.358-.004l-1.516-1.62a1.223 1.223 0 0 1 0-1.668l.004-.004a1.08 1.08 0 0 1 1.58.004z",fill:"#fff",fillOpacity:".54"})})}],[r]),current:e,onItemSelect:o=>{t(o.href);}}};var ts=e=>{let t=ui();return jsxRuntime.jsx(si,{...t,children:e.children})};
16
+ var __defProp = Object.defineProperty;
17
+ var __export = (target, all) => {
18
+ for (var name in all)
19
+ __defProp(target, name, { get: all[name], enumerable: true });
20
+ };
17
21
 
18
- exports.AffiliateLayoutWidget = ts;
19
- exports.Dashboard = ni;
20
- exports.ReferralContext = xt;
21
- exports.ReferralProvider = Rs;
22
- exports.TabTypes = xe;
23
- exports.useReferralContext = y;
22
+ // src/pages/dashboard/index.tsx
23
+ var dashboard_exports = {};
24
+ __export(dashboard_exports, {
25
+ AffiliatePage: () => AffiliatePage,
26
+ DashboardPage: () => DashboardPage,
27
+ HomePage: () => HomePage,
28
+ TraderPage: () => TraderPage
29
+ });
30
+ var AffiliateIcon = (props) => {
31
+ const { size = 16, className, ...rest } = props;
32
+ return /* @__PURE__ */ jsxRuntime.jsxs(
33
+ "svg",
34
+ {
35
+ width: size,
36
+ height: size,
37
+ viewBox: "0 0 16 16",
38
+ fill: "#fff",
39
+ fillOpacity: ".98",
40
+ xmlns: "http://www.w3.org/2000/svg",
41
+ className: props.className,
42
+ ...rest,
43
+ children: [
44
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M8 1.302c-3.683 0-6.655 2.985-6.667 6.667-.013 3.676 2.987 6.68 6.666 6.687s6.674-3.037 6.667-6.687c-.007-3.682-2.985-6.667-6.667-6.667m0 1.333a5.333 5.333 0 0 1 5.333 5.334c0 1.5-.625 2.852-1.622 3.821-.49-1.062-1.545-1.821-2.753-1.821H7.04c-1.207 0-2.259.75-2.75 1.812A5.3 5.3 0 0 1 2.666 7.97a5.333 5.333 0 0 1 5.333-5.334M8 3.97a2.667 2.667 0 1 0 0 5.333A2.667 2.667 0 0 0 8 3.97" }),
45
+ /* @__PURE__ */ jsxRuntime.jsx(
46
+ "path",
47
+ {
48
+ d: "M16 12.667a3.333 3.333 0 1 1-6.667 0 3.333 3.333 0 0 1 6.667 0",
49
+ fill: "#1828C3"
50
+ }
51
+ ),
52
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M11.917 11.433a.917.917 0 0 0-.917.917c0 .53.302 1.031.802 1.49a4.6 4.6 0 0 0 .713.53l.068.043c.05.027.117.027.167 0l.068-.042q.08-.05.177-.115c.182-.123.366-.26.536-.416.5-.459.802-.96.802-1.49a.917.917 0 0 0-.917-.917.97.97 0 0 0-.744.386.95.95 0 0 0-.756-.386" })
53
+ ]
54
+ }
55
+ );
56
+ };
57
+ var TraderIcon = (props) => {
58
+ const { size = 16, className, ...rest } = props;
59
+ return /* @__PURE__ */ jsxRuntime.jsxs(
60
+ "svg",
61
+ {
62
+ width: size,
63
+ height: size,
64
+ viewBox: "0 0 16 16",
65
+ fill: "white",
66
+ fillOpacity: "0.36",
67
+ xmlns: "http://www.w3.org/2000/svg",
68
+ className: props.className,
69
+ ...rest,
70
+ children: [
71
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M7.99929 1.30212C4.31735 1.30212 1.34509 4.28679 1.33262 7.96878C1.32015 11.6454 4.32042 14.6488 7.99929 14.6561C11.6782 14.6634 14.6726 11.6194 14.666 7.96878C14.6593 4.28679 11.6812 1.30212 7.99929 1.30212ZM7.99929 2.63546C10.9448 2.63546 13.3326 5.02345 13.3326 7.96878C13.3326 9.46878 12.7078 10.8208 11.7112 11.7901C11.2202 10.7281 10.1656 9.96878 8.95762 9.96878C8.71802 9.96878 7.28042 9.96878 7.04095 9.96878C5.83369 9.96878 4.78215 10.7188 4.29095 11.7814C3.29429 10.8121 2.66595 9.46878 2.66595 7.96878C2.66595 5.02345 5.05375 2.63546 7.99929 2.63546ZM7.99929 3.96879C6.52649 3.96879 5.33255 5.16279 5.33262 6.63545C5.33262 8.10812 6.52649 9.30212 7.99929 9.30212C9.47202 9.30212 10.666 8.10812 10.666 6.63545C10.666 5.16279 9.47202 3.96879 7.99929 3.96879Z" }),
72
+ /* @__PURE__ */ jsxRuntime.jsx(
73
+ "path",
74
+ {
75
+ d: "M16 12.6667C16 14.5076 14.5076 16 12.6666 16C10.8257 16 9.33331 14.5076 9.33331 12.6667C9.33331 10.8257 10.8257 9.33333 12.6666 9.33333C14.5076 9.33333 16 10.8257 16 12.6667Z",
76
+ fill: "#005A4F"
77
+ }
78
+ ),
79
+ /* @__PURE__ */ jsxRuntime.jsx(
80
+ "path",
81
+ {
82
+ d: "M14.3325 13.3345C14.3325 13.2918 14.3182 13.2473 14.2857 13.2147L13.6658 12.6002L13.4315 12.8345L13.7595 13.1678H11.3325C11.2405 13.1678 11.1658 13.2425 11.1658 13.3345C11.1658 13.4265 11.2405 13.5012 11.3325 13.5012H13.7595L13.4315 13.8345L13.6658 14.0688L14.2857 13.4543C14.3182 13.4217 14.3325 13.3772 14.3325 13.3345ZM14.1658 12.0012C14.1658 11.9092 14.0912 11.8345 13.9992 11.8345H11.572L11.9002 11.5012L11.6658 11.2668L11.046 11.8813C10.981 11.9465 10.981 12.0558 11.046 12.121L11.6658 12.7355L11.9002 12.5012L11.572 12.1678H13.9992C14.0912 12.1678 14.1658 12.0932 14.1658 12.0012Z",
83
+ fill: "white",
84
+ fillOpacity: "0.98"
85
+ }
86
+ )
87
+ ]
88
+ }
89
+ );
90
+ };
91
+ var TabTypes = /* @__PURE__ */ ((TabTypes2) => {
92
+ TabTypes2["affiliate"] = "affiliate";
93
+ TabTypes2["trader"] = "trader";
94
+ return TabTypes2;
95
+ })(TabTypes || {});
96
+ var ReferralContext = react.createContext(
97
+ {}
98
+ );
99
+ var useReferralContext = () => {
100
+ return react.useContext(ReferralContext);
101
+ };
102
+ var ReferralProvider = (props) => {
103
+ const {
104
+ becomeAnAffiliateUrl = "https://orderly.network/",
105
+ learnAffiliateUrl = "https://orderly.network/",
106
+ referralLinkUrl = "https://orderly.network/",
107
+ chartConfig,
108
+ overwrite,
109
+ children,
110
+ splashPage,
111
+ onBecomeAnAffiliate,
112
+ bindReferralCodeState,
113
+ onLearnAffiliate,
114
+ showReferralPage
115
+ } = props;
116
+ const { state } = hooks.useAccount();
117
+ const {
118
+ data,
119
+ mutate: referralInfoMutate,
120
+ isLoading
121
+ } = hooks.usePrivateQuery("/v1/referral/info", {
122
+ revalidateOnFocus: true,
123
+ errorRetryCount: 3,
124
+ ...hooks.noCacheConfig
125
+ });
126
+ const { data: generateCode, mutate: generateCodeMutate } = hooks.usePrivateQuery(
127
+ "/v1/referral/auto_referral/progress",
128
+ {
129
+ revalidateOnFocus: true,
130
+ errorRetryCount: 2,
131
+ formatter: (data2) => {
132
+ return {
133
+ code: data2.auto_referral_code,
134
+ requireVolume: data2.required_volume,
135
+ completedVolume: data2.completed_volume
136
+ };
137
+ }
138
+ }
139
+ );
140
+ const [showHome, setShowHome] = react.useState(isLoading);
141
+ react.useEffect(() => {
142
+ setShowHome(true);
143
+ }, [isLoading]);
144
+ const { data: dailyVolume, mutate: dailyVolumeMutate } = hooks.useDaily({
145
+ startDate: dateFns.subDays(/* @__PURE__ */ new Date(), 1),
146
+ endDate: dateFns.subDays(/* @__PURE__ */ new Date(), 90)
147
+ });
148
+ const { data: volumeStatistics, mutate: volumeStatisticsMutate } = hooks.usePrivateQuery("/v1/volume/user/stats", {
149
+ revalidateOnFocus: true
150
+ });
151
+ const isAffiliate = react.useMemo(() => {
152
+ return (data?.referrer_info?.referral_codes?.length || 0) > 0;
153
+ }, [data?.referrer_info]);
154
+ const isTrader = react.useMemo(() => {
155
+ return (data?.referee_info?.referer_code?.length || 0) > 0;
156
+ }, [data?.referee_info]);
157
+ const userVolume = react.useMemo(() => {
158
+ const volume = {};
159
+ if (dailyVolume && dailyVolume.length > 0) {
160
+ const now = dateFns.format(/* @__PURE__ */ new Date(), "yyyy-MM-dd");
161
+ const index = dailyVolume.findIndex((item) => item.date === now);
162
+ let oneDayVolume = 0;
163
+ if (index !== -1) {
164
+ oneDayVolume = dailyVolume[index].perp_volume;
165
+ }
166
+ volume["1d_volume"] = oneDayVolume;
167
+ }
168
+ if (volumeStatistics) {
169
+ volume["7d_volume"] = volumeStatistics.perp_volume_last_7_days;
170
+ volume["30d_volume"] = volumeStatistics.perp_volume_last_30_days;
171
+ volume["all_volume"] = volumeStatistics.perp_volume_ltd;
172
+ }
173
+ return volume;
174
+ }, [dailyVolume, volumeStatistics]);
175
+ react.useEffect(() => {
176
+ if (isAffiliate || isTrader) {
177
+ setShowHome(false);
178
+ }
179
+ }, [isAffiliate, isTrader]);
180
+ const memoMutate = hooks.useMemoizedFn(() => {
181
+ volumeStatisticsMutate();
182
+ dailyVolumeMutate();
183
+ referralInfoMutate();
184
+ generateCodeMutate();
185
+ });
186
+ react.useEffect(() => {
187
+ const searchParams = new URLSearchParams(window.location.search);
188
+ const refCode = searchParams.get("ref");
189
+ if (refCode) {
190
+ localStorage.setItem("referral_code", refCode);
191
+ }
192
+ }, []);
193
+ const [tab, setTab] = react.useState(() => {
194
+ const savedTab = localStorage.getItem("orderly_affiliate_dashboard_tab");
195
+ return savedTab || "affiliate" /* affiliate */;
196
+ });
197
+ react.useEffect(() => {
198
+ localStorage.setItem("orderly_affiliate_dashboard_tab", tab);
199
+ }, [tab]);
200
+ const { wrongNetwork, disabledConnect } = reactApp.useAppContext();
201
+ const lastStete = react.useRef(types.AccountStatusEnum.NotConnected);
202
+ const timerRef = react.useRef(null);
203
+ react.useEffect(() => {
204
+ if (lastStete.current !== state.status) {
205
+ lastStete.current = state.status;
206
+ timerRef.current = setTimeout(() => {
207
+ memoMutate();
208
+ }, 1e3);
209
+ }
210
+ return () => {
211
+ if (timerRef.current) {
212
+ clearTimeout(timerRef.current);
213
+ }
214
+ };
215
+ }, [memoMutate, state.status]);
216
+ const memoizedValue = react.useMemo(() => {
217
+ return {
218
+ generateCode,
219
+ showHome,
220
+ referralInfo: data,
221
+ isAffiliate,
222
+ isTrader,
223
+ tab,
224
+ becomeAnAffiliateUrl,
225
+ learnAffiliateUrl,
226
+ referralLinkUrl,
227
+ userVolume,
228
+ dailyVolume,
229
+ chartConfig,
230
+ overwrite,
231
+ isLoading,
232
+ wrongNetwork,
233
+ disabledConnect,
234
+ setShowHome,
235
+ setTab,
236
+ mutate: memoMutate,
237
+ onBecomeAnAffiliate,
238
+ bindReferralCodeState,
239
+ onLearnAffiliate,
240
+ showReferralPage,
241
+ splashPage
242
+ };
243
+ }, [
244
+ becomeAnAffiliateUrl,
245
+ chartConfig,
246
+ dailyVolume,
247
+ data,
248
+ disabledConnect,
249
+ generateCode,
250
+ isAffiliate,
251
+ isLoading,
252
+ isTrader,
253
+ learnAffiliateUrl,
254
+ overwrite,
255
+ referralLinkUrl,
256
+ showHome,
257
+ tab,
258
+ userVolume,
259
+ wrongNetwork,
260
+ onBecomeAnAffiliate,
261
+ bindReferralCodeState,
262
+ onLearnAffiliate,
263
+ showReferralPage,
264
+ splashPage,
265
+ memoMutate
266
+ ]);
267
+ return /* @__PURE__ */ jsxRuntime.jsx(ReferralContext.Provider, { value: memoizedValue, children });
268
+ };
269
+ var USDCIcon = (props) => {
270
+ return /* @__PURE__ */ jsxRuntime.jsxs(
271
+ "svg",
272
+ {
273
+ width: "21",
274
+ height: "20",
275
+ viewBox: "0 0 21 20",
276
+ fill: "none",
277
+ xmlns: "http://www.w3.org/2000/svg",
278
+ className: props.className,
279
+ children: [
280
+ /* @__PURE__ */ jsxRuntime.jsxs("g", { clipPath: "url(#a)", children: [
281
+ /* @__PURE__ */ jsxRuntime.jsx(
282
+ "path",
283
+ {
284
+ d: "M10.5 20c5.542 0 10-4.458 10-10s-4.458-10-10-10S.5 4.458.5 10s4.458 10 10 10",
285
+ fill: "#2775CA"
286
+ }
287
+ ),
288
+ /* @__PURE__ */ jsxRuntime.jsx(
289
+ "path",
290
+ {
291
+ d: "M13.5 11.473c0-1.452-.94-1.95-2.82-2.158-1.344-.166-1.613-.498-1.613-1.078s.448-.955 1.343-.955c.806 0 1.254.25 1.478.872.045.124.18.207.313.207h.717c.179 0 .313-.125.313-.29v-.042c-.179-.913-.985-1.618-2.015-1.701v-.996c0-.166-.134-.29-.358-.332h-.671c-.18 0-.314.124-.359.332v.954c-1.343.166-2.194.996-2.194 2.034 0 1.369.896 1.908 2.776 2.116 1.254.207 1.657.456 1.657 1.12s-.627 1.12-1.477 1.12c-1.165 0-1.568-.456-1.702-1.078a.32.32 0 0 0-.313-.25h-.762c-.179 0-.313.125-.313.291v.042c.179 1.037.895 1.784 2.373 1.991v.996c0 .166.134.29.358.332h.672c.18 0 .313-.124.358-.332v-.996c1.344-.207 2.239-1.079 2.239-2.199",
292
+ fill: "#fff",
293
+ fillOpacity: ".98"
294
+ }
295
+ ),
296
+ /* @__PURE__ */ jsxRuntime.jsx(
297
+ "path",
298
+ {
299
+ d: "M8.24 16.57c-3.458-1.215-5.23-4.986-3.945-8.324.665-1.821 2.127-3.208 3.944-3.859.178-.086.266-.216.266-.433v-.607c0-.174-.088-.304-.266-.347-.044 0-.133 0-.177.043-4.21 1.3-6.516 5.68-5.186 9.798.798 2.428 2.704 4.292 5.186 5.072.177.087.355 0 .4-.173.043-.043.043-.087.043-.173v-.608c0-.13-.133-.303-.266-.39m4.698-13.527c-.178-.086-.355 0-.4.174-.043.043-.043.086-.043.173v.607c0 .174.133.347.266.434 3.457 1.213 5.23 4.985 3.944 8.323-.664 1.821-2.127 3.209-3.944 3.859-.178.086-.266.216-.266.433v.607c0 .174.088.304.266.347.044 0 .133 0 .177-.043 4.21-1.3 6.515-5.68 5.186-9.798-.798-2.471-2.748-4.335-5.186-5.116",
300
+ fill: "#fff",
301
+ fillOpacity: ".98"
302
+ }
303
+ )
304
+ ] }),
305
+ /* @__PURE__ */ jsxRuntime.jsx("defs", { children: /* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "a", children: /* @__PURE__ */ jsxRuntime.jsx("path", { fill: "#fff", d: "M.5 0h20v20H.5z" }) }) })
306
+ ]
307
+ }
308
+ );
309
+ };
310
+ var Summary = (props) => {
311
+ const { t } = i18n.useTranslation();
312
+ return /* @__PURE__ */ jsxRuntime.jsxs(
313
+ ui.Flex,
314
+ {
315
+ id: "oui-affiliate-affiliate-summary",
316
+ r: "2xl",
317
+ p: 6,
318
+ width: "100%",
319
+ height: "100%",
320
+ gap: 4,
321
+ direction: "column",
322
+ className: "oui-bg-base-9",
323
+ children: [
324
+ /* @__PURE__ */ jsxRuntime.jsx(Title, { ...props }),
325
+ /* @__PURE__ */ jsxRuntime.jsx(CommissionData, { ...props }),
326
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "column", width: "100%", gap: 2, children: [
327
+ /* @__PURE__ */ jsxRuntime.jsx(
328
+ Row,
329
+ {
330
+ title: `${t("affiliate.referralVol")} (USDC)`,
331
+ value: props.referralVol,
332
+ dp: 2,
333
+ ...props
334
+ }
335
+ ),
336
+ /* @__PURE__ */ jsxRuntime.jsx(
337
+ Row,
338
+ {
339
+ title: t("affiliate.referees"),
340
+ value: props.referees,
341
+ dp: 0,
342
+ ...props
343
+ }
344
+ ),
345
+ /* @__PURE__ */ jsxRuntime.jsx(
346
+ Row,
347
+ {
348
+ title: t("affiliate.summary.refereesTraded"),
349
+ value: props.refereesTades,
350
+ dp: 0,
351
+ ...props
352
+ }
353
+ )
354
+ ] })
355
+ ]
356
+ }
357
+ );
358
+ };
359
+ var Title = (props) => {
360
+ const { t } = i18n.useTranslation();
361
+ return /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "row", justify: "between", width: "100%", children: [
362
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "oui-text-lg", children: t("affiliate.summary") }),
363
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-min-w-14", children: /* @__PURE__ */ jsxRuntime.jsx(
364
+ ui.Select.options,
365
+ {
366
+ size: "xs",
367
+ value: props.period,
368
+ onValueChange: props.onPeriodChange,
369
+ options: props.periodTypes
370
+ }
371
+ ) })
372
+ ] });
373
+ };
374
+ var CommissionData = (props) => {
375
+ const { t } = i18n.useTranslation();
376
+ return /* @__PURE__ */ jsxRuntime.jsxs(
377
+ ui.Flex,
378
+ {
379
+ gradient: "primary",
380
+ angle: 180,
381
+ r: "xl",
382
+ py: 4,
383
+ px: 6,
384
+ width: "100%",
385
+ direction: "column",
386
+ gap: 3,
387
+ height: "100%",
388
+ className: "oui-max-h-[104px]",
389
+ children: [
390
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { intensity: 54, className: "oui-text-base 2xl:oui-text-lg", children: `${t("affiliate.commission")} (USDC)` }),
391
+ /* @__PURE__ */ jsxRuntime.jsxs(
392
+ ui.Flex,
393
+ {
394
+ direction: "row",
395
+ gap: 3,
396
+ className: "oui-text-xl md:oui-text-2xl xl:oui-text-3xl",
397
+ children: [
398
+ /* @__PURE__ */ jsxRuntime.jsx(USDCIcon, { className: "md:oui-w-[24px] md:oui-h-[24px] lg:oui-w-[28px] lg:oui-h-[28px] " }),
399
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: utils.commifyOptional(props.commission, { fix: 2, fallback: "0" }) })
400
+ ]
401
+ }
402
+ )
403
+ ]
404
+ }
405
+ );
406
+ };
407
+ var Row = (props) => {
408
+ return /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "row", justify: "between", width: "100%", children: [
409
+ /* @__PURE__ */ jsxRuntime.jsx(
410
+ ui.Text,
411
+ {
412
+ intensity: 54,
413
+ className: "oui-text-2xs md:oui-text-xs xl:oui-text-sm",
414
+ children: props.title
415
+ }
416
+ ),
417
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "oui-text-xs md:oui-text-sm xl:oui-text-base", children: utils.commifyOptional(props.value, { fix: props.dp, fallback: "0" }) })
418
+ ] });
419
+ };
420
+ var useSummaryScript = () => {
421
+ const { t } = i18n.useTranslation();
422
+ const [period, setPeriod] = react.useState("All");
423
+ const periodTypes = [
424
+ { label: t("common.all"), value: "All" },
425
+ { label: t("common.select.1d"), value: "1D" },
426
+ { label: t("common.select.7d"), value: "7D" },
427
+ { label: t("common.select.30d"), value: "30D" }
428
+ ];
429
+ const { referralInfo } = useReferralContext();
430
+ const commission = react.useMemo(() => {
431
+ if (!referralInfo || !referralInfo.referrer_info) {
432
+ return 0;
433
+ }
434
+ switch (period) {
435
+ case "All":
436
+ return referralInfo.referrer_info.total_referrer_rebate;
437
+ case "1D":
438
+ return referralInfo.referrer_info["1d_referrer_rebate"];
439
+ case "7D":
440
+ return referralInfo.referrer_info["7d_referrer_rebate"];
441
+ case "30D":
442
+ return referralInfo.referrer_info["30d_referrer_rebate"];
443
+ }
444
+ }, [referralInfo, period]);
445
+ const referralVol = react.useMemo(() => {
446
+ if (!referralInfo || !referralInfo.referrer_info) {
447
+ return 0;
448
+ }
449
+ switch (period) {
450
+ case "All":
451
+ return referralInfo.referrer_info.total_referee_volume;
452
+ case "1D":
453
+ return referralInfo.referrer_info["1d_referee_volume"];
454
+ case "7D":
455
+ return referralInfo.referrer_info["7d_referee_volume"];
456
+ case "30D":
457
+ return referralInfo.referrer_info["30d_referee_volume"];
458
+ }
459
+ }, [referralInfo, period]);
460
+ const referees = react.useMemo(() => {
461
+ if (!referralInfo || !referralInfo.referrer_info) {
462
+ return 0;
463
+ }
464
+ switch (period) {
465
+ case "All":
466
+ return referralInfo.referrer_info.total_invites;
467
+ case "1D":
468
+ return referralInfo.referrer_info["1d_invites"];
469
+ case "7D":
470
+ return referralInfo.referrer_info["7d_invites"];
471
+ case "30D":
472
+ return referralInfo.referrer_info["30d_invites"];
473
+ }
474
+ }, [referralInfo, period]);
475
+ const refereesTades = react.useMemo(() => {
476
+ if (!referralInfo || !referralInfo.referrer_info) {
477
+ return 0;
478
+ }
479
+ switch (period) {
480
+ case "All":
481
+ return referralInfo.referrer_info.total_traded;
482
+ case "1D":
483
+ return referralInfo.referrer_info["1d_traded"];
484
+ case "7D":
485
+ return referralInfo.referrer_info["7d_traded"];
486
+ case "30D":
487
+ return referralInfo.referrer_info["30d_traded"];
488
+ }
489
+ }, [referralInfo, period]);
490
+ const onPeriodChange = (item) => {
491
+ setPeriod(item);
492
+ };
493
+ return {
494
+ period,
495
+ periodTypes,
496
+ onPeriodChange,
497
+ commission,
498
+ referralVol,
499
+ referees,
500
+ refereesTades
501
+ };
502
+ };
503
+ var SummaryWidget = () => {
504
+ const state = useSummaryScript();
505
+ return /* @__PURE__ */ jsxRuntime.jsx(Summary, { ...state });
506
+ };
507
+ var AutoHideText = (props) => {
508
+ const { text, visibleCount } = props;
509
+ const containerRef = react.useRef(null);
510
+ const textRef = react.useRef(null);
511
+ const lastContainerWidth = react.useRef(void 0);
512
+ function getTextWidth(ref, text2) {
513
+ const canvas = document.createElement("canvas");
514
+ const context = canvas.getContext("2d");
515
+ const element = ref;
516
+ if (context && element) {
517
+ let fontStyle = getComputedStyle(element).font;
518
+ if (fontStyle.length === 0) {
519
+ fontStyle = [
520
+ getComputedStyle(element).fontWeight,
521
+ getComputedStyle(element).fontSize,
522
+ getComputedStyle(element).fontFamily
523
+ ].join(" ");
524
+ }
525
+ context.font = fontStyle;
526
+ context.letterSpacing = getComputedStyle(element).letterSpacing;
527
+ const width = context.measureText(text2).width;
528
+ return width;
529
+ }
530
+ return void 0;
531
+ }
532
+ const [visibleChars, setVisibleChars] = react.useState(0);
533
+ react.useEffect(() => {
534
+ const calculateVisibleChars = () => {
535
+ if (props.visibleCount !== void 0)
536
+ return;
537
+ if (containerRef.current && textRef.current) {
538
+ const containerWidth = containerRef.current.clientWidth;
539
+ if (containerWidth == lastContainerWidth.current)
540
+ return;
541
+ lastContainerWidth.current = containerWidth;
542
+ const textElement = textRef.current;
543
+ const textContent = text;
544
+ const pWidth = Math.ceil(getTextWidth(textElement, "...") || 0);
545
+ const maxDisplayW = containerWidth - pWidth;
546
+ let count = 0;
547
+ while (count < text.length) {
548
+ let contentW = getTextWidth(textElement, subText(text, count++)) || maxDisplayW;
549
+ if (contentW <= maxDisplayW) {
550
+ break;
551
+ }
552
+ }
553
+ setVisibleChars(textContent.length - count);
554
+ }
555
+ };
556
+ lastContainerWidth.current = void 0;
557
+ calculateVisibleChars();
558
+ window.addEventListener("resize", calculateVisibleChars);
559
+ return () => {
560
+ lastContainerWidth.current = void 0;
561
+ window.removeEventListener("resize", calculateVisibleChars);
562
+ };
563
+ }, [text, textRef]);
564
+ const truncatedText = react.useMemo(() => {
565
+ if (visibleChars + 1 >= text.length) {
566
+ return text;
567
+ }
568
+ const maxCharacters = visibleCount || visibleChars;
569
+ const startText = text.slice(0, Math.ceil(maxCharacters / 2));
570
+ const endText = text.slice(
571
+ text.length - Math.floor(maxCharacters / 2),
572
+ text.length
573
+ );
574
+ return `${startText}...${endText}`;
575
+ }, [text, visibleCount, visibleChars]);
576
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: containerRef, className: ui.cn("oui-relative oui-w-full oui-text-end", props.className), children: [
577
+ /* @__PURE__ */ jsxRuntime.jsx(
578
+ "div",
579
+ {
580
+ className: ui.cn(
581
+ "oui-hidden oui-whitespace-nowrap oui-absolute oui-top-0 oui-bottom-0 oui-right-0 oui-left-0"
582
+ ),
583
+ children: /* @__PURE__ */ jsxRuntime.jsx("span", { ref: textRef, children: text })
584
+ }
585
+ ),
586
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: truncatedText })
587
+ ] });
588
+ };
589
+ var subText = (text, count) => {
590
+ const start = Math.floor(text.length / 2 - (count > 0 ? count / 2 : 1));
591
+ const first = text.slice(0, start);
592
+ const end = text.slice(start + count);
593
+ return first + end;
594
+ };
595
+ var ReferralLink = (props) => {
596
+ const { t } = i18n.useTranslation();
597
+ return /* @__PURE__ */ jsxRuntime.jsxs(
598
+ ui.Flex,
599
+ {
600
+ id: "oui-affiliate-affiliate-referralLink",
601
+ r: "2xl",
602
+ p: 6,
603
+ width: "100%",
604
+ gap: 4,
605
+ direction: "column",
606
+ className: "oui-bg-base-9",
607
+ children: [
608
+ /* @__PURE__ */ jsxRuntime.jsx(Title2, { ...props }),
609
+ /* @__PURE__ */ jsxRuntime.jsxs(
610
+ ui.Flex,
611
+ {
612
+ width: "100%",
613
+ className: "oui-flex oui-flex-col 3xl:oui-flex-row",
614
+ gap: 4,
615
+ children: [
616
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-w-full 3xl:oui-w-1/3", children: /* @__PURE__ */ jsxRuntime.jsx(Subtitle, { ...props }) }),
617
+ /* @__PURE__ */ jsxRuntime.jsxs(
618
+ ui.Flex,
619
+ {
620
+ direction: "column",
621
+ width: "100%",
622
+ className: "3xl:oui-w-2/3 3xl:oui-gap-2",
623
+ children: [
624
+ /* @__PURE__ */ jsxRuntime.jsx(
625
+ Input,
626
+ {
627
+ title: t("affiliate.referralCode"),
628
+ value: props.refCode,
629
+ ...props
630
+ }
631
+ ),
632
+ /* @__PURE__ */ jsxRuntime.jsx(
633
+ Input,
634
+ {
635
+ title: t("affiliate.referralLink"),
636
+ value: props.refLink,
637
+ ...props
638
+ }
639
+ )
640
+ ]
641
+ }
642
+ )
643
+ ]
644
+ }
645
+ )
646
+ ]
647
+ }
648
+ );
649
+ };
650
+ var Title2 = (props) => {
651
+ const { t } = i18n.useTranslation();
652
+ return /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { direction: "row", justify: "between", width: "100%", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "oui-text-lg", children: t("affiliate.referralLink") }) });
653
+ };
654
+ var Subtitle = (props) => {
655
+ const { t } = i18n.useTranslation();
656
+ const item = (title, value, gradient, className, tooltip) => {
657
+ const valueClsName = "oui-text-lg md:oui-text-xl lg:oui-text-2xl xl:oui-text-3xl";
658
+ return /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "column", itemAlign: "start", className, children: [
659
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { direction: "row", gap: 2, children: /* @__PURE__ */ jsxRuntime.jsx(Alert, { title, tooltip }) }),
660
+ gradient ? /* @__PURE__ */ jsxRuntime.jsx(ui.Text.gradient, { color: "brand", className: valueClsName, children: value }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: valueClsName, children: value })
661
+ ] });
662
+ };
663
+ return /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "row", width: "100%", children: [
664
+ item(
665
+ t("affiliate.referralLink.earn"),
666
+ props.earn || "-",
667
+ true,
668
+ "oui-flex-1",
669
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
670
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text.gradient, { color: "brand", children: props.earn || "-" }),
671
+ " ",
672
+ t("affiliate.referralLink.earn.tooltip", {
673
+ brokerName: props.brokerName
674
+ })
675
+ ] })
676
+ // @ts-ignore
677
+ // <Trans
678
+ // i18nKey="affiliate.referralLink.earn.tooltip"
679
+ // values={{
680
+ // value: props.earn || "-",
681
+ // brokerName: props.brokerName,
682
+ // }}
683
+ // components={[<Text.gradient color="brand" />]}
684
+ // />
685
+ ),
686
+ item(
687
+ t("affiliate.referralLink.share"),
688
+ props.share || "-",
689
+ false,
690
+ "oui-flex-1",
691
+ // @ts-ignore
692
+ /* @__PURE__ */ jsxRuntime.jsx(
693
+ i18n.Trans,
694
+ {
695
+ i18nKey: "affiliate.referralLink.share.tooltip",
696
+ values: {
697
+ value: props.share || "-",
698
+ brokerName: props.brokerName
699
+ },
700
+ components: [/* @__PURE__ */ jsxRuntime.jsx(ui.Text.gradient, { color: "brand" })]
701
+ }
702
+ )
703
+ )
704
+ ] });
705
+ };
706
+ var Input = (props) => {
707
+ const { title, value = "-" } = props;
708
+ return /* @__PURE__ */ jsxRuntime.jsxs(
709
+ ui.Flex,
710
+ {
711
+ r: "xl",
712
+ p: 3,
713
+ gap: 4,
714
+ direction: "row",
715
+ width: "100%",
716
+ className: "oui-bg-base-8",
717
+ children: [
718
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "oui-text-base-contrast-54 oui-flex-shrink oui-text-2xs md:oui-text-xs xl:oui-text-sm", children: title }),
719
+ /* @__PURE__ */ jsxRuntime.jsxs(
720
+ ui.Flex,
721
+ {
722
+ direction: "row",
723
+ justify: "end",
724
+ gap: 2,
725
+ className: "oui-flex-1 oui-text-xs md:oui-text-sm xl:oui-text-base",
726
+ children: [
727
+ /* @__PURE__ */ jsxRuntime.jsx(AutoHideText, { text: value }),
728
+ /* @__PURE__ */ jsxRuntime.jsx(
729
+ "button",
730
+ {
731
+ className: "oui-cursor-pointer oui-text-sm oui-flex-shrink",
732
+ onClick: () => {
733
+ navigator.clipboard.writeText(value);
734
+ props.onCopy?.(value);
735
+ },
736
+ children: /* @__PURE__ */ jsxRuntime.jsx(
737
+ ui.CopyIcon,
738
+ {
739
+ size: 12,
740
+ color: "white",
741
+ className: "oui-w-[13px] oui-h-[13px] md:oui-w-[14px] md:oui-h-[14px] xl:oui-w-4 xl:oui-h-4"
742
+ }
743
+ )
744
+ }
745
+ )
746
+ ]
747
+ }
748
+ )
749
+ ]
750
+ }
751
+ );
752
+ };
753
+ var Alert = (props) => {
754
+ return /* @__PURE__ */ jsxRuntime.jsx(ui.Tooltip, { content: props.tooltip, className: "oui-max-w-[200px]", children: /* @__PURE__ */ jsxRuntime.jsx(
755
+ "div",
756
+ {
757
+ onClick: () => {
758
+ ui.modal.alert({
759
+ title: props.title,
760
+ message: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-text-base-contrast/30 oui-space-y-3 oui-text-xs desktop:oui-text-xs", children: props.tooltip })
761
+ });
762
+ },
763
+ children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "column", children: [
764
+ /* @__PURE__ */ jsxRuntime.jsx(
765
+ ui.Text,
766
+ {
767
+ intensity: 54,
768
+ className: "oui-text-2xs md:oui-text-xs xl:oui-text-sm",
769
+ children: props.title
770
+ }
771
+ ),
772
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { className: "oui-w-full", lineStyle: "dotted", intensity: 16 })
773
+ ] })
774
+ }
775
+ ) });
776
+ };
777
+ function addQueryParam(url, paramName, paramValue) {
778
+ try {
779
+ const urlObj = new URL(url);
780
+ const searchParams = new URLSearchParams(urlObj.search);
781
+ searchParams.set(paramName, paramValue);
782
+ urlObj.search = searchParams.toString();
783
+ return urlObj.toString();
784
+ } catch (error) {
785
+ return url;
786
+ }
787
+ }
788
+ async function copyText(content) {
789
+ try {
790
+ await navigator.clipboard.writeText(content);
791
+ ui.toast.success(i18n.i18n.t("common.copy.copied"));
792
+ } catch (error) {
793
+ ui.toast.success(i18n.i18n.t("common.copy.failed"));
794
+ }
795
+ }
796
+ function formatDateTimeToUTC(input) {
797
+ if (input === void 0) {
798
+ return "";
799
+ }
800
+ const date = dateFns.toDate(input);
801
+ const utcDate = toUTCDate(date);
802
+ return dateFns.format(utcDate, "yyyy-MM-dd HH:mm:ss 'UTC'");
803
+ }
804
+ function formatYMDTime(time) {
805
+ if (time === void 0) {
806
+ return void 0;
807
+ }
808
+ const date = dateFns.toDate(time);
809
+ const utcDate = toUTCDate(date);
810
+ return dateFns.format(utcDate, "yyyy-MM-dd");
811
+ }
812
+ function compareDate(d1, d2) {
813
+ const isEqual = d1 && d2 && d1.toISOString().substring(0, 10) === d2.toISOString().substring(0, 10);
814
+ return isEqual;
815
+ }
816
+ function toUTCDate(date) {
817
+ return new Date(date.toUTCString());
818
+ }
819
+
820
+ // src/pages/affiliate/referralLink/referralLink.script.tsx
821
+ var useReferralLinkScript = () => {
822
+ const { t } = i18n.useTranslation();
823
+ const onCopy = (value) => {
824
+ ui.toast.success(t("common.copy.copied"));
825
+ };
826
+ const { referralInfo, referralLinkUrl, overwrite } = useReferralContext();
827
+ const [pinCodes, setPinCodes] = hooks.useLocalStorage(
828
+ "orderly_referral_codes",
829
+ []
830
+ );
831
+ const codes = react.useMemo(() => {
832
+ if (!referralInfo?.referrer_info?.referral_codes)
833
+ return [];
834
+ const referralCodes = [...referralInfo?.referrer_info?.referral_codes];
835
+ const pinedItems = [];
836
+ for (let i = 0; i < pinCodes.length; i++) {
837
+ const code2 = pinCodes[i];
838
+ const index = referralCodes.findIndex((item) => item.code === code2);
839
+ if (index !== -1) {
840
+ pinedItems.push({ ...referralCodes[index] });
841
+ referralCodes.splice(index, 1);
842
+ }
843
+ }
844
+ return [...pinedItems, ...referralCodes];
845
+ }, [referralInfo?.referrer_info?.referral_codes, pinCodes]);
846
+ const firstCode = react.useMemo(() => {
847
+ if (codes.length === 0) {
848
+ return void 0;
849
+ }
850
+ return codes[0];
851
+ }, [codes]);
852
+ const code = react.useMemo(() => {
853
+ return firstCode?.code;
854
+ }, [firstCode]);
855
+ const referralLink = react.useMemo(() => {
856
+ if (!firstCode)
857
+ return "";
858
+ return addQueryParam(referralLinkUrl, "ref", firstCode.code);
859
+ }, [firstCode]);
860
+ const earn = react.useMemo(() => {
861
+ const value = new utils.Decimal(firstCode?.referrer_rebate_rate || "0").mul(100).toDecimalPlaces(0, utils.Decimal.ROUND_DOWN).toString();
862
+ return `${value}%`;
863
+ }, [firstCode?.referrer_rebate_rate]);
864
+ const share = react.useMemo(() => {
865
+ const value = new utils.Decimal(firstCode?.referee_rebate_rate || "0").mul(100).toDecimalPlaces(0, utils.Decimal.ROUND_DOWN).toString();
866
+ return `${value}%`;
867
+ }, [firstCode?.referee_rebate_rate]);
868
+ return {
869
+ onCopy,
870
+ refLink: referralLink,
871
+ refCode: code,
872
+ share,
873
+ earn,
874
+ brokerName: overwrite?.brokerName ?? overwrite?.shortBrokerName
875
+ };
876
+ };
877
+ var ReferralLinkWidget = () => {
878
+ const state = useReferralLinkScript();
879
+ return /* @__PURE__ */ jsxRuntime.jsx(ReferralLink, { ...state });
880
+ };
881
+ var TitleStatistic = (props) => {
882
+ return /* @__PURE__ */ jsxRuntime.jsxs(
883
+ ui.Flex,
884
+ {
885
+ id: "oui-affiliate-affiliate-titleStatistic",
886
+ r: "2xl",
887
+ p: 6,
888
+ width: "100%",
889
+ gap: 4,
890
+ direction: "column",
891
+ className: "oui-bg-base-9",
892
+ children: [
893
+ /* @__PURE__ */ jsxRuntime.jsx(Title3, { ...props }),
894
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { className: "oui-h-[170px] 2xl:oui-h-[196px] oui-w-full oui-flex oui-flex-row oui-items-stretch", children: /* @__PURE__ */ jsxRuntime.jsx(
895
+ chart.VolBarChart,
896
+ {
897
+ data: props.dataSource || types.EMPTY_LIST,
898
+ colors: { fill: "rgba(0, 180, 158, 1)" },
899
+ className: "oui-w-full oui-flex-1",
900
+ tooltip: {
901
+ rm: utils.Decimal.ROUND_DOWN,
902
+ dp: props.volType === "Commission" ? 6 : 2
903
+ }
904
+ }
905
+ ) })
906
+ ]
907
+ }
908
+ );
909
+ };
910
+ var Title3 = (props) => {
911
+ const { t } = i18n.useTranslation();
912
+ return /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "row", justify: "between", width: "100%", children: [
913
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "oui-text-lg", children: t("affiliate.statistics") }),
914
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "row", gap: 2, className: "oui-min-w-14", children: [
915
+ /* @__PURE__ */ jsxRuntime.jsx(
916
+ ui.Select.options,
917
+ {
918
+ size: "xs",
919
+ value: props.period,
920
+ onValueChange: props.onPeriodChange,
921
+ options: props.periodTypes
922
+ }
923
+ ),
924
+ /* @__PURE__ */ jsxRuntime.jsx(
925
+ ui.Select.options,
926
+ {
927
+ size: "xs",
928
+ value: props.volType,
929
+ onValueChange: props.onVolTypeChange,
930
+ options: props.volTypes
931
+ }
932
+ )
933
+ ] })
934
+ ] });
935
+ };
936
+ function fillData(days, origin) {
937
+ const now = Date();
938
+ const result = new Array(days).fill(0).map((_, index) => {
939
+ return {
940
+ date: dateFns.format(dateFns.subDays(now, index + 1), "yyyy-MM-dd"),
941
+ volume: 0,
942
+ opacity: 0
943
+ };
944
+ }).reverse();
945
+ const dataObject = origin?.reduce(
946
+ (acc, curr) => {
947
+ acc[curr.date] = curr;
948
+ return acc;
949
+ },
950
+ {}
951
+ );
952
+ for (let index = 0; index < result.length; index++) {
953
+ const element = result[index];
954
+ const originData = dataObject?.[element.date];
955
+ if (originData) {
956
+ result[index] = { ...originData, opacity: originData.volume > 0 ? 1 : 0 };
957
+ }
958
+ }
959
+ return result;
960
+ }
961
+ var useTitleStatisticScript = () => {
962
+ const { t } = i18n.useTranslation();
963
+ const [period, setPeriod] = react.useState("7");
964
+ const periodTypes = [
965
+ { label: t("common.select.7d"), value: "7" },
966
+ { label: t("common.select.30d"), value: "30" },
967
+ { label: t("common.select.90d"), value: "90" }
968
+ ];
969
+ const onPeriodChange = (item) => {
970
+ setPeriod(item);
971
+ };
972
+ const [volType, setVolType] = react.useState("Commission");
973
+ const volTypes = [
974
+ { label: t("affiliate.commission"), value: "Commission" },
975
+ { label: t("affiliate.referralVol"), value: "ref" }
976
+ ];
977
+ const onVolTypeChange = (item) => {
978
+ setVolType(item);
979
+ };
980
+ const dateRange = react.useMemo(() => {
981
+ if (period === "7") {
982
+ return {
983
+ startDate: dateFns.subDays(/* @__PURE__ */ new Date(), 7),
984
+ endDate: dateFns.subDays(/* @__PURE__ */ new Date(), 1)
985
+ };
986
+ } else if (period === "30") {
987
+ return {
988
+ startDate: dateFns.subDays(/* @__PURE__ */ new Date(), 30),
989
+ endDate: dateFns.subDays(/* @__PURE__ */ new Date(), 1)
990
+ };
991
+ } else if (period === "90") {
992
+ return {
993
+ startDate: dateFns.subDays(/* @__PURE__ */ new Date(), 90),
994
+ endDate: dateFns.subDays(/* @__PURE__ */ new Date(), 1)
995
+ };
996
+ } else {
997
+ return {
998
+ startDate: dateFns.subDays(/* @__PURE__ */ new Date(), 7),
999
+ endDate: dateFns.subDays(/* @__PURE__ */ new Date(), 1)
1000
+ };
1001
+ }
1002
+ }, [period]);
1003
+ const [rebateSummary] = hooks.useReferralRebateSummary({
1004
+ startDate: dateFns.format(dateRange.startDate, "yyyy-MM-dd"),
1005
+ endDate: dateFns.format(dateRange.endDate, "yyyy-MM-dd"),
1006
+ size: Number(period)
1007
+ });
1008
+ const dataSource = react.useMemo(() => {
1009
+ return (rebateSummary?.map(
1010
+ (e) => ({
1011
+ date: e.date,
1012
+ volume: volType === "Commission" ? e.referral_rebate : e.volume
1013
+ })
1014
+ ) || []).reverse();
1015
+ }, [rebateSummary, volType]);
1016
+ return {
1017
+ period,
1018
+ periodTypes,
1019
+ onPeriodChange,
1020
+ volType,
1021
+ volTypes,
1022
+ onVolTypeChange,
1023
+ dataSource: fillData(Number(period), dataSource)
1024
+ };
1025
+ };
1026
+ var TitleStatisticWidget = () => {
1027
+ const state = useTitleStatisticScript();
1028
+ return /* @__PURE__ */ jsxRuntime.jsx(TitleStatistic, { ...state });
1029
+ };
1030
+ var EditIcon = (props) => {
1031
+ const { className, ...rest } = props;
1032
+ return /* @__PURE__ */ jsxRuntime.jsx(
1033
+ "svg",
1034
+ {
1035
+ width: "12",
1036
+ height: "13",
1037
+ viewBox: "0 0 12 13",
1038
+ xmlns: "http://www.w3.org/2000/svg",
1039
+ fill: "white",
1040
+ fillOpacity: "0.36",
1041
+ className,
1042
+ ...rest,
1043
+ children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M8.49773 1.47656C8.36523 1.47656 8.23223 1.52357 8.13823 1.61707C7.86023 1.89507 6.85973 2.89558 6.63773 3.11808L2.13523 7.62059L1.63473 8.12059C1.56523 8.19059 1.52923 8.28958 1.50973 8.38658L1.00973 10.8881C0.939727 11.2381 1.23773 11.5361 1.58773 11.4666C1.90073 11.4036 3.77673 11.0286 4.08923 10.9661C4.18623 10.9466 4.28523 10.9106 4.35523 10.8411L4.85523 10.3406L9.35773 5.83808C9.58023 5.61608 10.5807 4.61506 10.8587 4.33756C10.9522 4.24356 10.9992 4.11056 10.9992 3.97806C10.9992 3.15956 10.7907 2.57456 10.3582 2.13306C9.92173 1.68756 9.33873 1.47656 8.49773 1.47656ZM8.69473 2.48606C9.14623 2.51256 9.43873 2.61608 9.63923 2.82108C9.84423 3.03008 9.97373 3.32008 10.0017 3.76258C9.72773 4.03608 9.32673 4.43106 8.99823 4.75956C8.60173 4.36306 8.11273 3.87407 7.71623 3.47757C8.04523 3.14907 8.42123 2.75956 8.69473 2.48606ZM6.99723 4.19657L8.27923 5.47858L4.49573 9.26207L3.21373 7.98009L6.99723 4.19657ZM2.49473 8.69908L3.77673 9.98107L3.72973 10.0281C3.39973 10.0941 2.73323 10.2336 2.11923 10.3566L2.44773 8.74608L2.49473 8.69908Z" })
1044
+ }
1045
+ );
1046
+ };
1047
+ var EditCode = (props) => {
1048
+ return /* @__PURE__ */ jsxRuntime.jsx("button", { children: /* @__PURE__ */ jsxRuntime.jsx(
1049
+ EditIcon,
1050
+ {
1051
+ className: " oui-mt-px oui-cursor-pointer oui-fill-base-contrast-36 hover:oui-fill-base-contrast-80",
1052
+ fillOpacity: 1,
1053
+ fill: "currentColor",
1054
+ onClick: props.onClick
1055
+ }
1056
+ ) });
1057
+ };
1058
+ var PinBtn = (props) => {
1059
+ return /* @__PURE__ */ jsxRuntime.jsx(
1060
+ "button",
1061
+ {
1062
+ onClick: (e) => {
1063
+ props?.onClick?.(!props.pinned);
1064
+ },
1065
+ children: props.pinned === false ? /* @__PURE__ */ jsxRuntime.jsx(
1066
+ UnPinIcon,
1067
+ {
1068
+ size: props.size,
1069
+ fillOpacity: 1,
1070
+ className: "orderly-fill-primary-darken hover:orderly-fill-primary-darken/80"
1071
+ }
1072
+ ) : /* @__PURE__ */ jsxRuntime.jsx(
1073
+ PinnedIcon,
1074
+ {
1075
+ size: props.size,
1076
+ fillOpacity: 1,
1077
+ className: "orderly-fill-base-contrast-36 hover:orderly-fill-base-contrast"
1078
+ }
1079
+ )
1080
+ }
1081
+ );
1082
+ };
1083
+ var PinnedIcon = (props) => {
1084
+ const { size = 12 } = props;
1085
+ return /* @__PURE__ */ jsxRuntime.jsx(
1086
+ "svg",
1087
+ {
1088
+ width: size,
1089
+ height: size,
1090
+ viewBox: "0 0 16 16",
1091
+ fill: "#608CFF",
1092
+ xmlns: "http://www.w3.org/2000/svg",
1093
+ children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M10.008 1.302a.74.74 0 0 0-.486.215c-1.033.988-1.349 1.815-.972 2.947-.88.675-1.437.841-2.536.841-1.503 0-2.484.181-3.152.848v.021a1.583 1.583 0 0 0 0 2.249l1.867 1.881-3.181 3.18c-.26.26-.28.696-.02.956.261.26.699.26.959 0l3.193-3.193 1.87 1.86a1.585 1.585 0 0 0 2.25 0h.02c.668-.667.854-1.522.854-3.144 0-1.03.212-1.758.853-2.523 1.232.361 1.95.015 2.96-.995a.68.68 0 0 0 .188-.479c0-.234-.06-.594-.209-1.041a5.34 5.34 0 0 0-1.312-2.103A5.35 5.35 0 0 0 11.05 1.51c-.448-.149-.808-.208-1.042-.208" })
1094
+ }
1095
+ );
1096
+ };
1097
+ var UnPinIcon = (props) => {
1098
+ const { size = 12 } = props;
1099
+ return /* @__PURE__ */ jsxRuntime.jsx(
1100
+ "svg",
1101
+ {
1102
+ width: size,
1103
+ height: size,
1104
+ viewBox: "0 0 16 16",
1105
+ fill: "#fff",
1106
+ fillOpacity: ".36",
1107
+ xmlns: "http://www.w3.org/2000/svg",
1108
+ children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M10.008 1.302a.74.74 0 0 0-.486.215c-1.033.988-1.349 1.815-.972 2.947-.88.675-1.437.841-2.536.841-1.503 0-2.484.181-3.152.848v.021a1.583 1.583 0 0 0 0 2.249l1.867 1.881-3.181 3.18c-.26.26-.28.696-.02.956.261.26.699.26.959 0l3.193-3.193 1.87 1.86a1.585 1.585 0 0 0 2.25 0h.02c.668-.667.854-1.522.854-3.144 0-1.03.212-1.758.853-2.523 1.232.361 1.95.015 2.96-.995a.68.68 0 0 0 .188-.479c0-.234-.06-.594-.209-1.041a5.34 5.34 0 0 0-1.312-2.103A5.35 5.35 0 0 0 11.05 1.51c-.448-.149-.808-.208-1.042-.208m.258 1.37c.708.131 1.421.6 1.93 1.108.507.507.94 1.13 1.119 1.944-.636.61-1.026.659-1.662.324a.67.67 0 0 0-.779.116c-1.214 1.213-1.533 2.314-1.533 3.8 0 1.293-.076 1.774-.48 2.207-.113.123-.27.104-.374 0L3.799 7.486a.24.24 0 0 1-.017-.34c.239-.29.769-.514 2.226-.514 1.742.001 2.668-.447 3.812-1.52a.67.67 0 0 0 .125-.77c-.343-.685-.29-1.046.321-1.67" })
1109
+ }
1110
+ );
1111
+ };
1112
+ var ReferralCodes = (props) => {
1113
+ const isTablet = hooks.useMediaQuery("(max-width: 767px)");
1114
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1115
+ ui.Flex,
1116
+ {
1117
+ r: "2xl",
1118
+ p: 6,
1119
+ width: "100%",
1120
+ gap: 4,
1121
+ direction: "column",
1122
+ className: "oui-h-full oui-bg-base-9 oui-p-6 oui-tabular-nums",
1123
+ children: [
1124
+ /* @__PURE__ */ jsxRuntime.jsx(Title4, { ...props }),
1125
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-flex oui-w-full oui-flex-col 2xl:oui-h-full", children: [
1126
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Divider, {}),
1127
+ isTablet ? /* @__PURE__ */ jsxRuntime.jsx(MobileLayout, { ...props }) : /* @__PURE__ */ jsxRuntime.jsx(DesktopLayout, { ...props })
1128
+ ] })
1129
+ ]
1130
+ }
1131
+ );
1132
+ };
1133
+ var Title4 = (props) => {
1134
+ const { t } = i18n.useTranslation();
1135
+ return /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "row", justify: "between", width: "100%", children: [
1136
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "oui-text-lg", children: t("affiliate.referralCodes") }),
1137
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-text-2xs md:oui-text-xs xl:oui-text-sm", children: [
1138
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "oui-text-base-contrast-54", children: `${t("affiliate.referralCodes.remaining")}: ` }),
1139
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "oui-text-primary-light", children: props.codes?.length || "--" })
1140
+ ] })
1141
+ ] });
1142
+ };
1143
+ var MobileLayout = (props) => {
1144
+ return /* @__PURE__ */ jsxRuntime.jsx(
1145
+ ui.ListView,
1146
+ {
1147
+ dataSource: props.codes,
1148
+ className: "oui-max-h-[240px] oui-w-full",
1149
+ renderItem: (e, index) => {
1150
+ return /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "column", children: [
1151
+ /* @__PURE__ */ jsxRuntime.jsx(
1152
+ MobileCell,
1153
+ {
1154
+ data: e,
1155
+ editRate: props.editRate,
1156
+ copyLink: props.copyLink,
1157
+ copyCode: props.copyCode,
1158
+ setPinCode: props.setPinCode,
1159
+ editCode: props.editCode
1160
+ },
1161
+ index
1162
+ ),
1163
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { className: "oui-mt-3 oui-w-full" })
1164
+ ] });
1165
+ }
1166
+ }
1167
+ );
1168
+ };
1169
+ var MobileCellItem = (props) => {
1170
+ const { title, copyable, value, align, className, editRate, onCopy } = props;
1171
+ return /* @__PURE__ */ jsxRuntime.jsx(
1172
+ ui.Statistic,
1173
+ {
1174
+ id: "oui-affiliate-affiliate-referralCodes",
1175
+ className: ui.cn("oui-flex-1", className),
1176
+ label: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "oui-text-2xs oui-text-base-contrast-36", children: title }),
1177
+ align,
1178
+ children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "row", gap: 1, children: [
1179
+ /* @__PURE__ */ jsxRuntime.jsx(
1180
+ ui.Text.formatted,
1181
+ {
1182
+ copyable,
1183
+ onCopy: () => {
1184
+ onCopy?.();
1185
+ },
1186
+ className: "oui-mt-[6px] oui-text-sm oui-text-base-contrast-80",
1187
+ children: value
1188
+ }
1189
+ ),
1190
+ editRate && /* @__PURE__ */ jsxRuntime.jsx(
1191
+ EditIcon,
1192
+ {
1193
+ className: "oui-mt-px oui-cursor-pointer oui-fill-white/[.36] hover:oui-fill-white/80",
1194
+ fillOpacity: 1,
1195
+ fill: "currentColor",
1196
+ onClick: () => editRate()
1197
+ }
1198
+ )
1199
+ ] })
1200
+ }
1201
+ );
1202
+ };
1203
+ var MobileCell = (props) => {
1204
+ const { data, setPinCode, copyLink, editRate, editCode } = props;
1205
+ const { t } = i18n.useTranslation();
1206
+ return /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 3, direction: "column", className: "oui-w-full", children: [
1207
+ /* @__PURE__ */ jsxRuntime.jsxs(
1208
+ ui.Flex,
1209
+ {
1210
+ direction: "row",
1211
+ justify: "between",
1212
+ itemAlign: "stretch",
1213
+ width: "100%",
1214
+ children: [
1215
+ /* @__PURE__ */ jsxRuntime.jsx(
1216
+ MobileCellItem,
1217
+ {
1218
+ title: t("affiliate.referralCode"),
1219
+ value: data.code,
1220
+ copyable: true,
1221
+ onCopy: () => {
1222
+ props.copyCode?.(data.code);
1223
+ },
1224
+ editRate: () => {
1225
+ editCode(data);
1226
+ }
1227
+ }
1228
+ ),
1229
+ /* @__PURE__ */ jsxRuntime.jsx(
1230
+ MobileCellItem,
1231
+ {
1232
+ title: t("affiliate.referralCodes.column.you&Referee"),
1233
+ value: getRate(data),
1234
+ align: "end",
1235
+ editRate: () => {
1236
+ editRate(data);
1237
+ }
1238
+ }
1239
+ ),
1240
+ /* @__PURE__ */ jsxRuntime.jsx(
1241
+ MobileCellItem,
1242
+ {
1243
+ title: t("affiliate.referralCodes.column.referees&Traders"),
1244
+ value: getCount(data),
1245
+ align: "end",
1246
+ className: "oui-hidden md:oui-flex"
1247
+ }
1248
+ )
1249
+ ]
1250
+ }
1251
+ ),
1252
+ /* @__PURE__ */ jsxRuntime.jsxs(
1253
+ ui.Flex,
1254
+ {
1255
+ direction: "row",
1256
+ justify: "between",
1257
+ itemAlign: "stretch",
1258
+ width: "100%",
1259
+ className: "md:oui-hidden",
1260
+ children: [
1261
+ /* @__PURE__ */ jsxRuntime.jsx(
1262
+ MobileCellItem,
1263
+ {
1264
+ title: t("affiliate.referees"),
1265
+ value: getCount(data).split("/")?.[0],
1266
+ align: "start"
1267
+ }
1268
+ ),
1269
+ /* @__PURE__ */ jsxRuntime.jsx(
1270
+ MobileCellItem,
1271
+ {
1272
+ title: t("affiliate.referralCodes.column.traders"),
1273
+ value: getCount(data).split("/")?.[1],
1274
+ align: "end"
1275
+ }
1276
+ )
1277
+ ]
1278
+ }
1279
+ ),
1280
+ /* @__PURE__ */ jsxRuntime.jsxs(
1281
+ ui.Flex,
1282
+ {
1283
+ direction: "row",
1284
+ justify: "between",
1285
+ itemAlign: "stretch",
1286
+ width: "100%",
1287
+ children: [
1288
+ /* @__PURE__ */ jsxRuntime.jsx(
1289
+ PinBtn,
1290
+ {
1291
+ pinned: data.isPined || false,
1292
+ onClick: (e) => {
1293
+ setPinCode(data.code, !e);
1294
+ }
1295
+ }
1296
+ ),
1297
+ /* @__PURE__ */ jsxRuntime.jsx(
1298
+ ui.Button,
1299
+ {
1300
+ variant: "outlined",
1301
+ size: "xs",
1302
+ className: "oui-px-[20px]",
1303
+ onClick: (e) => {
1304
+ copyLink(data.code);
1305
+ },
1306
+ children: t("affiliate.referralCodes.copyLink")
1307
+ }
1308
+ )
1309
+ ]
1310
+ }
1311
+ )
1312
+ ] }, data.code);
1313
+ };
1314
+ var DesktopLayout = (props) => {
1315
+ const { t } = i18n.useTranslation();
1316
+ const moreColumn = hooks.useMediaQuery("(min-width: 1024px)");
1317
+ const columns = react.useMemo(() => {
1318
+ const cols = [
1319
+ {
1320
+ title: t("affiliate.referralCode"),
1321
+ dataIndex: "code",
1322
+ width: moreColumn ? 115 : 120,
1323
+ className: "!oui-px-0",
1324
+ render: (value, data) => {
1325
+ return /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "row", itemAlign: "center", gap: 1, children: [
1326
+ /* @__PURE__ */ jsxRuntime.jsx(
1327
+ PinBtn,
1328
+ {
1329
+ size: 12,
1330
+ pinned: data.isPined || false,
1331
+ onClick: (e) => {
1332
+ props.setPinCode(data.code, !e);
1333
+ }
1334
+ }
1335
+ ),
1336
+ /* @__PURE__ */ jsxRuntime.jsx(
1337
+ ui.Text.formatted,
1338
+ {
1339
+ suffix: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1340
+ data.isAutoGenerated && data.total_invites < 1 && /* @__PURE__ */ jsxRuntime.jsx(EditCode, { onClick: () => props.editCode?.(data) }),
1341
+ /* @__PURE__ */ jsxRuntime.jsx(
1342
+ ui.CopyIcon,
1343
+ {
1344
+ className: "oui-cursor-pointer",
1345
+ size: 12,
1346
+ color: "white",
1347
+ onClick: () => props.copyCode?.(data.code)
1348
+ }
1349
+ )
1350
+ ] }),
1351
+ copyable: true,
1352
+ onCopy: () => {
1353
+ props.copyCode?.(data.code);
1354
+ },
1355
+ children: value
1356
+ }
1357
+ )
1358
+ ] });
1359
+ }
1360
+ },
1361
+ {
1362
+ title: t("affiliate.referralCodes.column.you&Referee"),
1363
+ dataIndex: "dffd",
1364
+ width: moreColumn ? 120 : 120,
1365
+ className: "oui-pr-0",
1366
+ render: (value, data) => {
1367
+ return /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "row", itemAlign: "center", gap: 1, children: [
1368
+ getRate(data),
1369
+ /* @__PURE__ */ jsxRuntime.jsx(
1370
+ EditIcon,
1371
+ {
1372
+ className: "oui-mt-[6px] oui-cursor-pointer oui-fill-white/[.36] hover:oui-fill-white/80",
1373
+ fillOpacity: 1,
1374
+ fill: "currentColor",
1375
+ onClick: (e) => props.editRate?.(data)
1376
+ }
1377
+ )
1378
+ ] });
1379
+ }
1380
+ }
1381
+ ];
1382
+ if (moreColumn) {
1383
+ cols.push({
1384
+ title: t("affiliate.referees"),
1385
+ dataIndex: "referee_rebate_rate",
1386
+ width: 65,
1387
+ className: "oui-pr-0",
1388
+ render: (value, data) => getCount(data).split("/")[0]
1389
+ });
1390
+ cols.push({
1391
+ title: t("affiliate.referralCodes.column.traders"),
1392
+ dataIndex: "referrer_rebate_rate",
1393
+ width: 65,
1394
+ className: "oui-pr-0",
1395
+ render: (value, data) => getCount(data).split("/")[1]
1396
+ });
1397
+ } else {
1398
+ cols.push({
1399
+ title: t("affiliate.referralCodes.column.referees&Traders"),
1400
+ dataIndex: "total_invites/total_traded",
1401
+ width: 120,
1402
+ fixed: "left",
1403
+ render: (value, data) => getCount(data)
1404
+ });
1405
+ }
1406
+ cols.push({
1407
+ dataIndex: "link",
1408
+ align: "right",
1409
+ width: 74,
1410
+ className: "!oui-px-0",
1411
+ render: (value, data) => /* @__PURE__ */ jsxRuntime.jsx(
1412
+ ui.Button,
1413
+ {
1414
+ variant: "outlined",
1415
+ size: "sm",
1416
+ className: "oui-px-5",
1417
+ onClick: (e) => {
1418
+ props?.copyLink?.(data.code);
1419
+ },
1420
+ children: t("affiliate.referralCodes.copyLink")
1421
+ }
1422
+ )
1423
+ });
1424
+ return cols;
1425
+ }, [moreColumn, t]);
1426
+ return /* @__PURE__ */ jsxRuntime.jsx(
1427
+ ui.DataTable,
1428
+ {
1429
+ bordered: true,
1430
+ columns,
1431
+ dataSource: props.codes,
1432
+ classNames: {
1433
+ header: "oui-px-0",
1434
+ root: "2xl:oui-flex-1 2xl:oui-max-h-[230px] 3xl:oui-max-h-[300px]"
1435
+ },
1436
+ onRow: (record) => {
1437
+ return {
1438
+ className: "oui-h-[45px]"
1439
+ };
1440
+ }
1441
+ }
1442
+ );
1443
+ };
1444
+ var getRate = (item) => {
1445
+ const refereeRate = new utils.Decimal(item.referee_rebate_rate).mul(100).toFixed(1, utils.Decimal.ROUND_DOWN).toString();
1446
+ const referralRate = new utils.Decimal(item.referrer_rebate_rate).mul(100).toFixed(1, utils.Decimal.ROUND_DOWN).toString();
1447
+ return `${referralRate}% / ${refereeRate}%`;
1448
+ };
1449
+ var getCount = (item) => {
1450
+ return `${item.total_invites} / ${item.total_traded}`;
1451
+ };
1452
+ var EditCodeModal = ui.modal.create((props) => {
1453
+ const { t } = i18n.useTranslation();
1454
+ const { visible, onOpenChange } = ui.useModal();
1455
+ const [newCode, setNewCode] = react.useState("");
1456
+ const [filedError, setFiledError] = react.useState({
1457
+ length: false,
1458
+ format: false
1459
+ });
1460
+ const [editCode, { error, isMutating }] = hooks.useMutation(
1461
+ "/v1/referral/edit_referral_code",
1462
+ "POST"
1463
+ );
1464
+ react.useEffect(() => {
1465
+ setNewCode(props.code.code);
1466
+ }, [props.code]);
1467
+ react.useEffect(() => {
1468
+ const _code = newCode.toUpperCase();
1469
+ const _fieldError = {
1470
+ length: false,
1471
+ format: false
1472
+ };
1473
+ if (_code.length < 4 || _code.length > 10) {
1474
+ _fieldError.length = true;
1475
+ }
1476
+ if (!/^[A-Z0-9]+$/.test(_code)) {
1477
+ _fieldError.format = true;
1478
+ }
1479
+ setFiledError(_fieldError);
1480
+ }, [newCode]);
1481
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1482
+ ui.SimpleDialog,
1483
+ {
1484
+ classNames: {
1485
+ content: "oui-max-w-[360px]"
1486
+ },
1487
+ title: /* @__PURE__ */ jsxRuntime.jsx("div", { children: t("affiliate.referralCode.editCodeModal.title") }),
1488
+ open: visible,
1489
+ onOpenChange,
1490
+ actions: {
1491
+ primary: {
1492
+ loading: isMutating,
1493
+ disabled: filedError.length || filedError.format,
1494
+ label: t("common.confirm"),
1495
+ onClick: async () => {
1496
+ try {
1497
+ const res = await editCode({
1498
+ current_referral_code: props.code.code,
1499
+ new_referral_code: newCode.toUpperCase()
1500
+ });
1501
+ if (res.success) {
1502
+ ui.toast.success(
1503
+ t("affiliate.referralCode.editCodeModal.success")
1504
+ );
1505
+ props.successCallback();
1506
+ onOpenChange(false);
1507
+ return;
1508
+ }
1509
+ ui.toast.error(res.message);
1510
+ } catch (e) {
1511
+ }
1512
+ }
1513
+ }
1514
+ },
1515
+ children: [
1516
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-mb-6 oui-text-xs oui-text-base-contrast-54", children: t("affiliate.referralCode.editCodeModal.description") }),
1517
+ /* @__PURE__ */ jsxRuntime.jsx(
1518
+ ui.TextField,
1519
+ {
1520
+ placeholder: "",
1521
+ fullWidth: true,
1522
+ label: t("affiliate.referralCode.editCodeModal.label"),
1523
+ onClean: () => {
1524
+ setNewCode("");
1525
+ },
1526
+ value: newCode,
1527
+ onChange: (e) => {
1528
+ const _value = e.target.value.toUpperCase().replace(/[^A-Z0-9]/g, "");
1529
+ setNewCode(_value);
1530
+ },
1531
+ formatters: [
1532
+ ui.inputFormatter.createRegexInputFormatter((value) => {
1533
+ return String(value).replace(
1534
+ /[a-z]/g,
1535
+ (char) => char.toUpperCase()
1536
+ );
1537
+ }),
1538
+ ui.inputFormatter.createRegexInputFormatter(/[^A-Z0-9]/g)
1539
+ ],
1540
+ classNames: {
1541
+ label: "oui-text-base-contrast-54 oui-text-xs",
1542
+ input: "placeholder:oui-text-base-contrast-20 placeholder:oui-text-sm"
1543
+ },
1544
+ maxLength: 10,
1545
+ minLength: 4,
1546
+ autoComplete: "off",
1547
+ helpText: ""
1548
+ }
1549
+ ),
1550
+ /* @__PURE__ */ jsxRuntime.jsxs(
1551
+ ui.Flex,
1552
+ {
1553
+ direction: "column",
1554
+ justify: "center",
1555
+ itemAlign: "start",
1556
+ gap: 1,
1557
+ className: "oui-mt-3",
1558
+ children: [
1559
+ /* @__PURE__ */ jsxRuntime.jsx(
1560
+ ui.Text,
1561
+ {
1562
+ className: ui.cn(
1563
+ "oui-ml-4 oui-list-item oui-list-outside oui-list-disc oui-text-xs oui-text-base-contrast-36 marker:oui-text-3xs",
1564
+ filedError.length ? "oui-text-danger" : "oui-text-success"
1565
+ ),
1566
+ children: t("affiliate.referralCode.editCodeModal.helpText.length")
1567
+ }
1568
+ ),
1569
+ /* @__PURE__ */ jsxRuntime.jsx(
1570
+ ui.Text,
1571
+ {
1572
+ className: ui.cn(
1573
+ "oui-ml-4 oui-list-item oui-list-outside oui-list-disc oui-text-xs oui-text-base-contrast-36 marker:oui-text-3xs",
1574
+ "oui-text-success"
1575
+ ),
1576
+ children: t("affiliate.referralCode.editCodeModal.helpText.format")
1577
+ }
1578
+ )
1579
+ ]
1580
+ }
1581
+ )
1582
+ ]
1583
+ }
1584
+ );
1585
+ });
1586
+ var EditReferralRate = ui.modal.create((props) => {
1587
+ const { code, mutate } = props;
1588
+ const { visible, hide, resolve, reject, onOpenChange } = ui.useModal();
1589
+ const maxRate = new utils.Decimal(code.max_rebate_rate).mul(100);
1590
+ const [refereeRebateRate, setRefereeRebateRate] = react.useState(
1591
+ `${new utils.Decimal(code.referee_rebate_rate).mul(100)}`
1592
+ );
1593
+ const [referrerRebateRate, setReferrerRebateRate] = react.useState(
1594
+ `${new utils.Decimal(code.referrer_rebate_rate).mul(100)}`
1595
+ );
1596
+ const [showError, setShowError] = react.useState(false);
1597
+ const inputRef = react.useRef(null);
1598
+ const { t } = i18n.useTranslation();
1599
+ react.useEffect(() => {
1600
+ if (inputRef?.current) {
1601
+ inputRef.current.focus();
1602
+ inputRef.current.setSelectionRange(
1603
+ inputRef.current.value.length,
1604
+ inputRef.current.value.length
1605
+ );
1606
+ }
1607
+ }, [inputRef]);
1608
+ react.useEffect(() => {
1609
+ setRefereeRebateRate(`${new utils.Decimal(code.referee_rebate_rate).mul(100)}`);
1610
+ setReferrerRebateRate(`${new utils.Decimal(code.referrer_rebate_rate).mul(100)}`);
1611
+ }, [code]);
1612
+ const [editRate, { error, isMutating }] = hooks.useMutation(
1613
+ "/v1/referral/edit_split",
1614
+ "POST"
1615
+ );
1616
+ const onClickConfirm = async () => {
1617
+ try {
1618
+ const r1 = Number.parseFloat(refereeRebateRate);
1619
+ const r2 = Number.parseFloat(referrerRebateRate);
1620
+ await editRate({
1621
+ referral_code: code.code,
1622
+ referee_rebate_rate: r1 / 100,
1623
+ referrer_rebate_rate: r2 / 100
1624
+ });
1625
+ ui.toast.success(t("affiliate.referralRate.editRateModal.success"));
1626
+ mutate();
1627
+ hide();
1628
+ } catch (e) {
1629
+ ui.toast.error(e?.message || e || "");
1630
+ }
1631
+ };
1632
+ return /* @__PURE__ */ jsxRuntime.jsx(ui.Dialog, { open: visible, onOpenChange, children: /* @__PURE__ */ jsxRuntime.jsxs(
1633
+ ui.DialogContent,
1634
+ {
1635
+ className: "oui-px-6 oui-max-w-[320px] oui-bg-base-8 oui-shadow-[0px_12px_20px_0px_rgba(0,0,0,0.25)]",
1636
+ closable: true,
1637
+ children: [
1638
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.DialogTitle, { children: [
1639
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-my-3", children: t("affiliate.referralRate.editRateModal.title") }),
1640
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Divider, {})
1641
+ ] }),
1642
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-mt-3 oui-h-full oui-flex oui-flex-col oui-justify-end", children: [
1643
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-text-xs oui-text-base-contrast-54", children: t("affiliate.referralRate.editRateModal.description") }),
1644
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-text-xs oui-text-base-contrast-80 oui-mt-2 oui-flex", children: [
1645
+ t("affiliate.referralRate.editRateModal.label"),
1646
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-text-warning-darken oui-pl-1", children: `${new utils.Decimal(
1647
+ code.max_rebate_rate
1648
+ ).mul(100).toFixed(0, utils.Decimal.ROUND_DOWN)}%` })
1649
+ ] }),
1650
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-text-2xs oui-mt-6 oui-text-base-contrast-80", children: t("affiliate.referralRate.editRateModal.label.you") }),
1651
+ /* @__PURE__ */ jsxRuntime.jsx(
1652
+ ui.Input,
1653
+ {
1654
+ ref: inputRef,
1655
+ containerClassName: "oui-h-[40px] oui-mt-3 oui-bg-base-700 oui-outline oui-outline-1 oui-outline-base-contrast-12 focus-within:oui-outline-primary-darken",
1656
+ placeholder: "Enter code",
1657
+ type: "text",
1658
+ inputMode: "decimal",
1659
+ autoComplete: "off",
1660
+ value: referrerRebateRate,
1661
+ onChange: (e) => {
1662
+ const text = hooks.cleanStringStyle(e.target.value);
1663
+ const rate = Number.parseFloat(text);
1664
+ setReferrerRebateRate(text);
1665
+ if (!Number.isNaN(rate)) {
1666
+ setRefereeRebateRate(
1667
+ `${maxDecimal(new utils.Decimal(0), maxRate.sub(rate))}`
1668
+ );
1669
+ setShowError(maxRate.sub(rate) < new utils.Decimal(0));
1670
+ } else {
1671
+ setRefereeRebateRate("");
1672
+ setReferrerRebateRate("");
1673
+ }
1674
+ },
1675
+ suffix: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-px-3 oui-text-base-contrast-54 oui-text-base", children: "%" }),
1676
+ color: showError ? "danger" : void 0
1677
+ }
1678
+ ),
1679
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-text-2xs oui-mt-6 oui-text-base-contrast-80", children: t("affiliate.referralRate.editRateModal.label.referee") }),
1680
+ /* @__PURE__ */ jsxRuntime.jsx(
1681
+ ui.Input,
1682
+ {
1683
+ containerClassName: "oui-h-[40px] oui-mt-3 oui-bg-base-700 oui-outline oui-outline-1 oui-outline-base-contrast-12 focus-within:oui-outline-primary-darken",
1684
+ placeholder: "Enter code",
1685
+ type: "text",
1686
+ inputMode: "decimal",
1687
+ autoComplete: "off",
1688
+ autoFocus: false,
1689
+ value: refereeRebateRate,
1690
+ onChange: (e) => {
1691
+ const text = hooks.cleanStringStyle(e.target.value);
1692
+ const rate = Number.parseFloat(text);
1693
+ setRefereeRebateRate(text);
1694
+ if (!Number.isNaN(rate)) {
1695
+ setReferrerRebateRate(
1696
+ `${maxDecimal(new utils.Decimal(0), maxRate.sub(rate))}`
1697
+ );
1698
+ setShowError(maxRate.sub(rate) < new utils.Decimal(0));
1699
+ } else {
1700
+ setRefereeRebateRate("");
1701
+ setReferrerRebateRate("");
1702
+ }
1703
+ },
1704
+ suffix: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-px-3 oui-text-base-contrast-54 oui-text-base", children: "%" }),
1705
+ color: showError ? "danger" : void 0
1706
+ }
1707
+ ),
1708
+ showError && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-text-danger oui-text-xs oui-mt-8 oui-text-center oui-px-4", children: t("affiliate.referralRate.editRateModal.helpText.max") }),
1709
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { width: "100%", justify: "center", children: /* @__PURE__ */ jsxRuntime.jsx(
1710
+ ui.Button,
1711
+ {
1712
+ id: "referral_bind_referral_code_btn",
1713
+ disabled: refereeRebateRate.length === 0 || referrerRebateRate.length === 0 || showError,
1714
+ loading: isMutating,
1715
+ className: ui.cn(
1716
+ "oui-mt-8 oui-mb-4 oui-w-[154px]",
1717
+ showError && "oui-mt-3"
1718
+ ),
1719
+ onClick: (e) => {
1720
+ e.stopPropagation();
1721
+ onClickConfirm();
1722
+ },
1723
+ children: t("common.confirm")
1724
+ }
1725
+ ) })
1726
+ ] })
1727
+ ]
1728
+ }
1729
+ ) });
1730
+ });
1731
+ function maxDecimal(a, b) {
1732
+ return a > b ? a : b;
1733
+ }
1734
+
1735
+ // src/pages/affiliate/referralCodes/referralCodes.script.tsx
1736
+ var useReferralCodesScript = () => {
1737
+ const { referralInfo, referralLinkUrl, mutate, generateCode } = useReferralContext();
1738
+ const copyLink = (code) => {
1739
+ copyText(addQueryParam(referralLinkUrl, "ref", code));
1740
+ };
1741
+ const copyCode = (code) => {
1742
+ copyText(code);
1743
+ };
1744
+ const editRate = (code) => {
1745
+ ui.modal.show(EditReferralRate, { code: { ...code }, mutate });
1746
+ };
1747
+ const editCode = (code) => {
1748
+ ui.modal.show(EditCodeModal, {
1749
+ code: { ...code },
1750
+ successCallback: () => {
1751
+ mutate();
1752
+ }
1753
+ });
1754
+ };
1755
+ const [pinCodes, setPinCodes] = hooks.useLocalStorage(
1756
+ "orderly_referral_codes",
1757
+ []
1758
+ );
1759
+ const setPinCode = (code, del) => {
1760
+ if (del) {
1761
+ const index = pinCodes.findIndex((item) => item === code);
1762
+ if (index !== -1) {
1763
+ pinCodes.splice(index, 1);
1764
+ }
1765
+ } else {
1766
+ pinCodes.splice(0, 0, code);
1767
+ }
1768
+ if (pinCodes.length > 6) {
1769
+ pinCodes.splice(pinCodes.length - 1, 1);
1770
+ }
1771
+ setPinCodes([...pinCodes]);
1772
+ };
1773
+ const codes = react.useMemo(() => {
1774
+ if (!referralInfo?.referrer_info?.referral_codes) {
1775
+ return void 0;
1776
+ }
1777
+ const referralCodes = referralInfo?.referrer_info?.referral_codes?.map((item) => {
1778
+ if (generateCode && generateCode.code === item.code) {
1779
+ item.isAutoGenerated = true;
1780
+ }
1781
+ return item;
1782
+ });
1783
+ const pinedItems = [];
1784
+ for (let i = 0; i < pinCodes.length; i++) {
1785
+ const code = pinCodes[i];
1786
+ const index = referralCodes.findIndex((item) => item.code === code);
1787
+ if (index !== -1) {
1788
+ pinedItems.push({ ...referralCodes[index], isPined: true });
1789
+ referralCodes.splice(index, 1);
1790
+ }
1791
+ }
1792
+ return [...pinedItems, ...referralCodes];
1793
+ }, [referralInfo?.referrer_info?.referral_codes, pinCodes, generateCode]);
1794
+ return {
1795
+ copyCode,
1796
+ copyLink,
1797
+ editRate,
1798
+ editCode,
1799
+ setPinCode,
1800
+ codes
1801
+ };
1802
+ };
1803
+ var ReferralCodesWidget = () => {
1804
+ const state = useReferralCodesScript();
1805
+ return /* @__PURE__ */ jsxRuntime.jsx(ReferralCodes, { ...state });
1806
+ };
1807
+ var CommissionAndReferees = (props) => {
1808
+ const { t } = i18n.useTranslation();
1809
+ return /* @__PURE__ */ jsxRuntime.jsx(
1810
+ ui.Flex,
1811
+ {
1812
+ id: "oui-affiliate-affiliate-commissionAndReferees",
1813
+ r: "2xl",
1814
+ p: 6,
1815
+ width: "100%",
1816
+ gap: 4,
1817
+ direction: "column",
1818
+ className: "oui-bg-base-9 oui-tabular-nums",
1819
+ children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Tabs, { defaultValue: "account", className: "oui-w-full", variant: "contained", children: [
1820
+ /* @__PURE__ */ jsxRuntime.jsx(ui.TabPanel, { value: "account", title: t("affiliate.commission"), children: /* @__PURE__ */ jsxRuntime.jsx(CommissionList, { ...props }) }),
1821
+ /* @__PURE__ */ jsxRuntime.jsx(ui.TabPanel, { value: "password", title: t("affiliate.myReferees"), children: /* @__PURE__ */ jsxRuntime.jsx(RefereesList, { ...props }) })
1822
+ ] })
1823
+ }
1824
+ );
1825
+ };
1826
+ var MobileCellItem2 = (props) => {
1827
+ const { title, value, align, className, rule, formatString, prefix } = props;
1828
+ return /* @__PURE__ */ jsxRuntime.jsx(
1829
+ ui.Statistic,
1830
+ {
1831
+ className: ui.cn("oui-flex-1", className),
1832
+ label: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "oui-text-base-contrast-36 oui-text-2xs", children: title }),
1833
+ align,
1834
+ children: /* @__PURE__ */ jsxRuntime.jsx(
1835
+ ui.Text.formatted,
1836
+ {
1837
+ rule: rule || "",
1838
+ formatString,
1839
+ prefix,
1840
+ className: "oui-text-base-contrast-80 oui-text-sm oui-mt-[6px]",
1841
+ children: value
1842
+ }
1843
+ )
1844
+ }
1845
+ );
1846
+ };
1847
+ var CommissionList = (props) => {
1848
+ const { t } = i18n.useTranslation();
1849
+ const isLG = hooks.useMediaQuery("(max-width: 767px)");
1850
+ const columns = react.useMemo(() => {
1851
+ const cols = [
1852
+ {
1853
+ title: `${t("affiliate.commission")} (USDC)`,
1854
+ dataIndex: "referral_rebate",
1855
+ render: (value) => /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: utils.commifyOptional(value, {
1856
+ fix: 6,
1857
+ fallback: "0",
1858
+ padEnd: true,
1859
+ prefix: "$"
1860
+ }) }),
1861
+ width: 216
1862
+ },
1863
+ {
1864
+ title: `${t("affiliate.referralVol")} (USDC)`,
1865
+ dataIndex: "volume",
1866
+ render: (value) => /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: utils.commifyOptional(value, {
1867
+ fix: 2,
1868
+ fallback: "0",
1869
+ padEnd: true,
1870
+ prefix: "$"
1871
+ }) }),
1872
+ width: 216
1873
+ },
1874
+ {
1875
+ title: t("affiliate.commission.column.activeUsers"),
1876
+ dataIndex: "daily_traded_referral",
1877
+ render: (value) => /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: value }),
1878
+ width: 216
1879
+ },
1880
+ {
1881
+ title: t("common.date"),
1882
+ dataIndex: "date",
1883
+ render: (value) => formatYMDTime(value),
1884
+ width: 216
1885
+ }
1886
+ ];
1887
+ return cols;
1888
+ }, [t]);
1889
+ const body = react.useMemo(() => {
1890
+ if (isLG) {
1891
+ return /* @__PURE__ */ jsxRuntime.jsx(
1892
+ ui.ListView,
1893
+ {
1894
+ className: "oui-max-h-[200px] oui-w-full",
1895
+ dataSource: props.commission.data,
1896
+ loadMore: props.commission.loadMore,
1897
+ isLoading: props.commission.isLoading,
1898
+ renderItem: (e) => {
1899
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1900
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "row", width: "100%", children: [
1901
+ /* @__PURE__ */ jsxRuntime.jsx(
1902
+ MobileCellItem2,
1903
+ {
1904
+ title: t("affiliate.commission"),
1905
+ value: utils.commifyOptional(e.referral_rebate, {
1906
+ fix: 6,
1907
+ fallback: "0",
1908
+ padEnd: true
1909
+ }),
1910
+ prefix: "$"
1911
+ }
1912
+ ),
1913
+ /* @__PURE__ */ jsxRuntime.jsx(
1914
+ MobileCellItem2,
1915
+ {
1916
+ title: t("affiliate.referralVol"),
1917
+ value: utils.commifyOptional(e.volume, {
1918
+ fix: 2,
1919
+ fallback: "0",
1920
+ padEnd: true
1921
+ }),
1922
+ prefix: "$"
1923
+ }
1924
+ ),
1925
+ /* @__PURE__ */ jsxRuntime.jsx(
1926
+ MobileCellItem2,
1927
+ {
1928
+ title: t("affiliate.commission.column.activeUsers"),
1929
+ value: e.daily_traded_referral
1930
+ }
1931
+ ),
1932
+ /* @__PURE__ */ jsxRuntime.jsx(
1933
+ MobileCellItem2,
1934
+ {
1935
+ title: t("common.date"),
1936
+ value: e.date,
1937
+ rule: "date",
1938
+ formatString: "yyyy-MM-dd",
1939
+ align: "end"
1940
+ }
1941
+ )
1942
+ ] }),
1943
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { className: "oui-mt-3 oui-w-full" })
1944
+ ] });
1945
+ }
1946
+ }
1947
+ );
1948
+ }
1949
+ return /* @__PURE__ */ jsxRuntime.jsx(
1950
+ uiConnector.AuthGuardDataTable,
1951
+ {
1952
+ bordered: true,
1953
+ columns,
1954
+ loading: props.commission.isLoading,
1955
+ ignoreLoadingCheck: true,
1956
+ dataSource: props.commission.data,
1957
+ pagination: props.commission.pagination,
1958
+ onRow: (record) => {
1959
+ return {
1960
+ className: "oui-h-[41px]"
1961
+ };
1962
+ }
1963
+ }
1964
+ );
1965
+ }, [isLG, props.commission]);
1966
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1967
+ ui.Flex,
1968
+ {
1969
+ direction: "column",
1970
+ width: "100%",
1971
+ justify: "start",
1972
+ itemAlign: "start",
1973
+ children: [
1974
+ /* @__PURE__ */ jsxRuntime.jsx(
1975
+ DateFiler,
1976
+ {
1977
+ value: props.commission.dateRange,
1978
+ setValue: props.commission.setDateRange
1979
+ }
1980
+ ),
1981
+ body
1982
+ ]
1983
+ }
1984
+ );
1985
+ };
1986
+ var RefereesList = (props) => {
1987
+ const { t } = i18n.useTranslation();
1988
+ const isLG = hooks.useMediaQuery("(max-width: 767px)");
1989
+ const columns = react.useMemo(() => {
1990
+ const cols = [
1991
+ {
1992
+ title: t("affiliate.referees.column.refereeAddress"),
1993
+ dataIndex: "user_address",
1994
+ render: (value) => /* @__PURE__ */ jsxRuntime.jsx(ui.Text.formatted, { rule: "address", children: value }),
1995
+ className: "oui-w-1/5"
1996
+ },
1997
+ {
1998
+ title: t("affiliate.referralCode"),
1999
+ dataIndex: "referral_code",
2000
+ // render: (value) => value,
2001
+ className: "oui-w-1/5"
2002
+ },
2003
+ {
2004
+ title: `${t("affiliate.referees.column.totalCommission")} (USDC)`,
2005
+ dataIndex: "referral_rebate",
2006
+ render: (value) => /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: utils.commifyOptional(value, { fix: 6, prefix: "$", padEnd: true }) }),
2007
+ className: "oui-w-1/5"
2008
+ },
2009
+ {
2010
+ title: `${t("affiliate.referees.column.totalVol")} (USDC)`,
2011
+ dataIndex: "volume",
2012
+ render: (value) => /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: utils.commifyOptional(value, { fix: 2, prefix: "$", padEnd: true }) }),
2013
+ className: "oui-w-1/5"
2014
+ },
2015
+ {
2016
+ title: t("affiliate.referees.column.invitationTime"),
2017
+ dataIndex: "code_binding_time",
2018
+ render: (value) => /* @__PURE__ */ jsxRuntime.jsx(
2019
+ ui.Text.formatted,
2020
+ {
2021
+ rule: "date",
2022
+ formatString: "yyyy-MM-dd",
2023
+ children: value
2024
+ }
2025
+ ),
2026
+ className: "oui-w-1/5"
2027
+ }
2028
+ ];
2029
+ return cols;
2030
+ }, [t]);
2031
+ const body = react.useMemo(() => {
2032
+ if (isLG) {
2033
+ return /* @__PURE__ */ jsxRuntime.jsx(
2034
+ ui.ListView,
2035
+ {
2036
+ className: "oui-w-full oui-max-h-[200px]",
2037
+ dataSource: props.referees.data,
2038
+ loadMore: props.referees.loadMore,
2039
+ isLoading: props.referees.isLoading,
2040
+ renderItem: (e, index) => {
2041
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2042
+ ui.Flex,
2043
+ {
2044
+ direction: "column",
2045
+ gap: 3,
2046
+ className: "oui-border-b-2 oui-border-line-6 oui-pb-3",
2047
+ children: [
2048
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "row", width: "100%", children: [
2049
+ /* @__PURE__ */ jsxRuntime.jsx(
2050
+ MobileCellItem2,
2051
+ {
2052
+ title: t("affiliate.referralCode"),
2053
+ value: e.referral_code
2054
+ }
2055
+ ),
2056
+ /* @__PURE__ */ jsxRuntime.jsx(
2057
+ MobileCellItem2,
2058
+ {
2059
+ title: `${t(
2060
+ "affiliate.referees.column.totalCommission"
2061
+ )} (USDC)`,
2062
+ value: utils.commifyOptional(e.referral_rebate, {
2063
+ fix: 6,
2064
+ prefix: "$",
2065
+ padEnd: true
2066
+ }),
2067
+ className: "oui-min-w-[102px]"
2068
+ }
2069
+ ),
2070
+ /* @__PURE__ */ jsxRuntime.jsx(
2071
+ MobileCellItem2,
2072
+ {
2073
+ title: t("affiliate.referees.column.totalVol"),
2074
+ value: utils.commifyOptional(e.volume, {
2075
+ fix: 2,
2076
+ prefix: "$",
2077
+ padEnd: true
2078
+ }),
2079
+ align: "end"
2080
+ }
2081
+ )
2082
+ ] }),
2083
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "row", pt: 3, gap: 3, width: "100%", children: [
2084
+ /* @__PURE__ */ jsxRuntime.jsx(
2085
+ MobileCellItem2,
2086
+ {
2087
+ title: t("affiliate.referees.column.refereeAddress"),
2088
+ value: e.user_address,
2089
+ rule: "address"
2090
+ }
2091
+ ),
2092
+ /* @__PURE__ */ jsxRuntime.jsx(
2093
+ MobileCellItem2,
2094
+ {
2095
+ title: t("affiliate.referees.column.invitationTime"),
2096
+ value: e.code_binding_time,
2097
+ align: "end",
2098
+ rule: "date",
2099
+ formatString: "yyyy-MM-dd"
2100
+ }
2101
+ )
2102
+ ] })
2103
+ ]
2104
+ },
2105
+ index
2106
+ );
2107
+ }
2108
+ }
2109
+ );
2110
+ }
2111
+ return /* @__PURE__ */ jsxRuntime.jsx(
2112
+ uiConnector.AuthGuardDataTable,
2113
+ {
2114
+ bordered: true,
2115
+ loading: props.referees.isLoading,
2116
+ ignoreLoadingCheck: true,
2117
+ columns,
2118
+ dataSource: props.referees.data,
2119
+ pagination: props.referees.pagination,
2120
+ onRow: (record) => {
2121
+ return {
2122
+ className: "oui-h-[41px]"
2123
+ };
2124
+ }
2125
+ }
2126
+ );
2127
+ }, [isLG, props.referees]);
2128
+ return /* @__PURE__ */ jsxRuntime.jsx(
2129
+ ui.Flex,
2130
+ {
2131
+ direction: "column",
2132
+ width: "100%",
2133
+ justify: "start",
2134
+ itemAlign: "start",
2135
+ children: body
2136
+ }
2137
+ );
2138
+ };
2139
+ var DateFiler = (props) => {
2140
+ return /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { width: "100%", height: 49, className: "oui-border-b oui-border-line-6", children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(
2141
+ ui.DatePicker.range,
2142
+ {
2143
+ size: "xs",
2144
+ value: props.value,
2145
+ onChange: (range) => {
2146
+ props.setValue(range);
2147
+ },
2148
+ max: 90,
2149
+ disabled: {
2150
+ after: /* @__PURE__ */ new Date()
2151
+ }
2152
+ }
2153
+ ) }) });
2154
+ };
2155
+ var useCommissionAndRefereesScript = () => {
2156
+ const commission = useCommissionDataScript();
2157
+ const referees = useRefereesDataScript();
2158
+ return {
2159
+ commission,
2160
+ referees
2161
+ };
2162
+ };
2163
+ var useCommissionDataScript = () => {
2164
+ const [commissionRange, setCommissionRange] = react.useState(
2165
+ {
2166
+ from: dateFns.subDays(/* @__PURE__ */ new Date(), 90),
2167
+ to: dateFns.subDays(/* @__PURE__ */ new Date(), 1)
2168
+ }
2169
+ );
2170
+ const isLG = hooks.useMediaQuery("(max-width: 767px)");
2171
+ const { page, pageSize, setPage, parsePagination } = ui.usePagination();
2172
+ const [commissionData, { refresh, isLoading, loadMore, meta }] = hooks.useReferralRebateSummary({
2173
+ startDate: commissionRange?.from !== void 0 ? dateFns.format(commissionRange.from, "yyyy-MM-dd") : void 0,
2174
+ endDate: commissionRange?.to !== void 0 ? dateFns.format(commissionRange.to, "yyyy-MM-dd") : void 0,
2175
+ size: pageSize,
2176
+ page: !isLG ? page : void 0
2177
+ });
2178
+ react.useEffect(() => {
2179
+ refresh();
2180
+ }, [commissionRange]);
2181
+ const pagination = react.useMemo(
2182
+ () => parsePagination(meta),
2183
+ [parsePagination, meta]
2184
+ );
2185
+ react.useEffect(() => {
2186
+ setPage(1);
2187
+ }, [commissionRange]);
2188
+ return {
2189
+ data: commissionData || void 0,
2190
+ pagination,
2191
+ dateRange: commissionRange,
2192
+ setDateRange: setCommissionRange,
2193
+ isLoading,
2194
+ loadMore
2195
+ };
2196
+ };
2197
+ var useRefereesDataScript = () => {
2198
+ const [commissionRange, setCommissionRange] = react.useState(
2199
+ {
2200
+ from: dateFns.subDays(/* @__PURE__ */ new Date(), 90),
2201
+ to: dateFns.subDays(/* @__PURE__ */ new Date(), 1)
2202
+ }
2203
+ );
2204
+ const isLG = hooks.useMediaQuery("(max-width: 767px)");
2205
+ const { page, pageSize, setPage, parsePagination } = ui.usePagination();
2206
+ const [commissionData, { refresh, isLoading, loadMore, meta }] = hooks.useRefereeInfo({
2207
+ startDate: commissionRange?.from !== void 0 ? dateFns.format(commissionRange.from, "yyyy-MM-dd") : void 0,
2208
+ endDate: commissionRange?.to !== void 0 ? dateFns.format(commissionRange.to, "yyyy-MM-dd") : void 0,
2209
+ size: pageSize,
2210
+ page: !isLG ? page : void 0,
2211
+ sort: "descending_code_binding_time"
2212
+ });
2213
+ react.useEffect(() => {
2214
+ refresh();
2215
+ }, [commissionRange]);
2216
+ const pagination = react.useMemo(
2217
+ () => parsePagination(meta),
2218
+ [parsePagination, meta]
2219
+ );
2220
+ react.useEffect(() => {
2221
+ setPage(1);
2222
+ }, [commissionRange]);
2223
+ return {
2224
+ data: commissionData || void 0,
2225
+ pagination,
2226
+ dateRange: commissionRange,
2227
+ setDateRange: setCommissionRange,
2228
+ isLoading,
2229
+ loadMore
2230
+ };
2231
+ };
2232
+ var CommissionAndRefereesWidget = () => {
2233
+ const state = useCommissionAndRefereesScript();
2234
+ return /* @__PURE__ */ jsxRuntime.jsx(CommissionAndReferees, { ...state });
2235
+ };
2236
+ var AffiliatePage = () => {
2237
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2238
+ ui.Flex,
2239
+ {
2240
+ id: "oui-affiliate-affiliate-page",
2241
+ className: ui.cn(
2242
+ "oui-h-lvw",
2243
+ // padding
2244
+ // "oui-p-4 lg:oui-p-6 xl:oui-p-3",
2245
+ "oui-font-semibold"
2246
+ ),
2247
+ direction: "column",
2248
+ gap: 4,
2249
+ children: [
2250
+ /* @__PURE__ */ jsxRuntime.jsx(Layout, {}),
2251
+ /* @__PURE__ */ jsxRuntime.jsx(CommissionAndRefereesWidget, {})
2252
+ ]
2253
+ }
2254
+ );
2255
+ };
2256
+ var Layout = () => {
2257
+ const is2XL = hooks.useMediaQuery("(max-width: 1279px)");
2258
+ if (is2XL) {
2259
+ return /* @__PURE__ */ jsxRuntime.jsx(Layout1024, {});
2260
+ }
2261
+ return /* @__PURE__ */ jsxRuntime.jsx(Layout1280, {});
2262
+ };
2263
+ var Layout1024 = () => {
2264
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2265
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-flex oui-flex-col xl:oui-flex-row oui-gap-4 oui-w-full", children: [
2266
+ /* @__PURE__ */ jsxRuntime.jsx(SummaryWidget, {}),
2267
+ /* @__PURE__ */ jsxRuntime.jsx(ReferralLinkWidget, {})
2268
+ ] }),
2269
+ /* @__PURE__ */ jsxRuntime.jsx(TitleStatisticWidget, {}),
2270
+ /* @__PURE__ */ jsxRuntime.jsx(ReferralCodesWidget, {})
2271
+ ] });
2272
+ };
2273
+ var Layout1280 = () => {
2274
+ return /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "row", itemAlign: "stretch", gap: 4, children: [
2275
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "column", gap: 4, className: "oui-flex-1 oui-w-1/2", children: [
2276
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-flex-1 oui-h-full oui-w-full", children: /* @__PURE__ */ jsxRuntime.jsx(SummaryWidget, {}) }),
2277
+ /* @__PURE__ */ jsxRuntime.jsx(TitleStatisticWidget, {})
2278
+ ] }),
2279
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "column", gap: 4, className: "oui-w-1/2", children: [
2280
+ /* @__PURE__ */ jsxRuntime.jsx(ReferralLinkWidget, {}),
2281
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-flex-1", children: /* @__PURE__ */ jsxRuntime.jsx(ReferralCodesWidget, {}) })
2282
+ ] })
2283
+ ] });
2284
+ };
2285
+ var BecomeAffiliate = (props) => {
2286
+ const { t } = i18n.useTranslation();
2287
+ const { generateCode } = useReferralContext();
2288
+ const applyText = react.useMemo(() => {
2289
+ if (!generateCode) {
2290
+ return {
2291
+ title: t("affiliate.process.step1.title"),
2292
+ desc: t("affiliate.process.step1.description")
2293
+ };
2294
+ }
2295
+ if (generateCode.requireVolume > 0) {
2296
+ return {
2297
+ title: t("affiliate.process.step1.volumeGt0.title", {
2298
+ requireVolume: generateCode.requireVolume
2299
+ }),
2300
+ desc: t("affiliate.process.step1.volumeGt0.description", {
2301
+ volume: utils.commify(generateCode.completedVolume ?? 0, 2),
2302
+ requireVolume: utils.commify(generateCode.requireVolume)
2303
+ })
2304
+ };
2305
+ }
2306
+ return {
2307
+ title: t("affiliate.process.step1.volumeEq0.title"),
2308
+ desc: t("affiliate.process.step1.volumeEq0.description")
2309
+ };
2310
+ }, [generateCode, t]);
2311
+ if (typeof props.overwrite === "function") {
2312
+ return props.overwrite?.(props.state);
2313
+ }
2314
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2315
+ ui.Flex,
2316
+ {
2317
+ id: "oui-affiliate-home-becomeAffiliate",
2318
+ direction: "column",
2319
+ gap: 6,
2320
+ p: 6,
2321
+ itemAlign: "center",
2322
+ r: "2xl",
2323
+ className: "oui-bg-base-9",
2324
+ width: "100%",
2325
+ children: [
2326
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: t("affiliate.process.title") }),
2327
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { className: "oui-flex oui-flex-col oui-gap-3 lg:oui-w-full lg:oui-flex-row lg:oui-items-stretch", children: [
2328
+ /* @__PURE__ */ jsxRuntime.jsx(
2329
+ Item,
2330
+ {
2331
+ icon: /* @__PURE__ */ jsxRuntime.jsx(ApplyIcon, {}),
2332
+ title: applyText.title,
2333
+ content: applyText.desc
2334
+ }
2335
+ ),
2336
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-shrink lg:oui-flex lg:-oui-rotate-90 lg:oui-flex-row lg:oui-items-center lg:oui-justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(ArrowDownIcon, {}) }),
2337
+ /* @__PURE__ */ jsxRuntime.jsx(
2338
+ Item,
2339
+ {
2340
+ icon: /* @__PURE__ */ jsxRuntime.jsx(ShareIcon, {}),
2341
+ title: t("affiliate.process.step2.title"),
2342
+ content: t("affiliate.process.step2.description")
2343
+ }
2344
+ ),
2345
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-shrink lg:oui-flex lg:-oui-rotate-90 lg:oui-flex-row lg:oui-items-center lg:oui-justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(ArrowDownIcon, {}) }),
2346
+ /* @__PURE__ */ jsxRuntime.jsx(
2347
+ Item,
2348
+ {
2349
+ icon: /* @__PURE__ */ jsxRuntime.jsx(EarnIcon, {}),
2350
+ title: t("affiliate.process.step3.title"),
2351
+ content: t("affiliate.process.step3.description")
2352
+ }
2353
+ )
2354
+ ] })
2355
+ ]
2356
+ }
2357
+ );
2358
+ };
2359
+ var Item = (props) => {
2360
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2361
+ ui.Flex,
2362
+ {
2363
+ className: ui.cn(
2364
+ "oui-flex oui-flex-row oui-gap-3",
2365
+ "lg:oui-flex-1 lg:oui-flex-col lg:oui-gap-[6px]"
2366
+ ),
2367
+ width: "100%",
2368
+ children: [
2369
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-shrink-0", children: props.icon }),
2370
+ /* @__PURE__ */ jsxRuntime.jsxs(
2371
+ ui.Flex,
2372
+ {
2373
+ className: ui.cn(
2374
+ "oui-flex oui-flex-col oui-items-start oui-h-full oui-justify-between",
2375
+ // lg
2376
+ "lg:oui-items-center lg:oui-justify-start"
2377
+ ),
2378
+ children: [
2379
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "oui-text-sm md:oui-text-base 2xl:oui-text-lg lg:oui-text-center", children: props.title }),
2380
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "oui-text-2xs oui-text-base-contrast-36 lg:oui-text-center", children: props.content })
2381
+ ]
2382
+ }
2383
+ )
2384
+ ]
2385
+ }
2386
+ );
2387
+ };
2388
+ var ApplyIcon = () => {
2389
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2390
+ "svg",
2391
+ {
2392
+ width: "48",
2393
+ height: "48",
2394
+ viewBox: "0 0 48 48",
2395
+ fill: "none",
2396
+ xmlns: "http://www.w3.org/2000/svg",
2397
+ className: "lg:oui-w-[64px] lg:oui-h-[64px] 2xl:oui-w-[80px] 2xl:oui-h-[80px]",
2398
+ children: [
2399
+ /* @__PURE__ */ jsxRuntime.jsx(
2400
+ "path",
2401
+ {
2402
+ fillRule: "evenodd",
2403
+ clipRule: "evenodd",
2404
+ d: "M24.941 5.4h-6.682a.6.6 0 0 0-.593.509l-.462 3a.6.6 0 0 0 .593.691h7.606a.6.6 0 0 0 .593-.691l-.462-3a.6.6 0 0 0-.593-.509m-6.682-1.8a2.4 2.4 0 0 0-2.372 2.035l-.462 3a2.4 2.4 0 0 0 2.372 2.765h7.606a2.4 2.4 0 0 0 2.372-2.765l-.462-3A2.4 2.4 0 0 0 24.941 3.6z",
2405
+ fill: "#fff",
2406
+ fillOpacity: ".36"
2407
+ }
2408
+ ),
2409
+ /* @__PURE__ */ jsxRuntime.jsx(
2410
+ "path",
2411
+ {
2412
+ d: "M32.721 28.2c.924-1.6 3.233-1.6 4.157 0l7.275 12.6c.924 1.6-.231 3.6-2.079 3.6H27.525c-1.848 0-3.002-2-2.078-3.6z",
2413
+ fill: "#335FFC"
2414
+ }
2415
+ ),
2416
+ /* @__PURE__ */ jsxRuntime.jsx(
2417
+ "path",
2418
+ {
2419
+ d: "M33.492 38.12H31.56c-.252 0-.426-.276-.336-.535l1.92-5.53a.4.4 0 0 1 .132-.185.34.34 0 0 1 .204-.07h3.24c.255 0 .43.284.333.544l-1.118 3.011h2.104c.31 0 .475.4.27.656l-5.158 6.453c-.251.313-.716.041-.619-.362z",
2420
+ fill: "#fff",
2421
+ fillOpacity: ".98"
2422
+ }
2423
+ ),
2424
+ /* @__PURE__ */ jsxRuntime.jsx(
2425
+ "path",
2426
+ {
2427
+ fillRule: "evenodd",
2428
+ clipRule: "evenodd",
2429
+ d: "M14.4 16.8v2.4h2.4v-2.4zM13.2 15a.6.6 0 0 0-.6.6v4.8a.6.6 0 0 0 .6.6H18a.6.6 0 0 0 .6-.6v-4.8a.6.6 0 0 0-.6-.6z",
2430
+ fill: "#fff",
2431
+ fillOpacity: ".36"
2432
+ }
2433
+ ),
2434
+ /* @__PURE__ */ jsxRuntime.jsx(
2435
+ "path",
2436
+ {
2437
+ d: "M20.4 16.2a.6.6 0 0 1 .6-.6h2.4a.6.6 0 0 1 .6.6v.6a.6.6 0 0 1-.6.6H21a.6.6 0 0 1-.6-.6zm0 3a.6.6 0 0 1 .6-.6h9a.6.6 0 0 1 .6.6v.6a.6.6 0 0 1-.6.6h-9a.6.6 0 0 1-.6-.6zm-7.8 5.4a.6.6 0 0 1 .6-.6H30a.6.6 0 0 1 .6.6v.6a.6.6 0 0 1-.6.6H13.2a.6.6 0 0 1-.6-.6zm0 3.6a.6.6 0 0 1 .6-.6H30a.6.6 0 0 1 .6.6v.6a.6.6 0 0 1-.6.6H13.2a.6.6 0 0 1-.6-.6zm0 3.6a.6.6 0 0 1 .6-.6h9a.6.6 0 0 1 .6.6v.6a.6.6 0 0 1-.6.6h-9a.6.6 0 0 1-.6-.6z",
2438
+ fill: "#fff",
2439
+ fillOpacity: ".36"
2440
+ }
2441
+ ),
2442
+ /* @__PURE__ */ jsxRuntime.jsx(
2443
+ "path",
2444
+ {
2445
+ fillRule: "evenodd",
2446
+ clipRule: "evenodd",
2447
+ d: "M15.739 6.6H10.2A2.4 2.4 0 0 0 7.8 9v30a2.4 2.4 0 0 0 2.4 2.4h13.84l1.014-1.8H10.2a.6.6 0 0 1-.6-.6V9a.6.6 0 0 1 .6-.6h5.262zm12 1.8H33a.6.6 0 0 1 .6.6v16.47a2.8 2.8 0 0 1 1.8-.205V9A2.4 2.4 0 0 0 33 6.6h-5.538z",
2448
+ fill: "#fff",
2449
+ fillOpacity: ".36"
2450
+ }
2451
+ )
2452
+ ]
2453
+ }
2454
+ );
2455
+ };
2456
+ var ShareIcon = () => {
2457
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2458
+ "svg",
2459
+ {
2460
+ width: "48",
2461
+ height: "48",
2462
+ viewBox: "0 0 48 48",
2463
+ fill: "none",
2464
+ xmlns: "http://www.w3.org/2000/svg",
2465
+ className: "lg:oui-w-[64px] lg:oui-h-[64px] 2xl:oui-w-[80px] 2xl:oui-h-[80px]",
2466
+ children: [
2467
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M24 33a9 9 0 1 1-18 0 9 9 0 0 1 18 0", fill: "#335FFC" }),
2468
+ /* @__PURE__ */ jsxRuntime.jsx(
2469
+ "path",
2470
+ {
2471
+ fillRule: "evenodd",
2472
+ clipRule: "evenodd",
2473
+ d: "M15 32.4a1.8 1.8 0 1 0 0-3.6 1.8 1.8 0 0 0 0 3.6m0 1.8a3.6 3.6 0 1 0 0-7.2 3.6 3.6 0 0 0 0 7.2m-6.578 4.942A4.8 4.8 0 0 1 13.2 34.8h3.6a4.8 4.8 0 0 1 4.778 4.342 9 9 0 0 1-1.778 1.473V39.6a3 3 0 0 0-3-3h-3.6a3 3 0 0 0-3 3v1.015a9 9 0 0 1-1.778-1.473",
2474
+ fill: "#fff",
2475
+ fillOpacity: ".98"
2476
+ }
2477
+ ),
2478
+ /* @__PURE__ */ jsxRuntime.jsx(
2479
+ "path",
2480
+ {
2481
+ fillRule: "evenodd",
2482
+ clipRule: "evenodd",
2483
+ d: "M16.2 12a4.2 4.2 0 1 1-8.4 0 4.2 4.2 0 0 1 8.4 0m1.8 0c0 1.37-.459 2.632-1.231 3.642l2.308 2.308a7.76 7.76 0 0 1 4.023-1.7v-.764A3.602 3.602 0 0 1 24 8.4a3.6 3.6 0 0 1 .9 7.087v.764c1.48.17 2.833.754 3.942 1.633l2.326-2.326a6 6 0 1 1 1.273 1.273l-2.326 2.326a7.76 7.76 0 0 1 1.634 3.943h.764a3.602 3.602 0 0 1 7.087.9 3.6 3.6 0 0 1-7.087.9h-.764a7.76 7.76 0 0 1-1.699 4.023l2.308 2.308a6 6 0 1 1-1.25 1.295l-2.347-2.347a7.8 7.8 0 0 1-3.05 1.433 11 11 0 0 0-.377-1.76 6 6 0 1 0-7.185-7.185q-.855-.261-1.76-.379a7.8 7.8 0 0 1 1.432-3.049l-2.347-2.347A6 6 0 1 1 18 12m7.8 0a1.8 1.8 0 1 1-3.6 0 1.8 1.8 0 0 1 3.6 0M36 25.8a1.8 1.8 0 1 0 0-3.6 1.8 1.8 0 0 0 0 3.6m0-9.6a4.2 4.2 0 1 0 0-8.4 4.2 4.2 0 0 0 0 8.4M40.2 36a4.2 4.2 0 1 1-8.4 0 4.2 4.2 0 0 1 8.4 0",
2484
+ fill: "#fff",
2485
+ fillOpacity: ".36"
2486
+ }
2487
+ )
2488
+ ]
2489
+ }
2490
+ );
2491
+ };
2492
+ var EarnIcon = () => {
2493
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2494
+ "svg",
2495
+ {
2496
+ width: "48",
2497
+ height: "48",
2498
+ viewBox: "0 0 48 48",
2499
+ fill: "none",
2500
+ xmlns: "http://www.w3.org/2000/svg",
2501
+ className: "lg:oui-w-[64px] lg:oui-h-[64px] 2xl:oui-w-[80px] 2xl:oui-h-[80px]",
2502
+ children: [
2503
+ /* @__PURE__ */ jsxRuntime.jsx(
2504
+ "path",
2505
+ {
2506
+ fillRule: "evenodd",
2507
+ clipRule: "evenodd",
2508
+ d: "M24 24a2.4 2.4 0 1 0 0-4.8 2.4 2.4 0 0 0 0 4.8m0 1.8a4.2 4.2 0 1 0 0-8.4 4.2 4.2 0 0 0 0 8.4",
2509
+ fill: "#fff",
2510
+ fillOpacity: ".36"
2511
+ }
2512
+ ),
2513
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M45 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0", fill: "#335FFC" }),
2514
+ /* @__PURE__ */ jsxRuntime.jsx(
2515
+ "path",
2516
+ {
2517
+ fillRule: "evenodd",
2518
+ clipRule: "evenodd",
2519
+ d: "M35.1 6.6a.9.9 0 1 1 1.8 0v.437A3 3 0 0 1 39 9.9h-1.8a1.2 1.2 0 1 0-1.2 1.2 3 3 0 0 1 .9 5.863v.437a.9.9 0 0 1-1.8 0v-.437A3 3 0 0 1 33 14.1h1.8a1.2 1.2 0 1 0 1.2-1.2 3 3 0 0 1-.9-5.863z",
2520
+ fill: "#fff",
2521
+ fillOpacity: ".98"
2522
+ }
2523
+ ),
2524
+ /* @__PURE__ */ jsxRuntime.jsx(
2525
+ "path",
2526
+ {
2527
+ fillRule: "evenodd",
2528
+ clipRule: "evenodd",
2529
+ d: "M40.2 23.7a.9.9 0 0 1 1.8 0v.6q0 .045-.004.086c-.197 9.351-7.525 16.948-16.765 17.573l1.205 1.205a.9.9 0 1 1-1.272 1.272l-2.7-2.7a.9.9 0 0 1 0-1.272l2.7-2.7a.9.9 0 1 1 1.272 1.272l-1.11 1.11c8.325-.674 14.87-7.642 14.874-16.14zM21.564 4.836a.9.9 0 1 1 1.272-1.272l2.7 2.7a.9.9 0 0 1 0 1.272l-2.7 2.7a.9.9 0 1 1-1.272-1.272l1.11-1.11C14.347 8.528 7.8 15.5 7.8 24v.3a.9.9 0 1 1-1.8 0v-.6l.004-.086C6.201 14.263 13.53 6.666 22.77 6.042z",
2530
+ fill: "#fff",
2531
+ fillOpacity: ".36"
2532
+ }
2533
+ ),
2534
+ /* @__PURE__ */ jsxRuntime.jsx(
2535
+ "path",
2536
+ {
2537
+ fillRule: "evenodd",
2538
+ clipRule: "evenodd",
2539
+ d: "M24 11.4q.615 0 1.213.058a11 11 0 0 0 .061 1.816Q24.647 13.2 24 13.2c-5.965 0-10.8 4.835-10.8 10.8 0 2.898 1.142 5.53 3 7.47a4.8 4.8 0 0 1 4.8-4.79h6a4.8 4.8 0 0 1 4.8 4.789c1.858-1.94 3-4.572 3-7.47q0-.647-.074-1.274a11 11 0 0 0 1.816.06q.057.6.058 1.214c0 6.959-5.641 12.6-12.6 12.6S11.4 30.959 11.4 24 17.041 11.4 24 11.4m6 21.581v-1.5a3 3 0 0 0-3-3h-6a3 3 0 0 0-3 3v1.5a10.75 10.75 0 0 0 6 1.819c2.22 0 4.284-.67 6-1.819",
2540
+ fill: "#fff",
2541
+ fillOpacity: ".36"
2542
+ }
2543
+ )
2544
+ ]
2545
+ }
2546
+ );
2547
+ };
2548
+ var ArrowDownIcon = () => {
2549
+ return /* @__PURE__ */ jsxRuntime.jsx(
2550
+ "svg",
2551
+ {
2552
+ width: "17",
2553
+ height: "16",
2554
+ viewBox: "0 0 17 16",
2555
+ fill: "none",
2556
+ xmlns: "http://www.w3.org/2000/svg",
2557
+ children: /* @__PURE__ */ jsxRuntime.jsx(
2558
+ "path",
2559
+ {
2560
+ d: "M8.5048 4.00806C8.8728 4.00806 9.1708 4.30626 9.1708 4.67406C9.1708 4.99259 9.1708 8.71739 9.1708 9.71072L11.1688 7.73339L12.1055 8.67005L8.98346 11.8127C8.85346 11.9434 8.6788 12.0081 8.50413 12.0081C8.33013 12.0081 8.15612 11.9427 8.02612 11.8127L4.90413 8.67005L5.8408 7.73339L7.83881 9.71072C7.83881 8.71739 7.83881 4.99259 7.83881 4.67406C7.83881 4.30626 8.1368 4.00806 8.5048 4.00806Z",
2561
+ fill: "#608CFF"
2562
+ }
2563
+ )
2564
+ }
2565
+ );
2566
+ };
2567
+
2568
+ // src/pages/home/becomeAffiliate/becomeAffiliate.script.tsx
2569
+ var useBecomeAffiliateScript = () => {
2570
+ const state = useReferralContext();
2571
+ return {
2572
+ overwrite: state.overwrite?.ref?.step,
2573
+ state
2574
+ };
2575
+ };
2576
+ var BecomeAffiliateWidget = () => {
2577
+ const state = useBecomeAffiliateScript();
2578
+ return /* @__PURE__ */ jsxRuntime.jsx(BecomeAffiliate, { ...state });
2579
+ };
2580
+ var Title5 = () => {
2581
+ const { t } = i18n.useTranslation();
2582
+ return /* @__PURE__ */ jsxRuntime.jsx(
2583
+ "div",
2584
+ {
2585
+ id: "oui-affiliate-home-title",
2586
+ className: "oui-text-center oui-text-3xl oui-font-bold md:oui-text-3xl lg:oui-text-4xl xl:oui-text-5xl",
2587
+ children: t("affiliate.page.title")
2588
+ }
2589
+ );
2590
+ };
2591
+ var TitleWidget = () => {
2592
+ return /* @__PURE__ */ jsxRuntime.jsx(Title5, {});
2593
+ };
2594
+ var Subtitle2 = (props) => {
2595
+ const { t } = i18n.useTranslation();
2596
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2597
+ ui.Flex,
2598
+ {
2599
+ id: "oui-affiliate-home-subtitle",
2600
+ direction: "column",
2601
+ className: "oui-text-sm md:oui-text-base xl:oui-text-lg oui-text-base-contrast-80 oui-text-center",
2602
+ gap: 3,
2603
+ children: [
2604
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: t("affiliate.page.subTitle") }),
2605
+ /* @__PURE__ */ jsxRuntime.jsxs(
2606
+ ui.Flex,
2607
+ {
2608
+ direction: "row",
2609
+ gap: 1,
2610
+ className: "oui-text-primary-light oui-fill-primary-light hover:oui-text-primary-darken oui-cursor-pointer oui-text-2xs md:oui-text-xs xl:oui-text-sm",
2611
+ onClick: (e) => {
2612
+ if (props.onLearnAffiliate) {
2613
+ props.onLearnAffiliate?.();
2614
+ } else if (props.learnAffiliateUrl) {
2615
+ window.open(props.learnAffiliateUrl, "_blank");
2616
+ }
2617
+ },
2618
+ children: [
2619
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: t("affiliate.page.learnMore") }),
2620
+ /* @__PURE__ */ jsxRuntime.jsx(
2621
+ "svg",
2622
+ {
2623
+ width: "16",
2624
+ height: "16",
2625
+ viewBox: "0 0 16 16",
2626
+ fill: "currentColor",
2627
+ xmlns: "http://www.w3.org/2000/svg",
2628
+ children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M4.008 7.995c0-.368.298-.666.666-.666H9.71L7.733 5.331l.937-.936 3.143 3.122c.13.13.195.304.195.479a.67.67 0 0 1-.195.478L8.67 11.596l-.937-.937 1.978-1.998H4.674a.666.666 0 0 1-.666-.666" })
2629
+ }
2630
+ )
2631
+ ]
2632
+ }
2633
+ )
2634
+ ]
2635
+ }
2636
+ );
2637
+ };
2638
+
2639
+ // src/pages/home/subtitle/subtitle.script.tsx
2640
+ var useSubtitleScript = () => {
2641
+ const state = useReferralContext();
2642
+ const { onLearnAffiliate, learnAffiliateUrl } = state;
2643
+ return {
2644
+ onLearnAffiliate,
2645
+ learnAffiliateUrl
2646
+ };
2647
+ };
2648
+ var SubtitleWidget = () => {
2649
+ const state = useSubtitleScript();
2650
+ return /* @__PURE__ */ jsxRuntime.jsx(Subtitle2, { ...state });
2651
+ };
2652
+ var Top = (props) => {
2653
+ if (props.overwriteTop !== void 0) {
2654
+ return props.overwriteTop?.(props.state);
2655
+ }
2656
+ return /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { id: "oui-affiliate-home-top", direction: "column", gap: 6, children: [
2657
+ /* @__PURE__ */ jsxRuntime.jsx(TitleWidget, {}),
2658
+ /* @__PURE__ */ jsxRuntime.jsx(SubtitleWidget, {})
2659
+ ] });
2660
+ };
2661
+
2662
+ // src/pages/home/top/top.script.tsx
2663
+ var useTopScript = () => {
2664
+ const state = useReferralContext();
2665
+ return {
2666
+ overwriteTop: state.overwrite?.ref?.top,
2667
+ state
2668
+ };
2669
+ };
2670
+ var TopWidget = () => {
2671
+ const state = useTopScript();
2672
+ return /* @__PURE__ */ jsxRuntime.jsx(Top, { ...state });
2673
+ };
2674
+ var ArrowRightIcon = (props) => {
2675
+ return /* @__PURE__ */ jsxRuntime.jsx(
2676
+ "svg",
2677
+ {
2678
+ width: "16",
2679
+ height: "16",
2680
+ viewBox: "0 0 16 16",
2681
+ fill: "white",
2682
+ fillOpacity: "0.98",
2683
+ xmlns: "http://www.w3.org/2000/svg",
2684
+ className: props.className,
2685
+ children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M4.00806 7.9952C4.00806 7.6272 4.30626 7.3292 4.67406 7.3292C4.99259 7.3292 8.71739 7.3292 9.71072 7.3292L7.73339 5.3312L8.67005 4.39453L11.8127 7.51654C11.9434 7.64654 12.0081 7.8212 12.0081 7.99587C12.0081 8.16987 11.9427 8.34388 11.8127 8.47388L8.67005 11.5959L7.73339 10.6592L9.71072 8.66119C8.71739 8.66119 4.99259 8.66119 4.67406 8.66119C4.30626 8.66119 4.00806 8.3632 4.00806 7.9952Z" })
2686
+ }
2687
+ );
2688
+ };
2689
+ var AsTrader = (props) => {
2690
+ const { t } = i18n.useTranslation();
2691
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2692
+ ui.Flex,
2693
+ {
2694
+ id: "oui-affiliate-home-asTrader",
2695
+ gradient: "success",
2696
+ r: "2xl",
2697
+ p: 6,
2698
+ gap: 6,
2699
+ direction: "column",
2700
+ angle: 180,
2701
+ width: "100%",
2702
+ justify: "between",
2703
+ children: [
2704
+ /* @__PURE__ */ jsxRuntime.jsxs(
2705
+ ui.Flex,
2706
+ {
2707
+ height: 80,
2708
+ direction: "row",
2709
+ gap: 3,
2710
+ itemAlign: "start",
2711
+ width: "100%",
2712
+ justify: "between",
2713
+ children: [
2714
+ /* @__PURE__ */ jsxRuntime.jsxs(
2715
+ ui.Flex,
2716
+ {
2717
+ direction: "column",
2718
+ itemAlign: "start",
2719
+ justify: "between",
2720
+ className: "oui-h-full",
2721
+ children: [
2722
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "oui-text-lg md:oui-text-xl lg:oui-text-2xl xl:oui-text-3xl", children: props.isTrader ? t("affiliate.trader") : t("affiliate.asTrader.title") }),
2723
+ /* @__PURE__ */ jsxRuntime.jsx(
2724
+ ui.Text,
2725
+ {
2726
+ className: ui.cn(
2727
+ "oui-text-xs oui-text-base-contrast-54 md:oui-text-sm 2xl:oui-text-base",
2728
+ props.isTrader && "oui-hidden"
2729
+ ),
2730
+ children: t("affiliate.asTrader.description")
2731
+ }
2732
+ )
2733
+ ]
2734
+ }
2735
+ ),
2736
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-shrink-0", children: /* @__PURE__ */ jsxRuntime.jsx(Icon, {}) })
2737
+ ]
2738
+ }
2739
+ ),
2740
+ /* @__PURE__ */ jsxRuntime.jsx(Bottom, { ...props })
2741
+ ]
2742
+ }
2743
+ );
2744
+ };
2745
+ var Icon = () => {
2746
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2747
+ "svg",
2748
+ {
2749
+ width: "72",
2750
+ height: "72",
2751
+ viewBox: "0 0 90 90",
2752
+ fill: "none",
2753
+ xmlns: "http://www.w3.org/2000/svg",
2754
+ className: "xl:oui-size-[90px] ",
2755
+ children: [
2756
+ /* @__PURE__ */ jsxRuntime.jsx(
2757
+ "path",
2758
+ {
2759
+ d: "M44.996 7.324c-20.71 0-37.43 16.79-37.5 37.5-.07 20.682 16.806 37.575 37.5 37.617 20.694.04 37.537-17.082 37.5-37.617-.037-20.71-16.79-37.5-37.5-37.5m0 7.5c16.569 0 30 13.433 30 30 0 8.438-3.514 16.043-9.12 21.495-2.762-5.973-8.694-10.245-15.49-10.245h-10.78c-6.791 0-12.706 4.22-15.47 10.197-5.606-5.453-9.14-13.01-9.14-21.447 0-16.567 13.431-30 30-30m0 7.5c-8.284 0-15 6.717-15 15s6.716 15 15 15 15-6.716 15-15-6.716-15-15-15",
2760
+ fill: "#fff",
2761
+ fillOpacity: ".2"
2762
+ }
2763
+ ),
2764
+ /* @__PURE__ */ jsxRuntime.jsx(
2765
+ "path",
2766
+ {
2767
+ d: "M90 71.25C90 81.605 81.605 90 71.25 90S52.5 81.605 52.5 71.25 60.895 52.5 71.25 52.5 90 60.895 90 71.25",
2768
+ fill: "#005A4F"
2769
+ }
2770
+ ),
2771
+ /* @__PURE__ */ jsxRuntime.jsx(
2772
+ "path",
2773
+ {
2774
+ d: "M80.62 75.007c0-.24-.08-.49-.263-.675l-3.487-3.456-1.318 1.318 1.845 1.875H63.745a.938.938 0 0 0 0 1.875h13.652l-1.845 1.875 1.318 1.318 3.487-3.456a.95.95 0 0 0 .263-.674m-.937-7.5a.94.94 0 0 0-.938-.938H65.093l1.846-1.875-1.319-1.318-3.486 3.456a.966.966 0 0 0 0 1.349l3.486 3.456 1.319-1.318-1.846-1.875h13.652c.518 0 .938-.42.938-.937",
2775
+ fill: "#fff",
2776
+ fillOpacity: ".98"
2777
+ }
2778
+ )
2779
+ ]
2780
+ }
2781
+ );
2782
+ };
2783
+ var Bottom = (props) => {
2784
+ const { t } = i18n.useTranslation();
2785
+ const content = () => {
2786
+ if (props.isTrader && !props.wrongNetwork) {
2787
+ const totalReferrerRebate = props.referralInfo?.referee_info?.total_referee_rebate;
2788
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2789
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "column", itemAlign: "start", gap: 2, children: [
2790
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { className: "oui-text-2xs md:oui-text-xs xl:oui-text-sm", children: [
2791
+ t("affiliate.commission"),
2792
+ " ",
2793
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { intensity: 36, children: "(USDC)" })
2794
+ ] }),
2795
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "row", gap: 1, children: [
2796
+ /* @__PURE__ */ jsxRuntime.jsx(USDCIcon, {}),
2797
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "oui-text-base md:oui-text-lg lg:oui-text-xl xl:oui-text-2xl", children: utils.commifyOptional(totalReferrerRebate, {
2798
+ fix: 2,
2799
+ fallback: "0"
2800
+ }) })
2801
+ ] })
2802
+ ] }),
2803
+ /* @__PURE__ */ jsxRuntime.jsxs(
2804
+ ui.Flex,
2805
+ {
2806
+ direction: "row",
2807
+ gap: 1,
2808
+ justify: "end",
2809
+ itemAlign: "center",
2810
+ className: "oui-cursor-pointer",
2811
+ onClick: props?.onEnterTraderPage,
2812
+ children: [
2813
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "oui-text-sm md:oui-text-base xl:oui-text-lg", children: t("affiliate.enter") }),
2814
+ /* @__PURE__ */ jsxRuntime.jsx(ArrowRightIcon, { className: "md:oui-size-[18px] lg:oui-size-[20px] xl:oui-size-[24px]" })
2815
+ ]
2816
+ }
2817
+ )
2818
+ ] });
2819
+ }
2820
+ return /* @__PURE__ */ jsxRuntime.jsx(EntryCode, { ...props });
2821
+ };
2822
+ return /* @__PURE__ */ jsxRuntime.jsx(
2823
+ ui.Flex,
2824
+ {
2825
+ direction: "row",
2826
+ justify: "between",
2827
+ width: "100%",
2828
+ itemAlign: "end",
2829
+ children: content()
2830
+ }
2831
+ );
2832
+ };
2833
+ var EntryCode = (props) => {
2834
+ const { t } = i18n.useTranslation();
2835
+ return /* @__PURE__ */ jsxRuntime.jsxs(ui.Dialog, { open: props.open, onOpenChange: props.setOpen, children: [
2836
+ /* @__PURE__ */ jsxRuntime.jsx(ui.DialogTrigger, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "contained", color: "light", children: t("affiliate.asTrader.button") }) }),
2837
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.DialogContent, { className: "oui-w-[320px] oui-font-semibold", children: [
2838
+ /* @__PURE__ */ jsxRuntime.jsx(ui.DialogHeader, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.DialogTitle, { children: t("affiliate.referralCode.dialog.title") }) }),
2839
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Divider, {}),
2840
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.DialogBody, { children: [
2841
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "sm", intensity: 54, children: t("affiliate.referralCode.dialog.description") }),
2842
+ /* @__PURE__ */ jsxRuntime.jsx(
2843
+ ui.TextField,
2844
+ {
2845
+ className: "oui-mt-4 oui-w-full",
2846
+ placeholder: t("affiliate.referralCode"),
2847
+ value: props.code,
2848
+ onChange: (e) => {
2849
+ const _value = e.target.value.toUpperCase().replace(/[^A-Z0-9]/g, "");
2850
+ props.setCode(_value);
2851
+ },
2852
+ formatters: [
2853
+ ui.inputFormatter.createRegexInputFormatter(
2854
+ (value) => {
2855
+ return String(value).replace(
2856
+ /[a-z]/g,
2857
+ (char) => char.toUpperCase()
2858
+ );
2859
+ }
2860
+ ),
2861
+ ui.inputFormatter.createRegexInputFormatter(/[^A-Z0-9]/g)
2862
+ ],
2863
+ onClean: () => {
2864
+ props.setCode("");
2865
+ },
2866
+ label: t("affiliate.referralCode.label"),
2867
+ classNames: {
2868
+ label: "oui-text-2xs oui-text-base-contrast-54"
2869
+ },
2870
+ helpText: !props.isExist && !props.isLoading && props.code.length > 0 ? t("affiliate.referralCode.notExist") : void 0,
2871
+ color: !props.isExist && !props.isLoading && props.code.length > 0 ? "danger" : void 0
2872
+ }
2873
+ ),
2874
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "column", gapY: 3, mt: 6, children: [
2875
+ props.warningMessage && /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "2xs", className: "oui-text-warning-darken", children: props.warningMessage }),
2876
+ /* @__PURE__ */ jsxRuntime.jsx(uiConnector.AuthGuard, { buttonProps: { size: "md", fullWidth: true }, children: /* @__PURE__ */ jsxRuntime.jsx(
2877
+ ui.Button,
2878
+ {
2879
+ variant: "contained",
2880
+ color: "primary",
2881
+ size: "md",
2882
+ className: "oui-px-[40px]",
2883
+ fullWidth: true,
2884
+ disabled: props.code.length < 4 || !props.isExist,
2885
+ onClick: (e) => {
2886
+ e.stopPropagation();
2887
+ props.onClickConfirm();
2888
+ },
2889
+ children: t("common.confirm")
2890
+ }
2891
+ ) })
2892
+ ] })
2893
+ ] })
2894
+ ] })
2895
+ ] });
2896
+ };
2897
+ var useAsTraderScript = () => {
2898
+ const { t } = i18n.useTranslation();
2899
+ const {
2900
+ isTrader,
2901
+ referralInfo,
2902
+ setShowHome,
2903
+ bindReferralCodeState,
2904
+ setTab,
2905
+ mutate
2906
+ } = useReferralContext();
2907
+ const { wrongNetwork, disabledConnect } = reactApp.useAppContext();
2908
+ const { state } = hooks.useAccount();
2909
+ const onEnterTraderPage = () => {
2910
+ setTab("trader" /* trader */);
2911
+ setShowHome(false);
2912
+ };
2913
+ const [code, setCode] = react.useState("");
2914
+ const [open, setOpen] = react.useState(false);
2915
+ const {
2916
+ isExist,
2917
+ error: checkCodeError,
2918
+ isLoading
2919
+ } = hooks.useCheckReferralCode(code);
2920
+ const hide = () => {
2921
+ setOpen(false);
2922
+ };
2923
+ const [bindCode, { error, isMutating }] = hooks.useMutation(
2924
+ "/v1/referral/bind",
2925
+ "POST"
2926
+ );
2927
+ const onClickConfirm = async () => {
2928
+ try {
2929
+ await bindCode({ referral_code: code });
2930
+ ui.toast.success(t("affiliate.referralCode.bound"));
2931
+ mutate();
2932
+ if (bindReferralCodeState) {
2933
+ bindReferralCodeState(true, null, hide, { tab: 1 });
2934
+ } else {
2935
+ hide();
2936
+ }
2937
+ } catch (e) {
2938
+ let errorText = `${e}`;
2939
+ if ("message" in e) {
2940
+ errorText = e.message;
2941
+ }
2942
+ if ("referral code not exist" === errorText) {
2943
+ errorText = t("affiliate.referralCode.notExist");
2944
+ }
2945
+ if (bindReferralCodeState) {
2946
+ ui.toast.error(errorText);
2947
+ bindReferralCodeState(false, e, hide, {});
2948
+ } else {
2949
+ ui.toast.error(errorText);
2950
+ }
2951
+ }
2952
+ };
2953
+ const { isMobile } = ui.useScreen();
2954
+ const authStatus = uiConnector.useAuthStatus();
2955
+ const warningMessage = react.useMemo(() => {
2956
+ const message = {
2957
+ [uiConnector.AuthStatusEnum.ConnectWallet]: t("affiliate.connectWallet.tooltip"),
2958
+ [uiConnector.AuthStatusEnum.CreateAccount]: t("affiliate.createAccount.tooltip"),
2959
+ [uiConnector.AuthStatusEnum.WrongNetwork]: t("connector.wrongNetwork.tooltip")
2960
+ };
2961
+ return message[authStatus];
2962
+ }, [authStatus]);
2963
+ return {
2964
+ isTrader,
2965
+ isLoading,
2966
+ referralInfo,
2967
+ onEnterTraderPage,
2968
+ code,
2969
+ setCode,
2970
+ open,
2971
+ setOpen,
2972
+ onClickConfirm,
2973
+ isExist,
2974
+ wrongNetwork,
2975
+ isMobile,
2976
+ warningMessage
2977
+ };
2978
+ };
2979
+ var AsTraderWidget = () => {
2980
+ const state = useAsTraderScript();
2981
+ return /* @__PURE__ */ jsxRuntime.jsx(AsTrader, { ...state });
2982
+ };
2983
+ var AsAnAffiliate = (props) => {
2984
+ const { t } = i18n.useTranslation();
2985
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2986
+ ui.Flex,
2987
+ {
2988
+ id: "oui-affiliate-home-asAnAffiliate",
2989
+ gradient: "primary",
2990
+ r: "2xl",
2991
+ p: 6,
2992
+ gap: 6,
2993
+ direction: "column",
2994
+ angle: 180,
2995
+ width: "100%",
2996
+ justify: "between",
2997
+ children: [
2998
+ /* @__PURE__ */ jsxRuntime.jsxs(
2999
+ ui.Flex,
3000
+ {
3001
+ direction: "row",
3002
+ gap: 3,
3003
+ itemAlign: "start",
3004
+ width: "100%",
3005
+ justify: "between",
3006
+ children: [
3007
+ /* @__PURE__ */ jsxRuntime.jsxs(
3008
+ ui.Flex,
3009
+ {
3010
+ direction: "column",
3011
+ itemAlign: "start",
3012
+ justify: "between",
3013
+ className: "oui-h-full",
3014
+ children: [
3015
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "oui-text-lg md:oui-text-xl lg:oui-text-2xl xl:oui-text-3xl", children: props.isAffiliate ? t("common.affiliate") : t("affiliate.asAffiliate.title") }),
3016
+ /* @__PURE__ */ jsxRuntime.jsx(
3017
+ ui.Text,
3018
+ {
3019
+ className: ui.cn(
3020
+ "oui-text-xs oui-text-base-contrast-54 md:oui-text-sm 2xl:oui-text-base",
3021
+ props.isAffiliate && "oui-hidden"
3022
+ ),
3023
+ children: t("affiliate.asAffiliate.description")
3024
+ }
3025
+ )
3026
+ ]
3027
+ }
3028
+ ),
3029
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-shrink-0", children: /* @__PURE__ */ jsxRuntime.jsx(Icon2, {}) })
3030
+ ]
3031
+ }
3032
+ ),
3033
+ /* @__PURE__ */ jsxRuntime.jsx(Bottom2, { ...props })
3034
+ ]
3035
+ }
3036
+ );
3037
+ };
3038
+ var Icon2 = () => {
3039
+ return /* @__PURE__ */ jsxRuntime.jsxs(
3040
+ "svg",
3041
+ {
3042
+ width: "72",
3043
+ height: "72",
3044
+ viewBox: "0 0 72 72",
3045
+ fill: "none",
3046
+ xmlns: "http://www.w3.org/2000/svg",
3047
+ className: "xl:oui-size-[90px]",
3048
+ children: [
3049
+ /* @__PURE__ */ jsxRuntime.jsx(
3050
+ "path",
3051
+ {
3052
+ d: "M35.997 5.86c-16.569 0-29.944 13.43-30 30-.056 16.545 13.445 30.06 30 30.093s30.03-13.665 30-30.093c-.03-16.57-13.432-30-30-30m0 6c13.255 0 24 10.746 24 24 0 6.75-2.812 12.834-7.297 17.196-2.209-4.78-6.955-8.196-12.39-8.196h-8.626c-5.432 0-10.164 3.375-12.375 8.157-4.485-4.362-7.312-10.407-7.312-17.157 0-13.254 10.745-24 24-24m0 6c-6.628 0-12 5.373-12 12s5.372 12 12 12c6.627 0 12-5.373 12-12s-5.373-12-12-12",
3053
+ fill: "#fff",
3054
+ fillOpacity: ".2"
3055
+ }
3056
+ ),
3057
+ /* @__PURE__ */ jsxRuntime.jsx(
3058
+ "path",
3059
+ {
3060
+ d: "M72 57c0 8.284-6.716 15-15 15s-15-6.716-15-15 6.716-15 15-15 15 6.716 15 15",
3061
+ fill: "#1828C3"
3062
+ }
3063
+ ),
3064
+ /* @__PURE__ */ jsxRuntime.jsx(
3065
+ "path",
3066
+ {
3067
+ d: "M53.624 51.45a4.125 4.125 0 0 0-4.125 4.125c0 2.388 1.36 4.641 3.61 6.703a21 21 0 0 0 2.414 1.875c.287.194.556.37.797.516.147.089.243.154.304.187a.79.79 0 0 0 .75 0c.061-.033.158-.098.305-.187.24-.147.51-.322.797-.516a21 21 0 0 0 2.414-1.875c2.25-2.062 3.61-4.315 3.61-6.703a4.125 4.125 0 0 0-4.126-4.125c-1.294 0-2.557.705-3.351 1.734-.775-1.047-2.034-1.734-3.399-1.734",
3068
+ fill: "#fff",
3069
+ fillOpacity: ".98"
3070
+ }
3071
+ )
3072
+ ]
3073
+ }
3074
+ );
3075
+ };
3076
+ var Bottom2 = (props) => {
3077
+ const { t } = i18n.useTranslation();
3078
+ const content = () => {
3079
+ if (props.isAffiliate && !props.wrongNetwork) {
3080
+ const totalReferrerRebate = props.referralInfo?.referrer_info?.total_referrer_rebate;
3081
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3082
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "column", itemAlign: "start", gap: 2, children: [
3083
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { className: "oui-text-2xs md:oui-text-xs xl:oui-text-sm", children: [
3084
+ t("affiliate.commission"),
3085
+ " ",
3086
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { intensity: 36, children: "(USDC)" })
3087
+ ] }),
3088
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "row", gap: 1, children: [
3089
+ /* @__PURE__ */ jsxRuntime.jsx(USDCIcon, {}),
3090
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "oui-text-base md:oui-text-lg lg:oui-text-xl xl:oui-text-2xl", children: utils.commifyOptional(totalReferrerRebate, {
3091
+ fix: 2,
3092
+ fallback: "0"
3093
+ }) })
3094
+ ] })
3095
+ ] }),
3096
+ /* @__PURE__ */ jsxRuntime.jsxs(
3097
+ ui.Flex,
3098
+ {
3099
+ direction: "row",
3100
+ gap: 1,
3101
+ justify: "end",
3102
+ itemAlign: "center",
3103
+ className: "oui-cursor-pointer",
3104
+ onClick: props.onEnterAffiliatePage,
3105
+ children: [
3106
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "oui-text-sm md:oui-text-base xl:oui-text-lg", children: t("affiliate.enter") }),
3107
+ /* @__PURE__ */ jsxRuntime.jsx(ArrowRightIcon, { className: "md:oui-size-[18px] lg:oui-size-[20px] xl:oui-size-[24px]" })
3108
+ ]
3109
+ }
3110
+ )
3111
+ ] });
3112
+ }
3113
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3114
+ /* @__PURE__ */ jsxRuntime.jsx(
3115
+ ui.Button,
3116
+ {
3117
+ variant: "contained",
3118
+ color: "light",
3119
+ onClick: props.becomeAnAffiliate,
3120
+ children: t("affiliate.asAffiliate.button")
3121
+ }
3122
+ ),
3123
+ /* @__PURE__ */ jsxRuntime.jsxs(
3124
+ ui.Flex,
3125
+ {
3126
+ direction: "column",
3127
+ justify: "between",
3128
+ className: "oui-h-full",
3129
+ itemAlign: "end",
3130
+ children: [
3131
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "oui-text-base md:oui-text-lg lg:oui-text-xl 2xl:oui-text-2xl", children: t("affiliate.upTo") }),
3132
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "oui-text-2xs oui-text-base-contrast-54 md:oui-text-xs 2xl:oui-text-sm", children: t("affiliate.commission") })
3133
+ ]
3134
+ }
3135
+ )
3136
+ ] });
3137
+ };
3138
+ return /* @__PURE__ */ jsxRuntime.jsx(
3139
+ ui.Flex,
3140
+ {
3141
+ direction: "row",
3142
+ justify: "between",
3143
+ width: "100%",
3144
+ itemAlign: "end",
3145
+ children: content()
3146
+ }
3147
+ );
3148
+ };
3149
+ var useAsAnAffiliateScript = () => {
3150
+ const {
3151
+ isAffiliate,
3152
+ isLoading,
3153
+ referralInfo,
3154
+ becomeAnAffiliateUrl,
3155
+ setShowHome,
3156
+ setTab
3157
+ } = useReferralContext();
3158
+ const { wrongNetwork } = reactApp.useAppContext();
3159
+ const becomeAnAffiliate = () => {
3160
+ window.open(becomeAnAffiliateUrl, "_blank");
3161
+ };
3162
+ const onEnterAffiliatePage = () => {
3163
+ setTab("affiliate" /* affiliate */);
3164
+ setShowHome(false);
3165
+ };
3166
+ const { isMobile } = ui.useScreen();
3167
+ return {
3168
+ isAffiliate,
3169
+ isLoading,
3170
+ referralInfo,
3171
+ onEnterAffiliatePage,
3172
+ becomeAnAffiliate,
3173
+ wrongNetwork,
3174
+ isMobile
3175
+ };
3176
+ };
3177
+ var AsAnAffiliateWidget = () => {
3178
+ const state = useAsAnAffiliateScript();
3179
+ return /* @__PURE__ */ jsxRuntime.jsx(AsAnAffiliate, { ...state });
3180
+ };
3181
+ var Card = (props) => {
3182
+ if (typeof props.overwrite === "function") {
3183
+ return props.overwrite?.(props.state);
3184
+ }
3185
+ return /* @__PURE__ */ jsxRuntime.jsxs(
3186
+ ui.Flex,
3187
+ {
3188
+ id: "oui-affiliate-home-card",
3189
+ className: "oui-flex oui-w-full oui-flex-col oui-items-stretch oui-gap-6 xl:oui-flex-row xl:oui-gap-[36px]",
3190
+ children: [
3191
+ /* @__PURE__ */ jsxRuntime.jsx(AsAnAffiliateWidget, {}),
3192
+ /* @__PURE__ */ jsxRuntime.jsx(AsTraderWidget, {})
3193
+ ]
3194
+ }
3195
+ );
3196
+ };
3197
+
3198
+ // src/pages/home/card/card.script.tsx
3199
+ var useCardScript = () => {
3200
+ const state = useReferralContext();
3201
+ return {
3202
+ overwrite: state.overwrite?.ref?.card,
3203
+ state
3204
+ };
3205
+ };
3206
+ var CardWidget = () => {
3207
+ const state = useCardScript();
3208
+ return /* @__PURE__ */ jsxRuntime.jsx(Card, { ...state });
3209
+ };
3210
+ var HomePage = () => {
3211
+ return /* @__PURE__ */ jsxRuntime.jsxs(
3212
+ ui.Flex,
3213
+ {
3214
+ id: "oui-affiliate-home-page",
3215
+ className: ui.cn(
3216
+ "oui-h-lvw ",
3217
+ // padding
3218
+ // "oui-p-4 lg:oui-p-6 xl:oui-p-3",
3219
+ "oui-font-semibold"
3220
+ ),
3221
+ direction: "column",
3222
+ gap: 4,
3223
+ children: [
3224
+ /* @__PURE__ */ jsxRuntime.jsx(TopWidget, {}),
3225
+ /* @__PURE__ */ jsxRuntime.jsx(CardWidget, {}),
3226
+ /* @__PURE__ */ jsxRuntime.jsx(BecomeAffiliateWidget, {})
3227
+ ]
3228
+ }
3229
+ );
3230
+ };
3231
+ var Summary2 = (props) => {
3232
+ const { t } = i18n.useTranslation();
3233
+ return /* @__PURE__ */ jsxRuntime.jsxs(
3234
+ ui.Flex,
3235
+ {
3236
+ id: "oui-affiliate-trader-summary",
3237
+ r: "2xl",
3238
+ p: 6,
3239
+ width: "100%",
3240
+ height: "100%",
3241
+ gap: 4,
3242
+ direction: "column",
3243
+ className: "oui-bg-base-9 xl:oui-flex-1",
3244
+ children: [
3245
+ /* @__PURE__ */ jsxRuntime.jsx(Title6, { ...props }),
3246
+ /* @__PURE__ */ jsxRuntime.jsx(Rebate, { className: "md:oui-hidden", ...props }),
3247
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "column", gap: 3, width: "100%", className: "md:oui-mt-3", children: [
3248
+ /* @__PURE__ */ jsxRuntime.jsx(SummaryFilter, { ...props }),
3249
+ /* @__PURE__ */ jsxRuntime.jsx(CommissionData2, { ...props })
3250
+ ] }),
3251
+ /* @__PURE__ */ jsxRuntime.jsx(Row2, { title: `${t("affiliate.trader.tradingVol")} (USDC)`, ...props })
3252
+ ]
3253
+ }
3254
+ );
3255
+ };
3256
+ var Title6 = (props) => {
3257
+ const { t } = i18n.useTranslation();
3258
+ return /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "row", width: "100%", gap: 3, children: [
3259
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "row", gap: 3, className: "oui-flex-1", children: [
3260
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "oui-text-lg", children: t("affiliate.trader.yourReferrer") }),
3261
+ /* @__PURE__ */ jsxRuntime.jsx(
3262
+ ui.Button,
3263
+ {
3264
+ color: "secondary",
3265
+ size: "sm",
3266
+ className: "oui-text-primary-light oui-text-2xs md:oui-text-xs 2xl:oui-text-sm oui-bg-base-6",
3267
+ children: props.code
3268
+ }
3269
+ )
3270
+ ] }),
3271
+ /* @__PURE__ */ jsxRuntime.jsx(
3272
+ Rebate,
3273
+ {
3274
+ className: "oui-hidden md:oui-flex md:oui-flex-shrink md:oui-w-fit",
3275
+ ...props
3276
+ }
3277
+ )
3278
+ ] });
3279
+ };
3280
+ var Rebate = (props) => {
3281
+ const { t } = i18n.useTranslation();
3282
+ return /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "row", width: "100%", gap: 2, className: props.className, children: [
3283
+ /* @__PURE__ */ jsxRuntime.jsx(
3284
+ ui.Text,
3285
+ {
3286
+ intensity: 54,
3287
+ className: "oui-text-sm md:oui-text-base 2xl:oui-text-lg",
3288
+ children: `${t("affiliate.trader.rebate")}:`
3289
+ }
3290
+ ),
3291
+ /* @__PURE__ */ jsxRuntime.jsx(
3292
+ ui.Text.gradient,
3293
+ {
3294
+ color: "brand",
3295
+ className: "oui-text-lg md:oui-text-xl 2xl:oui-text-2xl",
3296
+ children: props.rebateText
3297
+ }
3298
+ )
3299
+ ] });
3300
+ };
3301
+ var SummaryFilter = (props) => {
3302
+ const { t } = i18n.useTranslation();
3303
+ return /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "row", width: "100%", justify: "between", gap: 3, children: [
3304
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "oui-text-sm", children: t("affiliate.summary") }),
3305
+ /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(
3306
+ ui.Select.options,
3307
+ {
3308
+ size: "xs",
3309
+ value: props.period,
3310
+ onValueChange: props.onPeriodChange,
3311
+ options: props.periodTypes
3312
+ }
3313
+ ) })
3314
+ ] });
3315
+ };
3316
+ var CommissionData2 = (props) => {
3317
+ const { t } = i18n.useTranslation();
3318
+ return /* @__PURE__ */ jsxRuntime.jsxs(
3319
+ ui.Flex,
3320
+ {
3321
+ gradient: "success",
3322
+ angle: 180,
3323
+ r: "xl",
3324
+ py: 4,
3325
+ px: 6,
3326
+ width: "100%",
3327
+ direction: "column",
3328
+ gap: 3,
3329
+ children: [
3330
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { intensity: 54, className: "oui-text-base 2xl:oui-text-lg", children: `${t("affiliate.trader.rebates")} (USDC)` }),
3331
+ /* @__PURE__ */ jsxRuntime.jsxs(
3332
+ ui.Flex,
3333
+ {
3334
+ direction: "row",
3335
+ gap: 3,
3336
+ className: "oui-text-xl md:oui-text-2xl xl:oui-text-3xl",
3337
+ children: [
3338
+ /* @__PURE__ */ jsxRuntime.jsx(USDCIcon, { className: "md:oui-w-[24px] md:oui-h-[24px] lg:oui-w-[28px] lg:oui-h-[28px] " }),
3339
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: utils.commifyOptional(props.rebates, { fix: 2, fallback: "0" }) })
3340
+ ]
3341
+ }
3342
+ )
3343
+ ]
3344
+ }
3345
+ );
3346
+ };
3347
+ var Row2 = (props) => {
3348
+ return /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "row", justify: "between", width: "100%", children: [
3349
+ /* @__PURE__ */ jsxRuntime.jsx(
3350
+ ui.Text,
3351
+ {
3352
+ intensity: 54,
3353
+ className: "oui-text-2xs md:oui-text-xs xl:oui-text-sm",
3354
+ children: props.title
3355
+ }
3356
+ ),
3357
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "oui-text-xs md:oui-text-sm xl:oui-text-base", children: utils.commifyOptional(props.vol, { fix: 2, fallback: "0" }) })
3358
+ ] });
3359
+ };
3360
+ var useSummaryScript2 = () => {
3361
+ const { t } = i18n.useTranslation();
3362
+ const [period, setPeriod] = react.useState("All");
3363
+ const periodTypes = [
3364
+ { label: t("common.all"), value: "All" },
3365
+ { label: t("common.select.1d"), value: "1D" },
3366
+ { label: t("common.select.7d"), value: "7D" },
3367
+ { label: t("common.select.30d"), value: "30D" }
3368
+ ];
3369
+ const { referralInfo, userVolume } = useReferralContext();
3370
+ const rebates = react.useMemo(() => {
3371
+ if (!referralInfo)
3372
+ return 0;
3373
+ switch (period) {
3374
+ case "All":
3375
+ return referralInfo.referee_info.total_referee_rebate;
3376
+ case "1D":
3377
+ return referralInfo.referee_info["1d_referee_rebate"];
3378
+ case "7D":
3379
+ return referralInfo.referee_info["7d_referee_rebate"];
3380
+ case "30D":
3381
+ return referralInfo.referee_info["30d_referee_rebate"];
3382
+ }
3383
+ }, [referralInfo, period]);
3384
+ const vol = react.useMemo(() => {
3385
+ if (!userVolume)
3386
+ return void 0;
3387
+ switch (period) {
3388
+ case "All":
3389
+ return userVolume.all_volume;
3390
+ case "1D":
3391
+ return userVolume["1d_volume"];
3392
+ case "7D":
3393
+ return userVolume["7d_volume"];
3394
+ case "30D":
3395
+ return userVolume["30d_volume"];
3396
+ }
3397
+ }, [userVolume, period]);
3398
+ const code = referralInfo?.referee_info?.referer_code;
3399
+ const rebate = referralInfo?.referee_info?.referee_rebate_rate;
3400
+ const rebateText = react.useMemo(() => {
3401
+ if (!!rebate) {
3402
+ return new utils.Decimal(rebate).mul(100).toDecimalPlaces(2, utils.Decimal.ROUND_DOWN).toString() + "%";
3403
+ }
3404
+ return "-";
3405
+ }, [rebate]);
3406
+ const onPeriodChange = (item) => {
3407
+ setPeriod(item);
3408
+ };
3409
+ return {
3410
+ period,
3411
+ periodTypes,
3412
+ onPeriodChange,
3413
+ rebates,
3414
+ vol,
3415
+ rebateText,
3416
+ code
3417
+ };
3418
+ };
3419
+ var SummaryWidget2 = () => {
3420
+ const state = useSummaryScript2();
3421
+ return /* @__PURE__ */ jsxRuntime.jsx(Summary2, { ...state });
3422
+ };
3423
+ var TitleStatistic2 = (props) => {
3424
+ return /* @__PURE__ */ jsxRuntime.jsxs(
3425
+ ui.Flex,
3426
+ {
3427
+ id: "oui-affiliate-trader-titleStatistic",
3428
+ r: "2xl",
3429
+ p: 6,
3430
+ width: "100%",
3431
+ gap: 4,
3432
+ direction: "column",
3433
+ className: "oui-bg-base-9 xl:oui-flex-1",
3434
+ children: [
3435
+ /* @__PURE__ */ jsxRuntime.jsx(Title7, { ...props }),
3436
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { className: "oui-min-h-[170px] oui-h-full oui-w-full oui-flex oui-flex-row oui-items-stretch", children: /* @__PURE__ */ jsxRuntime.jsx(
3437
+ chart.VolBarChart,
3438
+ {
3439
+ data: props.dataSource,
3440
+ colors: { fill: "rgba(0, 180, 158, 1)" },
3441
+ className: "oui-w-full oui-flex-1",
3442
+ tooltip: {
3443
+ rm: utils.Decimal.ROUND_DOWN,
3444
+ dp: props.volType === "volume" ? 2 : 6
3445
+ }
3446
+ }
3447
+ ) })
3448
+ ]
3449
+ }
3450
+ );
3451
+ };
3452
+ var Title7 = (props) => {
3453
+ const { t } = i18n.useTranslation();
3454
+ return /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "row", justify: "between", width: "100%", children: [
3455
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "oui-text-lg", children: t("affiliate.statistics") }),
3456
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "row", gap: 2, className: "oui-min-w-14", children: [
3457
+ /* @__PURE__ */ jsxRuntime.jsx(
3458
+ ui.Select.options,
3459
+ {
3460
+ size: "xs",
3461
+ value: props.period,
3462
+ onValueChange: props.onPeriodChange,
3463
+ options: props.periodTypes
3464
+ }
3465
+ ),
3466
+ /* @__PURE__ */ jsxRuntime.jsx(
3467
+ ui.Select.options,
3468
+ {
3469
+ size: "xs",
3470
+ value: props.volType,
3471
+ onValueChange: props.onVolTypeChange,
3472
+ options: props.volTypes
3473
+ }
3474
+ )
3475
+ ] })
3476
+ ] });
3477
+ };
3478
+ var useTitleStatisticScript2 = () => {
3479
+ const { t } = i18n.useTranslation();
3480
+ const [period, setPeriod] = react.useState("7");
3481
+ const periodTypes = [
3482
+ { label: t("common.select.7d"), value: "7" },
3483
+ { label: t("common.select.30d"), value: "30" },
3484
+ { label: t("common.select.90d"), value: "90" }
3485
+ ];
3486
+ const onPeriodChange = (item) => {
3487
+ setPeriod(item);
3488
+ };
3489
+ const [volType, setVolType] = react.useState("rebate");
3490
+ const volTypes = [
3491
+ { label: t("affiliate.trader.rebate"), value: "rebate" },
3492
+ { label: t("common.volume"), value: "volume" }
3493
+ ];
3494
+ const onVolTypeChange = (item) => {
3495
+ setVolType(item);
3496
+ };
3497
+ const dateRange = react.useMemo(() => {
3498
+ if (period === "7") {
3499
+ return {
3500
+ startDate: dateFns.subDays(/* @__PURE__ */ new Date(), 7),
3501
+ endDate: dateFns.subDays(/* @__PURE__ */ new Date(), 1)
3502
+ };
3503
+ } else if (period === "30") {
3504
+ return {
3505
+ startDate: dateFns.subDays(/* @__PURE__ */ new Date(), 30),
3506
+ endDate: dateFns.subDays(/* @__PURE__ */ new Date(), 1)
3507
+ };
3508
+ } else if (period === "90") {
3509
+ return {
3510
+ startDate: dateFns.subDays(/* @__PURE__ */ new Date(), 90),
3511
+ endDate: dateFns.subDays(/* @__PURE__ */ new Date(), 1)
3512
+ };
3513
+ } else {
3514
+ return {
3515
+ startDate: dateFns.subDays(/* @__PURE__ */ new Date(), 7),
3516
+ endDate: dateFns.subDays(/* @__PURE__ */ new Date(), 1)
3517
+ };
3518
+ }
3519
+ }, [period]);
3520
+ const { data: distributionData, mutate } = hooks.useRefereeRebateSummary(dateRange);
3521
+ const { dailyVolume, chartConfig } = useReferralContext();
3522
+ const dataSource = react.useMemo(() => {
3523
+ if (volType === "rebate") {
3524
+ const newData = distributionData || [];
3525
+ return newData.map((e) => ({
3526
+ date: e.date,
3527
+ volume: e.referee_rebate
3528
+ })).reverse();
3529
+ } else if (volType === "volume") {
3530
+ return dailyVolume?.filter((e) => {
3531
+ return e.date > dateFns.format(dateFns.subDays(Date(), Number(period) + 1), "yyyy-MM-dd");
3532
+ }).map((e) => ({
3533
+ date: e.date,
3534
+ volume: e.perp_volume
3535
+ })) || [];
3536
+ } else {
3537
+ return [];
3538
+ }
3539
+ }, [distributionData, dailyVolume, volType]);
3540
+ return {
3541
+ period,
3542
+ periodTypes,
3543
+ onPeriodChange,
3544
+ volType,
3545
+ volTypes,
3546
+ onVolTypeChange,
3547
+ dataSource: fillData(Number(period), dataSource)
3548
+ };
3549
+ };
3550
+ var TitleStatisticWidget2 = () => {
3551
+ const state = useTitleStatisticScript2();
3552
+ return /* @__PURE__ */ jsxRuntime.jsx(TitleStatistic2, { ...state });
3553
+ };
3554
+ var Rebates = (props) => {
3555
+ return /* @__PURE__ */ jsxRuntime.jsxs(
3556
+ ui.Flex,
3557
+ {
3558
+ id: "oui-affiliate-trader-rebates",
3559
+ r: "2xl",
3560
+ p: 6,
3561
+ width: "100%",
3562
+ gap: 4,
3563
+ direction: "column",
3564
+ className: "oui-bg-base-9 oui-tabular-nums",
3565
+ children: [
3566
+ /* @__PURE__ */ jsxRuntime.jsx(Title8, { ...props }),
3567
+ /* @__PURE__ */ jsxRuntime.jsx(
3568
+ ui.Flex,
3569
+ {
3570
+ width: "100%",
3571
+ className: "oui-border-y-2 oui-border-line-6",
3572
+ height: 49,
3573
+ direction: "row",
3574
+ itemAlign: "center",
3575
+ children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(
3576
+ ui.DatePicker.range,
3577
+ {
3578
+ size: "xs",
3579
+ value: props.dateRange,
3580
+ onChange: (range) => {
3581
+ props.setDateRange(range);
3582
+ },
3583
+ max: 90,
3584
+ disabled: {
3585
+ after: /* @__PURE__ */ new Date()
3586
+ }
3587
+ }
3588
+ ) })
3589
+ }
3590
+ ),
3591
+ /* @__PURE__ */ jsxRuntime.jsx(List, { ...props })
3592
+ ]
3593
+ }
3594
+ );
3595
+ };
3596
+ var Title8 = (props) => {
3597
+ const { t } = i18n.useTranslation();
3598
+ return /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "row", justify: "between", width: "100%", children: [
3599
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "oui-text-lg", children: t("affiliate.trader.myRebates") }),
3600
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { intensity: 36, className: "oui-text-2xs", children: props.displayDate })
3601
+ ] });
3602
+ };
3603
+ var List = (props) => {
3604
+ const { t } = i18n.useTranslation();
3605
+ const layout767 = hooks.useMediaQuery("(max-width: 767px)");
3606
+ const columns = [
3607
+ {
3608
+ title: `${t("affiliate.trader.rebates")} (USDC)`,
3609
+ dataIndex: "referee_rebate",
3610
+ render: (value) => /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: utils.commifyOptional(value, {
3611
+ fix: 6,
3612
+ fallback: "0",
3613
+ padEnd: true,
3614
+ prefix: "$"
3615
+ }) }),
3616
+ width: 127
3617
+ },
3618
+ {
3619
+ title: `${t("affiliate.trader.tradingVol")} (USDC)`,
3620
+ dataIndex: "vol",
3621
+ render: (value) => utils.commifyOptional(value, {
3622
+ fix: 2,
3623
+ fallback: "0",
3624
+ padEnd: true,
3625
+ prefix: "$"
3626
+ }),
3627
+ width: 127
3628
+ },
3629
+ {
3630
+ title: t("common.date"),
3631
+ dataIndex: "date",
3632
+ render: (value) => /* @__PURE__ */ jsxRuntime.jsx(ui.Text.formatted, { formatString: "yyyy-MM-dd", children: value }),
3633
+ width: 127
3634
+ }
3635
+ ];
3636
+ if (layout767) {
3637
+ return /* @__PURE__ */ jsxRuntime.jsx(
3638
+ ui.ListView,
3639
+ {
3640
+ dataSource: props.dataSource,
3641
+ className: "oui-h-[197px] oui-w-full",
3642
+ renderItem: (item, index) => {
3643
+ return /* @__PURE__ */ jsxRuntime.jsx(Cell, { item });
3644
+ }
3645
+ }
3646
+ );
3647
+ }
3648
+ return /* @__PURE__ */ jsxRuntime.jsx(
3649
+ uiConnector.AuthGuardDataTable,
3650
+ {
3651
+ bordered: true,
3652
+ loading: props.isLoading,
3653
+ columns,
3654
+ dataSource: props.dataSource,
3655
+ ignoreLoadingCheck: true,
3656
+ onRow: (record) => {
3657
+ return {
3658
+ className: "oui-h-[41px]"
3659
+ };
3660
+ },
3661
+ pagination: props.pagination,
3662
+ manualPagination: false
3663
+ }
3664
+ );
3665
+ };
3666
+ var Cell = (props) => {
3667
+ const { t } = i18n.useTranslation();
3668
+ return /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "column", width: "100%", children: [
3669
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { width: "100%", gap: 1, children: [
3670
+ /* @__PURE__ */ jsxRuntime.jsx(
3671
+ ui.Statistic,
3672
+ {
3673
+ label: `${t("affiliate.trader.rebates")} (USDC)`,
3674
+ className: "oui-text-xs oui-text-base-contrast-54 oui-flex-1 oui-min-w-[105px]",
3675
+ children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "sm", intensity: 80, children: utils.commifyOptional(props.item.referee_rebate, {
3676
+ fix: 6,
3677
+ fallback: "0",
3678
+ padEnd: true,
3679
+ prefix: "$"
3680
+ }) })
3681
+ }
3682
+ ),
3683
+ /* @__PURE__ */ jsxRuntime.jsx(
3684
+ ui.Statistic,
3685
+ {
3686
+ label: `${t("affiliate.trader.tradingVol")} (USDC)`,
3687
+ className: "oui-text-xs oui-text-base-contrast-54 oui-flex-shrink",
3688
+ children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "sm", intensity: 80, children: utils.commifyOptional(props.item.vol, {
3689
+ fix: 2,
3690
+ fallback: "0",
3691
+ padEnd: true,
3692
+ prefix: "$"
3693
+ }) })
3694
+ }
3695
+ ),
3696
+ /* @__PURE__ */ jsxRuntime.jsx(
3697
+ ui.Statistic,
3698
+ {
3699
+ label: t("common.date"),
3700
+ className: "oui-text-xs oui-text-base-contrast-54 oui-flex-1",
3701
+ align: "end",
3702
+ children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text.formatted, { size: "sm", intensity: 80, formatString: "yyyy-MM-dd", children: props.item.date })
3703
+ }
3704
+ )
3705
+ ] }),
3706
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { className: "oui-w-full oui-mt-3" })
3707
+ ] });
3708
+ };
3709
+ var useRebatesScript = () => {
3710
+ const [dateRange, setDateRange] = react.useState({
3711
+ from: dateFns.subDays(/* @__PURE__ */ new Date(), 90),
3712
+ to: dateFns.subDays(/* @__PURE__ */ new Date(), 1)
3713
+ });
3714
+ const {
3715
+ data: distributionData,
3716
+ mutate,
3717
+ isLoading
3718
+ } = hooks.useRefereeRebateSummary({
3719
+ startDate: dateRange?.from,
3720
+ endDate: dateRange?.to
3721
+ });
3722
+ const { data: dailyVolume, mutate: dailyVolumeMutate } = hooks.useDaily({
3723
+ startDate: dateRange?.to,
3724
+ endDate: dateRange?.from
3725
+ });
3726
+ const dataSource = react.useMemo(() => {
3727
+ if (typeof distributionData === "undefined")
3728
+ return [];
3729
+ return distributionData.map((item) => {
3730
+ const createdTime = item.date;
3731
+ const volume = dailyVolume?.filter((item2) => {
3732
+ return compareDate(dateFns.toDate(createdTime), dateFns.toDate(item2.date));
3733
+ })?.[0];
3734
+ if (volume) {
3735
+ return { ...item, vol: volume.perp_volume };
3736
+ }
3737
+ return item;
3738
+ });
3739
+ }, [distributionData, dailyVolume]);
3740
+ let displayDate = void 0;
3741
+ if ((dataSource?.length || 0) > 0) {
3742
+ displayDate = formatDateTimeToUTC(dataSource?.[0].date);
3743
+ }
3744
+ const { pagination, setPage } = ui.usePagination();
3745
+ react.useEffect(() => {
3746
+ setPage(1);
3747
+ }, [dateRange]);
3748
+ return {
3749
+ dateRange,
3750
+ setDateRange,
3751
+ displayDate,
3752
+ dataSource,
3753
+ // meta,
3754
+ // onPageChange,
3755
+ // onPageSizeChange,
3756
+ pagination,
3757
+ isLoading
3758
+ };
3759
+ };
3760
+ var RebatesWidget = () => {
3761
+ const state = useRebatesScript();
3762
+ return /* @__PURE__ */ jsxRuntime.jsx(Rebates, { ...state });
3763
+ };
3764
+ var TraderPage = () => {
3765
+ return /* @__PURE__ */ jsxRuntime.jsxs(
3766
+ ui.Flex,
3767
+ {
3768
+ id: "oui-affiliate-trader-page",
3769
+ className: ui.cn(
3770
+ "oui-h-lvw oui-w-full",
3771
+ // padding
3772
+ // "oui-p-4 lg:oui-p-6 xl:oui-p-3",
3773
+ "oui-font-semibold"
3774
+ ),
3775
+ direction: "column",
3776
+ gap: 4,
3777
+ children: [
3778
+ /* @__PURE__ */ jsxRuntime.jsxs(
3779
+ ui.Flex,
3780
+ {
3781
+ width: "100%",
3782
+ gap: 4,
3783
+ className: "oui-flex oui-flex-col xl:oui-flex-row xl:oui-items-stretch",
3784
+ children: [
3785
+ /* @__PURE__ */ jsxRuntime.jsx(SummaryWidget2, {}),
3786
+ /* @__PURE__ */ jsxRuntime.jsx(TitleStatisticWidget2, {})
3787
+ ]
3788
+ }
3789
+ ),
3790
+ /* @__PURE__ */ jsxRuntime.jsx(RebatesWidget, {})
3791
+ ]
3792
+ }
3793
+ );
3794
+ };
3795
+ var Tab = (props) => {
3796
+ const { t } = i18n.useTranslation();
3797
+ const extendNode = () => {
3798
+ if (props.isAffiliate && !props.isTrader) {
3799
+ return /* @__PURE__ */ jsxRuntime.jsxs(
3800
+ ui.Button,
3801
+ {
3802
+ variant: "contained",
3803
+ color: "success",
3804
+ size: "sm",
3805
+ className: "oui-px-2 oui-flex oui-gap-1",
3806
+ style: {
3807
+ position: "absolute",
3808
+ top: "50%",
3809
+ right: "24px",
3810
+ transform: "translateY(-50%)"
3811
+ },
3812
+ onClick: (e) => {
3813
+ props.anATrader();
3814
+ },
3815
+ children: [
3816
+ /* @__PURE__ */ jsxRuntime.jsx(TraderIcon, {}),
3817
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: t("affiliate.asTrader.title") })
3818
+ ]
3819
+ }
3820
+ );
3821
+ }
3822
+ if (!props.isAffiliate && props.isTrader) {
3823
+ return /* @__PURE__ */ jsxRuntime.jsxs(
3824
+ ui.Button,
3825
+ {
3826
+ variant: "contained",
3827
+ color: "primary",
3828
+ size: "sm",
3829
+ className: "oui-px-2 oui-flex oui-gap-1",
3830
+ style: {
3831
+ position: "absolute",
3832
+ top: "50%",
3833
+ right: "24px",
3834
+ transform: "translateY(-50%)"
3835
+ },
3836
+ onClick: (e) => {
3837
+ props.anAnAffiliate();
3838
+ },
3839
+ children: [
3840
+ /* @__PURE__ */ jsxRuntime.jsx(AffiliateIcon, {}),
3841
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: t("affiliate.asAffiliate.title") })
3842
+ ]
3843
+ }
3844
+ );
3845
+ }
3846
+ return void 0;
3847
+ };
3848
+ if (props.isLoading) {
3849
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: ui.cn("oui-max-w-[960px]", props.classNames?.loadding), children: props.splashPage?.() || /* @__PURE__ */ jsxRuntime.jsx(HomePage, {}) });
3850
+ }
3851
+ if (!props.isAffiliate && !props.isTrader || props.showHome) {
3852
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: ui.cn("oui-max-w-[960px]", props?.classNames?.home), children: /* @__PURE__ */ jsxRuntime.jsx(HomePage, {}) });
3853
+ }
3854
+ return /* @__PURE__ */ jsxRuntime.jsxs(
3855
+ ui.TabsBase,
3856
+ {
3857
+ id: "oui-affiliate-dashboard-tab",
3858
+ value: props.tab,
3859
+ onValueChange: (e) => {
3860
+ props.setTab(e);
3861
+ },
3862
+ className: ui.cn("oui-w-full", props.classNames?.dashboard),
3863
+ children: [
3864
+ /* @__PURE__ */ jsxRuntime.jsxs(
3865
+ ui.TabsList,
3866
+ {
3867
+ className: ui.cn(
3868
+ "oui-px-6 oui-flex oui-flex-row oui-justify-start oui-h-[44px] oui-relative oui-items-end",
3869
+ "oui-text-base md:oui-text-lg",
3870
+ "oui-rounded-xl oui-bg-base-9",
3871
+ "oui-border oui-border-line-6",
3872
+ props.isAffiliate && props.isTrader && "oui-justify-center"
3873
+ ),
3874
+ children: [
3875
+ props.isAffiliate && /* @__PURE__ */ jsxRuntime.jsx(
3876
+ ui.TabsTrigger,
3877
+ {
3878
+ id: "oui-affiliate-dashboard-tab-affiliate",
3879
+ value: "affiliate" /* affiliate */,
3880
+ children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "row", gap: 1, mb: 2, children: [
3881
+ /* @__PURE__ */ jsxRuntime.jsx(
3882
+ AffiliateIcon,
3883
+ {
3884
+ fillOpacity: 1,
3885
+ fill: "currentColor",
3886
+ className: props.tab === "affiliate" /* affiliate */ ? "oui-fill-white/[.98]" : "oui-fill-white/[.36]"
3887
+ }
3888
+ ),
3889
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: t("common.affiliate") })
3890
+ ] })
3891
+ }
3892
+ ),
3893
+ props.isTrader && /* @__PURE__ */ jsxRuntime.jsx(
3894
+ ui.TabsTrigger,
3895
+ {
3896
+ id: "oui-affiliate-dashboard-tab-trader",
3897
+ value: "trader" /* trader */,
3898
+ children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "row", gap: 1, mb: 2, children: [
3899
+ /* @__PURE__ */ jsxRuntime.jsx(
3900
+ TraderIcon,
3901
+ {
3902
+ fillOpacity: 1,
3903
+ fill: "currentColor",
3904
+ className: props.tab === "trader" /* trader */ ? "oui-fill-white/[.98]" : "oui-fill-white/[.36]"
3905
+ }
3906
+ ),
3907
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: t("affiliate.trader") })
3908
+ ] })
3909
+ }
3910
+ ),
3911
+ extendNode()
3912
+ ]
3913
+ }
3914
+ ),
3915
+ props.isAffiliate && /* @__PURE__ */ jsxRuntime.jsx(ui.TabsContent, { value: "affiliate" /* affiliate */, className: "oui-mt-4", children: /* @__PURE__ */ jsxRuntime.jsx(AffiliatePage, {}) }),
3916
+ props.isTrader && /* @__PURE__ */ jsxRuntime.jsx(ui.TabsContent, { value: "trader" /* trader */, className: "oui-mt-4", children: /* @__PURE__ */ jsxRuntime.jsx(TraderPage, {}) })
3917
+ ]
3918
+ }
3919
+ );
3920
+ };
3921
+ var useTabScript = () => {
3922
+ const {
3923
+ isAffiliate,
3924
+ isTrader,
3925
+ isLoading,
3926
+ splashPage,
3927
+ showHome,
3928
+ setShowHome,
3929
+ tab,
3930
+ setTab
3931
+ } = useReferralContext();
3932
+ const tableValue = react.useMemo(() => {
3933
+ if (isAffiliate && isTrader) {
3934
+ return tab;
3935
+ } else if (isAffiliate && !isTrader) {
3936
+ return "affiliate" /* affiliate */;
3937
+ } else if (!isAffiliate && isTrader) {
3938
+ return "trader" /* trader */;
3939
+ } else {
3940
+ return "affiliate" /* affiliate */;
3941
+ }
3942
+ }, [tab, isAffiliate, isTrader]);
3943
+ react.useEffect(() => {
3944
+ const searchParams = new URLSearchParams(window.location.search);
3945
+ const tab2 = searchParams.get("tab");
3946
+ if (tab2) {
3947
+ setTab(tab2);
3948
+ }
3949
+ }, [window.location.search]);
3950
+ const anAnAffiliate = () => {
3951
+ setShowHome(true);
3952
+ };
3953
+ const anATrader = () => {
3954
+ setShowHome(true);
3955
+ };
3956
+ return {
3957
+ setTab,
3958
+ tab: tableValue,
3959
+ isAffiliate,
3960
+ isTrader,
3961
+ isLoading,
3962
+ anAnAffiliate,
3963
+ anATrader,
3964
+ splashPage,
3965
+ showHome,
3966
+ setShowHome
3967
+ // tab: TabTypes.affiliate,
3968
+ // isAffiliate: false,
3969
+ // isTrader: false,
3970
+ // isLoading: false,
3971
+ };
3972
+ };
3973
+ var TabWidget = (props) => {
3974
+ const state = useTabScript();
3975
+ return /* @__PURE__ */ jsxRuntime.jsx(Tab, { classNames: props.classNames, ...state });
3976
+ };
3977
+ var DashboardPage = (props) => {
3978
+ const { classNames = {} } = props;
3979
+ const { root, ...rest } = classNames;
3980
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { id: "oui-affiliate-dashboard-page", className: ui.cn("oui-w-full oui-tracking-tight", root), children: /* @__PURE__ */ jsxRuntime.jsx(TabWidget, { classNames: rest }) });
3981
+ };
3982
+ var AffiliateLayout = (props) => {
3983
+ const { ...rest } = props;
3984
+ return /* @__PURE__ */ jsxRuntime.jsx(uiScaffold.Scaffold, { leftSidebar: /* @__PURE__ */ jsxRuntime.jsx(LeftSidebar, { ...rest }), children: /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { mx: 3, my: 6, children: props.children }) });
3985
+ };
3986
+ var LeftSidebar = (props) => {
3987
+ return /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { p: 4, m: 3, border: true, borderColor: 8, r: "xl", children: /* @__PURE__ */ jsxRuntime.jsx(uiScaffold.SideBar, { ...props }) });
3988
+ };
3989
+ var useLayoutBuilder = () => {
3990
+ const [current, setCurrent] = react.useState("/");
3991
+ const { t } = i18n.useTranslation();
3992
+ const items = react.useMemo(() => {
3993
+ return [
3994
+ {
3995
+ name: t("common.trading"),
3996
+ href: "/",
3997
+ icon: /* @__PURE__ */ jsxRuntime.jsxs(
3998
+ "svg",
3999
+ {
4000
+ width: "18",
4001
+ height: "18",
4002
+ viewBox: "0 0 18 18",
4003
+ fill: "none",
4004
+ xmlns: "http://www.w3.org/2000/svg",
4005
+ children: [
4006
+ /* @__PURE__ */ jsxRuntime.jsx(
4007
+ "path",
4008
+ {
4009
+ d: "M4.883 1.5c-.166.01-.393.076-.515.173a2 2 0 0 0-.18.173L.918 6.553a.86.86 0 0 0-.168.475c0 .339.232.543.232.543l7.374 8.633c.005.006.269.301.644.296s.64-.29.644-.296l7.402-8.663s.204-.269.204-.513-.196-.517-.196-.517L13.82 1.848c-.023-.032-.076-.021-.103-.049-.033-.038-.037-.091-.077-.124-.123-.097-.267-.106-.413-.123-.04-.005-.063-.049-.103-.049h-.078zm1.745 1.582h4.744L9 5.795zm-1.675.542 2.294 2.615H3.122zm8.094 0 1.831 2.615h-4.125zM3.328 7.818h4.847v5.672zm6.497 0h4.847c-1.151 1.345-3.422 4.007-4.847 5.672z",
4010
+ fill: "url(#a)"
4011
+ }
4012
+ ),
4013
+ /* @__PURE__ */ jsxRuntime.jsx("defs", { children: /* @__PURE__ */ jsxRuntime.jsxs(
4014
+ "linearGradient",
4015
+ {
4016
+ id: "a",
4017
+ x1: "17.25",
4018
+ y1: "9",
4019
+ x2: ".75",
4020
+ y2: "9",
4021
+ gradientUnits: "userSpaceOnUse",
4022
+ children: [
4023
+ /* @__PURE__ */ jsxRuntime.jsx("stop", { stopColor: "rgb(var(--oui-gradient-brand-end))" }),
4024
+ /* @__PURE__ */ jsxRuntime.jsx(
4025
+ "stop",
4026
+ {
4027
+ offset: "1",
4028
+ stopColor: "rgb(var(--oui-gradient-brand-start))"
4029
+ }
4030
+ )
4031
+ ]
4032
+ }
4033
+ ) })
4034
+ ]
4035
+ }
4036
+ )
4037
+ },
4038
+ {
4039
+ name: t("common.affiliate"),
4040
+ href: "/affiliate",
4041
+ icon: /* @__PURE__ */ jsxRuntime.jsx(
4042
+ "svg",
4043
+ {
4044
+ width: "18",
4045
+ height: "18",
4046
+ viewBox: "0 0 18 18",
4047
+ fill: "none",
4048
+ xmlns: "http://www.w3.org/2000/svg",
4049
+ children: /* @__PURE__ */ jsxRuntime.jsx(
4050
+ "path",
4051
+ {
4052
+ fillRule: "evenodd",
4053
+ clipRule: "evenodd",
4054
+ d: "M5.625 4.95c0-.746.604-1.35 1.35-1.35h4.05c.746 0 1.35.604 1.35 1.35v4.62L9 12.195 5.625 9.57zm8.624 3.163-.524.407v-.96l.074.05c.193.128.346.302.45.502m-4.42 5.148L14.4 9.705v3.345a1.35 1.35 0 0 1-1.35 1.35h-8.1a1.35 1.35 0 0 1-1.35-1.35V9.705l4.571 3.556c.488.379 1.17.379 1.658 0M4.275 8.52l-.524-.407c.104-.2.257-.374.45-.503l.074-.049zm0-2.581V4.95a2.7 2.7 0 0 1 2.7-2.7h4.05a2.7 2.7 0 0 1 2.7 2.7v.989l.823.548a2.7 2.7 0 0 1 1.202 2.247v4.316a2.7 2.7 0 0 1-2.7 2.7h-8.1a2.7 2.7 0 0 1-2.7-2.7V8.734a2.7 2.7 0 0 1 1.202-2.247zM9 6.089l.111-.118.005-.005a1.08 1.08 0 0 1 1.58.004 1.223 1.223 0 0 1 0 1.668l-1.515 1.62-.004.004c-.1.102-.26.1-.358-.004l-1.516-1.62a1.223 1.223 0 0 1 0-1.668l.004-.004a1.08 1.08 0 0 1 1.58.004z",
4055
+ fill: "#fff",
4056
+ fillOpacity: ".54"
4057
+ }
4058
+ )
4059
+ }
4060
+ )
4061
+ }
4062
+ ];
4063
+ }, [t]);
4064
+ return {
4065
+ items,
4066
+ current,
4067
+ // open: sideOpen,
4068
+ // onOpenChange(open) {
4069
+ // setSideOpen(open);
4070
+ // },
4071
+ onItemSelect: (item) => {
4072
+ setCurrent(item.href);
4073
+ }
4074
+ };
4075
+ };
4076
+ var AffiliateLayoutWidget = (props) => {
4077
+ const state = useLayoutBuilder();
4078
+ return /* @__PURE__ */ jsxRuntime.jsx(AffiliateLayout, { ...state, children: props.children });
4079
+ };
4080
+
4081
+ exports.AffiliateLayoutWidget = AffiliateLayoutWidget;
4082
+ exports.Dashboard = dashboard_exports;
4083
+ exports.ReferralContext = ReferralContext;
4084
+ exports.ReferralProvider = ReferralProvider;
4085
+ exports.TabTypes = TabTypes;
4086
+ exports.useReferralContext = useReferralContext;
24
4087
  //# sourceMappingURL=out.js.map
25
4088
  //# sourceMappingURL=index.js.map