@liberfi.io/ui-channels 0.1.0 → 0.1.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/client/index.js +1 -1
- package/dist/client/index.js.map +1 -1
- package/dist/client/index.mjs +1 -1
- package/dist/client/index.mjs.map +1 -1
- package/dist/index.d.mts +56 -112
- package/dist/index.d.ts +56 -112
- package/dist/index.js +2 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -9
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import {useTranslation}from'@liberfi.io/i18n';import {z,usePinata,useForm,zodResolver,RHForm,RHInput,RHTextArea,RHUpload,Button,toast,StyledTabs,Tab,TelegramIcon,useCopyToClipboard,StyledInput,SearchIcon,StyledTable,TableHeader,TableColumn,TableBody,TableRow,TableCell,CopyIcon,TrashIcon,EmptyIcon,HorizontalScrollContainer,StyledTooltip,Chip,useScreen,clsx,WalletIcon,PeopleIcon,TimerIcon,Link,TwitterIcon,DiscordIcon,Avatar,StyledButton,EditIcon,CheckIcon,PlusIcon,Skeleton,
|
|
2
|
-
`).map(n=>n.trim()).filter(n=>!!n).map(n=>{let[s,o]=n.split(",");return {address:s?s.trim():void 0,alias:o?o.trim():void 0}})}function $e({wallets:e=[],onSubmit:t,isSubmitting:n}){let{t:s}=useTranslation(),o=useCopyToClipboard(),r=useAuthCallback(c=>{let u=e.filter(y=>y.value!==c.value).map(y=>({address:y.value??"",alias:y.alias}));t?.(u);},[e,t]),[a,i]=useState(""),h=debounce(i,200),m=useMemo(()=>e.filter(c=>c.alias?.toLowerCase()?.includes(a.toLowerCase())||c.value?.toLowerCase()?.includes(a.toLowerCase())),[a,e]);return jsxs("div",{className:"space-y-2",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("h2",{className:"text-sm font-medium",children:s("channels.forms.wallets.list.title")}),jsx(StyledInput,{size:"sm",className:"max-w-50",radius:"full",startContent:jsx(SearchIcon,{width:16,height:16,className:"text-neutral"}),placeholder:s("channels.forms.wallets.list.search.placeholder"),onValueChange:h})]}),jsxs(StyledTable,{isHeaderSticky:true,isVirtualized:m.length>10||m.length===0,radius:"lg",classNames:{emptyWrapper:"pt-10"},maxTableHeight:500,rowHeight:52,"aria-label":s("channels.forms.wallets.list.title"),children:[jsxs(TableHeader,{children:[jsx(TableColumn,{textValue:s("channels.forms.wallets.list.header.address"),width:"60%",children:s("channels.forms.wallets.list.header.address")},"address"),jsx(TableColumn,{textValue:s("channels.forms.wallets.list.header.actions"),width:"40%",align:"end",children:s("channels.forms.wallets.list.header.actions")},"actions")]}),jsx(TableBody,{items:m,emptyContent:jsxs("div",{className:"space-y-2",children:[jsx(EmptyIcon,{className:"w-10 h-10 mx-auto text-neutral"}),jsx("p",{className:"text-xs text-neutral text-center",children:s("channels.forms.wallets.list.empty")})]}),children:c=>jsxs(TableRow,{children:[jsx(TableCell,{children:jsxs("div",{className:"flex flex-col gap-1 text-xs",children:[jsx("div",{children:c.alias}),jsxs("div",{className:"text-neutral flex items-center gap-1",onClick:()=>o(c.value??""),"aria-label":s("common.copy"),children:[jsx("div",{children:shortAddress(c.value??"")}),jsx("div",{children:jsx(CopyIcon,{width:12,height:12})})]})]})},"address"),jsx(TableCell,{children:jsx(Button,{isIconOnly:true,size:"sm",radius:"full",className:"bg-transparent",disabled:n,onPress:()=>r(c),children:jsx(TrashIcon,{className:"text-danger-500",width:18,height:18})})},"actions")]},c.value)})]})]})}var Vo=z.object({walletsText:z.string({error:"channels.forms.wallets.required"}).min(1,"channels.forms.wallets.required")});function Ye({channel:e,wallets:t=[],onSubmit:n,isSubmitting:s=false}){let{t:o}=useTranslation(),r=useForm({mode:"onChange",reValidateMode:"onBlur",resolver:zodResolver(Vo),defaultValues:{walletsText:""}}),a=useMemo(()=>t.map(l=>({address:l.value??"",alias:l.alias})),[t]),{setError:i,reset:h}=r,m=useCallback(l=>{try{let u=Oe.parse(Ge(l)),y=u.length-uniqBy(u,"address").length;if(y!==0)throw new Error(o("channels.forms.wallets.address.duplicated",{count:y}));let Te=intersectionBy(u,a,"address").length;if(Te>0)throw new Error(o("channels.forms.wallets.address.alreadyAdded",{count:Te}));if(u.length+a.length>500)throw new Error(o("channels.forms.wallets.maxCount"));let me=0;for(let zt of u)isValidWalletAddress(e.chain,zt.address)||me++;if(me>0)throw new Error(o("channels.forms.wallets.address.invalid",{count:me}));return u}catch(u){u instanceof z.ZodError?i("walletsText",{message:u.issues[0].message,type:"manual"}):u instanceof Error?i("walletsText",{message:u.message,type:"manual"}):i("walletsText",{message:o("channels.forms.wallets.invalid"),type:"manual"});return}},[a,o,e.chain]),c=useCallback(async l=>{let u=m(l.walletsText);u&&u.length>0&&(await n?.([...a,...u]),h());},[m,n,a]);return jsxs("div",{className:"flex flex-col gap-6",children:[jsxs(RHForm,{methods:r,onSubmit:c,className:"relative",children:[jsx(RHTextArea,{name:"walletsText",label:o("channels.forms.wallets.label"),"aria-label":o("channels.forms.wallets.label"),placeholder:o("channels.forms.wallets.placeholder"),variant:"bordered",radius:"lg",size:"sm",fullWidth:true,minRows:10,maxRows:10,labelPlacement:"outside-top"}),jsxs("div",{className:"absolute right-0 top-0 text-xs flex gap-1 text-neutral",children:[jsxs("span",{className:"text-neutral",children:[o("channels.forms.wallets.addedCount"),":"]}),jsxs("span",{children:[a.length," / 500"]})]}),jsxs("div",{className:"w-full flex items-center gap-4",children:[jsx(HorizontalScrollContainer,{className:"flex-auto min-w-0",children:jsxs("div",{className:"flex items-center gap-2",children:[jsxs("span",{className:"text-xs text-neutral flex-none",children:[o("channels.forms.wallets.supportedFormats"),":"]}),jsx(StyledTooltip,{closeDelay:0,content:jsx("div",{className:"text-xs whitespace-pre-line",children:o("channels.forms.wallets.supportedFormats.text.hint")}),children:jsx(Chip,{size:"sm",variant:"flat",children:o("channels.forms.wallets.supportedFormats.text")})})]})}),jsx("div",{className:"flex-none flex gap-4 items-center",children:jsx(Button,{color:"primary",type:"submit",radius:"lg",isLoading:s,size:"sm",children:o("channels.forms.wallets.submit")})})]})]}),jsx($e,{wallets:t,onSubmit:n,isSubmitting:s})]})}function tt({channel:e,type:t="base",baseFormDefaultValues:n,isSubmittingBaseForm:s=false,onSubmitBaseForm:o,baseFormSubmitLabel:r,wallets:a,isSubmittingWalletsForm:i=false,onSubmitWalletsForm:h,className:m}){let{t:c}=useTranslation(),[l,u]=useState(t),{isMobile:y}=useScreen();return jsxs("div",{className:clsx("w-full flex flex-col gap-4",m),children:[jsxs(StyledTabs,{fullWidth:true,variant:"solid",size:y?"sm":void 0,selectedKey:l,onSelectionChange:u,children:[jsx(Tab,{title:c("channels.forms.base.title")},"base"),jsx(Tab,{title:c("channels.forms.wallets.title")},"wallets"),jsx(Tab,{title:c("channels.forms.socials.title")},"social")]}),l==="base"&&jsx($,{defaultValues:n,isSubmitting:s,onSubmit:o,submitLabel:r}),l==="wallets"&&jsx(Ye,{channel:e,wallets:a,isSubmitting:i,onSubmit:h}),l==="social"&&jsx(Ke,{channel:e})]})}function nt({type:e="base",className:t}){let{t:n}=useTranslation(),[s,o]=useState(e),{isMobile:r}=useScreen();return jsxs("div",{className:clsx("w-full flex flex-col gap-4",t),children:[jsxs(StyledTabs,{fullWidth:true,variant:"solid",size:r?"sm":void 0,selectedKey:s,onSelectionChange:o,children:[jsx(Tab,{title:n("channels.forms.base.title")},"base"),jsx(Tab,{title:n("channels.forms.wallets.title")},"wallets"),jsx(Tab,{title:n("channels.forms.socials.title")},"social")]}),s==="base"&&jsx(ge,{}),s==="wallets"&&jsx(ge,{}),s==="social"&&jsx(ge,{})]})}function ge(){return jsxs("div",{className:"flex flex-col gap-4",children:[jsx(Skeleton,{className:"w-full h-10 rounded-md"}),jsx(Skeleton,{className:"w-full h-10 rounded-md"}),jsx(Skeleton,{className:"w-full h-40 rounded-md"})]})}function st(e,t){let{t:n}=useTranslation(),{data:s,isLoading:o}=Be(e),{mutateAsync:r,isPending:a}=Qe(),i=useAuthCallback(async h=>{try{if(!t?.chain)throw new Error("Channel chain is not set");await r({channel_id:e,type:"wallet",sources:h.map(m=>({type:"wallet",value:m.address,alias:m.alias,configs:{chain:chainSlug(t.chain)}}))}),toast.success(n("channels.forms.wallets.update.success"));}catch{toast.error(n("channels.forms.wallets.update.error"));}},[r,e,t?.chain]);return {isLoading:o,isSubmitting:a,wallets:s,submit:i}}function bl({id:e,type:t="base"}){let{t:n}=useTranslation(),{channel:s,defaultValues:o,isLoading:r,isSubmitting:a,submit:i}=_e(e),{wallets:h,isLoading:m,isSubmitting:c,submit:l}=st(e,s);return r||m||!s?jsx(nt,{type:t}):jsx(tt,{channel:s,type:t,baseFormDefaultValues:o,isSubmittingBaseForm:a,onSubmitBaseForm:i,baseFormSubmitLabel:n("channels.forms.base.update.submit"),wallets:h,isSubmittingWalletsForm:c,onSubmitWalletsForm:l})}function Y({channel:e}){let{t}=useTranslation(),n=useTickAge(new Date(e.updated_at));return jsx(HorizontalScrollContainer,{classNames:{leftArrow:"from-content1/60 to-transparent",rightArrow:"from-content1/60 to-transparent"},children:jsxs("div",{className:"flex items-center gap-4",children:[jsx(StyledTooltip,{content:t("channels.info.walletCount"),closeDelay:0,children:jsxs("div",{className:"flex items-center gap-1",children:[jsx(WalletIcon,{width:16,height:16}),jsx("p",{className:"text-xs",children:e.source_count||"-"})]})}),jsx(StyledTooltip,{content:t("channels.info.subscribeCount"),closeDelay:0,children:jsxs("div",{className:"flex items-center gap-1",children:[jsx(PeopleIcon,{width:16,height:16}),jsx("p",{className:"text-xs",children:e.subscribe_count||"-"})]})}),jsx(StyledTooltip,{content:t("channels.info.updatedAt"),closeDelay:0,children:jsxs("div",{className:"flex items-center gap-1",children:[jsx(TimerIcon,{width:16,height:16}),jsx("p",{className:"text-xs",children:formatAge(n)})]})}),e.twitter&&jsx(Link,{href:e.twitter,target:"_blank",className:"text-neutral",children:jsx(TwitterIcon,{width:16,height:16})}),e.telegram&&jsx(Link,{href:e.telegram,target:"_blank",className:"text-neutral",children:jsx(TelegramIcon,{width:16,height:16})}),e.discord&&jsx(Link,{href:e.discord,target:"_blank",className:"text-neutral",children:jsx(DiscordIcon,{width:16,height:16})})]})})}function it({channel:e,customActions:t}){let n=useMemo(()=>e.chain?chainIcon(e.chain):void 0,[e.chain]);return jsxs("div",{className:"flex gap-4",children:[jsx("div",{className:"flex-none flex flex-col",children:jsxs("div",{className:"relative",children:[jsx(Avatar,{src:e.icon,alt:e.name,className:"w-18 h-18",radius:"md"}),n&&jsx(Avatar,{radius:"full",src:n,className:"w-5 h-5 absolute -bottom-1 -right-1 border border-border shadow-sm"})]})}),jsxs("div",{className:"flex-auto min-w-0 flex flex-col gap-2 text-neutral",children:[jsxs("div",{className:"h-6 flex items-center gap-2",children:[jsx("p",{className:"flex-auto min-w-0 text-sm font-medium text-foreground truncate",children:e.name}),jsx("div",{className:"flex-none",children:t})]}),jsx(Y,{channel:e}),jsx("p",{className:"text-xs whitespace-pre-wrap line-clamp-1 h-4 overflow-hidden",children:e.description})]})]})}function Hl({channel:e,onEdit:t}){let{user:n}=useAuth(),s=useAuthCallback(()=>{t?.(e);},[e,t]);return n?.id!==e.owner_id?jsx(Fragment,{}):jsx(StyledButton,{className:"bg-transparent",isIconOnly:true,size:"sm",onPress:s,children:jsx(EditIcon,{width:16,height:16,className:"text-neutral"})})}function ne({channel:e}){let{t}=useTranslation();return jsx(HorizontalScrollContainer,{classNames:{leftArrow:"from-content1/60 to-transparent",rightArrow:"from-content1/60 to-transparent"},children:jsxs("div",{className:"flex items-center gap-4 text-xs",children:[jsx(StyledTooltip,{content:t("channels.stats.7dTxs.hint"),closeDelay:0,children:jsxs("div",{className:"flex-none flex flex-col gap-1 items-center",children:[jsx("p",{className:"text-neutral font-medium",children:t("channels.stats.7dTxs.title")}),jsx("p",{className:"text-foreground font-semibold",children:"--"})]})}),jsx(StyledTooltip,{content:t("channels.stats.7dPnl.hint"),closeDelay:0,children:jsxs("div",{className:"flex-none flex flex-col gap-1 items-center",children:[jsx("p",{className:"text-neutral font-medium",children:t("channels.stats.7dPnl.title")}),jsx("p",{className:"text-bullish font-semibold",children:"--"})]})}),jsx(StyledTooltip,{content:t("channels.stats.7dWr.hint"),closeDelay:0,children:jsxs("div",{className:"flex-none flex flex-col gap-1 items-center",children:[jsx("p",{className:"text-neutral font-medium",children:t("channels.stats.7dWr.title")}),jsx("p",{className:"text-bullish font-semibold",children:"--%"})]})})]})})}function sm({channel:e,onSubscribeSuccess:t,onUnsubscribeSuccess:n,onSubscribeError:s,onUnsubscribeError:o}){let{t:r}=useTranslation(),[a,i]=useState(e.is_subscribed);useEffect(()=>{i(e.is_subscribed);},[e.is_subscribed]);let{mutateAsync:h,isPending:m}=De(),{mutateAsync:c,isPending:l}=Me(),u=useAuthCallback(async()=>{try{a?(await c(e.id),i(!1),toast.success(r("channels.unsubscribe.success")),n?.(e)):(await h(e.id),i(!0),toast.success(r("channels.subscribe.success")),t?.(e));}catch(y){a?(toast.error(r("channels.unsubscribe.error")),o?.(e,y)):(toast.error(r("channels.subscribe.error")),s?.(e,y));}},[r,a,e,h,c,t,n,s,o]);return jsx(StyledButton,{color:a?"default":"primary",size:"sm",radius:"lg",onPress:u,isLoading:m||l,variant:a?"bordered":"flat",className:clsx("gap-1",a&&"text-neutral"),startContent:a?!m&&!l?jsx(CheckIcon,{width:16,height:16}):void 0:!m&&!l?jsx(PlusIcon,{width:16,height:16}):void 0,children:r(a?"channels.unsubscribe.submit":"channels.subscribe.submit")})}function mt({channel:e,onSelect:t,headerActions:n,footerActions:s}){let o=useCallback(()=>{t?.(e);},[e,t]);return jsxs("div",{className:clsx("bg-content1 hover:bg-content2 border border-border rounded-lg w-full h-full p-2.5","flex flex-col gap-2.5",t&&"cursor-pointer"),onClick:o,children:[jsx(it,{channel:e,customActions:n}),jsxs("div",{className:"flex items-center gap-4",children:[jsx("div",{className:"flex-auto min-w-0",children:jsx(ne,{channel:e})}),jsx("div",{className:"flex-none",children:s})]})]})}function M({channels:e,onSelect:t,customHeaderActions:n,customFooterActions:s}){return jsx("div",{className:"w-full grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:e.map(o=>jsx(mt,{channel:o,onSelect:t,headerActions:n?.(o),footerActions:s?.(o)},o.id))})}function Q({count:e}){return jsx("div",{className:"w-full grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Array.from({length:e}).map((t,n)=>jsxs("div",{className:"bg-content1 hover:bg-content2 border border-border rounded-lg w-full h-35 p-2.5 flex flex-col gap-2.5",children:[jsxs("div",{className:"flex gap-4",children:[jsx("div",{className:"flex-none flex flex-col",children:jsx(Skeleton,{className:"w-18 h-18 flex-none rounded-md"})}),jsxs("div",{className:"flex-auto min-w-0 flex flex-col gap-2 justify-center text-neutral",children:[jsx(Skeleton,{className:"w-24 h-4 rounded-md"}),jsx(Skeleton,{className:"w-48 h-4 rounded-md"}),jsx(Skeleton,{className:"w-48 h-4 rounded-md"})]})]}),jsxs("div",{className:"w-full flex justify-between gap-4",children:[jsx(Skeleton,{className:"flex-auto min-w-0 h-6 rounded-md"}),jsx(Skeleton,{className:"w-24 h-6 rounded-md"})]})]},n))})}function V({message:e}){let{t}=useTranslation();return jsxs("div",{className:"pt-24 mx-auto",children:[jsx(EmptyIcon,{width:28,height:28,className:"text-neutral mx-auto"}),jsx("p",{className:"pt-2 text-sm text-neutral text-center",children:e||t("common.empty")})]})}var pt=()=>{let{status:e}=useAuth(),t=Ae(),{refetch:n}=t;return useEffect(()=>{e==="authenticated"&&n();},[e,n]),t};function ut({onSelect:e,customHeaderActions:t,customFooterActions:n}){let{data:s,isLoading:o}=pt();return o?jsx(Q,{count:9}):!s||s.list.length===0?jsx(V,{}):jsx(M,{channels:s.list,onSelect:e,customHeaderActions:t,customFooterActions:n})}function re({message:e}){let{t}=useTranslation(),{signIn:n}=useAuth();return jsxs("div",{className:"pt-24 flex flex-col items-center justify-center gap-2",children:[jsx("p",{className:"text-neutral text-sm",children:e||t("common.unauthenticated")}),jsx(StyledButton,{color:"primary",size:"sm",onPress:n,radius:"lg",children:t("common.signIn")})]})}function ft({onSelect:e,customHeaderActions:t,customFooterActions:n}){let{status:s}=useAuth(),{data:o,isLoading:r}=j({},{enabled:s==="authenticated"});return s==="unauthenticated"?jsx(re,{}):s==="authenticating"||r?jsx(Q,{count:9}):!o||o.list.length===0?jsx(V,{}):jsx(M,{channels:o.list,onSelect:e,customHeaderActions:t,customFooterActions:n})}var Ym=()=>j();function gt({onSelect:e,customHeaderActions:t,customFooterActions:n}){let{status:s}=useAuth(),{data:o,isLoading:r}=G({},{enabled:s==="authenticated"});return s==="unauthenticated"?jsx(re,{}):s==="authenticating"||r?jsx(Q,{count:9}):!o||o.list.length===0?jsx(V,{}):jsx(M,{channels:o.list,onSelect:e,customHeaderActions:t,customFooterActions:n})}var cc=()=>G();function yt({channel:e,headerActions:t,footerActions:n}){let s=useMemo(()=>e.chain?chainIcon(e.chain):void 0,[e.chain]);return jsxs("div",{className:clsx("bg-content1 border border-border rounded-lg w-full h-full p-2.5","flex flex-col gap-2.5"),children:[jsxs("div",{className:"flex gap-4",children:[jsx("div",{className:"flex-none flex flex-col",children:jsxs("div",{className:"relative",children:[jsx(Avatar,{src:e.icon,alt:e.name,className:"w-18 h-18",radius:"md"}),s&&jsx(Avatar,{radius:"full",src:s,className:"w-5 h-5 absolute -bottom-1 -right-1 border border-border shadow-sm"})]})}),jsxs("div",{className:"flex-auto min-w-0 flex flex-col gap-2 text-neutral",children:[jsxs("div",{className:"h-6 flex items-center gap-2",children:[jsx("p",{className:"flex-auto min-w-0 text-sm font-medium text-foreground truncate",children:e.name}),jsx("div",{className:"flex-none",children:t})]}),jsx(Y,{channel:e})]})]}),jsxs("div",{className:"flex gap-4",children:[jsx("div",{className:"flex-auto min-w-0",children:jsx(ne,{channel:e})}),jsx("div",{className:"flex-none",children:n})]}),e.description&&jsx("p",{className:"text-xs whitespace-pre-wrap",children:e.description})]})}function Pe(){let{t:e}=useTranslation();return jsxs("div",{className:"w-ful bg-content1 border border-border rounded-lg p-2.5",children:[jsx(EmptyIcon,{width:28,height:28,className:"text-neutral mx-auto mt-20"}),jsx("p",{className:"pt-2 text-sm text-neutral text-center mb-20",children:e("common.empty")})]})}function wt(){let{t:e}=useTranslation();return jsxs("div",{className:"w-full",children:[jsx(EmptyIcon,{width:40,height:40,className:"mt-10 text-neutral mx-auto"}),jsx("p",{className:"text-sm text-neutral text-center mt-2",children:e("channels.detail.notfound")})]})}function Pt(){return jsxs("div",{className:"w-full space-y-6",children:[jsx(Skeleton,{className:"w-full h-35 rounded-md"}),jsx(Skeleton,{className:"w-full h-40 rounded-md"})]})}var It=e=>K(e);function Nt({id:e,customHeaderActions:t,customFooterActions:n}){let{t:s}=useTranslation(),{data:o,isLoading:r}=It(e);return r?jsx(Pt,{}):o?jsxs("div",{className:"space-y-6",children:[jsx(yt,{channel:o,headerActions:t?.(o),footerActions:n?.(o)}),jsxs("div",{className:"space-y-2.5",children:[jsx("h2",{className:"text-sm font-semibold",children:s("channels.detail.events.title")}),jsx(Pe,{})]})]}):jsx(wt,{})}function hd({onCreateChannel:e,onSelectChannel:t,customHeaderActions:n,customFooterActions:s}){let{t:o}=useTranslation(),{isMobile:r}=useScreen(),[a,i]=useState("trending");return jsxs("div",{className:"w-full max-w-7xl mx-auto py-2 px-2 sm:py-4 sm:px-4",children:[jsxs("div",{className:"flex items-center justify-between gap-2 w-full overflow-x-auto",children:[jsx(HorizontalScrollContainer,{className:"flex-auto min-w-0",children:jsxs(StyledTabs,{variant:"primaryPlain",radius:"lg",selectedKey:a,onSelectionChange:i,"aria-label":o("channels.list.title"),size:r?"sm":void 0,children:[jsx(Tab,{title:o("channels.trending.title"),"aria-label":o("channels.trending.title")},"trending"),jsx(Tab,{title:o("channels.my.title"),"aria-label":o("channels.my.title")},"my"),jsx(Tab,{title:o("channels.subscribed.title"),"aria-label":o("channels.subscribed.title")},"subscribed")]})}),jsx("div",{className:"flex-none flex items-center gap-2",children:e&&jsxs(Fragment,{children:[jsx(Button,{radius:"lg",color:"primary",size:"sm",onPress:e,className:"max-sm:hidden gap-1",startContent:jsx(PlusIcon,{width:18,height:18}),"aria-label":o("channels.create.title"),children:o("channels.create.title")}),jsx(Button,{isIconOnly:true,radius:"full",color:"primary",size:"sm",onPress:e,className:"sm:hidden w-7 min-w-7 h-7 min-h-7","aria-label":o("channels.create.title"),children:jsx(PlusIcon,{width:18,height:18})})]})})]}),jsxs("div",{className:"mt-4 w-full",children:[a==="trending"&&jsx(ut,{onSelect:t,customHeaderActions:n,customFooterActions:s}),a==="my"&&jsx(gt,{onSelect:t,customHeaderActions:n,customFooterActions:s}),a==="subscribed"&&jsx(ft,{onSelect:t,customHeaderActions:n,customFooterActions:s})]})]})}function bd({id:e,customHeaderActions:t,customFooterActions:n}){let{t:s}=useTranslation();return jsxs("div",{className:"w-full max-w-2xl mx-auto py-2 px-2 sm:py-4 sm:px-4 space-y-2 sm:space-y-4",children:[jsx("h1",{className:"text-sm sm:text-lg font-semibold",children:s("channels.detail.title")}),jsx(Nt,{id:e,customFooterActions:n,customHeaderActions:t})]})}function ke(e){return jsx("svg",{width:"8",height:"16",viewBox:"0 0 5 9",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:jsx("path",{d:"M5 5.72727L2.5 9L0 5.72727H5ZM2.5 0L5 3.27273H0L2.5 0Z",fill:"currentColor"})})}function Lt(e){return jsx("svg",{width:"24",height:"24",viewBox:"0 0 12 12",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e,children:jsx("path",{d:"M6 0C2.6856 0 0 2.68698 0 6C0 9.3144 2.68698 12 6 12C9.3144 12 12 9.31302 12 6C12.0014 2.68698 9.3144 0 6 0ZM8.53878 6.2036L5.21191 8.88089C5.04155 9.01801 4.78947 8.89612 4.78947 8.67867V3.32271C4.78947 3.10526 5.04155 2.98338 5.21191 3.1205L8.53878 5.79917C8.66897 5.90305 8.66897 6.09972 8.53878 6.2036Z",fill:"currentColor"})})}function Mt({onFilterChange:e}){let[t,n]=useState("newest"),[s,o]=useState("1D"),[r,a]=useState("buy"),[i,h]=useState(""),[m,c]=useState("P1");return useEffect(()=>{e?.({sort:t,timeRange:s,tradeType:r,search:i,plan:m});},[t,s,r,i,m,e]),jsxs("div",{className:"flex items-center justify-between w-full",children:[jsxs("div",{className:"flex items-center gap-3",children:[jsxs(Button,{variant:"bordered",className:"flex items-center gap-1",onPress:()=>n("newest"),children:[jsx(ke,{className:"w-4 h-4"}),jsx("p",{className:"text-sm font-medium",children:"Newest"})]}),jsxs(Button,{variant:"bordered",className:"flex items-center gap-1",onPress:()=>n("amount"),children:[jsx(ke,{className:"w-4 h-4"}),jsx("p",{className:"text-sm font-medium",children:"Amount"})]}),jsxs(Tabs,{variant:"solid",size:"sm",selectedKey:s,onSelectionChange:l=>o(l),children:[jsx(Tab,{title:"1D"},"1D"),jsx(Tab,{title:"7D"},"7D"),jsx(Tab,{title:"30D"},"30D")]}),jsxs(ButtonGroup,{size:"sm",children:[jsx(Button,{variant:"flat",onPress:()=>a("buy"),children:jsx("span",{className:"text-primary font-semibold",children:"Buy"})}),jsx(Button,{variant:"flat",onPress:()=>a("sell"),children:jsx("span",{className:"text-danger font-semibold",children:"Sell"})})]})]}),jsx(Input,{placeholder:"Token symbol or address\u2026",variant:"faded",className:"max-w-80",value:i,onChange:l=>h(l.target.value)}),jsxs("div",{className:"flex items-center gap-3",children:[jsxs(Button,{size:"sm",variant:"light",className:"flex items-center gap-1",children:[jsx(Lt,{className:"w-4 h-4"}),jsx("p",{className:"text-sm font-medium",children:"Listen"})]}),jsxs(Tabs,{variant:"bordered",size:"sm",selectedKey:m,onSelectionChange:l=>c(l),color:"primary",children:[jsx(Tab,{title:"P1"},"P1"),jsx(Tab,{title:"P2"},"P2"),jsx(Tab,{title:"P3"},"P3")]})]})]})}function Qt({trading:e,onBuy:t}){return jsxs(Table,{classNames:{wrapper:"bg-transparent p-0"},className:"text-default-800",children:[jsxs(TableHeader,{children:[jsx(TableColumn,{children:"Date"},"date"),jsx(TableColumn,{children:"Channel"},"channel"),jsx(TableColumn,{children:"Address"},"address"),jsx(TableColumn,{children:"Token"},"token"),jsx(TableColumn,{children:"$ MC"},"mc"),jsxs(TableColumn,{children:["Amount ",jsx("span",{className:"text-primary",children:"$"})]},"amount"),jsx(TableColumn,{children:"Actions"},"actions")]}),jsx(TableBody,{items:e,isLoading:false,children:n=>jsxs(TableRow,{children:[jsx(TableCell,{children:formatAge(Date.now()-n.date)}),jsx(TableCell,{children:jsxs("div",{className:"flex items-center gap-2",children:[jsx(Image,{radius:"md",src:n.channel.imageUrl,alt:n.channel.name,width:20,height:20}),n.channel.name]})}),jsx(TableCell,{children:jsx("p",{className:clsx(n.type==="buy"?"text-primary":"text-secondary"),children:shortAddress(n.address)})}),jsx(TableCell,{children:jsxs("div",{className:"flex items-center gap-1",children:[jsx(Image,{radius:"md",src:n.token.image,alt:n.token.symbol,width:16,height:16})," ",jsxs("div",{className:"flex items-end gap-0.5",children:[jsx("p",{children:n.token.symbol}),jsx("p",{className:"text-xs text-default-500",children:shortAddress(n.token.address)})]})]})}),jsx(TableCell,{children:formatAmountUSD2(n.mc)}),jsx(TableCell,{children:jsxs("div",{className:"flex gap-1 items-center",children:[jsx(Image,{src:n.token.chainIcon,alt:n.token.symbol,width:16,height:16}),jsx("p",{className:clsx(n.type==="buy"?"text-primary":"text-secondary"),children:formatAmount(n.amount)})]})}),jsx(TableCell,{children:jsxs(Button,{radius:"full",className:clsx("text-white bg-[#B1FF3770]"),size:"sm",onPress:()=>t(n),children:["Buy 0.002 ",n.token.symbol]})})]},n.id)})]})}function qt({trading:e,onBuy:t}){return jsxs("div",{className:"flex flex-col gap-3",children:[jsx(Mt,{}),jsx(Qt,{trading:e,onBuy:t})]})}var Zt=[{id:"1",date:Date.now()-32*1e3,type:"buy",channel:{id:"1",imageUrl:"https://pbs.twimg.com/profile_images/1821642506800353280/xIpx4wIO_normal.jpg",name:"Zoro - Channel 1",description:"Sol-Daily Update-Golden Dog Smart Money",createdAt:"8h",people:1109,volume:94,followers:105,createdBy:"Zoro",timeAgo:300,socials:{telegram:"https://t.me/Zoro",discord:"https://discord.com/Zoro"},dex:{fromToken:{name:"BNB",image:"https://assets.coingecko.com/coins/images/825/standard/bnb-icon2_2x.png?1696501970"},toToken:{name:"SOL",image:"https://assets.coingecko.com/coins/images/4128/standard/solana.png?1718769756"},txs7d:{total:140,bullish:70,bearish:70},pnl7d:{total:21876},wr7d:{total:60.9}}},address:"BwqpHv4s2wZoxf1ktVjFSfz8LkX4Wyjrf7QGrbPSDMqe",token:{symbol:"PINK",image:"https://s1.chainstream.io/tokens/images/4ab7c44fa49cc29bda25878622e5c3f1.webp",address:"BwqpHv4s2wZoxf1ktVjFSfz8LkX4Wyjrf7QGrbPSDMqe",chainIcon:"https://assets.coingecko.com/coins/images/4128/standard/solana.png?1718769756"},mc:26900,amount:1.3579},{id:"2",date:Date.now()-60*1e3,type:"sell",channel:{id:"1",imageUrl:"https://pbs.twimg.com/profile_images/1821642506800353280/xIpx4wIO_normal.jpg",name:"Zoro - Channel 1",description:"Sol-Daily Update-Golden Dog Smart Money",createdAt:"8h",people:1109,volume:94,followers:105,createdBy:"Zoro",timeAgo:300,socials:{telegram:"https://t.me/Zoro",discord:"https://discord.com/Zoro"},dex:{fromToken:{name:"BNB",image:"https://assets.coingecko.com/coins/images/825/standard/bnb-icon2_2x.png?1696501970"},toToken:{name:"SOL",image:"https://assets.coingecko.com/coins/images/4128/standard/solana.png?1718769756"},txs7d:{total:140,bullish:70,bearish:70},pnl7d:{total:21876},wr7d:{total:60.9}}},address:"BwqpHv4s2wZoxf1ktVjFSfz8LkX4Wyjrf7QGrbPSDMqe",token:{symbol:"PINK",image:"https://s1.chainstream.io/tokens/images/4ab7c44fa49cc29bda25878622e5c3f1.webp",address:"BwqpHv4s2wZoxf1ktVjFSfz8LkX4Wyjrf7QGrbPSDMqe",chainIcon:"https://assets.coingecko.com/coins/images/4128/standard/solana.png?1718769756"},mc:26900,amount:1.3579},{id:"3",date:Date.now()-780*1e3,type:"buy",channel:{id:"1",imageUrl:"https://pbs.twimg.com/profile_images/1821642506800353280/xIpx4wIO_normal.jpg",name:"Zoro - Channel 1",description:"Sol-Daily Update-Golden Dog Smart Money",createdAt:"8h",people:1109,volume:94,followers:105,createdBy:"Zoro",timeAgo:300,socials:{telegram:"https://t.me/Zoro",discord:"https://discord.com/Zoro"},dex:{fromToken:{name:"BNB",image:"https://assets.coingecko.com/coins/images/825/standard/bnb-icon2_2x.png?1696501970"},toToken:{name:"SOL",image:"https://assets.coingecko.com/coins/images/4128/standard/solana.png?1718769756"},txs7d:{total:140,bullish:70,bearish:70},pnl7d:{total:21876},wr7d:{total:60.9}}},address:"BwqpHv4s2wZoxf1ktVjFSfz8LkX4Wyjrf7QGrbPSDMqe",token:{symbol:"PINK",image:"https://s1.chainstream.io/tokens/images/4ab7c44fa49cc29bda25878622e5c3f1.webp",address:"BwqpHv4s2wZoxf1ktVjFSfz8LkX4Wyjrf7QGrbPSDMqe",chainIcon:"https://assets.coingecko.com/coins/images/4128/standard/solana.png?1718769756"},mc:26900,amount:1.3579},{id:"4",date:Date.now()-3600*1e3,type:"sell",channel:{id:"1",imageUrl:"https://pbs.twimg.com/profile_images/1821642506800353280/xIpx4wIO_normal.jpg",name:"Zoro - Channel 1",description:"Sol-Daily Update-Golden Dog Smart Money",createdAt:"8h",people:1109,volume:94,followers:105,createdBy:"Zoro",timeAgo:300,socials:{telegram:"https://t.me/Zoro",discord:"https://discord.com/Zoro"},dex:{fromToken:{name:"BNB",image:"https://assets.coingecko.com/coins/images/825/standard/bnb-icon2_2x.png?1696501970"},toToken:{name:"SOL",image:"https://assets.coingecko.com/coins/images/4128/standard/solana.png?1718769756"},txs7d:{total:140,bullish:70,bearish:70},pnl7d:{total:21876},wr7d:{total:60.9}}},address:"BwqpHv4s2wZoxf1ktVjFSfz8LkX4Wyjrf7QGrbPSDMqe",token:{symbol:"PINK",image:"https://s1.chainstream.io/tokens/images/4ab7c44fa49cc29bda25878622e5c3f1.webp",address:"BwqpHv4s2wZoxf1ktVjFSfz8LkX4Wyjrf7QGrbPSDMqe",chainIcon:"https://assets.coingecko.com/coins/images/4128/standard/solana.png?1718769756"},mc:26900,amount:1.3579},{id:"5",date:Date.now()-1.5*60*60*1e3,type:"buy",channel:{id:"1",imageUrl:"https://pbs.twimg.com/profile_images/1821642506800353280/xIpx4wIO_normal.jpg",name:"Zoro - Channel 1",description:"Sol-Daily Update-Golden Dog Smart Money",createdAt:"8h",people:1109,volume:94,followers:105,createdBy:"Zoro",timeAgo:300,socials:{telegram:"https://t.me/Zoro",discord:"https://discord.com/Zoro"},dex:{fromToken:{name:"BNB",image:"https://assets.coingecko.com/coins/images/825/standard/bnb-icon2_2x.png?1696501970"},toToken:{name:"SOL",image:"https://assets.coingecko.com/coins/images/4128/standard/solana.png?1718769756"},txs7d:{total:140,bullish:70,bearish:70},pnl7d:{total:21876},wr7d:{total:60.9}}},address:"BwqpHv4s2wZoxf1ktVjFSfz8LkX4Wyjrf7QGrbPSDMqe",token:{symbol:"PINK",image:"https://s1.chainstream.io/tokens/images/4ab7c44fa49cc29bda25878622e5c3f1.webp",address:"BwqpHv4s2wZoxf1ktVjFSfz8LkX4Wyjrf7QGrbPSDMqe",chainIcon:"https://assets.coingecko.com/coins/images/4128/standard/solana.png?1718769756"},mc:26900,amount:1.3579},{id:"6",date:Date.now()-10800*1e3,type:"sell",channel:{id:"1",imageUrl:"https://pbs.twimg.com/profile_images/1821642506800353280/xIpx4wIO_normal.jpg",name:"Zoro - Channel 1",description:"Sol-Daily Update-Golden Dog Smart Money",createdAt:"8h",people:1109,volume:94,followers:105,createdBy:"Zoro",timeAgo:300,socials:{telegram:"https://t.me/Zoro",discord:"https://discord.com/Zoro"},dex:{fromToken:{name:"BNB",image:"https://assets.coingecko.com/coins/images/825/standard/bnb-icon2_2x.png?1696501970"},toToken:{name:"SOL",image:"https://assets.coingecko.com/coins/images/4128/standard/solana.png?1718769756"},txs7d:{total:140,bullish:70,bearish:70},pnl7d:{total:21876},wr7d:{total:60.9}}},address:"BwqpHv4s2wZoxf1ktVjFSfz8LkX4Wyjrf7QGrbPSDMqe",token:{symbol:"PINK",image:"https://s1.chainstream.io/tokens/images/4ab7c44fa49cc29bda25878622e5c3f1.webp",address:"BwqpHv4s2wZoxf1ktVjFSfz8LkX4Wyjrf7QGrbPSDMqe",chainIcon:"https://assets.coingecko.com/coins/images/4128/standard/solana.png?1718769756"},mc:26900,amount:1.3579},{id:"7",date:Date.now()-720*60*1e3,type:"buy",channel:{id:"1",imageUrl:"https://pbs.twimg.com/profile_images/1821642506800353280/xIpx4wIO_normal.jpg",name:"Zoro - Channel 1",description:"Sol-Daily Update-Golden Dog Smart Money",createdAt:"8h",people:1109,volume:94,followers:105,createdBy:"Zoro",timeAgo:300,socials:{telegram:"https://t.me/Zoro",discord:"https://discord.com/Zoro"},dex:{fromToken:{name:"BNB",image:"https://assets.coingecko.com/coins/images/825/standard/bnb-icon2_2x.png?1696501970"},toToken:{name:"SOL",image:"https://assets.coingecko.com/coins/images/4128/standard/solana.png?1718769756"},txs7d:{total:140,bullish:70,bearish:70},pnl7d:{total:21876},wr7d:{total:60.9}}},address:"BwqpHv4s2wZoxf1ktVjFSfz8LkX4Wyjrf7QGrbPSDMqe",token:{symbol:"PINK",image:"https://s1.chainstream.io/tokens/images/4ab7c44fa49cc29bda25878622e5c3f1.webp",address:"BwqpHv4s2wZoxf1ktVjFSfz8LkX4Wyjrf7QGrbPSDMqe",chainIcon:"https://assets.coingecko.com/coins/images/4128/standard/solana.png?1718769756"},mc:26900,amount:1.3579},{id:"8",date:Date.now()-1440*60*1e3,type:"sell",channel:{id:"1",imageUrl:"https://pbs.twimg.com/profile_images/1821642506800353280/xIpx4wIO_normal.jpg",name:"Zoro - Channel 1",description:"Sol-Daily Update-Golden Dog Smart Money",createdAt:"8h",people:1109,volume:94,followers:105,createdBy:"Zoro",timeAgo:300,socials:{telegram:"https://t.me/Zoro",discord:"https://discord.com/Zoro"},dex:{fromToken:{name:"BNB",image:"https://assets.coingecko.com/coins/images/825/standard/bnb-icon2_2x.png?1696501970"},toToken:{name:"SOL",image:"https://assets.coingecko.com/coins/images/4128/standard/solana.png?1718769756"},txs7d:{total:140,bullish:70,bearish:70},pnl7d:{total:21876},wr7d:{total:60.9}}},address:"BwqpHv4s2wZoxf1ktVjFSfz8LkX4Wyjrf7QGrbPSDMqe",token:{symbol:"PINK",image:"https://s1.chainstream.io/tokens/images/4ab7c44fa49cc29bda25878622e5c3f1.webp",address:"BwqpHv4s2wZoxf1ktVjFSfz8LkX4Wyjrf7QGrbPSDMqe",chainIcon:"https://assets.coingecko.com/coins/images/4128/standard/solana.png?1718769756"},mc:26900,amount:1.3579},{id:"9",date:Date.now()-7200*60*1e3,type:"buy",channel:{id:"1",imageUrl:"https://pbs.twimg.com/profile_images/1821642506800353280/xIpx4wIO_normal.jpg",name:"Zoro - Channel 1",description:"Sol-Daily Update-Golden Dog Smart Money",createdAt:"8h",people:1109,volume:94,followers:105,createdBy:"Zoro",timeAgo:300,socials:{telegram:"https://t.me/Zoro",discord:"https://discord.com/Zoro"},dex:{fromToken:{name:"BNB",image:"https://assets.coingecko.com/coins/images/825/standard/bnb-icon2_2x.png?1696501970"},toToken:{name:"SOL",image:"https://assets.coingecko.com/coins/images/4128/standard/solana.png?1718769756"},txs7d:{total:140,bullish:70,bearish:70},pnl7d:{total:21876},wr7d:{total:60.9}}},address:"BwqpHv4s2wZoxf1ktVjFSfz8LkX4Wyjrf7QGrbPSDMqe",token:{symbol:"PINK",image:"https://s1.chainstream.io/tokens/images/4ab7c44fa49cc29bda25878622e5c3f1.webp",address:"BwqpHv4s2wZoxf1ktVjFSfz8LkX4Wyjrf7QGrbPSDMqe",chainIcon:"https://assets.coingecko.com/coins/images/4128/standard/solana.png?1718769756"},mc:26900,amount:1.3579},{id:"10",date:Date.now()-14400*60*1e3,type:"sell",channel:{id:"1",imageUrl:"https://pbs.twimg.com/profile_images/1821642506800353280/xIpx4wIO_normal.jpg",name:"Zoro - Channel 1",description:"Sol-Daily Update-Golden Dog Smart Money",createdAt:"8h",people:1109,volume:94,followers:105,createdBy:"Zoro",timeAgo:300,socials:{telegram:"https://t.me/Zoro",discord:"https://discord.com/Zoro"},dex:{fromToken:{name:"BNB",image:"https://assets.coingecko.com/coins/images/825/standard/bnb-icon2_2x.png?1696501970"},toToken:{name:"SOL",image:"https://assets.coingecko.com/coins/images/4128/standard/solana.png?1718769756"},txs7d:{total:140,bullish:70,bearish:70},pnl7d:{total:21876},wr7d:{total:60.9}}},address:"BwqpHv4s2wZoxf1ktVjFSfz8LkX4Wyjrf7QGrbPSDMqe",token:{symbol:"PINK",image:"https://s1.chainstream.io/tokens/images/4ab7c44fa49cc29bda25878622e5c3f1.webp",address:"BwqpHv4s2wZoxf1ktVjFSfz8LkX4Wyjrf7QGrbPSDMqe",chainIcon:"https://assets.coingecko.com/coins/images/4128/standard/solana.png?1718769756"},mc:26900,amount:1.3579}],Ot=[32*1e3,60*1e3,780*1e3,3600*1e3,1.5*60*60*1e3,10800*1e3,720*60*1e3,1440*60*1e3,7200*60*1e3,14400*60*1e3],Et=["buy","sell"];for(let e=11;e<=20;e++)Zt.push({id:`${e}`,date:Date.now()-Ot[(e-1)%Ot.length],type:Et[(e-1)%Et.length],channel:{id:"1",imageUrl:"https://pbs.twimg.com/profile_images/1821642506800353280/xIpx4wIO_normal.jpg",name:"Zoro - Channel 1",description:"Sol-Daily Update-Golden Dog Smart Money",createdAt:"8h",people:1109,volume:94,followers:105,createdBy:"Zoro",timeAgo:300,socials:{telegram:"https://t.me/Zoro",discord:"https://discord.com/Zoro"},dex:{fromToken:{name:"BNB",image:"https://assets.coingecko.com/coins/images/825/standard/bnb-icon2_2x.png?1696501970"},toToken:{name:"SOL",image:"https://assets.coingecko.com/coins/images/4128/standard/solana.png?1718769756"},txs7d:{total:140,bullish:70,bearish:70},pnl7d:{total:21876},wr7d:{total:60.9}}},address:"BwqpHv4s2wZoxf1ktVjFSfz8LkX4Wyjrf7QGrbPSDMqe",token:{symbol:"PINK",image:"https://s1.chainstream.io/tokens/images/4ab7c44fa49cc29bda25878622e5c3f1.webp",address:"BwqpHv4s2wZoxf1ktVjFSfz8LkX4Wyjrf7QGrbPSDMqe",chainIcon:"https://assets.coingecko.com/coins/images/4128/standard/solana.png?1718769756"},mc:26900,amount:1.3579});var _t=()=>Zt;function Hd(){let e=_t();return jsx(qt,{trading:e,onBuy:n=>{}})}function lp({client:e,children:t}){return jsx(H.Provider,{value:{client:e},children:t})}
|
|
3
|
-
export{$ as BaseFormUI,Y as ChannelAttributes,it as ChannelBaseInfo,yt as ChannelDetailUI,Nt as ChannelDetailWidget,Hl as ChannelEditButton,ne as ChannelStats,sm as ChannelSubscribeButton,H as ChannelsContext,bd as ChannelsDetailPage,V as ChannelsEmptyUI,hd as ChannelsHomePage,lp as ChannelsProvider,Q as ChannelsSkeletonUI,M as ChannelsUI,li as CreateChannelWidget,gt as MyChannelsWidget,Ke as SocialsFormUI,ft as SubscribedChannelsWidget,qt as TradingUI,Hd as TradingWidget,ut as TrendingChannelsWidget,tt as UpdateChannelFormUI,bl as UpdateChannelWidget,Ye as WalletsFormUI,$e as WalletsListUI,jt as channelEventsQueryKey,F as channelQueryKey,ce as channelSourcesQueryKey,nn as channelsListQueryKey,mn as createChannel,Yt as fetchChannel,Xt as fetchChannelEvents,an as fetchChannelSources,on as fetchChannelsList,un as fetchMyChannelsList,xn as fetchSubscribedChannelsList,pn as myChannelsListQueryKey,Ge as parseWalletsText,gn as subscribeChannel,bn as subscribedChannelsListQueryKey,Sn as unsubscribeChannel,Nn as updateChannel,Fn as updateChannelSources,It as useChannelDetail,$t as useChannelEventsQuery,K as useChannelQuery,Be as useChannelSourcesQuery,d as useChannelsClient,Fe as useChannelsContext,Ae as useChannelsListQuery,Le as useCreateChannelMutation,cc as useMyChannels,G as useMyChannelsListQuery,De as useSubscribeChannelMutation,Ym as useSubscribedChannels,j as useSubscribedChannelsListQuery,_t as useTrading,pt as useTrendingChannels,Me as useUnsubscribeChannelMutation,_e as useUpdateBaseForm,We as useUpdateChannelMutation,Qe as useUpdateChannelSourcesMutation,st as useUpdateWalletsForm,Ve as useUpload,Rt as version};//# sourceMappingURL=index.mjs.map
|
|
1
|
+
import {useTranslation}from'@liberfi.io/i18n';import {z as z$1,usePinata,useForm,zodResolver,RHForm,RHInput,RHTextArea,RHUpload,Button,toast,StyledTabs,Tab,TelegramIcon,useCopyToClipboard,StyledInput,SearchIcon,StyledTable,TableHeader,TableColumn,TableBody,TableRow,TableCell,CopyIcon,TrashIcon,EmptyIcon,HorizontalScrollContainer,StyledTooltip,Chip,useScreen,clsx,WalletIcon,PeopleIcon,TimerIcon,Link,TwitterIcon,DiscordIcon,Avatar,StyledButton,EditIcon,CheckIcon,PlusIcon,Skeleton,useInfiniteLoader,List}from'@liberfi.io/ui';import {useQuery,useInfiniteQuery,useMutation,useQueryClient}from'@tanstack/react-query';import {createContext,useContext,useCallback,useMemo,useState,useEffect,useRef}from'react';import {chainSlug,debounce,shortAddress,uniqBy,intersectionBy,isValidWalletAddress,formatAge,chainIcon,mapValues,keyBy,COMMON_TOKEN_ADDRESSES,COMMON_TOKEN_SYMBOLS_MAP,formatAmount,SafeBigNumber,formatPriceUSD}from'@liberfi.io/utils';import {useDexClient,fetchPresignedUploadUrl,fetchTokens}from'@liberfi.io/client';import {jsxs,jsx,Fragment}from'react/jsx-runtime';import {Chain}from'@liberfi.io/types';import {useAuthCallback,useAuth}from'@liberfi.io/wallet-connector';import {useTickAge,useResizeObserver}from'@liberfi.io/hooks';typeof window<"u"&&(window.__LIBERFI_VERSION__=window.__LIBERFI_VERSION__||{},window.__LIBERFI_VERSION__["@liberfi.io/ui-channels"]="0.1.0");var Bt="0.1.0";var q=createContext({});function Ie(){let e=useContext(q);if(!e)throw new Error("useChannelsContext must be used within a ChannelsProvider");return e}function p(){let{client:e}=Ie();return e}function Kt(e,t){return ["channelEvents",e,t.limit?`${t.limit}`:"",t.timestamp?`${t.timestamp}`:"",t.next_page?`${t.next_page}`:""]}async function ie(e,t,n){return await e.getChannelEvents(t,n)}function Ue(e,t={},n={}){let a=p();return useQuery({queryKey:Kt(e,t),queryFn:async()=>ie(a,e,t),...n})}function Dt(e){return ["channelEvents","infinite",e]}function Ae(e,t={},n={}){let a=p();return useInfiniteQuery({queryKey:Dt(e),queryFn:async({pageParam:s})=>ie(a,e,s),initialPageParam:t,getNextPageParam:(s,r,o)=>s.has_more?{timestamp:s.next_timestamp,next_page:o.next_page,limit:o.limit}:void 0,...n})}function T(e){return ["channel",e]}async function $t(e,t){return await e.get(t)}function V(e,t={}){let n=p();return useQuery({queryKey:T(e),queryFn:async()=>$t(n,e),...t})}function Gt(e){return ["channels",e.chain??"",e.page?`${e.page}`:"",e.size?`${e.size}`:"",e.search??"",e.sort??"",e.order??""]}async function Jt(e,t){let n={...t,chain:t.chain?chainSlug(t.chain):void 0};return await e.getChannels(n)}function Fe(e={},t={}){let n=p();return useQuery({queryKey:Gt(e),queryFn:async()=>Jt(n,e),...t})}function me(e){return ["channelSources",e]}async function jt(e,t){return await e.getSources(t)}function K(e,t={}){let n=p();return useQuery({queryKey:me(e),queryFn:async()=>jt(n,e),...t})}async function nn(e,t){let n=chainSlug(t.chain);if(!n)throw new Error("Invalid chain");return e.create({...t,chain:n})}function Te(e={}){let t=p();return useMutation({mutationFn:async n=>nn(t,n),...e})}function on(e){return ["myChannels",e.chain??"",e.page?`${e.page}`:"",e.size?`${e.size}`:"",e.search??"",e.sort??"",e.order??""]}async function rn(e,t){let n={...t,chain:t.chain?chainSlug(t.chain):void 0};return await e.getMyChannels(n)}function z(e={},t={}){let n=p();return useQuery({queryKey:on(e),queryFn:async()=>rn(n,e),...t})}async function cn(e,t){await e.subscribe(t);}function Ee(e={}){let t=useQueryClient(),n=p();return useMutation({mutationFn:async a=>cn(n,a),...e,onSuccess:(a,s,r,o)=>{t.invalidateQueries({queryKey:["subscribedChannels"]}),t.invalidateQueries({queryKey:T(s)}),e?.onSuccess?.(a,s,r,o);}})}function pn(e){return ["subscribedChannels",e.chain??"",e.page?`${e.page}`:"",e.size?`${e.size}`:"",e.search??"",e.sort??"",e.order??""]}async function hn(e,t){let n={...t,chain:t.chain?chainSlug(t.chain):void 0};return await e.getSubscribedChannels(n)}function D(e={},t={}){let n=p();return useQuery({queryKey:pn(e),queryFn:async()=>hn(n,e),...t})}async function xn(e,t){await e.unsubscribe(t);}function Le(e={}){let t=p(),n=useQueryClient();return useMutation({mutationFn:async a=>xn(t,a),...e,onSuccess:(a,s,r,o)=>{n.invalidateQueries({queryKey:["subscribedChannels"]}),n.invalidateQueries({queryKey:T(s)}),e?.onSuccess?.(a,s,r,o);}})}async function bn(e,t){let n={...t};if(t.chain){let a=chainSlug(t.chain);if(!a)throw new Error("Invalid chain");n.chain=a;}return e.update(n)}function Re(e={}){let t=p(),n=useQueryClient();return useMutation({mutationFn:async a=>bn(t,a),...e,onSuccess:(a,s,r,o)=>{n.invalidateQueries({queryKey:T(s.id)}),e?.onSuccess?.(a,s,r,o);}})}async function Nn(e,t){return e.updateSources(t)}function ke(e={}){let t=p(),n=useQueryClient();return useMutation({mutationFn:async a=>Nn(t,a),...e,onSuccess:(a,s,r,o)=>{n.invalidateQueries({queryKey:me(s.channel_id)}),e?.onSuccess?.(a,s,r,o);}})}var Me=()=>{let e=usePinata(),{client:t}=useDexClient();return useCallback(async a=>{let s=await fetchPresignedUploadUrl(t),r=await e.upload.public.file(a).url(s);return e.gateways.public.convert(r.cid)},[e,t])};var Qe=z$1.object({name:z$1.string({error:"channels.forms.base.name.required"}).min(1,"channels.forms.base.name.min").max(24,"channels.forms.base.name.max"),description:z$1.string().optional(),icon:z$1.url({error:"channels.forms.base.icon.required"})}),Fn=z$1.object({address:z$1.string({error:"channels.forms.wallets.address.required"}),alias:z$1.string().optional()}),We=z$1.array(Fn).min(1,"channels.forms.wallets.required").max(500,"channels.forms.wallets.maxCount");function $({isSubmitting:e=false,onSubmit:t,defaultValues:n={name:"",description:"",icon:""},submitLabel:a}){let{t:s}=useTranslation(),r=useForm({mode:"onChange",reValidateMode:"onBlur",resolver:zodResolver(Qe),defaultValues:n}),o=Me();return jsxs(RHForm,{methods:r,onSubmit:t,children:[jsx(RHInput,{name:"name",label:s("channels.forms.base.name.label"),"aria-label":s("channels.forms.base.name.label"),placeholder:s("channels.forms.base.name.placeholder"),variant:"bordered",radius:"lg",size:"sm",fullWidth:true,labelPlacement:"outside-top"}),jsx(RHTextArea,{name:"description",label:s("channels.forms.base.description.label"),"aria-label":s("channels.forms.base.description.label"),placeholder:s("channels.forms.base.description.placeholder"),variant:"bordered",radius:"lg",size:"sm",fullWidth:true,labelPlacement:"outside-top"}),jsx(RHUpload,{name:"icon",upload:o,label:s("channels.forms.base.icon.label"),placeholder:s("channels.forms.base.icon.placeholder"),hint:s("channels.forms.base.icon.hint"),radius:"lg",classNames:{upload:"sm:max-w-80"}}),jsx(Button,{color:"primary",fullWidth:true,type:"submit",radius:"lg",className:"mt-8",isLoading:e,children:a??s("channels.forms.base.submit")})]})}function bl({onSuccess:e,onError:t}){let{t:n}=useTranslation(),{mutateAsync:a,isPending:s}=Te(),r=useAuthCallback(async o=>{try{let l=await a({name:o.name,description:o.description,icon:o.icon,chain:Chain.SOLANA,privacy:"public"});toast.success(n("channels.create.success")),e?.(l);}catch(l){toast.error(n("channels.create.error")),t?.(l);}},[n,a,e,t]);return jsx($,{onSubmit:r,isSubmitting:s})}function _e(e){let{t}=useTranslation(),{data:n,isLoading:a}=V(e),{mutateAsync:s,isPending:r}=Re(),o=useMemo(()=>{if(n)return {name:n.name,description:n.description,icon:n.icon??""}},[n]),l=useAuthCallback(async m=>{try{await s({id:e,name:m.name,description:m.description,icon:m.icon}),toast.success(t("channels.update.success"));}catch(i){console.error("Update channel base info error",i),toast.error(t("channels.update.error"));}},[s,e]);return {channel:n,isLoading:a,isSubmitting:r,defaultValues:o,submit:l}}function Ve({sink:e,onSaveToken:t}){let{t:n}=useTranslation(),[a,s]=useState("");return useEffect(()=>{},[e]),jsxs("div",{className:"px-2 sm:px-4 space-y-4",children:[jsx("p",{className:"whitespace-pre-wrap text-sm p-2 sm:p-4 bg-content2 rounded-lg text-neutral leading-[2]",children:n("channels.forms.socials.telegram.guide")}),jsxs("div",{className:"flex gap-4 items-center",children:[jsx(StyledInput,{fullWidth:true,placeholder:n("channels.forms.socials.telegram.placeholder"),radius:"lg",value:a,onValueChange:s}),jsx(Button,{color:"primary",radius:"lg",size:"sm",className:"h-10 min-h-10",children:n("common.save")})]})]})}function ze({channel:e}){let[t,n]=useState("telegram");return jsxs("div",{className:"w-full space-y-4",children:[jsx(StyledTabs,{variant:"underlined",selectedKey:t,onSelectionChange:n,disableAnimation:false,children:jsx(Tab,{title:jsxs("div",{className:"flex items-center gap-2",children:[jsx(TelegramIcon,{width:16,height:16}),jsx("h3",{children:"Telegram"})]})},"telegram")}),t==="telegram"&&jsx(Ve,{channel:e})]})}function De(e){return e.split(`
|
|
2
|
+
`).map(n=>n.trim()).filter(n=>!!n).map(n=>{let[a,s]=n.split(",");return {address:a?a.trim():void 0,alias:s?s.trim():void 0}})}function Ye({wallets:e=[],onSubmit:t,isSubmitting:n}){let{t:a}=useTranslation(),s=useCopyToClipboard(),r=useAuthCallback(u=>{let h=e.filter(v=>v.value!==u.value).map(v=>({address:v.value??"",alias:v.alias}));t?.(h);},[e,t]),[o,l]=useState(""),m=debounce(l,200),i=useMemo(()=>e.filter(u=>u.alias?.toLowerCase()?.includes(o.toLowerCase())||u.value?.toLowerCase()?.includes(o.toLowerCase())),[o,e]);return jsxs("div",{className:"space-y-2",children:[jsxs("div",{className:"flex items-center justify-between",children:[jsx("h2",{className:"text-sm font-medium",children:a("channels.forms.wallets.list.title")}),jsx(StyledInput,{size:"sm",className:"max-w-50",radius:"full",startContent:jsx(SearchIcon,{width:16,height:16,className:"text-neutral"}),placeholder:a("channels.forms.wallets.list.search.placeholder"),onValueChange:m})]}),jsxs(StyledTable,{isHeaderSticky:true,isVirtualized:i.length>10||i.length===0,radius:"lg",classNames:{emptyWrapper:"pt-10"},maxTableHeight:500,rowHeight:52,"aria-label":a("channels.forms.wallets.list.title"),children:[jsxs(TableHeader,{children:[jsx(TableColumn,{textValue:a("channels.forms.wallets.list.header.address"),width:"60%",children:a("channels.forms.wallets.list.header.address")},"address"),jsx(TableColumn,{textValue:a("channels.forms.wallets.list.header.actions"),width:"40%",align:"end",children:a("channels.forms.wallets.list.header.actions")},"actions")]}),jsx(TableBody,{items:i,emptyContent:jsxs("div",{className:"space-y-2",children:[jsx(EmptyIcon,{className:"w-10 h-10 mx-auto text-neutral"}),jsx("p",{className:"text-xs text-neutral text-center",children:a("channels.forms.wallets.list.empty")})]}),children:u=>jsxs(TableRow,{children:[jsx(TableCell,{children:jsxs("div",{className:"flex flex-col gap-1 text-xs",children:[jsx("div",{children:u.alias}),jsxs("div",{className:"text-neutral flex items-center gap-1",onClick:()=>s(u.value??""),"aria-label":a("common.copy"),children:[jsx("div",{children:shortAddress(u.value??"")}),jsx("div",{children:jsx(CopyIcon,{width:12,height:12})})]})]})},"address"),jsx(TableCell,{children:jsx(Button,{isIconOnly:true,size:"sm",radius:"full",className:"bg-transparent",disabled:n,onPress:()=>r(u),children:jsx(TrashIcon,{className:"text-danger-500",width:18,height:18})})},"actions")]},u.value)})]})]})}var Es=z$1.object({walletsText:z$1.string({error:"channels.forms.wallets.required"}).min(1,"channels.forms.wallets.required")});function Ge({channel:e,wallets:t=[],onSubmit:n,isSubmitting:a=false}){let{t:s}=useTranslation(),r=useForm({mode:"onChange",reValidateMode:"onBlur",resolver:zodResolver(Es),defaultValues:{walletsText:""}}),o=useMemo(()=>t.map(d=>({address:d.value??"",alias:d.alias})),[t]),{setError:l,reset:m}=r,i=useCallback(d=>{try{let h=We.parse(De(d)),v=h.length-uniqBy(h,"address").length;if(v!==0)throw new Error(s("channels.forms.wallets.address.duplicated",{count:v}));let Pe=intersectionBy(h,o,"address").length;if(Pe>0)throw new Error(s("channels.forms.wallets.address.alreadyAdded",{count:Pe}));if(h.length+o.length>500)throw new Error(s("channels.forms.wallets.maxCount"));let le=0;for(let Ot of h)isValidWalletAddress(e.chain,Ot.address)||le++;if(le>0)throw new Error(s("channels.forms.wallets.address.invalid",{count:le}));return h}catch(h){h instanceof z$1.ZodError?l("walletsText",{message:h.issues[0].message,type:"manual"}):h instanceof Error?l("walletsText",{message:h.message,type:"manual"}):l("walletsText",{message:s("channels.forms.wallets.invalid"),type:"manual"});return}},[o,s,e.chain]),u=useCallback(async d=>{let h=i(d.walletsText);h&&h.length>0&&(await n?.([...o,...h]),m());},[i,n,o]);return jsxs("div",{className:"flex flex-col gap-6",children:[jsxs(RHForm,{methods:r,onSubmit:u,className:"relative",children:[jsx(RHTextArea,{name:"walletsText",label:s("channels.forms.wallets.label"),"aria-label":s("channels.forms.wallets.label"),placeholder:s("channels.forms.wallets.placeholder"),variant:"bordered",radius:"lg",size:"sm",fullWidth:true,minRows:10,maxRows:10,labelPlacement:"outside-top"}),jsxs("div",{className:"absolute right-0 top-0 text-xs flex gap-1 text-neutral",children:[jsxs("span",{className:"text-neutral",children:[s("channels.forms.wallets.addedCount"),":"]}),jsxs("span",{children:[o.length," / 500"]})]}),jsxs("div",{className:"w-full flex items-center gap-4",children:[jsx(HorizontalScrollContainer,{className:"flex-auto min-w-0",children:jsxs("div",{className:"flex items-center gap-2",children:[jsxs("span",{className:"text-xs text-neutral flex-none",children:[s("channels.forms.wallets.supportedFormats"),":"]}),jsx(StyledTooltip,{closeDelay:0,content:jsx("div",{className:"text-xs whitespace-pre-line",children:s("channels.forms.wallets.supportedFormats.text.hint")}),children:jsx(Chip,{size:"sm",variant:"flat",children:s("channels.forms.wallets.supportedFormats.text")})})]})}),jsx("div",{className:"flex-none flex gap-4 items-center",children:jsx(Button,{color:"primary",type:"submit",radius:"lg",isLoading:a,size:"sm",children:s("channels.forms.wallets.submit")})})]})]}),jsx(Ye,{wallets:t,onSubmit:n,isSubmitting:a})]})}function Xe({channel:e,type:t="base",baseFormDefaultValues:n,isSubmittingBaseForm:a=false,onSubmitBaseForm:s,baseFormSubmitLabel:r,wallets:o,isSubmittingWalletsForm:l=false,onSubmitWalletsForm:m,className:i}){let{t:u}=useTranslation(),[d,h]=useState(t),{isMobile:v}=useScreen();return jsxs("div",{className:clsx("w-full flex flex-col gap-4",i),children:[jsxs(StyledTabs,{fullWidth:true,variant:"solid",size:v?"sm":void 0,selectedKey:d,onSelectionChange:h,children:[jsx(Tab,{title:u("channels.forms.base.title")},"base"),jsx(Tab,{title:u("channels.forms.wallets.title")},"wallets"),jsx(Tab,{title:u("channels.forms.socials.title")},"social")]}),d==="base"&&jsx($,{defaultValues:n,isSubmitting:a,onSubmit:s,submitLabel:r}),d==="wallets"&&jsx(Ge,{channel:e,wallets:o,isSubmitting:l,onSubmit:m}),d==="social"&&jsx(ze,{channel:e})]})}function je({type:e="base",className:t}){let{t:n}=useTranslation(),[a,s]=useState(e),{isMobile:r}=useScreen();return jsxs("div",{className:clsx("w-full flex flex-col gap-4",t),children:[jsxs(StyledTabs,{fullWidth:true,variant:"solid",size:r?"sm":void 0,selectedKey:a,onSelectionChange:s,children:[jsx(Tab,{title:n("channels.forms.base.title")},"base"),jsx(Tab,{title:n("channels.forms.wallets.title")},"wallets"),jsx(Tab,{title:n("channels.forms.socials.title")},"social")]}),a==="base"&&jsx(fe,{}),a==="wallets"&&jsx(fe,{}),a==="social"&&jsx(fe,{})]})}function fe(){return jsxs("div",{className:"flex flex-col gap-4",children:[jsx(Skeleton,{className:"w-full h-10 rounded-md"}),jsx(Skeleton,{className:"w-full h-10 rounded-md"}),jsx(Skeleton,{className:"w-full h-40 rounded-md"})]})}function tt(e,t){let{t:n}=useTranslation(),{data:a,isLoading:s}=K(e),{mutateAsync:r,isPending:o}=ke(),l=useAuthCallback(async m=>{try{if(!t?.chain)throw new Error("Channel chain is not set");await r({channel_id:e,type:"wallet",sources:m.map(i=>({type:"wallet",value:i.address,alias:i.alias,configs:{chain:chainSlug(t.chain)}}))}),toast.success(n("channels.forms.wallets.update.success"));}catch(i){console.error("Update channel wallets error",i),toast.error(n("channels.forms.wallets.update.error"));}},[r,e,t?.chain]);return {isLoading:s,isSubmitting:o,wallets:a,submit:l}}function Li({id:e,type:t="base"}){let{t:n}=useTranslation(),{channel:a,defaultValues:s,isLoading:r,isSubmitting:o,submit:l}=_e(e),{wallets:m,isLoading:i,isSubmitting:u,submit:d}=tt(e,a);return r||i||!a?jsx(je,{type:t}):jsx(Xe,{channel:a,type:t,baseFormDefaultValues:s,isSubmittingBaseForm:o,onSubmitBaseForm:l,baseFormSubmitLabel:n("channels.forms.base.update.submit"),wallets:m,isSubmittingWalletsForm:u,onSubmitWalletsForm:d})}function Z({channel:e}){let{t}=useTranslation(),n=useTickAge(new Date(e.updated_at));return jsx(HorizontalScrollContainer,{classNames:{leftArrow:"from-content1/60 to-transparent",rightArrow:"from-content1/60 to-transparent"},children:jsxs("div",{className:"flex items-center gap-4",children:[jsx(StyledTooltip,{content:t("channels.info.walletCount"),closeDelay:0,children:jsxs("div",{className:"flex items-center gap-1",children:[jsx(WalletIcon,{width:16,height:16}),jsx("p",{className:"text-xs",children:e.source_count||"-"})]})}),jsx(StyledTooltip,{content:t("channels.info.subscribeCount"),closeDelay:0,children:jsxs("div",{className:"flex items-center gap-1",children:[jsx(PeopleIcon,{width:16,height:16}),jsx("p",{className:"text-xs",children:e.subscribe_count||"-"})]})}),jsx(StyledTooltip,{content:t("channels.info.updatedAt"),closeDelay:0,children:jsxs("div",{className:"flex items-center gap-1",children:[jsx(TimerIcon,{width:16,height:16}),jsx("p",{className:"text-xs",children:formatAge(n)})]})}),e.twitter&&jsx(Link,{href:e.twitter,target:"_blank",className:"text-neutral",children:jsx(TwitterIcon,{width:16,height:16})}),e.telegram&&jsx(Link,{href:e.telegram,target:"_blank",className:"text-neutral",children:jsx(TelegramIcon,{width:16,height:16})}),e.discord&&jsx(Link,{href:e.discord,target:"_blank",className:"text-neutral",children:jsx(DiscordIcon,{width:16,height:16})})]})})}function at({channel:e,customActions:t}){let n=useMemo(()=>e.chain?chainIcon(e.chain):void 0,[e.chain]);return jsxs("div",{className:"flex gap-4",children:[jsx("div",{className:"flex-none flex flex-col",children:jsxs("div",{className:"relative",children:[jsx(Avatar,{src:e.icon,alt:e.name,className:"w-18 h-18",radius:"md"}),n&&jsx(Avatar,{radius:"full",src:n,className:"w-5 h-5 absolute -bottom-1 -right-1 border border-border shadow-sm"})]})}),jsxs("div",{className:"flex-auto min-w-0 flex flex-col gap-2 text-neutral",children:[jsxs("div",{className:"h-6 flex items-center gap-2",children:[jsx("p",{className:"flex-auto min-w-0 text-sm font-medium text-foreground truncate",children:e.name}),jsx("div",{className:"flex-none",children:t})]}),jsx(Z,{channel:e}),jsx("p",{className:"text-xs whitespace-pre-wrap line-clamp-1 h-4 overflow-hidden",children:e.description})]})]})}function om({channel:e,onEdit:t}){let{user:n}=useAuth(),a=useAuthCallback(()=>{t?.(e);},[e,t]);return n?.id!==e.owner_id?jsx(Fragment,{}):jsx(StyledButton,{className:"bg-transparent",isIconOnly:true,size:"sm",onPress:a,children:jsx(EditIcon,{width:16,height:16,className:"text-neutral"})})}function X({channel:e}){let{t}=useTranslation();return jsx(HorizontalScrollContainer,{classNames:{leftArrow:"from-content1/60 to-transparent",rightArrow:"from-content1/60 to-transparent"},children:jsxs("div",{className:"flex items-center gap-4 text-xs",children:[jsx(StyledTooltip,{content:t("channels.stats.7dTxs.hint"),closeDelay:0,children:jsxs("div",{className:"flex-none flex flex-col gap-1 items-center",children:[jsx("p",{className:"text-neutral font-medium",children:t("channels.stats.7dTxs.title")}),jsx("p",{className:"text-foreground font-semibold",children:"--"})]})}),jsx(StyledTooltip,{content:t("channels.stats.7dPnl.hint"),closeDelay:0,children:jsxs("div",{className:"flex-none flex flex-col gap-1 items-center",children:[jsx("p",{className:"text-neutral font-medium",children:t("channels.stats.7dPnl.title")}),jsx("p",{className:"text-bullish font-semibold",children:"--"})]})}),jsx(StyledTooltip,{content:t("channels.stats.7dWr.hint"),closeDelay:0,children:jsxs("div",{className:"flex-none flex flex-col gap-1 items-center",children:[jsx("p",{className:"text-neutral font-medium",children:t("channels.stats.7dWr.title")}),jsx("p",{className:"text-bullish font-semibold",children:"--%"})]})})]})})}function xm({channel:e,onSubscribeSuccess:t,onUnsubscribeSuccess:n,onSubscribeError:a,onUnsubscribeError:s}){let{t:r}=useTranslation(),[o,l]=useState(e.is_subscribed);useEffect(()=>{l(e.is_subscribed);},[e.is_subscribed]);let{mutateAsync:m,isPending:i}=Ee(),{mutateAsync:u,isPending:d}=Le(),h=useAuthCallback(async()=>{try{o?(await u(e.id),l(!1),toast.success(r("channels.unsubscribe.success")),n?.(e)):(await m(e.id),l(!0),toast.success(r("channels.subscribe.success")),t?.(e));}catch(v){console.error("Subscribe / Unsubscribe channel error",v),o?(toast.error(r("channels.unsubscribe.error")),s?.(e,v)):(toast.error(r("channels.subscribe.error")),a?.(e,v));}},[r,o,e,m,u,t,n,a,s]);return jsx(StyledButton,{color:o?"default":"primary",size:"sm",radius:"lg",onPress:h,isLoading:i||d,variant:o?"bordered":"flat",className:clsx("gap-1",o&&"text-neutral"),startContent:o?!i&&!d?jsx(CheckIcon,{width:16,height:16}):void 0:!i&&!d?jsx(PlusIcon,{width:16,height:16}):void 0,children:r(o?"channels.unsubscribe.submit":"channels.subscribe.submit")})}function rt({channel:e,onSelect:t,headerActions:n,footerActions:a}){let s=useCallback(()=>{t?.(e);},[e,t]);return jsxs("div",{className:clsx("bg-content1 hover:bg-content2 border border-border rounded-lg w-full h-full p-2.5","flex flex-col gap-2.5",t&&"cursor-pointer"),onClick:s,children:[jsx(at,{channel:e,customActions:n}),jsxs("div",{className:"flex items-center gap-4",children:[jsx("div",{className:"flex-auto min-w-0",children:jsx(X,{channel:e})}),jsx("div",{className:"flex-none",children:a})]})]})}function R({channels:e,onSelect:t,customHeaderActions:n,customFooterActions:a}){return jsx("div",{className:"w-full grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:e.map(s=>jsx(rt,{channel:s,onSelect:t,headerActions:n?.(s),footerActions:a?.(s)},s.id))})}function M({count:e}){return jsx("div",{className:"w-full grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Array.from({length:e}).map((t,n)=>jsxs("div",{className:"bg-content1 hover:bg-content2 border border-border rounded-lg w-full h-35 p-2.5 flex flex-col gap-2.5",children:[jsxs("div",{className:"flex gap-4",children:[jsx("div",{className:"flex-none flex flex-col",children:jsx(Skeleton,{className:"w-18 h-18 flex-none rounded-md"})}),jsxs("div",{className:"flex-auto min-w-0 flex flex-col gap-2 justify-center text-neutral",children:[jsx(Skeleton,{className:"w-24 h-4 rounded-md"}),jsx(Skeleton,{className:"w-48 h-4 rounded-md"}),jsx(Skeleton,{className:"w-48 h-4 rounded-md"})]})]}),jsxs("div",{className:"w-full flex justify-between gap-4",children:[jsx(Skeleton,{className:"flex-auto min-w-0 h-6 rounded-md"}),jsx(Skeleton,{className:"w-24 h-6 rounded-md"})]})]},n))})}function Q({message:e}){let{t}=useTranslation();return jsxs("div",{className:"pt-24 mx-auto",children:[jsx(EmptyIcon,{width:28,height:28,className:"text-neutral mx-auto"}),jsx("p",{className:"pt-2 text-sm text-neutral text-center",children:e||t("common.empty")})]})}var mt=()=>{let{status:e}=useAuth(),t=Fe(),{refetch:n}=t;return useEffect(()=>{e==="authenticated"&&n();},[e,n]),t};function ct({onSelect:e,customHeaderActions:t,customFooterActions:n}){let{data:a,isLoading:s}=mt();return s?jsx(M,{count:9}):!a||a.list.length===0?jsx(Q,{}):jsx(R,{channels:a.list,onSelect:e,customHeaderActions:t,customFooterActions:n})}function ne({message:e}){let{t}=useTranslation(),{signIn:n}=useAuth();return jsxs("div",{className:"pt-24 flex flex-col items-center justify-center gap-2",children:[jsx("p",{className:"text-neutral text-sm",children:e||t("common.unauthenticated")}),jsx(StyledButton,{color:"primary",size:"sm",onPress:n,radius:"lg",children:t("common.signIn")})]})}function dt({onSelect:e,customHeaderActions:t,customFooterActions:n}){let{status:a}=useAuth(),{data:s,isLoading:r}=D({},{enabled:a==="authenticated"});return a==="unauthenticated"?jsx(ne,{}):a==="authenticating"||r?jsx(M,{count:9}):!s||s.list.length===0?jsx(Q,{}):jsx(R,{channels:s.list,onSelect:e,customHeaderActions:t,customFooterActions:n})}var dc=()=>D();function pt({onSelect:e,customHeaderActions:t,customFooterActions:n}){let{status:a}=useAuth(),{data:s,isLoading:r}=z({},{enabled:a==="authenticated"});return a==="unauthenticated"?jsx(ne,{}):a==="authenticating"||r?jsx(M,{count:9}):!s||s.list.length===0?jsx(Q,{}):jsx(R,{channels:s.list,onSelect:e,customHeaderActions:t,customFooterActions:n})}var Sc=()=>z();function ft({channel:e,headerActions:t,footerActions:n,className:a}){let s=useMemo(()=>e.chain?chainIcon(e.chain):void 0,[e.chain]);return jsxs("div",{className:clsx("bg-content1 border border-border rounded-lg w-full h-fit p-2.5","flex flex-col gap-2.5",a),children:[jsxs("div",{className:"flex gap-4",children:[jsx("div",{className:"flex-none flex flex-col",children:jsxs("div",{className:"relative",children:[jsx(Avatar,{src:e.icon,alt:e.name,className:"w-18 h-18",radius:"md"}),s&&jsx(Avatar,{radius:"full",src:s,className:"w-5 h-5 absolute -bottom-1 -right-1 border border-border shadow-sm"})]})}),jsxs("div",{className:"flex-auto min-w-0 flex flex-col gap-2 text-neutral",children:[jsxs("div",{className:"h-6 flex items-center gap-2",children:[jsx("p",{className:"flex-auto min-w-0 text-sm font-medium text-foreground truncate",children:e.name}),jsx("div",{className:"flex-none",children:t})]}),jsx(Z,{channel:e})]})]}),jsxs("div",{className:"flex gap-4",children:[jsx("div",{className:"flex-auto min-w-0",children:jsx(X,{channel:e})}),jsx("div",{className:"flex-none",children:n})]}),e.description&&jsx("p",{className:"text-xs whitespace-pre-wrap",children:e.description})]})}function vt({event:e,walletAliases:t,tokens:n}){let{t:a}=useTranslation(),s=useTickAge(new Date(e.data.timestamp)),r=e.data.wallet_address,o=t?.[r],l=e.data.quote_address,m=n?.[l]?.symbol??COMMON_TOKEN_SYMBOLS_MAP[l],i=e.data.base_address,u=n?.[i]?.symbol??COMMON_TOKEN_SYMBOLS_MAP[i],d=e.data.type;return jsxs("div",{className:"w-full h-full flex items-center gap-2.5 text-xs",children:[jsx("div",{className:"flex-none w-24",children:o?jsxs("div",{className:"flex flex-col justify-center gap-0.5",children:[jsx("div",{className:"truncate",children:o}),jsxs("div",{className:"text-neutral",children:["(",shortAddress(r),")"]})]}):jsx("div",{children:shortAddress(r)})}),d==="buy"&&jsxs(Fragment,{children:[jsx("div",{className:"flex-none w-18",children:jsxs("div",{className:"flex flex-col justify-center gap-0.5",children:[jsx("div",{className:"text-neutral",children:a("channels.events.walletTrade.buy")}),jsx("div",{className:"text-bullish",children:formatAmount(new SafeBigNumber(e.data.base_amount).abs())})]})}),jsx("div",{className:"flex-none w-24",children:u?jsxs("div",{className:"flex flex-col justify-center gap-0.5",children:[jsx("div",{className:"truncate",children:u}),jsxs("div",{className:"text-neutral",children:["(",shortAddress(i),")"]})]}):jsx("div",{children:shortAddress(i)})}),jsx("div",{className:"flex-none w-18",children:jsxs("div",{className:"flex flex-col justify-center gap-0.5",children:[jsx("div",{className:"text-neutral",children:a("channels.events.walletTrade.cost")}),jsx("div",{className:"text-bearish",children:formatAmount(new SafeBigNumber(e.data.quote_amount).abs())})]})}),jsx("div",{className:"flex-none w-24",children:m?jsxs("div",{className:"flex flex-col justify-center gap-0.5",children:[jsx("div",{className:"truncate",children:m}),jsxs("div",{className:"text-neutral",children:["(",shortAddress(l),")"]})]}):jsx("div",{children:shortAddress(l)})}),jsx("div",{className:"flex-none w-18",children:jsxs("div",{className:"flex flex-col justify-center gap-0.5",children:[jsx("div",{className:"truncate text-neutral",children:a("channels.events.walletTrade.price")}),jsx("div",{children:formatPriceUSD(e.data.quote_price_usd)})]})})]}),d==="sell"&&jsxs(Fragment,{children:[jsx("div",{className:"flex-none w-18",children:jsxs("div",{className:"flex flex-col justify-center gap-0.5",children:[jsx("div",{className:"text-neutral",children:a("channels.events.walletTrade.sell")}),jsx("div",{className:"text-bearish",children:formatAmount(new SafeBigNumber(e.data.quote_amount).abs())})]})}),jsx("div",{className:"flex-none w-24",children:m?jsxs("div",{className:"flex flex-col justify-center gap-0.5",children:[jsx("div",{className:"truncate",children:m}),jsxs("div",{className:"text-neutral",children:["(",shortAddress(l),")"]})]}):jsx("div",{children:shortAddress(l)})}),jsx("div",{className:"flex-none w-18",children:jsxs("div",{className:"flex flex-col justify-center gap-0.5",children:[jsx("div",{className:"text-neutral",children:a("channels.events.walletTrade.got")}),jsx("div",{className:"text-bullish",children:formatAmount(new SafeBigNumber(e.data.base_amount).abs())})]})}),jsx("div",{className:"flex-none w-24",children:u?jsxs("div",{className:"flex flex-col justify-center gap-0.5",children:[jsx("div",{className:"truncate",children:u}),jsxs("div",{className:"text-neutral",children:["(",shortAddress(i),")"]})]}):jsx("div",{children:shortAddress(i)})}),jsx("div",{className:"flex-none w-18",children:jsxs("div",{className:"flex flex-col justify-center gap-0.5",children:[jsx("div",{className:"truncate text-neutral",children:a("channels.events.walletTrade.price")}),jsx("div",{children:formatPriceUSD(e.data.quote_price_usd)})]})})]}),jsx("div",{className:"flex-none w-18 text-end",children:formatAge(s)})]})}function wt({data:e=[],isLoading:t=false,hasMore:n=false,onFetchMore:a,className:s,walletAliases:r,tokens:o}){let l=useRef(null),{height:m}=useResizeObserver({ref:l}),i=useCallback(v=>v<e.length,[e]),u=useCallback(async()=>{a?.();},[a]),d=useMemo(()=>n?e.length+1:e.length,[e,n]),h=useInfiniteLoader({isRowLoaded:i,loadMoreRows:u,rowCount:d,threshold:3});return t?jsx($a,{}):!e||e.length===0?jsx(Ha,{}):jsx("div",{className:clsx("w-full h-full bg-content1 border border-border rounded-lg py-2.5 overflow-x-auto",s),children:jsx("div",{className:"w-full min-w-164 h-full",ref:l,children:jsx(List,{style:{height:m},onRowsRendered:h,rowComponent:Ya,rowCount:d,rowHeight:60,rowProps:{data:e,walletAliases:r,tokens:o}})})})}function Ha(){let{t:e}=useTranslation();return jsxs("div",{className:"w-full bg-content1 border border-border rounded-lg p-2.5",children:[jsx(EmptyIcon,{width:28,height:28,className:"text-neutral mx-auto mt-20"}),jsx("p",{className:"pt-2 text-sm text-neutral text-center mb-20",children:e("channels.events.empty")})]})}function $a(){return jsx("div",{className:"w-full bg-content1 border border-border rounded-lg p-2.5",children:Array.from({length:6}).map((e,t)=>jsx("div",{className:"w-full h-10 flex items-center",children:jsx(Skeleton,{className:"w-full h-6 rounded-md"})},t))})}function Ya({index:e,style:t,data:n,walletAliases:a,tokens:s}){let{t:r}=useTranslation();if(!n)return jsx("div",{className:"px-2.5",style:t});let o=n[e];return o?jsx("div",{style:t,className:"px-2.5 hover:bg-content2",children:jsx(Za,{event:o,walletAliases:a,tokens:s})}):jsx("div",{style:t,className:"px-2.5 text-xs text-neutral text-center",children:r("common.loadingMore")})}function Za(e){switch(e.event.type){case "wallet":return jsx(vt,{...e});default:return jsx(Fragment,{})}}function St(e){let{data:t,...n}=Ae(e,{next_page:true,limit:50}),{data:a}=Ue(e,{next_page:false,limit:50},{refetchInterval:1e4}),s=useMemo(()=>{let r=t?.pages?.flatMap(m=>m.data)??[],o=a?.data??[];return uniqBy([...o,...r],m=>m.data.tx_hash+":"+m.data.type).sort((m,i)=>i.timestamp-m.timestamp)},[t,a]);return {...n,data:s}}function Pt(e){let{client:t}=useDexClient(),[n,a]=useState({}),s=useRef(new Set);return useEffect(()=>{let r=new Set;e.forEach(o=>{!COMMON_TOKEN_ADDRESSES.includes(o.data.quote_address)&&!s.current.has(o.data.quote_address)&&(r.add(o.data.quote_address),s.current.add(o.data.quote_address)),!COMMON_TOKEN_ADDRESSES.includes(o.data.base_address)&&!s.current.has(o.data.base_address)&&(r.add(o.data.base_address),s.current.add(o.data.base_address));}),r.size>0&&fetchTokens(t,{chain:Chain.SOLANA,addresses:Array.from(r)}).then(o=>{a(l=>{let m={...l};return o.forEach(i=>{m[i.address]=i;}),m});}).catch(o=>{console.error(o);});},[e,t]),{tokens:n}}function Ut(){let{t:e}=useTranslation();return jsxs("div",{className:"w-full",children:[jsx(EmptyIcon,{width:40,height:40,className:"mt-10 text-neutral mx-auto"}),jsx("p",{className:"text-sm text-neutral text-center mt-2",children:e("channels.detail.notfound")})]})}function Tt(){return jsxs("div",{className:"w-full space-y-6",children:[jsx(Skeleton,{className:"w-full h-35 rounded-md"}),jsx(Skeleton,{className:"w-full h-40 rounded-md"})]})}var Et=e=>V(e);function Rt(e){let{data:t}=K(e),n=useMemo(()=>t?.filter(s=>s.type==="wallet")??[],[t]),a=useMemo(()=>mapValues(keyBy(n.filter(s=>!!s.alias),"value"),s=>s.alias),[n]);return {wallets:n,aliases:a}}function Mt({id:e,customHeaderActions:t,customFooterActions:n}){let{t:a}=useTranslation(),{data:s,isLoading:r}=Et(e),{data:o,isLoading:l,hasNextPage:m,fetchNextPage:i}=St(e),{aliases:u}=Rt(e),{tokens:d}=Pt(o);return r?jsx(Tt,{}):s?jsxs("div",{className:"w-full h-full flex flex-col gap-6",children:[jsx(ft,{channel:s,headerActions:t?.(s),footerActions:n?.(s),className:"flex-none"}),jsxs("div",{className:"flex-auto min-h-0 flex flex-col gap-2.5",children:[jsx("h2",{className:"text-sm font-semibold flex-none",children:a("channels.events.title")}),jsx(wt,{data:o,isLoading:l,hasMore:m,onFetchMore:i,className:"flex-auto min-h-0",walletAliases:u,tokens:d})]})]}):jsx(Ut,{})}function Hu({onCreateChannel:e,onSelectChannel:t,customHeaderActions:n,customFooterActions:a}){let{t:s}=useTranslation(),{isMobile:r}=useScreen(),[o,l]=useState("trending");return jsxs("div",{className:"w-full max-w-7xl mx-auto py-2 px-2 sm:py-4 sm:px-4",children:[jsxs("div",{className:"flex items-center justify-between gap-2 w-full overflow-x-auto",children:[jsx(HorizontalScrollContainer,{className:"flex-auto min-w-0",children:jsxs(StyledTabs,{variant:"primaryPlain",radius:"lg",selectedKey:o,onSelectionChange:l,"aria-label":s("channels.list.title"),size:r?"sm":void 0,children:[jsx(Tab,{title:s("channels.trending.title"),"aria-label":s("channels.trending.title")},"trending"),jsx(Tab,{title:s("channels.my.title"),"aria-label":s("channels.my.title")},"my"),jsx(Tab,{title:s("channels.subscribed.title"),"aria-label":s("channels.subscribed.title")},"subscribed")]})}),jsx("div",{className:"flex-none flex items-center gap-2",children:e&&jsxs(Fragment,{children:[jsx(Button,{radius:"lg",color:"primary",size:"sm",onPress:e,className:"max-sm:hidden gap-1",startContent:jsx(PlusIcon,{width:18,height:18}),"aria-label":s("channels.create.title"),children:s("channels.create.title")}),jsx(Button,{isIconOnly:true,radius:"full",color:"primary",size:"sm",onPress:e,className:"sm:hidden w-7 min-w-7 h-7 min-h-7","aria-label":s("channels.create.title"),children:jsx(PlusIcon,{width:18,height:18})})]})})]}),jsxs("div",{className:"mt-4 w-full",children:[o==="trending"&&jsx(ct,{onSelect:t,customHeaderActions:n,customFooterActions:a}),o==="my"&&jsx(pt,{onSelect:t,customHeaderActions:n,customFooterActions:a}),o==="subscribed"&&jsx(dt,{onSelect:t,customHeaderActions:n,customFooterActions:a})]})]})}function Ju({id:e,customHeaderActions:t,customFooterActions:n}){let{t:a}=useTranslation();return jsxs("div",{className:"w-full h-full max-w-2xl mx-auto py-2 px-2 sm:py-4 sm:px-4 flex flex-col gap-2 sm:gap-4",children:[jsx("h1",{className:"text-sm sm:text-lg font-semibold flex-none",children:a("channels.detail.title")}),jsx("div",{className:"w-full flex-auto min-h-0",children:jsx(Mt,{id:e,customFooterActions:n,customHeaderActions:t})})]})}function id({client:e,children:t}){return jsx(q.Provider,{value:{client:e},children:t})}export{$ as BaseFormUI,Z as ChannelAttributes,at as ChannelBaseInfo,ft as ChannelDetailUI,Mt as ChannelDetailWidget,om as ChannelEditButton,X as ChannelStats,xm as ChannelSubscribeButton,q as ChannelsContext,Ju as ChannelsDetailPage,Q as ChannelsEmptyUI,Hu as ChannelsHomePage,id as ChannelsProvider,M as ChannelsSkeletonUI,R as ChannelsUI,bl as CreateChannelWidget,pt as MyChannelsWidget,ze as SocialsFormUI,dt as SubscribedChannelsWidget,ct as TrendingChannelsWidget,Xe as UpdateChannelFormUI,Li as UpdateChannelWidget,Ge as WalletsFormUI,Ye as WalletsListUI,Qe as baseFormSchema,Dt as channelEventsInfiniteQueryKey,Kt as channelEventsQueryKey,T as channelQueryKey,me as channelSourcesQueryKey,Gt as channelsListQueryKey,nn as createChannel,$t as fetchChannel,ie as fetchChannelEvents,jt as fetchChannelSources,Jt as fetchChannelsList,rn as fetchMyChannelsList,hn as fetchSubscribedChannelsList,on as myChannelsListQueryKey,De as parseWalletsText,cn as subscribeChannel,pn as subscribedChannelsListQueryKey,xn as unsubscribeChannel,bn as updateChannel,Nn as updateChannelSources,Et as useChannelDetail,Ae as useChannelEventsInfiniteQuery,Ue as useChannelEventsQuery,V as useChannelQuery,K as useChannelSourcesQuery,p as useChannelsClient,Ie as useChannelsContext,Fe as useChannelsListQuery,Te as useCreateChannelMutation,Sc as useMyChannels,z as useMyChannelsListQuery,Ee as useSubscribeChannelMutation,dc as useSubscribedChannels,D as useSubscribedChannelsListQuery,mt as useTrendingChannels,Le as useUnsubscribeChannelMutation,_e as useUpdateBaseForm,Re as useUpdateChannelMutation,ke as useUpdateChannelSourcesMutation,tt as useUpdateWalletsForm,Me as useUpload,Bt as version,Fn as walletSchema,We as walletsFormSchema};//# sourceMappingURL=index.mjs.map
|
|
4
3
|
//# sourceMappingURL=index.mjs.map
|