PageSourceSearch

https://trybrain.io/assets/_authenticated.organic-competitors-CLXSxO_a.js

js trybrain.io collected 2026-09-24 15:05:13 UTC 8,321 bytes, 1 lines download raw bytes

1import{z as n,D as l,E as d,au as J,e as o,P as X,f as k,r,K as u,t as i,j as e,B as a,L,ab as Z,ac as ee,ad as se,ae as te,af as y,I as h,q as E,bm as ae,N as K,k as p,at as oe,aN as re,aE as ie,S as ne,aD as le}from"./index-DHwBXtP2.js";const de=n({method:"POST"}).middleware([l]).handler(d("src_lib_organic-competitor_functions_ts--listCompetitors_createServerFn_handler")),ce=n({method:"POST"}).middleware([l]).handler(d("src_lib_organic-competitor_functions_ts--addCompetitor_createServerFn_handler")),me=n({method:"POST"}).middleware([l]).handler(d("src_lib_organic-competitor_functions_ts--removeCompetitor_createServerFn_handler")),ue=n({method:"POST"}).middleware([l]).handler(d("src_lib_organic-competitor_functions_ts--listCompetitorPosts_createServerFn_handler")),pe=n({method:"POST"}).middleware([l]).handler(d("src_lib_organic-competitor_functions_ts--addCompetitorPostManual_createServerFn_handler")),he=n({method:"POST"}).middleware([l]).handler(d("src_lib_organic-competitor_functions_ts--scrapeCompetitorFn_createServerFn_handler")),xe=n({method:"POST"}).middleware([l]).handler(d("src_lib_organic-competitor_functions_ts--promoteCompetitorPost_createServerFn_handler"));function ve(){const c=J(),Q=o(X),A=o(de),M=o(ce),D=o(me),V=o(ue),R=o(pe),U=o(he),B=o(xe),{data:H}=k({queryKey:["workspaces"],queryFn:()=>Q({})}),t=H?.[0],x=k({queryKey:["organic-competitors",t?.id],queryFn:()=>A({data:{workspaceId:t.id}}),enabled:!!t?.id}),[C,W]=r.useState("instagram"),[g,S]=r.useState(""),[b,F]=r.useState(""),[m,P]=r.useState(null),[v,Y]=r.useState(!1),j=k({queryKey:["organic-competitor-posts",t?.id,m,v],queryFn:()=>V({data:{workspaceId:t.id,competitorId:m??void 0,outliersOnly:v}}),enabled:!!t?.id}),_=u({mutationFn:()=>M({data:{workspaceId:t.id,platform:C,handle:g,displayName:b||void 0}}),onSuccess:()=>{i.success("Competitor added"),S(""),F(""),c.invalidateQueries({queryKey:["organic-competitors",t?.id]})},onError:s=>i.error(s.message)}),$=u({mutationFn:s=>D({data:{workspaceId:t.id,id:s}}),onSuccess:()=>c.invalidateQueries({queryKey:["organic-competitors",t?.id]})}),I=u({mutationFn:s=>U({data:{workspaceId:t.id,competitorId:s}}),onSuccess:s=>{i.success(`Ingested ${s.ingested} post(s)`),c.invalidateQueries({queryKey:["organic-competitor-posts"]})},onError:s=>i.error(s.message)}),G=u({mutationFn:s=>B({data:{workspaceId:t.id,postId:s}}),onSuccess:()=>{i.success("Added to hook bank"),c.invalidateQueries({queryKey:["organic-competitor-posts"]})},onError:s=>i.error(s.message)}),[f,q]=r.useState(""),[T,O]=r.useState(""),[w,z]=r.useState(""),N=u({mutationFn:()=>R({data:{workspaceId:t.id,competitorId:m,caption:f,postUrl:T||void 0,views:w?Number(w):void 0}}),onSuccess:()=>{i.success("Post ingested + hook extracted"),q(""),O(""),z(""),c.invalidateQueries({queryKey:["organic-competitor-posts"]})},onError:s=>i.error(s.message)});return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 flex-wrap",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-semibold tracking-tight",children:"Organic Competitors"}),e.jsx("p",{className:"text-sm text-muted-foreground max-w-2xl",children:"Track what's working for competitors. Add handles, paste standout post captions, and promote the winning hooks straight into your hook bank."})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(a,{asChild:!0,variant:"outline",size:"sm",children:e.jsx(L,{to:"/organic",children:"Matrix"})}),e.jsx(a,{asChild:!0,variant:"outline",size:"sm",children:e.jsx(L,{to:"/organic-hook-lab",children:"Hook Lab"})})]})]}),e.jsxs("div",{className:"rounded-lg border p-4 space-y-3",children:[e.jsx("div",{className:"text-sm font-semibold",children:"Add competitor"}),e.jsxs("div",{className:"flex gap-2 flex-wrap items-center",children:[e.jsxs(Z,{value:C,onValueChange:s=>W(s),children:[e.jsx(ee,{className:"w-[140px] h-9",children:e.jsx(se,{})}),e.jsxs(te,{children:[e.jsx(y,{value:"instagram",children:"Instagram"}),e.jsx(y,{value:"tiktok",children:"TikTok"}),e.jsx(y,{value:"youtube",children:"YouTube"})]})]}),e.jsx(h,{placeholder:"handle (without @)",value:g,onChange:s=>S(s.target.value),className:"w-[220px] h-9"}),e.jsx(h,{placeholder:"display name (optional)",value:b,onChange:s=>F(s.target.value),className:"w-[220px] h-9"}),e.jsxs(a,{size:"sm",onClick:()=>_.mutate(),disabled:!t||!g.trim()||_.isPending,children:[_.isPending?e.jsx(E,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(ae,{className:"h-3.5 w-3.5"})," Add"]})]})]}),x.isLoading?e.jsx(K,{className:"h-32 w-full"}):e.jsxs("div",{className:"rounded-lg border",children:[e.jsx("div",{className:"p-3 text-xs font-medium text-muted-foreground border-b",children:"Competitors"}),e.jsxs("div",{className:"divide-y",children:[(x.data?.competitors??[]).length===0&&e.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"None yet — add one above."}),(x.data?.competitors??[]).map(s=>e.jsxs("div",{className:"p-3 flex items-center gap-3 flex-wrap",children:[e.jsx(p,{variant:"outline",children:s.platform}),e.jsxs("div",{className:"font-medium",children:["@",s.handle]}),s.display_name&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s.display_name}),s.last_scraped_at&&e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Last: ",new Date(s.last_scraped_at).toLocaleDateString()]}),e.jsxs("div",{className:"ml-auto flex gap-2",children:[e.jsx(a,{size:"sm",variant:"outline",onClick:()=>P(s.id),children:"View posts"}),e.jsxs(a,{size:"sm",variant:"outline",onClick:()=>I.mutate(s.id),disabled:I.isPending,children:[e.jsx(oe,{className:"h-3.5 w-3.5"})," Scrape"]}),e.jsx(a,{size:"sm",variant:"ghost",onClick:()=>$.mutate(s.id),children:e.jsx(re,{className:"h-3.5 w-3.5"})})]})]},s.id))]})]}),m&&e.jsxs("div",{className:"rounded-lg border p-4 space-y-3",children:[e.jsx("div",{className:"text-sm font-semibold",children:"Add post manually (paste caption)"}),e.jsx(ie,{placeholder:"Paste the post's caption…",value:f,onChange:s=>q(s.target.value),rows:4}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx(h,{placeholder:"post URL (optional)",value:T,onChange:s=>O(s.target.value),className:"w-[280px] h-9"}),e.jsx(h,{placeholder:"views",value:w,onChange:s=>
1z(s.target.value),className:"w-[120px] h-9"}),e.jsxs(a,{size:"sm",onClick:()=>N.mutate(),disabled:N.isPending||f.length<3,children:[N.isPending?e.jsx(E,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(ne,{className:"h-3.5 w-3.5"})," Extract hook"]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-sm font-semibold",children:"Posts"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(a,{size:"sm",variant:v?"default":"outline",onClick:()=>Y(s=>!s),children:"Outliers only"}),m&&e.jsx(a,{size:"sm",variant:"ghost",onClick:()=>P(null),children:"Clear filter"})]})]}),j.isLoading?e.jsx(K,{className:"h-64 w-full"}):e.jsxs("div",{className:"rounded-lg border divide-y",children:[(j.data?.posts??[]).length===0&&e.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"No posts yet."}),(j.data?.posts??[]).map(s=>e.jsxs("div",{className:"p-3 space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.is_outlier&&e.jsxs(p,{className:"bg-emerald-500/15 text-emerald-600",children:["Outlier ",s.engagement_ratio,"x"]}),s.angle_guess&&e.jsx(p,{variant:"outline",children:s.angle_guess}),s.format_guess&&e.jsx(p,{variant:"outline",children:s.format_guess}),s.views!=null&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:[s.views.toLocaleString()," views"]}),s.post_url&&e.jsxs("a",{href:s.post_url,target:"_blank",rel:"noreferrer",className:"text-xs text-muted-foreground inline-flex items-center gap-1 hover:underline",children:[e.jsx(le,{className:"h-3 w-3"})," open"]}),e.jsx("div",{className:"ml-auto",children:s.promoted_to_hook_bank?e.jsx(p,{variant:"secondary",children:"In hook bank"}):e.jsx(a,{size:"sm",variant:"outline",onClick:()=>G.mutate(s.id),disabled:!s.extracted_hook,children:"Add to hook bank"})})]}),s.extracted_hook&&e.jsxs("div",{className:"text-sm font-medium",children:['"',s.extracted_hook,'"']}),s.caption&&e.jsx("div",{className:"text-xs text-muted-foreground line-clamp-2",children:s.caption})]},s.id))]})]})}export{ve as component};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.