@orderly.network/ui-share 2.0.3 → 2.0.4-alpha.0
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.d.mts +9 -6
- package/dist/index.d.ts +9 -6
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
package/dist/index.d.mts
CHANGED
|
@@ -27,6 +27,7 @@ type PosterLayoutConfig = {
|
|
|
27
27
|
};
|
|
28
28
|
updateTime?: layoutInfo;
|
|
29
29
|
};
|
|
30
|
+
type SharePnLConfig = SharePnLOptions & Partial<Omit<SharePnLParams, "refCode" | "leverage">>;
|
|
30
31
|
type SharePnLParams = {
|
|
31
32
|
entity: ShareEntity;
|
|
32
33
|
leverage?: number;
|
|
@@ -34,7 +35,7 @@ type SharePnLParams = {
|
|
|
34
35
|
refSlogan?: string;
|
|
35
36
|
refLink?: string;
|
|
36
37
|
};
|
|
37
|
-
type
|
|
38
|
+
type SharePnLOptions = {
|
|
38
39
|
/**
|
|
39
40
|
* default is Manrope
|
|
40
41
|
*/
|
|
@@ -75,13 +76,15 @@ type ShareEntity = {
|
|
|
75
76
|
pnl?: number;
|
|
76
77
|
roi?: number;
|
|
77
78
|
openPrice?: number;
|
|
79
|
+
closePrice?: number;
|
|
78
80
|
openTime?: number;
|
|
81
|
+
closeTime?: number;
|
|
79
82
|
markPrice?: number;
|
|
80
83
|
quantity?: number;
|
|
81
84
|
};
|
|
82
85
|
|
|
83
86
|
declare const useSharePnLScript: (props: {
|
|
84
|
-
pnl?: (
|
|
87
|
+
pnl?: (SharePnLOptions & SharePnLParams) | undefined;
|
|
85
88
|
hide?: () => void;
|
|
86
89
|
}) => {
|
|
87
90
|
entity: ShareEntity | undefined;
|
|
@@ -89,20 +92,20 @@ declare const useSharePnLScript: (props: {
|
|
|
89
92
|
baseDp: any;
|
|
90
93
|
quoteDp: any;
|
|
91
94
|
referralInfo: ReferralType | undefined;
|
|
92
|
-
shareOptions:
|
|
95
|
+
shareOptions: SharePnLOptions | undefined;
|
|
93
96
|
hide: (() => void) | undefined;
|
|
94
97
|
};
|
|
95
98
|
|
|
96
99
|
declare const SharePnLBottomSheetWidget: (props: {
|
|
97
100
|
hide?: () => void;
|
|
98
|
-
pnl?:
|
|
101
|
+
pnl?: SharePnLOptions & SharePnLParams;
|
|
99
102
|
}) => react_jsx_runtime.JSX.Element;
|
|
100
103
|
declare const SharePnLDialogWidget: (props: {
|
|
101
104
|
hide?: () => void;
|
|
102
|
-
pnl?:
|
|
105
|
+
pnl?: SharePnLOptions & SharePnLParams;
|
|
103
106
|
}) => react_jsx_runtime.JSX.Element;
|
|
104
107
|
|
|
105
108
|
declare const SharePnLDialogId = "sharePnLDialog";
|
|
106
109
|
declare const SharePnLBottomSheetId = "sharePnLBottomSheet";
|
|
107
110
|
|
|
108
|
-
export { SharePnLBottomSheetId, SharePnLBottomSheetWidget, type SharePnLConfig, SharePnLDialogId, SharePnLDialogWidget, type SharePnLParams, useSharePnLScript };
|
|
111
|
+
export { SharePnLBottomSheetId, SharePnLBottomSheetWidget, type SharePnLConfig, SharePnLDialogId, SharePnLDialogWidget, type SharePnLOptions, type SharePnLParams, useSharePnLScript };
|
package/dist/index.d.ts
CHANGED
|
@@ -27,6 +27,7 @@ type PosterLayoutConfig = {
|
|
|
27
27
|
};
|
|
28
28
|
updateTime?: layoutInfo;
|
|
29
29
|
};
|
|
30
|
+
type SharePnLConfig = SharePnLOptions & Partial<Omit<SharePnLParams, "refCode" | "leverage">>;
|
|
30
31
|
type SharePnLParams = {
|
|
31
32
|
entity: ShareEntity;
|
|
32
33
|
leverage?: number;
|
|
@@ -34,7 +35,7 @@ type SharePnLParams = {
|
|
|
34
35
|
refSlogan?: string;
|
|
35
36
|
refLink?: string;
|
|
36
37
|
};
|
|
37
|
-
type
|
|
38
|
+
type SharePnLOptions = {
|
|
38
39
|
/**
|
|
39
40
|
* default is Manrope
|
|
40
41
|
*/
|
|
@@ -75,13 +76,15 @@ type ShareEntity = {
|
|
|
75
76
|
pnl?: number;
|
|
76
77
|
roi?: number;
|
|
77
78
|
openPrice?: number;
|
|
79
|
+
closePrice?: number;
|
|
78
80
|
openTime?: number;
|
|
81
|
+
closeTime?: number;
|
|
79
82
|
markPrice?: number;
|
|
80
83
|
quantity?: number;
|
|
81
84
|
};
|
|
82
85
|
|
|
83
86
|
declare const useSharePnLScript: (props: {
|
|
84
|
-
pnl?: (
|
|
87
|
+
pnl?: (SharePnLOptions & SharePnLParams) | undefined;
|
|
85
88
|
hide?: () => void;
|
|
86
89
|
}) => {
|
|
87
90
|
entity: ShareEntity | undefined;
|
|
@@ -89,20 +92,20 @@ declare const useSharePnLScript: (props: {
|
|
|
89
92
|
baseDp: any;
|
|
90
93
|
quoteDp: any;
|
|
91
94
|
referralInfo: ReferralType | undefined;
|
|
92
|
-
shareOptions:
|
|
95
|
+
shareOptions: SharePnLOptions | undefined;
|
|
93
96
|
hide: (() => void) | undefined;
|
|
94
97
|
};
|
|
95
98
|
|
|
96
99
|
declare const SharePnLBottomSheetWidget: (props: {
|
|
97
100
|
hide?: () => void;
|
|
98
|
-
pnl?:
|
|
101
|
+
pnl?: SharePnLOptions & SharePnLParams;
|
|
99
102
|
}) => react_jsx_runtime.JSX.Element;
|
|
100
103
|
declare const SharePnLDialogWidget: (props: {
|
|
101
104
|
hide?: () => void;
|
|
102
|
-
pnl?:
|
|
105
|
+
pnl?: SharePnLOptions & SharePnLParams;
|
|
103
106
|
}) => react_jsx_runtime.JSX.Element;
|
|
104
107
|
|
|
105
108
|
declare const SharePnLDialogId = "sharePnLDialog";
|
|
106
109
|
declare const SharePnLBottomSheetId = "sharePnLBottomSheet";
|
|
107
110
|
|
|
108
|
-
export { SharePnLBottomSheetId, SharePnLBottomSheetWidget, type SharePnLConfig, SharePnLDialogId, SharePnLDialogWidget, type SharePnLParams, useSharePnLScript };
|
|
111
|
+
export { SharePnLBottomSheetId, SharePnLBottomSheetWidget, type SharePnLConfig, SharePnLDialogId, SharePnLDialogWidget, type SharePnLOptions, type SharePnLParams, useSharePnLScript };
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var ui = require('@orderly.network/ui');
|
|
4
|
-
var hooks = require('@orderly.network/hooks');
|
|
5
4
|
var p = require('react');
|
|
5
|
+
var hooks = require('@orderly.network/hooks');
|
|
6
6
|
var utils = require('@orderly.network/utils');
|
|
7
7
|
var jsxRuntime = require('react/jsx-runtime');
|
|
8
8
|
var et = require('embla-carousel-react');
|
|
@@ -30,7 +30,7 @@ function _interopNamespace(e) {
|
|
|
30
30
|
var p__namespace = /*#__PURE__*/_interopNamespace(p);
|
|
31
31
|
var et__default = /*#__PURE__*/_interopDefault(et);
|
|
32
32
|
|
|
33
|
-
var G=e=>{let{pnl:t,hide:o}=e,a=t?.entity,n=hooks.useSymbolsInfo(),{getFirstRefCode:r}=hooks.useReferralInfo(),l=p.useMemo(()=>{let i=r()?.code;return {code:t?.refCode??i,slogan:t?.refSlogan,link:t?.refLink}},[r,t]),s=p.useMemo(()=>{if(a)return n[a?.symbol]("base_dp")},[a,n]),u=p.useMemo(()=>{if(a)return n[a?.symbol]("quote_dp")},[a,n]);return {entity:a,leverage:t?.leverage,baseDp:s,quoteDp:u,referralInfo:l,shareOptions:t,hide:o}};function X(e,t,o,a,n,r,l,s,u){let{symbol:i,currency:c}=Qe(e.symbol),d={symbol:i,currency:c,side:e.side};switch(n){case"pnl":{e.pnl!=null&&(d.pnl=new utils.Decimal(e.pnl).toFixed(2,utils.Decimal.ROUND_DOWN));break}case"roi":{e.roi!=null&&(d.ROI=new utils.Decimal(e.roi).toFixed(2,utils.Decimal.ROUND_DOWN));break}case"roi_pnl":{e.pnl!=null&&(d.pnl=new utils.Decimal(e.pnl).toFixed(2,utils.Decimal.ROUND_DOWN)),e.roi!=null&&(d.ROI=new utils.Decimal(e.roi).toFixed(2,utils.Decimal.ROUND_DOWN));break}}let C=[];r.has("leverage")&&(d.leverage=t),["openPrice","openTime","markPrice","quantity"].forEach(w=>{if(r.has(w))switch(w){case"leverage":break;case"openPrice":{e.openPrice!=null&&C.push({title:"Open price",value:ae(e.openPrice,s||2)});break}case"openTime":{e.openTime!=null&&C.push({title:"Opened at",value:Ye(e.openTime)});break}case"markPrice":{e.markPrice!=null&&C.push({title:"Mark price",value:ae(e.markPrice,s||2)});break}case"quantity":e.quantity!=null&&C.push({title:"Quantity",value:ae(e.quantity,l||2)});}}),d.informations=C;let S={position:d,updateTime:Je(new Date),domain:a};return o.length>0&&(S.message=o),typeof u<"u"&&u.code!==void 0&&(S.referral=u),S}function Qe(e){let t=e.split("_");if(t.length!==3)return {symbol:e,currency:"USDC"};let[o,a,n]=t;return {symbol:`${a}-${o}`,currency:n||"USDC"}}function Je(e){let t=e instanceof Date?e:new Date(e),o={year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hourCycle:"h24"},n=new Intl.DateTimeFormat("en-US",o).formatToParts(t),r=n.find(c=>c.type==="year"?c.value:"")?.value,l=n.find(c=>c.type==="month"?c.value:"")?.value,s=n.find(c=>c.type==="day"?c.value:"")?.value,u=n.find(c=>c.type==="hour"?c.value:"")?.value,i=n.find(c=>c.type==="minute"?c.value:"")?.value;return `${r}-${l}-${s} ${u}:${i}`}function Ye(e){let t=e instanceof Date?e:new Date(e),o={year:"numeric",month:"short",day:"2-digit",hour:"2-digit",minute:"2-digit"},n=new Intl.DateTimeFormat("en-US",o).formatToParts(t),r=n.find(i=>i.type==="month"?i.value:"")?.value,l=n.find(i=>i.type==="day"?i.value:"")?.value,s=n.find(i=>i.type==="hour"?i.value:"")?.value,u=n.find(i=>i.type==="minute"?i.value:"")?.value;return `${r}-${l} ${s}:${u}`}function ae(e,t){return new utils.Decimal(e).toFixed(t,utils.Decimal.ROUND_DOWN)}function j(e,t,o,a){localStorage.setItem("pnl_config_key",JSON.stringify({bgIndex:o,pnlFormat:e,options:Array.from(t),message:a}));}function ee(){let e=localStorage.getItem("pnl_config_key");if(e&&e.length>0)try{return JSON.parse(e)}catch{}return {bgIndex:0,pnlFormat:"roi_pnl",options:["openPrice","openTime","markPrice","quantity","leverage"],message:""}}var $=p.forwardRef((e,t)=>{let{width:o,height:a,className:n,data:r,style:l}=e,{ref:s,download:u,toDataURL:i,copy:c,toBlob:d}=hooks.usePoster(r,{ratio:e.ratio});return p.useImperativeHandle(t,()=>({download:u,toDataURL:i,toBlob:d,copy:c})),jsxRuntime.jsx("canvas",{ref:s,width:o,height:a,className:n,style:l})});var Ce=e=>{let{children:t,...o}=e;return jsxRuntime.jsx("button",{...o,children:jsxRuntime.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsx("rect",{width:"20",height:"20",rx:"10",fill:"#333948"}),jsxRuntime.jsx("path",{d:"M11.186 5.348a.67.67 0 0 0-.436.27l-2.657 4a.69.69 0 0 0 0 .75l2.657 4a.68.68 0 0 0 .934.188.685.685 0 0 0 .187-.937L9.463 9.993 11.87 6.37a.685.685 0 0 0-.187-.938.65.65 0 0 0-.498-.083",fill:"#fff",fillOpacity:".54"})]})})},xe=e=>{let{children:t,...o}=e;return jsxRuntime.jsx("button",{...o,children:jsxRuntime.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsx("rect",{width:"20",height:"20",rx:"10",fill:"#333948"}),jsxRuntime.jsx("path",{d:"M8.777 5.348a.65.65 0 0 0-.498.083.685.685 0 0 0-.187.938L10.5 9.993 8.092 13.62a.685.685 0 0 0 .187.937.68.68 0 0 0 .934-.187l2.657-4a.69.69 0 0 0 0-.75l-2.657-4a.67.67 0 0 0-.436-.271",fill:"#fff",fillOpacity:".54"})]})})};var be=e=>{let{backgroundImages:t,selectedSnap:o,setSelectedSnap:a}=e,[n,r]=et__default.default({containScroll:"keepSnaps",dragFree:!0}),l=p.useCallback(()=>{r&&r.scrollPrev();},[r]),s=p.useCallback(()=>{r&&r.scrollNext();},[r]),u=p.useCallback(i=>{a(i.selectedScrollSnap());},[]);return p.useEffect(()=>{r&&(u(r),r.on("reInit",u),r.on("select",u),r?.scrollTo(o));},[r,u]),jsxRuntime.jsxs(ui.Flex,{mt:4,px:2,children:[jsxRuntime.jsx(Ce,{onClick:l}),jsxRuntime.jsx("div",{ref:n,className:"oui-w-full oui-overflow oui-overflow-x-auto oui-scrollbar-hidden oui-hide-scrollbar oui-mx-0",children:jsxRuntime.jsx(ui.Flex,{children:t.map((i,c)=>jsxRuntime.jsx(ui.Box,{onClick:()=>{r?.scrollTo(c);},mx:2,my:1,mr:6,r:"base",className:ui.cn("oui-shrink-0 oui-w-[162px]",o===c&&"oui-outline oui-outline-1 oui-outline-primary-darken"),children:jsxRuntime.jsx("img",{src:i,className:"oui-rounded-sm"})},i))})}),jsxRuntime.jsx(xe,{onClick:s})]})};var we=e=>{let{type:t,curType:o,setPnlFormat:a}=e,n=p.useMemo(()=>{switch(t){case"roi_pnl":return "ROI & PnL";case"roi":return "ROI";case"pnl":return "PnL"}},[t]),r=t===o,l="oui-flex oui-items-center oui-gap-1 oui-cursor-pointer";return r?l+=" oui-text-base-contrast":l+="",jsxRuntime.jsxs("div",{className:l,onClick:()=>{a(t);},children:[jsxRuntime.jsx(lt,{sel:r}),jsxRuntime.jsx(ui.Text,{size:"xs",intensity:54,className:ui.cn("oui-ml-2 "),children:n})]})},lt=e=>jsxRuntime.jsx("button",{type:"button",children:e.sel===!0?jsxRuntime.jsx(ut,{}):jsxRuntime.jsx(ct,{})}),ut=()=>jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",className:"oui-fill-primary-darken",children:[jsxRuntime.jsx("path",{d:"M8.01 1.333a6.667 6.667 0 1 0 0 13.333 6.667 6.667 0 0 0 0-13.333m0 1.333a5.334 5.334 0 1 1-.001 10.667 5.334 5.334 0 0 1 0-10.667",fill:"#fff",fillOpacity:".36"}),jsxRuntime.jsx("circle",{cx:"8",cy:"8",r:"3.333"})]}),ct=()=>jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{d:"M8.01 1.333a6.667 6.667 0 1 0 0 13.333 6.667 6.667 0 0 0 0-13.333m0 1.333a5.334 5.334 0 1 1-.001 10.667 5.334 5.334 0 0 1 0-10.667",fill:"#fff",fillOpacity:".54"})});var te=e=>{let{size:t=16,className:o}=e;return jsxRuntime.jsx("button",{type:"button",onClick:a=>{e.onCheckedChange(!e.checked);},className:o,children:e.checked?jsxRuntime.jsx("svg",{width:t,height:t,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4.66 1.953A2.667 2.667 0 0 0 1.995 4.62v6.667a2.667 2.667 0 0 0 2.667 2.666h6.666a2.667 2.667 0 0 0 2.667-2.666V4.62a2.667 2.667 0 0 0-2.667-2.667zm6.664 2.922a.8.8 0 0 1 .557-.208c.2 0 .406.063.558.208a.734.734 0 0 1 0 1.063l-5.434 5.179a.826.826 0 0 1-1.115 0l-2.33-2.22a.736.736 0 0 1 0-1.063.827.827 0 0 1 1.117 0l1.77 1.687z",fill:"#fff",fillOpacity:".8"})}):jsxRuntime.jsx("svg",{width:t,height:t,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{d:"M4.66 1.953A2.667 2.667 0 0 0 1.995 4.62v6.667a2.667 2.667 0 0 0 2.667 2.666h6.666a2.667 2.667 0 0 0 2.667-2.666V4.62a2.667 2.667 0 0 0-2.667-2.667zm0 1.334h6.667c.737 0 1.334.596 1.334 1.333v6.667c0 .736-.597 1.333-1.334 1.333H4.661a1.333 1.333 0 0 1-1.334-1.333V4.62c0-.737.597-1.333 1.334-1.333",fill:"#fff",fillOpacity:".8"})})})};var De=e=>{let{type:t,curType:o,setShareOption:a}=e,n=p.useMemo(()=>{switch(t){case"openPrice":return "Open price";case"openTime":return "Opened at";case"markPrice":return "Mark price";case"quantity":return "Quantity";case"leverage":return "Leverage"}},[t]),r=o.has(t);return jsxRuntime.jsxs(ui.Flex,{itemAlign:"center",gap:1,className:ui.cn("hover:oui-cursor-pointer"),onClick:()=>{a(l=>{let s=new Set(l);return r?s.delete(t):s.add(t),s});},children:[jsxRuntime.jsx(te,{size:16,checked:r,className:"oui-pt-[2px]",onCheckedChange:l=>{a(s=>{let u=new Set(s);return r?u.delete(t):u.add(t),u});}}),jsxRuntime.jsx(ui.Text,{size:"xs",intensity:54,children:n})]})};var Le=e=>{let{message:t,setMessage:o,check:a,setCheck:n}=e,[r,l]=p.useState(!1),s=p.useRef(null);return jsxRuntime.jsxs("div",{className:"oui-mt-3 oui-mb-6 oui-flex oui-items-center",children:[jsxRuntime.jsx(te,{className:"oui-mt-[2px]",checked:a,onCheckedChange:u=>{n(u);}}),jsxRuntime.jsx("div",{className:"oui-text-xs oui-text-base-contrast-54 oui-ml-1 hover:oui-cursor-pointer",onClick:()=>{n(!e.check);},children:"Your message"}),jsxRuntime.jsx("div",{className:"oui-bg-base-900 oui-mx-2 oui-rounded-sm",children:jsxRuntime.jsx(ui.Input,{ref:s,placeholder:"Max 25 characters",classNames:{root:"oui-w-[320px]"},size:"sm",value:t,autoFocus:!1,suffix:r&&jsxRuntime.jsx("button",{className:"oui-mr-3 oui-cursor-pointer",onMouseDown:u=>{o(""),setTimeout(()=>{s.current?.focus();},50),u.stopPropagation();},children:jsxRuntime.jsx(ui.CloseCircleFillIcon,{size:18,color:"white"})}),onFocus:()=>l(!0),onBlur:()=>l(!1),onChange:u=>{if(u.target.value.length>25){ui.toast.error("Maximum support of 25 characters");return}n(u.target.value.length>0),o(u.target.value);}})})]})};var Ie=e=>{let{onClickDownload:t,onClickCopy:o}=e;return jsxRuntime.jsxs(ui.Flex,{px:8,gap:3,mt:3,itemAlign:"center",children:[jsxRuntime.jsxs(ui.Button,{color:"secondary",className:"oui-flex-1 oui-flex oui-gap-1",onClick:t,children:[jsxRuntime.jsx("span",{children:jsxRuntime.jsx(bt,{})}),"Download"]}),jsxRuntime.jsxs(ui.Button,{className:"oui-flex-1 oui-flex oui-gap-1",onClick:o,children:[jsxRuntime.jsx("span",{children:jsxRuntime.jsx(wt,{})}),"Copy"]})]})},bt=()=>jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{d:"M4.66 1.994A2.667 2.667 0 0 0 1.995 4.66v6.666a2.667 2.667 0 0 0 2.667 2.667h6.666a2.667 2.667 0 0 0 2.667-2.667V4.661a2.667 2.667 0 0 0-2.667-2.667zM7.995 4.66c.368 0 .667.298.667.666V8.66h2l-2.667 2.666L5.328 8.66h2V5.327c0-.368.299-.667.667-.667",fill:"#fff",fillOpacity:".98"})}),wt=()=>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:"M5.166 1.994A2.667 2.667 0 0 0 2.499 4.66v4a2.667 2.667 0 0 0 2.667 2.667 2.667 2.667 0 0 0 2.666 2.667h4a2.667 2.667 0 0 0 2.667-2.667v-4a2.667 2.667 0 0 0-2.667-2.667 2.667 2.667 0 0 0-2.666-2.666zm6.666 4c.737 0 1.334.596 1.334 1.333v4c0 .737-.597 1.334-1.334 1.334h-4A1.333 1.333 0 0 1 6.5 11.327h2.667a2.667 2.667 0 0 0 2.666-2.667z",fill:"#fff",fillOpacity:".98"})});var Te=e=>{let{shareOptions:t}=e,o=ee(),n=e.entity.roi!=null&&e.entity.pnl!=null?["roi_pnl","roi","pnl"]:e.entity.roi!=null?["roi"]:e.entity.pnl!=null?["pnl"]:[],[r,l]=p.useState(n.length==1?n[0]:o.pnlFormat),[s,u]=p.useState(new Set(o.options)),[i,c]=p.useState(o.bgIndex),[d,C]=p.useState(o.message),[B,S]=p.useState(!1),{backgroundImages:w,...O}=t??{backgroundImages:[]},[M,P]=p.useState(""),y=p.useRef(null);p.useEffect(()=>{let N=window.location.hostname;P(N);},[]);let I=p.useMemo(()=>t?.backgroundImages?.[i],[t?.backgroundImages,i]),W=X(e.entity,e.leverage,B?d:"",M,r,s,e.baseDp,e.quoteDp,e.referral),h=()=>{y.current?.copy().then(()=>{e.hide?.(),ui.toast.success("Image copied");}).catch(N=>{ui.toast.error(()=>jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{children:"Copy failed"}),jsxRuntime.jsx("div",{className:"oui-text-2xs oui-max-w-[396px] oui-mt-2 oui-text-base-contrast-54",children:"Browser version outdated, please update in order to copy image to clipboard."})]}));});},Z=()=>{y.current?.download("Poster.png"),e.hide?.();},ne=[...e.entity.openPrice?["openPrice"]:[],...e.entity.markPrice?["markPrice"]:[],...e.entity.openTime?["openTime"]:[],...e.leverage?["leverage"]:[],...e.entity.quantity?["quantity"]:[]];return j(r,s,i,d),jsxRuntime.jsxs("div",{className:"oui-h-full oui-flex oui-flex-col oui-relative oui-w-full",children:[jsxRuntime.jsxs("div",{className:"oui-flex-1 oui-h-full oui-overflow-y-auto",children:[jsxRuntime.jsxs(ui.Box,{mt:9,height:422,children:[jsxRuntime.jsx(ui.Flex,{itemAlign:"center",justify:"center",children:jsxRuntime.jsx($,{width:552,height:310,data:{backgroundImg:I,...O,data:W},ratio:3,ref:y})}),jsxRuntime.jsx(be,{backgroundImages:t?.backgroundImages??[],selectedSnap:i,setSelectedSnap:c})]}),jsxRuntime.jsxs(ui.Flex,{direction:"column",px:10,mt:6,justify:"start",itemAlign:"start",width:"100%",children:[jsxRuntime.jsx(ui.Text,{size:"sm",intensity:80,children:"PnL display format"}),jsxRuntime.jsx(ui.Flex,{pt:3,gap:3,itemAlign:"center",children:n.map((N,E)=>jsxRuntime.jsx(we,{setPnlFormat:l,type:N,curType:r},E))}),jsxRuntime.jsx(ui.Divider,{className:"oui-w-full oui-pt-6 oui-border-white/10"}),jsxRuntime.jsxs(ui.Flex,{mt:6,direction:"column",justify:"start",itemAlign:"start",children:[jsxRuntime.jsx(ui.Text,{size:"sm",intensity:80,children:"Optional information to share"}),jsxRuntime.jsx(ui.Flex,{mt:3,gap:4,children:ne.map((N,E)=>jsxRuntime.jsx(De,{setShareOption:u,type:N,curType:s},E))})]}),jsxRuntime.jsx(Le,{message:d,setMessage:C,check:B,setCheck:S})]})]}),jsxRuntime.jsx(Ie,{onClickCopy:h,onClickDownload:Z})]})};var Me=p__namespace.createContext(null);function F(){let e=p__namespace.useContext(Me);if(!e)throw new Error("useCarousel must be used within a <Carousel />");return e}var le=p__namespace.forwardRef(({orientation:e="horizontal",opts:t,setApi:o,plugins:a,className:n,children:r,...l},s)=>{let[u,i]=et__default.default({...t,axis:e==="horizontal"?"x":"y"},a),[c,d]=p__namespace.useState(!1),[C,B]=p__namespace.useState(!1),[S,w]=p__namespace.useState(l.initIndex||0),[O,M]=p__namespace.useState([]),P=p__namespace.useCallback(h=>{h&&(O.length===0&&M(h.scrollSnapList()),w(h.selectedScrollSnap()),d(h.canScrollPrev()),B(h.canScrollNext()));},[O]),y=p__namespace.useCallback(()=>{i?.scrollPrev();},[i]),I=p__namespace.useCallback(()=>{i?.scrollNext();},[i]),W=p__namespace.useCallback(h=>{h.key==="ArrowLeft"?(h.preventDefault(),y()):h.key==="ArrowRight"&&(h.preventDefault(),I());},[y,I]);return p__namespace.useEffect(()=>{!i||!o||o(i);},[i,o]),p__namespace.useEffect(()=>{if(i)return P(i),i.on("reInit",P),i.on("select",P),l.initIndex&&i.scrollTo(l.initIndex),()=>{i?.off("select",P);}},[i,P]),jsxRuntime.jsx(Me.Provider,{value:{carouselRef:u,api:i,opts:t,orientation:e||(t?.axis==="y"?"vertical":"horizontal"),scrollPrev:y,scrollNext:I,canScrollPrev:c,canScrollNext:C,selectedIndex:S,scrollSnaps:O},children:jsxRuntime.jsx("div",{ref:s,onKeyDownCapture:W,className:ui.cn("oui-relative",n),role:"region","aria-roledescription":"carousel",...l,children:r})})});le.displayName="Carousel";var Q=p__namespace.forwardRef(({className:e,...t},o)=>{let{carouselRef:a,orientation:n}=F();return jsxRuntime.jsx("div",{ref:a,className:"oui-overflow-hidden",children:jsxRuntime.jsx("div",{ref:o,className:ui.cn("oui-flex",n==="horizontal"?"oui--ml-4":"oui--mt-4 oui-flex-col",e),...t})})});Q.displayName="CarouselContent";var J=p__namespace.forwardRef(({className:e,...t},o)=>{let{orientation:a}=F();return jsxRuntime.jsx("div",{ref:o,role:"group","aria-roledescription":"slide",className:ui.cn("oui-min-w-0 oui-shrink-0 oui-grow-0 oui-basis-full",a==="horizontal"?"oui-pl-4":"oui-pt-4",e),...t})});J.displayName="CarouselItem";var ue=p__namespace.forwardRef(({className:e,variant:t="contained",size:o="icon",...a},n)=>{let{orientation:r,scrollPrev:l,canScrollPrev:s}=F();return jsxRuntime.jsxs(ui.Button,{ref:n,variant:t,className:ui.cn("oui-absolute oui-h-8 oui-w-8 oui-rounded-full",r==="horizontal"?"oui--left-12 oui-top-1/2 oui--translate-y-1/2":"oui--top-12 oui-left-1/2 oui--translate-x-1/2 oui-rotate-90",e),disabled:!s,onClick:l,...a,children:[jsxRuntime.jsx(ChevronLeft,{size:20}),jsxRuntime.jsx("span",{className:"oui-sr-only",children:"Previous slide"})]})});ue.displayName="CarouselPrevious";var ce=p__namespace.forwardRef(({className:e,variant:t="contained",size:o="icon",...a},n)=>{let{orientation:r,scrollNext:l,canScrollNext:s}=F();return jsxRuntime.jsxs(ui.Button,{ref:n,variant:t,className:ui.cn("oui-absolute oui-h-8 oui-w-8 oui-rounded-full",r==="horizontal"?"oui--right-12 oui-top-1/2 oui--translate-y-1/2":"oui--bottom-12 oui-left-1/2 oui--translate-x-1/2 oui-rotate-90",e),disabled:!s,onClick:l,...a,children:[jsxRuntime.jsx(ChevronRight,{size:20}),jsxRuntime.jsx("span",{className:"oui-sr-only",children:"Next slide"})]})});ce.displayName="CarouselNext";var me=e=>{let{scrollSnaps:t,selectedIndex:o}=F();return jsxRuntime.jsx("div",{className:ui.cn("oui-flex oui-gap-1",e.className),children:t.map((a,n)=>jsxRuntime.jsx(pe,{index:n,active:n===o,onClick:e.onClick,className:e.dotClassName,activeClassName:e.dotActiveClassName},n))})};me.displayName="CarouselIdentifier";var pe=({index:e,active:t,onClick:o,className:a,activeClassName:n})=>jsxRuntime.jsx("button",{onClick:()=>o?.(e),className:ui.cn("oui-w-2 oui-h-2 oui-rounded-full oui-bg-white/30",a,t&&`active ${n||"oui-bg-primary-darken"}`)});var T=le;T.Content=Q;T.Item=J;T.Next=ce;T.Previous=ue;T.indentify=me;var ze=e=>{let{shareOptions:t}=e,o=ee(),n=e.entity.roi!=null&&e.entity.pnl!=null?["roi_pnl","roi","pnl"]:e.entity.roi!=null?["roi"]:e.entity.pnl!=null?["pnl"]:[],[r,l]=p.useState(n.length==1?n[0]:o.pnlFormat),[s,u]=p.useState(new Set(o.options)),[i,c]=p.useState(o.message),[d,C]=p.useState(o.bgIndex),{backgroundImages:B,...S}=t??{backgroundImages:[]},[w,O]=p.useState(""),M=t?.backgroundImages?.map(()=>p.useRef(null));p.useEffect(()=>{let f=window.location.hostname;O(f);},[]);let P=X(e.entity,e.leverage,i,w,r,s,e.baseDp,e.quoteDp,e.referral),y=p.useRef(),I=552/310,[W,h]=p.useState(1),[Z,ne]=p.useState(0),[N,E]=p.useState(!1),ve=p.useRef(null);p.useEffect(()=>{if(y.current){let f=y.current.offsetWidth,A=f/I;ne(A),h(f/552);}},[y,w]);let We=async f=>{if(!f.current)return;let A=f.current?.toDataURL(),$e=At(A);try{navigator.share&&await navigator.share({text:i,files:[new File([$e],"image.png",{type:"image/png"})]}),e.hide?.();}catch{}};return j(r,s,d,i),jsxRuntime.jsxs("div",{className:"oui-w-full",children:[jsxRuntime.jsx("div",{ref:y,className:"oui-w-full oui-mt-4 oui-overflow-hidden",style:{height:`${Z+20}px`},children:jsxRuntime.jsxs(T,{className:"oui-w-full oui-overflow-hidden",opts:{align:"start"},initIndex:d,children:[jsxRuntime.jsx(Q,{style:{height:`${Z}px`},children:t?.backgroundImages?.map((f,A)=>jsxRuntime.jsx(J,{children:jsxRuntime.jsx($,{className:"oui-transform oui-origin-top-left",style:{scale:`${W}`},width:552,height:310,data:{backgroundImg:f,...S,data:P},ratio:3,ref:M?.[A]})},A))}),jsxRuntime.jsx("div",{className:"oui-mt-2 oui-mb-1 oui-flex oui-justify-center",children:jsxRuntime.jsx(zt,{dotClassName:"oui-w-[16px] oui-h-[4px] oui-bg-base-300",dotActiveClassName:"!oui-bg-primary-darken oui-w-[20px]",setSelectIndex:C})})]})}),jsxRuntime.jsxs(ui.ScrollArea,{className:"oui-max-h-[200px] oui-overflow-y-auto oui-custom-scrollbar",children:[jsxRuntime.jsxs("div",{className:"oui-mt-4",children:[jsxRuntime.jsx("div",{className:"oui-text-3xs oui-text-base-contrast-54",children:"PnL display format"}),jsxRuntime.jsx("div",{className:"oui-pt-3 oui-px-1 oui-justify-between oui-gap-3 oui-grid oui-grid-cols-3 oui-row-span-1",children:n.map(f=>jsxRuntime.jsx(Et,{setPnlFormat:l,type:f,curType:r}))})]}),jsxRuntime.jsxs("div",{className:"oui-mt-3",children:[jsxRuntime.jsx("div",{className:"oui-text-3xs oui-text-base-contrast-54 oui-h-[18px]",children:"Optional information to share"}),jsxRuntime.jsxs("div",{className:"oui-flex oui-flex-wrap oui-gap-3 oui-mt-3",children:[e.entity.openPrice&&jsxRuntime.jsx(Y,{setShareOption:u,type:"openPrice",curType:s}),e.entity.openTime&&jsxRuntime.jsx(Y,{setShareOption:u,type:"openTime",curType:s}),e.leverage&&jsxRuntime.jsx(Y,{setShareOption:u,type:"leverage",curType:s}),e.entity.markPrice&&jsxRuntime.jsx(Y,{setShareOption:u,type:"markPrice",curType:s}),e.entity.quantity&&jsxRuntime.jsx(Y,{setShareOption:u,type:"quantity",curType:s})]})]}),jsxRuntime.jsxs("div",{className:"oui-mt-3 oui-mb-8",children:[jsxRuntime.jsx("div",{className:"oui-text-3xs oui-text-base-contrast-54 oui-h-[18px]",children:"Your message"}),jsxRuntime.jsx("div",{className:"oui-mt-3 oui-h-[48px] oui-bg-base-600 oui-mx-1",children:jsxRuntime.jsx(ui.Input,{placeholder:"Max 25 characters",containerClassName:"oui-bg-transparent oui-h-[48px]",value:i,autoFocus:!1,onChange:f=>{if(f.target.value.length>25){ui.toast.error("Maximum support of 25 characters");return}c(f.target.value);},ref:ve,onFocus:()=>E(!0),onBlur:()=>E(!1),suffix:N&&jsxRuntime.jsx("button",{className:"oui-mr-3 oui-cursor-pointer",onMouseDown:f=>{c(""),setTimeout(()=>{ve.current?.focus();},50),f.stopPropagation();},children:jsxRuntime.jsx(ui.CloseCircleFillIcon,{size:18,color:"white"})})})})]})]}),jsxRuntime.jsx("div",{className:"oui-pt-2",children:jsxRuntime.jsx(ui.Button,{fullWidth:!0,className:"oui-h-[40px] oui-text-[16px]",onClick:()=>{let f=M?.[d];f&&We(f);},children:"Share"})})]})},Et=e=>{let{type:t,curType:o,setPnlFormat:a}=e,n=p.useMemo(()=>{switch(t){case"roi_pnl":return "ROI & PnL";case"roi":return "ROI";case"pnl":return "PnL"}},[t]);return jsxRuntime.jsx("div",{className:ui.cn("oui-shadow-lg oui-rounded-lg oui-h-[46px] oui-flex-1 oui-bg-base-4 hover:oui-cursor-pointer oui-flex oui-items-center oui-px-3 oui-referral-shadow",t===o&&"oui-bg-primary-darken oui-dot-sel"),onClick:()=>{a(t);},children:jsxRuntime.jsx("div",{className:"oui-text-sm oui-text-base-contrast",children:n})})},Y=e=>{let{type:t,curType:o,setShareOption:a}=e,n=p.useMemo(()=>{switch(t){case"openPrice":return "Open price";case"openTime":return "Opened at";case"markPrice":return "Mark price";case"quantity":return "Quantity";case"leverage":return "Leverage"}},[t]),r=o.has(t);return jsxRuntime.jsxs("div",{className:ui.cn("oui-shadow-lg oui-rounded-lg oui-h-[46px] oui-mt-0 oui-w-[calc(50%-6px)] oui-bg-base-4 hover:oui-cursor-pointer oui-items-center oui-flex oui-p-3 oui-referral-shadow"),onClick:()=>{a(l=>{let s=new Set(l);return r?s.delete(t):s.add(t),s});},children:[jsxRuntime.jsx("div",{className:"oui-text-sm oui-flex-1 oui-text-base-contrast",children:n}),r&&jsxRuntime.jsx(Ht,{})]})};function At(e){let t=atob(e.split(",")[1]),o=e.split(",")[0].split(":")[1].split(";")[0],a=new ArrayBuffer(t.length),n=new Uint8Array(a);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return new Blob([a],{type:o})}var zt=e=>{let{scrollSnaps:t,selectedIndex:o}=F();return p.useEffect(()=>{e.setSelectIndex(o);},[o]),jsxRuntime.jsx("div",{className:ui.cn("oui-flex oui-gap-1"),children:t.map((a,n)=>jsxRuntime.jsx(pe,{index:n,active:n===o,onClick:e.onClick,className:e.dotClassName,activeClassName:e.dotActiveClassName},n))})},Ht=()=>jsxRuntime.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2.01416 11.9989C2.01416 6.47589 6.49136 1.9989 12.0142 1.9989C17.5372 1.9989 22.0142 6.47589 22.0142 11.9989C22.0142 17.5219 17.5372 21.9989 12.0142 21.9989C6.49136 21.9989 2.01416 17.5219 2.01416 11.9989ZM16.9853 7.31211C17.2125 7.09537 17.5236 7 17.8218 7C18.1201 7 18.4312 7.09537 18.6583 7.31211C19.1139 7.74546 19.1139 8.47384 18.6583 8.9072L10.5077 16.675C10.0534 17.1083 9.28909 17.1083 8.83472 16.675L5.34077 13.3459C4.88641 12.9126 4.88641 12.1841 5.34077 11.7508C5.79631 11.3175 6.56057 11.3175 7.01493 11.7508L9.67122 14.2822L16.9853 7.31211Z",fill:"white",fillOpacity:"1"})});var He=e=>{let{leverage:t,entity:o,baseDp:a,quoteDp:n,referralInfo:r,shareOptions:l,hide:s}=e,[u,i]=p.useState(window.innerHeight<900?660:807);return p.useEffect(()=>{let c=()=>{i(window.innerHeight<900?660:807);};return window.addEventListener("resize",c),()=>{window.removeEventListener("resize",c);}},[]),l==null||o==null?jsxRuntime.jsx(jsxRuntime.Fragment,{}):jsxRuntime.jsx(Te,{entity:o,leverage:`${t}`,hide:s,baseDp:a,quoteDp:n,referral:r,shareOptions:l})},_e=e=>{let{leverage:t,entity:o,baseDp:a,quoteDp:n,referralInfo:r,shareOptions:l,hide:s}=e;return l==null||o==null?jsxRuntime.jsx(jsxRuntime.Fragment,{}):jsxRuntime.jsx(ze,{entity:o,leverage:t,hide:s,baseDp:a,quoteDp:n,referral:r,shareOptions:l})};var ge=e=>{let t=G({hide:e.hide,pnl:e.pnl});return jsxRuntime.jsx(_e,{...t})},ye=e=>{let t=G({hide:e.hide,pnl:e.pnl});return jsxRuntime.jsx(He,{...t})};var $t="sharePnLDialog",Vt="sharePnLBottomSheet";ui.registerSimpleDialog($t,ye,{classNames:{content:"!oui-max-w-[624px] oui-p-0"}});ui.registerSimpleSheet(Vt,ge,{title:"Share PnL",classNames:{body:"oui-pb-4 oui-pt-0"}});
|
|
33
|
+
var G=e=>{let{pnl:t,hide:o}=e,a=t?.entity,n=hooks.useSymbolsInfo(),{getFirstRefCode:r}=hooks.useReferralInfo(),l=p.useMemo(()=>{let i=r()?.code;return {code:t?.refCode??i,slogan:t?.refSlogan,link:t?.refLink}},[r,t]),s=p.useMemo(()=>{if(a)return n[a?.symbol]("base_dp")},[a,n]),c=p.useMemo(()=>{if(a)return n[a?.symbol]("quote_dp")},[a,n]);return {entity:a,leverage:t?.leverage,baseDp:s,quoteDp:c,referralInfo:l,shareOptions:t,hide:o}};function j(e,t,o,a,n,r,l,s,c){let{symbol:i,currency:u}=Je(e.symbol),d={symbol:i,currency:u,side:e.side};switch(n){case "pnl":{e.pnl!=null&&(d.pnl=new utils.Decimal(e.pnl).toFixed(2,utils.Decimal.ROUND_DOWN));break}case "roi":{e.roi!=null&&(d.ROI=new utils.Decimal(e.roi).toFixed(2,utils.Decimal.ROUND_DOWN));break}case "roi_pnl":{e.pnl!=null&&(d.pnl=new utils.Decimal(e.pnl).toFixed(2,utils.Decimal.ROUND_DOWN)),e.roi!=null&&(d.ROI=new utils.Decimal(e.roi).toFixed(2,utils.Decimal.ROUND_DOWN));break}}let y=[];r.has("leverage")&&(d.leverage=t),["openPrice","closePrice","openTime","closeTime","markPrice","quantity"].forEach(w=>{if(r.has(w))switch(w){case "leverage":break;case "openPrice":{e.openPrice!=null&&y.push({title:"Open price",value:X(e.openPrice,s||2)});break}case "closePrice":{e.closePrice!=null&&y.push({title:"Close price",value:X(e.closePrice,s||2)});break}case "openTime":{e.openTime!=null&&y.push({title:"Opened at",value:Ce(e.openTime)});break}case "closeTime":{e.closeTime!=null&&y.push({title:"Closed at",value:Ce(e.closeTime)});break}case "markPrice":{e.markPrice!=null&&y.push({title:"Mark price",value:X(e.markPrice,s||2)});break}case "quantity":e.quantity!=null&&y.push({title:"Quantity",value:X(e.quantity,l||2)});}}),d.informations=y;let P={position:d,updateTime:Ye(new Date),domain:a};return o.length>0&&(P.message=o),typeof c<"u"&&c.code!==void 0&&(P.referral=c),P}function Je(e){let t=e.split("_");if(t.length!==3)return {symbol:e,currency:"USDC"};let[o,a,n]=t;return {symbol:`${a}-${o}`,currency:n||"USDC"}}function Ye(e){let t=e instanceof Date?e:new Date(e),o={year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hourCycle:"h24"},n=new Intl.DateTimeFormat("en-US",o).formatToParts(t),r=n.find(u=>u.type==="year"?u.value:"")?.value,l=n.find(u=>u.type==="month"?u.value:"")?.value,s=n.find(u=>u.type==="day"?u.value:"")?.value,c=n.find(u=>u.type==="hour"?u.value:"")?.value,i=n.find(u=>u.type==="minute"?u.value:"")?.value;return `${r}-${l}-${s} ${c}:${i}`}function Ce(e){let t=e instanceof Date?e:new Date(e),o={year:"numeric",month:"short",day:"2-digit",hour:"2-digit",minute:"2-digit"},n=new Intl.DateTimeFormat("en-US",o).formatToParts(t),r=n.find(i=>i.type==="month"?i.value:"")?.value,l=n.find(i=>i.type==="day"?i.value:"")?.value,s=n.find(i=>i.type==="hour"?i.value:"")?.value,c=n.find(i=>i.type==="minute"?i.value:"")?.value;return `${r}-${l} ${s}:${c}`}function X(e,t){return new utils.Decimal(e).toFixed(t,utils.Decimal.ROUND_DOWN)}function ee(e,t,o,a){localStorage.setItem("pnl_config_key",JSON.stringify({bgIndex:o,pnlFormat:e,options:Array.from(t),message:a}));}function te(){let e=localStorage.getItem("pnl_config_key");if(e&&e.length>0)try{return JSON.parse(e)}catch{}return {bgIndex:0,pnlFormat:"roi_pnl",options:["openPrice","closePrice","openTime","closeTime","markPrice","quantity","leverage"],message:""}}var V=p.forwardRef((e,t)=>{let{width:o,height:a,className:n,data:r,style:l}=e,{ref:s,download:c,toDataURL:i,copy:u,toBlob:d}=hooks.usePoster(r,{ratio:e.ratio});return p.useImperativeHandle(t,()=>({download:c,toDataURL:i,toBlob:d,copy:u})),jsxRuntime.jsx("canvas",{ref:s,width:o,height:a,className:n,style:l})});var xe=e=>{let{children:t,...o}=e;return jsxRuntime.jsx("button",{...o,children:jsxRuntime.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsx("rect",{width:"20",height:"20",rx:"10",fill:"#333948"}),jsxRuntime.jsx("path",{d:"M11.186 5.348a.67.67 0 0 0-.436.27l-2.657 4a.69.69 0 0 0 0 .75l2.657 4a.68.68 0 0 0 .934.188.685.685 0 0 0 .187-.937L9.463 9.993 11.87 6.37a.685.685 0 0 0-.187-.938.65.65 0 0 0-.498-.083",fill:"#fff",fillOpacity:".54"})]})})},Pe=e=>{let{children:t,...o}=e;return jsxRuntime.jsx("button",{...o,children:jsxRuntime.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsx("rect",{width:"20",height:"20",rx:"10",fill:"#333948"}),jsxRuntime.jsx("path",{d:"M8.777 5.348a.65.65 0 0 0-.498.083.685.685 0 0 0-.187.938L10.5 9.993 8.092 13.62a.685.685 0 0 0 .187.937.68.68 0 0 0 .934-.187l2.657-4a.69.69 0 0 0 0-.75l-2.657-4a.67.67 0 0 0-.436-.271",fill:"#fff",fillOpacity:".54"})]})})};var we=e=>{let{backgroundImages:t,selectedSnap:o,setSelectedSnap:a}=e,[n,r]=et__default.default({containScroll:"keepSnaps",dragFree:true}),l=p.useCallback(()=>{r&&r.scrollPrev();},[r]),s=p.useCallback(()=>{r&&r.scrollNext();},[r]),c=p.useCallback(i=>{a(i.selectedScrollSnap());},[]);return p.useEffect(()=>{r&&(c(r),r.on("reInit",c),r.on("select",c),r?.scrollTo(o));},[r,c]),jsxRuntime.jsxs(ui.Flex,{mt:4,px:2,children:[jsxRuntime.jsx(xe,{onClick:l}),jsxRuntime.jsx("div",{ref:n,className:"oui-w-full oui-overflow oui-overflow-x-auto oui-scrollbar-hidden oui-hide-scrollbar oui-mx-0",children:jsxRuntime.jsx(ui.Flex,{children:t.map((i,u)=>jsxRuntime.jsx(ui.Box,{onClick:()=>{r?.scrollTo(u);},mx:2,my:1,mr:6,r:"base",className:ui.cn("oui-shrink-0 oui-w-[162px]",o===u&&"oui-outline oui-outline-1 oui-outline-primary-darken"),children:jsxRuntime.jsx("img",{src:i,className:"oui-rounded-sm"})},i))})}),jsxRuntime.jsx(Pe,{onClick:s})]})};var Ne=e=>{let{type:t,curType:o,setPnlFormat:a}=e,n=p.useMemo(()=>{switch(t){case "roi_pnl":return "ROI & PnL";case "roi":return "ROI";case "pnl":return "PnL"}},[t]),r=t===o,l="oui-flex oui-items-center oui-gap-1 oui-cursor-pointer";return r?l+=" oui-text-base-contrast":l+="",jsxRuntime.jsxs("div",{className:l,onClick:()=>{a(t);},children:[jsxRuntime.jsx(lt,{sel:r}),jsxRuntime.jsx(ui.Text,{size:"xs",intensity:54,className:ui.cn("oui-ml-2 "),children:n})]})},lt=e=>jsxRuntime.jsx("button",{type:"button",children:e.sel===true?jsxRuntime.jsx(ct,{}):jsxRuntime.jsx(ut,{})}),ct=()=>jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",className:"oui-fill-primary-darken",children:[jsxRuntime.jsx("path",{d:"M8.01 1.333a6.667 6.667 0 1 0 0 13.333 6.667 6.667 0 0 0 0-13.333m0 1.333a5.334 5.334 0 1 1-.001 10.667 5.334 5.334 0 0 1 0-10.667",fill:"#fff",fillOpacity:".36"}),jsxRuntime.jsx("circle",{cx:"8",cy:"8",r:"3.333"})]}),ut=()=>jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{d:"M8.01 1.333a6.667 6.667 0 1 0 0 13.333 6.667 6.667 0 0 0 0-13.333m0 1.333a5.334 5.334 0 1 1-.001 10.667 5.334 5.334 0 0 1 0-10.667",fill:"#fff",fillOpacity:".54"})});var oe=e=>{let{size:t=16,className:o}=e;return jsxRuntime.jsx("button",{type:"button",onClick:a=>{e.onCheckedChange(!e.checked);},className:o,children:e.checked?jsxRuntime.jsx("svg",{width:t,height:t,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4.66 1.953A2.667 2.667 0 0 0 1.995 4.62v6.667a2.667 2.667 0 0 0 2.667 2.666h6.666a2.667 2.667 0 0 0 2.667-2.666V4.62a2.667 2.667 0 0 0-2.667-2.667zm6.664 2.922a.8.8 0 0 1 .557-.208c.2 0 .406.063.558.208a.734.734 0 0 1 0 1.063l-5.434 5.179a.826.826 0 0 1-1.115 0l-2.33-2.22a.736.736 0 0 1 0-1.063.827.827 0 0 1 1.117 0l1.77 1.687z",fill:"#fff",fillOpacity:".8"})}):jsxRuntime.jsx("svg",{width:t,height:t,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{d:"M4.66 1.953A2.667 2.667 0 0 0 1.995 4.62v6.667a2.667 2.667 0 0 0 2.667 2.666h6.666a2.667 2.667 0 0 0 2.667-2.666V4.62a2.667 2.667 0 0 0-2.667-2.667zm0 1.334h6.667c.737 0 1.334.596 1.334 1.333v6.667c0 .736-.597 1.333-1.334 1.333H4.661a1.333 1.333 0 0 1-1.334-1.333V4.62c0-.737.597-1.333 1.334-1.333",fill:"#fff",fillOpacity:".8"})})})};var Le=e=>{let{type:t,curType:o,setShareOption:a}=e,n=p.useMemo(()=>{switch(t){case "openPrice":return "Open price";case "closePrice":return "Close price";case "openTime":return "Opened at";case "closeTime":return "Closed at";case "markPrice":return "Mark price";case "quantity":return "Quantity";case "leverage":return "Leverage"}},[t]),r=o.has(t);return jsxRuntime.jsxs(ui.Flex,{itemAlign:"center",gap:1,className:ui.cn("hover:oui-cursor-pointer"),onClick:()=>{a(l=>{let s=new Set(l);return r?s.delete(t):s.add(t),s});},children:[jsxRuntime.jsx(oe,{size:16,checked:r,className:"oui-pt-[2px]",onCheckedChange:l=>{a(s=>{let c=new Set(s);return r?c.delete(t):c.add(t),c});}}),jsxRuntime.jsx(ui.Text,{size:"xs",intensity:54,children:n})]})};var De=e=>{let{message:t,setMessage:o,check:a,setCheck:n}=e,[r,l]=p.useState(false),s=p.useRef(null);return jsxRuntime.jsxs("div",{className:"oui-mt-3 oui-mb-6 oui-flex oui-items-center",children:[jsxRuntime.jsx(oe,{className:"oui-mt-[2px]",checked:a,onCheckedChange:c=>{n(c);}}),jsxRuntime.jsx("div",{className:"oui-text-xs oui-text-base-contrast-54 oui-ml-1 hover:oui-cursor-pointer",onClick:()=>{n(!e.check);},children:"Your message"}),jsxRuntime.jsx("div",{className:"oui-bg-base-900 oui-mx-2 oui-rounded-sm",children:jsxRuntime.jsx(ui.Input,{ref:s,placeholder:"Max 25 characters",classNames:{root:"oui-w-[320px]"},size:"sm",value:t,autoFocus:false,suffix:r&&jsxRuntime.jsx("button",{className:"oui-mr-3 oui-cursor-pointer",onMouseDown:c=>{o(""),setTimeout(()=>{s.current?.focus();},50),c.stopPropagation();},children:jsxRuntime.jsx(ui.CloseCircleFillIcon,{size:18,color:"white"})}),onFocus:()=>l(true),onBlur:()=>l(false),onChange:c=>{if(c.target.value.length>25){ui.toast.error("Maximum support of 25 characters");return}n(c.target.value.length>0),o(c.target.value);}})})]})};var Te=e=>{let{onClickDownload:t,onClickCopy:o}=e;return jsxRuntime.jsxs(ui.Flex,{px:8,gap:3,mt:3,itemAlign:"center",children:[jsxRuntime.jsxs(ui.Button,{color:"secondary",className:"oui-flex-1 oui-flex oui-gap-1",onClick:t,children:[jsxRuntime.jsx("span",{children:jsxRuntime.jsx(bt,{})}),"Download"]}),jsxRuntime.jsxs(ui.Button,{className:"oui-flex-1 oui-flex oui-gap-1",onClick:o,children:[jsxRuntime.jsx("span",{children:jsxRuntime.jsx(wt,{})}),"Copy"]})]})},bt=()=>jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{d:"M4.66 1.994A2.667 2.667 0 0 0 1.995 4.66v6.666a2.667 2.667 0 0 0 2.667 2.667h6.666a2.667 2.667 0 0 0 2.667-2.667V4.661a2.667 2.667 0 0 0-2.667-2.667zM7.995 4.66c.368 0 .667.298.667.666V8.66h2l-2.667 2.666L5.328 8.66h2V5.327c0-.368.299-.667.667-.667",fill:"#fff",fillOpacity:".98"})}),wt=()=>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:"M5.166 1.994A2.667 2.667 0 0 0 2.499 4.66v4a2.667 2.667 0 0 0 2.667 2.667 2.667 2.667 0 0 0 2.666 2.667h4a2.667 2.667 0 0 0 2.667-2.667v-4a2.667 2.667 0 0 0-2.667-2.667 2.667 2.667 0 0 0-2.666-2.666zm6.666 4c.737 0 1.334.596 1.334 1.333v4c0 .737-.597 1.334-1.334 1.334h-4A1.333 1.333 0 0 1 6.5 11.327h2.667a2.667 2.667 0 0 0 2.666-2.667z",fill:"#fff",fillOpacity:".98"})});var Be=e=>{let{shareOptions:t}=e,o=te(),n=e.entity.roi!=null&&e.entity.pnl!=null?["roi_pnl","roi","pnl"]:e.entity.roi!=null?["roi"]:e.entity.pnl!=null?["pnl"]:[],[r,l]=p.useState(n.length==1?n[0]:o.pnlFormat),[s,c]=p.useState(new Set(o.options)),[i,u]=p.useState(o.bgIndex),[d,y]=p.useState(o.message),[M,P]=p.useState(false),{backgroundImages:w,...D}=t??{backgroundImages:[]},[E,S]=p.useState(""),v=p.useRef(null);p.useEffect(()=>{let N=window.location.hostname;S(N);},[]);let I=p.useMemo(()=>t?.backgroundImages?.[i],[t?.backgroundImages,i]),$=j(e.entity,e.leverage,M?d:"",E,r,s,e.baseDp,e.quoteDp,e.referral),h=()=>{v.current?.copy().then(()=>{e.hide?.(),ui.toast.success("Image copied");}).catch(N=>{ui.toast.error(()=>jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{children:"Copy failed"}),jsxRuntime.jsx("div",{className:"oui-text-2xs oui-max-w-[396px] oui-mt-2 oui-text-base-contrast-54",children:"Browser version outdated, please update in order to copy image to clipboard."})]}));});},Z=()=>{v.current?.download("Poster.png"),e.hide?.();},re=[...e.entity.openPrice?["openPrice"]:[],...e.entity.closePrice?["closePrice"]:[],...e.entity.markPrice?["markPrice"]:[],...e.entity.openTime?["openTime"]:[],...e.entity.closeTime?["closeTime"]:[],...e.leverage?["leverage"]:[],...e.entity.quantity?["quantity"]:[]];return ee(r,s,i,d),jsxRuntime.jsxs("div",{className:"oui-h-full oui-flex oui-flex-col oui-relative oui-w-full",children:[jsxRuntime.jsxs("div",{className:"oui-flex-1 oui-h-full oui-overflow-y-auto",children:[jsxRuntime.jsxs(ui.Box,{mt:9,height:422,children:[jsxRuntime.jsx(ui.Flex,{itemAlign:"center",justify:"center",children:jsxRuntime.jsx(V,{width:552,height:310,data:{backgroundImg:I,...D,data:$},ratio:3,ref:v})}),jsxRuntime.jsx(we,{backgroundImages:t?.backgroundImages??[],selectedSnap:i,setSelectedSnap:u})]}),jsxRuntime.jsxs(ui.Flex,{direction:"column",px:10,mt:6,justify:"start",itemAlign:"start",width:"100%",children:[jsxRuntime.jsx(ui.Text,{size:"sm",intensity:80,children:"PnL display format"}),jsxRuntime.jsx(ui.Flex,{pt:3,gap:3,itemAlign:"center",children:n.map((N,A)=>jsxRuntime.jsx(Ne,{setPnlFormat:l,type:N,curType:r},A))}),jsxRuntime.jsx(ui.Divider,{className:"oui-w-full oui-pt-6 oui-border-white/10"}),jsxRuntime.jsxs(ui.Flex,{mt:6,direction:"column",justify:"start",itemAlign:"start",children:[jsxRuntime.jsx(ui.Text,{size:"sm",intensity:80,children:"Optional information to share"}),jsxRuntime.jsx(ui.Flex,{mt:3,gap:4,className:"oui-flex-wrap",children:re.map((N,A)=>jsxRuntime.jsx(Le,{setShareOption:c,type:N,curType:s},A))})]}),jsxRuntime.jsx(De,{message:d,setMessage:y,check:M,setCheck:P})]})]}),jsxRuntime.jsx(Te,{onClickCopy:h,onClickDownload:Z})]})};var Ee=p__namespace.createContext(null);function R(){let e=p__namespace.useContext(Ee);if(!e)throw new Error("useCarousel must be used within a <Carousel />");return e}var le=p__namespace.forwardRef(({orientation:e="horizontal",opts:t,setApi:o,plugins:a,className:n,children:r,...l},s)=>{let[c,i]=et__default.default({...t,axis:e==="horizontal"?"x":"y"},a),[u,d]=p__namespace.useState(false),[y,M]=p__namespace.useState(false),[P,w]=p__namespace.useState(l.initIndex||0),[D,E]=p__namespace.useState([]),S=p__namespace.useCallback(h=>{h&&(D.length===0&&E(h.scrollSnapList()),w(h.selectedScrollSnap()),d(h.canScrollPrev()),M(h.canScrollNext()));},[D]),v=p__namespace.useCallback(()=>{i?.scrollPrev();},[i]),I=p__namespace.useCallback(()=>{i?.scrollNext();},[i]),$=p__namespace.useCallback(h=>{h.key==="ArrowLeft"?(h.preventDefault(),v()):h.key==="ArrowRight"&&(h.preventDefault(),I());},[v,I]);return p__namespace.useEffect(()=>{!i||!o||o(i);},[i,o]),p__namespace.useEffect(()=>{if(i)return S(i),i.on("reInit",S),i.on("select",S),l.initIndex&&i.scrollTo(l.initIndex),()=>{i?.off("select",S);}},[i,S]),jsxRuntime.jsx(Ee.Provider,{value:{carouselRef:c,api:i,opts:t,orientation:e||(t?.axis==="y"?"vertical":"horizontal"),scrollPrev:v,scrollNext:I,canScrollPrev:u,canScrollNext:y,selectedIndex:P,scrollSnaps:D},children:jsxRuntime.jsx("div",{ref:s,onKeyDownCapture:$,className:ui.cn("oui-relative",n),role:"region","aria-roledescription":"carousel",...l,children:r})})});le.displayName="Carousel";var J=p__namespace.forwardRef(({className:e,...t},o)=>{let{carouselRef:a,orientation:n}=R();return jsxRuntime.jsx("div",{ref:a,className:"oui-overflow-hidden",children:jsxRuntime.jsx("div",{ref:o,className:ui.cn("oui-flex",n==="horizontal"?"oui--ml-4":"oui--mt-4 oui-flex-col",e),...t})})});J.displayName="CarouselContent";var Y=p__namespace.forwardRef(({className:e,...t},o)=>{let{orientation:a}=R();return jsxRuntime.jsx("div",{ref:o,role:"group","aria-roledescription":"slide",className:ui.cn("oui-min-w-0 oui-shrink-0 oui-grow-0 oui-basis-full",a==="horizontal"?"oui-pl-4":"oui-pt-4",e),...t})});Y.displayName="CarouselItem";var ce=p__namespace.forwardRef(({className:e,variant:t="contained",size:o="icon",...a},n)=>{let{orientation:r,scrollPrev:l,canScrollPrev:s}=R();return jsxRuntime.jsxs(ui.Button,{ref:n,variant:t,className:ui.cn("oui-absolute oui-h-8 oui-w-8 oui-rounded-full",r==="horizontal"?"oui--left-12 oui-top-1/2 oui--translate-y-1/2":"oui--top-12 oui-left-1/2 oui--translate-x-1/2 oui-rotate-90",e),disabled:!s,onClick:l,...a,children:[jsxRuntime.jsx(ChevronLeft,{size:20}),jsxRuntime.jsx("span",{className:"oui-sr-only",children:"Previous slide"})]})});ce.displayName="CarouselPrevious";var ue=p__namespace.forwardRef(({className:e,variant:t="contained",size:o="icon",...a},n)=>{let{orientation:r,scrollNext:l,canScrollNext:s}=R();return jsxRuntime.jsxs(ui.Button,{ref:n,variant:t,className:ui.cn("oui-absolute oui-h-8 oui-w-8 oui-rounded-full",r==="horizontal"?"oui--right-12 oui-top-1/2 oui--translate-y-1/2":"oui--bottom-12 oui-left-1/2 oui--translate-x-1/2 oui-rotate-90",e),disabled:!s,onClick:l,...a,children:[jsxRuntime.jsx(ChevronRight,{size:20}),jsxRuntime.jsx("span",{className:"oui-sr-only",children:"Next slide"})]})});ue.displayName="CarouselNext";var me=e=>{let{scrollSnaps:t,selectedIndex:o}=R();return jsxRuntime.jsx("div",{className:ui.cn("oui-flex oui-gap-1",e.className),children:t.map((a,n)=>jsxRuntime.jsx(pe,{index:n,active:n===o,onClick:e.onClick,className:e.dotClassName,activeClassName:e.dotActiveClassName},n))})};me.displayName="CarouselIdentifier";var pe=({index:e,active:t,onClick:o,className:a,activeClassName:n})=>jsxRuntime.jsx("button",{onClick:()=>o?.(e),className:ui.cn("oui-w-2 oui-h-2 oui-rounded-full oui-bg-white/30",a,t&&`active ${n||"oui-bg-primary-darken"}`)});var F=le;F.Content=J;F.Item=Y;F.Next=ue;F.Previous=ce;F.indentify=me;var He=e=>{let{shareOptions:t}=e,o=te(),n=e.entity.roi!=null&&e.entity.pnl!=null?["roi_pnl","roi","pnl"]:e.entity.roi!=null?["roi"]:e.entity.pnl!=null?["pnl"]:[],[r,l]=p.useState(n.length==1?n[0]:o.pnlFormat),[s,c]=p.useState(new Set(o.options)),[i,u]=p.useState(o.message),[d,y]=p.useState(o.bgIndex),{backgroundImages:M,...P}=t??{backgroundImages:[]},[w,D]=p.useState(""),E=t?.backgroundImages?.map(()=>p.useRef(null));p.useEffect(()=>{let f=window.location.hostname;D(f);},[]);let S=j(e.entity,e.leverage,i,w,r,s,e.baseDp,e.quoteDp,e.referral),v=p.useRef(),I=552/310,[$,h]=p.useState(1),[Z,re]=p.useState(0),[N,A]=p.useState(false),ve=p.useRef(null);p.useEffect(()=>{if(v.current){let f=v.current.offsetWidth,z=f/I;re(z),h(f/552);}},[v,w]);let $e=async f=>{if(!f.current)return;let z=f.current?.toDataURL(),Ve=At(z);try{navigator.share&&await navigator.share({text:i,files:[new File([Ve],"image.png",{type:"image/png"})]}),e.hide?.();}catch{}};return ee(r,s,d,i),jsxRuntime.jsxs("div",{className:"oui-w-full",children:[jsxRuntime.jsx("div",{ref:v,className:"oui-w-full oui-mt-4 oui-overflow-hidden",style:{height:`${Z+20}px`},children:jsxRuntime.jsxs(F,{className:"oui-w-full oui-overflow-hidden",opts:{align:"start"},initIndex:d,children:[jsxRuntime.jsx(J,{style:{height:`${Z}px`},children:t?.backgroundImages?.map((f,z)=>jsxRuntime.jsx(Y,{children:jsxRuntime.jsx(V,{className:"oui-transform oui-origin-top-left",style:{scale:`${$}`},width:552,height:310,data:{backgroundImg:f,...P,data:S},ratio:3,ref:E?.[z]})},z))}),jsxRuntime.jsx("div",{className:"oui-mt-2 oui-mb-1 oui-flex oui-justify-center",children:jsxRuntime.jsx(zt,{dotClassName:"oui-w-[16px] oui-h-[4px] oui-bg-base-300",dotActiveClassName:"!oui-bg-primary-darken oui-w-[20px]",setSelectIndex:y})})]})}),jsxRuntime.jsxs(ui.ScrollArea,{className:"oui-max-h-[200px] oui-overflow-y-auto oui-custom-scrollbar",children:[jsxRuntime.jsxs("div",{className:"oui-mt-4",children:[jsxRuntime.jsx("div",{className:"oui-text-3xs oui-text-base-contrast-54",children:"PnL display format"}),jsxRuntime.jsx("div",{className:"oui-pt-3 oui-px-1 oui-justify-between oui-gap-3 oui-grid oui-grid-cols-3 oui-row-span-1",children:n.map(f=>jsxRuntime.jsx(Et,{setPnlFormat:l,type:f,curType:r}))})]}),jsxRuntime.jsxs("div",{className:"oui-mt-3",children:[jsxRuntime.jsx("div",{className:"oui-text-3xs oui-text-base-contrast-54 oui-h-[18px]",children:"Optional information to share"}),jsxRuntime.jsxs("div",{className:"oui-flex oui-flex-wrap oui-gap-3 oui-mt-3",children:[e.entity.openPrice&&jsxRuntime.jsx(B,{setShareOption:c,type:"openPrice",curType:s}),e.entity.closePrice&&jsxRuntime.jsx(B,{setShareOption:c,type:"closePrice",curType:s}),e.entity.openTime&&jsxRuntime.jsx(B,{setShareOption:c,type:"openTime",curType:s}),e.entity.closeTime&&jsxRuntime.jsx(B,{setShareOption:c,type:"closeTime",curType:s}),e.leverage&&jsxRuntime.jsx(B,{setShareOption:c,type:"leverage",curType:s}),e.entity.markPrice&&jsxRuntime.jsx(B,{setShareOption:c,type:"markPrice",curType:s}),e.entity.quantity&&jsxRuntime.jsx(B,{setShareOption:c,type:"quantity",curType:s})]})]}),jsxRuntime.jsxs("div",{className:"oui-mt-3 oui-mb-8",children:[jsxRuntime.jsx("div",{className:"oui-text-3xs oui-text-base-contrast-54 oui-h-[18px]",children:"Your message"}),jsxRuntime.jsx("div",{className:"oui-mt-3 oui-h-[48px] oui-bg-base-600 oui-mx-1",children:jsxRuntime.jsx(ui.Input,{placeholder:"Max 25 characters",containerClassName:"oui-bg-transparent oui-h-[48px]",value:i,autoFocus:false,onChange:f=>{if(f.target.value.length>25){ui.toast.error("Maximum support of 25 characters");return}u(f.target.value);},ref:ve,onFocus:()=>A(true),onBlur:()=>A(false),suffix:N&&jsxRuntime.jsx("button",{className:"oui-mr-3 oui-cursor-pointer",onMouseDown:f=>{u(""),setTimeout(()=>{ve.current?.focus();},50),f.stopPropagation();},children:jsxRuntime.jsx(ui.CloseCircleFillIcon,{size:18,color:"white"})})})})]})]}),jsxRuntime.jsx("div",{className:"oui-pt-2",children:jsxRuntime.jsx(ui.Button,{fullWidth:true,className:"oui-h-[40px] oui-text-[16px]",onClick:()=>{let f=E?.[d];f&&$e(f);},children:"Share"})})]})},Et=e=>{let{type:t,curType:o,setPnlFormat:a}=e,n=p.useMemo(()=>{switch(t){case "roi_pnl":return "ROI & PnL";case "roi":return "ROI";case "pnl":return "PnL"}},[t]);return jsxRuntime.jsx("div",{className:ui.cn("oui-shadow-lg oui-rounded-lg oui-h-[46px] oui-flex-1 oui-bg-base-4 hover:oui-cursor-pointer oui-flex oui-items-center oui-px-3 oui-referral-shadow",t===o&&"oui-bg-primary-darken oui-dot-sel"),onClick:()=>{a(t);},children:jsxRuntime.jsx("div",{className:"oui-text-sm oui-text-base-contrast",children:n})})},B=e=>{let{type:t,curType:o,setShareOption:a}=e,n=p.useMemo(()=>{switch(t){case "openPrice":return "Open price";case "closePrice":return "Close price";case "openTime":return "Opened at";case "closeTime":return "Closed at";case "markPrice":return "Mark price";case "quantity":return "Quantity";case "leverage":return "Leverage"}},[t]),r=o.has(t);return jsxRuntime.jsxs("div",{className:ui.cn("oui-shadow-lg oui-rounded-lg oui-h-[46px] oui-mt-0 oui-w-[calc(50%-6px)] oui-bg-base-4 hover:oui-cursor-pointer oui-items-center oui-flex oui-p-3 oui-referral-shadow"),onClick:()=>{a(l=>{let s=new Set(l);return r?s.delete(t):s.add(t),s});},children:[jsxRuntime.jsx("div",{className:"oui-text-sm oui-flex-1 oui-text-base-contrast",children:n}),r&&jsxRuntime.jsx(Ht,{})]})};function At(e){let t=atob(e.split(",")[1]),o=e.split(",")[0].split(":")[1].split(";")[0],a=new ArrayBuffer(t.length),n=new Uint8Array(a);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return new Blob([a],{type:o})}var zt=e=>{let{scrollSnaps:t,selectedIndex:o}=R();return p.useEffect(()=>{e.setSelectIndex(o);},[o]),jsxRuntime.jsx("div",{className:ui.cn("oui-flex oui-gap-1"),children:t.map((a,n)=>jsxRuntime.jsx(pe,{index:n,active:n===o,onClick:e.onClick,className:e.dotClassName,activeClassName:e.dotActiveClassName},n))})},Ht=()=>jsxRuntime.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2.01416 11.9989C2.01416 6.47589 6.49136 1.9989 12.0142 1.9989C17.5372 1.9989 22.0142 6.47589 22.0142 11.9989C22.0142 17.5219 17.5372 21.9989 12.0142 21.9989C6.49136 21.9989 2.01416 17.5219 2.01416 11.9989ZM16.9853 7.31211C17.2125 7.09537 17.5236 7 17.8218 7C18.1201 7 18.4312 7.09537 18.6583 7.31211C19.1139 7.74546 19.1139 8.47384 18.6583 8.9072L10.5077 16.675C10.0534 17.1083 9.28909 17.1083 8.83472 16.675L5.34077 13.3459C4.88641 12.9126 4.88641 12.1841 5.34077 11.7508C5.79631 11.3175 6.56057 11.3175 7.01493 11.7508L9.67122 14.2822L16.9853 7.31211Z",fill:"white",fillOpacity:"1"})});var _e=e=>{let{leverage:t,entity:o,baseDp:a,quoteDp:n,referralInfo:r,shareOptions:l,hide:s}=e,[c,i]=p.useState(window.innerHeight<900?660:807);return p.useEffect(()=>{let u=()=>{i(window.innerHeight<900?660:807);};return window.addEventListener("resize",u),()=>{window.removeEventListener("resize",u);}},[]),l==null||o==null?jsxRuntime.jsx(jsxRuntime.Fragment,{}):jsxRuntime.jsx(Be,{entity:o,leverage:t,hide:s,baseDp:a,quoteDp:n,referral:r,shareOptions:l})},qe=e=>{let{leverage:t,entity:o,baseDp:a,quoteDp:n,referralInfo:r,shareOptions:l,hide:s}=e;return l==null||o==null?jsxRuntime.jsx(jsxRuntime.Fragment,{}):jsxRuntime.jsx(He,{entity:o,leverage:t,hide:s,baseDp:a,quoteDp:n,referral:r,shareOptions:l})};var ge=e=>{let t=G({hide:e.hide,pnl:e.pnl});return jsxRuntime.jsx(qe,{...t})},ye=e=>{let t=G({hide:e.hide,pnl:e.pnl});return jsxRuntime.jsx(_e,{...t})};var $t="sharePnLDialog",Vt="sharePnLBottomSheet";ui.registerSimpleDialog($t,ye,{classNames:{content:"!oui-max-w-[624px] oui-p-0"}});ui.registerSimpleSheet(Vt,ge,{title:"Share PnL",classNames:{body:"oui-pb-4 oui-pt-0"}});
|
|
34
34
|
|
|
35
35
|
exports.SharePnLBottomSheetId = Vt;
|
|
36
36
|
exports.SharePnLBottomSheetWidget = ge;
|