hive-react-kit 1.6.8 → 1.6.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +2 -2
- package/dist/index.esm.js +166 -156
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1159,8 +1159,8 @@ ${fe}
|
|
|
1159
1159
|
<circle cx="12" cy="11.5" r="4.4" fill="var(--hrk-warning-soft)"/>
|
|
1160
1160
|
</svg>`,gz=ZL.divIcon({className:"hive-worldmappin-pin",html:pz,iconSize:[24,32],iconAnchor:[12,30],popupAnchor:[0,-28]}),fN=({lat:a,lng:o,description:l,height:u=320,zoom:d=12,className:f=""})=>{const m=T.useMemo(()=>[a,o],[a,o]);if(T.useEffect(()=>{mz()},[]),!Number.isFinite(a)||!Number.isFinite(o))return null;const g=typeof u=="number"?`${u}px`:u;return t.jsxs("div",{className:`hive-worldmappin rounded-lg overflow-hidden border border-[rgba(255,255,255,0.08)] bg-[var(--hrk-bg-surface-sunken)] ${f}`,children:[t.jsx("div",{style:{height:g,width:"100%"},children:t.jsxs(lz,{center:m,zoom:d,scrollWheelZoom:!1,zoomControl:!1,style:{height:"100%",width:"100%",background:"var(--hrk-bg-surface-sunken)"},children:[t.jsx(dz,{attribution:'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',url:"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"}),t.jsx(fz,{position:"bottomright"}),t.jsx(uz,{position:m,icon:gz,children:l&&t.jsx(cz,{children:t.jsx("div",{className:"text-sm text-gray-800 max-w-[220px]",children:l})})})]})}),t.jsxs("div",{className:"px-3 py-2 bg-[rgba(255,255,255,0.04)] border-t border-[rgba(255,255,255,0.08)] flex items-center gap-2 text-xs text-[var(--hrk-text-secondary)]",children:[t.jsx("span",{className:"flex-shrink-0 w-2 h-2 rounded-full bg-[var(--hrk-brand)]"}),t.jsx("span",{className:"truncate",children:l||`${a.toFixed(5)}, ${o.toFixed(5)}`})]})]})},uk=/\[\/\/\]:#\s*\(\s*!worldmappin\s+(-?\d+(?:\.\d+)?)\s+lat\s+(-?\d+(?:\.\d+)?)\s+long\s+([\s\S]*?)\s+d3scr\s*\)/gi;function NT(a){if(!a)return[];const o=[];uk.lastIndex=0;let l;for(;(l=uk.exec(a))!==null;){const u=parseFloat(l[1]),d=parseFloat(l[2]);!Number.isFinite(u)||!Number.isFinite(d)||o.push({lat:u,lng:d,description:l[3].trim(),raw:l[0]})}return o}function jT(a){return NT(a)[0]??null}function bz(a){return a&&a.replace(uk,"").replace(/\n{3,}/g,`
|
|
1161
1161
|
|
|
1162
|
-
`)}function ST({sort:a="trending",tag:o="",observer:l="hive.blog",limit:u=20,showSortDropdown:d=!0,theme:f="dark",onAuthorClick:m,onPostClick:g,onCommunityClick:x,onPayoutClick:y,onUpvoteClick:b,onCommentClick:w,onReblogClick:v}){const[j,M]=T.useState([]),[P,D]=T.useState(!0),[E,z]=T.useState(null),[H,$]=T.useState(a),[R,A]=T.useState(!0),[q,F]=T.useState(!1),X=T.useRef(null);new Bw.DefaultRenderer({baseUrl:"https://hive.blog/",breaks:!0,skipSanitization:!1,allowInsecureScriptTags:!1,addNofollowToLinks:!0,doNotShowImages:!1,assetsWidth:640,assetsHeight:480,imageProxyFn:G=>G,usertagUrlFn:G=>`/@${G}`,hashtagUrlFn:G=>`/trending/${G}`,isLinkSafeFn:G=>!0,addExternalCssClassToMatchingLinksFn:G=>!0,ipfsPrefix:"https://ipfs.io/ipfs/"});const Y=T.useCallback(async(G,K=!1)=>{K?F(!0):(D(!0),A(!0)),z(null);try{const ee=K&&j.length>0?j[j.length-1]:null,ye=await Cn.getRankedPosts(G,o,l,u,ee?.author,ee?.permlink);K?(M(we=>{const Me=new Set(we.map(se=>se.post_id)),Ue=ye.filter(se=>!Me.has(se.post_id));return[...we,...Ue]}),A(ye.length===u)):(M(ye),A(ye.length===u))}catch(ee){z(ee instanceof Error?ee.message:"Failed to load posts"),A(!1)}finally{D(!1),F(!1)}},[o,l,u,j]),Z=T.useCallback(()=>{!q&&R&&!P&&Y(H,!0)},[q,R,P,H,Y]);T.useEffect(()=>{Y(H)},[H,o,l,u]),T.useEffect(()=>{const G=new IntersectionObserver(K=>{K[0].isIntersecting&&Z()},{threshold:1});return X.current&&G.observe(X.current),()=>{X.current&&G.unobserve(X.current)}},[Z]);const J=G=>{$(G),M([]),A(!0)},re=G=>G>=1e6?`${(G/1e6).toFixed(1)}M`:G>=1e3?`${(G/1e3).toFixed(1)}K`:G.toString(),ce=G=>{const K=G.payout*.5,ee=G.payout*.5,we=(G.beneficiaries.find(Me=>Me.account==="commentrewarder")?.weight||0)/1e4*100;return{pending:`$${G.payout.toFixed(2)}`,breakdown:`${K.toFixed(2)} HBD, ${ee.toFixed(2)} HP`,commentRewarder:`${we.toFixed(2)}%`,payoutInDays:Math.ceil((new Date(G.payout_at).getTime()-Date.now())/(1e3*60*60*24))}},le=G=>{const ee=(G.body||"").replace(/!\[[^\]]*\]\([^)]+\)/g,"").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/^#+\s*/gm,"").replace(/\*\*([^*]+)\*\*/g,"$1").replace(/\*([^*]+)\*/g,"$1").replace(/`([^`]+)`/g,"$1").replace(/<[^>]*>/g,"").replace(/\n+/g," ").trim();return ee.length>200?ee.substring(0,200)+"...":ee};return P?t.jsx("div",{className:"flex justify-center items-center min-h-[400px]",children:t.jsx(W.Loader2,{className:"w-8 h-8 animate-spin"})}):E?t.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[400px] space-y-4",children:[t.jsx("h3",{className:"text-lg font-semibold text-card-foreground",children:"Failed to load posts"}),t.jsx("p",{className:"text-muted-foreground",children:E}),t.jsx("button",{onClick:()=>Y(H),className:"px-4 py-2 bg-primary text-primary-foreground rounded-lg hover:bg-primary/90",children:"Retry"})]}):t.jsx("div",{className:f==="dark"?"dark":"",children:t.jsxs("div",{className:`space-y-6 p-2 ${f==="dark"?"bg-slate-950":"bg-white"}`,children:[d&&t.jsx("div",{className:"flex justify-center",children:t.jsxs("select",{value:H,onChange:G=>J(G.target.value),className:`px-4 py-2 border border-border rounded-lg focus:outline-none focus:ring-2 focus:ring-primary ${f==="dark"?"bg-slate-950 text-white":"bg-card text-card-foreground"}`,children:[t.jsx("option",{value:"trending",children:"Trending"}),t.jsx("option",{value:"hot",children:"Hot"}),t.jsx("option",{value:"created",children:"New"})]})}),t.jsxs("div",{className:"space-y-4",children:[j.map(G=>{const K=G.json_metadata?.image?.[0],ee=ce(G);return t.jsxs("div",{className:`border border-border rounded-xl p-4 shadow-card hover:shadow-card-hover transition-shadow ${f==="dark"?"bg-slate-900 text-white":"bg-slate-50 text-black"}`,children:[t.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[t.jsx("img",{src:`https://images.hive.blog/u/${G.author}/avatar`,alt:G.author,className:"w-8 h-8 rounded-full cursor-pointer flex-shrink-0",onClick:()=>m?.(G.author,`https://images.hive.blog/u/${G.author}/avatar`),onError:ye=>{ye.target.src=`https://ui-avatars.com/api/?name=${G.author}&background=random`}}),t.jsx("span",{className:"font-medium cursor-pointer hover:text-primary",onClick:()=>m?.(G.author,`https://images.hive.blog/u/${G.author}/avatar`),children:G.author}),t.jsxs("span",{className:f==="dark"?"text-gray-400":"text-muted-foreground",children:["(",G.author_reputation.toFixed(2),")"]}),t.jsx("span",{className:`cursor-pointer hover:text-primary ${f==="dark"?"text-gray-400":"text-muted-foreground"}`,onClick:()=>x?.(G.community_title),children:G.community_title}),t.jsx("span",{className:`hidden sm:inline ${f==="dark"?"text-gray-400":"text-muted-foreground"}`,children:"•"}),t.jsx("span",{className:`text-sm ${f==="dark"?"text-gray-400":"text-muted-foreground"}`,children:Wv.formatDistanceToNow(new Date(G.created+"Z"),{addSuffix:!0})})]}),t.jsxs("div",{className:"flex gap-3 sm:gap-4",children:[t.jsx("div",{className:"flex-shrink-0",children:K?t.jsxs("div",{className:"relative",children:[t.jsx("img",{src:K.startsWith("http")?K:`https://images.hive.blog/u/320x0/${K}`,alt:G.title,className:"w-20 h-20 sm:w-32 sm:h-32 object-cover rounded-lg cursor-pointer",onClick:()=>g?.(G),onError:ye=>{ye.target.src!==`https://images.hive.blog/u/${G.author}/avatar`?ye.target.src=`https://images.hive.blog/u/${G.author}/avatar`:ye.target.src="https://images.hive.blog/u/null/avatar"}}),(()=>{const ye=G.body?.match(/!\[[^\]]*\]\(([^)]+)\)/g)?.map(we=>{const Me=we.match(/\(([^)]+)\)/);return Me?Me[1]:null}).filter(Boolean)||[];return ye.length>0?t.jsx("div",{className:"absolute -bottom-1 -right-1 sm:-bottom-2 sm:-right-2 flex space-x-1",children:ye.slice(0,3).map((we,Me)=>t.jsx("img",{src:we,alt:`body-image-${Me}`,className:"w-6 h-6 sm:w-8 sm:h-8 object-cover rounded border-2 border-white shadow-sm cursor-pointer",onClick:Ue=>{Ue.stopPropagation();const se=Ue.currentTarget.parentElement?.parentElement?.querySelector("img:not(.w-6):not(.w-8)");se&&(se.src=we)}},Me))}):null})()]}):t.jsx("img",{src:`https://images.hive.blog/u/${G.author}/avatar`,alt:G.author,className:"w-20 h-20 sm:w-32 sm:h-32 rounded-lg cursor-pointer",onClick:()=>g?.(G)})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("h3",{className:"font-semibold text-base sm:text-lg mb-1 sm:mb-2 cursor-pointer hover:text-primary line-clamp-2",onClick:()=>g?.(G),children:G.title}),t.jsx("p",{className:`mb-2 sm:mb-3 line-clamp-2 sm:line-clamp-3 cursor-pointer hover:text-primary text-sm sm:text-base ${f==="dark"?"text-gray-300":"text-gray-600"}`,onClick:()=>g?.(G),children:G.json_metadata?.description||le(G)||"No description available"}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"relative group",children:[t.jsxs("span",{className:"font-semibold text-green-600 cursor-pointer hover:text-green-700 text-sm sm:text-base",onClick:()=>y?.(G.payout),children:["$",G.payout.toFixed(2)]}),t.jsxs("div",{className:"absolute bottom-full left-0 mb-2 hidden group-hover:block bg-black text-white text-xs p-2 rounded shadow-lg whitespace-nowrap z-10",children:[t.jsxs("div",{children:["Pending payout amount: ",ee.pending]}),t.jsxs("div",{children:["Breakdown: ",ee.breakdown]}),t.jsxs("div",{children:["commentrewarder: ",ee.commentRewarder]}),t.jsxs("div",{children:["Payout in ",ee.payoutInDays," days"]})]})]}),t.jsxs("div",{className:"flex items-center gap-3 sm:gap-4",children:[t.jsxs("div",{className:`flex items-center gap-1 hover:text-primary transition-colors cursor-pointer ${f==="dark"?"text-gray-400":"text-muted-foreground"}`,onClick:()=>b?.(G),children:[t.jsx(W.ThumbsUp,{className:"w-3 h-3 sm:w-4 sm:h-4"}),t.jsx("span",{className:"text-xs sm:text-sm",children:re(G.stats.total_votes)})]}),t.jsxs("div",{className:`flex items-center gap-1 hover:text-blue-400 transition-colors cursor-pointer ${f==="dark"?"text-blue-400":"text-blue-600"}`,onClick:()=>w?.(G),children:[t.jsx(W.MessageCircle,{className:"w-3 h-3 sm:w-4 sm:h-4"}),t.jsx("span",{className:"text-xs sm:text-sm",children:re(G.children)})]}),t.jsxs("div",{className:`flex items-center gap-1 hover:text-gray-400 transition-colors cursor-pointer ${f==="dark"?"text-gray-400":"text-gray-600"}`,onClick:()=>v?.(G),children:[t.jsx(W.Repeat2,{className:"w-3 h-3 sm:w-4 sm:h-4"}),t.jsx("span",{className:"text-xs sm:text-sm",children:re(G.reblogs)})]})]})]})]})]})]},G.post_id)}),q&&t.jsxs("div",{className:"flex justify-center items-center py-4",children:[t.jsx(W.Loader2,{className:"w-6 h-6 animate-spin"}),t.jsx("span",{className:`ml-2 ${f==="dark"?"text-gray-400":"text-muted-foreground"}`,children:"Loading more posts..."})]}),R&&!q&&t.jsx("div",{ref:X,className:"h-10"})]})]})})}function Ag({author:a,permlink:o,currentUser:l,hiveValue:u,hiveIconUrl:d,payoutTooltip:f,payoutDetails:m,initialVotes:g,initialVoteCount:x,initialCommentsCount:y,onUpvote:b,onSubmitComment:w,onComments:v,onEdit:j,onReblog:M,onReSnap:P,onShare:D,onTip:E,onReport:z,onToggleBookmark:H,isBookmarked:$=!1,onDelete:R,onClickCommentUpvote:A,onUserClick:q,getUserUrl:F,ecencyToken:X,threeSpeakApiKey:Y,giphyApiKey:Z,templateToken:J,templateApiBaseUrl:re,disableCommentsModal:ce,onClickCommentIcon:le,onClickCommentCount:G,hasCommented:K=!1,myReplyKey:ee,showVoteButton:ye,parentTags:we,defaultReward:Me,defaultBeneficiaries:Ue,beneficiaryFavorites:se,defaultVotePercent:be=100,voteWeightStep:xe=.25,allowLandscapeVideos:Ae=!1,actionsAsMenu:Oe=!1,awaitingWalletApproval:Ye=!1,postCreatedAt:Se,size:He="default"}){const he=He==="lg"?"w-4 h-4 sm:w-4 sm:h-4":"w-3.5 h-3.5 sm:w-4 sm:h-4",ge=He==="lg"?"text-sm sm:text-sm":"text-xs sm:text-sm",me=He==="lg"?"w-5 h-5 sm:w-4 sm:h-4 rounded-full":"w-4 h-4 rounded-full",Ve=He==="lg"?"p-1.5 sm:p-1":"p-0.5 sm:p-1",Te=He==="lg"?"gap-1.5 sm:gap-0.5":"gap-0.5",Le=He==="lg"?"gap-2.5 sm:gap-3":"gap-1.5 sm:gap-3",je=He==="lg"?"p-1.5 sm:p-1":"p-0.5 sm:p-1",et=l==null||l===""?null:l,Lt=et!=null,bt=!!et&&!!a&&a.toLowerCase()===et.toLowerCase()?void 0:z,[xr,yr]=T.useState(g??[]),[hr,sr]=T.useState(x??g?.length??0),[or,pr]=T.useState(y??0),[$r,ta]=T.useState(!1),[Pt,wt]=T.useState(!1),[Wt,$t]=T.useState(!1),[Qt,Nr]=T.useState(!1),[Dr,It]=T.useState({message:"",visible:!1}),[da,_t]=T.useState(!1),qt=T.useCallback(gt=>{It({message:gt,visible:!0}),setTimeout(()=>It(Jt=>({...Jt,visible:!1})),2500)},[]),ne=g!==void 0,ue=y!==void 0,ve=T.useCallback(async()=>{try{const gt=await Cn.getActiveVotes(a,o);yr(gt),x===void 0&&sr(gt.length)}catch{}},[a,o,x]);T.useEffect(()=>{ne||ve()},[a,o,ne]),T.useEffect(()=>{ue||Cn.getCommentsList(a,o).then(gt=>{pr(gt.length)}).catch(()=>{})},[a,o,ue]);const ke=Lt&&!!et&&xr.some(gt=>gt.voter.toLowerCase()===et.toLowerCase()),[tt,jt]=T.useState(!1),[ir,Sr]=T.useState(null),[wr,Ot]=T.useState(!1),Vr=()=>{if(!K||(jt(!0),ir!==null||wr||!ee))return;const[gt,Jt]=ee.split("/");if(!gt||!Jt)return;Ot(!0),(async()=>{const Br=async(cr,_r,Aa)=>{const ze=await fetch(_l(),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",method:`${cr}.${_r}`,params:Aa,id:1})});if(!ze.ok)throw new Error(`Hive RPC ${ze.status}`);const Xe=await ze.json();if(Xe.error)throw new Error(Xe.error.message??"Hive RPC error");return Xe.result};try{const cr=await Br("bridge","get_post",{author:gt,permlink:Jt});if(cr&&typeof cr=="object"&&typeof cr.body=="string")return cr.body}catch{}try{const cr=await Br("condenser_api","get_content",[gt,Jt]);if(cr&&typeof cr=="object"&&typeof cr.body=="string")return cr.body}catch{}return""})().then(Br=>Sr(Br)).catch(()=>Sr("")).finally(()=>Ot(!1))},sa=T.useMemo(()=>{if(!ir)return"";let gt=ir;return gt=gt.replace(/\s*(?:<br\s*\/?>)?\s*<sub>\s*\[via Apps from\]\([^)]+\)\s*<\/sub>\s*$/i,""),gt=gt.replace(/\s*posted using.*$/i,""),gt=gt.replace(/!\[[^\]]*\]\([^)]+\)/g,""),gt=gt.replace(/\[([^\]]+)\]\([^)]+\)/g,"$1"),gt=gt.replace(/<[^>]+>/g,""),gt=gt.replace(/https?:\/\/\S+/g,""),gt=gt.replace(/[*_~`#>-]+/g," "),gt=gt.replace(/\s+/g," ").trim(),gt},[ir]),ra=(gt,Jt)=>{if(!Lt&>!=="Comment"){qt(`Please Login to ${gt}`);return}Jt()},Tt=T.useMemo(()=>Hw(Se),[Se]),vt=()=>{ra("Upvote",()=>{if(ke){qt("You have already upvoted this post");return}if(Tt){qt(qv);return}ta(!0)})},Gr=async gt=>{if(b){_t(!0);try{await Promise.resolve(b(gt)),ta(!1),qt("Vote submitted successfully"),x===void 0&&sr(Jt=>Jt+1),await ve(),setTimeout(()=>{ve()},4e3)}catch(Jt){const Ht=Jt instanceof Error?Jt.message:"Failed to upvote";qt(Ht)}finally{_t(!1)}}},Mr=()=>{wt(!0)},vr=()=>{if(wt(!1),!Lt){qt("Please Login to Upvote");return}if(ke){qt("You have already upvoted this post");return}if(Tt){qt(qv);return}ta(!0)},We=()=>{if(ce){v?.();return}ra("Comment",()=>{v?.(),Nr(!0)})},Mt=()=>{ra("Reblog",()=>M?.())},At=()=>{ra("Re-snap",()=>P?.())},Gt=()=>{ra("Report",()=>z?.())},Yt=()=>{ra("Tip",()=>E?.())},Kt=()=>{if(D){D();return}typeof navigator<"u"&&navigator.share?navigator.share({title:`${a}'s post`,url:`https://peakd.com/@${a}/${o}`,text:`Check out this post by @${a}`}).then(()=>qt("Shared")).catch(()=>{}):(navigator.clipboard?.writeText(`https://peakd.com/@${a}/${o}`),qt("Link copied to clipboard"))},er=async(gt,Jt,Ht,Br,cr)=>{if(w)try{if(await Promise.resolve(w(gt,Jt,Ht,Br??null,cr))===!1)return!1;qt("Comment posted")}catch(_r){const Aa=_r instanceof Error?_r.message:"Failed to post comment";throw qt(Aa),_r}},Bt="hidden";return t.jsxs("div",{className:`flex items-center justify-between gap-2 sm:gap-4 w-full ${ge}`,children:[t.jsxs("div",{className:`flex flex-wrap items-center justify-center shrink-0 ${Le}`,children:[t.jsxs("div",{className:`flex items-center ${Te}`,children:[t.jsxs("div",{className:"relative group",children:[t.jsx("span",{className:Bt,children:"Upvote"}),t.jsx("button",{type:"button",onClick:vt,disabled:da,className:`${je} rounded hover:bg-gray-700 disabled:opacity-50`,"aria-label":"Upvote",children:da?t.jsx(W.Loader2,{className:`${he} animate-spin text-blue-600`}):t.jsx(W.ThumbsUp,{className:`${he} ${ke?"fill-[var(--hrk-brand)] text-[var(--hrk-brand)]":"text-gray-300"}`})})]}),t.jsxs("div",{className:"relative group",children:[t.jsx("span",{className:Bt,children:"View upvotes"}),t.jsx("button",{type:"button",onClick:Mr,className:`flex items-center text-gray-300 hover:text-blue-400 transition-colors ${Te} ${je} rounded hover:bg-gray-700/40`,"aria-label":"View upvotes",children:t.jsx("span",{children:hr})})]})]}),le||G?t.jsxs("div",{className:`relative group flex items-center text-gray-300 ${Te}`,children:[t.jsx("span",{className:Bt,children:"Comments"}),t.jsxs("div",{className:"relative",onMouseEnter:Vr,onMouseLeave:()=>jt(!1),children:[t.jsx("button",{type:"button",onClick:()=>{le?le():We()},className:`rounded transition-colors hover:text-blue-400 ${Ve}`,"aria-label":K?"Reply to post (you've already commented)":"Reply to post",children:t.jsx(W.MessageCircle,{className:`${he} ${K?"fill-[var(--hrk-brand)] text-[var(--hrk-brand)]":""}`})}),K&&tt&&t.jsxs("div",{className:"absolute bottom-full left-0 z-30 mb-2 w-72 rounded-lg border border-[var(--hrk-border-default)] bg-[var(--hrk-bg-surface-sunken)] p-3 shadow-xl",children:[t.jsx("p",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wide text-[var(--hrk-brand-fg-soft)]",children:"Your comment"}),wr&&t.jsx("p",{className:"text-xs text-[var(--hrk-text-tertiary)]",children:"Loading…"}),!wr&&sa&&t.jsx("p",{className:"line-clamp-6 whitespace-pre-wrap text-xs leading-relaxed text-[var(--hrk-text-secondary)]",children:sa}),!wr&&!sa&&ir!==null&&t.jsx("p",{className:"text-xs italic text-[var(--hrk-text-tertiary)]",children:"No preview available."})]})]}),t.jsx("button",{type:"button",onClick:()=>{G?G():We()},className:`rounded transition-colors ${Ve} ${K?"text-[var(--hrk-brand-fg-soft)]":"text-gray-300 hover:text-blue-400"}`,"aria-label":"Open comments",children:or})]}):t.jsxs("div",{className:"relative group",onMouseEnter:Vr,onMouseLeave:()=>jt(!1),children:[t.jsx("span",{className:Bt,children:"Comments"}),t.jsxs("button",{type:"button",onClick:We,className:`flex items-center transition-colors hover:text-blue-400 rounded ${Te} ${Ve} ${K?"text-[var(--hrk-brand-fg-soft)]":"text-gray-300"}`,"aria-label":"Comments",children:[t.jsx(W.MessageCircle,{className:`${he} ${K?"fill-[var(--hrk-brand)] text-[var(--hrk-brand)]":""}`}),t.jsx("span",{children:or})]}),K&&tt&&t.jsxs("div",{className:"absolute bottom-full left-0 z-30 mb-2 w-72 rounded-lg border border-[var(--hrk-border-default)] bg-[var(--hrk-bg-surface-sunken)] p-3 shadow-xl",children:[t.jsx("p",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wide text-[var(--hrk-brand-fg-soft)]",children:"Your comment"}),wr&&t.jsx("p",{className:"text-xs text-[var(--hrk-text-tertiary)]",children:"Loading…"}),!wr&&sa&&t.jsx("p",{className:"line-clamp-6 whitespace-pre-wrap text-xs leading-relaxed text-[var(--hrk-text-secondary)]",children:sa}),!wr&&!sa&&ir!==null&&t.jsx("p",{className:"text-xs italic text-[var(--hrk-text-tertiary)]",children:"No preview available."})]})]}),Oe?t.jsx(Hv,{onEdit:j,onReblog:M?Mt:void 0,onReSnap:P?At:void 0,onShare:Kt,onTip:E?Yt:void 0,onReport:bt?Gt:void 0,onToggleBookmark:H,isBookmarked:$,onDelete:R}):t.jsxs(t.Fragment,{children:[M&&t.jsxs("div",{className:"relative group",children:[t.jsx("span",{className:Bt,children:"Reblog"}),t.jsx("button",{type:"button",onClick:Mt,className:`flex items-center text-gray-300 hover:text-blue-400 transition-colors rounded ${Te} ${Ve}`,"aria-label":"Reblog",children:t.jsx(W.Repeat2,{className:he})})]}),t.jsxs("div",{className:"relative group",children:[t.jsx("span",{className:Bt,children:"Share"}),t.jsx("button",{type:"button",onClick:Kt,className:`flex items-center text-gray-300 hover:text-blue-400 transition-colors rounded ${Te} ${Ve}`,"aria-label":"Share",children:t.jsx(W.Share2,{className:he})})]}),bt&&t.jsxs("div",{className:"relative group",children:[t.jsx("span",{className:Bt,children:"Report"}),t.jsx("button",{type:"button",onClick:Gt,className:`flex items-center text-gray-300 hover:text-red-400 transition-colors rounded ${Te} ${Ve}`,"aria-label":"Report",children:t.jsx(W.Flag,{className:he})})]}),E&&t.jsxs("div",{className:"relative group",children:[t.jsx("span",{className:Bt,children:"Tip"}),t.jsx("button",{type:"button",onClick:Yt,className:`flex items-center text-gray-300 hover:text-green-400 transition-colors rounded ${Te} ${Ve}`,"aria-label":"Tip",children:t.jsx(W.Gift,{className:he})})]}),(j||R||H)&&t.jsx(Hv,{onEdit:j,onToggleBookmark:H,isBookmarked:$,onDelete:R,ariaLabel:"More post actions"})]})]}),t.jsx("div",{className:"flex-1 flex justify-end min-w-0 shrink-0",children:u!=null&&u!==""&&(m?t.jsxs("button",{type:"button",onClick:gt=>{gt.stopPropagation(),$t(!0)},className:"flex items-center gap-1 rounded-md px-1 py-0.5 transition-colors hover:bg-white/5","aria-label":"Show rewards breakdown",children:[t.jsx("span",{className:`font-semibold text-green-400 ${ge}`,children:u}),d&&t.jsx("img",{src:d,alt:"Hive",className:me})]}):t.jsxs("div",{className:"relative group",children:[t.jsxs("div",{className:"flex items-center gap-1 cursor-default",children:[t.jsx("span",{className:`font-semibold text-green-400 ${ge}`,children:u}),d&&t.jsx("img",{src:d,alt:"Hive",className:me})]}),f&&t.jsx("div",{className:"absolute right-0 bottom-full mb-2 w-64 px-3 py-2 text-xs text-gray-200 bg-gray-900 border border-gray-700 rounded-lg shadow-xl whitespace-pre-line opacity-0 pointer-events-none group-hover:opacity-100 group-hover:pointer-events-auto transition-opacity duration-200 z-[60]",children:f})]}))}),$r&&t.jsx(Uw,{author:a,permlink:o,defaultValue:be,step:xe,onUpvote:Gr,onCancel:()=>ta(!1),awaitingWalletApproval:Ye}),Wt&&m&&t.jsx(yk,{onClose:()=>$t(!1),details:m,hiveIconUrl:d}),Pt&&t.jsx($w,{author:a,permlink:o,onClose:()=>wt(!1),currentUser:et??void 0,token:void 0,onClickUpvoteButton:vr,hiveIconUrl:d,onUserClick:q,getUserUrl:F}),Qt&&t.jsx(oN,{author:a,permlink:o,onClose:()=>{Nr(!1),Cn.getCommentsList(a,o).then(gt=>pr(gt.length))},currentUser:et??void 0,token:void 0,onSubmitComment:w?er:void 0,onClickCommentUpvote:A,ecencyToken:X,threeSpeakApiKey:Y,giphyApiKey:Z,templateToken:J,templateApiBaseUrl:re,showVoteButton:!!ye&&!ke,parentTags:we,defaultReward:Me,defaultBeneficiaries:Ue,beneficiaryFavorites:se,defaultVotePercent:be,voteWeightStep:xe,allowLandscapeVideos:Ae,awaitingWalletApproval:Ye}),Dr.visible&&t.jsx("div",{className:"fixed bottom-4 right-4 z-[100] max-w-[280px] rounded-lg bg-gray-900 text-white px-3 py-2 shadow-lg text-sm",children:Dr.message})]})}function hN(a){const o=a??"",{language:l}=$k(),[u,d]=T.useState(o),[f,m]=T.useState(!1);return T.useEffect(()=>{if(!l||!o){d(o),m(!1);return}let g=!1;return m(!0),Bk(o,l).then(x=>{g||(d(x),m(!1))}).catch(()=>{g||(d(o),m(!1))}),()=>{g=!0}},[o,l]),{text:u,loading:f}}const _g=({text:a,fallback:o})=>{const{text:l}=hN(a??""),u=l||a;return t.jsx(t.Fragment,{children:u||o||""})},xz=/!\[[^\]]*\]\(([^\s)]+)\)/g,vz=/<img[^>]+src=["']([^"']+)["'][^>]*>/gi,yz=/https?:\/\/[^\s"'<>)]+\.(?:jpe?g|png|gif|webp|avif)(?:\?[^\s"'<>)]*)?/gi,wz=/https?:\/\/(?:www\.)?youtube\.com\/watch\?v=([^&\s]+)|https?:\/\/youtu\.be\/([^?\s]+)|https?:\/\/(?:www\.)?youtube\.com\/shorts\/([^?\s]+)/gi,_z=/https?:\/\/(?:play\.)?3speak\.tv\/[^\s"'<>)]+/gi,kz=/https?:\/\/(?:www\.)?(?:twitter\.com|x\.com)\/[^/]+\/status\/(\d+)/gi;function Nz(a){const o=new Set,l=[];for(const u of a){const d=u.kind==="image"?`image:${u.url}`:u.kind==="youtube"?`youtube:${u.id}`:u.kind==="twitter"?`twitter:${u.id}`:`threespeak:${u.url}`;o.has(d)||(o.add(d),l.push(u))}return l}function ET(a){const o=[],l=a.json_metadata;if(l&&typeof l=="object"&&Array.isArray(l.image))for(const f of l.image)typeof f=="string"&&f&&o.push({kind:"image",url:f});const u=a.body??"";let d;for(;d=xz.exec(u);)o.push({kind:"image",url:d[1]});for(;d=vz.exec(u);)o.push({kind:"image",url:d[1]});for(;d=yz.exec(u);)o.push({kind:"image",url:d[0]});for(;d=wz.exec(u);){const f=d[1]||d[2]||d[3];f&&o.push({kind:"youtube",id:f})}for(;d=_z.exec(u);)o.push({kind:"threespeak",url:d[0]});for(;d=kz.exec(u);)o.push({kind:"twitter",id:d[1],url:d[0]});return Nz(o)}function jz(a){try{const l=new URL(a).searchParams.get("v");if(!l)return null;const[u,d]=l.split("/");return!u||!d?null:{author:u,permlink:d}}catch{return null}}const Sz="https://play.3speak.tv/api/embed",Ez="https://play.3speak.tv/api/watch";async function Az(a,o,l){const u=[`${Ez}?v=${a}/${o}`,`${Sz}?v=${a}/${o}`];let d=null;for(const f of u){if(l())throw new Error("cancelled");try{const m=await fetch(f,{headers:{Accept:"application/json"}});if(!m.ok){d=new Error(`HTTP ${m.status}`);continue}const g=await m.json();if(g?.success&&AT(g).length>0)return g;d=new Error("Video not found")}catch(m){d=m instanceof Error?m:new Error("fetch failed")}}throw d??new Error("Video unavailable")}function AT(a){return[a.videoUrl,a.videoUrlFallback1,a.videoUrlFallback2,a.videoUrlFallback3].filter(o=>typeof o=="string"&&o.length>0)}function Tz(a,o,l){if(a.canPlayType("application/vnd.apple.mpegurl")||!o.includes(".m3u8")){let f=!1;const m=()=>{f||(f=!0,l?.())};return a.addEventListener("error",m),a.src=o,()=>{a.removeEventListener("error",m),a.removeAttribute("src"),a.load()}}if(Pd.isSupported()){const f=new Pd({enableWorker:!0,lowLatencyMode:!1});let m=!1;return f.on(Pd.Events.ERROR,(g,x)=>{!x.fatal||m||(m=!0,l?.())}),f.loadSource(o),f.attachMedia(a),()=>{try{f.destroy()}catch{}}}let u=!1;const d=()=>{u||(u=!0,l?.())};return a.addEventListener("error",d),a.src=o,()=>{a.removeEventListener("error",d),a.removeAttribute("src"),a.load()}}function fm({author:a,permlink:o,hideThumbnail:l=!1}){const[u,d]=T.useState(null),[f,m]=T.useState(null),[g,x]=T.useState(null),[y,b]=T.useState(!1),w=T.useRef(null);T.useEffect(()=>{let z=!1;return d(null),m(null),x(null),b(!1),Az(a,o,()=>z).then(H=>{z||d(H)}).catch(H=>{!z&&(!(H instanceof Error)||H.message!=="cancelled")&&m("Failed to load video")}),()=>{z=!0}},[a,o]),T.useEffect(()=>{const z=w.current;if(!z||!u)return;const H=AT(u);if(H.length===0){m("Video unavailable");return}const $=()=>{z.videoWidth>0&&z.videoHeight>0&&x(z.videoWidth/z.videoHeight)},R=()=>b(!0);z.addEventListener("loadedmetadata",$),z.addEventListener("playing",R);let A=!1,q=null,F=0;const X=()=>{if(A)return;if(q&&(q(),q=null),F>=H.length){m("Failed to load video");return}const Y=H[F];F+=1,q=Tz(z,Y,()=>{setTimeout(X,0)})};return X(),()=>{A=!0,z.removeEventListener("loadedmetadata",$),z.removeEventListener("playing",R),q&&q()}},[u]);const M=`threeSpeakNative ${(g!=null?g<1:u?.short===!0)?"threeSpeakNativePortrait":"threeSpeakNativeLandscape"}${l?" threeSpeakNativeNoThumb":""}`,P=u?.short===!0?9/16:16/9,D=g??(u?P:null),E=l?D!=null?{aspectRatio:`${D}`}:void 0:g!=null?{aspectRatio:`${g}`}:void 0;return f?t.jsx("div",{className:M,"data-state":"error",children:t.jsx("div",{className:"threeSpeakNativeMessage",children:f})}):u?t.jsxs("div",{className:M,style:E,"data-state":"ready",children:[!l&&u.thumbnail&&!y&&t.jsx("img",{src:u.thumbnail,alt:"",className:"threeSpeakNativeThumb","aria-hidden":"true"}),t.jsx("video",{ref:w,controls:!0,playsInline:!0,preload:"metadata"})]}):t.jsx("div",{className:M,"data-state":"loading",children:t.jsx("div",{className:"threeSpeakNativeMessage",children:"Loading video…"})})}const rw=1,aw=4,jv=.5,TT=({items:a,startIndex:o=0,onClose:l})=>{const[u,d]=T.useState(()=>Math.max(0,Math.min(o,Math.max(0,a.length-1)))),[f,m]=T.useState(1),[g,x]=T.useState(0),[y,b]=T.useState(0),w=T.useRef(null),[v,j]=T.useState(!1),M=a.length===0?0:Math.max(0,Math.min(u,a.length-1)),P=a[M],D=P?.kind==="image";if(T.useEffect(()=>{m(1),x(0),b(0),j(!1)},[M]),T.useEffect(()=>{const F=Y=>{Y.key==="Escape"?l():Y.key==="ArrowLeft"?d(Z=>a.length===0?Z:(Z-1+a.length)%a.length):Y.key==="ArrowRight"?d(Z=>a.length===0?Z:(Z+1)%a.length):Y.key==="+"||Y.key==="="?m(Z=>Math.min(aw,Z+jv)):Y.key==="-"||Y.key==="_"?m(Z=>Math.max(rw,Z-jv)):Y.key==="0"&&(m(1),x(0),b(0))};window.addEventListener("keydown",F);const X=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{window.removeEventListener("keydown",F),document.body.style.overflow=X}},[l,a.length]),!P)return null;const E=()=>{a.length<=1||d(F=>(F-1+a.length)%a.length)},z=()=>{a.length<=1||d(F=>(F+1)%a.length)},H=F=>{if(!D)return;F.preventDefault();const X=F.deltaY<0?1:-1;m(Y=>Math.max(rw,Math.min(aw,Y+X*jv)))},$=F=>{!D||f===1||(w.current={startX:F.clientX,startY:F.clientY,baseTx:g,baseTy:y},F.target.setPointerCapture?.(F.pointerId))},R=F=>{w.current&&(x(w.current.baseTx+(F.clientX-w.current.startX)),b(w.current.baseTy+(F.clientY-w.current.startY)))},A=F=>{w.current=null,F.target.releasePointerCapture?.(F.pointerId)},q=()=>{D&&(m(F=>F===1?2:1),f!==1&&(x(0),b(0)))};return t.jsx("div",{className:"fixed inset-0 z-[2000] flex items-center justify-center bg-black/85 p-4",role:"dialog","aria-modal":"true",onClick:F=>{F.stopPropagation(),l()},children:t.jsxs("div",{className:"relative flex max-h-[90vh] w-full max-w-5xl items-center justify-center",onClick:F=>F.stopPropagation(),children:[t.jsx("button",{onClick:F=>{F.stopPropagation(),l()},className:"absolute -top-10 right-0 z-10 rounded-full bg-black/60 p-2 text-white transition-colors hover:bg-black/80","aria-label":"Close",children:t.jsx(W.X,{className:"h-5 w-5"})}),a.length>1&&t.jsxs("span",{className:"absolute -top-9 left-1/2 -translate-x-1/2 rounded-full bg-black/60 px-3 py-1 text-xs font-medium text-white",children:[M+1," / ",a.length]}),a.length>1&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:F=>{F.stopPropagation(),E()},className:"absolute left-2 top-1/2 -translate-y-1/2 z-10 rounded-full bg-black/60 p-2 text-white transition-colors hover:bg-black/80","aria-label":"Previous",children:t.jsx(W.ChevronLeft,{className:"h-6 w-6"})}),t.jsx("button",{onClick:F=>{F.stopPropagation(),z()},className:"absolute right-2 top-1/2 -translate-y-1/2 z-10 rounded-full bg-black/60 p-2 text-white transition-colors hover:bg-black/80","aria-label":"Next",children:t.jsx(W.ChevronRight,{className:"h-6 w-6"})})]}),D&&t.jsxs("div",{className:"absolute -bottom-12 left-1/2 -translate-x-1/2 z-10 flex items-center gap-2 rounded-full bg-black/60 px-2 py-1 text-white",children:[t.jsx("button",{onClick:F=>{F.stopPropagation(),m(X=>Math.max(rw,X-jv))},className:"rounded-full p-1.5 hover:bg-white/15 disabled:opacity-40","aria-label":"Zoom out",disabled:f<=rw,children:t.jsx(W.ZoomOut,{className:"h-4 w-4"})}),t.jsxs("span",{className:"min-w-[3rem] text-center text-xs tabular-nums",children:[Math.round(f*100),"%"]}),t.jsx("button",{onClick:F=>{F.stopPropagation(),m(X=>Math.min(aw,X+jv))},className:"rounded-full p-1.5 hover:bg-white/15 disabled:opacity-40","aria-label":"Zoom in",disabled:f>=aw,children:t.jsx(W.ZoomIn,{className:"h-4 w-4"})}),t.jsx("span",{className:"mx-1 h-4 w-px bg-white/25"}),t.jsx("button",{onClick:F=>{F.stopPropagation(),m(1),x(0),b(0)},className:"rounded-full p-1.5 hover:bg-white/15","aria-label":"Reset zoom",children:t.jsx(W.RotateCcw,{className:"h-4 w-4"})})]}),P.kind==="image"&&t.jsxs("div",{className:"relative flex max-h-[80vh] w-full items-center justify-center overflow-hidden select-none",onWheel:H,onPointerDown:$,onPointerMove:R,onPointerUp:A,onPointerCancel:A,onDoubleClick:q,style:{touchAction:f===1?"auto":"none"},children:[!v&&t.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center pointer-events-none",children:t.jsx(W.Loader2,{className:"h-8 w-8 animate-spin text-white/80"})}),t.jsx("img",{src:P.url,alt:"",draggable:!1,onLoad:()=>j(!0),onError:()=>j(!0),className:"max-h-[80vh] max-w-full rounded-lg object-contain transition-transform duration-100",style:{transform:`translate(${g}px, ${y}px) scale(${f})`,cursor:f===1?"zoom-in":w.current?"grabbing":"grab",opacity:v?1:.2}})]}),P.kind==="youtube"&&t.jsx("div",{className:"w-full overflow-hidden rounded-lg",style:{aspectRatio:"16/9"},children:t.jsx("iframe",{src:`https://www.youtube-nocookie.com/embed/${P.id}?autoplay=1&rel=0&playsinline=1`,title:"YouTube",className:"h-full w-full border-0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})}),P.kind==="threespeak"&&(()=>{const F=jz(P.url);return F?t.jsx("div",{className:"w-full",style:{maxWidth:"800px"},children:t.jsx(fm,{author:F.author,permlink:F.permlink,hideThumbnail:!0})}):t.jsx("a",{href:P.url,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-[var(--hrk-brand)] underline",children:"Open on 3Speak"})})()]})})};function pi({href:a,onActivate:o,className:l,style:u,title:d,stopPropagation:f=!0,children:m,...g}){const x=g["aria-label"];if(!a)return t.jsx("button",{type:"button",onClick:b=>{f&&b.stopPropagation(),o?.()},className:l,style:u,title:d,"aria-label":x,children:m});const y=b=>{f&&b.stopPropagation(),!(b.metaKey||b.ctrlKey||b.shiftKey||b.altKey||b.button!==0)&&(b.preventDefault(),o?.())};return t.jsx("a",{href:a,onClick:y,className:l,style:u,title:d,"aria-label":x,children:m})}const Cz=a=>{const o=/Z|[+-]\d{2}:?\d{2}$/.test(a)?a:`${a}Z`,l=new Date,u=new Date(o),d=Math.floor((l.getTime()-u.getTime())/1e3);return d<60?"just now":d<3600?`${Math.floor(d/60)}m ago`:d<86400?`${Math.floor(d/3600)}h ago`:d<2592e3?`${Math.floor(d/86400)}d ago`:u.toLocaleDateString()},Dz=a=>{let o=a;return o=o.replace(/<[^>]*>/g,""),o=o.replace(/!\[.*?\]\([^\s)]+\)/g,""),o=o.replace(/\[([^\]]*)\]\([^\s)]+\)/g,"$1"),o=o.replace(/https?:\/\/[^\s)>\]]+/g,""),o=o.replace(/\[.*?\]/g,""),o=o.replace(/\(https?:\/\/[^\s)]*\)/g,""),o=o.replace(/\s+/g," ").trim(),o},Mz=({media:a})=>{const[o,l]=T.useState(!1),u=a.kind+":"+("url"in a?a.url:a.id);return T.useEffect(()=>{l(!1)},[u]),a.kind==="image"?t.jsxs(t.Fragment,{children:[!o&&t.jsx("span",{className:"absolute inset-0 z-10 flex items-center justify-center bg-black/20 pointer-events-none",children:t.jsx(W.Loader2,{className:"h-5 w-5 animate-spin text-white/80"})}),t.jsx("img",{src:a.url,alt:"",className:"absolute inset-0 h-full w-full object-cover",onLoad:()=>l(!0),onError:d=>{l(!0),d.target.style.display="none"}})]}):a.kind==="youtube"?t.jsxs(t.Fragment,{children:[!o&&t.jsx("span",{className:"absolute inset-0 z-10 flex items-center justify-center bg-black/20 pointer-events-none",children:t.jsx(W.Loader2,{className:"h-5 w-5 animate-spin text-white/80"})}),t.jsx("img",{src:`https://i.ytimg.com/vi/${a.id}/hqdefault.jpg`,alt:"",className:"absolute inset-0 h-full w-full object-cover opacity-90",onLoad:()=>l(!0),onError:d=>{l(!0),d.target.style.display="none"}}),t.jsx("span",{className:"absolute inset-0 flex items-center justify-center",children:t.jsx("span",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-black/70 text-white",children:t.jsx(W.Play,{className:"h-5 w-5 fill-current"})})}),t.jsx("span",{className:"absolute bottom-1.5 left-1.5 rounded bg-black/60 px-1.5 py-0.5 text-[10px] font-medium text-white",children:"YouTube"})]}):a.kind==="threespeak"?t.jsxs("span",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-[var(--hrk-bg-surface-sunken)]",children:[t.jsx("span",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-[var(--hrk-brand)]/15 text-[var(--hrk-brand)]",children:t.jsx(W.Play,{className:"h-5 w-5 fill-current"})}),t.jsx("span",{className:"rounded bg-black/60 px-1.5 py-0.5 text-[10px] font-medium text-white",children:"3Speak"})]}):t.jsxs("span",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-[var(--hrk-bg-surface-sunken)] text-white",children:[t.jsx("span",{className:"text-3xl font-semibold",children:"𝕏"}),t.jsx("span",{className:"rounded bg-black/60 px-1.5 py-0.5 text-[10px] font-medium",children:"Tweet"})]})},Oz=({media:a})=>{const[o,l]=T.useState(0),[u,d]=T.useState(null);if(a.length===0)return null;const f=Math.min(o,a.length-1),m=a[f],g=x=>{if(x.stopPropagation(),m.kind==="twitter"){window.open(m.url,"_blank","noopener,noreferrer");return}d(f)};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative my-2 mr-2 h-20 w-28 flex-shrink-0 overflow-hidden rounded-[10px] bg-[var(--hrk-bg-surface-sunken)] ring-1 ring-[var(--hrk-border-subtle)] sm:my-3 sm:mr-3 sm:h-auto sm:w-32 sm:self-stretch md:w-40 lg:w-48",children:[t.jsx("button",{onClick:g,className:"absolute inset-0 block cursor-pointer","aria-label":"Open media preview",children:t.jsx(Mz,{media:m})}),a.length>1&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:x=>{x.stopPropagation(),l(y=>(y-1+a.length)%a.length)},className:"absolute left-1 top-1/2 -translate-y-1/2 rounded-full bg-black/60 p-1 text-white hover:bg-black/80",title:"Previous",children:t.jsx(W.ChevronLeft,{className:"h-4 w-4"})}),t.jsx("button",{onClick:x=>{x.stopPropagation(),l(y=>(y+1)%a.length)},className:"absolute right-1 top-1/2 -translate-y-1/2 rounded-full bg-black/60 p-1 text-white hover:bg-black/80",title:"Next",children:t.jsx(W.ChevronRight,{className:"h-4 w-4"})}),t.jsxs("span",{className:"absolute bottom-1.5 right-1.5 rounded-full bg-black/60 px-1.5 py-0.5 text-[10px] font-medium text-white",children:[f+1,"/",a.length]})]})]}),u!==null&&t.jsx(TT,{items:a.filter(x=>x.kind!=="twitter"),startIndex:Math.min(u,Math.max(0,a.slice(0,u+1).filter(x=>x.kind!=="twitter").length-1)),onClose:()=>d(null)})]})},CT=({posts:a,currentUser:o,loading:l=!1,loadingMore:u=!1,hasMore:d=!1,onLoadMore:f,emptyMessage:m="No blogs to show.",onUpvote:g,onSubmitComment:x,onClickCommentUpvote:y,onReblog:b,onTip:w,onSharePost:v,onCommentClick:j,onReportPost:M,onToggleBookmark:P,isPostBookmarked:D,onDeletePost:E,onUserClick:z,onPostClick:H,getPostUrl:$,getUserUrl:R,getCommunityUrl:A,ecencyToken:q,threeSpeakApiKey:F,giphyApiKey:X,templateToken:Y,templateApiBaseUrl:Z,defaultVotePercent:J,voteWeightStep:re,allowLandscapeVideos:ce,awaitingWalletApproval:le,defaultReward:G,actionsAsMenu:K})=>l&&a.length===0?t.jsx("div",{className:"space-y-3",children:Array.from({length:5}).map((ee,ye)=>t.jsxs("div",{className:"overflow-hidden rounded-[14px] border border-[var(--hrk-border-subtle)] bg-[var(--hrk-bg-surface)] animate-pulse",children:[t.jsxs("div",{className:"flex items-stretch",children:[t.jsxs("div",{className:"min-w-0 flex-1 space-y-1.5 p-2.5 sm:space-y-2 sm:p-4",children:[t.jsxs("div",{className:"flex items-center gap-2 sm:gap-3",children:[t.jsx("div",{className:"h-7 w-7 rounded-full bg-[var(--hrk-bg-surface-sunken)] sm:h-9 sm:w-9"}),t.jsx("div",{className:"h-2.5 w-20 rounded bg-[var(--hrk-bg-surface-sunken)] sm:h-3 sm:w-24"}),t.jsx("div",{className:"h-2 w-10 rounded bg-[var(--hrk-bg-surface-sunken)] opacity-70 sm:w-12"})]}),t.jsx("div",{className:"h-3 w-5/6 rounded bg-[var(--hrk-bg-surface-sunken)] sm:h-4"}),t.jsx("div",{className:"h-2.5 w-full rounded bg-[var(--hrk-bg-surface-sunken)] opacity-70 sm:h-3"}),t.jsx("div",{className:"h-2.5 w-4/6 rounded bg-[var(--hrk-bg-surface-sunken)] opacity-70 sm:h-3"})]}),t.jsx("div",{className:"my-2 mr-2 h-20 w-28 flex-shrink-0 rounded-[10px] bg-[var(--hrk-bg-surface-sunken)] opacity-80 sm:my-3 sm:mr-3 sm:h-auto sm:w-32 sm:self-stretch md:w-40 lg:w-48"})]}),t.jsxs("div",{className:"flex gap-3 border-t border-[var(--hrk-border-subtle)] px-2.5 py-2 sm:px-4",children:[t.jsx("div",{className:"h-3 w-10 rounded bg-[var(--hrk-bg-surface-sunken)] opacity-70"}),t.jsx("div",{className:"h-3 w-10 rounded bg-[var(--hrk-bg-surface-sunken)] opacity-70"}),t.jsx("div",{className:"h-3 w-10 rounded bg-[var(--hrk-bg-surface-sunken)] opacity-70"}),t.jsx("div",{className:"ml-auto h-3 w-10 rounded bg-[var(--hrk-bg-surface-sunken)] opacity-70"})]})]},ye))}):!l&&a.length===0?t.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 py-14 text-center",children:[t.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-full bg-[var(--hrk-bg-hover)] text-[var(--hrk-text-tertiary)]",children:t.jsx(W.FileText,{className:"h-5 w-5"})}),t.jsx("p",{className:"text-sm text-[var(--hrk-text-secondary)]",children:m})]}):t.jsxs("div",{className:"space-y-3",children:[a.map(ee=>{const ye=ET(ee),we=ee.json_metadata?.description||(ee.body?Dz(ee.body):""),Me=ee.payout?ee.payout.toFixed(3):ee.pending_payout_value?ee.pending_payout_value.replace(/[^\d.]/g,""):"0.000",Ue=[],se=ee.percent_hbd??1e4;if(se===0?Ue.push("Hive Rewards Payout 100% Powered Up"):Ue.push(`Hive Rewards Payout (${(se/200).toFixed(0)}%/${100-se/200}%)`),ee.is_paidout){const ge=ee.author_payout_value?ee.author_payout_value.replace(/[^\d.]/g,""):"";Ue.push("Past payouts:"),Ue.push(`${Me} Hive Rewards${ge?` (Author ${ge})`:""}`)}else se===0?Ue.push(`${Me} Hive Rewards (100% Powered Up)`):Ue.push(`${Me} Hive Rewards (${(se/200).toFixed(0)}%/${100-se/200}%)`);const be=Ue.join(`
|
|
1163
|
-
`),xe=ge=>parseFloat((ge??"").replace(/[^\d.]/g,""))||0,Ae=xe(ee.pending_payout_value),Oe=xe(ee.author_payout_value),Ye=xe(ee.curator_payout_value),Se=ee.payout&&ee.payout>0?ee.payout:Ae>0?Ae:Oe+Ye,He={pendingValue:Ae,authorValue:Oe,curatorValue:Ye,totalValue:Se,isPaidout:!!ee.is_paidout,payoutAt:ee.payout_at,percentHbd:ee.percent_hbd??1e4,beneficiaries:(ee.beneficiaries??[]).map(ge=>({account:ge.account,weight:ge.weight}))},he=H?ge=>{ge.button!==0||ge.metaKey||ge.ctrlKey||ge.shiftKey||ge.altKey||H(ee.author,ee.permlink,ee.title)}:void 0;return t.jsxs("div",{className:`group overflow-hidden rounded-[14px] border border-[var(--hrk-border-subtle)] bg-[var(--hrk-bg-surface)] transition-[background-color,border-color] duration-150 ease-out hover:border-[var(--hrk-border-default)] hover:bg-[var(--hrk-bg-surface-raised)] ${he?"cursor-pointer":""}`,onClick:he,children:[t.jsxs("div",{className:"flex items-stretch",children:[t.jsxs("div",{className:"min-w-0 flex-1 p-2.5 sm:p-4",children:[t.jsxs("div",{className:"mb-1 flex items-center gap-2 sm:mb-1.5 sm:gap-3",children:[t.jsx("img",{src:`https://images.hive.blog/u/${ee.author}/avatar`,alt:ee.author,className:"h-7 w-7 flex-shrink-0 rounded-full bg-[var(--hrk-bg-surface-sunken)] object-cover ring-1 ring-[var(--hrk-border-subtle)] sm:h-9 sm:w-9",onError:ge=>{ge.target.src=`https://ui-avatars.com/api/?name=${ee.author}&background=random&size=40`}}),t.jsxs("div",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-x-1.5 gap-y-0 sm:gap-x-2 sm:gap-y-0.5",children:[t.jsxs(pi,{href:R?.(ee.author),onActivate:()=>z?.(ee.author),className:"text-[11px] font-medium text-white hover:text-[var(--hrk-brand)] sm:text-sm",children:["@",ee.author]}),t.jsx(pi,{href:$?.(ee.author,ee.permlink),onActivate:()=>H?.(ee.author,ee.permlink,ee.title),className:"text-[10px] text-[var(--hrk-text-tertiary)] hover:text-[var(--hrk-brand)] hover:underline sm:text-xs",children:Cz(ee.created)}),ee.community_title&&t.jsxs(pi,{href:ee.community?A?.(ee.community):void 0,onActivate:()=>{ee.community&&z?.(ee.community)},className:"text-[10px] font-medium text-[var(--hrk-brand)] hover:underline sm:text-xs",children:["#",ee.community_title]})]})]}),ee.title&&t.jsx(pi,{href:$?.(ee.author,ee.permlink),onActivate:()=>H?.(ee.author,ee.permlink,ee.title),className:"mb-0.5 line-clamp-2 block text-left text-[13px] font-semibold leading-snug text-white hover:text-[var(--hrk-brand)] sm:mb-1 sm:text-base",children:t.jsx(_g,{text:ee.title})}),we&&t.jsx("p",{className:"line-clamp-2 text-[11px] leading-snug text-[var(--hrk-text-tertiary)] sm:line-clamp-3 sm:text-sm sm:leading-relaxed",children:t.jsx(_g,{text:we.substring(0,240)})})]}),t.jsx(Oz,{media:ye})]}),t.jsx("div",{className:"border-t border-[var(--hrk-border-subtle)] px-2.5 py-2 sm:px-4",onClick:ge=>ge.stopPropagation(),children:t.jsx(Ag,{author:ee.author,permlink:ee.permlink,currentUser:o,onUserClick:z,getUserUrl:R,hiveValue:Me,hiveIconUrl:"/images/hive_logo.png",payoutTooltip:be,payoutDetails:He,initialVotes:ee.active_votes??[],initialVoteCount:ee.stats?.total_votes??ee.net_votes??ee.active_votes?.length??0,initialCommentsCount:ee.children||0,postCreatedAt:ee.created,onUpvote:g?ge=>g(ee.author,ee.permlink,ge):void 0,onSubmitComment:x?(ge,me,Ve)=>x(ge,me,Ve):void 0,onClickCommentUpvote:y,onReblog:ee.author!==o&&b?()=>b(ee.author,ee.permlink):void 0,onShare:v?()=>v(ee.author,ee.permlink):void 0,onTip:ee.author!==o&&w?()=>w(ee.author,ee.permlink):void 0,onToggleBookmark:P?()=>P(ee.author,ee.permlink):void 0,isBookmarked:D?D(ee.author,ee.permlink):!1,onReport:ee.author!==o&&M?()=>M(ee.author,ee.permlink):void 0,onDelete:ee.author===o&&E?()=>E(ee.author,ee.permlink):void 0,disableCommentsModal:!!j,onComments:j?()=>j(ee.author,ee.permlink):void 0,ecencyToken:q,threeSpeakApiKey:F,giphyApiKey:X,templateToken:Y,templateApiBaseUrl:Z,defaultReward:G,defaultVotePercent:J,voteWeightStep:re,allowLandscapeVideos:ce,awaitingWalletApproval:le,actionsAsMenu:K})})]},`${ee.author}/${ee.permlink}`)}),d&&f&&t.jsx(Rz,{onLoadMore:f,loadingMore:u})]}),Rz=({onLoadMore:a,loadingMore:o})=>{const l=T.useRef(null),u=T.useRef(a),d=T.useRef(!!o);return T.useEffect(()=>{u.current=a},[a]),T.useEffect(()=>{d.current=!!o},[o]),T.useEffect(()=>{const f=l.current;if(!f)return;const m=new IntersectionObserver(g=>{g[0]?.isIntersecting&&!d.current&&u.current()},{root:null,rootMargin:"600px",threshold:0});return m.observe(f),()=>m.disconnect()},[]),t.jsx("div",{ref:l,className:"flex justify-center py-3 text-xs text-[var(--hrk-text-tertiary)]","aria-hidden":!o,children:o?t.jsxs("span",{className:"inline-flex items-center gap-2",role:"status","aria-live":"polite",children:[t.jsx(W.Loader2,{className:"h-3.5 w-3.5 animate-spin"}),"Loading more…"]}):t.jsx("span",{className:"block h-px w-full"})})},DT="hrk-selection-translate-cache-v1",c8=200;let Hd=null;const d8=new Map,O4=new Map;function f8(){if(Hd)return Hd;try{const a=typeof sessionStorage<"u"?sessionStorage.getItem(DT):null;Hd=a?JSON.parse(a):{}}catch{Hd={}}return Hd}function Lz(){if(Hd)try{const a=Object.keys(Hd);if(a.length>c8){const o=Math.max(1,Math.floor(a.length-c8*.8));for(let l=0;l<o;l++)delete Hd[a[l]]}typeof sessionStorage<"u"&&sessionStorage.setItem(DT,JSON.stringify(Hd))}catch{}}function zz(a){let o=5381;for(let l=0;l<a.length;l++)o=(o<<5)+o^a.charCodeAt(l);return(o>>>0).toString(36)}function Pz(a,o){return`${o}:${zz(a)}`}async function MT(a,o){const l=(a??"").trim();if(!l)return"";if(!o)return l;const u=Pz(l,o),d=f8()[u]??d8.get(u);if(d)return d;const f=O4.get(u);if(f)return f;const m=(async()=>{try{const g=`https://translate.googleapis.com/translate_a/single?client=gtx&sl=auto&tl=${encodeURIComponent(o)}&dt=t&q=${encodeURIComponent(l)}`,x=await fetch(g);if(!x.ok)throw new Error(`google ${x.status}`);const y=await x.json(),b=[];if(Array.isArray(y)&&Array.isArray(y[0]))for(const v of y[0])Array.isArray(v)&&typeof v[0]=="string"&&b.push(v[0]);const w=b.join("").trim();if(!w)throw new Error("empty");return d8.set(u,w),f8()[u]=w,Lz(),w}catch{return l}finally{O4.delete(u)}})();return O4.set(u,m),m}const Yw=[{code:"en",label:"English"},{code:"es",label:"Spanish"},{code:"pt",label:"Portuguese"},{code:"fr",label:"French"},{code:"de",label:"German"},{code:"it",label:"Italian"},{code:"ru",label:"Russian"},{code:"ar",label:"Arabic"},{code:"hi",label:"Hindi"},{code:"zh-CN",label:"Chinese (Simplified)"},{code:"ja",label:"Japanese"},{code:"ko",label:"Korean"},{code:"tr",label:"Turkish"},{code:"id",label:"Indonesian"},{code:"vi",label:"Vietnamese"}],OT="hrk-selection-translate-lang";function ck(){try{if(typeof sessionStorage<"u"){const a=sessionStorage.getItem(OT);if(a)return a}}catch{}if(typeof navigator<"u"&&navigator.language){const a=navigator.language.split("-")[0],o=Yw.find(l=>l.code===a);if(o)return o.code}return"en"}function RT(a){try{typeof sessionStorage<"u"&&sessionStorage.setItem(OT,a)}catch{}}const dk=8;function zv({children:a,languages:o=Yw,minLength:l=2}){const u=T.useRef(null),[d,f]=T.useState(null),[m,g]=T.useState(null),[x,y]=T.useState(()=>ck()),[b,w]=T.useState(!1),[v,j]=T.useState(!1),[M,P]=T.useState(null),[D,E]=T.useState(null);T.useEffect(()=>{const A=()=>{if(m)return;const Z=typeof window<"u"?window.getSelection():null;if(!Z||Z.isCollapsed||Z.rangeCount===0){f(null);return}const J=Z.toString().trim();if(J.length<l){f(null);return}const re=Z.getRangeAt(0),ce=re.commonAncestorContainer.nodeType===Node.TEXT_NODE?re.commonAncestorContainer.parentElement:re.commonAncestorContainer;if(!u.current||!ce||!u.current.contains(ce)){f(null);return}const le=re.getBoundingClientRect();f({text:J,anchor:{top:le.bottom+dk,left:le.left+le.width/2}})},q=()=>window.setTimeout(A,30),F=()=>q(),X=()=>q(),Y=Z=>{const J=Z.target;J&&J.closest("[data-hrk-translate-ui]")||f(null)};return document.addEventListener("pointerup",F),document.addEventListener("touchend",X),document.addEventListener("mousedown",Y),()=>{document.removeEventListener("pointerup",F),document.removeEventListener("touchend",X),document.removeEventListener("mousedown",Y)}},[l,m]),T.useEffect(()=>{if(!m)return;const A=q=>{q.key==="Escape"&&(g(null),P(null),E(null),w(!1))};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[m]);const z=T.useCallback(async(A,q)=>{j(!0);try{const F=await MT(A,q);P(F)}finally{j(!1)}},[]),H=T.useCallback(()=>{if(!d)return;const A=ck();y(A),E(d.text),g(d.anchor),f(null),P(null),z(d.text,A)},[d,z]),$=T.useCallback(A=>{y(A),RT(A),w(!1),D&&z(D,A)},[D,z]),R=T.useCallback(()=>{g(null),P(null),E(null),w(!1)},[]);return t.jsxs("div",{ref:u,children:[a,d&&t.jsx(Bz,{anchor:d.anchor,onClick:H}),m&&D&&Yu.createPortal(t.jsx(Uz,{anchor:m,sourceText:D,translated:M,loading:v,targetLang:x,picking:b,languages:o,onPickerToggle:()=>w(A=>!A),onPickLanguage:$,onClose:R}),document.body)]})}function Bz({anchor:a,onClick:o}){return typeof document>"u"?null:Yu.createPortal(t.jsxs("button",{type:"button","data-hrk-translate-ui":"trigger",onMouseDown:l=>{l.preventDefault(),l.stopPropagation(),o()},style:{position:"fixed",top:a.top,left:a.left,transform:"translateX(-50%)",zIndex:2100},className:"inline-flex items-center gap-1 rounded-full border border-[var(--hrk-border-default)] bg-[var(--hrk-bg-surface-raised)] px-2.5 py-1 text-[11px] font-semibold text-[var(--hrk-text-primary)] shadow-lg hover:bg-[var(--hrk-bg-hover)]","aria-label":"Translate selection",children:[t.jsx(W.Languages,{className:"h-3.5 w-3.5 text-[var(--hrk-brand)]"}),"Translate"]}),document.body)}const nw=320;function Uz({anchor:a,sourceText:o,translated:l,loading:u,targetLang:d,picking:f,languages:m,onPickerToggle:g,onPickLanguage:x,onClose:y}){const b=T.useRef(null),[w,v]=T.useState(a),[j,M]=T.useState(0);T.useLayoutEffect(()=>{const A=typeof window<"u"?window.innerWidth:0,q=typeof window<"u"?window.innerHeight:0,F=Math.max(8,Math.min(A-nw-8,a.left-nw/2)),X=8,Y=b.current?.offsetHeight??240;let Z=a.top,J=q-Z-X;if(Y>J){const ce=a.top-Y-16-2*dk,le=a.top-16-2*dk-X;ce>=X?(Z=ce,J=le):le>J&&(Z=X,J=le)}Z<X&&(Z=X);const re=Math.max(160,Math.min(J,q-X*2));v({top:Z,left:F}),M(re)},[a]),T.useEffect(()=>{const A=F=>{const X=F.target;X&&X.closest("[data-hrk-translate-ui]")||y()},q=window.setTimeout(()=>{document.addEventListener("mousedown",A)},0);return()=>{window.clearTimeout(q),document.removeEventListener("mousedown",A)}},[y]);const[P,D]=T.useState({dx:0,dy:0}),E=T.useRef(null),z=T.useCallback(A=>{const q=A.target;if(!(q&&q.closest("button"))){A.preventDefault(),A.stopPropagation(),E.current={startClientX:A.clientX,startClientY:A.clientY,startDx:P.dx,startDy:P.dy,pointerId:A.pointerId};try{A.currentTarget.setPointerCapture(A.pointerId)}catch{}}},[P.dx,P.dy]),H=T.useCallback(A=>{const q=E.current;if(!q||q.pointerId!==A.pointerId)return;A.preventDefault();const F=window.innerWidth,X=window.innerHeight,Y=b.current?.offsetHeight??240,Z=8,J=-(w.left+nw-Z),re=F-w.left-Z,ce=-(w.top-Z),le=X-w.top-Math.min(40,Y),G=q.startDx+(A.clientX-q.startClientX),K=q.startDy+(A.clientY-q.startClientY);D({dx:Math.max(J,Math.min(re,G)),dy:Math.max(ce,Math.min(le,K))})},[w.left,w.top]),$=T.useCallback(A=>{if(E.current?.pointerId===A.pointerId){try{A.currentTarget.releasePointerCapture(A.pointerId)}catch{}E.current=null}},[]),R=m.find(A=>A.code===d)?.label??d;return t.jsxs("div",{ref:b,"data-hrk-translate-ui":"popover",style:{position:"fixed",top:w.top+P.dy,left:w.left+P.dx,width:nw,maxHeight:j?`${j}px`:"calc(100vh - 16px)",display:"flex",flexDirection:"column",zIndex:2200},className:"overflow-hidden rounded-xl border border-[var(--hrk-border-default)] bg-[var(--hrk-bg-surface)] shadow-2xl",role:"dialog","aria-label":"Translation",children:[t.jsxs("div",{className:"flex shrink-0 cursor-grab items-center justify-between gap-2 border-b border-[var(--hrk-border-subtle)] px-3 py-2 active:cursor-grabbing",style:{touchAction:"none"},onPointerDown:z,onPointerMove:H,onPointerUp:$,onPointerCancel:$,"aria-label":"Drag to move",children:[t.jsxs("button",{type:"button",onClick:g,className:"inline-flex items-center gap-1.5 rounded-md px-2 py-1 text-xs font-semibold text-[var(--hrk-text-primary)] hover:bg-[var(--hrk-bg-hover)]",children:[t.jsx(W.Languages,{className:"h-3.5 w-3.5 text-[var(--hrk-brand)]"}),R,t.jsx(W.ChevronDown,{className:"h-3 w-3 text-[var(--hrk-text-tertiary)]"})]}),t.jsx(W.GripHorizontal,{"aria-hidden":!0,className:"pointer-events-none h-3.5 w-3.5 text-[var(--hrk-text-tertiary)]"}),t.jsx("button",{type:"button",onClick:y,"aria-label":"Close",className:"flex h-6 w-6 items-center justify-center rounded-full text-[var(--hrk-text-tertiary)] hover:bg-[var(--hrk-bg-hover)] hover:text-[var(--hrk-text-primary)]",children:t.jsx(W.X,{className:"h-3.5 w-3.5"})})]}),f?t.jsx("ul",{role:"listbox",className:"min-h-0 flex-1 overflow-y-auto overscroll-contain py-1",style:{touchAction:"pan-y",WebkitOverflowScrolling:"touch"},children:m.map(A=>{const q=A.code===d;return t.jsx("li",{children:t.jsxs("button",{type:"button",role:"option","aria-selected":q,onClick:()=>x(A.code),className:"flex w-full items-center justify-between px-3 py-1.5 text-left text-xs transition-colors "+(q?"bg-[var(--hrk-bg-hover)] text-[var(--hrk-text-primary)]":"text-[var(--hrk-text-secondary)] hover:bg-[var(--hrk-bg-hover)]"),children:[t.jsx("span",{children:A.label}),t.jsx("span",{className:"text-[10px] uppercase tracking-wide text-[var(--hrk-text-tertiary)]",children:A.code})]})},A.code)})}):t.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain px-3 py-2.5",style:{touchAction:"pan-y",WebkitOverflowScrolling:"touch"},children:[t.jsx("p",{className:"mb-2 text-[11px] italic text-[var(--hrk-text-tertiary)]",children:o}),t.jsx("div",{className:"min-h-[36px] whitespace-pre-wrap break-words text-xs leading-relaxed text-[var(--hrk-text-primary)]",children:u?t.jsxs("span",{className:"inline-flex items-center gap-1.5 text-[var(--hrk-text-tertiary)]",children:[t.jsx(W.Loader2,{className:"h-3.5 w-3.5 animate-spin"}),"Translating…"]}):l||o})]})]})}function Hz({author:a,permlink:o,currentUser:l,onVotePoll:u,parsedMetadata:d}){const[f,m]=T.useState(null),[g,x]=T.useState(!0),[y,b]=T.useState([]),[w,v]=T.useState([]),[j,M]=T.useState(!1);T.useEffect(()=>{const G=new AbortController;return x(!0),lr.getPollDetail(a,o,G.signal).then(K=>m(K??null)).catch(()=>m(null)).finally(()=>x(!1)),()=>G.abort()},[a,o]);const P=f?.max_choices_voted??d?.max_choices_voted??1,D=P>1,E=f?.end_time?new Date(f.end_time).getTime():(d?.end_time??0)*1e3,z=E>0&&Date.now()>E,H=w.length>0,$=l?f?.poll_voters?.find(G=>G.name===l):void 0,R=$?.choices?.length?$.choices:$?.choice_num!=null?[$.choice_num]:[],A=H||R.length>0,q=f?.allow_vote_changes??d?.allow_vote_changes??!1,F=H?w:R,X=!!l&&!z&&!!u&&(!A||q),Y=A&&q&&!H,Z=f?.poll_choices??(d?.choices??[]).map((G,K)=>({choice_num:K+1,choice_text:G,votes:null})),J=Z.reduce((G,K)=>G+(K.votes?.total_votes??0),0),re=D||Y,ce=async G=>{if(!(!X||j))if(re)b(K=>K.includes(G)?K.filter(ee=>ee!==G):K.length>=P?K:[...K,G]);else{M(!0);try{if(await Promise.resolve(u?.(a,o,[G]))===!1)return;v([G])}finally{M(!1)}}},le=async()=>{if(!(!X||j||y.length===0)){M(!0);try{if(await Promise.resolve(u?.(a,o,y))===!1)return;v(y),b([])}finally{M(!1)}}};return t.jsxs("div",{className:"mt-2 rounded-lg border border-[var(--hrk-border-subtle)] bg-[var(--hrk-bg-surface)]/60 overflow-hidden",children:[t.jsxs("div",{className:"flex items-center gap-2 px-3 pt-3 pb-2",children:[t.jsx(W.BarChart2,{className:"h-3.5 w-3.5 text-blue-400 flex-shrink-0"}),t.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-blue-400",children:"Poll"}),t.jsx("span",{className:`ml-auto rounded-full px-2 py-0.5 text-[10px] font-medium ${z?"bg-[var(--hrk-bg-surface-raised)] text-[var(--hrk-text-tertiary)]":"bg-green-900/50 text-green-400"}`,children:z?"Ended":E>0?`Ends in ${Math.ceil((E-Date.now())/(1e3*60*60*24))}d`:"Active"})]}),t.jsx("p",{className:"px-3 pb-2 text-sm font-semibold text-white",children:f?.question??d?.question??""}),X&&re&&t.jsxs("p",{className:"px-3 pb-1.5 text-[11px] text-[var(--hrk-text-tertiary)]",children:[Y?"Change your vote — ":"","Select up to ",P," option",P>1?"s":"",y.length>0&&t.jsxs("span",{className:"ml-1 text-blue-400",children:["· ",y.length," selected"]})]}),t.jsx("div",{className:"space-y-1.5 px-3 pb-3",children:g?[1,2,3].map(G=>t.jsx("div",{className:"h-8 animate-pulse rounded-lg bg-[var(--hrk-bg-surface-raised)]/50"},G)):Z.map(G=>{const K=G.votes?.total_votes??0,ee=J>0?Math.round(K/J*100):0,ye=F.includes(G.choice_num),we=y.includes(G.choice_num),Me=re&&y.length>=P&&!we,Ue=X&&!Me;let se="border-[var(--hrk-border-subtle)]",be=t.jsx(W.Circle,{className:"h-3 w-3 flex-shrink-0 text-[var(--hrk-text-tertiary)]"}),xe="bg-blue-600/20";return we?(se="border-blue-500/60",be=t.jsx(W.CheckCircle2,{className:"h-3 w-3 flex-shrink-0 text-blue-400"})):ye&&!Y?(se="border-green-600/60",be=t.jsx(W.CheckCircle2,{className:"h-3 w-3 flex-shrink-0 text-green-500"}),xe="bg-green-600/20"):ye&&Y&&(se="border-green-800/40",be=t.jsx(W.CheckCircle2,{className:"h-3 w-3 flex-shrink-0 text-green-700"}),xe="bg-green-900/10"),t.jsxs("button",{type:"button",onClick:Ae=>{Ae.stopPropagation(),ce(G.choice_num)},className:`relative w-full overflow-hidden rounded-md border bg-[var(--hrk-bg-app)]/50 text-left transition-colors ${se} ${Ue?"cursor-pointer hover:border-blue-500/40":Me?"cursor-not-allowed opacity-50":"cursor-default"}`,disabled:!Ue,children:[ee>0&&t.jsx("div",{className:`absolute inset-y-0 left-0 ${xe} transition-all duration-500`,style:{width:`${ee}%`}}),t.jsxs("div",{className:"relative flex items-center justify-between gap-2 px-2.5 py-2",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[be,t.jsx("span",{className:`truncate text-xs ${we?"font-medium text-blue-300":ye&&!Y?"font-medium text-green-300":ye&&Y?"text-green-700":"text-[var(--hrk-text-primary)]"}`,children:G.choice_text})]}),t.jsxs("div",{className:"flex flex-shrink-0 items-center gap-1.5 text-[10px] text-[var(--hrk-text-tertiary)]",children:[t.jsxs("span",{children:[ee,"%"]}),t.jsx("span",{className:"text-[var(--hrk-text-tertiary)]",children:"·"}),t.jsxs("span",{children:[K," vote",K!==1?"s":""]})]})]})]},G.choice_num)})}),X&&re&&t.jsx("div",{className:"px-3 pb-3",children:t.jsxs("button",{type:"button",onClick:G=>{G.stopPropagation(),le()},disabled:y.length===0||j,className:"flex w-full items-center justify-center gap-1.5 rounded-[10px] bg-[var(--hrk-brand)] px-3 py-1.5 text-xs font-medium text-[var(--hrk-text-on-brand)] transition-colors hover:bg-[var(--hrk-brand-hover)] disabled:bg-[var(--hrk-bg-surface-raised)] disabled:text-[var(--hrk-text-tertiary)]",children:[t.jsx(W.Send,{className:"h-3 w-3"}),j?"Submitting…":Y?"Change Vote":`Submit Vote${y.length>1?"s":""}`]})}),t.jsxs("div",{className:"flex items-center gap-2 border-t border-[var(--hrk-border-subtle)]/50 px-3 py-2 text-[10px] text-[var(--hrk-text-tertiary)]",children:[t.jsxs("span",{children:[f?.poll_stats?.total_voting_accounts_num??0," voter",(f?.poll_stats?.total_voting_accounts_num??0)!==1?"s":""," total"]}),A&&t.jsxs("span",{className:"ml-auto text-green-500",children:["✓ Voted",q?" · changes allowed":""]})]})]})}const $z=new Set(["peakd.com","www.peakd.com","hive.blog","www.hive.blog","ecency.com","www.ecency.com","inleo.io","www.inleo.io","snapie.io","www.snapie.io","hivesuite.app","www.hivesuite.app"]);function sw(a,o){const l=a?.toLowerCase();return l?o?{kind:"post",author:l,permlink:o}:{kind:"user",author:l}:null}function Tg(a){if(!a)return null;if(a.startsWith("#/@")){const[f,m]=a.slice(3).split("/").filter(Boolean);return sw(f,m)}if(a.startsWith("/@")){const[f,m]=a.slice(2).split("/").filter(Boolean);return sw(f,m)}let o;try{o=new URL(a)}catch{return null}const l=o.hostname.toLowerCase();if(!$z.has(l))return null;const u=o.pathname.split("/").filter(Boolean);if((l==="inleo.io"||l==="www.inleo.io")&&u[0]==="threads"&&u[1]==="view")return sw(u[2],u[3]);const d=u.findIndex(f=>f.startsWith("@"));return d===-1?null:sw(u[d].slice(1),u[d+1])}function LT(a,o){if(!a)return a;const l=o??(u=>`https://peakd.com/@${u}`);return a.replace(/(^|[^A-Za-z0-9_!#$%&*@/@])@([a-z][a-z0-9.-]{1,15}[a-z0-9])(?![a-z0-9.-])/gi,(u,d,f)=>{const m=f.toLowerCase();return`${d}[@${f}](${l(m)})`})}function qz(a){const o=/Z|[+-]\d{2}:?\d{2}$/.test(a)?a:`${a}Z`,l=Math.floor((Date.now()-new Date(o).getTime())/1e3);return l<60?"just now":l<3600?`${Math.floor(l/60)}m ago`:l<86400?`${Math.floor(l/3600)}h ago`:l<2592e3?`${Math.floor(l/86400)}d ago`:new Date(o).toLocaleDateString()}function Vz(a,o){if(o){const m=(typeof o=="string"?(()=>{try{return JSON.parse(o)}catch{return{}}})():o).image;if(Array.isArray(m)&&typeof m[0]=="string")return m[0]}const l=a.match(/!\[[^\]]*\]\(([^)\s]+)\)/);if(l)return l[1];const u=a.match(/<img[^>]+src=["']([^"']+)["']/i);if(u)return u[1];const d=a.match(/https?:\/\/\S+?\.(?:jpe?g|png|gif|webp|avif)(?:\?\S*)?/i);return d?d[0]:null}function Fz(a){return a.replace(/!\[[^\]]*\]\([^)]+\)/g,"").replace(/<img[^>]+>/gi,"").replace(/https?:\/\/\S+?\.(?:jpe?g|png|gif|webp|avif)(?:\?\S*)?/gi,"").replace(/<[^>]+>/g,"").replace(/[*_~`>#-]+/g," ").replace(/\s+/g," ").trim()}const Iz=({author:a,permlink:o,observer:l,onPostClick:u,onUserClick:d})=>{const[f,m]=T.useState(null),[g,x]=T.useState(!0),[y,b]=T.useState(!1);T.useEffect(()=>{let M=!1;return x(!0),b(!1),m(null),Cn.getPostContent(a,o,l??"").then(P=>{if(!M){if(!P||!P.author){b(!0),x(!1);return}m(P),x(!1)}}).catch(()=>{M||(b(!0),x(!1))}),()=>{M=!0}},[a,o,l]);const w=T.useMemo(()=>f?Vz(f.body??"",f.json_metadata):null,[f]),v=T.useMemo(()=>f?Fz(f.body??"").slice(0,280):"",[f]),j=M=>{M.stopPropagation(),f?u?.(f.author,f.permlink):u?.(a,o)};return t.jsxs("div",{className:"relative cursor-pointer overflow-hidden rounded-lg border border-emerald-500/30 bg-[var(--hrk-bg-surface-sunken)] transition hover:border-emerald-500/60",onClick:j,children:[t.jsxs("span",{className:"absolute right-2 top-2 z-10 inline-flex items-center gap-1 rounded-md bg-emerald-500/20 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-emerald-300",children:[t.jsx(W.Repeat,{className:"h-3 w-3"}),"Re-snap"]}),g?t.jsxs("div",{className:"space-y-2 p-3",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"h-7 w-7 rounded-full bg-[var(--hrk-bg-hover)]"}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("div",{className:"h-3 w-24 rounded bg-[var(--hrk-bg-hover)]"}),t.jsx("div",{className:"h-2 w-16 rounded bg-[var(--hrk-bg-hover)]"})]})]}),t.jsx("div",{className:"h-32 w-full rounded-md bg-[var(--hrk-bg-hover)]"}),t.jsx("div",{className:"h-3 w-3/4 rounded bg-[var(--hrk-bg-hover)]"})]}):y||!f?t.jsx("div",{className:"p-3 text-xs text-[var(--hrk-text-tertiary)]",children:"Original snap unavailable."}):t.jsxs("div",{className:"p-3",children:[t.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:M=>{M.stopPropagation(),d?.(f.author)},className:"shrink-0",children:t.jsx("img",{src:`https://images.hive.blog/u/${f.author}/avatar`,alt:f.author,className:"h-7 w-7 rounded-full bg-[var(--hrk-bg-hover)] object-cover",onError:M=>{M.target.src=`https://ui-avatars.com/api/?name=${f.author}&background=random&size=28`}})}),t.jsxs("div",{className:"min-w-0",children:[t.jsxs("button",{type:"button",onClick:M=>{M.stopPropagation(),d?.(f.author)},className:"block truncate text-sm font-semibold text-[var(--hrk-text-primary)] hover:text-[var(--hrk-brand)]",children:["@",f.author]}),t.jsx("span",{className:"text-[11px] text-[var(--hrk-brand)]",children:qz(f.created)})]})]}),w&&t.jsx("img",{src:w,alt:"",loading:"lazy",className:"mb-2 max-h-72 w-full rounded-md object-cover",onError:M=>{M.target.style.display="none"}}),v&&t.jsx("p",{className:"line-clamp-4 whitespace-pre-wrap break-words text-sm leading-relaxed text-[var(--hrk-text-secondary)]",children:v})]})]})},bh=/https?:\/\/[^\s"'<>)]+\/ipfs\/[a-zA-Z0-9]+(?:\/[^\s"'<>)]*)?/gi,Pv=new Map,R4=new Map;function Gz(a){const o=Pv.get(a);if(o)return Promise.resolve(o);const l=R4.get(a);if(l)return l;const u=fetch(a,{method:"HEAD"}).then(d=>{const f=(d.headers.get("content-type")??"").toLowerCase(),m=f.startsWith("image/")?"image":f.startsWith("video/")?"video":"unknown";return Pv.set(a,m),m}).catch(()=>{const d="unknown";return Pv.set(a,d),d}).finally(()=>{R4.delete(a)});return R4.set(a,u),u}function mN(a){const[o,l]=T.useState(()=>Pv.get(a)??null);return T.useEffect(()=>{let u=!1;const d=Pv.get(a);if(d){l(d);return}return l(null),Gz(a).then(f=>{u||l(f)}),()=>{u=!0}},[a]),o}const Zz=({url:a,variant:o="full",onTileClick:l,className:u})=>{const d=mN(a);return d===null?t.jsx("div",{className:`flex h-full w-full items-center justify-center bg-[var(--hrk-bg-surface-sunken)] ${u??""}`,"aria-label":"Resolving IPFS media",children:t.jsx("div",{className:"h-6 w-6 animate-pulse rounded-full bg-[var(--hrk-bg-hover)]"})}):d==="image"?o==="tile"?t.jsx("button",{type:"button",onClick:l,className:`relative flex h-full w-full items-center justify-center overflow-hidden rounded-lg bg-[var(--hrk-bg-surface-sunken)] ${u??""}`,"aria-label":"Open image preview",children:t.jsx("img",{src:a,alt:"",loading:"lazy",className:"max-h-full max-w-full object-contain"})}):t.jsx("img",{src:a,alt:"",className:`max-h-full max-w-full object-contain ${u??""}`}):d==="video"?t.jsx("video",{src:a,controls:!0,playsInline:!0,preload:"metadata",className:`max-h-full max-w-full ${u??""}`}):t.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:`text-sm text-[var(--hrk-brand)] underline ${u??""}`,children:a})},fk=/https?:\/\/(?:www\.)?(?:twitter\.com|x\.com)\/[^/]+\/status\/(\d+)/gi,hk=/https?:\/\/(?:www\.)?youtube\.com\/watch\?v=([^&\s]+)|https?:\/\/youtu\.be\/([^?\s]+)|https?:\/\/(?:www\.)?youtube\.com\/shorts\/([^?\s]+)/gi,mk=/https?:\/\/(?:play\.)?3speak\.tv\/[^\s"'<>)]+/gi,pk=/https?:\/\/[^\s"'<>)]+?\.(?:mp3|wav|ogg|m4a|aac|flac|webm|opus)(?:\?[^\s"'<>)]*)?/gi,gk=/https?:\/\/audio\.3speak\.tv\/play\?[^\s"'<>)]+/gi,bk=/!\[[^\]]*\]\(([^\s)]+)\)/g,xk=/<img[^>]+src=["']([^"']+)["'][^>]*>/gi,zT=/https?:\/\/[^\s"'<>)]+?\.(?:jpe?g|png|gif|webp|avif|bmp|svg)(?:\?[^\s"'<>)]*)?/gi,Yz=/https?:\/\/[^\s)<>\]]+/g,Xz=/@([a-z][a-z0-9.-]{1,15}[a-z0-9])/g,Wz=/(?:^|\s)#([a-zA-Z][\w-]{0,31})/g;function mg(a){return Array.from(new Set(a))}function Jz(a){return a.trim().replace(/[)\],.;:>\s"'<]+$/,"").replace(/^(https?):\/(?!\/)/,"$1://")}function Qz(a){const o=new Set,l=[];for(const u of a){if(typeof u!="string")continue;const d=Jz(u);if(!d||!/^https?:\/\//.test(d))continue;let f=d;try{f=decodeURIComponent(d)}catch{}o.has(f)||(o.add(f),l.push(d))}return l}function pN(a){if(!a)return{};if(typeof a=="string")try{return JSON.parse(a)}catch{return{}}return typeof a=="object"?a:{}}const Kz=new Set(["hsnaps","hreplier","hivesuite"]);function eP(a){const o=pN(a.json_metadata);return(Array.isArray(o.tags)?o.tags:[]).some(u=>typeof u=="string"&&Kz.has(u.toLowerCase()))}function tP(a){const o=pN(a.json_metadata);return(Array.isArray(o.tags)?o.tags:[]).filter(u=>typeof u=="string"&&u.length>0)}function PT(a){return a.replace(/\s*(?:<br\s*\/?>)?\s*<sub>\s*\[via Apps from\][^<]*<\/sub>\s*$/i,"").replace(/\s*(?:<br\s*\/?>)?\s*\[via Apps from\]\([^)]*\)\s*$/i,"").replace(/\s*(?:<br\s*\/?>)?\s*via Apps from\s+https?:\/\/\S+\s*$/i,"")}function rP(a){const o=(a||"").trim();if(!o)return null;const l=f=>{const m=Tg(f);return m&&m.kind==="post"?{author:m.author,permlink:m.permlink}:null};if(/^https?:\/\/\S+$/.test(o))return l(o);const u=o.match(/^\[[^\]]*\]\((https?:\/\/[^)\s]+)\)$/);if(u)return l(u[1]);const d=o.match(/^<a\s[^>]*href=["'](https?:\/\/[^"']+)["'][^>]*>[^<]*<\/a>$/i);return d?l(d[1]):null}function aP(a){const o=PT(a.body??""),l=[];let u;for(;u=bk.exec(o);)l.push(u[1]);for(;u=xk.exec(o);)l.push(u[1]);for(;u=zT.exec(o);)l.push(u[0]);const d=[],f=new RegExp(bh.source,bh.flags);for(;u=f.exec(o);)d.push(u[0]);const m=[];for(;u=hk.exec(o);)m.push(u[1]||u[2]||u[3]);const g=[];for(;u=mk.exec(o);)g.push(u[0]);const x=[];for(;u=gk.exec(o);)x.push(u[0]);const y=[];for(;u=pk.exec(o);)x.includes(u[0])||y.push(u[0]);const b=[];for(;u=fk.exec(o);)b.push(u[1]);const w=[...Qz(l).map($=>({kind:"image",url:$})),...mg(d).map($=>({kind:"ipfs",url:$})),...mg(m).map($=>({kind:"youtube",id:$})),...mg(g).map($=>({kind:"threespeak",url:$})),...mg(b).map($=>({kind:"twitter",id:$})),...mg(x).map($=>({kind:"3speak-audio",url:$})),...mg(y).map($=>({kind:"audio",url:$}))];let v=o;v=v.replace(bk,""),v=v.replace(xk,""),v=v.replace(bh,""),v=v.replace(hk,""),v=v.replace(mk,""),v=v.replace(gk,""),v=v.replace(pk,""),v=v.replace(fk,""),v=v.replace(/<[^>]+>/g,""),v=v.replace(/\[([^\]]+)\]\(([^\s)]+)\)/g,"$1 $2"),v=v.replace(/[*_~`>#-]+/g," "),v=v.replace(/\s+/g," ").trim();const j=[];let M=0;const P=[];let D;const E=new RegExp(Yz.source,"g");for(;(D=E.exec(v))!==null;)P.push({start:D.index,end:D.index+D[0].length,node:{kind:"link",url:D[0]}});const z=new RegExp(Xz.source,"g");for(;(D=z.exec(v))!==null;)P.some($=>D.index>=$.start&&D.index<$.end)||P.push({start:D.index,end:D.index+D[0].length,node:{kind:"mention",username:D[1]}});const H=new RegExp(Wz.source,"g");for(;(D=H.exec(v))!==null;){const $=D.index+(D[0].startsWith(" ")?1:0);P.some(R=>$>=R.start&&$<R.end)||P.push({start:$,end:$+(D[0].length-(D[0].startsWith(" ")?1:0)),node:{kind:"hashtag",tag:D[1]}})}P.sort(($,R)=>$.start-R.start);for(const $ of P)M<$.start&&j.push({kind:"text",text:v.slice(M,$.start)}),j.push($.node),M=$.end;return M<v.length&&j.push({kind:"text",text:v.slice(M)}),j.length===0&&v&&j.push({kind:"text",text:v}),{segments:j,attachments:w}}function nP(a){const o=/Z|[+-]\d{2}:?\d{2}$/.test(a)?a:`${a}Z`,l=Math.floor((Date.now()-new Date(o).getTime())/1e3);return l<60?"just now":l<3600?`${Math.floor(l/60)}m ago`:l<86400?`${Math.floor(l/3600)}h ago`:l<2592e3?`${Math.floor(l/86400)}d ago`:new Date(o).toLocaleDateString()}const sP=({segments:a,onUserClick:o,onTagClick:l,getUserUrl:u,getTagUrl:d})=>{const f=[];return a.forEach((m,g)=>{m.kind==="text"?f.push(t.jsx("span",{children:m.text},g)):m.kind==="mention"?f.push(t.jsxs(pi,{href:u?.(m.username),onActivate:()=>o?.(m.username),className:"text-[var(--hrk-brand)] hover:underline",children:["@",m.username]},g)):m.kind==="hashtag"?f.push(t.jsxs(pi,{href:d?.(m.tag),onActivate:()=>l?.(m.tag),className:"text-[var(--hrk-brand)] hover:underline",children:["#",m.tag]},g)):f.push(t.jsx("a",{href:m.url,target:"_blank",rel:"noopener noreferrer",onClick:x=>x.stopPropagation(),className:"break-all text-[var(--hrk-brand)] underline hover:text-[var(--hrk-brand-active)]",children:m.url},g))}),t.jsx("p",{className:"line-clamp-6 whitespace-pre-wrap break-words text-sm leading-relaxed text-[var(--hrk-text-secondary)]",children:f})};function BT(a){try{const l=new URL(a).searchParams.get("v");if(!l)return null;const[u,d]=l.split("/");return!u||!d?null:{author:u,permlink:d}}catch{return null}}const iP=({author:a,permlink:o})=>t.jsx("div",{className:"three-speak-embed my-3 hive-post-body",style:{margin:"0.75rem auto"},children:t.jsx(fm,{author:a,permlink:o})}),h8=a=>a.kind==="image"?a.url.toLowerCase().includes(".gif")?"GIF":"Image":a.kind==="youtube"?"YouTube":a.kind==="threespeak"?"3Speak":a.kind==="twitter"?"Tweet":a.kind==="3speak-audio"?"3Speak audio":"Audio",UT=({id:a})=>{const[o,l]=T.useState(null);T.useEffect(()=>{const d=f=>{try{const m=typeof f.data=="string"?JSON.parse(f.data):f.data;if(!m||typeof m!="object")return;let g;if(m.method==="resize"&&Array.isArray(m.params))for(const x of m.params)typeof x=="number"&&x>0&&(g=x),x&&typeof x=="object"&&typeof x.height=="number"&&(g=x.height);m["twttr.private.resize"]?.height&&(g=m["twttr.private.resize"].height),!g&&typeof m.height=="number"&&(g=m.height),!g&&m.msg_type==="resize"&&m.msg_data?.height&&(g=m.msg_data.height),g&&g>50&&l(Math.ceil(g))}catch{}};return window.addEventListener("message",d),()=>window.removeEventListener("message",d)},[]);const u=typeof window<"u"?window.location.origin:"";return t.jsx("div",{className:"twitter-embed-wrapper w-full overflow-hidden rounded-lg bg-black/60",style:o?{maxHeight:"80vh",overflowY:"auto"}:void 0,children:t.jsx("iframe",{src:`https://platform.twitter.com/embed/Tweet.html?id=${a}&theme=dark&dnt=true&origin=${encodeURIComponent(u)}`,title:`Tweet ${a}`,className:"twitter-embed-iframe w-full border-0 bg-black",scrolling:"yes",style:{height:o??"60vh"}})})},Sv=1,m8=.25,oP=.15,HT=({src:a})=>{const[o,l]=T.useState(1),[u,d]=T.useState(3),[f,m]=T.useState({x:0,y:0}),g=T.useRef(null),x=T.useRef(null),y=T.useRef(null),b=T.useRef(null),w=T.useCallback(()=>{l(1),m({x:0,y:0})},[]);T.useEffect(()=>{w()},[a,w]);const v=T.useCallback(()=>{const F=x.current;if(!F)return;const X=F.clientWidth||1,Y=F.clientHeight||1,Z=Math.max(F.naturalWidth/X,F.naturalHeight/Y);d(Math.max(1,Math.min(6,Z||1)))},[]),j=o>1,M=Math.round(o*100),P=T.useCallback(F=>{F.preventDefault();const X=g.current;if(!X)return;const Y=X.getBoundingClientRect(),Z=F.clientX-(Y.left+Y.width/2),J=F.clientY-(Y.top+Y.height/2);l(re=>{const ce=F.deltaY<0?1:-1,le=Math.max(Sv,Math.min(u,re+ce*oP));return le===re?re:(m(G=>{if(le===1)return{x:0,y:0};const K=le/re;return{x:Z-(Z-G.x)*K,y:J-(J-G.y)*K}}),le)})},[u]),D=T.useCallback(F=>{F.stopPropagation(),o===1?l(u):w()},[o,u,w]),E=T.useCallback(F=>{if(F.touches.length===2){const[X,Y]=[F.touches[0],F.touches[1]];b.current={startDistance:Math.hypot(X.clientX-Y.clientX,X.clientY-Y.clientY),startZoom:o};return}if(j){const X=F.touches[0];X&&(y.current={startClientX:X.clientX,startClientY:X.clientY,startPanX:f.x,startPanY:f.y})}},[o,j,f.x,f.y]),z=T.useCallback(F=>{if(F.touches.length===2&&b.current){const[X,Y]=[F.touches[0],F.touches[1]],J=Math.hypot(X.clientX-Y.clientX,X.clientY-Y.clientY)/b.current.startDistance;l(Math.max(Sv,Math.min(u,b.current.startZoom*J)));return}if(j&&y.current&&F.touches.length===1){const X=F.touches[0],Y=X.clientX-y.current.startClientX,Z=X.clientY-y.current.startClientY;m({x:y.current.startPanX+Y,y:y.current.startPanY+Z})}},[u,j]),H=T.useCallback(()=>{b.current=null,y.current=null},[]),$=T.useCallback(F=>{j&&(y.current={startClientX:F.clientX,startClientY:F.clientY,startPanX:f.x,startPanY:f.y})},[j,f.x,f.y]),R=T.useCallback(F=>{if(!y.current||F.buttons!==1)return;const X=F.clientX-y.current.startClientX,Y=F.clientY-y.current.startClientY;m({x:y.current.startPanX+X,y:y.current.startPanY+Y})},[]),A=T.useCallback(()=>{y.current=null},[]),q=F=>F.stopPropagation();return t.jsxs("div",{className:"relative w-full",onClick:q,children:[t.jsxs("div",{className:"mb-2 flex items-center justify-center gap-1",children:[t.jsx("button",{type:"button",onClick:F=>{F.stopPropagation(),l(X=>Math.max(Sv,X-m8)),m(X=>({x:X.x*.85,y:X.y*.85}))},className:"flex h-8 w-8 items-center justify-center rounded-full bg-white/10 text-white transition hover:bg-white/20 disabled:opacity-40","aria-label":"Zoom out",disabled:o<=Sv,children:t.jsx(W.ZoomOut,{className:"h-4 w-4"})}),t.jsxs("span",{className:"min-w-[3.25rem] text-center text-xs font-medium tabular-nums text-white",children:[M,"%"]}),t.jsx("button",{type:"button",onClick:F=>{F.stopPropagation(),l(X=>Math.min(u,X+m8))},className:"flex h-8 w-8 items-center justify-center rounded-full bg-white/10 text-white transition hover:bg-white/20 disabled:opacity-40","aria-label":"Zoom in",disabled:o>=u,children:t.jsx(W.ZoomIn,{className:"h-4 w-4"})}),t.jsx("button",{type:"button",onClick:F=>{F.stopPropagation(),w()},className:"flex h-8 w-8 items-center justify-center rounded-full bg-white/10 text-white transition hover:bg-white/20 disabled:opacity-40","aria-label":"Reset zoom",disabled:o===Sv,children:t.jsx(W.Maximize2,{className:"h-4 w-4"})})]}),t.jsx("div",{ref:g,className:"relative flex items-center justify-center overflow-hidden rounded-lg",style:{minHeight:240,touchAction:j?"none":"pan-y"},onWheel:P,onPointerDown:$,onPointerMove:R,onPointerUp:A,onPointerLeave:A,onPointerCancel:A,onTouchStart:E,onTouchMove:z,onTouchEnd:H,onTouchCancel:H,children:t.jsx("img",{ref:x,src:a,alt:"",draggable:!1,referrerPolicy:"no-referrer",className:"max-h-[80vh] max-w-full select-none object-contain",style:{transform:`translate3d(${f.x}px, ${f.y}px, 0) scale(${o})`,transformOrigin:"center center",transition:y.current||b.current?"none":"transform 120ms ease-out",cursor:j?y.current?"grabbing":"grab":"zoom-in"},onDoubleClick:D,onLoad:()=>requestAnimationFrame(v)})})]})},lP=({url:a,onOpen:o})=>{const l=mN(a);return l===null?t.jsx("div",{className:"flex h-full w-full items-center justify-center bg-[var(--hrk-bg-surface-sunken)]",children:t.jsx("div",{className:"h-6 w-6 animate-pulse rounded-full bg-[var(--hrk-bg-hover)]"})}):l==="video"?t.jsxs("button",{type:"button",onClick:o,className:"relative flex h-full w-full items-center justify-center overflow-hidden bg-black","aria-label":"Play video",children:[t.jsx("video",{src:a,preload:"metadata",muted:!0,playsInline:!0,className:"h-full w-full object-cover opacity-80"}),t.jsx("span",{className:"pointer-events-none absolute flex h-12 w-12 items-center justify-center rounded-full bg-black/70 text-white",children:t.jsx(W.Play,{className:"h-6 w-6"})})]}):t.jsx("button",{type:"button",onClick:o,className:"relative flex h-full w-full items-center justify-center overflow-hidden rounded-lg bg-[var(--hrk-bg-surface-sunken)]","aria-label":"Open image preview",children:t.jsx("img",{src:a,alt:"",loading:"lazy",className:"max-h-full max-w-full object-contain"})})},uP=({url:a})=>{const o=mN(a);return o==="video"?t.jsx("video",{src:a,controls:!0,autoPlay:!0,playsInline:!0,className:"max-h-[80vh] max-w-full"}):o==="image"||o===null?t.jsx(HT,{src:a}):t.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-[var(--hrk-brand)] underline",children:"Open in new tab"})},cP=({attachment:a,onClose:o,index:l,total:u,onPrev:d,onNext:f})=>{const m=typeof u=="number"&&u>1&&!!d&&!!f;T.useEffect(()=>{const b=v=>{v.key==="Escape"&&o(),v.key==="ArrowLeft"&&d&&d(),v.key==="ArrowRight"&&f&&f()};window.addEventListener("keydown",b);const w=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{window.removeEventListener("keydown",b),document.body.style.overflow=w}},[o,d,f]);const g=b=>b.stopPropagation(),x=b=>{b.stopPropagation(),o()},y=a.kind==="audio"||a.kind==="3speak-audio";return t.jsxs("div",{className:"fixed inset-0 z-[2000] flex flex-col bg-black/85 sm:items-center sm:justify-center sm:p-6",role:"dialog","aria-modal":"true",onClick:x,children:[t.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-2 bg-black/40 px-4 py-3 pt-[calc(env(safe-area-inset-top,0px)+1rem)] sm:hidden",onClick:g,children:[t.jsx("span",{className:"truncate text-sm font-medium text-white/80",children:h8(a)}),m&&t.jsxs("span",{className:"shrink-0 text-xs text-white/60 tabular-nums",children:[(l??0)+1," / ",u]})]}),t.jsx("button",{type:"button",onClick:x,className:"fixed right-3 top-[calc(env(safe-area-inset-top,0px)+1rem)] z-[2010] flex h-11 w-11 items-center justify-center rounded-full bg-black/80 text-white shadow-lg ring-1 ring-white/30 transition hover:bg-black sm:hidden","aria-label":"Close",children:t.jsx(W.X,{className:"h-5 w-5"})}),t.jsxs("div",{className:`flex min-h-0 flex-1 flex-col overflow-y-auto bg-[var(--hrk-bg-surface-sunken)] shadow-2xl sm:flex-initial sm:overflow-visible sm:rounded-2xl sm:border sm:border-[var(--hrk-border-default)] ${y?"sm:max-w-md":"sm:max-w-3xl"} sm:w-full`,onClick:g,children:[t.jsxs("div",{className:"hidden shrink-0 items-center justify-between border-b border-[var(--hrk-border-default)]/60 px-4 py-2.5 sm:flex",children:[t.jsxs("span",{className:"flex items-center gap-2 text-sm font-medium text-white/70",children:[t.jsx("span",{children:h8(a)}),m&&t.jsxs("span",{className:"text-xs text-white/50 tabular-nums",children:[(l??0)+1," / ",u]})]}),t.jsx("button",{type:"button",onClick:x,className:"flex h-8 w-8 items-center justify-center rounded-full bg-white/10 text-white transition hover:bg-white/20","aria-label":"Close",children:t.jsx(W.X,{className:"h-4 w-4"})})]}),t.jsxs("div",{className:"relative flex flex-1 flex-col items-center justify-center p-3 sm:p-4",children:[m&&t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:b=>{b.stopPropagation(),d?.()},className:"absolute left-2 top-1/2 z-20 flex h-10 w-10 -translate-y-1/2 items-center justify-center rounded-full bg-black/60 text-white shadow-lg transition hover:bg-black/80","aria-label":"Previous media",children:t.jsx(W.ChevronLeft,{className:"h-5 w-5"})}),t.jsx("button",{type:"button",onClick:b=>{b.stopPropagation(),f?.()},className:"absolute right-2 top-1/2 z-20 flex h-10 w-10 -translate-y-1/2 items-center justify-center rounded-full bg-black/60 text-white shadow-lg transition hover:bg-black/80","aria-label":"Next media",children:t.jsx(W.ChevronRight,{className:"h-5 w-5"})})]}),a.kind==="image"&&t.jsx(HT,{src:a.url}),a.kind==="ipfs"&&t.jsx(uP,{url:a.url}),a.kind==="youtube"&&t.jsxs("div",{className:"w-full",children:[t.jsx("div",{className:"w-full overflow-hidden rounded-lg",style:{aspectRatio:"16/9"},children:t.jsx("iframe",{src:`https://www.youtube-nocookie.com/embed/${a.id}?autoplay=1&rel=0&playsinline=1`,title:"YouTube",className:"h-full w-full border-0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})}),t.jsxs("a",{href:`https://www.youtube.com/watch?v=${a.id}`,target:"_blank",rel:"noopener noreferrer",className:"mt-3 inline-flex w-full items-center justify-center gap-2 rounded-lg bg-white/10 px-4 py-2.5 text-sm font-medium text-white/90 transition hover:bg-white/20",children:[t.jsx(W.Play,{className:"h-4 w-4 fill-current"}),"Watch on YouTube"]})]}),a.kind==="twitter"&&t.jsx("div",{className:"w-full",children:t.jsx(UT,{id:a.id})}),a.kind==="threespeak"&&(()=>{const b=BT(a.url);return b?t.jsx("div",{className:"w-full",children:t.jsx(iP,{author:b.author,permlink:b.permlink})}):t.jsx("a",{href:a.url,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-[var(--hrk-brand)] underline",children:"Open on 3Speak"})})(),a.kind==="audio"&&t.jsxs("div",{className:"w-full overflow-hidden rounded-xl border border-[var(--hrk-border-default)] bg-[#1a1d21] p-3",children:[t.jsxs("div",{className:"mb-2 flex items-center gap-2 text-sm text-[var(--hrk-text-tertiary)]",children:[t.jsx(W.Music,{className:"h-4 w-4 shrink-0 text-[var(--hrk-brand)]"}),t.jsx("span",{className:"truncate",children:decodeURIComponent(a.url.split("/").pop()?.split("?")[0]??"Audio")})]}),t.jsx("audio",{src:a.url,controls:!0,preload:"metadata",autoPlay:!0,className:"h-10 w-full"})]}),a.kind==="3speak-audio"&&t.jsx("div",{className:"w-full overflow-hidden rounded-xl border border-[var(--hrk-border-default)] bg-[#1a1d21]",children:t.jsx("iframe",{src:a.url,title:"3Speak audio",className:"h-24 w-full border-0",allow:"autoplay"})})]})]})]})},dP=({attachments:a})=>{const[o,l]=T.useState(0),[u,d]=T.useState(null),[f,m]=T.useState(0),[g,x]=T.useState(new Set),[y,b]=T.useState(!1),w=T.useRef(null);if(T.useEffect(()=>()=>{w.current&&clearTimeout(w.current)},[]),a.length===0)return null;const v=Math.min(o,a.length-1),j=a[v],M=()=>{b(!0),w.current&&clearTimeout(w.current),w.current=setTimeout(()=>b(!1),1200)},P=()=>{w.current&&(clearTimeout(w.current),w.current=null),b(!1)},D=()=>{M(),l(q=>(q+1)%a.length)},E=()=>{M(),l(q=>(q-1+a.length)%a.length)},z=(q,F)=>{q.stopPropagation();const X=a.indexOf(F);m(X>=0?X:0),d(F)},H=a.filter(q=>q.kind==="image"||q.kind==="ipfs"),$=()=>{H.length!==0&&m(q=>{const X=(Math.max(0,H.indexOf(a[q]))-1+H.length)%H.length,Y=H[X];return d(Y),a.indexOf(Y)})},R=()=>{H.length!==0&&m(q=>{const X=(Math.max(0,H.indexOf(a[q]))+1)%H.length,Y=H[X];return d(Y),a.indexOf(Y)})},A=()=>{if(j.kind==="ipfs")return t.jsx(lP,{url:j.url,onOpen:q=>z(q,j)});if(j.kind==="image")return g.has(v)?t.jsx("button",{type:"button",onClick:F=>F.stopPropagation(),className:"flex h-full w-full items-center justify-center bg-[var(--hrk-bg-app)] text-[var(--hrk-text-tertiary)]",children:t.jsx(W.ImageOff,{className:"h-6 w-6"})}):t.jsx("button",{type:"button",onClick:F=>z(F,j),className:"relative flex h-full w-full items-center justify-center overflow-hidden rounded-lg bg-[var(--hrk-bg-surface-sunken)]","aria-label":"Open image preview",children:t.jsx("img",{ref:F=>{F&&F.complete&&P()},src:j.url,alt:"",loading:"lazy",className:"max-h-full max-w-full object-contain",onLoad:P,onError:()=>{P(),x(F=>new Set(F).add(v))}},v)});if(j.kind==="youtube")return t.jsx("div",{className:"flex h-full w-full items-center justify-center bg-black",onClick:q=>q.stopPropagation(),children:t.jsx("iframe",{src:`https://www.youtube-nocookie.com/embed/${j.id}?rel=0&playsinline=1`,title:"YouTube",className:"border-0",style:{aspectRatio:"16/9",height:"100%",maxHeight:"100%",maxWidth:"100%"},allow:"accelerometer; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})});if(j.kind==="threespeak"){const q=BT(j.url);return t.jsx("div",{className:"three-speak-snap-strip flex h-full w-full items-center justify-center overflow-hidden bg-black",onClick:F=>F.stopPropagation(),children:q?t.jsx(fm,{author:q.author,permlink:q.permlink,hideThumbnail:!0}):t.jsx("a",{href:j.url,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-[var(--hrk-brand)] underline",onClick:F=>F.stopPropagation(),children:"Open on 3Speak"})})}return j.kind==="twitter"?t.jsx("div",{className:"h-full w-full overflow-y-auto bg-[var(--hrk-bg-surface-sunken)]",onClick:q=>q.stopPropagation(),children:t.jsx(UT,{id:j.id})}):j.kind==="3speak-audio"?t.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-3 bg-gradient-to-br from-violet-900/40 to-violet-950/60 px-4",onClick:q=>q.stopPropagation(),children:[t.jsxs("div",{className:"flex items-center gap-2 text-xs text-white/70",children:[t.jsx(W.Music,{className:"h-4 w-4 shrink-0 text-[var(--hrk-brand)]"}),t.jsx("span",{className:"font-medium",children:"3Speak audio"})]}),t.jsx("iframe",{src:j.url,title:"3Speak audio",className:"h-24 w-full max-w-md border-0",allow:"autoplay"})]}):t.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-3 bg-gradient-to-br from-emerald-900/40 to-emerald-950/60 px-4",onClick:q=>q.stopPropagation(),children:[t.jsxs("div",{className:"flex items-center gap-2 text-xs text-white/70",children:[t.jsx(W.Music,{className:"h-4 w-4 shrink-0 text-[var(--hrk-brand)]"}),t.jsx("span",{className:"max-w-[260px] truncate font-medium",children:decodeURIComponent(j.url.split("/").pop()?.split("?")[0]??"Audio")})]}),t.jsx("audio",{src:j.url,controls:!0,preload:"metadata",className:"h-10 w-full max-w-md"})]})};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative overflow-hidden rounded-lg border border-[var(--hrk-border-default)] bg-[var(--hrk-bg-app)]",children:[t.jsx("div",{className:"h-[280px] w-full",children:A()}),y&&t.jsx("div",{className:"pointer-events-none absolute inset-0 z-20 flex items-center justify-center bg-black/40",children:t.jsx(W.Loader2,{className:"h-7 w-7 animate-spin text-white"})}),a.length>1&&t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:q=>{q.stopPropagation(),E()},className:"absolute left-2 top-1/2 z-30 -translate-y-1/2 rounded-full bg-black/60 p-1.5 text-white hover:bg-black/80","aria-label":"Previous",children:t.jsx(W.ChevronLeft,{className:"h-4 w-4"})}),t.jsx("button",{type:"button",onClick:q=>{q.stopPropagation(),D()},className:"absolute right-2 top-1/2 z-30 -translate-y-1/2 rounded-full bg-black/60 p-1.5 text-white hover:bg-black/80","aria-label":"Next",children:t.jsx(W.ChevronRight,{className:"h-4 w-4"})}),t.jsxs("div",{className:"absolute bottom-2 right-2 z-30 rounded-full bg-black/60 px-2 py-0.5 text-[10px] text-white",children:[v+1," / ",a.length]})]})]}),u&&t.jsx(cP,{attachment:u,index:Math.max(0,H.indexOf(u)),total:H.length,onPrev:$,onNext:R,onClose:()=>d(null)})]})},$T=({post:a,currentUser:o,onUpvote:l,onSubmitComment:u,onClickCommentUpvote:d,onReblog:f,onReSnap:m,onTip:g,onSharePost:x,onCommentClick:y,onClickCommentIcon:b,onClickCommentCount:w,onReportPost:v,onToggleBookmark:j,isPostBookmarked:M,onDeletePost:P,onEditSnap:D,onVotePoll:E,onUserClick:z,onPostClick:H,onTagClick:$,getPostUrl:R,getUserUrl:A,getTagUrl:q,getCommunityUrl:F,ecencyToken:X,threeSpeakApiKey:Y,giphyApiKey:Z,templateToken:J,templateApiBaseUrl:re,defaultVotePercent:ce,voteWeightStep:le,allowLandscapeVideos:G,awaitingWalletApproval:K,defaultReward:ee,renderHeaderActions:ye,actionsAsMenu:we})=>{const Me=T.useMemo(()=>aP(a),[a.body,a.json_metadata]),Ue=T.useMemo(()=>rP(a.body??""),[a.body]),se=T.useMemo(()=>eP(a),[a.json_metadata]),be=T.useMemo(()=>tP(a),[a.json_metadata]);T.useEffect(()=>{},[a.author,a.permlink]);const xe=T.useMemo(()=>{try{return xm({baseUrl:"https://peakd.com/",ipfsGateway:"https://ipfs.3speak.tv",assetsWidth:640,assetsHeight:480,usertagUrlFn:ge=>`https://peakd.com/@${ge}`,hashtagUrlFn:ge=>`https://peakd.com/created/${ge}`,convertHiveUrls:!0})}catch{return null}},[]),Ae=T.useMemo(()=>{const ge=a.body??"";if(!ge||!xe)return"";let me=ge;if(me=PT(me),me=me.replace(/\r\n/g,`
|
|
1162
|
+
`)}function ST({sort:a="trending",tag:o="",observer:l="hive.blog",limit:u=20,showSortDropdown:d=!0,theme:f="dark",onAuthorClick:m,onPostClick:g,onCommunityClick:x,onPayoutClick:y,onUpvoteClick:b,onCommentClick:w,onReblogClick:v}){const[j,M]=T.useState([]),[P,D]=T.useState(!0),[E,z]=T.useState(null),[H,$]=T.useState(a),[R,A]=T.useState(!0),[q,F]=T.useState(!1),X=T.useRef(null);new Bw.DefaultRenderer({baseUrl:"https://hive.blog/",breaks:!0,skipSanitization:!1,allowInsecureScriptTags:!1,addNofollowToLinks:!0,doNotShowImages:!1,assetsWidth:640,assetsHeight:480,imageProxyFn:G=>G,usertagUrlFn:G=>`/@${G}`,hashtagUrlFn:G=>`/trending/${G}`,isLinkSafeFn:G=>!0,addExternalCssClassToMatchingLinksFn:G=>!0,ipfsPrefix:"https://ipfs.io/ipfs/"});const Y=T.useCallback(async(G,K=!1)=>{K?F(!0):(D(!0),A(!0)),z(null);try{const ee=K&&j.length>0?j[j.length-1]:null,ye=await Cn.getRankedPosts(G,o,l,u,ee?.author,ee?.permlink);K?(M(we=>{const Me=new Set(we.map(se=>se.post_id)),Ue=ye.filter(se=>!Me.has(se.post_id));return[...we,...Ue]}),A(ye.length===u)):(M(ye),A(ye.length===u))}catch(ee){z(ee instanceof Error?ee.message:"Failed to load posts"),A(!1)}finally{D(!1),F(!1)}},[o,l,u,j]),Z=T.useCallback(()=>{!q&&R&&!P&&Y(H,!0)},[q,R,P,H,Y]);T.useEffect(()=>{Y(H)},[H,o,l,u]),T.useEffect(()=>{const G=new IntersectionObserver(K=>{K[0].isIntersecting&&Z()},{threshold:1});return X.current&&G.observe(X.current),()=>{X.current&&G.unobserve(X.current)}},[Z]);const J=G=>{$(G),M([]),A(!0)},re=G=>G>=1e6?`${(G/1e6).toFixed(1)}M`:G>=1e3?`${(G/1e3).toFixed(1)}K`:G.toString(),ce=G=>{const K=G.payout*.5,ee=G.payout*.5,we=(G.beneficiaries.find(Me=>Me.account==="commentrewarder")?.weight||0)/1e4*100;return{pending:`$${G.payout.toFixed(2)}`,breakdown:`${K.toFixed(2)} HBD, ${ee.toFixed(2)} HP`,commentRewarder:`${we.toFixed(2)}%`,payoutInDays:Math.ceil((new Date(G.payout_at).getTime()-Date.now())/(1e3*60*60*24))}},le=G=>{const ee=(G.body||"").replace(/!\[[^\]]*\]\([^)]+\)/g,"").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/^#+\s*/gm,"").replace(/\*\*([^*]+)\*\*/g,"$1").replace(/\*([^*]+)\*/g,"$1").replace(/`([^`]+)`/g,"$1").replace(/<[^>]*>/g,"").replace(/\n+/g," ").trim();return ee.length>200?ee.substring(0,200)+"...":ee};return P?t.jsx("div",{className:"flex justify-center items-center min-h-[400px]",children:t.jsx(W.Loader2,{className:"w-8 h-8 animate-spin"})}):E?t.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[400px] space-y-4",children:[t.jsx("h3",{className:"text-lg font-semibold text-card-foreground",children:"Failed to load posts"}),t.jsx("p",{className:"text-muted-foreground",children:E}),t.jsx("button",{onClick:()=>Y(H),className:"px-4 py-2 bg-primary text-primary-foreground rounded-lg hover:bg-primary/90",children:"Retry"})]}):t.jsx("div",{className:f==="dark"?"dark":"",children:t.jsxs("div",{className:`space-y-6 p-2 ${f==="dark"?"bg-slate-950":"bg-white"}`,children:[d&&t.jsx("div",{className:"flex justify-center",children:t.jsxs("select",{value:H,onChange:G=>J(G.target.value),className:`px-4 py-2 border border-border rounded-lg focus:outline-none focus:ring-2 focus:ring-primary ${f==="dark"?"bg-slate-950 text-white":"bg-card text-card-foreground"}`,children:[t.jsx("option",{value:"trending",children:"Trending"}),t.jsx("option",{value:"hot",children:"Hot"}),t.jsx("option",{value:"created",children:"New"})]})}),t.jsxs("div",{className:"space-y-4",children:[j.map(G=>{const K=G.json_metadata?.image?.[0],ee=ce(G);return t.jsxs("div",{className:`border border-border rounded-xl p-4 shadow-card hover:shadow-card-hover transition-shadow ${f==="dark"?"bg-slate-900 text-white":"bg-slate-50 text-black"}`,children:[t.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[t.jsx("img",{src:`https://images.hive.blog/u/${G.author}/avatar`,alt:G.author,className:"w-8 h-8 rounded-full cursor-pointer flex-shrink-0",onClick:()=>m?.(G.author,`https://images.hive.blog/u/${G.author}/avatar`),onError:ye=>{ye.target.src=`https://ui-avatars.com/api/?name=${G.author}&background=random`}}),t.jsx("span",{className:"font-medium cursor-pointer hover:text-primary",onClick:()=>m?.(G.author,`https://images.hive.blog/u/${G.author}/avatar`),children:G.author}),t.jsxs("span",{className:f==="dark"?"text-gray-400":"text-muted-foreground",children:["(",G.author_reputation.toFixed(2),")"]}),t.jsx("span",{className:`cursor-pointer hover:text-primary ${f==="dark"?"text-gray-400":"text-muted-foreground"}`,onClick:()=>x?.(G.community_title),children:G.community_title}),t.jsx("span",{className:`hidden sm:inline ${f==="dark"?"text-gray-400":"text-muted-foreground"}`,children:"•"}),t.jsx("span",{className:`text-sm ${f==="dark"?"text-gray-400":"text-muted-foreground"}`,children:Wv.formatDistanceToNow(new Date(G.created+"Z"),{addSuffix:!0})})]}),t.jsxs("div",{className:"flex gap-3 sm:gap-4",children:[t.jsx("div",{className:"flex-shrink-0",children:K?t.jsxs("div",{className:"relative",children:[t.jsx("img",{src:K.startsWith("http")?K:`https://images.hive.blog/u/320x0/${K}`,alt:G.title,className:"w-20 h-20 sm:w-32 sm:h-32 object-cover rounded-lg cursor-pointer",onClick:()=>g?.(G),onError:ye=>{ye.target.src!==`https://images.hive.blog/u/${G.author}/avatar`?ye.target.src=`https://images.hive.blog/u/${G.author}/avatar`:ye.target.src="https://images.hive.blog/u/null/avatar"}}),(()=>{const ye=G.body?.match(/!\[[^\]]*\]\(([^)]+)\)/g)?.map(we=>{const Me=we.match(/\(([^)]+)\)/);return Me?Me[1]:null}).filter(Boolean)||[];return ye.length>0?t.jsx("div",{className:"absolute -bottom-1 -right-1 sm:-bottom-2 sm:-right-2 flex space-x-1",children:ye.slice(0,3).map((we,Me)=>t.jsx("img",{src:we,alt:`body-image-${Me}`,className:"w-6 h-6 sm:w-8 sm:h-8 object-cover rounded border-2 border-white shadow-sm cursor-pointer",onClick:Ue=>{Ue.stopPropagation();const se=Ue.currentTarget.parentElement?.parentElement?.querySelector("img:not(.w-6):not(.w-8)");se&&(se.src=we)}},Me))}):null})()]}):t.jsx("img",{src:`https://images.hive.blog/u/${G.author}/avatar`,alt:G.author,className:"w-20 h-20 sm:w-32 sm:h-32 rounded-lg cursor-pointer",onClick:()=>g?.(G)})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("h3",{className:"font-semibold text-base sm:text-lg mb-1 sm:mb-2 cursor-pointer hover:text-primary line-clamp-2",onClick:()=>g?.(G),children:G.title}),t.jsx("p",{className:`mb-2 sm:mb-3 line-clamp-2 sm:line-clamp-3 cursor-pointer hover:text-primary text-sm sm:text-base ${f==="dark"?"text-gray-300":"text-gray-600"}`,onClick:()=>g?.(G),children:G.json_metadata?.description||le(G)||"No description available"}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"relative group",children:[t.jsxs("span",{className:"font-semibold text-green-600 cursor-pointer hover:text-green-700 text-sm sm:text-base",onClick:()=>y?.(G.payout),children:["$",G.payout.toFixed(2)]}),t.jsxs("div",{className:"absolute bottom-full left-0 mb-2 hidden group-hover:block bg-black text-white text-xs p-2 rounded shadow-lg whitespace-nowrap z-10",children:[t.jsxs("div",{children:["Pending payout amount: ",ee.pending]}),t.jsxs("div",{children:["Breakdown: ",ee.breakdown]}),t.jsxs("div",{children:["commentrewarder: ",ee.commentRewarder]}),t.jsxs("div",{children:["Payout in ",ee.payoutInDays," days"]})]})]}),t.jsxs("div",{className:"flex items-center gap-3 sm:gap-4",children:[t.jsxs("div",{className:`flex items-center gap-1 hover:text-primary transition-colors cursor-pointer ${f==="dark"?"text-gray-400":"text-muted-foreground"}`,onClick:()=>b?.(G),children:[t.jsx(W.ThumbsUp,{className:"w-3 h-3 sm:w-4 sm:h-4"}),t.jsx("span",{className:"text-xs sm:text-sm",children:re(G.stats.total_votes)})]}),t.jsxs("div",{className:`flex items-center gap-1 hover:text-blue-400 transition-colors cursor-pointer ${f==="dark"?"text-blue-400":"text-blue-600"}`,onClick:()=>w?.(G),children:[t.jsx(W.MessageCircle,{className:"w-3 h-3 sm:w-4 sm:h-4"}),t.jsx("span",{className:"text-xs sm:text-sm",children:re(G.children)})]}),t.jsxs("div",{className:`flex items-center gap-1 hover:text-gray-400 transition-colors cursor-pointer ${f==="dark"?"text-gray-400":"text-gray-600"}`,onClick:()=>v?.(G),children:[t.jsx(W.Repeat2,{className:"w-3 h-3 sm:w-4 sm:h-4"}),t.jsx("span",{className:"text-xs sm:text-sm",children:re(G.reblogs)})]})]})]})]})]})]},G.post_id)}),q&&t.jsxs("div",{className:"flex justify-center items-center py-4",children:[t.jsx(W.Loader2,{className:"w-6 h-6 animate-spin"}),t.jsx("span",{className:`ml-2 ${f==="dark"?"text-gray-400":"text-muted-foreground"}`,children:"Loading more posts..."})]}),R&&!q&&t.jsx("div",{ref:X,className:"h-10"})]})]})})}function Ag({author:a,permlink:o,currentUser:l,hiveValue:u,hiveIconUrl:d,payoutTooltip:f,payoutDetails:m,initialVotes:g,initialVoteCount:x,initialCommentsCount:y,onUpvote:b,onSubmitComment:w,onComments:v,onEdit:j,onReblog:M,onReSnap:P,onShare:D,onTip:E,onReport:z,onToggleBookmark:H,isBookmarked:$=!1,onDelete:R,onClickCommentUpvote:A,onUserClick:q,getUserUrl:F,ecencyToken:X,threeSpeakApiKey:Y,giphyApiKey:Z,templateToken:J,templateApiBaseUrl:re,disableCommentsModal:ce,onClickCommentIcon:le,onClickCommentCount:G,hasCommented:K=!1,myReplyKey:ee,showVoteButton:ye,parentTags:we,defaultReward:Me,defaultBeneficiaries:Ue,beneficiaryFavorites:se,defaultVotePercent:be=100,voteWeightStep:xe=.25,allowLandscapeVideos:Ae=!1,actionsAsMenu:Oe=!1,awaitingWalletApproval:Ye=!1,postCreatedAt:Se,size:He="default"}){const he=He==="lg"?"w-4 h-4 sm:w-4 sm:h-4":"w-3.5 h-3.5 sm:w-4 sm:h-4",ge=He==="lg"?"text-sm sm:text-sm":"text-xs sm:text-sm",me=He==="lg"?"w-5 h-5 sm:w-4 sm:h-4 rounded-full":"w-4 h-4 rounded-full",Ve=He==="lg"?"p-1.5 sm:p-1":"p-0.5 sm:p-1",Te=He==="lg"?"gap-1.5 sm:gap-0.5":"gap-0.5",Le=He==="lg"?"gap-2.5 sm:gap-3":"gap-1.5 sm:gap-3",je=He==="lg"?"p-1.5 sm:p-1":"p-0.5 sm:p-1",et=l==null||l===""?null:l,Lt=et!=null,bt=!!et&&!!a&&a.toLowerCase()===et.toLowerCase()?void 0:z,[xr,yr]=T.useState(g??[]),[hr,sr]=T.useState(x??g?.length??0),[or,pr]=T.useState(y??0),[$r,ta]=T.useState(!1),[Pt,wt]=T.useState(!1),[Wt,$t]=T.useState(!1),[Qt,Nr]=T.useState(!1),[Dr,It]=T.useState({message:"",visible:!1}),[da,_t]=T.useState(!1),qt=T.useCallback(gt=>{It({message:gt,visible:!0}),setTimeout(()=>It(Jt=>({...Jt,visible:!1})),2500)},[]),ne=g!==void 0,ue=y!==void 0,ve=T.useCallback(async()=>{try{const gt=await Cn.getActiveVotes(a,o);yr(gt),x===void 0&&sr(gt.length)}catch{}},[a,o,x]);T.useEffect(()=>{ne||ve()},[a,o,ne]),T.useEffect(()=>{ue||Cn.getCommentsList(a,o).then(gt=>{pr(gt.length)}).catch(()=>{})},[a,o,ue]);const ke=Lt&&!!et&&xr.some(gt=>gt.voter.toLowerCase()===et.toLowerCase()),[tt,jt]=T.useState(!1),[ir,Sr]=T.useState(null),[wr,Ot]=T.useState(!1),Vr=()=>{if(!K||(jt(!0),ir!==null||wr||!ee))return;const[gt,Jt]=ee.split("/");if(!gt||!Jt)return;Ot(!0),(async()=>{const Br=async(cr,_r,Aa)=>{const ze=await fetch(_l(),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",method:`${cr}.${_r}`,params:Aa,id:1})});if(!ze.ok)throw new Error(`Hive RPC ${ze.status}`);const Xe=await ze.json();if(Xe.error)throw new Error(Xe.error.message??"Hive RPC error");return Xe.result};try{const cr=await Br("bridge","get_post",{author:gt,permlink:Jt});if(cr&&typeof cr=="object"&&typeof cr.body=="string")return cr.body}catch{}try{const cr=await Br("condenser_api","get_content",[gt,Jt]);if(cr&&typeof cr=="object"&&typeof cr.body=="string")return cr.body}catch{}return""})().then(Br=>Sr(Br)).catch(()=>Sr("")).finally(()=>Ot(!1))},sa=T.useMemo(()=>{if(!ir)return"";let gt=ir;return gt=gt.replace(/\s*(?:<br\s*\/?>)?\s*<sub>\s*\[via Apps from\]\([^)]+\)\s*<\/sub>\s*$/i,""),gt=gt.replace(/\s*posted using.*$/i,""),gt=gt.replace(/!\[[^\]]*\]\([^)]+\)/g,""),gt=gt.replace(/\[([^\]]+)\]\([^)]+\)/g,"$1"),gt=gt.replace(/<[^>]+>/g,""),gt=gt.replace(/https?:\/\/\S+/g,""),gt=gt.replace(/[*_~`#>-]+/g," "),gt=gt.replace(/\s+/g," ").trim(),gt},[ir]),ra=(gt,Jt)=>{if(!Lt&>!=="Comment"){qt(`Please Login to ${gt}`);return}Jt()},Tt=T.useMemo(()=>Hw(Se),[Se]),vt=()=>{ra("Upvote",()=>{if(ke){qt("You have already upvoted this post");return}if(Tt){qt(qv);return}ta(!0)})},Gr=async gt=>{if(b){_t(!0);try{await Promise.resolve(b(gt)),ta(!1),qt("Vote submitted successfully"),x===void 0&&sr(Jt=>Jt+1),await ve(),setTimeout(()=>{ve()},4e3)}catch(Jt){const Ht=Jt instanceof Error?Jt.message:"Failed to upvote";qt(Ht)}finally{_t(!1)}}},Mr=()=>{wt(!0)},vr=()=>{if(wt(!1),!Lt){qt("Please Login to Upvote");return}if(ke){qt("You have already upvoted this post");return}if(Tt){qt(qv);return}ta(!0)},We=()=>{if(ce){v?.();return}ra("Comment",()=>{v?.(),Nr(!0)})},Mt=()=>{ra("Reblog",()=>M?.())},At=()=>{ra("Re-snap",()=>P?.())},Gt=()=>{ra("Report",()=>z?.())},Yt=()=>{ra("Tip",()=>E?.())},Kt=()=>{if(D){D();return}typeof navigator<"u"&&navigator.share?navigator.share({title:`${a}'s post`,url:`https://peakd.com/@${a}/${o}`,text:`Check out this post by @${a}`}).then(()=>qt("Shared")).catch(()=>{}):(navigator.clipboard?.writeText(`https://peakd.com/@${a}/${o}`),qt("Link copied to clipboard"))},er=async(gt,Jt,Ht,Br,cr)=>{if(w)try{if(await Promise.resolve(w(gt,Jt,Ht,Br??null,cr))===!1)return!1;qt("Comment posted")}catch(_r){const Aa=_r instanceof Error?_r.message:"Failed to post comment";throw qt(Aa),_r}},Bt="hidden";return t.jsxs("div",{className:`flex items-center justify-between gap-2 sm:gap-4 w-full ${ge}`,children:[t.jsxs("div",{className:`flex flex-wrap items-center justify-center shrink-0 ${Le}`,children:[t.jsxs("div",{className:`flex items-center ${Te}`,children:[t.jsxs("div",{className:"relative group",children:[t.jsx("span",{className:Bt,children:"Upvote"}),t.jsx("button",{type:"button",onClick:vt,disabled:da,className:`${je} rounded hover:bg-gray-700 disabled:opacity-50`,"aria-label":"Upvote",children:da?t.jsx(W.Loader2,{className:`${he} animate-spin text-blue-600`}):t.jsx(W.ThumbsUp,{className:`${he} ${ke?"fill-[var(--hrk-brand)] text-[var(--hrk-brand)]":"text-gray-300"}`})})]}),t.jsxs("div",{className:"relative group",children:[t.jsx("span",{className:Bt,children:"View upvotes"}),t.jsx("button",{type:"button",onClick:Mr,className:`flex items-center text-gray-300 hover:text-blue-400 transition-colors ${Te} ${je} rounded hover:bg-gray-700/40`,"aria-label":"View upvotes",children:t.jsx("span",{children:hr})})]})]}),le||G?t.jsxs("div",{className:`relative group flex items-center text-gray-300 ${Te}`,children:[t.jsx("span",{className:Bt,children:"Comments"}),t.jsxs("div",{className:"relative",onMouseEnter:Vr,onMouseLeave:()=>jt(!1),children:[t.jsx("button",{type:"button",onClick:()=>{le?le():We()},className:`rounded transition-colors hover:text-blue-400 ${Ve}`,"aria-label":K?"Reply to post (you've already commented)":"Reply to post",children:t.jsx(W.MessageCircle,{className:`${he} ${K?"fill-[var(--hrk-brand)] text-[var(--hrk-brand)]":""}`})}),K&&tt&&t.jsxs("div",{className:"absolute bottom-full left-0 z-30 mb-2 w-72 rounded-lg border border-[var(--hrk-border-default)] bg-[var(--hrk-bg-surface-sunken)] p-3 shadow-xl",children:[t.jsx("p",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wide text-[var(--hrk-brand-fg-soft)]",children:"Your comment"}),wr&&t.jsx("p",{className:"text-xs text-[var(--hrk-text-tertiary)]",children:"Loading…"}),!wr&&sa&&t.jsx("p",{className:"line-clamp-6 whitespace-pre-wrap text-xs leading-relaxed text-[var(--hrk-text-secondary)]",children:sa}),!wr&&!sa&&ir!==null&&t.jsx("p",{className:"text-xs italic text-[var(--hrk-text-tertiary)]",children:"No preview available."})]})]}),t.jsx("button",{type:"button",onClick:()=>{G?G():We()},className:`rounded transition-colors ${Ve} ${K?"text-[var(--hrk-brand-fg-soft)]":"text-gray-300 hover:text-blue-400"}`,"aria-label":"Open comments",children:or})]}):t.jsxs("div",{className:"relative group",onMouseEnter:Vr,onMouseLeave:()=>jt(!1),children:[t.jsx("span",{className:Bt,children:"Comments"}),t.jsxs("button",{type:"button",onClick:We,className:`flex items-center transition-colors hover:text-blue-400 rounded ${Te} ${Ve} ${K?"text-[var(--hrk-brand-fg-soft)]":"text-gray-300"}`,"aria-label":"Comments",children:[t.jsx(W.MessageCircle,{className:`${he} ${K?"fill-[var(--hrk-brand)] text-[var(--hrk-brand)]":""}`}),t.jsx("span",{children:or})]}),K&&tt&&t.jsxs("div",{className:"absolute bottom-full left-0 z-30 mb-2 w-72 rounded-lg border border-[var(--hrk-border-default)] bg-[var(--hrk-bg-surface-sunken)] p-3 shadow-xl",children:[t.jsx("p",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wide text-[var(--hrk-brand-fg-soft)]",children:"Your comment"}),wr&&t.jsx("p",{className:"text-xs text-[var(--hrk-text-tertiary)]",children:"Loading…"}),!wr&&sa&&t.jsx("p",{className:"line-clamp-6 whitespace-pre-wrap text-xs leading-relaxed text-[var(--hrk-text-secondary)]",children:sa}),!wr&&!sa&&ir!==null&&t.jsx("p",{className:"text-xs italic text-[var(--hrk-text-tertiary)]",children:"No preview available."})]})]}),Oe?t.jsx(Hv,{onEdit:j,onReblog:M?Mt:void 0,onReSnap:P?At:void 0,onShare:Kt,onTip:E?Yt:void 0,onReport:bt?Gt:void 0,onToggleBookmark:H,isBookmarked:$,onDelete:R}):t.jsxs(t.Fragment,{children:[M&&t.jsxs("div",{className:"relative group",children:[t.jsx("span",{className:Bt,children:"Reblog"}),t.jsx("button",{type:"button",onClick:Mt,className:`flex items-center text-gray-300 hover:text-blue-400 transition-colors rounded ${Te} ${Ve}`,"aria-label":"Reblog",children:t.jsx(W.Repeat2,{className:he})})]}),t.jsxs("div",{className:"relative group",children:[t.jsx("span",{className:Bt,children:"Share"}),t.jsx("button",{type:"button",onClick:Kt,className:`flex items-center text-gray-300 hover:text-blue-400 transition-colors rounded ${Te} ${Ve}`,"aria-label":"Share",children:t.jsx(W.Share2,{className:he})})]}),bt&&t.jsxs("div",{className:"relative group",children:[t.jsx("span",{className:Bt,children:"Report"}),t.jsx("button",{type:"button",onClick:Gt,className:`flex items-center text-gray-300 hover:text-red-400 transition-colors rounded ${Te} ${Ve}`,"aria-label":"Report",children:t.jsx(W.Flag,{className:he})})]}),E&&t.jsxs("div",{className:"relative group",children:[t.jsx("span",{className:Bt,children:"Tip"}),t.jsx("button",{type:"button",onClick:Yt,className:`flex items-center text-gray-300 hover:text-green-400 transition-colors rounded ${Te} ${Ve}`,"aria-label":"Tip",children:t.jsx(W.Gift,{className:he})})]}),(j||R||H)&&t.jsx(Hv,{onEdit:j,onToggleBookmark:H,isBookmarked:$,onDelete:R,ariaLabel:"More post actions"})]})]}),t.jsx("div",{className:"flex-1 flex justify-end min-w-0 shrink-0",children:u!=null&&u!==""&&(m?t.jsxs("button",{type:"button",onClick:gt=>{gt.stopPropagation(),$t(!0)},className:"flex items-center gap-1 rounded-md px-1 py-0.5 transition-colors hover:bg-white/5","aria-label":"Show rewards breakdown",children:[t.jsx("span",{className:`font-semibold text-green-400 ${ge}`,children:u}),d&&t.jsx("img",{src:d,alt:"Hive",className:me})]}):t.jsxs("div",{className:"relative group",children:[t.jsxs("div",{className:"flex items-center gap-1 cursor-default",children:[t.jsx("span",{className:`font-semibold text-green-400 ${ge}`,children:u}),d&&t.jsx("img",{src:d,alt:"Hive",className:me})]}),f&&t.jsx("div",{className:"absolute right-0 bottom-full mb-2 w-64 px-3 py-2 text-xs text-gray-200 bg-gray-900 border border-gray-700 rounded-lg shadow-xl whitespace-pre-line opacity-0 pointer-events-none group-hover:opacity-100 group-hover:pointer-events-auto transition-opacity duration-200 z-[60]",children:f})]}))}),$r&&t.jsx(Uw,{author:a,permlink:o,defaultValue:be,step:xe,onUpvote:Gr,onCancel:()=>ta(!1),awaitingWalletApproval:Ye}),Wt&&m&&t.jsx(yk,{onClose:()=>$t(!1),details:m,hiveIconUrl:d}),Pt&&t.jsx($w,{author:a,permlink:o,onClose:()=>wt(!1),currentUser:et??void 0,token:void 0,onClickUpvoteButton:vr,hiveIconUrl:d,onUserClick:q,getUserUrl:F}),Qt&&t.jsx(oN,{author:a,permlink:o,onClose:()=>{Nr(!1),Cn.getCommentsList(a,o).then(gt=>pr(gt.length))},currentUser:et??void 0,token:void 0,onSubmitComment:w?er:void 0,onClickCommentUpvote:A,ecencyToken:X,threeSpeakApiKey:Y,giphyApiKey:Z,templateToken:J,templateApiBaseUrl:re,showVoteButton:!!ye&&!ke,parentTags:we,defaultReward:Me,defaultBeneficiaries:Ue,beneficiaryFavorites:se,defaultVotePercent:be,voteWeightStep:xe,allowLandscapeVideos:Ae,awaitingWalletApproval:Ye}),Dr.visible&&t.jsx("div",{className:"fixed bottom-4 right-4 z-[100] max-w-[280px] rounded-lg bg-gray-900 text-white px-3 py-2 shadow-lg text-sm",children:Dr.message})]})}function hN(a){const o=a??"",{language:l}=$k(),[u,d]=T.useState(o),[f,m]=T.useState(!1);return T.useEffect(()=>{if(!l||!o){d(o),m(!1);return}let g=!1;return m(!0),Bk(o,l).then(x=>{g||(d(x),m(!1))}).catch(()=>{g||(d(o),m(!1))}),()=>{g=!0}},[o,l]),{text:u,loading:f}}const _g=({text:a,fallback:o})=>{const{text:l}=hN(a??""),u=l||a;return t.jsx(t.Fragment,{children:u||o||""})},xz=/!\[[^\]]*\]\(([^\s)]+)\)/g,vz=/<img[^>]+src=["']([^"']+)["'][^>]*>/gi,yz=/https?:\/\/[^\s"'<>)]+\.(?:jpe?g|png|gif|webp|avif)(?:\?[^\s"'<>)]*)?/gi,wz=/https?:\/\/(?:www\.)?youtube\.com\/watch\?v=([^&\s]+)|https?:\/\/youtu\.be\/([^?\s]+)|https?:\/\/(?:www\.)?youtube\.com\/shorts\/([^?\s]+)/gi,_z=/https?:\/\/(?:play\.)?3speak\.tv\/[^\s"'<>)]+/gi,kz=/https?:\/\/(?:www\.)?(?:twitter\.com|x\.com)\/[^/]+\/status\/(\d+)/gi;function Nz(a){const o=new Set,l=[];for(const u of a){const d=u.kind==="image"?`image:${u.url}`:u.kind==="youtube"?`youtube:${u.id}`:u.kind==="twitter"?`twitter:${u.id}`:`threespeak:${u.url}`;o.has(d)||(o.add(d),l.push(u))}return l}function ET(a){const o=[],l=a.json_metadata;if(l&&typeof l=="object"&&Array.isArray(l.image))for(const f of l.image)typeof f=="string"&&f&&o.push({kind:"image",url:f});const u=a.body??"";let d;for(;d=xz.exec(u);)o.push({kind:"image",url:d[1]});for(;d=vz.exec(u);)o.push({kind:"image",url:d[1]});for(;d=yz.exec(u);)o.push({kind:"image",url:d[0]});for(;d=wz.exec(u);){const f=d[1]||d[2]||d[3];f&&o.push({kind:"youtube",id:f})}for(;d=_z.exec(u);)o.push({kind:"threespeak",url:d[0]});for(;d=kz.exec(u);)o.push({kind:"twitter",id:d[1],url:d[0]});return Nz(o)}function jz(a){try{const l=new URL(a).searchParams.get("v");if(!l)return null;const[u,d]=l.split("/");return!u||!d?null:{author:u,permlink:d}}catch{return null}}const Sz="https://play.3speak.tv/api/embed",Ez="https://play.3speak.tv/api/watch";async function Az(a,o,l){const u=[`${Ez}?v=${a}/${o}`,`${Sz}?v=${a}/${o}`];let d=null;for(const f of u){if(l())throw new Error("cancelled");try{const m=await fetch(f,{headers:{Accept:"application/json"}});if(!m.ok){d=new Error(`HTTP ${m.status}`);continue}const g=await m.json();if(g?.success&&AT(g).length>0)return g;d=new Error("Video not found")}catch(m){d=m instanceof Error?m:new Error("fetch failed")}}throw d??new Error("Video unavailable")}function AT(a){return[a.videoUrl,a.videoUrlFallback1,a.videoUrlFallback2,a.videoUrlFallback3].filter(o=>typeof o=="string"&&o.length>0)}function Tz(a,o,l){if(a.canPlayType("application/vnd.apple.mpegurl")||!o.includes(".m3u8")){let f=!1;const m=()=>{f||(f=!0,l?.())};return a.addEventListener("error",m),a.src=o,()=>{a.removeEventListener("error",m),a.removeAttribute("src"),a.load()}}if(Pd.isSupported()){const f=new Pd({enableWorker:!0,lowLatencyMode:!1});let m=!1;return f.on(Pd.Events.ERROR,(g,x)=>{!x.fatal||m||(m=!0,l?.())}),f.loadSource(o),f.attachMedia(a),()=>{try{f.destroy()}catch{}}}let u=!1;const d=()=>{u||(u=!0,l?.())};return a.addEventListener("error",d),a.src=o,()=>{a.removeEventListener("error",d),a.removeAttribute("src"),a.load()}}function fm({author:a,permlink:o,hideThumbnail:l=!1}){const[u,d]=T.useState(null),[f,m]=T.useState(null),[g,x]=T.useState(null),[y,b]=T.useState(!1),w=T.useRef(null);T.useEffect(()=>{let z=!1;return d(null),m(null),x(null),b(!1),Az(a,o,()=>z).then(H=>{z||d(H)}).catch(H=>{!z&&(!(H instanceof Error)||H.message!=="cancelled")&&m("Failed to load video")}),()=>{z=!0}},[a,o]),T.useEffect(()=>{const z=w.current;if(!z||!u)return;const H=AT(u);if(H.length===0){m("Video unavailable");return}const $=()=>{z.videoWidth>0&&z.videoHeight>0&&x(z.videoWidth/z.videoHeight)},R=()=>b(!0);z.addEventListener("loadedmetadata",$),z.addEventListener("playing",R);let A=!1,q=null,F=0;const X=()=>{if(A)return;if(q&&(q(),q=null),F>=H.length){m("Failed to load video");return}const Y=H[F];F+=1,q=Tz(z,Y,()=>{setTimeout(X,0)})};return X(),()=>{A=!0,z.removeEventListener("loadedmetadata",$),z.removeEventListener("playing",R),q&&q()}},[u]);const M=`threeSpeakNative ${(g!=null?g<1:u?.short===!0)?"threeSpeakNativePortrait":"threeSpeakNativeLandscape"}${l?" threeSpeakNativeNoThumb":""}`,P=u?.short===!0?9/16:16/9,D=g??(u?P:null),E=l?D!=null?{aspectRatio:`${D}`}:void 0:g!=null?{aspectRatio:`${g}`}:void 0;return f?t.jsx("div",{className:M,"data-state":"error",children:t.jsx("div",{className:"threeSpeakNativeMessage",children:f})}):u?t.jsxs("div",{className:M,style:E,"data-state":"ready",children:[!l&&u.thumbnail&&!y&&t.jsx("img",{src:u.thumbnail,alt:"",className:"threeSpeakNativeThumb","aria-hidden":"true"}),t.jsx("video",{ref:w,controls:!0,playsInline:!0,preload:"metadata"})]}):t.jsx("div",{className:M,"data-state":"loading",children:t.jsx("div",{className:"threeSpeakNativeMessage",children:"Loading video…"})})}const rw=1,aw=4,jv=.5,TT=({items:a,startIndex:o=0,onClose:l})=>{const[u,d]=T.useState(()=>Math.max(0,Math.min(o,Math.max(0,a.length-1)))),[f,m]=T.useState(1),[g,x]=T.useState(0),[y,b]=T.useState(0),w=T.useRef(null),[v,j]=T.useState(!1),M=a.length===0?0:Math.max(0,Math.min(u,a.length-1)),P=a[M],D=P?.kind==="image";if(T.useEffect(()=>{m(1),x(0),b(0),j(!1)},[M]),T.useEffect(()=>{const F=Y=>{Y.key==="Escape"?l():Y.key==="ArrowLeft"?d(Z=>a.length===0?Z:(Z-1+a.length)%a.length):Y.key==="ArrowRight"?d(Z=>a.length===0?Z:(Z+1)%a.length):Y.key==="+"||Y.key==="="?m(Z=>Math.min(aw,Z+jv)):Y.key==="-"||Y.key==="_"?m(Z=>Math.max(rw,Z-jv)):Y.key==="0"&&(m(1),x(0),b(0))};window.addEventListener("keydown",F);const X=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{window.removeEventListener("keydown",F),document.body.style.overflow=X}},[l,a.length]),!P)return null;const E=()=>{a.length<=1||d(F=>(F-1+a.length)%a.length)},z=()=>{a.length<=1||d(F=>(F+1)%a.length)},H=F=>{if(!D)return;F.preventDefault();const X=F.deltaY<0?1:-1;m(Y=>Math.max(rw,Math.min(aw,Y+X*jv)))},$=F=>{!D||f===1||(w.current={startX:F.clientX,startY:F.clientY,baseTx:g,baseTy:y},F.target.setPointerCapture?.(F.pointerId))},R=F=>{w.current&&(x(w.current.baseTx+(F.clientX-w.current.startX)),b(w.current.baseTy+(F.clientY-w.current.startY)))},A=F=>{w.current=null,F.target.releasePointerCapture?.(F.pointerId)},q=()=>{D&&(m(F=>F===1?2:1),f!==1&&(x(0),b(0)))};return t.jsx("div",{className:"fixed inset-0 z-[2000] flex items-center justify-center bg-black/85 p-4",role:"dialog","aria-modal":"true",onClick:F=>{F.stopPropagation(),l()},children:t.jsxs("div",{className:"relative flex max-h-[90vh] w-full max-w-5xl items-center justify-center",onClick:F=>F.stopPropagation(),children:[t.jsx("button",{onClick:F=>{F.stopPropagation(),l()},className:"absolute -top-10 right-0 z-10 rounded-full bg-black/60 p-2 text-white transition-colors hover:bg-black/80","aria-label":"Close",children:t.jsx(W.X,{className:"h-5 w-5"})}),a.length>1&&t.jsxs("span",{className:"absolute -top-9 left-1/2 -translate-x-1/2 rounded-full bg-black/60 px-3 py-1 text-xs font-medium text-white",children:[M+1," / ",a.length]}),a.length>1&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:F=>{F.stopPropagation(),E()},className:"absolute left-2 top-1/2 -translate-y-1/2 z-10 rounded-full bg-black/60 p-2 text-white transition-colors hover:bg-black/80","aria-label":"Previous",children:t.jsx(W.ChevronLeft,{className:"h-6 w-6"})}),t.jsx("button",{onClick:F=>{F.stopPropagation(),z()},className:"absolute right-2 top-1/2 -translate-y-1/2 z-10 rounded-full bg-black/60 p-2 text-white transition-colors hover:bg-black/80","aria-label":"Next",children:t.jsx(W.ChevronRight,{className:"h-6 w-6"})})]}),D&&t.jsxs("div",{className:"absolute -bottom-12 left-1/2 -translate-x-1/2 z-10 flex items-center gap-2 rounded-full bg-black/60 px-2 py-1 text-white",children:[t.jsx("button",{onClick:F=>{F.stopPropagation(),m(X=>Math.max(rw,X-jv))},className:"rounded-full p-1.5 hover:bg-white/15 disabled:opacity-40","aria-label":"Zoom out",disabled:f<=rw,children:t.jsx(W.ZoomOut,{className:"h-4 w-4"})}),t.jsxs("span",{className:"min-w-[3rem] text-center text-xs tabular-nums",children:[Math.round(f*100),"%"]}),t.jsx("button",{onClick:F=>{F.stopPropagation(),m(X=>Math.min(aw,X+jv))},className:"rounded-full p-1.5 hover:bg-white/15 disabled:opacity-40","aria-label":"Zoom in",disabled:f>=aw,children:t.jsx(W.ZoomIn,{className:"h-4 w-4"})}),t.jsx("span",{className:"mx-1 h-4 w-px bg-white/25"}),t.jsx("button",{onClick:F=>{F.stopPropagation(),m(1),x(0),b(0)},className:"rounded-full p-1.5 hover:bg-white/15","aria-label":"Reset zoom",children:t.jsx(W.RotateCcw,{className:"h-4 w-4"})})]}),P.kind==="image"&&t.jsxs("div",{className:"relative flex max-h-[80vh] w-full items-center justify-center overflow-hidden select-none",onWheel:H,onPointerDown:$,onPointerMove:R,onPointerUp:A,onPointerCancel:A,onDoubleClick:q,style:{touchAction:f===1?"auto":"none"},children:[!v&&t.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center pointer-events-none",children:t.jsx(W.Loader2,{className:"h-8 w-8 animate-spin text-white/80"})}),t.jsx("img",{src:P.url,alt:"",draggable:!1,onLoad:()=>j(!0),onError:()=>j(!0),className:"max-h-[80vh] max-w-full rounded-lg object-contain transition-transform duration-100",style:{transform:`translate(${g}px, ${y}px) scale(${f})`,cursor:f===1?"zoom-in":w.current?"grabbing":"grab",opacity:v?1:.2}})]}),P.kind==="youtube"&&t.jsx("div",{className:"w-full overflow-hidden rounded-lg",style:{aspectRatio:"16/9"},children:t.jsx("iframe",{src:`https://www.youtube-nocookie.com/embed/${P.id}?autoplay=1&rel=0&playsinline=1`,title:"YouTube",className:"h-full w-full border-0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})}),P.kind==="threespeak"&&(()=>{const F=jz(P.url);return F?t.jsx("div",{className:"w-full",style:{maxWidth:"800px"},children:t.jsx(fm,{author:F.author,permlink:F.permlink,hideThumbnail:!0})}):t.jsx("a",{href:P.url,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-[var(--hrk-brand)] underline",children:"Open on 3Speak"})})()]})})};function pi({href:a,onActivate:o,className:l,style:u,title:d,stopPropagation:f=!0,children:m,...g}){const x=g["aria-label"];if(!a)return t.jsx("button",{type:"button",onClick:b=>{f&&b.stopPropagation(),o?.()},className:l,style:u,title:d,"aria-label":x,children:m});const y=b=>{f&&b.stopPropagation(),!(b.metaKey||b.ctrlKey||b.shiftKey||b.altKey||b.button!==0)&&(b.preventDefault(),o?.())};return t.jsx("a",{href:a,onClick:y,className:l,style:u,title:d,"aria-label":x,children:m})}const Cz=a=>{const o=/Z|[+-]\d{2}:?\d{2}$/.test(a)?a:`${a}Z`,l=new Date,u=new Date(o),d=Math.floor((l.getTime()-u.getTime())/1e3);return d<60?"just now":d<3600?`${Math.floor(d/60)}m ago`:d<86400?`${Math.floor(d/3600)}h ago`:d<2592e3?`${Math.floor(d/86400)}d ago`:u.toLocaleDateString()},Dz=a=>{let o=a;return o=o.replace(/<[^>]*>/g,""),o=o.replace(/!\[.*?\]\([^\s)]+\)/g,""),o=o.replace(/\[([^\]]*)\]\([^\s)]+\)/g,"$1"),o=o.replace(/https?:\/\/[^\s)>\]]+/g,""),o=o.replace(/\[.*?\]/g,""),o=o.replace(/\(https?:\/\/[^\s)]*\)/g,""),o=o.replace(/\s+/g," ").trim(),o},Mz=({media:a})=>{const[o,l]=T.useState(!1),u=T.useRef(null),d=a.kind+":"+("url"in a?a.url:a.id);return T.useEffect(()=>{l(!1);const f=u.current;f&&f.complete&&f.naturalWidth>0&&l(!0)},[d]),a.kind==="image"?t.jsxs(t.Fragment,{children:[!o&&t.jsx("span",{className:"absolute inset-0 z-10 flex items-center justify-center bg-black/20 pointer-events-none",children:t.jsx(W.Loader2,{className:"h-5 w-5 animate-spin text-white/80"})}),t.jsx("img",{ref:u,src:a.url,alt:"",loading:"lazy",decoding:"async",className:"absolute inset-0 h-full w-full object-cover",onLoad:()=>l(!0),onError:f=>{l(!0),f.target.style.display="none"}})]}):a.kind==="youtube"?t.jsxs(t.Fragment,{children:[!o&&t.jsx("span",{className:"absolute inset-0 z-10 flex items-center justify-center bg-black/20 pointer-events-none",children:t.jsx(W.Loader2,{className:"h-5 w-5 animate-spin text-white/80"})}),t.jsx("img",{ref:u,src:`https://i.ytimg.com/vi/${a.id}/hqdefault.jpg`,alt:"",loading:"lazy",decoding:"async",className:"absolute inset-0 h-full w-full object-cover opacity-90",onLoad:()=>l(!0),onError:f=>{l(!0),f.target.style.display="none"}}),t.jsx("span",{className:"absolute inset-0 flex items-center justify-center",children:t.jsx("span",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-black/70 text-white",children:t.jsx(W.Play,{className:"h-5 w-5 fill-current"})})}),t.jsx("span",{className:"absolute bottom-1.5 left-1.5 rounded bg-black/60 px-1.5 py-0.5 text-[10px] font-medium text-white",children:"YouTube"})]}):a.kind==="threespeak"?t.jsxs("span",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-[var(--hrk-bg-surface-sunken)]",children:[t.jsx("span",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-[var(--hrk-brand)]/15 text-[var(--hrk-brand)]",children:t.jsx(W.Play,{className:"h-5 w-5 fill-current"})}),t.jsx("span",{className:"rounded bg-black/60 px-1.5 py-0.5 text-[10px] font-medium text-white",children:"3Speak"})]}):t.jsxs("span",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-[var(--hrk-bg-surface-sunken)] text-white",children:[t.jsx("span",{className:"text-3xl font-semibold",children:"𝕏"}),t.jsx("span",{className:"rounded bg-black/60 px-1.5 py-0.5 text-[10px] font-medium",children:"Tweet"})]})},Oz=({media:a})=>{const[o,l]=T.useState(0),[u,d]=T.useState(null);if(a.length===0)return null;const f=Math.min(o,a.length-1),m=a[f],g=x=>{if(x.stopPropagation(),m.kind==="twitter"){window.open(m.url,"_blank","noopener,noreferrer");return}d(f)};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative my-2 mr-2 h-20 w-28 flex-shrink-0 overflow-hidden rounded-[10px] bg-[var(--hrk-bg-surface-sunken)] ring-1 ring-[var(--hrk-border-subtle)] sm:my-3 sm:mr-3 sm:h-auto sm:w-32 sm:self-stretch md:w-40 lg:w-48",children:[t.jsx("button",{onClick:g,className:"absolute inset-0 block cursor-pointer","aria-label":"Open media preview",children:t.jsx(Mz,{media:m})}),a.length>1&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:x=>{x.stopPropagation(),l(y=>(y-1+a.length)%a.length)},className:"absolute left-1 top-1/2 -translate-y-1/2 rounded-full bg-black/60 p-1 text-white hover:bg-black/80",title:"Previous",children:t.jsx(W.ChevronLeft,{className:"h-4 w-4"})}),t.jsx("button",{onClick:x=>{x.stopPropagation(),l(y=>(y+1)%a.length)},className:"absolute right-1 top-1/2 -translate-y-1/2 rounded-full bg-black/60 p-1 text-white hover:bg-black/80",title:"Next",children:t.jsx(W.ChevronRight,{className:"h-4 w-4"})}),t.jsxs("span",{className:"absolute bottom-1.5 right-1.5 rounded-full bg-black/60 px-1.5 py-0.5 text-[10px] font-medium text-white",children:[f+1,"/",a.length]})]})]}),u!==null&&t.jsx(TT,{items:a.filter(x=>x.kind!=="twitter"),startIndex:Math.min(u,Math.max(0,a.slice(0,u+1).filter(x=>x.kind!=="twitter").length-1)),onClose:()=>d(null)})]})},CT=({posts:a,currentUser:o,loading:l=!1,loadingMore:u=!1,hasMore:d=!1,onLoadMore:f,emptyMessage:m="No blogs to show.",onUpvote:g,onSubmitComment:x,onClickCommentUpvote:y,onReblog:b,onTip:w,onSharePost:v,onCommentClick:j,onReportPost:M,onToggleBookmark:P,isPostBookmarked:D,onDeletePost:E,onUserClick:z,onPostClick:H,getPostUrl:$,getUserUrl:R,getCommunityUrl:A,ecencyToken:q,threeSpeakApiKey:F,giphyApiKey:X,templateToken:Y,templateApiBaseUrl:Z,defaultVotePercent:J,voteWeightStep:re,allowLandscapeVideos:ce,awaitingWalletApproval:le,defaultReward:G,actionsAsMenu:K})=>l&&a.length===0?t.jsx("div",{className:"space-y-3",children:Array.from({length:5}).map((ee,ye)=>t.jsxs("div",{className:"overflow-hidden rounded-[14px] border border-[var(--hrk-border-subtle)] bg-[var(--hrk-bg-surface)] animate-pulse",children:[t.jsxs("div",{className:"flex items-stretch",children:[t.jsxs("div",{className:"min-w-0 flex-1 space-y-1.5 p-2.5 sm:space-y-2 sm:p-4",children:[t.jsxs("div",{className:"flex items-center gap-2 sm:gap-3",children:[t.jsx("div",{className:"h-7 w-7 rounded-full bg-[var(--hrk-bg-surface-sunken)] sm:h-9 sm:w-9"}),t.jsx("div",{className:"h-2.5 w-20 rounded bg-[var(--hrk-bg-surface-sunken)] sm:h-3 sm:w-24"}),t.jsx("div",{className:"h-2 w-10 rounded bg-[var(--hrk-bg-surface-sunken)] opacity-70 sm:w-12"})]}),t.jsx("div",{className:"h-3 w-5/6 rounded bg-[var(--hrk-bg-surface-sunken)] sm:h-4"}),t.jsx("div",{className:"h-2.5 w-full rounded bg-[var(--hrk-bg-surface-sunken)] opacity-70 sm:h-3"}),t.jsx("div",{className:"h-2.5 w-4/6 rounded bg-[var(--hrk-bg-surface-sunken)] opacity-70 sm:h-3"})]}),t.jsx("div",{className:"my-2 mr-2 h-20 w-28 flex-shrink-0 rounded-[10px] bg-[var(--hrk-bg-surface-sunken)] opacity-80 sm:my-3 sm:mr-3 sm:h-auto sm:w-32 sm:self-stretch md:w-40 lg:w-48"})]}),t.jsxs("div",{className:"flex gap-3 border-t border-[var(--hrk-border-subtle)] px-2.5 py-2 sm:px-4",children:[t.jsx("div",{className:"h-3 w-10 rounded bg-[var(--hrk-bg-surface-sunken)] opacity-70"}),t.jsx("div",{className:"h-3 w-10 rounded bg-[var(--hrk-bg-surface-sunken)] opacity-70"}),t.jsx("div",{className:"h-3 w-10 rounded bg-[var(--hrk-bg-surface-sunken)] opacity-70"}),t.jsx("div",{className:"ml-auto h-3 w-10 rounded bg-[var(--hrk-bg-surface-sunken)] opacity-70"})]})]},ye))}):!l&&a.length===0?t.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 py-14 text-center",children:[t.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-full bg-[var(--hrk-bg-hover)] text-[var(--hrk-text-tertiary)]",children:t.jsx(W.FileText,{className:"h-5 w-5"})}),t.jsx("p",{className:"text-sm text-[var(--hrk-text-secondary)]",children:m})]}):t.jsxs("div",{className:"space-y-3",children:[a.map(ee=>{const ye=ET(ee),we=ee.json_metadata?.description||(ee.body?Dz(ee.body):""),Me=ee.payout?ee.payout.toFixed(3):ee.pending_payout_value?ee.pending_payout_value.replace(/[^\d.]/g,""):"0.000",Ue=[],se=ee.percent_hbd??1e4;if(se===0?Ue.push("Hive Rewards Payout 100% Powered Up"):Ue.push(`Hive Rewards Payout (${(se/200).toFixed(0)}%/${100-se/200}%)`),ee.is_paidout){const ge=ee.author_payout_value?ee.author_payout_value.replace(/[^\d.]/g,""):"";Ue.push("Past payouts:"),Ue.push(`${Me} Hive Rewards${ge?` (Author ${ge})`:""}`)}else se===0?Ue.push(`${Me} Hive Rewards (100% Powered Up)`):Ue.push(`${Me} Hive Rewards (${(se/200).toFixed(0)}%/${100-se/200}%)`);const be=Ue.join(`
|
|
1163
|
+
`),xe=ge=>parseFloat((ge??"").replace(/[^\d.]/g,""))||0,Ae=xe(ee.pending_payout_value),Oe=xe(ee.author_payout_value),Ye=xe(ee.curator_payout_value),Se=ee.payout&&ee.payout>0?ee.payout:Ae>0?Ae:Oe+Ye,He={pendingValue:Ae,authorValue:Oe,curatorValue:Ye,totalValue:Se,isPaidout:!!ee.is_paidout,payoutAt:ee.payout_at,percentHbd:ee.percent_hbd??1e4,beneficiaries:(ee.beneficiaries??[]).map(ge=>({account:ge.account,weight:ge.weight}))},he=H?ge=>{ge.button!==0||ge.metaKey||ge.ctrlKey||ge.shiftKey||ge.altKey||H(ee.author,ee.permlink,ee.title)}:void 0;return t.jsxs("div",{className:`group overflow-hidden rounded-[14px] border border-[var(--hrk-border-subtle)] bg-[var(--hrk-bg-surface)] transition-[background-color,border-color] duration-150 ease-out hover:border-[var(--hrk-border-default)] hover:bg-[var(--hrk-bg-surface-raised)] ${he?"cursor-pointer":""}`,onClick:he,children:[t.jsxs("div",{className:"flex items-stretch",children:[t.jsxs("div",{className:"min-w-0 flex-1 p-2.5 sm:p-4",children:[t.jsxs("div",{className:"mb-1 flex items-center gap-2 sm:mb-1.5 sm:gap-3",children:[t.jsx("img",{src:`https://images.hive.blog/u/${ee.author}/avatar`,alt:ee.author,loading:"lazy",decoding:"async",className:"h-7 w-7 flex-shrink-0 rounded-full bg-[var(--hrk-bg-surface-sunken)] object-cover ring-1 ring-[var(--hrk-border-subtle)] sm:h-9 sm:w-9",onError:ge=>{ge.target.src=`https://ui-avatars.com/api/?name=${ee.author}&background=random&size=40`}}),t.jsxs("div",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-x-1.5 gap-y-0 sm:gap-x-2 sm:gap-y-0.5",children:[t.jsxs(pi,{href:R?.(ee.author),onActivate:()=>z?.(ee.author),className:"text-[11px] font-medium text-white hover:text-[var(--hrk-brand)] sm:text-sm",children:["@",ee.author]}),t.jsx(pi,{href:$?.(ee.author,ee.permlink),onActivate:()=>H?.(ee.author,ee.permlink,ee.title),className:"text-[10px] text-[var(--hrk-text-tertiary)] hover:text-[var(--hrk-brand)] hover:underline sm:text-xs",children:Cz(ee.created)}),ee.community_title&&t.jsxs(pi,{href:ee.community?A?.(ee.community):void 0,onActivate:()=>{ee.community&&z?.(ee.community)},className:"text-[10px] font-medium text-[var(--hrk-brand)] hover:underline sm:text-xs",children:["#",ee.community_title]})]})]}),ee.title&&t.jsx(pi,{href:$?.(ee.author,ee.permlink),onActivate:()=>H?.(ee.author,ee.permlink,ee.title),className:"mb-0.5 line-clamp-2 block text-left text-[13px] font-semibold leading-snug text-white hover:text-[var(--hrk-brand)] sm:mb-1 sm:text-base",children:t.jsx(_g,{text:ee.title})}),we&&t.jsx("p",{className:"line-clamp-2 text-[11px] leading-snug text-[var(--hrk-text-tertiary)] sm:line-clamp-3 sm:text-sm sm:leading-relaxed",children:t.jsx(_g,{text:we.substring(0,240)})})]}),t.jsx(Oz,{media:ye})]}),t.jsx("div",{className:"border-t border-[var(--hrk-border-subtle)] px-2.5 py-2 sm:px-4",onClick:ge=>ge.stopPropagation(),children:t.jsx(Ag,{author:ee.author,permlink:ee.permlink,currentUser:o,onUserClick:z,getUserUrl:R,hiveValue:Me,hiveIconUrl:"/images/hive_logo.png",payoutTooltip:be,payoutDetails:He,initialVotes:ee.active_votes??[],initialVoteCount:ee.stats?.total_votes??ee.net_votes??ee.active_votes?.length??0,initialCommentsCount:ee.children||0,postCreatedAt:ee.created,onUpvote:g?ge=>g(ee.author,ee.permlink,ge):void 0,onSubmitComment:x?(ge,me,Ve)=>x(ge,me,Ve):void 0,onClickCommentUpvote:y,onReblog:ee.author!==o&&b?()=>b(ee.author,ee.permlink):void 0,onShare:v?()=>v(ee.author,ee.permlink):void 0,onTip:ee.author!==o&&w?()=>w(ee.author,ee.permlink):void 0,onToggleBookmark:P?()=>P(ee.author,ee.permlink):void 0,isBookmarked:D?D(ee.author,ee.permlink):!1,onReport:ee.author!==o&&M?()=>M(ee.author,ee.permlink):void 0,onDelete:ee.author===o&&E?()=>E(ee.author,ee.permlink):void 0,disableCommentsModal:!!j,onComments:j?()=>j(ee.author,ee.permlink):void 0,ecencyToken:q,threeSpeakApiKey:F,giphyApiKey:X,templateToken:Y,templateApiBaseUrl:Z,defaultReward:G,defaultVotePercent:J,voteWeightStep:re,allowLandscapeVideos:ce,awaitingWalletApproval:le,actionsAsMenu:K})})]},`${ee.author}/${ee.permlink}`)}),d&&f&&t.jsx(Rz,{onLoadMore:f,loadingMore:u})]}),Rz=({onLoadMore:a,loadingMore:o})=>{const l=T.useRef(null),u=T.useRef(a),d=T.useRef(!!o);return T.useEffect(()=>{u.current=a},[a]),T.useEffect(()=>{d.current=!!o},[o]),T.useEffect(()=>{const f=l.current;if(!f)return;const m=new IntersectionObserver(g=>{g[0]?.isIntersecting&&!d.current&&u.current()},{root:null,rootMargin:"600px",threshold:0});return m.observe(f),()=>m.disconnect()},[]),t.jsx("div",{ref:l,className:"flex justify-center py-3 text-xs text-[var(--hrk-text-tertiary)]","aria-hidden":!o,children:o?t.jsxs("span",{className:"inline-flex items-center gap-2",role:"status","aria-live":"polite",children:[t.jsx(W.Loader2,{className:"h-3.5 w-3.5 animate-spin"}),"Loading more…"]}):t.jsx("span",{className:"block h-px w-full"})})},DT="hrk-selection-translate-cache-v1",c8=200;let Hd=null;const d8=new Map,O4=new Map;function f8(){if(Hd)return Hd;try{const a=typeof sessionStorage<"u"?sessionStorage.getItem(DT):null;Hd=a?JSON.parse(a):{}}catch{Hd={}}return Hd}function Lz(){if(Hd)try{const a=Object.keys(Hd);if(a.length>c8){const o=Math.max(1,Math.floor(a.length-c8*.8));for(let l=0;l<o;l++)delete Hd[a[l]]}typeof sessionStorage<"u"&&sessionStorage.setItem(DT,JSON.stringify(Hd))}catch{}}function zz(a){let o=5381;for(let l=0;l<a.length;l++)o=(o<<5)+o^a.charCodeAt(l);return(o>>>0).toString(36)}function Pz(a,o){return`${o}:${zz(a)}`}async function MT(a,o){const l=(a??"").trim();if(!l)return"";if(!o)return l;const u=Pz(l,o),d=f8()[u]??d8.get(u);if(d)return d;const f=O4.get(u);if(f)return f;const m=(async()=>{try{const g=`https://translate.googleapis.com/translate_a/single?client=gtx&sl=auto&tl=${encodeURIComponent(o)}&dt=t&q=${encodeURIComponent(l)}`,x=await fetch(g);if(!x.ok)throw new Error(`google ${x.status}`);const y=await x.json(),b=[];if(Array.isArray(y)&&Array.isArray(y[0]))for(const v of y[0])Array.isArray(v)&&typeof v[0]=="string"&&b.push(v[0]);const w=b.join("").trim();if(!w)throw new Error("empty");return d8.set(u,w),f8()[u]=w,Lz(),w}catch{return l}finally{O4.delete(u)}})();return O4.set(u,m),m}const Yw=[{code:"en",label:"English"},{code:"es",label:"Spanish"},{code:"pt",label:"Portuguese"},{code:"fr",label:"French"},{code:"de",label:"German"},{code:"it",label:"Italian"},{code:"ru",label:"Russian"},{code:"ar",label:"Arabic"},{code:"hi",label:"Hindi"},{code:"zh-CN",label:"Chinese (Simplified)"},{code:"ja",label:"Japanese"},{code:"ko",label:"Korean"},{code:"tr",label:"Turkish"},{code:"id",label:"Indonesian"},{code:"vi",label:"Vietnamese"}],OT="hrk-selection-translate-lang";function ck(){try{if(typeof sessionStorage<"u"){const a=sessionStorage.getItem(OT);if(a)return a}}catch{}if(typeof navigator<"u"&&navigator.language){const a=navigator.language.split("-")[0],o=Yw.find(l=>l.code===a);if(o)return o.code}return"en"}function RT(a){try{typeof sessionStorage<"u"&&sessionStorage.setItem(OT,a)}catch{}}const dk=8;function zv({children:a,languages:o=Yw,minLength:l=2}){const u=T.useRef(null),[d,f]=T.useState(null),[m,g]=T.useState(null),[x,y]=T.useState(()=>ck()),[b,w]=T.useState(!1),[v,j]=T.useState(!1),[M,P]=T.useState(null),[D,E]=T.useState(null);T.useEffect(()=>{const A=()=>{if(m)return;const Z=typeof window<"u"?window.getSelection():null;if(!Z||Z.isCollapsed||Z.rangeCount===0){f(null);return}const J=Z.toString().trim();if(J.length<l){f(null);return}const re=Z.getRangeAt(0),ce=re.commonAncestorContainer.nodeType===Node.TEXT_NODE?re.commonAncestorContainer.parentElement:re.commonAncestorContainer;if(!u.current||!ce||!u.current.contains(ce)){f(null);return}const le=re.getBoundingClientRect();f({text:J,anchor:{top:le.bottom+dk,left:le.left+le.width/2}})},q=()=>window.setTimeout(A,30),F=()=>q(),X=()=>q(),Y=Z=>{const J=Z.target;J&&J.closest("[data-hrk-translate-ui]")||f(null)};return document.addEventListener("pointerup",F),document.addEventListener("touchend",X),document.addEventListener("mousedown",Y),()=>{document.removeEventListener("pointerup",F),document.removeEventListener("touchend",X),document.removeEventListener("mousedown",Y)}},[l,m]),T.useEffect(()=>{if(!m)return;const A=q=>{q.key==="Escape"&&(g(null),P(null),E(null),w(!1))};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[m]);const z=T.useCallback(async(A,q)=>{j(!0);try{const F=await MT(A,q);P(F)}finally{j(!1)}},[]),H=T.useCallback(()=>{if(!d)return;const A=ck();y(A),E(d.text),g(d.anchor),f(null),P(null),z(d.text,A)},[d,z]),$=T.useCallback(A=>{y(A),RT(A),w(!1),D&&z(D,A)},[D,z]),R=T.useCallback(()=>{g(null),P(null),E(null),w(!1)},[]);return t.jsxs("div",{ref:u,children:[a,d&&t.jsx(Bz,{anchor:d.anchor,onClick:H}),m&&D&&Yu.createPortal(t.jsx(Uz,{anchor:m,sourceText:D,translated:M,loading:v,targetLang:x,picking:b,languages:o,onPickerToggle:()=>w(A=>!A),onPickLanguage:$,onClose:R}),document.body)]})}function Bz({anchor:a,onClick:o}){return typeof document>"u"?null:Yu.createPortal(t.jsxs("button",{type:"button","data-hrk-translate-ui":"trigger",onMouseDown:l=>{l.preventDefault(),l.stopPropagation(),o()},style:{position:"fixed",top:a.top,left:a.left,transform:"translateX(-50%)",zIndex:2100},className:"inline-flex items-center gap-1 rounded-full border border-[var(--hrk-border-default)] bg-[var(--hrk-bg-surface-raised)] px-2.5 py-1 text-[11px] font-semibold text-[var(--hrk-text-primary)] shadow-lg hover:bg-[var(--hrk-bg-hover)]","aria-label":"Translate selection",children:[t.jsx(W.Languages,{className:"h-3.5 w-3.5 text-[var(--hrk-brand)]"}),"Translate"]}),document.body)}const nw=320;function Uz({anchor:a,sourceText:o,translated:l,loading:u,targetLang:d,picking:f,languages:m,onPickerToggle:g,onPickLanguage:x,onClose:y}){const b=T.useRef(null),[w,v]=T.useState(a),[j,M]=T.useState(0);T.useLayoutEffect(()=>{const A=typeof window<"u"?window.innerWidth:0,q=typeof window<"u"?window.innerHeight:0,F=Math.max(8,Math.min(A-nw-8,a.left-nw/2)),X=8,Y=b.current?.offsetHeight??240;let Z=a.top,J=q-Z-X;if(Y>J){const ce=a.top-Y-16-2*dk,le=a.top-16-2*dk-X;ce>=X?(Z=ce,J=le):le>J&&(Z=X,J=le)}Z<X&&(Z=X);const re=Math.max(160,Math.min(J,q-X*2));v({top:Z,left:F}),M(re)},[a]),T.useEffect(()=>{const A=F=>{const X=F.target;X&&X.closest("[data-hrk-translate-ui]")||y()},q=window.setTimeout(()=>{document.addEventListener("mousedown",A)},0);return()=>{window.clearTimeout(q),document.removeEventListener("mousedown",A)}},[y]);const[P,D]=T.useState({dx:0,dy:0}),E=T.useRef(null),z=T.useCallback(A=>{const q=A.target;if(!(q&&q.closest("button"))){A.preventDefault(),A.stopPropagation(),E.current={startClientX:A.clientX,startClientY:A.clientY,startDx:P.dx,startDy:P.dy,pointerId:A.pointerId};try{A.currentTarget.setPointerCapture(A.pointerId)}catch{}}},[P.dx,P.dy]),H=T.useCallback(A=>{const q=E.current;if(!q||q.pointerId!==A.pointerId)return;A.preventDefault();const F=window.innerWidth,X=window.innerHeight,Y=b.current?.offsetHeight??240,Z=8,J=-(w.left+nw-Z),re=F-w.left-Z,ce=-(w.top-Z),le=X-w.top-Math.min(40,Y),G=q.startDx+(A.clientX-q.startClientX),K=q.startDy+(A.clientY-q.startClientY);D({dx:Math.max(J,Math.min(re,G)),dy:Math.max(ce,Math.min(le,K))})},[w.left,w.top]),$=T.useCallback(A=>{if(E.current?.pointerId===A.pointerId){try{A.currentTarget.releasePointerCapture(A.pointerId)}catch{}E.current=null}},[]),R=m.find(A=>A.code===d)?.label??d;return t.jsxs("div",{ref:b,"data-hrk-translate-ui":"popover",style:{position:"fixed",top:w.top+P.dy,left:w.left+P.dx,width:nw,maxHeight:j?`${j}px`:"calc(100vh - 16px)",display:"flex",flexDirection:"column",zIndex:2200},className:"overflow-hidden rounded-xl border border-[var(--hrk-border-default)] bg-[var(--hrk-bg-surface)] shadow-2xl",role:"dialog","aria-label":"Translation",children:[t.jsxs("div",{className:"flex shrink-0 cursor-grab items-center justify-between gap-2 border-b border-[var(--hrk-border-subtle)] px-3 py-2 active:cursor-grabbing",style:{touchAction:"none"},onPointerDown:z,onPointerMove:H,onPointerUp:$,onPointerCancel:$,"aria-label":"Drag to move",children:[t.jsxs("button",{type:"button",onClick:g,className:"inline-flex items-center gap-1.5 rounded-md px-2 py-1 text-xs font-semibold text-[var(--hrk-text-primary)] hover:bg-[var(--hrk-bg-hover)]",children:[t.jsx(W.Languages,{className:"h-3.5 w-3.5 text-[var(--hrk-brand)]"}),R,t.jsx(W.ChevronDown,{className:"h-3 w-3 text-[var(--hrk-text-tertiary)]"})]}),t.jsx(W.GripHorizontal,{"aria-hidden":!0,className:"pointer-events-none h-3.5 w-3.5 text-[var(--hrk-text-tertiary)]"}),t.jsx("button",{type:"button",onClick:y,"aria-label":"Close",className:"flex h-6 w-6 items-center justify-center rounded-full text-[var(--hrk-text-tertiary)] hover:bg-[var(--hrk-bg-hover)] hover:text-[var(--hrk-text-primary)]",children:t.jsx(W.X,{className:"h-3.5 w-3.5"})})]}),f?t.jsx("ul",{role:"listbox",className:"min-h-0 flex-1 overflow-y-auto overscroll-contain py-1",style:{touchAction:"pan-y",WebkitOverflowScrolling:"touch"},children:m.map(A=>{const q=A.code===d;return t.jsx("li",{children:t.jsxs("button",{type:"button",role:"option","aria-selected":q,onClick:()=>x(A.code),className:"flex w-full items-center justify-between px-3 py-1.5 text-left text-xs transition-colors "+(q?"bg-[var(--hrk-bg-hover)] text-[var(--hrk-text-primary)]":"text-[var(--hrk-text-secondary)] hover:bg-[var(--hrk-bg-hover)]"),children:[t.jsx("span",{children:A.label}),t.jsx("span",{className:"text-[10px] uppercase tracking-wide text-[var(--hrk-text-tertiary)]",children:A.code})]})},A.code)})}):t.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain px-3 py-2.5",style:{touchAction:"pan-y",WebkitOverflowScrolling:"touch"},children:[t.jsx("p",{className:"mb-2 text-[11px] italic text-[var(--hrk-text-tertiary)]",children:o}),t.jsx("div",{className:"min-h-[36px] whitespace-pre-wrap break-words text-xs leading-relaxed text-[var(--hrk-text-primary)]",children:u?t.jsxs("span",{className:"inline-flex items-center gap-1.5 text-[var(--hrk-text-tertiary)]",children:[t.jsx(W.Loader2,{className:"h-3.5 w-3.5 animate-spin"}),"Translating…"]}):l||o})]})]})}function Hz({author:a,permlink:o,currentUser:l,onVotePoll:u,parsedMetadata:d}){const[f,m]=T.useState(null),[g,x]=T.useState(!0),[y,b]=T.useState([]),[w,v]=T.useState([]),[j,M]=T.useState(!1);T.useEffect(()=>{const G=new AbortController;return x(!0),lr.getPollDetail(a,o,G.signal).then(K=>m(K??null)).catch(()=>m(null)).finally(()=>x(!1)),()=>G.abort()},[a,o]);const P=f?.max_choices_voted??d?.max_choices_voted??1,D=P>1,E=f?.end_time?new Date(f.end_time).getTime():(d?.end_time??0)*1e3,z=E>0&&Date.now()>E,H=w.length>0,$=l?f?.poll_voters?.find(G=>G.name===l):void 0,R=$?.choices?.length?$.choices:$?.choice_num!=null?[$.choice_num]:[],A=H||R.length>0,q=f?.allow_vote_changes??d?.allow_vote_changes??!1,F=H?w:R,X=!!l&&!z&&!!u&&(!A||q),Y=A&&q&&!H,Z=f?.poll_choices??(d?.choices??[]).map((G,K)=>({choice_num:K+1,choice_text:G,votes:null})),J=Z.reduce((G,K)=>G+(K.votes?.total_votes??0),0),re=D||Y,ce=async G=>{if(!(!X||j))if(re)b(K=>K.includes(G)?K.filter(ee=>ee!==G):K.length>=P?K:[...K,G]);else{M(!0);try{if(await Promise.resolve(u?.(a,o,[G]))===!1)return;v([G])}finally{M(!1)}}},le=async()=>{if(!(!X||j||y.length===0)){M(!0);try{if(await Promise.resolve(u?.(a,o,y))===!1)return;v(y),b([])}finally{M(!1)}}};return t.jsxs("div",{className:"mt-2 rounded-lg border border-[var(--hrk-border-subtle)] bg-[var(--hrk-bg-surface)]/60 overflow-hidden",children:[t.jsxs("div",{className:"flex items-center gap-2 px-3 pt-3 pb-2",children:[t.jsx(W.BarChart2,{className:"h-3.5 w-3.5 text-blue-400 flex-shrink-0"}),t.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-blue-400",children:"Poll"}),t.jsx("span",{className:`ml-auto rounded-full px-2 py-0.5 text-[10px] font-medium ${z?"bg-[var(--hrk-bg-surface-raised)] text-[var(--hrk-text-tertiary)]":"bg-green-900/50 text-green-400"}`,children:z?"Ended":E>0?`Ends in ${Math.ceil((E-Date.now())/(1e3*60*60*24))}d`:"Active"})]}),t.jsx("p",{className:"px-3 pb-2 text-sm font-semibold text-white",children:f?.question??d?.question??""}),X&&re&&t.jsxs("p",{className:"px-3 pb-1.5 text-[11px] text-[var(--hrk-text-tertiary)]",children:[Y?"Change your vote — ":"","Select up to ",P," option",P>1?"s":"",y.length>0&&t.jsxs("span",{className:"ml-1 text-blue-400",children:["· ",y.length," selected"]})]}),t.jsx("div",{className:"space-y-1.5 px-3 pb-3",children:g?[1,2,3].map(G=>t.jsx("div",{className:"h-8 animate-pulse rounded-lg bg-[var(--hrk-bg-surface-raised)]/50"},G)):Z.map(G=>{const K=G.votes?.total_votes??0,ee=J>0?Math.round(K/J*100):0,ye=F.includes(G.choice_num),we=y.includes(G.choice_num),Me=re&&y.length>=P&&!we,Ue=X&&!Me;let se="border-[var(--hrk-border-subtle)]",be=t.jsx(W.Circle,{className:"h-3 w-3 flex-shrink-0 text-[var(--hrk-text-tertiary)]"}),xe="bg-blue-600/20";return we?(se="border-blue-500/60",be=t.jsx(W.CheckCircle2,{className:"h-3 w-3 flex-shrink-0 text-blue-400"})):ye&&!Y?(se="border-green-600/60",be=t.jsx(W.CheckCircle2,{className:"h-3 w-3 flex-shrink-0 text-green-500"}),xe="bg-green-600/20"):ye&&Y&&(se="border-green-800/40",be=t.jsx(W.CheckCircle2,{className:"h-3 w-3 flex-shrink-0 text-green-700"}),xe="bg-green-900/10"),t.jsxs("button",{type:"button",onClick:Ae=>{Ae.stopPropagation(),ce(G.choice_num)},className:`relative w-full overflow-hidden rounded-md border bg-[var(--hrk-bg-app)]/50 text-left transition-colors ${se} ${Ue?"cursor-pointer hover:border-blue-500/40":Me?"cursor-not-allowed opacity-50":"cursor-default"}`,disabled:!Ue,children:[ee>0&&t.jsx("div",{className:`absolute inset-y-0 left-0 ${xe} transition-all duration-500`,style:{width:`${ee}%`}}),t.jsxs("div",{className:"relative flex items-center justify-between gap-2 px-2.5 py-2",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[be,t.jsx("span",{className:`truncate text-xs ${we?"font-medium text-blue-300":ye&&!Y?"font-medium text-green-300":ye&&Y?"text-green-700":"text-[var(--hrk-text-primary)]"}`,children:G.choice_text})]}),t.jsxs("div",{className:"flex flex-shrink-0 items-center gap-1.5 text-[10px] text-[var(--hrk-text-tertiary)]",children:[t.jsxs("span",{children:[ee,"%"]}),t.jsx("span",{className:"text-[var(--hrk-text-tertiary)]",children:"·"}),t.jsxs("span",{children:[K," vote",K!==1?"s":""]})]})]})]},G.choice_num)})}),X&&re&&t.jsx("div",{className:"px-3 pb-3",children:t.jsxs("button",{type:"button",onClick:G=>{G.stopPropagation(),le()},disabled:y.length===0||j,className:"flex w-full items-center justify-center gap-1.5 rounded-[10px] bg-[var(--hrk-brand)] px-3 py-1.5 text-xs font-medium text-[var(--hrk-text-on-brand)] transition-colors hover:bg-[var(--hrk-brand-hover)] disabled:bg-[var(--hrk-bg-surface-raised)] disabled:text-[var(--hrk-text-tertiary)]",children:[t.jsx(W.Send,{className:"h-3 w-3"}),j?"Submitting…":Y?"Change Vote":`Submit Vote${y.length>1?"s":""}`]})}),t.jsxs("div",{className:"flex items-center gap-2 border-t border-[var(--hrk-border-subtle)]/50 px-3 py-2 text-[10px] text-[var(--hrk-text-tertiary)]",children:[t.jsxs("span",{children:[f?.poll_stats?.total_voting_accounts_num??0," voter",(f?.poll_stats?.total_voting_accounts_num??0)!==1?"s":""," total"]}),A&&t.jsxs("span",{className:"ml-auto text-green-500",children:["✓ Voted",q?" · changes allowed":""]})]})]})}const $z=new Set(["peakd.com","www.peakd.com","hive.blog","www.hive.blog","ecency.com","www.ecency.com","inleo.io","www.inleo.io","snapie.io","www.snapie.io","hivesuite.app","www.hivesuite.app"]);function sw(a,o){const l=a?.toLowerCase();return l?o?{kind:"post",author:l,permlink:o}:{kind:"user",author:l}:null}function Tg(a){if(!a)return null;if(a.startsWith("#/@")){const[f,m]=a.slice(3).split("/").filter(Boolean);return sw(f,m)}if(a.startsWith("/@")){const[f,m]=a.slice(2).split("/").filter(Boolean);return sw(f,m)}let o;try{o=new URL(a)}catch{return null}const l=o.hostname.toLowerCase();if(!$z.has(l))return null;const u=o.pathname.split("/").filter(Boolean);if((l==="inleo.io"||l==="www.inleo.io")&&u[0]==="threads"&&u[1]==="view")return sw(u[2],u[3]);const d=u.findIndex(f=>f.startsWith("@"));return d===-1?null:sw(u[d].slice(1),u[d+1])}function LT(a,o){if(!a)return a;const l=o??(u=>`https://peakd.com/@${u}`);return a.replace(/(^|[^A-Za-z0-9_!#$%&*@/@])@([a-z][a-z0-9.-]{1,15}[a-z0-9])(?![a-z0-9.-])/gi,(u,d,f)=>{const m=f.toLowerCase();return`${d}[@${f}](${l(m)})`})}function qz(a){const o=/Z|[+-]\d{2}:?\d{2}$/.test(a)?a:`${a}Z`,l=Math.floor((Date.now()-new Date(o).getTime())/1e3);return l<60?"just now":l<3600?`${Math.floor(l/60)}m ago`:l<86400?`${Math.floor(l/3600)}h ago`:l<2592e3?`${Math.floor(l/86400)}d ago`:new Date(o).toLocaleDateString()}function Vz(a,o){if(o){const m=(typeof o=="string"?(()=>{try{return JSON.parse(o)}catch{return{}}})():o).image;if(Array.isArray(m)&&typeof m[0]=="string")return m[0]}const l=a.match(/!\[[^\]]*\]\(([^)\s]+)\)/);if(l)return l[1];const u=a.match(/<img[^>]+src=["']([^"']+)["']/i);if(u)return u[1];const d=a.match(/https?:\/\/\S+?\.(?:jpe?g|png|gif|webp|avif)(?:\?\S*)?/i);return d?d[0]:null}function Fz(a){return a.replace(/!\[[^\]]*\]\([^)]+\)/g,"").replace(/<img[^>]+>/gi,"").replace(/https?:\/\/\S+?\.(?:jpe?g|png|gif|webp|avif)(?:\?\S*)?/gi,"").replace(/<[^>]+>/g,"").replace(/[*_~`>#-]+/g," ").replace(/\s+/g," ").trim()}const Iz=({author:a,permlink:o,observer:l,onPostClick:u,onUserClick:d})=>{const[f,m]=T.useState(null),[g,x]=T.useState(!0),[y,b]=T.useState(!1);T.useEffect(()=>{let M=!1;return x(!0),b(!1),m(null),Cn.getPostContent(a,o,l??"").then(P=>{if(!M){if(!P||!P.author){b(!0),x(!1);return}m(P),x(!1)}}).catch(()=>{M||(b(!0),x(!1))}),()=>{M=!0}},[a,o,l]);const w=T.useMemo(()=>f?Vz(f.body??"",f.json_metadata):null,[f]),v=T.useMemo(()=>f?Fz(f.body??"").slice(0,280):"",[f]),j=M=>{M.stopPropagation(),f?u?.(f.author,f.permlink):u?.(a,o)};return t.jsxs("div",{className:"relative cursor-pointer overflow-hidden rounded-lg border border-emerald-500/30 bg-[var(--hrk-bg-surface-sunken)] transition hover:border-emerald-500/60",onClick:j,children:[t.jsxs("span",{className:"absolute right-2 top-2 z-10 inline-flex items-center gap-1 rounded-md bg-emerald-500/20 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-emerald-300",children:[t.jsx(W.Repeat,{className:"h-3 w-3"}),"Re-snap"]}),g?t.jsxs("div",{className:"space-y-2 p-3",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"h-7 w-7 rounded-full bg-[var(--hrk-bg-hover)]"}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("div",{className:"h-3 w-24 rounded bg-[var(--hrk-bg-hover)]"}),t.jsx("div",{className:"h-2 w-16 rounded bg-[var(--hrk-bg-hover)]"})]})]}),t.jsx("div",{className:"h-32 w-full rounded-md bg-[var(--hrk-bg-hover)]"}),t.jsx("div",{className:"h-3 w-3/4 rounded bg-[var(--hrk-bg-hover)]"})]}):y||!f?t.jsx("div",{className:"p-3 text-xs text-[var(--hrk-text-tertiary)]",children:"Original snap unavailable."}):t.jsxs("div",{className:"p-3",children:[t.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:M=>{M.stopPropagation(),d?.(f.author)},className:"shrink-0",children:t.jsx("img",{src:`https://images.hive.blog/u/${f.author}/avatar`,alt:f.author,className:"h-7 w-7 rounded-full bg-[var(--hrk-bg-hover)] object-cover",onError:M=>{M.target.src=`https://ui-avatars.com/api/?name=${f.author}&background=random&size=28`}})}),t.jsxs("div",{className:"min-w-0",children:[t.jsxs("button",{type:"button",onClick:M=>{M.stopPropagation(),d?.(f.author)},className:"block truncate text-sm font-semibold text-[var(--hrk-text-primary)] hover:text-[var(--hrk-brand)]",children:["@",f.author]}),t.jsx("span",{className:"text-[11px] text-[var(--hrk-brand)]",children:qz(f.created)})]})]}),w&&t.jsx("img",{src:w,alt:"",loading:"lazy",className:"mb-2 max-h-72 w-full rounded-md object-cover",onError:M=>{M.target.style.display="none"}}),v&&t.jsx("p",{className:"line-clamp-4 whitespace-pre-wrap break-words text-sm leading-relaxed text-[var(--hrk-text-secondary)]",children:v})]})]})},bh=/https?:\/\/[^\s"'<>)]+\/ipfs\/[a-zA-Z0-9]+(?:\/[^\s"'<>)]*)?/gi,Pv=new Map,R4=new Map;function Gz(a){const o=Pv.get(a);if(o)return Promise.resolve(o);const l=R4.get(a);if(l)return l;const u=fetch(a,{method:"HEAD"}).then(d=>{const f=(d.headers.get("content-type")??"").toLowerCase(),m=f.startsWith("image/")?"image":f.startsWith("video/")?"video":"unknown";return Pv.set(a,m),m}).catch(()=>{const d="unknown";return Pv.set(a,d),d}).finally(()=>{R4.delete(a)});return R4.set(a,u),u}function mN(a){const[o,l]=T.useState(()=>Pv.get(a)??null);return T.useEffect(()=>{let u=!1;const d=Pv.get(a);if(d){l(d);return}return l(null),Gz(a).then(f=>{u||l(f)}),()=>{u=!0}},[a]),o}const Zz=({url:a,variant:o="full",onTileClick:l,className:u})=>{const d=mN(a);return d===null?t.jsx("div",{className:`flex h-full w-full items-center justify-center bg-[var(--hrk-bg-surface-sunken)] ${u??""}`,"aria-label":"Resolving IPFS media",children:t.jsx("div",{className:"h-6 w-6 animate-pulse rounded-full bg-[var(--hrk-bg-hover)]"})}):d==="image"?o==="tile"?t.jsx("button",{type:"button",onClick:l,className:`relative flex h-full w-full items-center justify-center overflow-hidden rounded-lg bg-[var(--hrk-bg-surface-sunken)] ${u??""}`,"aria-label":"Open image preview",children:t.jsx("img",{src:a,alt:"",loading:"lazy",className:"max-h-full max-w-full object-contain"})}):t.jsx("img",{src:a,alt:"",className:`max-h-full max-w-full object-contain ${u??""}`}):d==="video"?t.jsx("video",{src:a,controls:!0,playsInline:!0,preload:"metadata",className:`max-h-full max-w-full ${u??""}`}):t.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:`text-sm text-[var(--hrk-brand)] underline ${u??""}`,children:a})},fk=/https?:\/\/(?:www\.)?(?:twitter\.com|x\.com)\/[^/]+\/status\/(\d+)/gi,hk=/https?:\/\/(?:www\.)?youtube\.com\/watch\?v=([^&\s]+)|https?:\/\/youtu\.be\/([^?\s]+)|https?:\/\/(?:www\.)?youtube\.com\/shorts\/([^?\s]+)/gi,mk=/https?:\/\/(?:play\.)?3speak\.tv\/[^\s"'<>)]+/gi,pk=/https?:\/\/[^\s"'<>)]+?\.(?:mp3|wav|ogg|m4a|aac|flac|webm|opus)(?:\?[^\s"'<>)]*)?/gi,gk=/https?:\/\/audio\.3speak\.tv\/play\?[^\s"'<>)]+/gi,bk=/!\[[^\]]*\]\(([^\s)]+)\)/g,xk=/<img[^>]+src=["']([^"']+)["'][^>]*>/gi,zT=/https?:\/\/[^\s"'<>)]+?\.(?:jpe?g|png|gif|webp|avif|bmp|svg)(?:\?[^\s"'<>)]*)?/gi,Yz=/https?:\/\/[^\s)<>\]]+/g,Xz=/@([a-z][a-z0-9.-]{1,15}[a-z0-9])/g,Wz=/(?:^|\s)#([a-zA-Z][\w-]{0,31})/g;function mg(a){return Array.from(new Set(a))}function Jz(a){return a.trim().replace(/[)\],.;:>\s"'<]+$/,"").replace(/^(https?):\/(?!\/)/,"$1://")}function Qz(a){const o=new Set,l=[];for(const u of a){if(typeof u!="string")continue;const d=Jz(u);if(!d||!/^https?:\/\//.test(d))continue;let f=d;try{f=decodeURIComponent(d)}catch{}o.has(f)||(o.add(f),l.push(d))}return l}function pN(a){if(!a)return{};if(typeof a=="string")try{return JSON.parse(a)}catch{return{}}return typeof a=="object"?a:{}}const Kz=new Set(["hsnaps","hreplier","hivesuite"]);function eP(a){const o=pN(a.json_metadata);return(Array.isArray(o.tags)?o.tags:[]).some(u=>typeof u=="string"&&Kz.has(u.toLowerCase()))}function tP(a){const o=pN(a.json_metadata);return(Array.isArray(o.tags)?o.tags:[]).filter(u=>typeof u=="string"&&u.length>0)}function PT(a){return a.replace(/\s*(?:<br\s*\/?>)?\s*<sub>\s*\[via Apps from\][^<]*<\/sub>\s*$/i,"").replace(/\s*(?:<br\s*\/?>)?\s*\[via Apps from\]\([^)]*\)\s*$/i,"").replace(/\s*(?:<br\s*\/?>)?\s*via Apps from\s+https?:\/\/\S+\s*$/i,"")}function rP(a){const o=(a||"").trim();if(!o)return null;const l=f=>{const m=Tg(f);return m&&m.kind==="post"?{author:m.author,permlink:m.permlink}:null};if(/^https?:\/\/\S+$/.test(o))return l(o);const u=o.match(/^\[[^\]]*\]\((https?:\/\/[^)\s]+)\)$/);if(u)return l(u[1]);const d=o.match(/^<a\s[^>]*href=["'](https?:\/\/[^"']+)["'][^>]*>[^<]*<\/a>$/i);return d?l(d[1]):null}function aP(a){const o=PT(a.body??""),l=[];let u;for(;u=bk.exec(o);)l.push(u[1]);for(;u=xk.exec(o);)l.push(u[1]);for(;u=zT.exec(o);)l.push(u[0]);const d=[],f=new RegExp(bh.source,bh.flags);for(;u=f.exec(o);)d.push(u[0]);const m=[];for(;u=hk.exec(o);)m.push(u[1]||u[2]||u[3]);const g=[];for(;u=mk.exec(o);)g.push(u[0]);const x=[];for(;u=gk.exec(o);)x.push(u[0]);const y=[];for(;u=pk.exec(o);)x.includes(u[0])||y.push(u[0]);const b=[];for(;u=fk.exec(o);)b.push(u[1]);const w=[...Qz(l).map($=>({kind:"image",url:$})),...mg(d).map($=>({kind:"ipfs",url:$})),...mg(m).map($=>({kind:"youtube",id:$})),...mg(g).map($=>({kind:"threespeak",url:$})),...mg(b).map($=>({kind:"twitter",id:$})),...mg(x).map($=>({kind:"3speak-audio",url:$})),...mg(y).map($=>({kind:"audio",url:$}))];let v=o;v=v.replace(bk,""),v=v.replace(xk,""),v=v.replace(bh,""),v=v.replace(hk,""),v=v.replace(mk,""),v=v.replace(gk,""),v=v.replace(pk,""),v=v.replace(fk,""),v=v.replace(/<[^>]+>/g,""),v=v.replace(/\[([^\]]+)\]\(([^\s)]+)\)/g,"$1 $2"),v=v.replace(/[*_~`>#-]+/g," "),v=v.replace(/\s+/g," ").trim();const j=[];let M=0;const P=[];let D;const E=new RegExp(Yz.source,"g");for(;(D=E.exec(v))!==null;)P.push({start:D.index,end:D.index+D[0].length,node:{kind:"link",url:D[0]}});const z=new RegExp(Xz.source,"g");for(;(D=z.exec(v))!==null;)P.some($=>D.index>=$.start&&D.index<$.end)||P.push({start:D.index,end:D.index+D[0].length,node:{kind:"mention",username:D[1]}});const H=new RegExp(Wz.source,"g");for(;(D=H.exec(v))!==null;){const $=D.index+(D[0].startsWith(" ")?1:0);P.some(R=>$>=R.start&&$<R.end)||P.push({start:$,end:$+(D[0].length-(D[0].startsWith(" ")?1:0)),node:{kind:"hashtag",tag:D[1]}})}P.sort(($,R)=>$.start-R.start);for(const $ of P)M<$.start&&j.push({kind:"text",text:v.slice(M,$.start)}),j.push($.node),M=$.end;return M<v.length&&j.push({kind:"text",text:v.slice(M)}),j.length===0&&v&&j.push({kind:"text",text:v}),{segments:j,attachments:w}}function nP(a){const o=/Z|[+-]\d{2}:?\d{2}$/.test(a)?a:`${a}Z`,l=Math.floor((Date.now()-new Date(o).getTime())/1e3);return l<60?"just now":l<3600?`${Math.floor(l/60)}m ago`:l<86400?`${Math.floor(l/3600)}h ago`:l<2592e3?`${Math.floor(l/86400)}d ago`:new Date(o).toLocaleDateString()}const sP=({segments:a,onUserClick:o,onTagClick:l,getUserUrl:u,getTagUrl:d})=>{const f=[];return a.forEach((m,g)=>{m.kind==="text"?f.push(t.jsx("span",{children:m.text},g)):m.kind==="mention"?f.push(t.jsxs(pi,{href:u?.(m.username),onActivate:()=>o?.(m.username),className:"text-[var(--hrk-brand)] hover:underline",children:["@",m.username]},g)):m.kind==="hashtag"?f.push(t.jsxs(pi,{href:d?.(m.tag),onActivate:()=>l?.(m.tag),className:"text-[var(--hrk-brand)] hover:underline",children:["#",m.tag]},g)):f.push(t.jsx("a",{href:m.url,target:"_blank",rel:"noopener noreferrer",onClick:x=>x.stopPropagation(),className:"break-all text-[var(--hrk-brand)] underline hover:text-[var(--hrk-brand-active)]",children:m.url},g))}),t.jsx("p",{className:"line-clamp-6 whitespace-pre-wrap break-words text-sm leading-relaxed text-[var(--hrk-text-secondary)]",children:f})};function BT(a){try{const l=new URL(a).searchParams.get("v");if(!l)return null;const[u,d]=l.split("/");return!u||!d?null:{author:u,permlink:d}}catch{return null}}const iP=({author:a,permlink:o})=>t.jsx("div",{className:"three-speak-embed my-3 hive-post-body",style:{margin:"0.75rem auto"},children:t.jsx(fm,{author:a,permlink:o})}),h8=a=>a.kind==="image"?a.url.toLowerCase().includes(".gif")?"GIF":"Image":a.kind==="youtube"?"YouTube":a.kind==="threespeak"?"3Speak":a.kind==="twitter"?"Tweet":a.kind==="3speak-audio"?"3Speak audio":"Audio",UT=({id:a})=>{const[o,l]=T.useState(null);T.useEffect(()=>{const d=f=>{try{const m=typeof f.data=="string"?JSON.parse(f.data):f.data;if(!m||typeof m!="object")return;let g;if(m.method==="resize"&&Array.isArray(m.params))for(const x of m.params)typeof x=="number"&&x>0&&(g=x),x&&typeof x=="object"&&typeof x.height=="number"&&(g=x.height);m["twttr.private.resize"]?.height&&(g=m["twttr.private.resize"].height),!g&&typeof m.height=="number"&&(g=m.height),!g&&m.msg_type==="resize"&&m.msg_data?.height&&(g=m.msg_data.height),g&&g>50&&l(Math.ceil(g))}catch{}};return window.addEventListener("message",d),()=>window.removeEventListener("message",d)},[]);const u=typeof window<"u"?window.location.origin:"";return t.jsx("div",{className:"twitter-embed-wrapper w-full overflow-hidden rounded-lg bg-black/60",style:o?{maxHeight:"80vh",overflowY:"auto"}:void 0,children:t.jsx("iframe",{src:`https://platform.twitter.com/embed/Tweet.html?id=${a}&theme=dark&dnt=true&origin=${encodeURIComponent(u)}`,title:`Tweet ${a}`,className:"twitter-embed-iframe w-full border-0 bg-black",scrolling:"yes",style:{height:o??"60vh"}})})},Sv=1,m8=.25,oP=.15,HT=({src:a})=>{const[o,l]=T.useState(1),[u,d]=T.useState(3),[f,m]=T.useState({x:0,y:0}),g=T.useRef(null),x=T.useRef(null),y=T.useRef(null),b=T.useRef(null),w=T.useCallback(()=>{l(1),m({x:0,y:0})},[]);T.useEffect(()=>{w()},[a,w]);const v=T.useCallback(()=>{const F=x.current;if(!F)return;const X=F.clientWidth||1,Y=F.clientHeight||1,Z=Math.max(F.naturalWidth/X,F.naturalHeight/Y);d(Math.max(1,Math.min(6,Z||1)))},[]),j=o>1,M=Math.round(o*100),P=T.useCallback(F=>{F.preventDefault();const X=g.current;if(!X)return;const Y=X.getBoundingClientRect(),Z=F.clientX-(Y.left+Y.width/2),J=F.clientY-(Y.top+Y.height/2);l(re=>{const ce=F.deltaY<0?1:-1,le=Math.max(Sv,Math.min(u,re+ce*oP));return le===re?re:(m(G=>{if(le===1)return{x:0,y:0};const K=le/re;return{x:Z-(Z-G.x)*K,y:J-(J-G.y)*K}}),le)})},[u]),D=T.useCallback(F=>{F.stopPropagation(),o===1?l(u):w()},[o,u,w]),E=T.useCallback(F=>{if(F.touches.length===2){const[X,Y]=[F.touches[0],F.touches[1]];b.current={startDistance:Math.hypot(X.clientX-Y.clientX,X.clientY-Y.clientY),startZoom:o};return}if(j){const X=F.touches[0];X&&(y.current={startClientX:X.clientX,startClientY:X.clientY,startPanX:f.x,startPanY:f.y})}},[o,j,f.x,f.y]),z=T.useCallback(F=>{if(F.touches.length===2&&b.current){const[X,Y]=[F.touches[0],F.touches[1]],J=Math.hypot(X.clientX-Y.clientX,X.clientY-Y.clientY)/b.current.startDistance;l(Math.max(Sv,Math.min(u,b.current.startZoom*J)));return}if(j&&y.current&&F.touches.length===1){const X=F.touches[0],Y=X.clientX-y.current.startClientX,Z=X.clientY-y.current.startClientY;m({x:y.current.startPanX+Y,y:y.current.startPanY+Z})}},[u,j]),H=T.useCallback(()=>{b.current=null,y.current=null},[]),$=T.useCallback(F=>{j&&(y.current={startClientX:F.clientX,startClientY:F.clientY,startPanX:f.x,startPanY:f.y})},[j,f.x,f.y]),R=T.useCallback(F=>{if(!y.current||F.buttons!==1)return;const X=F.clientX-y.current.startClientX,Y=F.clientY-y.current.startClientY;m({x:y.current.startPanX+X,y:y.current.startPanY+Y})},[]),A=T.useCallback(()=>{y.current=null},[]),q=F=>F.stopPropagation();return t.jsxs("div",{className:"relative w-full",onClick:q,children:[t.jsxs("div",{className:"mb-2 flex items-center justify-center gap-1",children:[t.jsx("button",{type:"button",onClick:F=>{F.stopPropagation(),l(X=>Math.max(Sv,X-m8)),m(X=>({x:X.x*.85,y:X.y*.85}))},className:"flex h-8 w-8 items-center justify-center rounded-full bg-white/10 text-white transition hover:bg-white/20 disabled:opacity-40","aria-label":"Zoom out",disabled:o<=Sv,children:t.jsx(W.ZoomOut,{className:"h-4 w-4"})}),t.jsxs("span",{className:"min-w-[3.25rem] text-center text-xs font-medium tabular-nums text-white",children:[M,"%"]}),t.jsx("button",{type:"button",onClick:F=>{F.stopPropagation(),l(X=>Math.min(u,X+m8))},className:"flex h-8 w-8 items-center justify-center rounded-full bg-white/10 text-white transition hover:bg-white/20 disabled:opacity-40","aria-label":"Zoom in",disabled:o>=u,children:t.jsx(W.ZoomIn,{className:"h-4 w-4"})}),t.jsx("button",{type:"button",onClick:F=>{F.stopPropagation(),w()},className:"flex h-8 w-8 items-center justify-center rounded-full bg-white/10 text-white transition hover:bg-white/20 disabled:opacity-40","aria-label":"Reset zoom",disabled:o===Sv,children:t.jsx(W.Maximize2,{className:"h-4 w-4"})})]}),t.jsx("div",{ref:g,className:"relative flex items-center justify-center overflow-hidden rounded-lg",style:{minHeight:240,touchAction:j?"none":"pan-y"},onWheel:P,onPointerDown:$,onPointerMove:R,onPointerUp:A,onPointerLeave:A,onPointerCancel:A,onTouchStart:E,onTouchMove:z,onTouchEnd:H,onTouchCancel:H,children:t.jsx("img",{ref:x,src:a,alt:"",draggable:!1,referrerPolicy:"no-referrer",className:"max-h-[80vh] max-w-full select-none object-contain",style:{transform:`translate3d(${f.x}px, ${f.y}px, 0) scale(${o})`,transformOrigin:"center center",transition:y.current||b.current?"none":"transform 120ms ease-out",cursor:j?y.current?"grabbing":"grab":"zoom-in"},onDoubleClick:D,onLoad:()=>requestAnimationFrame(v)})})]})},lP=({url:a,onOpen:o})=>{const l=mN(a);return l===null?t.jsx("div",{className:"flex h-full w-full items-center justify-center bg-[var(--hrk-bg-surface-sunken)]",children:t.jsx("div",{className:"h-6 w-6 animate-pulse rounded-full bg-[var(--hrk-bg-hover)]"})}):l==="video"?t.jsxs("button",{type:"button",onClick:o,className:"relative flex h-full w-full items-center justify-center overflow-hidden bg-black","aria-label":"Play video",children:[t.jsx("video",{src:a,preload:"metadata",muted:!0,playsInline:!0,className:"h-full w-full object-cover opacity-80"}),t.jsx("span",{className:"pointer-events-none absolute flex h-12 w-12 items-center justify-center rounded-full bg-black/70 text-white",children:t.jsx(W.Play,{className:"h-6 w-6"})})]}):t.jsx("button",{type:"button",onClick:o,className:"relative flex h-full w-full items-center justify-center overflow-hidden rounded-lg bg-[var(--hrk-bg-surface-sunken)]","aria-label":"Open image preview",children:t.jsx("img",{src:a,alt:"",loading:"lazy",className:"max-h-full max-w-full object-contain"})})},uP=({url:a})=>{const o=mN(a);return o==="video"?t.jsx("video",{src:a,controls:!0,autoPlay:!0,playsInline:!0,className:"max-h-[80vh] max-w-full"}):o==="image"||o===null?t.jsx(HT,{src:a}):t.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-[var(--hrk-brand)] underline",children:"Open in new tab"})},cP=({attachment:a,onClose:o,index:l,total:u,onPrev:d,onNext:f})=>{const m=typeof u=="number"&&u>1&&!!d&&!!f;T.useEffect(()=>{const b=v=>{v.key==="Escape"&&o(),v.key==="ArrowLeft"&&d&&d(),v.key==="ArrowRight"&&f&&f()};window.addEventListener("keydown",b);const w=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{window.removeEventListener("keydown",b),document.body.style.overflow=w}},[o,d,f]);const g=b=>b.stopPropagation(),x=b=>{b.stopPropagation(),o()},y=a.kind==="audio"||a.kind==="3speak-audio";return t.jsxs("div",{className:"fixed inset-0 z-[2000] flex flex-col bg-black/85 sm:items-center sm:justify-center sm:p-6",role:"dialog","aria-modal":"true",onClick:x,children:[t.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-2 bg-black/40 px-4 py-3 pt-[calc(env(safe-area-inset-top,0px)+1rem)] sm:hidden",onClick:g,children:[t.jsx("span",{className:"truncate text-sm font-medium text-white/80",children:h8(a)}),m&&t.jsxs("span",{className:"shrink-0 text-xs text-white/60 tabular-nums",children:[(l??0)+1," / ",u]})]}),t.jsx("button",{type:"button",onClick:x,className:"fixed right-3 top-[calc(env(safe-area-inset-top,0px)+1rem)] z-[2010] flex h-11 w-11 items-center justify-center rounded-full bg-black/80 text-white shadow-lg ring-1 ring-white/30 transition hover:bg-black sm:hidden","aria-label":"Close",children:t.jsx(W.X,{className:"h-5 w-5"})}),t.jsxs("div",{className:`flex min-h-0 flex-1 flex-col overflow-y-auto bg-[var(--hrk-bg-surface-sunken)] shadow-2xl sm:flex-initial sm:overflow-visible sm:rounded-2xl sm:border sm:border-[var(--hrk-border-default)] ${y?"sm:max-w-md":"sm:max-w-3xl"} sm:w-full`,onClick:g,children:[t.jsxs("div",{className:"hidden shrink-0 items-center justify-between border-b border-[var(--hrk-border-default)]/60 px-4 py-2.5 sm:flex",children:[t.jsxs("span",{className:"flex items-center gap-2 text-sm font-medium text-white/70",children:[t.jsx("span",{children:h8(a)}),m&&t.jsxs("span",{className:"text-xs text-white/50 tabular-nums",children:[(l??0)+1," / ",u]})]}),t.jsx("button",{type:"button",onClick:x,className:"flex h-8 w-8 items-center justify-center rounded-full bg-white/10 text-white transition hover:bg-white/20","aria-label":"Close",children:t.jsx(W.X,{className:"h-4 w-4"})})]}),t.jsxs("div",{className:"relative flex flex-1 flex-col items-center justify-center p-3 sm:p-4",children:[m&&t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:b=>{b.stopPropagation(),d?.()},className:"absolute left-2 top-1/2 z-20 flex h-10 w-10 -translate-y-1/2 items-center justify-center rounded-full bg-black/60 text-white shadow-lg transition hover:bg-black/80","aria-label":"Previous media",children:t.jsx(W.ChevronLeft,{className:"h-5 w-5"})}),t.jsx("button",{type:"button",onClick:b=>{b.stopPropagation(),f?.()},className:"absolute right-2 top-1/2 z-20 flex h-10 w-10 -translate-y-1/2 items-center justify-center rounded-full bg-black/60 text-white shadow-lg transition hover:bg-black/80","aria-label":"Next media",children:t.jsx(W.ChevronRight,{className:"h-5 w-5"})})]}),a.kind==="image"&&t.jsx(HT,{src:a.url}),a.kind==="ipfs"&&t.jsx(uP,{url:a.url}),a.kind==="youtube"&&t.jsxs("div",{className:"w-full",children:[t.jsx("div",{className:"w-full overflow-hidden rounded-lg",style:{aspectRatio:"16/9"},children:t.jsx("iframe",{src:`https://www.youtube-nocookie.com/embed/${a.id}?autoplay=1&rel=0&playsinline=1`,title:"YouTube",className:"h-full w-full border-0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})}),t.jsxs("a",{href:`https://www.youtube.com/watch?v=${a.id}`,target:"_blank",rel:"noopener noreferrer",className:"mt-3 inline-flex w-full items-center justify-center gap-2 rounded-lg bg-white/10 px-4 py-2.5 text-sm font-medium text-white/90 transition hover:bg-white/20",children:[t.jsx(W.Play,{className:"h-4 w-4 fill-current"}),"Watch on YouTube"]})]}),a.kind==="twitter"&&t.jsx("div",{className:"w-full",children:t.jsx(UT,{id:a.id})}),a.kind==="threespeak"&&(()=>{const b=BT(a.url);return b?t.jsx("div",{className:"w-full",children:t.jsx(iP,{author:b.author,permlink:b.permlink})}):t.jsx("a",{href:a.url,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-[var(--hrk-brand)] underline",children:"Open on 3Speak"})})(),a.kind==="audio"&&t.jsxs("div",{className:"w-full overflow-hidden rounded-xl border border-[var(--hrk-border-default)] bg-[#1a1d21] p-3",children:[t.jsxs("div",{className:"mb-2 flex items-center gap-2 text-sm text-[var(--hrk-text-tertiary)]",children:[t.jsx(W.Music,{className:"h-4 w-4 shrink-0 text-[var(--hrk-brand)]"}),t.jsx("span",{className:"truncate",children:decodeURIComponent(a.url.split("/").pop()?.split("?")[0]??"Audio")})]}),t.jsx("audio",{src:a.url,controls:!0,preload:"metadata",autoPlay:!0,className:"h-10 w-full"})]}),a.kind==="3speak-audio"&&t.jsx("div",{className:"w-full overflow-hidden rounded-xl border border-[var(--hrk-border-default)] bg-[#1a1d21]",children:t.jsx("iframe",{src:a.url,title:"3Speak audio",className:"h-24 w-full border-0",allow:"autoplay"})})]})]})]})},dP=({attachments:a})=>{const[o,l]=T.useState(0),[u,d]=T.useState(null),[f,m]=T.useState(0),[g,x]=T.useState(new Set),[y,b]=T.useState(!1),w=T.useRef(null);if(T.useEffect(()=>()=>{w.current&&clearTimeout(w.current)},[]),a.length===0)return null;const v=Math.min(o,a.length-1),j=a[v],M=()=>{b(!0),w.current&&clearTimeout(w.current),w.current=setTimeout(()=>b(!1),1200)},P=()=>{w.current&&(clearTimeout(w.current),w.current=null),b(!1)},D=()=>{M(),l(q=>(q+1)%a.length)},E=()=>{M(),l(q=>(q-1+a.length)%a.length)},z=(q,F)=>{q.stopPropagation();const X=a.indexOf(F);m(X>=0?X:0),d(F)},H=a.filter(q=>q.kind==="image"||q.kind==="ipfs"),$=()=>{H.length!==0&&m(q=>{const X=(Math.max(0,H.indexOf(a[q]))-1+H.length)%H.length,Y=H[X];return d(Y),a.indexOf(Y)})},R=()=>{H.length!==0&&m(q=>{const X=(Math.max(0,H.indexOf(a[q]))+1)%H.length,Y=H[X];return d(Y),a.indexOf(Y)})},A=()=>{if(j.kind==="ipfs")return t.jsx(lP,{url:j.url,onOpen:q=>z(q,j)});if(j.kind==="image")return g.has(v)?t.jsx("button",{type:"button",onClick:F=>F.stopPropagation(),className:"flex h-full w-full items-center justify-center bg-[var(--hrk-bg-app)] text-[var(--hrk-text-tertiary)]",children:t.jsx(W.ImageOff,{className:"h-6 w-6"})}):t.jsx("button",{type:"button",onClick:F=>z(F,j),className:"relative flex h-full w-full items-center justify-center overflow-hidden rounded-lg bg-[var(--hrk-bg-surface-sunken)]","aria-label":"Open image preview",children:t.jsx("img",{ref:F=>{F&&F.complete&&P()},src:j.url,alt:"",loading:"lazy",className:"max-h-full max-w-full object-contain",onLoad:P,onError:()=>{P(),x(F=>new Set(F).add(v))}},v)});if(j.kind==="youtube")return t.jsx("div",{className:"flex h-full w-full items-center justify-center bg-black",onClick:q=>q.stopPropagation(),children:t.jsx("iframe",{src:`https://www.youtube-nocookie.com/embed/${j.id}?rel=0&playsinline=1`,title:"YouTube",className:"border-0",style:{aspectRatio:"16/9",height:"100%",maxHeight:"100%",maxWidth:"100%"},allow:"accelerometer; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})});if(j.kind==="threespeak"){const q=BT(j.url);return t.jsx("div",{className:"three-speak-snap-strip flex h-full w-full items-center justify-center overflow-hidden bg-black",onClick:F=>F.stopPropagation(),children:q?t.jsx(fm,{author:q.author,permlink:q.permlink,hideThumbnail:!0}):t.jsx("a",{href:j.url,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-[var(--hrk-brand)] underline",onClick:F=>F.stopPropagation(),children:"Open on 3Speak"})})}return j.kind==="twitter"?t.jsx("div",{className:"h-full w-full overflow-y-auto bg-[var(--hrk-bg-surface-sunken)]",onClick:q=>q.stopPropagation(),children:t.jsx(UT,{id:j.id})}):j.kind==="3speak-audio"?t.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-3 bg-gradient-to-br from-violet-900/40 to-violet-950/60 px-4",onClick:q=>q.stopPropagation(),children:[t.jsxs("div",{className:"flex items-center gap-2 text-xs text-white/70",children:[t.jsx(W.Music,{className:"h-4 w-4 shrink-0 text-[var(--hrk-brand)]"}),t.jsx("span",{className:"font-medium",children:"3Speak audio"})]}),t.jsx("iframe",{src:j.url,title:"3Speak audio",className:"h-24 w-full max-w-md border-0",allow:"autoplay"})]}):t.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-3 bg-gradient-to-br from-emerald-900/40 to-emerald-950/60 px-4",onClick:q=>q.stopPropagation(),children:[t.jsxs("div",{className:"flex items-center gap-2 text-xs text-white/70",children:[t.jsx(W.Music,{className:"h-4 w-4 shrink-0 text-[var(--hrk-brand)]"}),t.jsx("span",{className:"max-w-[260px] truncate font-medium",children:decodeURIComponent(j.url.split("/").pop()?.split("?")[0]??"Audio")})]}),t.jsx("audio",{src:j.url,controls:!0,preload:"metadata",className:"h-10 w-full max-w-md"})]})};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative overflow-hidden rounded-lg border border-[var(--hrk-border-default)] bg-[var(--hrk-bg-app)]",children:[t.jsx("div",{className:"h-[280px] w-full",children:A()}),y&&t.jsx("div",{className:"pointer-events-none absolute inset-0 z-20 flex items-center justify-center bg-black/40",children:t.jsx(W.Loader2,{className:"h-7 w-7 animate-spin text-white"})}),a.length>1&&t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:q=>{q.stopPropagation(),E()},className:"absolute left-2 top-1/2 z-30 -translate-y-1/2 rounded-full bg-black/60 p-1.5 text-white hover:bg-black/80","aria-label":"Previous",children:t.jsx(W.ChevronLeft,{className:"h-4 w-4"})}),t.jsx("button",{type:"button",onClick:q=>{q.stopPropagation(),D()},className:"absolute right-2 top-1/2 z-30 -translate-y-1/2 rounded-full bg-black/60 p-1.5 text-white hover:bg-black/80","aria-label":"Next",children:t.jsx(W.ChevronRight,{className:"h-4 w-4"})}),t.jsxs("div",{className:"absolute bottom-2 right-2 z-30 rounded-full bg-black/60 px-2 py-0.5 text-[10px] text-white",children:[v+1," / ",a.length]})]})]}),u&&t.jsx(cP,{attachment:u,index:Math.max(0,H.indexOf(u)),total:H.length,onPrev:$,onNext:R,onClose:()=>d(null)})]})},$T=({post:a,currentUser:o,onUpvote:l,onSubmitComment:u,onClickCommentUpvote:d,onReblog:f,onReSnap:m,onTip:g,onSharePost:x,onCommentClick:y,onClickCommentIcon:b,onClickCommentCount:w,onReportPost:v,onToggleBookmark:j,isPostBookmarked:M,onDeletePost:P,onEditSnap:D,onVotePoll:E,onUserClick:z,onPostClick:H,onTagClick:$,getPostUrl:R,getUserUrl:A,getTagUrl:q,getCommunityUrl:F,ecencyToken:X,threeSpeakApiKey:Y,giphyApiKey:Z,templateToken:J,templateApiBaseUrl:re,defaultVotePercent:ce,voteWeightStep:le,allowLandscapeVideos:G,awaitingWalletApproval:K,defaultReward:ee,renderHeaderActions:ye,actionsAsMenu:we})=>{const Me=T.useMemo(()=>aP(a),[a.body,a.json_metadata]),Ue=T.useMemo(()=>rP(a.body??""),[a.body]),se=T.useMemo(()=>eP(a),[a.json_metadata]),be=T.useMemo(()=>tP(a),[a.json_metadata]);T.useEffect(()=>{},[a.author,a.permlink]);const xe=T.useMemo(()=>{try{return xm({baseUrl:"https://peakd.com/",ipfsGateway:"https://ipfs.3speak.tv",assetsWidth:640,assetsHeight:480,usertagUrlFn:ge=>`https://peakd.com/@${ge}`,hashtagUrlFn:ge=>`https://peakd.com/created/${ge}`,convertHiveUrls:!0})}catch{return null}},[]),Ae=T.useMemo(()=>{const ge=a.body??"";if(!ge||!xe)return"";let me=ge;if(me=PT(me),me=me.replace(/\r\n/g,`
|
|
1164
1164
|
`),me=me.replace(/<br\s*\/?>\s*\n?/gi,`
|
|
1165
1165
|
`),me=me.replace(/(?:^|\n)\s*(?:#[\p{L}\p{N}_-]+(?:\s*,?\s*)){1,}$/u,""),me=me.replace(/([^\n|])\n(\|)/g,`$1
|
|
1166
1166
|
|