PageSourceSearch

https://thetool.company/_next/static/chunks/0a075htywsmp6.js

js thetool.company collected 2026-10-02 01:54:41 UTC 83,023 bytes, 1 lines download raw bytes

1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,90267,391435,268252,246314,e=>{"use strict";var t=e.i(494913),n=e.i(843476),r=e.i(271645),i=e.i(686311),a=e.i(102008),o=e.i(514764),l=e.i(248256),s=e.i(431343),c=e.i(778917),m=e.i(941388),u=e.i(555436),d=e.i(430172),p=e.i(37727),h=e.i(541071),f=e.i(788699),g=e.i(373375),x=e.i(463059),y=e.i(178583),b=e.i(400417),v=e.i(463415),N=e.i(852917),U=e.i(846696),j=e.i(362597),w=e.i(127341),C=e.i(974841),k=e.i(916371),P=e.i(647163),I=e.i(934296),S=e.i(618548),_=e.i(182082),T=e.i(514511),L=e.i(965627),R=e.i(548106),E=e.i(920755);let A=new Map,$=new Map,D=null,F=null;function M(e,t,n){let r=e.get(t);r?r.add(n):e.set(t,new Set([n]))}function O(e,t,n){let r=e.get(t);r&&(r.delete(n),0===r.size&&e.delete(t))}let z=new Map,B=new Map;function K(e,t){return`li-posts:profile:${e}:${t}`}function W(e){return`li-posts:company:${e}`}function V(e){let t=z.get(e);return t?Date.now()-t.timestamp>12e4?(z.delete(e),null):t:null}function q(e,t="posts"){return V(K(e,t))}function H(e){return V(W(e))}function J(e){if(e.length)try{fetch("/api/linkedin/posts/cache",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({posts:e.map(e=>({...e,raw:void 0}))})}).catch(()=>{})}catch{}}async function G(e,t,n){let r=await (0,S.fetchLinkedInPosts)({profileUrn:e,count:n,kind:t});if(!r.ok)return null;let i=(0,T.decodePostsResponse)(r.data),a={posts:i.posts,paginationToken:i.paginationToken,timestamp:Date.now()};return z.set(K(e,t),a),J(i.posts),a}async function X(e,t){let n=await (0,S.fetchLinkedInPosts)({organizationalPageUrn:e,count:t});if(!n.ok)return null;let r=(0,T.decodePostsResponse)(n.data),i={posts:r.posts,paginationToken:r.paginationToken,timestamp:Date.now()};return z.set(W(e),i),J(r.posts),i}function Q(e){let t=e.kind??"posts",n=K(e.profileUrn,t),r=V(n);if(r)return Promise.resolve(r);let i=B.get(n);if(i)return i;let a=G(e.profileUrn,t,e.count??10).catch(()=>null).finally(()=>B.delete(n));return B.set(n,a),a}function Y(e){let t=W(e.organizationalPageUrn),n=V(t);if(n)return Promise.resolve(n);let r=B.get(t);if(r)return r;let i=X(e.organizationalPageUrn,e.count??20).catch(()=>null).finally(()=>B.delete(t));return B.set(t,i),i}e.s(["ensureLinkedInCompanyPosts",0,Y,"ensureLinkedInProfilePosts",0,Q,"getCachedCompanyPosts",0,H,"getCachedProfilePosts",0,q,"prefetchLinkedInCompanyPosts",0,function(e){(0,S.isExtensionInstalled)()&&Y(e)},"prefetchLinkedInProfilePosts",0,function(e){(0,S.isExtensionInstalled)()&&Q(e)}],391435);var Z=e.i(640223),ee=e.i(694533),et=e.i(465989),en=e.i(341256),er=e.i(783618),ei=e.i(609216);function ea(e){try{fetch("/api/linkedin/posts/cache",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).catch(()=>{})}catch{}}function eo(e,t,r){let i=e||"Contact",a=r?.alreadyThere?`${i} is already in Everything`:`Saved ${i} to Everything`;U.toast.custom(()=>(0,n.jsxs)("div",{className:"flex w-full min-w-0 items-center gap-3 rounded-lg border border-border bg-popover px-4 py-3 text-sm text-popover-foreground shadow-lg",children:[(0,n.jsx)("span",{className:"min-w-0 flex-1 leading-snug",children:a}),(0,n.jsx)("a",{href:`/people/${t}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex shrink-0 text-ring transition-opacity hover:opacity-80","aria-label":"Open profile",children:(0,n.jsx)(Z.SidebarForwardArrowIcon,{})})]}),{duration:r?.alreadyThere?3500:5e3})}function el(e,t){let n=0,r="",i=[];for(let a of t.filter(e=>!!e.linkedin_profile_urn&&!!e.display_name).map(t=>({name:t.display_name,urn:t.linkedin_profile_urn,pos:e.indexOf(`@${t.display_name}`,0)})).filter(e=>e.pos>=0).sort((e,t)=>e.pos-t.pos)){let t=e.indexOf(`@${a.name}`,n);if(t<0)continue;let o=(r+=e.slice(n,t)).length;r+=a.name,i.push({start:o,length:a.name.length,detailDataUnion:{profileMention:a.urn},$type:"com.linkedin.voyager.dash.common.text.TextAttribute"}),n=t+1+a.name.length}return{text:r+=e.slice(n),attributesV2:i}}function es(e){let t=e?.trim();return t&&t.startsWith("urn:")?(0,ee.normalizeLinkedinProfileUrnForMatch)(t)||t:null}function ec(e,t){if(e.linkedin_urn){let n=(0,ee.trimLinkedinUrn)(e.linkedin_urn),r=es(n)||n;t.set(r,e);let i=(0,ee.personUrnLookupKey)(r);i&&t.set(i,e)}let n=(0,et.linkedinInProfileSlug)(e.linkedin_url);for(let r of(n&&(t.set(`in:${n}`,e),t.set((0,et.canonicalHttpsLinkedinInUrl)(n),e)),[e.linkedin_id,e.linkedin_urn,e.linkedin_url])){if(!r)continue;let n=(0,ee.extractLinkedinProfileOpaqueId)(r);if(n&&n.length>=8){let r=(0,ee.personUrnLookupKey)(`urn:li:fsd_profile:${n}`);r&&t.set(r,e);break}}let r=(e.linkedin_id||"").trim();/^\d+$/.test(r)&&t.set(`member:${r}`,e)}let em=(0,r.createContext)({lookup:()=>null,register:()=>{},markAdded:()=>{}});function eu(){return(0,r.useContext)(em)}function ed({children:e,knownContactSeed:t}){let[i,a]=(0,r.useState)(new Map),o=(0,r.useRef)(new Set),l=(0,r.useRef)(new Set),s=(0,r.useRef)(new Set),c=(0,r.useRef)(new Set),m=(0,r.useRef)([]),u=(0,r.useRef)([]),d=(0,r.useRef)(null),p=(0,r.useRef)(0);(0,r.useEffect)(()=>
1{if(!t)return;a(e=>{let n=new Map(e);return ec(t,n),n});let e=es(t.linkedin_urn);e&&o.current.add(e);let n=(0,et.canonicalLinkedinProfileUrlFromVanityOrUrl)(t.linkedin_url);n&&l.current.add(n)},[t?.id,t?.linkedin_urn,t?.linkedin_url,t?.linkedin_id]);let h=(0,r.useCallback)(async()=>{d.current=null;let e=[...m.current],t=[...u.current];if(m.current=[],u.current=[],s.current.clear(),c.current.clear(),0===e.length&&0===t.length)return;let n=()=>{if(!(p.current>=5)){for(let t of(p.current+=1,e))o.current.has(t)||s.current.has(t)||(s.current.add(t),m.current.push(t));for(let e of t)l.current.has(e)||c.current.has(e)||(c.current.add(e),u.current.push(e));(m.current.length||u.current.length)&&(d.current=setTimeout(h,400+200*p.current))}};try{let r=await fetch("/api/contacts/known-linkedin",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({urns:e,linkedinUrls:t})});if(!r.ok)return void n();let i=await r.json(),s=new Map;if(i.contactsByUrn)for(let[e,t]of Object.entries(i.contactsByUrn))s.set(e,t),ec(t,s);if(i.contactsByLinkedinUrl)for(let[e,t]of Object.entries(i.contactsByLinkedinUrl))s.set(e,t),ec(t,s);for(let t of(s.size&&a(e=>{let t=new Map(e);for(let[e,n]of s)t.set(e,n);return t}),e))o.current.add(t);for(let e of t)l.current.add(e);p.current=0}catch{n()}},[]),f=(0,r.useCallback)(e=>{let t=!1;for(let n of e){let e=es(n.urn)||n.urn?.trim();e&&e.startsWith("urn:")&&!o.current.has(e)&&!s.current.has(e)&&(s.current.add(e),m.current.push(e),t=!0);let r=(0,et.canonicalLinkedinProfileUrlFromVanityOrUrl)(n.vanityName);!r||l.current.has(r)||c.current.has(r)||(c.current.add(r),u.current.push(r),t=!0)}t&&(d.current&&clearTimeout(d.current),d.current=setTimeout(h,80))},[h]);(0,r.useEffect)(()=>()=>{d.current&&clearTimeout(d.current)},[]);let g=(0,r.useCallback)(e=>{let t=e.urn?.trim(),n=t?.startsWith("urn:")?es(t)||(0,ee.trimLinkedinUrn)(t):null;if(n){let e=(0,ee.extractLinkedinMemberNumericId)(n);if(e){let t=i.get(`member:${e}`);if(t)return t}let t=(0,ee.trimLinkedinUrn)(n),r=i.get(t);if(r)return r;let a=(0,ee.personUrnLookupKey)(t);if(a){let e=i.get(a);if(e)return e}}let r=(0,et.canonicalLinkedinProfileUrlFromVanityOrUrl)(e.vanityName);if(r){let e=i.get(r);if(e)return e}let a=(0,et.linkedinInProfileSlug)(e.vanityName);if(a){let e=i.get(`in:${a}`);if(e)return e}return null},[i]),x=(0,r.useCallback)((e,t)=>{let n=es(e.urn)||e.urn?.trim();n&&n.startsWith("urn:")&&o.current.add(n);let r=(0,et.canonicalLinkedinProfileUrlFromVanityOrUrl)(e.vanityName);r&&l.current.add(r),a(i=>{let a=new Map(i);if(ec(t,a),n&&n.startsWith("urn:")){let e=(0,ee.trimLinkedinUrn)(n);a.set(e,t);let r=(0,ee.personUrnLookupKey)(n);r&&a.set(r,t);let i=(0,ee.extractLinkedinMemberNumericId)(n);i&&a.set(`member:${i}`,t)}r&&a.set(r,t);let o=(0,et.linkedinInProfileSlug)(e.vanityName);return o&&a.set(`in:${o}`,t),a})},[]),y=(0,r.useMemo)(()=>({lookup:g,register:f,markAdded:x}),[g,f,x]);return(0,n.jsx)(em.Provider,{value:y,children:e})}let ep=[{id:"posts",label:"Posts"},{id:"comments",label:"Comments"},{id:"reactions",label:"Reactions"},{id:"videos",label:"Videos"},{id:"images",label:"Images"},{id:"articles",label:"Articles"},{id:"documents",label:"Documents"}];function eh(e){let t=e=>e.ugcPostUrn||e.socialDetailUrn||e.urn,n=new Map;for(let r of e){let e=t(r),i=n.get(e);if(!i){n.set(e,r);continue}let a=new Set(i.inlineComments.map(e=>e.commentUrn).filter(Boolean));for(let e of r.inlineComments)e.commentUrn&&!a.has(e.commentUrn)&&(i.inlineComments.push(e),a.add(e.commentUrn))}return[...n.values()]}function ef({profileUrn:e,organizationalPageUrn:t}){let{register:i}=eu(),[a,o]=(0,r.useState)([]),[l,s]=(0,r.useState)(!0),[c,m]=(0,r.useState)(null),[h,f]=(0,r.useState)(null),g=(0,_.useExtensionStatus)(),[x,y]=(0,r.useState)("posts"),[b,v]=(0,r.useState)(!1),[U,j]=(0,r.useState)(""),[C,k]=(0,r.useState)(!1),P=e||t,I=!!e,L=(0,r.useCallback)(async(n,r)=>{if(!P)return;s(!0),m(null);let i=r??x,a="comments"===i?"comments":"reactions"===i?"reactions":"posts";if(!n){let n=e?q(e,a):t?H(t):null;if(n){o(eh(n.posts)),f(n.paginationToken),s(!1);return}}let l=await (0,S.fetchLinkedInPosts)({profileUrn:e||void 0,organizationalPageUrn:t||void 0,count:10,paginationToken:n,kind:a});if(!l.ok){m(l.error||"Failed to fetch posts"),s(!1);return}let c=(0,T.decodePostsResponse)(l.data);o(e=>eh(n?[...e,...c.posts]:c.posts)),f(c.paginationToken),s(!1),c.posts.length&&ea({posts:c.posts.map(e=>({...e,raw:void 0}))})},[e,t,P,x]);if((0,r.useEffect)(()=>{!P||["posts","comments","reactions"].includes(x)&&(o([]),f(null),L())},[P,x]),(0,r.useEffect)(()=>{let e=a.map(e=>({vanityName:e.author?.vanityName??null,urn:e.author?.urn??null})).filter(e=>e.urn||e.vanityName);e.length&&i(e)},[a,i]),!P)return(0,n.jsxs)("div",{className:"rounded-xl border border-border bg-card p-8 text-center text-sm text-muted-foreground",children:["No LinkedIn URN on this ",void 0!==e?"contact":"company"," yet. Enrich them once via the extension and posts will appear here."]});let R=function(e,t){switch(t){case"posts":case"comments":case"reactions":return e;case"videos":return e.filter(e=>e.media.some(e=>"video"===e.type));case"images":return e.filter(e=>e.media.some(e=>"image"===e.type));case"articles":return e.filter(e=>e.media.some(e=>"article"===e.type));case"documents":return e.filter(e=>e.media.some(e=>"document"===e.type));default:return[]}}(a,x),E=U.trim().toLowerCase(),A=E?R.filter(e=>[e.text||"",e.author?.name||"",e.author?.headline||"",e.resharedPost?.text||"",e.resharedPost?.author?.name||""].join(" ").toLowerCase().includes(E)):R,$="posts"!==x&&"comments"!==x&&"reactions"!==x&&a.length>0&&0===R.length,D=(0,n.jsxs)("div",{className:"flex items-center gap-2 px-3 pt-3 pb-2 border-b border-border",children:[I?(0,n.jsx)("div",{className:"min-w-0 flex-1 overflow-x-auto scrollbar-none",children:(0,n.jsx)(w.Tabs,{value:x,onValueChange:e=>y(e),children:(0,n.jsx)(w.TabsList,{children:ep.map(e=>(0,n.jsx)(w.TabsTrigger,{value:e.id,children:e.label},e.id))})})}):(0,n.jsx)("div",{className:"flex-1"}),(0,n.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[!g.localInstalled&&!g.loading&&(0,n.jsxs)("span",{className:`${(0,er.tonePillClass)("attention")} hidden sm:inline-flex`,title:"LinkedIn calls route through your desktop chrome extension. Open your desktop browser for faster responses.",children:[(0,n.jsx)("span",{className:"size-1.5 rounded-full bg-amber-500 animate-pulse"}),"via desktop"]}),b?(0,n.jsxs)("div",{className:"flex items-center gap-1 rounded-full bg-muted/60 px-2 py-1",children:[(0,n.jsx)(u.Search,{className:"size-3.5 text-muted-foreground"}),(0,n.jsx)("input",{autoFocus:!0,value:U,onChange:e=>j(e.target.value),onKeyDown:e=>{"Escape"===e.key&&(j(""),v(!1))},placeholder:"Search…",className:"bg-transparent outline-none text-xs w-32 placeholder:text-muted-foreground"}),(0,n.jsx)("button",{type:"button",onClick:()=>{j(""),v(!1)},className:"text-muted-foreground hover:text-foreground","aria-label":"Close search",children:(0,n.jsx)(p.X,{className:"size-3.5"})})]}):(0,n.jsx)("button",{type:"button",onClick:()=>v(!0),className:"size-8 rounded-full flex items-center justify-center text-muted-foreground hover:text-foreground hover:bg-accent transition","aria-label":"Search posts",title:"Search",children:(0,n.jsx)(u.Search,{className:"size-4"})}),!C&&(0,n.jsx)("button",{type:"button",onClick:()=>k(!0),className:"size-8 rounded-full flex items-center justify-center text-muted-foreground hover:text-foreground hover:bg-accent transition","aria-label":"Open side panel",title:"Open in side panel",children:(0,n.jsx)(d.PanelRightOpen,{className:"size-4"})})]})]});return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"rounded-xl border border-border bg-card overflow-hidden",children:[D,(0,n.jsxs)("div",{className:"p-3 space-y-3",children:[c&&(0,n.jsx)("div",{className:"rounded-xl border border-destructive/30 bg-destructive/5 px-4 py-3 text-sm text-destructive",children:c}),l&&0===a.length&&(0,n.jsx)("div",{className:"space-y-3",children:[1,2,3].map(e=>(0,n.jsxs)("div",{className:"rounded-[20px] border border-card-border bg-[#FAF9F5] dark:bg-card p-4 space-y-3",children:[(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsx)("div",{className:"h-12 w-12 squircle bg-muted animate-pulse"}),(0,n.jsxs)("div",{className:"space-y-2 flex-1",children:[(0,n.jsx)("div",{className:"h-3 w-32 bg-muted animate-pulse rounded"}),(0,n.jsx)("div",{className:"h-2 w-48 bg-muted animate-pulse rounded"})]})]}),(0,n.jsx)("div",{className:"h-3 w-full bg-muted animate-pulse rounded"}),(0,n.jsx)("div",{className:"h-3 w-5/6 bg-muted animate-pulse rounded"})]},e))}),!l&&!c&&0===A.length&&(0,n.jsxs)("div",{className:"rounded-[20px] border border-card-border bg-[#FAF9F5] dark:bg-card p-8 text-center text-sm text-muted-foreground",children:["comments"===x&&"No comments yet.","reactions"===x&&"No reactions yet.","posts"===x&&"No posts found.",("videos"===x||"images"===x||"articles"===x||"documents"===x)&&($?`No ${x} in their authored posts.`:"No posts found.")]}),A.map(e=>(0,n.jsx)(ey,{post:e},e.urn)),h&&(0,n.jsx)("button",{onClick:()=>L(h),disabled:l,className:"w-full rounded-full border border-border bg-card px-4 py-2 text-sm hover:bg-accent disabled:opacity-50 transition",children:l?"Loading…":"comments"===x?"Load more comments":"reactions"===x?"Load more reactions":"Load more posts"})]})]}),(0,n.jsx)(N.Sheet,{open:C,onOpenChange:k,children:(0,n.jsxs)(N.SheetContent,{side:"right",showCloseButton:!0,className:"!max-w-[min(98vw,900px)] w-full p-0 gap-0 flex flex-col",children:[(0,n.jsx)(N.SheetTitle,{className:"sr-only",children:"LinkedIn feed"}),(0,n.jsxs)("div",{className:"flex items-center gap-2 px-4 pt-3 pb-2 border-b border-border pr-12",children:[I?(0,n.jsx)("div",{className:"min-w-0 flex-1 overflow-x-auto scrollbar-none",children:(0,n.jsx)(w.Tabs,{value:x,onValueChange:e=>y(e),children:(0,n.jsx)(w.TabsList,{children:ep.map(e=>(0,n.jsx)(w.TabsTrigger,{value:e.id,children:e.label},`m-${e.id}`))})})}):(0,n.jsx)("div",{className:"flex-1"}),(0,n.jsx)("div",{className:"flex items-center gap-1 shrink-0",children:(0,n.jsxs)("div",{className:"flex items-center gap-1 search-pill roun
1ded-full border bg-white border-[oklch(0.85_0.01_60)] dark:bg-black dark:border-transparent px-2 py-1",children:[(0,n.jsx)(u.Search,{className:"size-3.5 text-muted-foreground"}),(0,n.jsx)("input",{value:U,onChange:e=>j(e.target.value),placeholder:"Search…",className:"bg-transparent outline-none text-xs w-36 placeholder:text-muted-foreground"}),U&&(0,n.jsx)("button",{type:"button",onClick:()=>j(""),className:"text-muted-foreground hover:text-foreground","aria-label":"Clear search",children:(0,n.jsx)(p.X,{className:"size-3.5"})})]})})]}),(0,n.jsxs)("div",{className:"flex-1 overflow-y-auto p-4 space-y-3",children:[0===A.length&&!l&&(0,n.jsx)("div",{className:"rounded-[20px] border border-card-border bg-[#FAF9F5] dark:bg-card p-8 text-center text-sm text-muted-foreground",children:E?`No posts matching "${E}".`:"No posts found."}),A.map(e=>(0,n.jsx)(ey,{post:e},`m-${e.urn}`)),h&&(0,n.jsx)("button",{onClick:()=>L(h),disabled:l,className:"w-full rounded-full border border-border bg-card px-4 py-2 text-sm hover:bg-accent disabled:opacity-50 transition",children:l?"Loading…":"comments"===x?"Load more comments":"reactions"===x?"Load more reactions":"Load more posts"})]})]})})]})}function eg(e,t){return!e.parentCommentUrn||!t.some(t=>(0,T.commentUrnEquals)(t.commentUrn,e.parentCommentUrn))}async function ex(e,{maxPages:t=10,pageSize:n=20}={}){let r=new Set,i=[],a=e=>{for(let t of e){let e=(0,T.commentIdentityKey)(t.commentUrn)||t.commentUrn;!e||r.has(e)||(r.add(e),i.push(t))}},o=t=>t.filter(t=>!(0,T.commentUrnEquals)(t.commentUrn,e)).map(t=>({...t,parentCommentUrn:(0,T.parentCommentUrnForReplyFetch)(t.parentCommentUrn,e)})),l=await (0,S.fetchLinkedInCommentReplies)({commentUrn:e,count:n});if(!l.ok)return i;let s=(0,T.decodeCommentsResponse)(l.data);a(o(s.comments));let c=s.replyPreviousCursor;for(let r=0;r<t&&c;r++){let t=await (0,S.fetchLinkedInCommentReplies)({commentUrn:e,count:n,cursor:c});if(!t.ok)break;let r=(0,T.decodeCommentsResponse)(t.data);if(a(o(r.comments)),!r.replyPreviousCursor||r.replyPreviousCursor===c)break;c=r.replyPreviousCursor}let m=s.replyNextCursor;for(let r=0;r<t&&m;r++){let t=await (0,S.fetchLinkedInCommentReplies)({commentUrn:e,count:n,cursor:m});if(!t.ok)break;let r=(0,T.decodeCommentsResponse)(t.data);if(a(o(r.comments)),!r.replyNextCursor||r.replyNextCursor===m)break;m=r.replyNextCursor}return i}function ey({post:e,rank:t,engagementPoints:s,kindPill:m,surface:u="oat",previewMode:d=!1,platformTag:p,initialShowComments:h=!1,contextSlot:f}){let g,x,{lookup:y,register:v}=eu(),[N,j]=(0,r.useState)(!1),[w,k]=(0,r.useState)(h),[I,_]=(0,r.useState)([]),[L,z]=(0,r.useState)(()=>(0,T.inferCommentParentsFromUrns)([...e.inlineComments||[]])),B=(0,r.useMemo)(()=>(0,T.dropSupersededOptimisticComments)(L),[L]),[K,W]=(0,r.useState)(!1),[V,q]=(0,r.useState)(!1),[H,J]=(0,r.useState)(null),[G,X]=(0,r.useState)(null),[Q,Y]=(0,r.useState)(null),[Z,ee]=(0,r.useState)(!1),[et,en]=(0,r.useState)(!1),[er,ei]=(0,r.useState)(e.reactionsCount);(0,r.useEffect)(()=>{ei(e.reactionsCount)},[e.reactionsCount]),function({postUrn:e,enabled:t=!0,onComment:n,onReactor:i}){let a=(0,r.useRef)(n);a.current=n;let o=(0,r.useRef)(i);o.current=i,(0,r.useEffect)(()=>{if(t&&e){var n,r;return n=(e,t)=>{e.comment_urn&&a.current?.({commentUrn:e.comment_urn,parentCommentUrn:e.parent_comment_urn,commenter:{urn:e.commenter_profile_urn,name:e.commenter_name,headline:e.commenter_headline,vanityName:e.commenter_vanity,pictureUrl:e.commenter_picture_url},text:e.text,attributes:Array.isArray(e.mentions)?e.mentions:[],mentions:[],reactionsCount:e.reactions_count??0,repliesCount:e.replies_count??0,postedAt:e.posted_at?new Date(e.posted_at).getTime():null,pinned:!!e.is_pinned,actions:[],viewerReaction:null,raw:null},t)},r=(e,t)=>{e.reactor_profile_urn&&o.current?.({reactorUrn:e.reactor_profile_urn,reactionType:e.reaction_type,name:e.reactor_name,headline:e.reactor_headline,vanityName:e.reactor_vanity,pictureUrl:e.reactor_picture_url},t)},M(A,e,n),M($,e,r),F&&(clearTimeout(F),F=null),D||(D=(0,E.createClient)().channel("post-engagement").on("postgres_changes",{event:"*",schema:"public",table:"linkedin_post_comments"},e=>{if("INSERT"!==e.eventType&&"UPDATE"!==e.eventType)return;let t=e.new;if(!t?.post_urn)return;let n=A.get(t.post_urn);if(n)for(let r of n)r(t,e.eventType)}).on("postgres_changes",{event:"*",schema:"public",table:"linkedin_post_reactions"},e=>{if("INSERT"!==e.eventType&&"UPDATE"!==e.eventType)return;let t=e.new;if(!t?.post_urn)return;let n=$.get(t.post_urn);if(n)for(let r of n)r(t,e.eventType)}).subscribe()),()=>{O(A,e,n),O($,e,r),A.size>0||$.size>0||F||(F=setTimeout(()=>{if(F=null,A.size>0||$.size>0)return;let e=D;D=null,e&&(0,E.createClient)().removeChannel(e)},1e4))}}},[e,t])}({postUrn:d?null:e.urn,onComment:e=>{z(t=>{let n=(0,T.commentIdentityKey)(e.commentUrn)||e.commentUrn;return t.some(e=>((0,T.commentIdentityKey)(e.commentUrn)||e.commentUrn)===n)?t.map(t=>((0,T.commentIdentityKey)(t.commentUrn)||t.commentUrn)===n?e:t):(0,T.inferCommentParentsFromUrns)([...t,e])})},onReactor:e=>{_(t=>t.some(t=>t.reactorUrn===e.reactorUrn)?t.map(t=>t.reactorUrn===e.reactorUrn?e:t):[...t,e])}}),(0,r.useEffect)(()=>{let t=[];if((e.author?.urn||e.author?.vanityName)&&t.push({vanityName:e.author.vanityName,urn:e.author.urn}),e.resharedPost?.author?.urn||e.resharedPost?.author?.vanityName){let n=e.resharedPost.author;t.push({vanityName:n.vanityName,urn:n.urn})}for(let e of L)for(let n of((e.commenter?.urn||e.commenter?.vanityName)&&t.push({vanityName:e.commenter.vanityName,urn:e.commenter.urn}),e.mentions||[]))(n.urn||n.vanityName)&&t.push({vanityName:n.vanityName,urn:n.urn});t.length&&v(t)},[v,e.urn,e.author?.urn,e.author?.vanityName,e.resharedPost?.author?.urn,e.resharedPost?.author?.vanityName,L]);let eo=async t=>{if(!e.ugcPostUrn)return;W(!0);let n=async e=>{let n=await (0,S.fetchLinkedInPostReactions)({threadUrn:e,count:50,paginationToken:t});return n.ok?(0,T.decodeReactionsResponse)(n.data):null},r=await n(e.ugcPostUrn);if(r&&0===r.reactors.length&&e.reactionsCount>0&&e.ugcPostUrn!==e.urn){let t=await n(e.urn);t&&t.reactors.length&&(r=t)}if(r){let n=r.reactors,i=!1;_(e=>{if(!t)return n;let r=new Set(e.map(e=>
1e.reactorUrn).filter(Boolean)),a=n.filter(e=>!e.reactorUrn||!r.has(e.reactorUrn));return i=n.length>0&&0===a.length,a.length?[...e,...a]:e}),J(0===n.length||i||t&&r.paginationToken===t?null:r.paginationToken);let a=n.map(e=>({vanityName:e.vanityName??null,urn:e.reactorUrn??null})).filter(e=>e.urn||e.vanityName);a.length&&v(a),n.length&&ea({reactions:{postUrn:e.urn,reactors:n}})}W(!1)},el=async t=>{if(!e.socialDetailUrn)return;q(!0);let n=await (0,S.fetchLinkedInPostComments)({socialDetailUrn:e.socialDetailUrn,count:50,numReplies:3,sortOrder:"RELEVANCE",paginationToken:t});if(n.ok){let r=(0,T.decodeCommentsResponse)(n.data),i=[...r.comments].filter(e=>e.repliesCount>0).sort((e,t)=>Number(!!e.parentCommentUrn)-Number(!!t.parentCommentUrn)),a=(await Promise.all(i.slice(0,25).map(e=>ex(e.commentUrn)))).flat(),o=new Map,l=e=>{let t=(0,T.commentIdentityKey)(e.commentUrn)||e.commentUrn,n=o.get(t);n&&(n.parentCommentUrn||!e.parentCommentUrn)||o.set(t,e)};for(let e of r.comments)l(e);for(let e of a)l(e);let s=(0,T.inferCommentParentsFromUrns)(Array.from(o.values())),c={list:[]};z(e=>(c.list=function(e,t,n){if(!n){let n=new Map,r=e=>{let t=(0,T.commentIdentityKey)(e.commentUrn)||e.commentUrn,r=n.get(t);r&&(r.parentCommentUrn||!e.parentCommentUrn)||n.set(t,e)};for(let e of t)r(e);for(let t of e){let e=(0,T.commentIdentityKey)(t.commentUrn)||t.commentUrn;n.has(e)||n.set(e,t)}let i=Array.from(n.values());return(0,T.inferCommentParentsFromUrns)(i)}let r=new Map;for(let t of e){let e=(0,T.commentIdentityKey)(t.commentUrn)||t.commentUrn;r.set(e,t)}for(let e of t){let t=(0,T.commentIdentityKey)(e.commentUrn)||e.commentUrn,n=r.get(t);n&&(n.parentCommentUrn||!e.parentCommentUrn)||r.set(t,e)}let i=Array.from(r.values());return(0,T.inferCommentParentsFromUrns)(i)}(e,s,t),c.list));let m=r.paginationToken;X(t&&r.comments.length>0&&r.comments.every(e=>L.some(t=>t.commentUrn===e.commentUrn))||0===r.comments.length?null:m);let u=[];for(let e of c.list)for(let t of((e.commenter?.urn||e.commenter?.vanityName)&&u.push({vanityName:e.commenter.vanityName,urn:e.commenter.urn}),e.mentions||[]))(t.urn||t.vanityName)&&u.push({vanityName:t.vanityName,urn:t.urn});u.length&&v(u),c.list.length&&ea({comments:{postUrn:e.urn,comments:c.list.map(e=>({...e,raw:void 0}))}});let d=r.updatedCommentCount;"number"==typeof d&&e.urn&&fetch("/api/linkedin/posts/refresh-metrics",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({urn:e.urn,comments_count:d})}).catch(()=>{})}q(!1)},es=async t=>{if(!e.urn||Z)return;ee(!0);let n=Q===t,r=er;n?r=Math.max(0,er-1):Q||(r=er+1),ei(r),Y(n?null:t),n?fetch(`/api/linkedin/posts/optimistic-engagement?postUrn=${encodeURIComponent(e.urn)}`,{method:"DELETE"}).catch(()=>{}):fetch("/api/linkedin/posts/optimistic-engagement",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({kind:"reaction",postUrn:e.urn,reactionType:t})}).catch(()=>{});let i=n?S.unreactLinkedInPost:S.reactToLinkedInPost,a={threadUrn:e.urn,reactionType:t,backendUpdateUrn:e.urn},o=await i(a);o.ok?fetch("/api/linkedin/posts/refresh-metrics",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({urn:e.urn,reactions_count:r})}).catch(()=>{}):(Y(Q),ei(er),U.toast.error(o.error||"Failed to react")),ee(!1)},ec="white"===u?"bg-[#FAF9F5] dark:bg-card":"bg-white dark:bg-card",em=e.text||"",ed=em.length>280&&!et,ep=ed?em.slice(0,280).trimEnd()+"…":em;return(0,n.jsxs)("article",{className:(0,P.cn)("rounded-[20px] border border-card-border overflow-hidden","white"===u?"bg-white dark:bg-background":"bg-[#FAF9F5] dark:bg-background"),children:[(f||e.contextHeader)&&(0,n.jsx)("div",{className:"px-4 pt-3 pb-1 text-xs text-muted-foreground border-b border-border/40",children:f??e.contextHeader}),(0,n.jsxs)("header",{className:"flex items-start gap-3 px-4 pt-4",children:[void 0!==t&&(0,n.jsx)("span",{className:"text-sm font-semibold text-muted-foreground tabular-nums w-5 shrink-0 pt-2 text-center",children:t}),(0,n.jsx)("div",{className:"h-12 w-12 squircle overflow-hidden bg-muted shrink-0 flex items-center justify-center text-sm font-medium text-muted-foreground",children:e.author.pictureUrl?(0,n.jsx)(R.SafeImage,{src:e.author.pictureUrl,alt:"",fallback:(0,n.jsx)("span",{children:e.author.name?.[0]||"?"}),className:"h-full w-full object-cover"}):(0,n.jsx)("span",{children:e.author.name?.[0]||"?"})}),(0,n.jsxs)("div",{className:"min-w-0 flex-1 leading-tight",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("div",{className:"font-semibold text-sm truncate",children:e.author.name||"Unknown"}),m,void 0!==t&&void 0!==s&&(0,n.jsxs)("span",{className:"ml-auto text-[10px] font-semibold text-primary tabular-nums shrink-0",children:[s.toLocaleStr
1ing()," pts"]})]}),e.author.headline&&(0,n.jsx)("div",{className:"text-xs text-muted-foreground line-clamp-2 mt-0.5",children:e.author.headline}),(0,n.jsxs)("div",{className:"text-xs text-muted-foreground mt-1 flex items-center gap-1.5",children:[(0,n.jsx)("span",{children:e.postedAgeText?.trim()||""}),(0,n.jsx)(l.Globe,{className:"size-3","aria-label":"Public"})]})]}),p&&(0,n.jsx)("div",{className:"shrink-0 self-center",children:p}),!d&&!p&&(0,n.jsx)("a",{href:`https://www.linkedin.com/feed/update/${encodeURIComponent(e.urn)}/`,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground shrink-0 p-1",title:"Open on LinkedIn",children:(0,n.jsx)(c.ExternalLink,{className:"size-4"})})]}),em&&(0,n.jsxs)("div",{className:"px-4 pt-3 pb-4 text-sm leading-relaxed whitespace-pre-wrap",children:[ep,ed&&(0,n.jsx)("button",{onClick:()=>en(!0),className:"ml-1 text-muted-foreground hover:text-foreground",children:"see more"})]}),e.media.length>0&&(0,n.jsx)("div",{className:`mt-3 grid gap-1 ${1===e.media.length?"grid-cols-1":"grid-cols-2"}`,children:e.media.slice(0,4).map((t,r)=>(0,n.jsx)(eb,{media:t,singleton:1===e.media.length,postUrn:e.urn},r))}),e.resharedPost&&(0,n.jsx)("div",{className:(0,P.cn)("mx-4 mt-3 rounded-[16px] border border-card-border overflow-hidden",ec),children:(0,n.jsx)(eN,{post:e.resharedPost})}),(er>0||e.commentsCount>0||e.sharesCount>0||(e.impressionsCount??0)>0)&&(0,n.jsxs)("div",{className:"flex items-center justify-between px-4 pt-3 pb-2 text-xs text-muted-foreground",children:[(0,n.jsxs)("button",{onClick:()=>{e.ugcPostUrn?(j(e=>!e),N||0!==I.length||eo()):window.open(`https://www.linkedin.com/feed/update/${e.urn}/`,"_blank","noopener")},className:"flex items-center gap-1 hover:text-foreground",disabled:0===er,children:[(0,n.jsxs)("span",{className:"flex -space-x-1",children:[(0,n.jsx)(C.ReactionIcon,{type:"LIKE",size:16}),(0,n.jsx)(C.ReactionIcon,{type:"LOVE",size:16}),(0,n.jsx)(C.ReactionIcon,{type:"INSIGHTFUL",size:16})]}),(0,n.jsx)("span",{children:er.toLocaleString()})]}),(0,n.jsxs)("div",{className:"flex gap-3",children:[(0,n.jsxs)("button",{onClick:()=>{e.socialDetailUrn?(k(e=>!e),!w&&B.length<e.commentsCount&&el()):window.open(`https://www.linkedin.com/feed/update/${e.urn}/`,"_blank","noopener")},className:"hover:text-foreground",disabled:0===e.commentsCount,children:[e.commentsCount.toLocaleString()," comment",1===e.commentsCount?"":"s"]}),e.sharesCount>0&&(0,n.jsxs)("span",{children:[e.sharesCount.toLocaleString()," repost",1===e.sharesCount?"":"s"]}),(e.impressionsCount??0)>0&&(0,n.jsxs)("span",{children:[e.impressionsCount.toLocaleString()," impression",1===e.impressionsCount?"":"s"]})]})]}),!w&&(0===(g=B.filter(e=>eg(e,B)&&!!y({urn:e.commenter?.urn,vanityName:e.commenter?.vanityName})).slice(0,3)).length?null:(0,n.jsxs)("div",{className:"border-t border-border bg-emerald-500/5 px-4 py-3 space-y-2",children:[(0,n.jsx)("div",{className:"text-[10px] uppercase tracking-wide font-semibold text-emerald-700/80 dark:text-emerald-400/80",children:"From saved contacts"}),g.map(e=>(0,n.jsxs)("div",{className:"flex items-start gap-2",children:[(0,n.jsx)(ek,{person:e.commenter,size:"sm"}),(0,n.jsx)("div",{className:"min-w-0 flex-1",children:(0,n.jsxs)("div",{className:(0,P.cn)("rounded-[14px] [corner-shape:squircle] px-3 py-2 leading-tight",ec),children:[(0,n.jsx)("div",{className:"text-[11px] font-semibold",children:e.commenter.name||"Unknown"}),e.commenter.headline&&(0,n.jsx)("div",{className:"text-[10px] text-muted-foreground line-clamp-1",children:e.commenter.headline}),(0,n.jsx)("div",{className:"text-sm mt-1 whitespace-pre-wrap line-clamp-4",children:(0,n.jsx)(eU,{text:e.text,mentions:e.mentions})})]})})]},e.commentUrn)),e.commentsCount>g.length&&(0,n.jsxs)("button",{onClick:()=>{k(!0),B.length<e.commentsCount&&el()},className:"text-[11px] font-medium text-muted-foreground hover:text-foreground",children:["View all ",e.commentsCount," comment",1===e.commentsCount?"":"s"," →"]})]})),d&&(0,n.jsxs)("div",{"aria-hidden":!0,className:"select-none mt-auto",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-4 pt-3 pb-2 text-xs text-muted-foreground",children:[(0,n.jsxs)("span",{className:"flex items-center gap-1",children:[(0,n.jsxs)("span",{className:"flex -sp
1ace-x-1",children:[(0,n.jsx)(C.ReactionIcon,{type:"LIKE",size:16}),(0,n.jsx)(C.ReactionIcon,{type:"LOVE",size:16}),(0,n.jsx)(C.ReactionIcon,{type:"INSIGHTFUL",size:16})]}),(0,n.jsx)("span",{children:"36"})]}),(0,n.jsxs)("div",{className:"flex gap-3",children:[(0,n.jsx)("span",{children:"4 comments"}),(0,n.jsx)("span",{children:"2 reposts"})]})]}),(0,n.jsx)("div",{className:"border-t border-border px-2 pt-1.5 pb-2 flex items-center justify-around whitespace-nowrap",children:[{icon:b.ThumbsUp,label:"Like"},{icon:i.MessageSquare,label:"Comment"},{icon:a.Repeat2,label:"Repost"},{icon:o.Send,label:"Share"}].map(({icon:e,label:t})=>(0,n.jsxs)("span",{className:"flex items-center gap-1.5 rounded-full px-2.5 py-1.5 text-[13px] font-medium text-muted-foreground",children:[(0,n.jsx)(e,{className:"size-4"}),t]},t))})]}),!d&&(0,n.jsxs)("div",{className:"border-t border-border px-2 pt-2.5 pb-3.5 flex items-center gap-1 flex-wrap",children:[C.PICKABLE_REACTIONS.map(t=>{let r=Q===t;return(0,n.jsx)("button",{onClick:()=>es(t),disabled:Z||!e.ugcPostUrn,title:(0,C.reactionLabel)(t),"aria-label":(0,C.reactionLabel)(t),className:`flex items-center justify-center rounded-full transition-all duration-150 disabled:opacity-50 p-1 ${r?"ring-2 ring-offset-1 bg-accent scale-110":"hover:scale-125 hover:bg-accent/60"}`,style:r?{"--tw-ring-color":(0,C.reactionColor)(t)}:void 0,children:(0,n.jsx)(C.ReactionIcon,{type:t,size:26})},t)}),(0,n.jsx)("div",{className:"flex-1"}),(0,n.jsxs)("button",{onClick:()=>{k(e=>!e),!w&&B.length<e.commentsCount&&el()},className:"flex items-center gap-1.5 rounded-full px-3 py-1.5 text-sm text-muted-foreground hover:bg-accent hover:text-foreground transition",title:"Comment",children:[(0,n.jsx)(i.MessageSquare,{className:"size-4"}),(0,n.jsx)("span",{className:"hidden sm:inline",children:"Comment"})]}),(0,n.jsxs)("a",{href:`https://www.linkedin.com/feed/update/${encodeURIComponent(e.urn)}/`,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 rounded-full px-3 py-1.5 text-sm text-muted-foreground hover:bg-accent hover:text-foreground transition",title:"Repost on LinkedIn",children:[(0,n.jsx)(a.Repeat2,{className:"size-4"}),(0,n.jsx)("span",{className:"hidden sm:inline",children:"Repost"})]}),(0,n.jsxs)("button",{onClick:()=>{let t=`https://www.linkedin.com/feed/update/${encodeURIComponent(e.urn)}/`;try{navigator.clipboard.writeText(t),U.toast.success("Post link copied")}catch{window.open(t,"_blank")}},className:"flex items-center gap-1.5 rounded-full px-3 py-1.5 text-sm text-muted-foreground hover:bg-accent hover:text-foreground transition",title:"Copy post link",children:[(0,n.jsx)(o.Send,{className:"size-4"}),(0,n.jsx)("span",{className:"hidden sm:inline",children:"Share"})]})]}),N&&(0,n.jsxs)("div",{className:"border-t border-border px-4 py-3 space-y-2 bg-muted/30",children:[(0,n.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:"Reactions"}),K&&(0,n.jsx)(eP,{}),!K&&0===I.length&&(0,n.jsx)("div",{className:"text-xs text-muted-foreground",children:"No reactors loaded yet."}),(0,n.jsx)("ul",{className:"space-y-2",children:I.map((e,t)=>(0,n.jsxs)("li",{className:"flex items-center gap-2",children:[(0,n.jsx)(C.ReactionIcon,{type:e.reactionType,size:16}),(0,n.jsx)(ek,{person:{urn:e.reactorUrn,name:e.name,vanityName:e.vanityName,pictureUrl:e.pictureUrl},size:"sm"}),(0,n.jsxs)("div",{className:"min-w-0 flex-1 leading-tight",children:[(0,n.jsx)("div",{className:"text-xs font-medium truncate",children:e.name||"Unknown"}),e.headline&&(0,n.jsx)("div",{className:"text-[11px] text-muted-foreground truncate",children:e.headline})]})]},e.reactorUrn||t))}),H&&(0,n.jsx)("button",{onClick:()=>eo(H),disabled:K,className:"w-full mt-2 rounded-md border border-border bg-card px-3 py-1.5 text-xs hover:bg-accent disabled:opacity-50",children:K?"Loading…":"Load more reactors"})]}),w&&(0,n.jsxs)("div",{className:(0,P.cn)("border-t border-border px-4 py-3 space-y-3","white"===u?"bg-transparent dark:bg-muted/30":"bg-muted/30"),children:[(0,n.jsx)(eC,{postUrn:e.urn,ugcPostUrn:e.ugcPostUrn,onPosted:()=>el(),surfaceClass:ec}),B.length>0&&(0,n.jsx)("div",{className:"text-xs font-medium text-muted-foreground pt-1",children:"Comments"}),V&&(0,n.jsx)(eP,{}),((x=B.filter(e=>eg(e,B)).map((e,t)=>({c:e,idx:t,inRecord:!!y({urn:e.commenter?.urn,vanityName:e.commenter?.vanityName})}))).sort((e,t)=>
1e.inRecord!==t.inRecord?e.inRecord?-1:1:e.idx-t.idx),(0,n.jsx)("div",{className:"flex flex-col gap-6",children:x.map(({c:t})=>(0,n.jsx)(ew,{comment:t,allComments:B,postUrn:e.urn,ugcPostUrn:e.ugcPostUrn,onReplied:()=>el(),depth:0,chipClass:ec},(0,T.commentIdentityKey)(t.commentUrn)||t.commentUrn))})),G&&(0,n.jsx)("button",{onClick:()=>el(G),disabled:V,className:(0,P.cn)("w-full mt-1 rounded-[12px] border border-card-border px-3 py-1.5 text-xs hover:bg-accent disabled:opacity-50",ec),children:V?"Loading…":"Load more comments"}),!V&&!G&&B.length<e.commentsCount&&e.commentsCount>0&&(0,n.jsx)("a",{href:`https://www.linkedin.com/feed/update/${encodeURIComponent(e.urn)}/`,target:"_blank",rel:"noopener noreferrer",className:(0,P.cn)("block w-full rounded-[12px] border border-card-border px-3 py-2 text-xs hover:bg-accent text-center font-medium",ec),children:0===B.length?`View ${e.commentsCount} comment${1===e.commentsCount?"":"s"} on LinkedIn ↗`:`View all ${e.commentsCount} comments on LinkedIn ↗`})]})]})}function eb({media:e,singleton:t,postUrn:i}){let[a,o]=(0,r.useState)(null),l=e.thumbnailUrl||e.url,c=!t,m=c?"aspect-square":"",u=`https://www.linkedin.com/feed/update/${encodeURIComponent(i)}/`,d=e.width&&e.height?e.width:void 0,p=e.width&&e.height?e.height:void 0,h=d??a?.w,f=p??a?.h,g=t?function(e,t){if(e&&t&&e>0&&t>0)return{aspectRatio:`${e} / ${t}`}}(h,f):void 0;if("image"===e.type&&l)return(0,n.jsx)("a",{href:u,target:"_blank",rel:"noopener noreferrer",className:"block",children:(0,n.jsx)("img",{src:l,alt:"",className:(0,P.cn)("w-full bg-muted/10",t?"h-auto max-h-[min(85vh,1200px)] object-contain":`${m} object-cover`)})});if("video"===e.type)return e.streamUrl?(0,n.jsx)("div",{className:(0,P.cn)("relative w-full overflow-hidden bg-black",t&&"max-h-[min(85vh,1200px)]",c&&m),style:t?g??{minHeight:"12rem"}:void 0,children:(0,n.jsx)(ei.VideoPlayer,{src:e.streamUrl,poster:e.thumbnailUrl,className:"block h-full w-full",onLoadedMetadata:n=>{if(!t||e.width&&e.height)return;let r=n.currentTarget;r.videoWidth>0&&r.videoHeight>0&&o({w:r.videoWidth,h:r.videoHeight})},videoClassName:(0,P.cn)("h-full w-full object-contain",c&&"object-cover")})}):(0,n.jsxs)("a",{href:u,target:"_blank",rel:"noopener noreferrer",className:(0,P.cn)("relative block w-full overflow-hidden bg-black group",t&&"max-h-[min(85vh,1200px)]",c&&m),style:t?g??{minHeight:"10rem"}:void 0,children:[l&&(0,n.jsx)("img",{src:l,alt:"",onLoad:n=>{if(!t||e.width&&e.height)return;let r=n.currentTarget;r.naturalWidth>0&&r.naturalHeight>0&&o({w:r.naturalWidth,h:r.naturalHeight})},className:(0,P.cn)("bg-black",t?"absolute inset-0 h-full w-full object-contain":"h-full w-full object-cover opacity-90 group-hover:opacity-100 transition")}),(0,n.jsx)("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",children:(0,n.jsx)("div",{className:"h-14 w-14 rounded-full bg-white/95 flex items-center justify-center shadow-lg group-hover:scale-110 transition",children:(0,n.jsx)(s.Play,{className:"size-6 text-black fill-black ml-0.5"})})})]});if("document"===e.type)return(0,n.jsx)(ev,{media:e,postUrl:u,singleton:t});if("article"===e.type){let t=!!e.thumbnailUrl;return(0,n.jsxs)("a",{href:e.url||u,target:"_blank",rel:"noopener noreferrer",className:"block border-t border-b border-border hover:bg-accent/30 transition",children:[t&&(0,n.jsx)("img",{src:e.thumbnailUrl,alt:"",className:"w-full aspect-[1.91/1] object-cover"}),(0,n.jsxs)("div",{className:"p-3 space-y-0.5",children:[(0,n.jsx)("div",{className:"text-sm font-medium line-clamp-2",children:e.title||e.url||"Linked article"}),(e.domain||e.subtitle)&&(0,n.jsx)("div",{className:"text-xs text-muted-foreground line-clamp-1",children:e.domain||e.subtitle})]})]})}return(0,n.jsxs)("div",{className:(0,P.cn)("flex w-full items-center justify-center bg-muted text-xs text-muted-foreground",c?m:"min-h-[8rem]"),children:["[",e.type,"]"]})}function ev({media:e,postUrl:t,singleton:i}){let{images:a}=function(e){if(Array.isArray(e.pageImages)&&e.pageImages.length)return{images:e.pageImages,width:e.width,height:e.height};let t=e.raw?.document?.coverPages?.pagesPerResolution;if(Array.isArray(t)&&t.length){let e=[...t].sort((e,t)=>
1(Number(e?.width)||0)-(Number(t?.width)||0)),n=e.find(e=>(Number(e?.width)||0)>=1e3)??e[e.length-1],r=Array.isArray(n?.imageUrls)?n.imageUrls.filter(e=>"string"==typeof e&&/^https?:\/\//.test(e)):[];if(r.length)return{images:r,width:Number(n?.width)||void 0,height:Number(n?.height)||void 0}}return e.thumbnailUrl?{images:[e.thumbnailUrl],width:e.width,height:e.height}:{images:[]}}(e),[o,l]=(0,r.useState)(0);if(!a.length)return(0,n.jsxs)("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 border-t border-b border-border px-4 py-3 hover:bg-accent/30 transition",children:[(0,n.jsx)(y.FileText,{className:"size-4 shrink-0 text-muted-foreground"}),(0,n.jsx)("span",{className:"text-sm font-medium line-clamp-1",children:e.title||"View document"})]});let s=Math.min(o,a.length-1),c=e=>l(t=>{let n=a.length;return((Math.min(t,n-1)+e)%n+n)%n});return(0,n.jsxs)("div",{className:"relative w-full overflow-hidden bg-neutral-900 group",children:[(0,n.jsx)("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"block",children:(0,n.jsx)("img",{src:a[s],alt:e.title?`${e.title} - page ${s+1}`:`Document page ${s+1}`,className:(0,P.cn)("mx-auto bg-neutral-900",i?"max-h-[420px] w-auto max-w-full object-contain":"aspect-square w-full object-cover")})}),a.length>1&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("button",{type:"button",onClick:e=>{e.preventDefault(),e.stopPropagation(),c(-1)},"aria-label":"Previous page",className:"absolute left-2 top-1/2 -translate-y-1/2 flex h-8 w-8 items-center justify-center rounded-full bg-black/55 text-white opacity-0 transition group-hover:opacity-100 hover:bg-black/75",children:(0,n.jsx)(g.ChevronLeft,{className:"size-4"})}),(0,n.jsx)("button",{type:"button",onClick:e=>{e.preventDefault(),e.stopPropagation(),c(1)},"aria-label":"Next page",className:"absolute right-2 top-1/2 -translate-y-1/2 flex h-8 w-8 items-center justify-center rounded-full bg-black/55 text-white opacity-0 transition group-hover:opacity-100 hover:bg-black/75",children:(0,n.jsx)(x.ChevronRight,{className:"size-4"})}),(0,n.jsxs)("div",{className:"absolute right-2 top-2 rounded-full bg-black/60 px-2 py-0.5 text-[11px] font-medium text-white tabular-nums",children:[s+1," / ",a.length]})]}),e.title&&(0,n.jsx)("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/70 to-transparent px-3 pb-2.5 pt-8",children:(0,n.jsx)("span",{className:"line-clamp-2 text-sm font-semibold text-white",children:e.title})})]})}function eN({post:e}){let[t,i]=(0,r.useState)(!1),a=e.text||"",o=a.length>200&&!t,s=o?a.slice(0,200).trimEnd()+"…":a;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("header",{className:"flex items-start gap-2 px-3 pt-3",children:[(0,n.jsx)("div",{className:"h-9 w-9 squircle overflow-hidden bg-muted shrink-0 flex items-center justify-center text-xs font-medium text-muted-foreground",children:e.author.pictureUrl?(0,n.jsx)(R.SafeImage,{src:e.author.pictureUrl,alt:"",fallback:(0,n.jsx)("span",{children:e.author.name?.[0]||"?"}),className:"h-full w-full object-cover"}):(0,n.jsx)("span",{children:e.author.name?.[0]||"?"})}),(0,n.jsxs)("div",{className:"min-w-0 flex-1 leading-tight",children:[(0,n.jsx)("div",{className:"font-semibold text-xs truncate",children:e.author.name||"Unknown"}),e.author.headline&&(0,n.jsx)("div",{className:"text-[11px] text-muted-foreground line-clamp-1 mt-0.5",children:e.author.headline}),(0,n.jsxs)("div",{className:"text-[11px] text-muted-foreground mt-0.5 flex items-center gap-1.5",children:[(0,n.jsx)("span",{children:e.postedAgeText?.trim()||""}),(0,n.jsx)(l.Globe,{className:"size-3","aria-label":"Public"})]})]})]}),a&&(0,n.jsxs)("div",{className:"px-3 pt-2 text-xs leading-relaxed whitespace-pre-wrap",children:[s,o&&(0,n.jsx)("button",{onClick:()=>i(!0),className:"ml-1 text-muted-foreground hover:text-foreground",children:"see more"})]}),(e.media??[]).length>0&&(0,n.jsx)("div",{className:`mt-2 grid gap-1 ${1===(e.media??[]).length?"grid-cols-1":"grid-cols-2"}`,children:(e.media??[]).slice(0,4).map((t,r)=>(0,n.jsx)(eb,{media:t,singleton:1===(e.media??[]).length,postUrn:e.urn},r))}),(e.reactionsCount>0||e.commentsCount>0)&&(0,n.jsxs)("div",{className:"text-[11px] text-muted-foreground px-3 py-2 border-t border-border/40 mt-2",children:[e.reactionsCount>
10&&`${e.reactionsCount.toLocaleString()} reaction${1===e.reactionsCount?"":"s"}`,e.reactionsCount>0&&e.commentsCount>0&&" · ",e.commentsCount>0&&`${e.commentsCount.toLocaleString()} comment${1===e.commentsCount?"":"s"}`]})]})}function eU({text:e,mentions:t,className:i}){if(!e)return null;let a=(t||[]).filter(t=>t.start>=0&&t.length>0&&t.start+t.length<=e.length);if(0===a.length)return(0,n.jsx)("span",{className:i,children:e});let o=[],l=0;return a.forEach((t,r)=>{t.start>l&&o.push({key:`t-${r}`,node:e.slice(l,t.start)});let i=e.slice(t.start,t.start+t.length);o.push({key:`m-${r}`,node:(0,n.jsx)(ej,{mention:t,label:i},`m-${r}`)}),l=t.start+t.length}),l<e.length&&o.push({key:"tail",node:e.slice(l)}),(0,n.jsx)("span",{className:i,children:o.map(e=>(0,n.jsx)(r.default.Fragment,{children:e.node},e.key))})}function ej({mention:e,label:t}){let{lookup:i,register:a,markAdded:o}=eu();(0,r.useEffect)(()=>{e.urn&&a([{vanityName:e.vanityName,urn:e.urn}])},[e.urn,a]);let l=i({vanityName:e.vanityName,urn:e.urn}),s=!!l,[c,m]=(0,r.useState)("idle"),[u,d]=(0,r.useState)(!1),p=(0,r.useRef)(null),h=()=>{p.current&&(clearTimeout(p.current),p.current=null),d(!0)},f=()=>{p.current&&clearTimeout(p.current),p.current=setTimeout(()=>d(!1),120)};(0,r.useEffect)(()=>()=>{p.current&&clearTimeout(p.current)},[]);let g="company"===e.kind&&e.vanityName?`https://www.linkedin.com/company/${e.vanityName}/`:e.vanityName?`https://www.linkedin.com/in/${e.vanityName}/`:void 0,x=s&&l?`/people/${l.id}`:g,y=l?.name||e.name||t.replace(/^@/,""),b=l?l.job_title&&l.company_name?`${l.job_title} \xb7 ${l.company_name}`:l.job_title||l.company_name||l.headline||l.email||e.headline:e.headline,v=l?.image_url||e.pictureUrl,N=!!(y||b||v||l),j=async()=>{if("adding"===c||s||"profile"!==e.kind||!e.vanityName)return;m("adding");let n=`https://www.linkedin.com/in/${e.vanityName}`;try{let r=await fetch("/api/contacts/quick-add-linkedin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({linkedinUrl:n,name:e.name||t.replace(/^@/,""),headline:e.headline,pictureUrl:e.pictureUrl,profileUrn:e.urn})}),i=await r.json().catch(()=>({}));if(r.ok&&i.contactId){let t=i.contactId,r=i.contact,a=r?.name||e.name||y;eo(a,t,{alreadyThere:!1===i.isNew}),o({vanityName:e.vanityName,urn:e.urn},r??{id:i.contactId,name:e.name,headline:e.headline,job_title:null,email:null,image_url:e.pictureUrl,linkedin_url:n,linkedin_urn:e.urn,linkedin_id:null,company_name:null}),m("idle"),!1!==i.isNew&&(0,I.triggerPostAddEnrichment)({contactId:i.contactId,linkedinUrl:n,linkedinUrn:e.urn,name:e.name,pictureUrl:e.pictureUrl})}else m("error"),U.toast.error(i.error||"Could not save contact"),setTimeout(()=>m("idle"),2500)}catch(e){console.error("[MentionChip] add failed",e),m("error"),U.toast.error("Could not save contact"),setTimeout(()=>m("idle"),2500)}},w=!s&&"profile"===e.kind&&!!e.vanityName;return(0,n.jsxs)("span",{className:"relative inline",onMouseEnter:h,onMouseLeave:f,children:[x?(0,n.jsx)("a",{href:x,target:s?void 0:"_blank",rel:s?void 0:"noopener noreferrer",className:"font-semibold text-foreground hover:underline underline-offset-2 decoration-foreground/40",children:t}):(0,n.jsx)("span",{className:"font-semibold text-foreground",children:t}),N&&u&&(0,n.jsx)("span",{role:"tooltip",className:"absolute left-0 top-full z-50 pt-2",onMouseEnter:h,onMouseLeave:f,children:(0,n.jsxs)("span",{className:"relative block w-80 rounded-[14px] border border-border bg-popover text-popover-foreground p-3 leading-tight",children:[(0,n.jsxs)("span",{className:"flex items-start gap-2.5",children:[v?x?(0,n.jsx)("a",{href:x,target:s?void 0:"_blank",rel:s?void 0:"noopener noreferrer",className:`h-11 w-11 squircle shrink-0 overflow-hidden ${s?"ring-1 ring-emerald-500/40":""}`,"aria-label":s?"Open in Everything":"Open LinkedIn profile",children:(0,n.jsx)("img",{src:v,alt:"",className:"h-full w-full object-cover"})}):(0,n.jsx)("img",{src:v,alt:"",className:`h-11 w-11 squircle object-cover shrink-0 ${s?"ring-1 ring-emerald-500/40":""}`}):x?(0,n.jsx)("a",{href:x,target:s?void 0:"_blank",rel:s?void 0:"noopener noreferrer",className:`h-11 w-11 squircle bg-muted flex items-center justify-center text-xs font-medium text-muted-foreground shrink-0 ${s?"ring-1 ring-emerald-500/40":""}`,"aria-label":s?"Open in Everything":"Open LinkedIn profile",children:y?.[0]?.toUpperCase()||"?"}):(0,n.jsx)("span",{className:`h-11 w-11 squircle bg-muted flex items-center justify-center text-xs font-medium text-muted-foreground shrink-0 ${s?"ring-1 ring-emerald-500/40":""}`,children:y?.[0]?.toUpperCase()||"?"}),(0,n.jsxs)("span",{className:`min-w-0 flex-1 ${w?"pr-16":""}`,children:[(0,n.jsx)("span",{className:"block text-sm font-semibold truncate",children:y}),b&&(0,n.jsx)("span",{className:"block text-[11px] text-muted-foreground line-clamp-2 mt-0.5",children:b}),s&&l&&(0,n.jsxs)(n.Fragment,{children:[l.email&&(0,n.jsx)("span",{className:"block text-[10px] text-muted-foreground truncate mt-1",children:l.email}),(0,n.jsxs)("span",{className:"flex items-center gap-1.5 mt-1.5",children:[(0,n.jsx)("span",{className:"text-[10px] font-medium text-emerald-600",children:"In Everything"}),(0,n.jsxs)("a",{href:`/people/${l.id}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-0.5 text-[10px] font-medium text-ring transition-opacity hover:opacity-80",children:["Open",(0,n.jsx)(Z.SidebarForwardArrowIcon,{width:12,height:9})]})]})]})]})]}),w&&(0,n.jsx)("button",{type:"button",onClick:j,disabled:"adding"===c||s,style:{backgroundColor:"var(--ring)"},className:"absolute bottom-3 right-3 inline-flex min-h-[30px] min-w-[4.5rem] items-center justify-center rounded-full px-4 py-1.5 text-xs font-semibold text-white transition hover:opacity-90 disabled:opacity-60",children:"adding"===c?(0,n.jsx)(L.LinkedInExportSpinner,{className:"h-5 w-5",alt:""}):"Add"})]})})]})}function ew({comment:e,allComments:t,postUrn:i,ugcPostUrn:a,onReplied:o,depth:l=0,chipClass:s="bg-white dark:bg-card"}){let[c,m]=(0,r.useState)(!1),[u,d]=(0,r.useState)([]),[p,g]=(0,r.useState)(!1),[x,y]=(0,r.useState)(!1),[b,N]=(0,r.useState)(!1),[w,I]=(0,r.useState)(e.viewerReaction??null),[_,L]=(0,r.useState)(e.reactionsCount||0),[R,E]=(0,r.useState)(!1),[A,$]=(0,r.useState)(!1),D=(0,r.useRef)(null),F=()=>{D.current&&(clearTimeout(D.current),D.current=null),$(!0)},M=()=>{D.current&&clearTimeout(D.current),D.current=setTimeout(()=>$(!1),120)};(0,r.useEffect)(()=>()=>{D.current&&clearTimeout(D.current)},[]);let O=(0,r.useMemo)(()=>t.filter(t=>(0,T.commentUrnEquals)(t.parentCommentUrn,e.commentUrn)),[t,e.commentUrn]),z=(0,r.useMemo)(()=>{let t=new Map,n=0,r=e=>{let r=(0,T.commentIdentityKey)(e.commentUrn)||e.commentUrn||`__noid_${n++}`;t.set(r,e)};for(let e of O)r(e);for(let e of u)r(e);return Array.from(t.values()).filter(t=>!(0,T.commentUrnEquals)(t.commentUrn,e.commentUrn)).sort((e,t)=>
1(e.postedAt??Number.MAX_SAFE_INTEGER)-(t.postedAt??Number.MAX_SAFE_INTEGER))},[e.commentUrn,u,O]),B=async()=>{p||(g(!0),d(await ex(e.commentUrn)),g(!1),y(!0))},K=async(t,n,r=[])=>{if(!a)throw U.toast.error("Cannot reply: missing post URN"),Error("missing ugcPostUrn");let l=[t.trim(),...n].filter(Boolean).join("\n").trim();if(!l)return;let{text:s,attributesV2:c}=el(l,r),u=await (0,S.commentOnLinkedInPost)({threadUrn:a,parentCommentUrn:e.commentUrn,text:s,mentions:c,backendUpdateUrn:i});if(!u.ok)throw U.toast.error(u.error||"Failed to reply"),Error(u.error||"Failed to reply");m(!1),o()},[W,V]=(0,r.useState)(!1),[q,H]=(0,r.useState)(!1),J=e.actions?.includes("EDIT_COMMENT")??!1,G=e.actions?.includes("DELETE")??!1,X=async(t,n,r=[])=>{let a=[t.trim(),...n].filter(Boolean).join("\n").trim();if(!a)return;let{text:l,attributesV2:s}=el(a,r),c=await (0,S.editLinkedInComment)({commentUrn:e.commentUrn,text:l,mentions:s,backendUpdateUrn:i});if(!c.ok)throw U.toast.error(c.error||"Failed to edit comment"),Error(c.error||"Failed to edit comment");V(!1),o(),U.toast.success("Comment updated")},Q=async t=>{if(R||!e.commentUrn)return;let n=w===t;E(!0),$(!1),I(n?null:t),L(n?Math.max(0,_-1):w?_:_+1);let r=n?S.unreactLinkedInPost:S.reactToLinkedInPost,a={threadUrn:e.commentUrn,reactionType:t,backendUpdateUrn:i},o=await r(a);o.ok||(I(w),L(_),U.toast.error(o.error||"Failed to react")),E(!1)},Y=(0,r.useRef)(null),Z=(0,r.useRef)(null),ee=(0,r.useRef)(null),[et,er]=(0,r.useState)(0),ei=l>0?11:15,ea=l>0?30:38,eo=!x&&(e.repliesCount||0)>z.length,es=!b&&z.length>0,ec=z.length>0||eo,em=Math.max(z.length,e.repliesCount||0);return(0,r.useLayoutEffect)(()=>{let e=Y.current,t=ee.current;if(!ec||!e||!t)return void er(0);let n=()=>{let n=t.getBoundingClientRect(),r=e.getBoundingClientRect().top;er(Math.max(12,n.top+n.height/2-r-ea))};n();let r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[ec,es,z.length,ea,12]),(0,n.jsxs)("div",{ref:Y,className:"relative flex flex-col",children:[ec&&et>0&&(0,n.jsx)("span",{"aria-hidden":!0,className:"absolute border-l-2 border-b-2 border-border/70 dark:border-border/50 rounded-bl-[12px] pointer-events-none",style:{left:ei,top:ea,width:(0===l?42:34)-ei+2,height:et}}),(0,n.jsxs)("div",{className:"flex items-start gap-2.5",children:[(0,n.jsx)(ek,{person:e.commenter,size:l>0?"sm":"md"}),(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsxs)("div",{className:(0,P.cn)("group/comment relative rounded-[16px] [corner-shape:squircle] px-3 py-2 leading-tight",s,l>0&&"rounded-[14px]"),children:[(0,n.jsx)("div",{className:(0,P.cn)("font-semibold",l>0?"text-[11px]":"text-xs"),children:e.commenter.name||"Unknown"}),e.commenter.headline&&(0,n.jsx)("div",{className:"text-[10px] text-muted-foreground line-clamp-1",children:e.commenter.headline}),W?(0,n.jsx)("div",{className:"mt-1.5",children:(0,n.jsx)(k.CommentComposer,{placeholder:"Edit your comment…",submitLabel:"Save",autoFocus:!0,initialText:e.text??"",onCancel:()=>V(!1),mentionSource:"linkedin",className:"bg-transparent border-0 shadow-none p-0",onSubmit:async({body:e,mentions:t,attachments:n})=>{let r=n.map(e=>e.url).filter(Boolean);await X(e,r,t)}})}):(0,n.jsx)("div",{className:(0,P.cn)("mt-1 whitespace-pre-wrap",l>0?"text-xs":"text-sm"),children:(0,n.jsx)(eU,{text:e.text,mentions:e.mentions})}),(J||G)&&!W&&(0,n.jsxs)(v.DropdownMenu,{children:[(0,n.jsx)(v.DropdownMenuTrigger,{asChild:!0,children:(0,n.jsx)("button",{type:"button","aria-label":"Comment actions",className:"absolute top-1.5 right-1.5 p-1 rounded-full text-muted-foreground opacity-0 group-hover/comment:opacity-100 hover:bg-muted/60 transition-opacity",children:(0,n.jsx)(h.MoreHorizontal,{className:"h-3.5 w-3.5"})})}),(0,n.jsxs)(v.DropdownMenuContent,{align:"end",className:"text-xs",children:[J&&(0,n.jsxs)(v.DropdownMenuItem,{onSelect:()=>V(!0),children:[(0,n.jsx)(f.Pencil,{className:"h-3.5 w-3.5"})," Edit"]}),G&&(0,n.jsxs)(v.DropdownMenuItem,{onSelect:()=>{q||confirm("Delete this comment?")&&(H(!0),(0,j.deleteWithUndo)({message:"Comment deleted",onCommitted:()=>o(),onUndo:()=>H(!1),onError:e=>{H(!1),U.toast.error(e instanceof Error?e.message:"Failed to delete comment")},commit:async()=>{let t=await (0,S.deleteLinkedInComment)({commentUrn:e.commentUrn,backendUpdateUrn:i});if(!t.ok)throw Error(t.error||"Failed to delete comment")}}))},disabled:q,className:"text-destructive focus:text-destructive",children:[(0,n.jsx)(en.TrashIcon,{className:"h-3.5 w-3.5"})," ",q?"Deleting…":"Delete"]})]})]})]}),(0,n.jsxs)("div",{className:"flex items-center gap-3 px-3 mt-1 text-[11px] text-muted-foreground",children:[(0,n.jsxs)("div",{className:"relative",onMouseEnter:F,onMouseLeave:M,children:[(0,n.jsx)("button",{type:"button",onClick:()=>Q(w??"LIKE"),disabled:R,className:(0,P.cn)("font-medium transition flex items-center gap-1 disabled:opacity-50",w?"text-foreground":"hover:text-foreground"),style:w?{color:(0,C.reactionColor)(w)}:void 0,"aria-label":w?`Reacted ${(0,C.reactionLabel)(w)} - click to un-react`:"React to comment",children:w?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(C.ReactionIcon,{type:w,size:14}),(0,C.reactionLabel)(w)]}):"React"}),A&&(0,n.jsx)("div",{className:"absolute bottom-full left-0 pb-1 flex items-center gap-0.5 z-10",role:"menu",onMouseEnter:F,onMouseLeave:M,children:(0,n.jsx)("div",{className:"flex items-center gap-0.5 rounded-full border border-border bg-popover shadow-md px-1.5 py-1",children:C.PICKABLE_REACTIONS.map(e=>{let t=w===e;return(0,n.jsx)("button",{type:"button",onClick:()=>Q(e),disabled:R,title:(0,C.reactionLabel)(e),"aria-label":(0,C.reactionLabel)(e),className:(0,P.cn)("flex items-center justify-center rounded-full p-0.5 transition disabled:opacity-50",t?"bg-accent scale-110":"hover:scale-125 hover:bg-accent/60"),children:(0,n.jsx)(C.ReactionIcon,{type:e,size:18})},e)})})})]}),(0,n.jsx)("button",{type:"button",onClick:()=>m(e=>!e),className:"hover:text-foreground font-medium",children:"Reply"}),_>0&&(0,n.jsxs)("span",{children:[_," reaction",1===_?"":"s"]})]}),c&&(0,n.jsx)("div",{className:"mt-2 ml-2",children:(0,n.jsx)(k.CommentComposer,{placeholder:"Add a reply…",submitLabel:"Reply",autoF
1ocus:!0,onCancel:()=>m(!1),mentionSource:"linkedin",className:(0,P.cn)("border-0 shadow-none",s),onSubmit:async({body:e,mentions:t,attachments:n})=>{let r=n.map(e=>e.url).filter(Boolean);await K(e,r,t)}})})]})]}),ec&&(0,n.jsxs)("div",{className:"mt-3 flex gap-2.5",children:[(0,n.jsx)("div",{className:(0,P.cn)("shrink-0",0===l?"w-8":"w-6"),"aria-hidden":!0}),(0,n.jsxs)("div",{ref:Z,className:"flex min-w-0 flex-1 flex-col gap-4 pb-0.5",children:[es&&z.map(e=>(0,n.jsx)(ew,{comment:e,allComments:t,postUrn:i,ugcPostUrn:a,onReplied:o,depth:l+1,chipClass:s},(0,T.commentIdentityKey)(e.commentUrn)||e.commentUrn)),(0,n.jsx)("button",{ref:ee,type:"button",disabled:p,onClick:async()=>{es?N(!0):(eo&&await B(),N(!1))},className:"self-start text-[11px] font-semibold text-muted-foreground hover:bg-muted/60 hover:text-foreground px-2.5 py-1 rounded-full disabled:opacity-50 transition-colors",children:p?"Loading…":es?"Collapse replies":`See ${em} more repl${1===em?"y":"ies"}`})]})]})]})}function eC({postUrn:e,ugcPostUrn:t,onPosted:r,autoFocus:i,placeholder:a="Add a comment…",submitLabel:o="Comment",className:l,surfaceClass:s="bg-white dark:bg-card"}){return(0,n.jsx)(k.CommentComposer,{placeholder:a,submitLabel:o,autoFocus:i,className:(0,P.cn)("border-0 shadow-none",s,l),mentionSource:"linkedin",onSubmit:async({body:n,mentions:i,attachments:a})=>{if(!t)return void U.toast.error("Cannot comment: missing post URN");let o=[n.trim()];for(let e of a)e.url&&o.push(e.url);let l=o.filter(Boolean).join("\n").trim();if(!l)return;let{text:s,attributesV2:c}=el(l,i);fetch("/api/linkedin/posts/optimistic-engagement",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({kind:"comment",postUrn:e,text:s,mentions:c})}).catch(()=>{});let m=await (0,S.commentOnLinkedInPost)({threadUrn:t,text:s,mentions:c,backendUpdateUrn:e});if(m.ok)r();else throw U.toast.error(m.error||"Failed to post comment"),Error(m.error||"Failed to post comment")}})}function ek({person:e,size:t="md"}){let{lookup:i,register:a,markAdded:o}=eu();(0,r.useEffect)(()=>{(e.urn||e.vanityName)&&a([{vanityName:e.vanityName,urn:e.urn}])},[e.urn,e.vanityName,a]);let[l,s]=(0,r.useState)("idle"),c="lg"===t?"h-12 w-12":"sm"===t?"h-6 w-6":"h-8 w-8",u="lg"===t?"h-3 w-3":"sm"===t?"h-2 w-2":"h-2.5 w-2.5",d=e.vanityName?`https://www.linkedin.com/in/${e.vanityName}`:null,p=i({vanityName:e.vanityName,urn:e.urn}),h=!!p,f=p?`/people/${p.id}`:null,g=async t=>{if(t.stopPropagation(),t.preventDefault(),"adding"!==l&&d&&!h){s("adding");try{let t=await fetch("/api/contacts/quick-add-linkedin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({linkedinUrl:d,name:e.name,pictureUrl:e.pictureUrl,profileUrn:e.urn})}),n=await t.json().catch(()=>({}));if(t.ok&&n.contactId){let t=n.contactId,r=n.contact;eo(e.name||"Contact",t,{alreadyThere:!1===n.isNew}),(e.vanityName||e.urn)&&o({vanityName:e.vanityName,urn:e.urn},r??{id:n.contactId,name:e.name,headline:null,job_title:null,email:null,image_url:e.pictureUrl,linkedin_url:d,linkedin_urn:e.urn,linkedin_id:null,company_name:null}),s("idle"),!1!==n.isNew&&(0,I.triggerPostAddEnrichment)({contactId:n.contactId,linkedinUrl:d,linkedinUrn:e.urn,name:e.name,pictureUrl:e.pictureUrl})}else s("error"),U.toast.error(n.error||"Could not save contact"),setTimeout(()=>s("idle"),2500)}catch(e){console.error("[AddableAvatar] add failed",e),s("error"),U.toast.error("Could not save contact"),setTimeout(()=>s("idle"),2500)}}},x=(0,n.jsx)("div",{className:`${c} squircle overflow-hidden bg-muted flex items-center justify-center ${"lg"===t?"text-sm":"sm"===t?"text-[10px]":"text-xs"} font-medium text-muted-foreground ${h?"ring-1 ring-emerald-500/40":""}`,children:e.pictureUrl?(0,n.jsx)(R.SafeImage,{src:e.pictureUrl,alt:"",fallback:(0,n.jsx)("span",{children:e.name?.[0]?.toUpperCase()||"?"}),className:"h-full w-full object-cover"}):(0,n.jsx)("span",{children:e.name?.[0]?.toUpperCase()||"?"})}),y=h?`${e.name||"Contact"} \xb7 open in Everything`:d?`${e.name||"Contact"} \xb7 open LinkedIn profile`:void 0,b=f||d,v=h?`Open ${e.name||"contact"} in Everything`:`Open ${e.name||"contact"} on LinkedIn`,N=b?(0,n.jsx)("a",{href:b,target:f?void 0:"_blank",rel:f?void 0:"noopener noreferrer","aria-label":v,className:"block hover:opacity-90 transition-opacity",children:x}):x;return(0,n.jsxs)("div",{className:`relative group/avatar ${c} shrink-0`,title:y,children:[N,d&&!h&&(0,n.jsx)("button",{onClick:g,disabled:"adding"===l,title:"Save to Everything","aria-label":"Save to Everything",className:`absolute -top-1 -right-1 ${"lg"===t?"h-5 w-5":"sm"===t?"h-3.5 w-3.5":"h-4 w-4"} squircle bg-foreground text-background flex items-center justify-center opacity-0 group-hover/avatar:opacity-100 transition-opacity hover:scale-110 disabled:opacity-100`,children:"adding"===l?(0,n.jsx)(L.LinkedInExportSpinner,{className:u,alt:""}):(0,n.jsx)(m.Plus,{className:u,strokeWidth:3})})]})}function eP(){return(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("div",{className:"h-6 w-6 squircle bg-muted animate-pulse"}),(0,n.jsx)("div",{className:"h-3 w-32 bg-muted animate-pulse rounded"})]})}function eI(e){if(!e)return null;let n=new Date(e);if(Number.isNaN(n.getTime()))return null;try{return(0,t.formatDistanceToNow)(n,{addSuffix:!1})}catch{return null}}e.s(["PostCard",0,ey,"RecordKnownProvider",0,ed,"cacheToDb",0,ea,"default",0,function(e){return(0,n.jsx)(ed,{knownContactSeed:e.knownContactSeed,children:(0,n.jsx)(ef,{...e})})}],268252),e.s(["feedItemToDecodedPost",0,function(e){var t;let n=e.id,r=e.posted_at?new Date(e.posted_at).getTime():null;return{urn:n,ugcPostUrn:e.ugc_post_urn??null,socialDetailUrn:e.social_detail_urn??null,contextHeader:null,author:{urn:e.author.id??null,
1name:e.author.name??null,headline:e.author.headline??null,vanityName:e.author.vanity??null,pictureUrl:e.author.avatar_url??null},text:e.content??null,attributes:[],media:Array.isArray(t=e.media)?t:[],resharedPostUrn:e.reshared_post?.urn??null,resharedPost:e.reshared_post??null,inlineComments:[],postedAt:Number.isFinite(r)?r:null,postedAgeText:eI(e.posted_at),reactionsCount:e.metrics.likes??0,commentsCount:e.metrics.comments??0,sharesCount:e.metrics.reposts??0,impressionsCount:e.metrics.views>0?e.metrics.views:null,raw:null}},"socialPostToDecodedPost",0,function(e,t){let n=e.linkedin_post_urn??`social-${e.id}`,r=e.published_at??e.scheduled_at??null,i=r?new Date(r).getTime():null,a=e.author?.full_name||e.author?.avatar_url?{urn:t?.linkedin_urn??null,name:e.author?.full_name??t?.name??null,headline:t?.headline??null,vanityName:null,pictureUrl:e.author?.avatar_url??t?.avatar_url??null}:{urn:t?.linkedin_urn??null,name:t?.name??null,headline:t?.headline??null,vanityName:null,pictureUrl:t?.avatar_url??null};return{urn:n,ugcPostUrn:e.linkedin_post_urn??null,socialDetailUrn:e.social_detail_urn??null,contextHeader:null,author:a,text:e.content??null,attributes:[],media:[],resharedPostUrn:null,resharedPost:null,inlineComments:[],postedAt:Number.isFinite(i)?i:null,postedAgeText:eI(r),reactionsCount:Number(e.metrics?.likes??0),commentsCount:Number(e.metrics?.comments??0),sharesCount:Number(e.metrics?.reposts??0),impressionsCount:Number(e.metrics?.views??0)>0?Number(e.metrics.views):null,raw:null}}],90267),e.s(["LinkedInPostCard",0,ey],246314)},514511,e=>{"use strict";var t=e.i(694533);function n(e){let t=new Map;for(let n of e||[])n?.entityUrn&&t.set(n.entityUrn,n),n?.preDashEntityUrn&&t.set(n.preDashEntityUrn,n),"string"==typeof n?.predashEntityUrn&&n.predashEntityUrn&&t.set(n.predashEntityUrn,n);return t}function r(e,t){return t&&e.get(t)||null}let i=/urn:li:(?:fsd_profile|fs_miniProfile|fs_salesProfile|member):[^,")\s]+/;function a(e){if(!e)return null;let t=e.trim().match(/^urn:li:(?:fsd_)?comment:\((.+)\)\s*$/);if(!t)return null;let n=t[1],r=0;for(let e=0;e<n.length;e++){let t=n[e];if("("===t)r++;else if(")"===t)r--;else if(","===t&&0===r)return{id:n.slice(0,e),parent:n.slice(e+1)}}return null}function o(e){let t=e?.trim();if(!t)return null;let n=a(t);return n?`${n.parent}^^^${n.id}`:t}function l(e){let t=a(e?.trim()??"");return!!t&&t.id.startsWith("optimistic-")}function s(e){return(e??"").replace(/\s+/g," ").trim()}function c(e,t){if(!e?.trim()||!t?.trim())return!1;if(e.trim()===t.trim())return!0;let n=o(e),r=o(t);return null!=n&&n===r}function m(e){if(!e?.trim())return!1;let t=a(e.trim());return null!=t&&/^urn:li:(?:fsd_)?comment:/i.test(t.parent)}function u(e){if(e.length<2)return e;let t=e;for(let e=0;e<6;e++){let e=!1;if(t=t.map(n=>{if(n.parentCommentUrn)return n;let r=a(String(n.commentUrn).trim());if(!r||!/^urn:li:(?:fsd_)?comment:/i.test(r.parent))return n;let i=t.find(e=>c(e.commentUrn,r.parent));return i?(e=!0,{...n,parentCommentUrn:i.commentUrn}):n}),!e)break}return t}function d(e,n){if(!e)return{urn:null,name:null,headline:null,vanityName:null,pictureUrl:null};let r=e.firstName?.text??("string"==typeof e.firstName?e.firstName:null),i=e.lastName?.text??("string"==typeof e.lastName?e.lastName:null),a=r||i?[r,i].filter(Boolean).join(" ").trim()||null:e.name?.text??("string"==typeof e.name?e.name:null),o=e.description?.text??e.headline?.text??("string"==typeof e.headline?e.headline:null)??e.tagline?.text??("string"==typeof e.tagline?e.tagline:null)??null,l=p(e.image)||p(e.profilePicture)||p(e.logo)||null,s=function(e){if("string"!=typeof e||!e)return{urn:null,vanity:null};let t=null,n=e.match(/miniProfileUrn=([^&]+)/);if(n)try{let e=decodeURIComponent(n[1]);e.startsWith("urn:")&&(t=e)}catch{}let r=null,i=e.match(/linkedin\.com\/in\/([^/?#]+)/i),a=e.match(/linkedin\.com\/company\/([^/?#]+)/i),o=i?.[1]??a?.[1]??null;if(o)try{r=decodeURIComponent(o).toLowerCase()}catch{r=o.toLowerCase()}return{urn:t,vanity:r}}(e.navigationContext?.actionTarget),c=e.publicIdentifier||e.universalName||null,m=c?(()=>{try{return decodeURIComponent(String(c))}catch{return String(c)}})():s.vanity,u=e.entityUrn||e["*entityUrn"]||e.urn||function(e){let t=e?.name?.attributesV2;if(Array.isArray(t))for(let e of t){let t=e?.detailData;if(!t)continue;let n=t["*profileFullName"]||t["*companyName"];if("string"==typeof n&&n.startsWith("urn:"))return n}let n=e?.image?.attributes;if(Array.isArray(n))for(let e of n){let t=e?.detailData;if(!t)continue;let n=t.nonEntityProfilePicture?.["*profile"]||t.profilePicture?.["*profile"]||t.profilePictureWithoutFrame?.["*profile"];if("string"==typeof n&&n.startsWith("urn:"))return n;let r=t.nonEntityCompanyLogo?.["*company"]||t.companyLogo?.["*company"];if("string"==typeof r&&r.startsWith("urn:"))return r}return null}(e)||s.urn||null,d="string"==typeof u?u.trim():"";return{urn:d.startsWith("urn:")?(0,t.normalizeLinkedinProfileUrnForMatch)(d)||d:null,name:a,headline:o,vanityName:m,pictureUrl:l}}function p(e){if(!e)return null;if("string"==typeof e)return e;if(e.url&&"string"==typeof e.url)return e.url;let t=e.rootUrl&&Array.isArray(e.artifacts)?e:null;if(t)return h(t);if(Array.isArray(e.attributes)&&e.attributes[0]?.detailData){let t=function(e){if(!e||"object"!=typeof e)return null;for(let t of["nonEntityProfilePicture","profilePicture","profilePictureWithoutFrame","profilePictureWithRingStatus","nonEntityCompanyLogo","companyLogo","nonEntityGroupLogo","groupLogo","nonEntitySchoolLogo","schoolLogo","nonEntityProfessionalEventLogo","professionalEventLogo","vectorImage"]){let n=e[t];if(!n)continue;let r=(n.rootUrl?n:null)||n.vectorImage||n.profilePicture?.vectorImage||n.profilePicture?.displayImageReference?.vectorImage||null;if(r?.rootUrl){let e=h(r);if(e)return e}}return"string"==typeof e.imageUrl?e.imageUrl:null}(e.attributes[0].detailData);if(t)return t}let n=e.vectorImage||e.profilePicture?.vectorImage||e.profilePicture?.displayImageReference?.vectorImage||e.displayImageReference?.vectorImage||null;return n?h(n):null}function h(e){if(!e?.rootUrl||!Array.isArray(e.artifacts)||0===e.artifacts.length)return null;let t=[...e.artifacts].sort((e,t)=>
1(t?.width||0)-(e?.width||0))[0];return e.rootUrl+(t.fileIdentifyingUrlPathSegment||"")}function f(e){if(!e?.rootUrl||!Array.isArray(e.artifacts)||0===e.artifacts.length)return null;let t=[...e.artifacts].sort((e,t)=>(Number(t?.width)||0)-(Number(e?.width)||0))[0],n=Number(t?.width),r=Number(t?.height);return n>0&&r>0?{width:n,height:r}:null}function g(e){if(!e)return null;if(e.rootUrl&&Array.isArray(e.artifacts)){let t=f(e);if(t)return t}if(Array.isArray(e.attributes)&&e.attributes[0]?.detailData){let t=e.attributes[0].detailData;for(let e of Object.keys(t)){let n=t[e];if(!n)continue;let r=(n.rootUrl&&Array.isArray(n.artifacts)?n:null)||n.vectorImage||n.profilePicture?.vectorImage||n.profilePicture?.displayImageReference?.vectorImage||null;if(r?.rootUrl&&Array.isArray(r.artifacts)){let e=f(r);if(e)return e}}}let t=e.vectorImage||e.profilePicture?.vectorImage||e.profilePicture?.displayImageReference?.vectorImage||e.displayImageReference?.vectorImage||null;return t?.rootUrl?f(t):null}function x(e){return e?"string"==typeof e?{text:e,attributes:[]}:{text:e?.text?.text??e?.text??null,attributes:e?.text?.attributesV2??e?.attributesV2??e?.attributes??[]}:{text:null,attributes:[]}}function y(e,n=new Map){let o=e.commenter||{},l=o.title?.text??null,s=o.subtitle?.text??null,u=p(o.image),h=(o.navigationUrl||"").match(/\/in\/([^/?]+)/),f=h?(()=>{try{return decodeURIComponent(h[1])}catch{return h[1]}})():null,g=("string"==typeof e.commenter?.["*entityUrn"]?e.commenter["*entityUrn"]:null)||("string"==typeof e.commenter?.entityUrn?e.commenter.entityUrn:null)||("string"==typeof o["*entityUrn"]?o["*e
1ntityUrn"]:null)||("string"==typeof o.entityUrn?o.entityUrn:null)||("string"==typeof e["*commenter"]?e["*commenter"]:null);if(g&&!g.startsWith("urn:")){let e=r(n,g);g=e?.entityUrn||e?.preDashEntityUrn||e?.predashEntityUrn||("string"==typeof e?.urn?e.urn:null)||g}g&&!g.startsWith("urn:")&&(g=null),g||(g=function e(t,n,r=0,a=new Set){if(!t||r>6)return null;if("string"==typeof t){let o=t.match(i)?.[0];return o||(r<6&&n.has(t)?e(n.get(t),n,r+1,a):null)}if("object"!=typeof t||a.has(t))return null;if(a.add(t),Array.isArray(t)){for(let i of t){let t=e(i,n,r+1,a);if(t)return t}return null}let o=Object.keys(t),l=o.filter(e=>/urn|profile|actor|entity|commenter/i.test(e));for(let i of[...l,...o.filter(e=>!l.includes(e))]){let o=e(t[i],n,r+1,a);if(o)return o}return null}(o,n)),g&&(g=(0,t.normalizeLinkedinProfileUrnForMatch)(g)||g);let{text:b,attributes:v}=x(e.commentary),N="string"==typeof e.entityUrn?e.entityUrn:"",U="string"==typeof e.preDashEntityUrn&&e.preDashEntityUrn||"string"==typeof e.predashEntityUrn&&e.predashEntityUrn||"",j="string"==typeof e.urn?e.urn:"",w=N||U||j||"",C=("string"==typeof e.parentCommentUrn&&e.parentCommentUrn.trim()?e.parentCommentUrn.trim():null)||e.parentComment?.entityUrn||e.parentComment?.preDashEntityUrn||null,k=e=>{if("string"!=typeof e||!e)return null;if(e.startsWith("urn:"))return e;let t=r(n,e);return t?.entityUrn||t?.preDashEntityUrn||t?.predashEntityUrn||null},P=[e["*parentComment"],e["*replyToComment"],e["*threadParentComment"],e["*parent"],e["*inReplyTo"]].filter(Boolean);if(!C)for(let e of P){let t=k(e);if(t&&/^urn:li:(?:fsd_)?comment:/i.test(t)){C=t;break}}if(!C&&"string"==typeof e.parentUrn&&/^urn:li:(?:fsd_)?comment:/i.test(e.parentUrn)&&(C=e.parentUrn.trim()),!C)for(let e of[N,U,j,w].filter(e=>"string"==typeof e&&e.length>0)){let t=a(e.trim());if(t&&/^urn:li:(?:fsd_)?comment:/i.test(t.parent)){C=t.parent;break}}if(!m(C)&&"string"==typeof e.permalink&&e.permalink.trim()){let t=function(e,t){let n;try{n=new URL(e,"https://www.linkedin.com")}catch{return null}let r=[];for(let e of["dashCommentUrn","commentUrn"]){let t,i=n.searchParams.get(e);if(!i)continue;try{t=decodeURIComponent(i)}catch{t=i}r.push(t);let a=function(e){let t=e.trim().match(/^urn:li:comment:\(activity:(\d+),(\d+)\)\s*$/i);return t?`urn:li:fsd_comment:(${t[2]},urn:li:activity:${t[1]})`:null}(t);a&&r.push(a)}for(let e of r){let n=e.trim();if(n&&!c(n,t))return n}return null}(e.permalink,w);t&&(C=t)}let I="string"==typeof e["*socialDetail"]&&e["*socialDetail"]||"string"==typeof e.socialDetail&&e.socialDetail||null,S=I?r(n,I):e.socialDetail,_=(S&&"string"==typeof S["*totalSocialActivityCounts"]?S["*totalSocialActivityCounts"]:null)||("string"==typeof e["*totalSocialActivityCounts"]?e["*totalSocialActivityCounts"]:null),T=_?r(n,_):null,L=e.totalSocialActivityCounts?.numComments??e.socialDetail?.totalSocialActivityCounts?.numComments??e.commentSocialActivityCounts?.numComments??S?.totalSocialActivityCounts?.numComments??S?.comments?.paging?.total??S?.comments?.metadata?.updatedCommentCount??T?.numComments??0,R=e.reactionByOriginatingActor??e.viewerReaction??e.commenterReaction??null,E=R?"string"==typeof R?R:"object"==typeof R&&"string"==typeof R.reactionType?R.reactionType:null:null;return{commentUrn:w,parentCommentUrn:C,commenter:{urn:g,name:l,headline:s,vanityName:f,pictureUrl:u},text:b,attributes:v,mentions:function(e,n){if(!Array.isArray(e)||0===e.length)return[];let i=[];for(let a of e){if(!a)continue;let e=Number(a.start??a.startIndex??-1),o=Number(a.length??a.numChars??0);if(e<0||o<=0)continue;let l=a.detailDataUnion||a.detailData||{},s=e=>e?"string"==typeof e?e:e?.["*profile"]||e?.["*company"]||e?.profile||e?.company||e?.profileUrn||e?.companyUrn||null:null,c="unknown",m=null;if(l.profileMention||l.profileFullName||l["*profileMention"])c="profile",m=s(l.profileMention)||s(l.profileFullName)||s(l["*profileMention"]);else if(l.companyMention||l["*companyMention"])c="company",m=s(l.companyMention)||s(l["*companyMention"]);else{if(!l.hashtag&&!l.hashtagMention)continue;c="hashtag"}let u=m?r(n,m):null,p=u?d(u,n):{urn:null,name:null,headline:null,vanityName:null,pictureUrl:null}
1,h="string"==typeof m&&m.trim().startsWith("urn:")?m.trim():p.urn,f="profile"===c?(0,t.normalizeLinkedinProfileUrnForMatch)(h):h;i.push({start:e,length:o,kind:c,urn:f,name:p.name,headline:p.headline,vanityName:p.vanityName,pictureUrl:p.pictureUrl})}return i.sort((e,t)=>e.start-t.start),i}(v,n),reactionsCount:e.totalSocialActivityCounts?.numReactions??e.totalSocialActivityCounts?.numLikes??0,repliesCount:L,postedAt:e.createdAt||null,pinned:!!e.pinned,actions:Array.isArray(e.actions)?e.actions.filter(e=>"string"==typeof e):[],viewerReaction:E,raw:e}}e.s(["commentIdentityKey",0,o,"commentUrnEquals",0,c,"decodeCommentsResponse",0,function(e){if(!e)return{comments:[],paginationToken:null,replyPreviousCursor:null,replyNextCursor:null,updatedCommentCount:null,totalCount:null};let t=e.included||[],r=n(t),i=u(t.filter(e=>e?.$type==="com.linkedin.voyager.dash.social.Comment").map(e=>y(e,r))),a=e.data?.data||e.data||e,o=a?.socialDashCommentsByThread||a?.socialDashCommentsBySocialDetail||a?.socialDashCommentsByRepliesByCursor||a?.socialDashComments||Object.values(a||{}).find(e=>e&&"object"==typeof e&&e.metadata?.paginationToken)||null,l=o?.metadata||{},s=l.paginationToken||l.replyNextCursor||l.replyPreviousCursor||null,c="string"==typeof l.replyPreviousCursor&&l.replyPreviousCursor?l.replyPreviousCursor:null,m="string"==typeof l.replyNextCursor&&l.replyNextCursor?l.replyNextCursor:null;return{comments:i,paginationToken:s,replyPreviousCursor:c,replyNextCursor:m,updatedCommentCount:"number"==typeof l.updatedCommentCount?l.updatedCommentCount:null,totalCount:"number"==typeof o?.paging?.total?o.paging.total:null}},"decodePostsResponse",0,function(e){let t;if(!e)return{posts:[],paginationToken:null};let i=e.included||[],o=n(i),l=e.data?.data||e.data||e,s=l&&"object"==typeof l&&Object.entries(l).find(([e,t])=>/^feedDash(Profile|OrganizationalPage)Updates/.test(e)&&t&&"object"==typeof t&&("*elements"in t||"elements"in t||"metadata"in t))?.[1]||null,c=s?.["*elements"]||s?.elements||null,m=s?.metadata?.paginationToken||s?.paging?.paginationToken||null,h=Array.isArray(c)?c:[];t=h.length?h.map(e=>o.get(e)).filter(Boolean):i.filter(e=>e?.$type==="com.linkedin.voyager.dash.feed.Update");let f=i.filter(e=>e?.$type==="com.linkedin.voyager.dash.social.Comment");return{posts:t.map(e=>(function e(t,n,i=[],o=0){let l=t.entityUrn||t.preDashEntityUrn||"",s=l.match(/urn:li:activity:\d+/),c=s?s[0]:l,m=t.socialContent?.["*socialDetail"]||t["*socialDetail"]||t.socialDetail?.["*entityUrn"]||null,h=r(n,m),f=(()=>{if(h?.urn&&"string"==typeof h.urn)return h.urn;if("string"==typeof m){let e=m.match(/fsd_socialDetail:\(([^,]+),/);if(e&&e[1])return e[1];let t=m.match(/urn:li:(?:ugcPost|share|linkedInArticle|activity):\d+/);if(t)return t[0]}try{let e=JSON.stringify(t).match(/urn:li:(?:ugcPost|share|linkedInArticle):\d+/);if(e)return e[0]}catch{}return c||null})(),b=r(n,h?.["*totalSocialActivityCounts"])||h?.totalSocialActivityCounts||t.socialDetail?.totalSocialActivityCounts||{},v=d((t.actor?.name?.text?t.actor:r(n,t.actor?.["*entityUrn"]))||t.actor,n),{text:N,attributes:U}=x(t.commentary||t.content?.commentary),j=t["*resharedUpdate"]||t.resharedUpdate?.["*entityUrn"]||t.resharedUpdateV2?.["*entityUrn"]||t["*resharedUpdateV2"]||t.content?.feedRepublishComponent?.["*update"]||t.content?.shareSubComponent?.["*update"]||t.content?.entityComponent?.["*update"]||null,w=null;if(j&&o<2){let t=r(n,j);t&&(w=e(t,n,i,o+1))}!w&&o<2&&t.resharedUpdate&&"object"==typeof t.resharedUpdate&&(t.resharedUpdate.entityUrn||t.resharedUpdate.actor)&&(w=e(t.resharedUpdate,n,i,o+1));let C=t.header?.text?.text??t.actor?.supplementaryActorInfo?.text??null,k=[];for(let e of i){let t=e.entityUrn||"",r=a(t),i=r?.parent;(f&&i===f||f&&t.includes(f)||c&&t.includes(c))&&k.push(y(e,n))}let P=u(k);return{urn:c,ugcPostUrn:f,socialDetailUrn:h?.entityUrn||m||null,contextHeader:C,author:v,text:N,attributes:U,media:function(e,t){if(!e)return[];let n=[];if(e.imageComponent?.images?.length)for(let t of e.imageComponent.images){let e=p(t)||void 0;if(!e)continue;let r=g(t);n.push({type:"image",url:e,width:r?.width,height:r?.height,raw:t})}if(e.linkedInVideoComponent){let r,i=e.linkedInVideoComponent,a=p(i.insightImage)||void 0,o=i["*videoPlayMetadata"],l=t&&o?t.get(o):i.videoPlayMetadata||null,s=l?.progressiveStreams?.[0],c=s?.streamingLocations?.[0]?.url;c&&(r=c);let m=function(e){if(!e||"object"!=typeof e)return null;let t=e.progressiveStreams;if(Array.isArray(t)&&t.length)for(let e of[...t].sort((e,t)=>
1(Number(t?.width)||0)-(Number(e?.width)||0))){let t=Number(e?.width),n=Number(e?.height);if(t>0&&n>0)return{width:t,height:n}}let n=Number(e.width),r=Number(e.height);return n>0&&r>0?{width:n,height:r}:null}(l),u=g(i.insightImage),d=m?.width??u?.width,h=m?.height??u?.height;n.push({type:"video",thumbnailUrl:a,url:i.embedUrl||void 0,streamUrl:r,title:i.title?.text||void 0,...d&&h?{width:d,height:h}:{},raw:i})}if(e.externalVideoComponent){let t=e.externalVideoComponent,r=t.previewImage,i=g(r);n.push({type:"video",thumbnailUrl:p(r)||void 0,url:t.viewingUrl||t.url,title:t.title?.text||void 0,...i?{width:i.width,height:i.height}:{},raw:t})}if(e.articleComponent){let t,r=e.articleComponent,i=r.navigationContext?.actionTarget||void 0;if(i)try{t=new URL(i).hostname.replace(/^www\./,"")}catch{}n.push({type:"article",title:r.title?.text||void 0,subtitle:r.subtitle?.text||t||void 0,url:i,domain:t,thumbnailUrl:p(r.largeImage)||p(r.smallImage)||void 0,raw:r})}if(e.documentComponent){let t=e.documentComponent,r=function(e){let t=e?.coverPages?.pagesPerResolution;if(!Array.isArray(t)||0===t.length)return{images:[]};let n=[...t].sort((e,t)=>(Number(e?.width)||0)-(Number(t?.width)||0)),r=n.find(e=>(Number(e?.width)||0)>=1e3)??n[n.length-1];return{images:Array.isArray(r?.imageUrls)?r.imageUrls.filter(e=>"string"==typeof e&&/^https?:\/\//.test(e)):[],width:Number(r?.width)||void 0,height:Number(r?.height)||void 0}}(t.document);n.push({type:"document",title:t.document?.title||t.title?.text||void 0,thumbnailUrl:r.images[0]||p(t.document?.coverPages?.[0])||void 0,pageImages:r.images.length?r.images:void 0,pageCount:"number"==typeof t.document?.totalPageCount?t.document.totalPageCount:r.images.length||void 0,width:r.width,height:r.height,url:t.actionTarget||void 0,raw:t})}if(e.pollComponent){let t=e.pollComponent;n.push({type:"poll",title:t.question?.text||t.pollSummary?.text||void 0,raw:t})}if(e.celebrationComponent&&n.push({type:"celebration",raw:e.celebrationComponent}),e.entityComponent){let t=e.entityComponent;n.push({type:"article",title:t.titleV2?.text?.text||t.title?.text||void 0,subtitle:t.subtitle?.text||void 0,thumbnailUrl:p(t.image)||void 0,url:t.navigationContext?.actionTarget||void 0,raw:t})}return n}(t.content,n),resharedPostUrn:j,resharedPost:w,inlineComments:P,postedAt:function(e){if(!e)return null;let t=e.match(/urn:li:(?:fs_)?activity:(\d+)/)||e.match(/urn:li:fsd_update:\(urn:li:activity:(\d+)/);if(!t)return null;try{let e=BigInt(t[1]),n=Number(e>>BigInt(22));if(n>1e12&&n<4e12)return n}catch{}return null}(c),postedAgeText:t.actor?.subDescription?.text?.trim()||null,reactionsCount:b.numLikes??b.numReactions??0,commentsCount:b.numComments??0,sharesCount:b.numShares??0,impressionsCount:null,raw:0===o?t:void 0}})(e,o,f)),paginationToken:m}},"decodeReactionsResponse",0,function(e){if(!e)return{reactors:[],paginationToken:null};let i=e.included||[],a=n(i),o=i.filter(e=>e?.$type==="com.linkedin.voyager.dash.social.Reaction").map(e=>{let n=e.reactorLockup||{},i=n.title?.text??null,o=n.subtitle?.text??null,l=p(n.image),s=(n.navigationUrl||"").match(/\/in\/([^/?]+)/),c=s?(()=>{try{return decodeURIComponent(s[1])}catch{return s[1]}})():null,m=e.actorUrn||e["*reactor"]||e.reactorUrn||"";"string"!=typeof m&&(m="");let u=m.trim();if(u&&!u.startsWith("urn:")){let e=r(a,u);u=("string"==typeof e?.entityUrn?e.entityUrn:null)||("string"==typeof e?.preDashEntityUrn?e.preDashEntityUrn:null)||u}return u&&!u.startsWith("urn:")&&(u=""),{reactorUrn:u.startsWith("urn:")?(0,t.normalizeLinkedinProfileUrnForMatch)(u)||u:null,reactionType:e.reactionType||"LIKE",name:i,headline:o,vanityName:c,pictureUrl:l}}),l=e.data?.data||e.data||e,s=l?.socialDashReactionsByReactionType||l?.socialDashReactionsByThread||l?.socialDashReactions||Object.values(l||{}).find(e=>e&&"object"==typeof e&&e.metadata?.paginationToken)||null;return{reactors:o,paginationToken:s?.metadata?.paginationToken||null}},"dropSupersededOptimisticComments",0,function(e){let t=new Set;for(let n of e){if(l(n.commentUrn))continue;let e=s(n.text);e&&t.add(e)}return t.size?e.filter(e=>!(l(e.commentUrn)&&t.has(s(e.text)))):e},"inferCommentParentsFromUrns",0,u,"parentCommentUrnForReplyFetch",0,function(e,t){return e?.trim()&&(c(e,t)||m(e))?e:t}])},430172,e=>{"use strict";var t=e.i(309789);e.s(["PanelRightOpen",()=>t.default])}]);

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.