ghost 6.19.0 → 6.19.1

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.
Files changed (119) hide show
  1. package/components/tryghost-i18n-6.19.1.tgz +0 -0
  2. package/components/{tryghost-parse-email-address-6.19.0.tgz → tryghost-parse-email-address-6.19.1.tgz} +0 -0
  3. package/core/built/admin/assets/{PolarAngleAxis-CGprvq8M.js → PolarAngleAxis-BzbazaED.js} +1 -1
  4. package/core/built/admin/assets/{_baseAssignValue-Bwn07Ln5.js → _baseAssignValue-D0bBhNG1.js} +1 -1
  5. package/core/built/admin/assets/{a-large-small-p58xibEK.js → a-large-small-gBDqOWOy.js} +1 -1
  6. package/core/built/admin/assets/{at-sign-BZPuAx5m.js → at-sign-V79EBNTJ.js} +1 -1
  7. package/core/built/admin/assets/{audience-Cy9gLIa9.js → audience-DF--nR_q.js} +1 -1
  8. package/core/built/admin/assets/{avatar-flipboard-CLmWb5Xn.js → avatar-flipboard-GK39JNWl.js} +1 -1
  9. package/core/built/admin/assets/{bluesky-sharing-BHt0oiii.js → bluesky-sharing-BKRqTAow.js} +1 -1
  10. package/core/built/admin/assets/{chart--RFLGIL4.js → chart-0ezwQhyB.js} +1 -1
  11. package/core/built/admin/assets/{chunk.524.5c5c3f3273a86d1d9913.js → chunk.524.e62f8276cc561fcddb66.js} +6 -6
  12. package/core/built/admin/assets/{chunk.582.e6c787cdf7e6de7819e0.js → chunk.582.0cdc35e120cf621f18b9.js} +8 -8
  13. package/core/built/admin/assets/{code-editor-view-BW9y0JXN.js → code-editor-view-xVA7A1IE.js} +1 -1
  14. package/core/built/admin/assets/{comments-C_lilDBp.js → comments-Tt1iOjcd.js} +1 -1
  15. package/core/built/admin/assets/{content-helpers-BOnQQADZ.js → content-helpers-TSHyiXwF.js} +1 -1
  16. package/core/built/admin/assets/{copy-Bi7VpgPR.js → copy-CTHgI4YI.js} +1 -1
  17. package/core/built/admin/assets/{data-list-Bu3jzs1s.js → data-list-6rXP5AUF.js} +1 -1
  18. package/core/built/admin/assets/{deleted-feed-item-B-doIIKc.js → deleted-feed-item-CK_4qToF.js} +1 -1
  19. package/core/built/admin/assets/{edit-profile-ZBdjFfvL.js → edit-profile-B_ViIhsd.js} +1 -1
  20. package/core/built/admin/assets/{empty-indicator-C6BBh99D.js → empty-indicator-CzTRebSi.js} +1 -1
  21. package/core/built/admin/assets/{en-C7eSFQRw.js → en-D1H4BpXe.js} +1 -1
  22. package/core/built/admin/assets/{feed-CAioauwD.js → feed-0iLmr_Xb.js} +1 -1
  23. package/core/built/admin/assets/{filters-DEKF0tIB.js → filters-6zg35bLL.js} +1 -1
  24. package/core/built/admin/assets/{gh-chart-D9KI0_sO.js → gh-chart-ldqA2tQU.js} +1 -1
  25. package/core/built/admin/assets/{ghost-6bff5c535ef015b0ed9421ceb6c699a7.js → ghost-6b109ed708c502afee4ff1d9185ae40c.js} +256 -268
  26. package/core/built/admin/assets/ghost-b3dff8469d9c9af487866537210234bd.css +1 -0
  27. package/core/built/admin/assets/ghost-dark-16a7b98c352c1f70016e73af10962179.css +1 -0
  28. package/core/built/admin/assets/{growth-C6XGchvT.js → growth-BUQvBEMA.js} +1 -1
  29. package/core/built/admin/assets/{hash-DFhnGHId.js → hash-CRtHv162.js} +1 -1
  30. package/core/built/admin/assets/{inbox-p-Y5uScT.js → inbox-DWYGFLuU.js} +1 -1
  31. package/core/built/admin/assets/{index-CIZ_upe2.js → index-1J5JrBgd.js} +1 -1
  32. package/core/built/admin/assets/{index-CS4XqyC-.js → index-BFT8PQPd.js} +1 -1
  33. package/core/built/admin/assets/{index-BWnrLoWI.js → index-BeG1PnbN.js} +1 -1
  34. package/core/built/admin/assets/{index-DCTdAEHx.js → index-Bgo4hw-T.js} +3 -3
  35. package/core/built/admin/assets/{index-jAidr8jI.js → index-CCmy-hD6.js} +1 -1
  36. package/core/built/admin/assets/index-CKfif8kf.js +13 -0
  37. package/core/built/admin/assets/{index-FPf-AERu.js → index-Cc9yKRsT.js} +1 -1
  38. package/core/built/admin/assets/{index-3uU4zg_6.js → index-CvV71sVO.js} +1 -1
  39. package/core/built/admin/assets/{index-LyfDjTto.js → index-D0RISNEd.js} +1 -1
  40. package/core/built/admin/assets/{index-JmqyGBro.js → index-D1AppGlg.js} +1 -1
  41. package/core/built/admin/assets/{index-D17PEsUB.js → index-EFWmaChO.js} +1 -1
  42. package/core/built/admin/assets/{index-Wx8_AGZX.js → index-SulwGym9.js} +1 -1
  43. package/core/built/admin/assets/{index-lPLmWtv0.js → index-_dLVP2u2.js} +1 -1
  44. package/core/built/admin/assets/{index-BzU2odQq.js → index-nb8rSrz_.js} +1 -1
  45. package/core/built/admin/assets/{index--VlvGKWi.js → index-zvNmrx86.js} +1 -1
  46. package/core/built/admin/assets/{koenig-lexical-CWnkYKQt.js → koenig-lexical-D8K6acyr.js} +1 -1
  47. package/core/built/admin/assets/{kpi-card-B5UaJgOT.js → kpi-card-CaX6eHyr.js} +1 -1
  48. package/core/built/admin/assets/{kpis-Cc2RxnvZ.js → kpis-BfR_uoFr.js} +1 -1
  49. package/core/built/admin/assets/{label-CW7Kmp9w.js → label-BQ5mfFHN.js} +1 -1
  50. package/core/built/admin/assets/{links-wWNc9Uat.js → links-lZnz9cuZ.js} +1 -1
  51. package/core/built/admin/assets/{list-filter-3EF6cVg-.js → list-filter-CofVbkA4.js} +1 -1
  52. package/core/built/admin/assets/{lucide-react-DtMIZssr.js → lucide-react-7D_Tsesk.js} +1 -1
  53. package/core/built/admin/assets/{main-layout-BFYhCrLn.js → main-layout-DBVy-lM5.js} +1 -1
  54. package/core/built/admin/assets/{message-square-text-BDZtUW-2.js → message-square-text-DzuHB7uU.js} +1 -1
  55. package/core/built/admin/assets/{minus-CSphShdJ.js → minus-BIdO1CDG.js} +1 -1
  56. package/core/built/admin/assets/{modals-CDWP04Iy.js → modals-GY5yP0Bl.js} +1 -1
  57. package/core/built/admin/assets/{moderation-qcng2_lB.js → moderation-CB9TwdgZ.js} +1 -1
  58. package/core/built/admin/assets/{newsletter-R-IYcV4M.js → newsletter-Bww4nkp5.js} +1 -1
  59. package/core/built/admin/assets/{newsletters-BB4e24i1.js → newsletters-C8pT7kSQ.js} +1 -1
  60. package/core/built/admin/assets/{note-B_bpRX66.js → note-BeCIv25U.js} +1 -1
  61. package/core/built/admin/assets/{overview-Nh-IoP-v.js → overview-BCZDRsR0.js} +1 -1
  62. package/core/built/admin/assets/{pagemenu-Cd45frnF.js → pagemenu-D3ByoZIR.js} +1 -1
  63. package/core/built/admin/assets/{post-analytics-jHZOhQ8L.js → post-analytics-B4z47Loe.js} +1 -1
  64. package/core/built/admin/assets/{post-analytics-context-BST4bzps.js → post-analytics-context-BQ8IcW4n.js} +1 -1
  65. package/core/built/admin/assets/{post-analytics-header-DAZPp6M8.js → post-analytics-header-CpBVLNat.js} +1 -1
  66. package/core/built/admin/assets/{post-share-modal-D1JQfuYx.js → post-share-modal-Dz4BNSV-.js} +1 -1
  67. package/core/built/admin/assets/{posts-DFiJPOft.js → posts-C94RiQ4S.js} +1 -1
  68. package/core/built/admin/assets/{repeat-Smml9n0k.js → repeat-YTCeIlQZ.js} +1 -1
  69. package/core/built/admin/assets/{reply-CooY4lmk.js → reply-CUazFbTY.js} +1 -1
  70. package/core/built/admin/assets/{select-WwMsbBbg.js → select-MVpx-Kfp.js} +1 -1
  71. package/core/built/admin/assets/{settings-CQEhPDQU.js → settings-CEfmF6wO.js} +4 -4
  72. package/core/built/admin/assets/{settings-CxWtvcUf.js → settings-Q3y0Zw5o.js} +1 -1
  73. package/core/built/admin/assets/{sort-button-DFr8vezl.js → sort-button-CEXkgGLb.js} +1 -1
  74. package/core/built/admin/assets/{source-icon-VpYWpwYb.js → source-icon-BDparw9V.js} +1 -1
  75. package/core/built/admin/assets/{sprout-DRqlFJSK.js → sprout-CXg43Zav.js} +1 -1
  76. package/core/built/admin/assets/{square-CwHQ9sJ2.js → square-C8G-1gV_.js} +1 -1
  77. package/core/built/admin/assets/stats/{audience-Caf7BjaU.mjs → audience-DJv-je5C.mjs} +3 -3
  78. package/core/built/admin/assets/stats/{content-helpers-MbtAvUJh.mjs → content-helpers-Bq8zgCUT.mjs} +4 -4
  79. package/core/built/admin/assets/stats/{index-DMkZbbZs.mjs → index-B12PHa64.mjs} +8 -8
  80. package/core/built/admin/assets/stats/{index-wT0OIw_N.mjs → index-DRN41f8l.mjs} +5 -5
  81. package/core/built/admin/assets/stats/{index-ChjIxhHy.mjs → index-DwqY9qrn.mjs} +5 -5
  82. package/core/built/admin/assets/stats/{index-BGqKbF1D.mjs → index-GLg_cfiu.mjs} +464 -461
  83. package/core/built/admin/assets/stats/{index-BTjfXOi6.mjs → index-gS3EAScL.mjs} +5 -5
  84. package/core/built/admin/assets/stats/{sort-button-B8n8fYMi.mjs → sort-button-f_Dfri5f.mjs} +8 -8
  85. package/core/built/admin/assets/stats/{stats-CGH-0JNs.mjs → stats-CTWb7qo1.mjs} +96 -91
  86. package/core/built/admin/assets/stats/stats.js +1 -1
  87. package/core/built/admin/assets/stats/{tabs-EQCUj3Y9.mjs → tabs-DVvxZ7wa.mjs} +7 -7
  88. package/core/built/admin/assets/stats/{use-growth-stats--CIfag21.mjs → use-growth-stats-w7-2bD-r.mjs} +3 -3
  89. package/core/built/admin/assets/{stats-lnFiOQZx.js → stats-B2vPCVx7.js} +1 -1
  90. package/core/built/admin/assets/stats-view-BRy4IDHe.js +1 -0
  91. package/core/built/admin/assets/{step-1-Bx8MiQVF.js → step-1-MLqNxHrJ.js} +1 -1
  92. package/core/built/admin/assets/{step-2-CLLXppER.js → step-2-DY3jIa6G.js} +1 -1
  93. package/core/built/admin/assets/{step-3-C5WrQe8u.js → step-3-Dt6w5-MB.js} +1 -1
  94. package/core/built/admin/assets/{table-2waWpIF5.js → table-BWAnP2ln.js} +1 -1
  95. package/core/built/admin/assets/{tabs-CBD0hW8V.js → tabs-Bw13eFRh.js} +1 -1
  96. package/core/built/admin/assets/{tags-CKrBptuC.js → tags-BQz2NtFF.js} +1 -1
  97. package/core/built/admin/assets/{tags-Bgw5Hrb5.js → tags-Bj9RJW9l.js} +1 -1
  98. package/core/built/admin/assets/{tiers-CO-pz1FX.js → tiers-jCNws2RK.js} +1 -1
  99. package/core/built/admin/assets/{toggle-group-BXAZzvJ9.js → toggle-group-B0wGpmLS.js} +1 -1
  100. package/core/built/admin/assets/{topic-filter-U3qUH2P_.js → topic-filter-BPOZf5IO.js} +1 -1
  101. package/core/built/admin/assets/{trash-CJY1Wro_.js → trash-BKeiM6WP.js} +1 -1
  102. package/core/built/admin/assets/{use-growth-stats-BrLZI7da.js → use-growth-stats-C5TiRW1S.js} +1 -1
  103. package/core/built/admin/assets/{use-infinite-virtual-scroll-CiRn3kpz.js → use-infinite-virtual-scroll-CdNJ5RT5.js} +1 -1
  104. package/core/built/admin/assets/{use-simple-pagination-CskJ0MDP.js → use-simple-pagination-CCVB_aJH.js} +1 -1
  105. package/core/built/admin/assets/{user-round-check-zOuzV3OS.js → user-round-check-Df7ko4Tm.js} +1 -1
  106. package/core/built/admin/assets/{wallet-cards-ddLuIN-b.js → wallet-cards-Cl4bJBBw.js} +1 -1
  107. package/core/built/admin/assets/{web-CGbkZWn3.js → web-DxLX2yUi.js} +1 -1
  108. package/core/built/admin/index.html +5 -5
  109. package/core/frontend/helpers/get.js +51 -3
  110. package/core/server/api/endpoints/utils/serializers/input/utils/slug-filter-order.js +8 -5
  111. package/core/server/models/base/plugins/crud.js +6 -1
  112. package/core/server/services/email-suppression-list/email-suppression-list.js +1 -1
  113. package/package.json +16 -10
  114. package/yarn.lock +128 -181
  115. package/components/tryghost-i18n-6.19.0.tgz +0 -0
  116. package/core/built/admin/assets/ghost-3c48d37b32f4fcd7eb15cfd739905a03.css +0 -1
  117. package/core/built/admin/assets/ghost-dark-0100fe3ec7b4c3f6d8d043c904254a63.css +0 -1
  118. package/core/built/admin/assets/index-S62-c8TV.js +0 -13
  119. package/core/built/admin/assets/stats-view-BJVawuIv.js +0 -1
@@ -1 +1 @@
1
- import{j as t,bn as F,e as u,b as g,bo as T,r as j,bj as z,bk as E,L as S,E as M,c as P,bp as U,S as w,A as $,B as L,bb as B,n as C,h as v,d as W,s as _,bq as D,br as H,f as O,P as q}from"./index-DCTdAEHx.js";import{A as V}from"./at-sign-BZPuAx5m.js";import{R as G,U as K}from"./user-round-check-zOuzV3OS.js";import{R as Q}from"./reply-CooY4lmk.js";const I=({notificationType:a,size:l="lg",className:i})=>{let r,s="";const n="white",c=l==="sm"?13:20,o=l==="sm"?2:1.5;switch(a){case"follow":r=t.jsx(K,{className:`-mr-0.5 -mt-0.5 ${l==="sm"&&"size-[11px]"}`,color:n,size:c,strokeWidth:o}),s="bg-blue-600";break;case"like":r=t.jsx(F,{className:`${l==="sm"?"size-[11px]":"mt-px size-5"}`,color:n,strokeWidth:o}),s="bg-pink-600";break;case"reply":r=t.jsx(Q,{className:"mb-px mr-px",color:n,size:c,strokeWidth:o}),s="bg-purple-600";break;case"repost":r=t.jsx(G,{color:n,size:c,strokeWidth:o}),s="bg-green-500";break;case"mention":r=t.jsx(V,{className:`${l==="sm"?"size-[12px]":"size-5"}`,color:n,size:c,strokeWidth:o}),s="bg-orange-500";break}return t.jsx("div",{className:`flex ${l==="sm"?"size-5":"size-9"} items-center justify-center rounded-full ${s} ${i&&i}`,children:r})},Z=u.createContext(void 0),h=({isGrouped:a,centerAlign:l,children:i,onClick:r,url:s,className:n})=>t.jsx(Z.Provider,{value:{onClick:r,url:s},children:t.jsx("div",{className:`group relative -mx-4 -my-px ${a?"grid":"flex"} ${l?"items-center":"items-start"} cursor-pointer grid-cols-[auto_1fr] gap-x-4 gap-y-2.5 rounded-lg px-4 py-5 text-left break-anywhere hover:bg-gray-75 ${n}`,role:"button",onClick:r,children:i})}),J=({size:a="lg",type:l})=>t.jsx("div",{className:"col-start-1 row-start-1",children:t.jsx(I,{notificationType:l,size:a})}),X=({children:a})=>t.jsx("div",{className:"col-start-2 row-start-1 flex gap-2",children:a}),Y=({children:a})=>t.jsx("div",{className:"col-start-2 row-start-2 -mt-0.5 grow overflow-hidden",children:a});h.Icon=J;h.Avatars=X;h.Content=Y;const ee=()=>t.jsx("div",{className:"h-px w-full bg-gray-150 dark:bg-gray-950"});function te(a){const r=new Date(a).getTime();return(Math.floor(r/864e5)*864e5).toString()}function se(a){const l={};let i=null,r=0;return a.forEach(s=>{s.type!==i&&(r+=1,i=s.type);let n="";const c=`_${te(s.createdAt)}`,o=`_seq${r}`;switch(s.type){case"like":s.post?.id&&(n=`like_${s.post.id}${c}${o}`);break;case"reply":n=`reply_${s.id}`;break;case"repost":s.post?.id&&(n=`repost_${s.post.id}${c}${o}`);break;case"follow":n=`follow_${c}${o}`;break;case"mention":n=`mention_${s.id}`;break}l[n]||(l[n]={id:s.id,type:s.type,actors:[],post:s.post,inReplyTo:s.inReplyTo,createdAt:s.createdAt}),l[n].actors.find(f=>f.id===s.actor.id)||l[n].actors.push(s.actor)}),Object.values(l)}const ae=({group:a})=>{const[l,...i]=a.actors,r=i.length>0,s="cursor-pointer font-semibold hover:underline text-black dark:text-white",n=g(),c=t.jsxs(t.Fragment,{children:[t.jsx(q,{actor:l,align:"center",isCurrentUser:!1,children:t.jsx("span",{className:s,onClick:o=>{o?.stopPropagation(),v(l.handle,n)},children:l.name})}),r&&` and ${i.length} ${i.length>1?"others":"other"}`]});switch(a.type){case"follow":return t.jsxs(t.Fragment,{children:[c," followed you"]});case"like":return t.jsxs(t.Fragment,{children:[c," liked your ",a.post?.type==="article"?"post":"note"]});case"repost":return t.jsxs(t.Fragment,{children:[c," reposted your ",a.post?.type==="article"?"post":"note"]});case"reply":if(a.inReplyTo&&typeof a.inReplyTo!="string")return c;break;case"mention":return c}return t.jsx(t.Fragment,{})},ne=({content:a,className:l,stripTags:i=[]})=>{const r=j.useRef(null),s=g();return j.useEffect(()=>{const n=r.current;if(!n)return;const c=o=>{const y=o.target.closest("a[data-profile]");if(y){const x=y.getAttribute("data-profile")?.trim();/^@([\w.-]+)@([\w-]+\.[\w.-]+[a-zA-Z])$/.test(x||"")&&x&&(o.preventDefault(),o.stopPropagation(),v(x,s))}};return n.addEventListener("click",c),()=>{n.removeEventListener("click",c)}},[s,a]),t.jsx("div",{dangerouslySetInnerHTML:{__html:_(a||"",i)},ref:r,className:l})},ce=()=>{const[a,l]=u.useState({}),i=g(),r=e=>{l(d=>({...d,[e]:!d[e]}))},s=()=>{},n=5,{data:c,error:o,fetchNextPage:f,hasNextPage:y,isFetchingNextPage:x,isLoading:b}=T("index"),k=c?.pages.flatMap(e=>se(e.notifications))??Array(10).fill({actors:[{}]}),p=j.useRef(null),N=j.useRef(null);j.useEffect(()=>(p.current&&p.current.disconnect(),p.current=new IntersectionObserver(e=>{e[0].isIntersecting&&y&&!x&&f()}),N.current&&p.current.observe(N.current),()=>{p.current&&p.current.disconnect()}),[y,x,f]);const R=(e,d)=>{switch(e.type){case"like":e.post&&i(`/${e.post.type==="article"?"reader":"notes"}/${encodeURIComponent(e.post.id)}`);break;case"reply":e.post&&e.inReplyTo&&i(`/notes/${encodeURIComponent(e.post.id)}`);break;case"repost":e.post&&i(`/${e.post.type==="article"?"reader":"notes"}/${encodeURIComponent(e.post.id)}`);break;case"follow":e.actors.length>1?r(e.id||`${e.type}_${d}`):v(e.actors[0].handle,i);break;case"mention":e.post&&i(`/notes/${encodeURIComponent(e.post.id)}`);break}};return o&&z(o)?t.jsx(E,{errorCode:o.code,statusCode:o.statusCode}):t.jsx(S,{children:t.jsxs("div",{className:"z-0 flex w-full flex-col items-center",children:[b===!1&&k.length===0&&t.jsxs(M,{children:[t.jsx(P,{children:t.jsx(U,{})}),"Quiet for now, but not for long! When someone likes, boosts, or replies to you, you'll find it here."]}),k.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"my-8 flex w-full max-w-[620px] flex-col max-md:mt-5",children:k.map((e,d)=>t.jsxs(u.Fragment,{children:[t.jsxs(h,{centerAlign:e.actors.length<2&&e.type==="follow",className:"hover:bg-gray-75 dark:hover:bg-gray-950",isGrouped:e.actors.length>1,onClick:()=>R(e,d),children:[b?t.jsx(w,{className:"rounded-full",containerClassName:"flex h-10 w-10"}):e.actors.length>1?t.jsx(h.Icon,{type:e.type}):t.jsxs("div",{className:"relative",children:[t.jsx($,{author:{icon:{url:e.actors[0].avatarUrl||""},name:e.actors[0].name,handle:e.actors[0].handle},size:"notification"},e.actors[0].id),t.jsx(I,{className:"absolute -bottom-1 -right-1 z-10 border-2 border-white dark:border-black",notificationType:e.type,size:"sm"})]}),e.actors.length>1&&t.jsx(h.Avatars,{children:t.jsxs("div",{className:"flex w-full flex-col",children:[t.jsxs("div",{className:"relative flex items-center pl-2",children:[!a[e.id||`${e.type}_${d}`]&&e.actors.slice(0,n).map(m=>t.jsx($,{author:{icon:{url:m.avatarUrl||""},name:m.name,handle:m.handle},className:"-ml-2 !bg-[#F3F3F3] outline outline-2 outline-white group-hover:!bg-[#EDEEF0] group-hover:outline-gray-75 dark:outline-black group-hover:dark:outline-gray-950",size:"notification"},m.id)),e.actors.length>n&&!a[e.id||`${e.type}_${d}`]&&t.jsx("div",{className:"absolute right-[28px] z-10 flex size-9 items-center justify-center rounded-full bg-black/50 text-base font-semibold tracking-tightest text-white",children:`+${e.actors.length-n}`}),e.actors.length>1&&t.jsxs(L,{className:`group flex items-center gap-0.5 text-gray-700 hover:bg-transparent hover:text-black dark:text-gray-600 dark:hover:text-white ${a[e.id||`${e.type}_${d}`]?"ml-[-20px]":"ml-0 w-[28px]"}`,variant:"ghost",onClick:m=>{m?.stopPropagation(),r(e.id||`${e.type}_${d}`)},children:[t.jsx(B,{className:`${a[e.id||`${e.type}_${d}`]?"rotate-180":""}`,size:20,strokeWidth:1.5}),a[e.id||`${e.type}_${d}`]?"Hide":t.jsx("span",{className:"sr-only",children:"Show all"})]})]}),t.jsx("div",{className:`overflow-hidden transition-all duration-300 ease-in-out ${a[e.id||`${e.type}_${d}`]?"mb-2 max-h-[1384px] opacity-100":"max-h-0 opacity-0"}`,children:a[e.id||`${e.type}_${d}`]&&e.actors.length>1&&t.jsx("div",{className:"flex flex-col gap-2 pt-2",children:e.actors.map(m=>t.jsxs("div",{className:"group/item flex items-center justify-between gap-4 break-anywhere",onClick:A=>{A?.stopPropagation(),v(m.handle,i)},children:[t.jsxs("div",{className:"flex min-w-0 items-center",children:[t.jsx($,{author:{icon:{url:m.avatarUrl||""},name:m.name,handle:m.handle},size:"xs"}),t.jsx("span",{className:"ml-2 line-clamp-1 text-base font-semibold group-hover/item:underline dark:text-white",children:m.name}),t.jsx("span",{className:"ml-1 line-clamp-1 text-base text-gray-700 dark:text-gray-600",children:m.handle})]}),e.type==="follow"&&!m.followedByMe&&t.jsx(C,{following:!1,handle:m.handle,variant:"link"})]},m.id))})})]})}),t.jsxs(h.Content,{children:[t.jsx("div",{children:b?t.jsxs(t.Fragment,{children:[t.jsx(w,{}),t.jsx(w,{className:"w-full max-w-60"})]}):t.jsxs("div",{className:"flex justify-between",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"truncate",children:t.jsx(ae,{group:e})}),e.actors.length<2&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"mt-px text-[8px] text-gray-700 dark:text-gray-600",children:"•"}),t.jsx("span",{className:"mt-0.5 text-sm text-gray-700 dark:text-gray-600",children:W(e,!1)})]})]}),e.actors.length===1&&(e.type==="follow"||e.type==="reply"||e.type==="mention")&&!e.actors[0].followedByMe&&t.jsx(C,{following:!1,handle:e.actors[0].handle,variant:"link"})]})}),(e.type==="reply"&&e.inReplyTo||e.type==="mention"||e.type==="like"&&!e.post?.name&&e.post?.content||e.type==="repost"&&!e.post?.name&&e.post?.content)&&(e.type!=="reply"&&e.type!=="mention"?t.jsxs("div",{className:"ap-note-content mt-0.5 line-clamp-1 text-pretty text-sm text-gray-700 dark:text-gray-600",children:[e.post?.type==="article"&&e.post?.title&&t.jsxs(t.Fragment,{children:[e.post.title," — "]}),t.jsx("span",{dangerouslySetInnerHTML:{__html:_(e.post?.content||"")}})]}):t.jsx(t.Fragment,{children:t.jsxs("div",{className:"mt-2.5 rounded-md bg-gray-100 px-5 py-[14px] group-hover:bg-gray-200 dark:bg-gray-925/30 group-hover:dark:bg-black/40",children:[t.jsx(ne,{className:"ap-note-content text-pretty",content:e.post?.content||"",stripTags:["a"]}),e.post&&e.post.attachments&&e.post.attachments.length>0&&t.jsx("div",{className:"notification-attachments mb-1 [&_.attachment-gallery]:flex [&_.attachment-gallery]:flex-wrap [&_img]:aspect-square [&_img]:max-w-[calc(20%-6.4px)]",children:D({...e.post,type:"Note",attachment:e.post.attachments})})]})})),(e.type==="reply"&&e.post||e.type==="mention")&&t.jsx("div",{className:"mt-1.5",children:t.jsx(H,{actor:{...e.actors[0],icon:{url:e.actors[0].avatarUrl||""},id:e.actors[0].url,preferredUsername:e.actors[0].handle?.replace(/^@([^@]+)@.*$/,"$1")||"unknown"},buttonClassName:"hover:bg-gray-200",commentCount:e.post.replyCount||0,layout:"notification",likeCount:e.post.likeCount||0,object:{...e.post,liked:e.post.likedByMe,reposted:e.post.repostedByMe},repostCount:e.post.repostCount||0,onLikeClick:s})})]})]}),d<k.length-1&&t.jsx("div",{className:"pl-[52px]",children:t.jsx(ee,{})})]},e.id||`${e.type}_${d}`))}),t.jsx("div",{ref:N,className:"h-1"}),x&&t.jsx("div",{className:"-mt-4 mb-8 flex flex-col items-center justify-center space-y-4 text-center",children:t.jsx(O,{size:"md"})})]})]})})};export{ce as default};
1
+ import{j as t,bn as F,e as u,b as g,bo as T,r as j,bj as z,bk as E,L as S,E as M,c as P,bp as U,S as w,A as $,B as L,bb as B,n as C,h as v,d as W,s as _,bq as D,br as H,f as O,P as q}from"./index-Bgo4hw-T.js";import{A as V}from"./at-sign-V79EBNTJ.js";import{R as G,U as K}from"./user-round-check-Df7ko4Tm.js";import{R as Q}from"./reply-CUazFbTY.js";const I=({notificationType:a,size:l="lg",className:i})=>{let r,s="";const n="white",c=l==="sm"?13:20,o=l==="sm"?2:1.5;switch(a){case"follow":r=t.jsx(K,{className:`-mr-0.5 -mt-0.5 ${l==="sm"&&"size-[11px]"}`,color:n,size:c,strokeWidth:o}),s="bg-blue-600";break;case"like":r=t.jsx(F,{className:`${l==="sm"?"size-[11px]":"mt-px size-5"}`,color:n,strokeWidth:o}),s="bg-pink-600";break;case"reply":r=t.jsx(Q,{className:"mb-px mr-px",color:n,size:c,strokeWidth:o}),s="bg-purple-600";break;case"repost":r=t.jsx(G,{color:n,size:c,strokeWidth:o}),s="bg-green-500";break;case"mention":r=t.jsx(V,{className:`${l==="sm"?"size-[12px]":"size-5"}`,color:n,size:c,strokeWidth:o}),s="bg-orange-500";break}return t.jsx("div",{className:`flex ${l==="sm"?"size-5":"size-9"} items-center justify-center rounded-full ${s} ${i&&i}`,children:r})},Z=u.createContext(void 0),h=({isGrouped:a,centerAlign:l,children:i,onClick:r,url:s,className:n})=>t.jsx(Z.Provider,{value:{onClick:r,url:s},children:t.jsx("div",{className:`group relative -mx-4 -my-px ${a?"grid":"flex"} ${l?"items-center":"items-start"} cursor-pointer grid-cols-[auto_1fr] gap-x-4 gap-y-2.5 rounded-lg px-4 py-5 text-left break-anywhere hover:bg-gray-75 ${n}`,role:"button",onClick:r,children:i})}),J=({size:a="lg",type:l})=>t.jsx("div",{className:"col-start-1 row-start-1",children:t.jsx(I,{notificationType:l,size:a})}),X=({children:a})=>t.jsx("div",{className:"col-start-2 row-start-1 flex gap-2",children:a}),Y=({children:a})=>t.jsx("div",{className:"col-start-2 row-start-2 -mt-0.5 grow overflow-hidden",children:a});h.Icon=J;h.Avatars=X;h.Content=Y;const ee=()=>t.jsx("div",{className:"h-px w-full bg-gray-150 dark:bg-gray-950"});function te(a){const r=new Date(a).getTime();return(Math.floor(r/864e5)*864e5).toString()}function se(a){const l={};let i=null,r=0;return a.forEach(s=>{s.type!==i&&(r+=1,i=s.type);let n="";const c=`_${te(s.createdAt)}`,o=`_seq${r}`;switch(s.type){case"like":s.post?.id&&(n=`like_${s.post.id}${c}${o}`);break;case"reply":n=`reply_${s.id}`;break;case"repost":s.post?.id&&(n=`repost_${s.post.id}${c}${o}`);break;case"follow":n=`follow_${c}${o}`;break;case"mention":n=`mention_${s.id}`;break}l[n]||(l[n]={id:s.id,type:s.type,actors:[],post:s.post,inReplyTo:s.inReplyTo,createdAt:s.createdAt}),l[n].actors.find(f=>f.id===s.actor.id)||l[n].actors.push(s.actor)}),Object.values(l)}const ae=({group:a})=>{const[l,...i]=a.actors,r=i.length>0,s="cursor-pointer font-semibold hover:underline text-black dark:text-white",n=g(),c=t.jsxs(t.Fragment,{children:[t.jsx(q,{actor:l,align:"center",isCurrentUser:!1,children:t.jsx("span",{className:s,onClick:o=>{o?.stopPropagation(),v(l.handle,n)},children:l.name})}),r&&` and ${i.length} ${i.length>1?"others":"other"}`]});switch(a.type){case"follow":return t.jsxs(t.Fragment,{children:[c," followed you"]});case"like":return t.jsxs(t.Fragment,{children:[c," liked your ",a.post?.type==="article"?"post":"note"]});case"repost":return t.jsxs(t.Fragment,{children:[c," reposted your ",a.post?.type==="article"?"post":"note"]});case"reply":if(a.inReplyTo&&typeof a.inReplyTo!="string")return c;break;case"mention":return c}return t.jsx(t.Fragment,{})},ne=({content:a,className:l,stripTags:i=[]})=>{const r=j.useRef(null),s=g();return j.useEffect(()=>{const n=r.current;if(!n)return;const c=o=>{const y=o.target.closest("a[data-profile]");if(y){const x=y.getAttribute("data-profile")?.trim();/^@([\w.-]+)@([\w-]+\.[\w.-]+[a-zA-Z])$/.test(x||"")&&x&&(o.preventDefault(),o.stopPropagation(),v(x,s))}};return n.addEventListener("click",c),()=>{n.removeEventListener("click",c)}},[s,a]),t.jsx("div",{dangerouslySetInnerHTML:{__html:_(a||"",i)},ref:r,className:l})},ce=()=>{const[a,l]=u.useState({}),i=g(),r=e=>{l(d=>({...d,[e]:!d[e]}))},s=()=>{},n=5,{data:c,error:o,fetchNextPage:f,hasNextPage:y,isFetchingNextPage:x,isLoading:b}=T("index"),k=c?.pages.flatMap(e=>se(e.notifications))??Array(10).fill({actors:[{}]}),p=j.useRef(null),N=j.useRef(null);j.useEffect(()=>(p.current&&p.current.disconnect(),p.current=new IntersectionObserver(e=>{e[0].isIntersecting&&y&&!x&&f()}),N.current&&p.current.observe(N.current),()=>{p.current&&p.current.disconnect()}),[y,x,f]);const R=(e,d)=>{switch(e.type){case"like":e.post&&i(`/${e.post.type==="article"?"reader":"notes"}/${encodeURIComponent(e.post.id)}`);break;case"reply":e.post&&e.inReplyTo&&i(`/notes/${encodeURIComponent(e.post.id)}`);break;case"repost":e.post&&i(`/${e.post.type==="article"?"reader":"notes"}/${encodeURIComponent(e.post.id)}`);break;case"follow":e.actors.length>1?r(e.id||`${e.type}_${d}`):v(e.actors[0].handle,i);break;case"mention":e.post&&i(`/notes/${encodeURIComponent(e.post.id)}`);break}};return o&&z(o)?t.jsx(E,{errorCode:o.code,statusCode:o.statusCode}):t.jsx(S,{children:t.jsxs("div",{className:"z-0 flex w-full flex-col items-center",children:[b===!1&&k.length===0&&t.jsxs(M,{children:[t.jsx(P,{children:t.jsx(U,{})}),"Quiet for now, but not for long! When someone likes, boosts, or replies to you, you'll find it here."]}),k.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"my-8 flex w-full max-w-[620px] flex-col max-md:mt-5",children:k.map((e,d)=>t.jsxs(u.Fragment,{children:[t.jsxs(h,{centerAlign:e.actors.length<2&&e.type==="follow",className:"hover:bg-gray-75 dark:hover:bg-gray-950",isGrouped:e.actors.length>1,onClick:()=>R(e,d),children:[b?t.jsx(w,{className:"rounded-full",containerClassName:"flex h-10 w-10"}):e.actors.length>1?t.jsx(h.Icon,{type:e.type}):t.jsxs("div",{className:"relative",children:[t.jsx($,{author:{icon:{url:e.actors[0].avatarUrl||""},name:e.actors[0].name,handle:e.actors[0].handle},size:"notification"},e.actors[0].id),t.jsx(I,{className:"absolute -bottom-1 -right-1 z-10 border-2 border-white dark:border-black",notificationType:e.type,size:"sm"})]}),e.actors.length>1&&t.jsx(h.Avatars,{children:t.jsxs("div",{className:"flex w-full flex-col",children:[t.jsxs("div",{className:"relative flex items-center pl-2",children:[!a[e.id||`${e.type}_${d}`]&&e.actors.slice(0,n).map(m=>t.jsx($,{author:{icon:{url:m.avatarUrl||""},name:m.name,handle:m.handle},className:"-ml-2 !bg-[#F3F3F3] outline outline-2 outline-white group-hover:!bg-[#EDEEF0] group-hover:outline-gray-75 dark:outline-black group-hover:dark:outline-gray-950",size:"notification"},m.id)),e.actors.length>n&&!a[e.id||`${e.type}_${d}`]&&t.jsx("div",{className:"absolute right-[28px] z-10 flex size-9 items-center justify-center rounded-full bg-black/50 text-base font-semibold tracking-tightest text-white",children:`+${e.actors.length-n}`}),e.actors.length>1&&t.jsxs(L,{className:`group flex items-center gap-0.5 text-gray-700 hover:bg-transparent hover:text-black dark:text-gray-600 dark:hover:text-white ${a[e.id||`${e.type}_${d}`]?"ml-[-20px]":"ml-0 w-[28px]"}`,variant:"ghost",onClick:m=>{m?.stopPropagation(),r(e.id||`${e.type}_${d}`)},children:[t.jsx(B,{className:`${a[e.id||`${e.type}_${d}`]?"rotate-180":""}`,size:20,strokeWidth:1.5}),a[e.id||`${e.type}_${d}`]?"Hide":t.jsx("span",{className:"sr-only",children:"Show all"})]})]}),t.jsx("div",{className:`overflow-hidden transition-all duration-300 ease-in-out ${a[e.id||`${e.type}_${d}`]?"mb-2 max-h-[1384px] opacity-100":"max-h-0 opacity-0"}`,children:a[e.id||`${e.type}_${d}`]&&e.actors.length>1&&t.jsx("div",{className:"flex flex-col gap-2 pt-2",children:e.actors.map(m=>t.jsxs("div",{className:"group/item flex items-center justify-between gap-4 break-anywhere",onClick:A=>{A?.stopPropagation(),v(m.handle,i)},children:[t.jsxs("div",{className:"flex min-w-0 items-center",children:[t.jsx($,{author:{icon:{url:m.avatarUrl||""},name:m.name,handle:m.handle},size:"xs"}),t.jsx("span",{className:"ml-2 line-clamp-1 text-base font-semibold group-hover/item:underline dark:text-white",children:m.name}),t.jsx("span",{className:"ml-1 line-clamp-1 text-base text-gray-700 dark:text-gray-600",children:m.handle})]}),e.type==="follow"&&!m.followedByMe&&t.jsx(C,{following:!1,handle:m.handle,variant:"link"})]},m.id))})})]})}),t.jsxs(h.Content,{children:[t.jsx("div",{children:b?t.jsxs(t.Fragment,{children:[t.jsx(w,{}),t.jsx(w,{className:"w-full max-w-60"})]}):t.jsxs("div",{className:"flex justify-between",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"truncate",children:t.jsx(ae,{group:e})}),e.actors.length<2&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"mt-px text-[8px] text-gray-700 dark:text-gray-600",children:"•"}),t.jsx("span",{className:"mt-0.5 text-sm text-gray-700 dark:text-gray-600",children:W(e,!1)})]})]}),e.actors.length===1&&(e.type==="follow"||e.type==="reply"||e.type==="mention")&&!e.actors[0].followedByMe&&t.jsx(C,{following:!1,handle:e.actors[0].handle,variant:"link"})]})}),(e.type==="reply"&&e.inReplyTo||e.type==="mention"||e.type==="like"&&!e.post?.name&&e.post?.content||e.type==="repost"&&!e.post?.name&&e.post?.content)&&(e.type!=="reply"&&e.type!=="mention"?t.jsxs("div",{className:"ap-note-content mt-0.5 line-clamp-1 text-pretty text-sm text-gray-700 dark:text-gray-600",children:[e.post?.type==="article"&&e.post?.title&&t.jsxs(t.Fragment,{children:[e.post.title," — "]}),t.jsx("span",{dangerouslySetInnerHTML:{__html:_(e.post?.content||"")}})]}):t.jsx(t.Fragment,{children:t.jsxs("div",{className:"mt-2.5 rounded-md bg-gray-100 px-5 py-[14px] group-hover:bg-gray-200 dark:bg-gray-925/30 group-hover:dark:bg-black/40",children:[t.jsx(ne,{className:"ap-note-content text-pretty",content:e.post?.content||"",stripTags:["a"]}),e.post&&e.post.attachments&&e.post.attachments.length>0&&t.jsx("div",{className:"notification-attachments mb-1 [&_.attachment-gallery]:flex [&_.attachment-gallery]:flex-wrap [&_img]:aspect-square [&_img]:max-w-[calc(20%-6.4px)]",children:D({...e.post,type:"Note",attachment:e.post.attachments})})]})})),(e.type==="reply"&&e.post||e.type==="mention")&&t.jsx("div",{className:"mt-1.5",children:t.jsx(H,{actor:{...e.actors[0],icon:{url:e.actors[0].avatarUrl||""},id:e.actors[0].url,preferredUsername:e.actors[0].handle?.replace(/^@([^@]+)@.*$/,"$1")||"unknown"},buttonClassName:"hover:bg-gray-200",commentCount:e.post.replyCount||0,layout:"notification",likeCount:e.post.likeCount||0,object:{...e.post,liked:e.post.likedByMe,reposted:e.post.repostedByMe},repostCount:e.post.repostCount||0,onLikeClick:s})})]})]}),d<k.length-1&&t.jsx("div",{className:"pl-[52px]",children:t.jsx(ee,{})})]},e.id||`${e.type}_${d}`))}),t.jsx("div",{ref:N,className:"h-1"}),x&&t.jsx("div",{className:"-mt-4 mb-8 flex flex-col items-center justify-center space-y-4 text-center",children:t.jsx(O,{size:"md"})})]})]})})};export{ce as default};
@@ -1 +1 @@
1
- import{m as J,r as u,b as $,j as e,Q as H,R as L,c7 as ye,g as Ne,e as Ce,P as Ue,U as Me,A as oe,B as j,n as ae,h as Be,f as W,bn as De,F as ie,aR as ce,a0 as de,cI as Pe,a1 as ue,a2 as Q,a3 as Y,a4 as K,H as q,bH as Te,aT as Fe,a5 as G,a6 as me,V as U,cq as Re,cr as Oe,ct as Ie,cJ as ne,a7 as Ee,a8 as Se,u as xe,ck as Ae,a as $e,J as He,K as Le,M as Ve,N as ze,L as te,E as _e,c as Qe,S as O,bK as Ye,D as Ke,q as qe,t as Ge,v as Je,w as We,O as Xe,$ as Ze,cK as es,o as ss,s as ls,cD as z,T as ns,bj as ts,bk as rs,cL as os,cM as fe,cN as as}from"./index-DCTdAEHx.js";import{P as is}from"./tags-CKrBptuC.js";import{E as cs}from"./edit-profile-ZBdjFfvL.js";import{T as ds,a as us,b as S,f as _,c as A}from"./tabs-CBD0hW8V.js";import{a as ms}from"./settings-CxWtvcUf.js";import{U as xs}from"./lucide-react-DtMIZssr.js";import{C as fs}from"./copy-Bi7VpgPR.js";import"./label-CW7Kmp9w.js";import"./at-sign-BZPuAx5m.js";import"./index-LyfDjTto.js";import"./wallet-cards-ddLuIN-b.js";import"./a-large-small-p58xibEK.js";import"./message-square-text-BDZtUW-2.js";import"./hash-DFhnGHId.js";import"./inbox-p-Y5uScT.js";import"./list-filter-3EF6cVg-.js";import"./minus-CSphShdJ.js";import"./square-CwHQ9sJ2.js";import"./user-round-check-zOuzV3OS.js";import"./repeat-Smml9n0k.js";import"./reply-CooY4lmk.js";import"./sprout-DRqlFJSK.js";import"./trash-CJY1Wro_.js";function hs(s){return typeof s.name=="string"?s.name:typeof s.preferredUsername=="string"?s.preferredUsername:typeof s.preferredUsername=="object"&&s.preferredUsername!==null&&"@value"in s.preferredUsername&&typeof s.preferredUsername["@value"]=="string"?s.preferredUsername["@value"]:"Unknown"}const he=({noResultsMessage:s,actors:o,isLoading:n,fetchNextPage:c,hasNextPage:x,isFetchingNextPage:d})=>{const i=J("index","me"),{data:r}=i,t=u.useRef(null),a=u.useRef(null);u.useEffect(()=>(t.current&&t.current.disconnect(),t.current=new IntersectionObserver(l=>{l[0].isIntersecting&&x&&!d&&c()}),a.current&&t.current.observe(a.current),()=>{t.current&&t.current.disconnect()}),[x,d,c]);const m=$();return e.jsxs("div",{className:"pt-3","data-testid":"actor-list",children:[x===!1&&o.length===0?e.jsxs(H,{children:[e.jsx(L,{children:e.jsx(ye,{})}),s]}):e.jsx("div",{className:"flex flex-col",children:o.map(({actor:l,isFollowing:h,blockedByMe:b,domainBlockedByMe:k})=>{const w=l.handle||Ne(l),y=w===r?.handle;return e.jsx(Ce.Fragment,{children:e.jsx(Ue,{actor:l,align:"center",isCurrentUser:y,side:"left",children:e.jsx("div",{children:e.jsxs(Me,{"data-testid":"actor-item",onClick:()=>{Be(l,m)},children:[e.jsx(oe,{author:l}),e.jsx("div",{children:e.jsxs("div",{className:"text-gray-600 break-anywhere",children:[e.jsx("span",{className:"mr-1 line-clamp-1 font-bold text-black dark:text-white",children:hs(l)}),e.jsx("div",{className:"line-clamp-1 text-sm",children:w})]})}),b||k?e.jsx(j,{className:"pointer-events-none ml-auto min-w-[90px]",variant:"destructive",children:"Blocked"}):y?null:e.jsx(ae,{className:"ml-auto","data-testid":"follow-button",following:h,handle:w,type:"secondary"})]},l.id)})})},l.id)})}),e.jsx("div",{ref:a,className:"h-1"}),(d||n)&&e.jsx("div",{className:"mt-6 flex flex-col items-center justify-center space-y-4 text-center",children:e.jsx(W,{size:"md"})})]})},ps=({posts:s,fetchNextPage:o,hasNextPage:n,isFetchingNextPage:c,isLoading:x})=>{const d=u.useRef(null),i=u.useRef(null),r=u.useRef(null),t=Math.max(0,Math.floor(s.length*.75)-1);u.useEffect(()=>(d.current&&d.current.disconnect(),d.current=new IntersectionObserver(m=>{m[0].isIntersecting&&n&&!c&&o()}),i.current&&d.current.observe(i.current),r.current&&d.current.observe(r.current),()=>{d.current&&d.current.disconnect()}),[n,c,o]);const a=$();return e.jsxs(e.Fragment,{children:[n===!1&&s.length===0&&e.jsxs(H,{children:[e.jsx(L,{children:e.jsx(De,{})}),"You haven't liked anything yet."]}),e.jsxs("ul",{className:"mx-auto flex max-w-[640px] flex-col","data-testid":"profile-likes-list",children:[s.map((m,l)=>e.jsxs("li",{"data-testid":"profile-like-item","data-test-view-article":!0,children:[e.jsx(ie,{actor:m.actor,allowDelete:m.object.authored,commentCount:m.object.replyCount,isLoading:x,layout:"feed",likeCount:m.object.likeCount,object:m.object,repostCount:m.object.repostCount,type:m.type,onClick:()=>{m.object.type==="Note"?a(`/notes/${encodeURIComponent(m.object.id)}`):m.object.type==="Article"&&a(`/reader/${encodeURIComponent(m.object.id)}`)}}),l<s.length-1&&e.jsx(ce,{}),l===t&&e.jsx("div",{ref:i,className:"h-1"})]},`likes-${m.id}`)),c&&e.jsx("li",{className:"flex flex-col items-center justify-center space-y-4 text-center",children:e.jsx(W,{size:"md"})})]}),e.jsx("div",{ref:r,className:"h-1"})]})},js=({posts:s,fetchNextPage:o,hasNextPage:n,isFetchingNextPage:c,isLoading:x,noResultsMessage:d})=>{const i=u.useRef(null),r=u.useRef(null),t=u.useRef(null),a=Math.max(0,Math.floor(s.length*.75)-1);u.useEffect(()=>(i.current&&i.current.disconnect(),i.current=new IntersectionObserver(l=>{l[0].isIntersecting&&n&&!c&&o()}),r.current&&i.current.observe(r.current),t.current&&i.current.observe(t.current),()=>{i.current&&i.current.disconnect()}),[n,c,o]);const m=$();return e.jsxs(e.Fragment,{children:[n===!1&&s.length===0&&e.jsxs(H,{children:[e.jsx(L,{children:e.jsx(is,{})}),d]}),e.jsxs("ul",{className:"mx-auto flex max-w-[640px] flex-col","data-testid":"profile-posts-list",children:[s.map((l,h)=>e.jsxs("li",{"data-testid":"profile-post-item","data-test-view-article":!0,children:[e.jsx(ie,{actor:l.actor,allowDelete:l.object.authored,commentCount:l.object.replyCount,isLoading:x,layout:"feed",likeCount:l.object.likeCount,object:l.object,repostCount:l.object.repostCount,type:l.type,onClick:()=>{l.object.type==="Note"?m(`/notes/${encodeURIComponent(l.object.id)}`):l.object.type==="Article"&&m(`/reader/${encodeURIComponent(l.object.id)}`)}}),h<s.length-1&&e.jsx(ce,{}),h===a&&e.jsx("div",{ref:r,className:"h-1"})]},`posts-${l.id}`)),c&&e.jsx("li",{className:"flex flex-col items-center justify-center space-y-4 text-center",children:e.jsx(W,{size:"md"})})]}),e.jsx("div",{ref:t,className:"h-1"})]})},pe=({handle:s,isUserBlocked:o,isDomainBlocked:n,onUnblockUser:c,onUnblockDomain:x,trigger:d,onUnblockComplete:i,isOpen:r,onOpenChange:t})=>{const[a,m]=u.useState(!1),[l,h]=u.useState(()=>{const p=o&&n,N=o&&!n,F=!o&&n;let g="idle";return p?g="dual":N?g="userOnly":F&&(g="domainOnly"),{mode:g,userUnblocked:!1,domainUnblocked:!1}}),b=r!==void 0,k=b?r:a,[w,y]=u.useState(!1),M=u.useCallback(()=>{const p=o&&n,N=o&&!n,F=!o&&n;let g="idle";p?g="dual":N?g="userOnly":F&&(g="domainOnly"),h(C=>({...C,mode:g,userUnblocked:!1,domainUnblocked:!1}))},[o,n]);u.useEffect(()=>{k&&!w?(M(),y(!0)):k||y(!1)},[k,w,M]);const P=()=>{b?t?.(!0):m(!0)},f=p=>{p||(b?t?.(!1):m(!1))},I=async()=>{await c(),h(p=>({...p,userUnblocked:!0})),(l.mode!=="dual"||l.domainUnblocked)&&(f(!1),i?.()),U.success("User unblocked")},E=async()=>{await x(),h(p=>({...p,domainUnblocked:!0})),(l.mode!=="dual"||l.userUnblocked)&&(f(!1),i?.()),U.success("Domain unblocked")},T=s.split("@").filter(Boolean)[1],B=()=>e.jsxs(e.Fragment,{children:[e.jsxs(Q,{children:[e.jsx(Y,{className:"mb-1 flex flex-col gap-1",children:"Unblock"}),e.jsx(K,{className:"!mt-4",asChild:!0,children:e.jsxs("div",{className:"flex flex-col rounded-md border",children:[e.jsxs("div",{className:"flex justify-between gap-6 p-5",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(q,{children:"Unblock user"}),e.jsxs("p",{children:[e.jsx("span",{className:"font-semibold text-black",children:s})," will be able to follow you and engage with your public posts."]})]}),e.jsxs(j,{className:`gap-1 ${l.userUnblocked?"pointer-events-none border-green bg-green text-white hover:bg-green hover:text-white":"text-red hover:text-red-400"}`,variant:"outline",onClick:I,children:[e.jsx(Te,{}),l.userUnblocked?"User unblocked":"Unblock user"]})]}),e.jsx("div",{className:"border-t"}),e.jsxs("div",{className:"flex justify-between gap-6 p-5",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(q,{children:"Unblock domain"}),e.jsxs("p",{children:["Users from ",e.jsx("span",{className:"font-semibold text-black",children:T})," will be able to follow you and engage with your public posts."]})]}),e.jsxs(j,{className:`gap-1 ${l.domainUnblocked?"pointer-events-none border-green bg-green text-white hover:bg-green hover:text-white":"text-red hover:text-red-400"}`,variant:"outline",onClick:E,children:[e.jsx(Fe,{}),l.domainUnblocked?"Domain unblocked":"Unblock domain"]})]})]})})]}),e.jsx(G,{children:e.jsx(j,{onClick:()=>f(!1),children:"OK"})})]}),D=()=>{const p=l.mode==="userOnly";return e.jsxs(e.Fragment,{children:[e.jsxs(Q,{children:[e.jsx(Y,{className:"mb-1 flex flex-col gap-1",children:p?"Unblock this user?":"Unblock this domain?"}),e.jsx(K,{children:p?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-semibold text-black",children:s})," will be able to follow you and engage with your public posts."]}):e.jsxs(e.Fragment,{children:["Users from ",e.jsx("span",{className:"font-semibold text-black",children:T})," will be able to follow you and engage with your public posts."]})})]}),e.jsxs(G,{children:[e.jsx(me,{children:"Cancel"}),e.jsx(j,{onClick:p?I:E,children:"Unblock"})]})]})};return e.jsxs(de,{open:k,onOpenChange:f,children:[d&&e.jsx(Pe,{asChild:!0,onClick:P,children:d}),e.jsx(ue,{className:`${l.mode==="dual"&&"max-w-[600px]"}`,children:l.mode==="dual"?B():D()})]})},bs=({account:s,children:o,onCopyHandle:n,onBlockAccount:c,onBlockDomain:x,disabled:d=!1,isBlocked:i=!1,isDomainBlocked:r=!1})=>{const[t,a]=u.useState(null),[m,l]=u.useState(!1),h=f=>{f.stopPropagation(),n()},b=f=>{f.stopPropagation(),c()},k=f=>{f.stopPropagation(),x()},w=s?.handle,y=w?.split("@").filter(Boolean)[1],M=()=>e.jsx(de,{open:m,onOpenChange:l,children:e.jsxs(ue,{onClick:f=>f.stopPropagation(),children:[e.jsxs(Q,{children:[e.jsx(Y,{className:"mb-1 flex flex-col gap-1",children:t==="user"?"Block this user?":"Block this domain?"}),e.jsx(K,{children:t==="user"?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-semibold text-black",children:w})," will be able to see your public posts, but will no longer be able follow you or interact with your content on the social web."]}):e.jsxs(e.Fragment,{children:["All users from ",e.jsx("span",{className:"font-semibold text-black",children:y})," will be able to see your public posts, but won't be able to follow you or interact with your content."]})})]}),e.jsxs(G,{children:[t!=="domain"&&e.jsx(j,{className:"-ml-3 mr-auto hover:bg-transparent hover:opacity-80",variant:"ghost",onClick:f=>{f.stopPropagation(),a("domain")},children:"Block domain instead"}),e.jsx(me,{onClick:f=>f.stopPropagation(),children:"Cancel"}),e.jsx(Ee,{className:Se({variant:"destructive"}),onClick:t==="user"?b:k,children:"Block"})]})]})}),P=()=>s&&e.jsx(pe,{handle:s.handle,isDomainBlocked:s.domainBlockedByMe,isOpen:m,isUserBlocked:s.blockedByMe,onOpenChange:l,onUnblockDomain:x,onUnblockUser:c});return e.jsxs(e.Fragment,{children:[e.jsxs(Re,{children:[e.jsx(Oe,{disabled:d,asChild:!0,onClick:f=>f.stopPropagation(),children:o}),e.jsx(Ie,{align:"end",className:"p-2",children:e.jsxs("div",{className:"flex w-48 flex-col",children:[e.jsx(ne,{asChild:!0,children:e.jsx(j,{className:"justify-start",variant:"ghost",onClick:h,children:"Copy handle"})}),e.jsx(ne,{asChild:!0,children:e.jsx(j,{className:"justify-start text-red hover:bg-red/5 hover:text-red",variant:"ghost",onClick:f=>{f.stopPropagation(),!i&&!r&&a("user"),l(!0)},children:i?"Unblock user":r?"Unblock domain":"Block user"})})]})})]}),i||r?P():M()]})},gs=({account:s,onUnblock:o,onDomainUnblock:n,className:c=""})=>{const[x,d]=u.useState(!1),i=e.jsx(j,{className:`min-w-[90px] ${c}`,variant:"destructive",onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),children:x?"Unblock":"Blocked"});return e.jsx(pe,{handle:s.handle,isDomainBlocked:s.domainBlockedByMe,isUserBlocked:s.blockedByMe,trigger:i,onUnblockDomain:n,onUnblockUser:o})},re=()=>{},ks=({account:s,customFields:o,isLoadingAccount:n,postsTab:c,likesTab:x,followingTab:d,followersTab:i})=>{const r=xe(),t=Ae(),a=$(),{canGoBack:m}=$e(),l=r.handle?`/profile/${r.handle}`:"/profile",h=!r.handle,b=r.handle?r.tab||"":t.pathname.split("/").pop()||"",k=u.useMemo(()=>h?["likes","following","followers"]:["following","followers"],[h]),w=k.includes(b)?b:"posts",y=He("index"),M=Le("index"),P=Ve("index"),f=ze("index"),I=J("index","me"),{data:E}=r.handle?I:{data:void 0},T=r.handle===E?.handle||!r.handle,B=s?.blockedByMe,D=s?.domainBlockedByMe,[p,N]=u.useState(!1),[F,g]=u.useState(!1),C=u.useRef(null);u.useEffect(()=>()=>{C.current&&window.clearTimeout(C.current)},[]);const X=()=>{B?M.mutate(s):(y.mutate(s),U.success("User blocked")),N(!1)},Z=()=>{D?f.mutate({url:s.apId,handle:s.handle}):(P.mutate({url:s.apId,handle:s.handle}),U.success("Domain blocked")),N(!1)},ee=async()=>{if(!s?.handle||!navigator?.clipboard?.writeText){U.error("Unable to copy handle");return}try{await navigator.clipboard.writeText(s.handle),g(!0),U.success("Handle copied"),C.current&&window.clearTimeout(C.current),C.current=window.setTimeout(()=>g(!1),2e3)}catch{U.error("Failed to copy handle"),g(!1)}},[R,je]=u.useState(!1),[be,se]=u.useState(!1),ge=()=>{je(!R)},V=u.useRef(null),[le,ke]=u.useState(!1);u.useEffect(()=>{V.current&&ke(V.current.scrollHeight>160)},[R,s?.bio,o,n]),u.useEffect(()=>{b&&(k.includes(b)||a(l,{replace:!0}))},[k,l,a,b]);const we=v=>v==="posts"?l:`${l}/${v}`,ve=v=>{v!==w&&a(we(v),{replace:!0})};return!n&&!s?e.jsx(te,{children:e.jsx("div",{className:"mx-auto mt-4 flex w-full max-w-[620px] flex-col items-center [&_svg]:translate-x-px",children:e.jsxs(_e,{children:[e.jsx(Qe,{children:e.jsx(xs,{})}),e.jsx("div",{children:"Profile not found"})]})})}):e.jsx(te,{children:e.jsx("div",{className:"z-0 mx-[max(-4vw,-32px)] -mt-9 flex flex-col items-center pb-16",children:e.jsx("div",{className:"mx-auto w-full",children:e.jsxs(e.Fragment,{children:[s?.bannerImageUrl?e.jsx("div",{className:"h-[15vw] min-h-[200px] w-full overflow-hidden bg-gradient-to-tr from-gray-200 to-gray-100",children:e.jsx("img",{alt:s?.name,className:"size-full object-cover",referrerPolicy:"no-referrer",src:s?.bannerImageUrl})}):e.jsx("div",{className:"h-[max(8vw,132px)] w-full overflow-hidden bg-gradient-to-tr from-white to-white dark:from-black dark:to-black"}),e.jsxs("div",{className:`mx-auto max-w-[620px] px-6 ${!s?.bannerImageUrl&&!m?"-mt-8":"-mt-12"}`,children:[e.jsxs("div",{className:"flex items-end justify-between",children:[e.jsx("div",{className:"-ml-2 rounded-full bg-white p-1 dark:bg-black",children:n?e.jsx(O,{className:"size-[92px] rounded-full"}):e.jsx(oe,{author:{icon:{url:s?.avatarUrl},name:s?.name,handle:s?.handle},size:"lg"})}),!T&&!n&&e.jsxs("div",{className:"flex gap-2",children:[B||D?e.jsx(gs,{account:s,onDomainUnblock:Z,onUnblock:X}):e.jsx(ae,{following:s?.followedByMe,handle:s?.handle,type:"primary",onFollow:re,onUnfollow:re}),e.jsx(bs,{account:s,isBlocked:B,isDomainBlocked:D,onBlockAccount:X,onBlockDomain:Z,onCopyHandle:ee,children:e.jsx(j,{"aria-label":"Open profile menu",variant:"outline",children:e.jsx(Ye,{})})})]}),T&&!n&&e.jsxs(Ke,{open:be,onOpenChange:se,children:[e.jsx(qe,{children:e.jsx(ms,{children:e.jsx(j,{variant:"secondary",children:"Edit profile"})})}),e.jsxs(Ge,{className:"w-full max-w-[520px]",onOpenAutoFocus:v=>v.preventDefault(),children:[e.jsx(Je,{children:e.jsx(We,{children:"Profile settings"})}),s&&e.jsx(cs,{account:s,setIsEditingProfile:se})]})]})]}),e.jsx(Xe,{className:"mt-4 truncate break-anywhere",children:n?e.jsx(O,{className:"w-32"}):s?.name}),e.jsxs("div",{className:"mb-4 flex items-center gap-2",children:[e.jsx("a",{className:"inline-flex max-w-full truncate text-[1.5rem] text-gray-800 hover:text-gray-900 dark:text-gray-600 dark:hover:text-gray-500",href:s?.url,rel:"noopener noreferrer",target:"_blank",children:e.jsx("span",{className:"truncate",children:n?e.jsx(O,{className:"w-full max-w-56"}):s?.handle})}),!n&&e.jsx(j,{className:"-ml-1.5 size-6 p-0 text-gray-800 hover:text-gray-900 dark:text-gray-700 dark:hover:text-gray-600",title:"Copy handle",variant:"link",onClick:ee,children:F?e.jsx(Ze,{size:16}):e.jsx(fs,{size:16})}),s?.followsMe&&!n&&e.jsx(es,{className:"mt-px whitespace-nowrap",variant:"secondary",children:"Follows you"})]}),(s?.bio||o?.length>0)&&e.jsxs("div",{ref:V,className:`ap-profile-content relative text-[1.5rem] break-anywhere [&>p]:mb-3 ${R?"max-h-none pb-7":"max-h-[160px] overflow-hidden"} relative`,children:[n?e.jsxs(e.Fragment,{children:[e.jsx(O,{}),e.jsx(O,{className:"w-full max-w-48"})]}):e.jsx("div",{dangerouslySetInnerHTML:{__html:ss(ls(s?.bio??"",["a","br"]))}}),o?.map(v=>e.jsxs("span",{className:"mt-3 line-clamp-1 flex flex-col text-[1.5rem]",children:[e.jsx("span",{className:"text-xs font-semibold",children:v.name}),e.jsx("span",{dangerouslySetInnerHTML:{__html:v.value},className:"ap-profile-content truncate"})]})),!R&&le&&e.jsx("div",{className:"absolute inset-x-0 bottom-0 h-16 bg-gradient-to-t from-white via-white/100 via-60% to-transparent dark:from-black dark:via-black/100"}),le&&e.jsx(j,{className:"absolute bottom-0 h-auto p-0 text-md",variant:"link",onClick:ge,children:R?"Show less":"Show all"})]}),e.jsxs(ds,{className:"mt-5",value:w,variant:"underline",onValueChange:v=>ve(v),children:[e.jsxs(us,{children:[e.jsx(S,{value:"posts",children:"Posts"}),h&&e.jsxs(S,{value:"likes",children:["Likes",e.jsx(_,{children:z(s?.likedCount||0)})]}),e.jsxs(S,{value:"following",children:["Following",e.jsx(_,{children:z(s?.followingCount||0)})]}),e.jsxs(S,{value:"followers",children:["Followers",e.jsx(_,{children:z(s?.followerCount||0)})]})]}),e.jsx(A,{value:"posts",children:(B||D)&&!p?e.jsxs(H,{children:[e.jsx(L,{children:e.jsx(ns,{})}),e.jsxs("div",{className:"mt-2 flex flex-col items-center gap-0.5",children:[e.jsxs(q,{children:[s.name," is blocked"]}),e.jsx("p",{children:"You can view the posts, but it won't unblock the user."}),e.jsx(j,{className:"mt-4",variant:"secondary",onClick:()=>N(!0),children:"View posts"})]})]}):c}),h&&e.jsx(A,{value:"likes",children:x}),e.jsx(A,{value:"following",children:d}),e.jsx(A,{value:"followers",children:i})]},r.handle||s?.handle||"current-user")]})]})})})})},ws=({handle:s})=>{const{postsByAccountQuery:o}=os(s||"me",{enabled:!0}),{data:n,fetchNextPage:c,hasNextPage:x,isFetchingNextPage:d,isLoading:i}=o,r=n?.pages.flatMap(t=>t.posts)??Array.from({length:5},(t,a)=>({id:`placeholder-${a}`,object:{}}));return e.jsx(js,{fetchNextPage:c,hasNextPage:x,isFetchingNextPage:d,isLoading:i,noResultsMessage:s?`${s} hasn't posted anything yet`:"You haven't posted anything yet.",posts:r})},vs=()=>{const{postsLikedByAccountQuery:s}=as({enabled:!0}),{data:o,fetchNextPage:n,hasNextPage:c,isFetchingNextPage:x,isLoading:d}=s,i=o?.pages.flatMap(r=>r.posts)??Array.from({length:5},(r,t)=>({id:`placeholder-${t}`,object:{}}));return e.jsx(ps,{fetchNextPage:n,hasNextPage:c,isFetchingNextPage:x,isLoading:d,posts:i})},ys=({handle:s})=>{const o=fe(s===""?"me":s,"following"),{data:n,fetchNextPage:c,hasNextPage:x,isFetchingNextPage:d,isLoading:i}=o,r=n?.pages.flatMap(t=>"following"in t?t.following:"accounts"in t?t.accounts.map(a=>({actor:{id:a.id,name:a.name,handle:a.handle,icon:{url:a.avatarUrl}},isFollowing:a.isFollowing,blockedByMe:a.blockedByMe,domainBlockedByMe:a.domainBlockedByMe})):[])??[];return e.jsx(he,{actors:r,fetchNextPage:c,hasNextPage:x,isFetchingNextPage:d,isLoading:i,noResultsMessage:`${s||"You"} have no following`})},Ns=({handle:s})=>{const o=fe(s===""?"me":s,"followers"),{data:n,fetchNextPage:c,hasNextPage:x,isFetchingNextPage:d,isLoading:i}=o,r=n?.pages.flatMap(t=>"followers"in t?t.followers:"accounts"in t?t.accounts.map(a=>({actor:{id:a.id,name:a.name,handle:a.handle,icon:{url:a.avatarUrl}},isFollowing:a.isFollowing})):[])??[];return e.jsx(he,{actors:r,fetchNextPage:c,hasNextPage:x,isFetchingNextPage:d,isLoading:i,noResultsMessage:`${s||"You"} have no followers yet`})},qs=({})=>{const s=xe(),{data:o,isLoading:n,error:c,refetch:x}=J("index",s.handle||"me");if(u.useEffect(()=>{x()},[s.handle,x]),c&&ts(c)&&c.statusCode!==404)return e.jsx(rs,{errorCode:c.code,statusCode:c.statusCode});const d=Object.keys(o?.customFields||{}).map(m=>({name:m,value:o.customFields[m]}))||[],i=e.jsx(ws,{handle:s.handle||""}),r=e.jsx(vs,{}),t=e.jsx(ys,{handle:s.handle||""}),a=e.jsx(Ns,{handle:s.handle||""});return e.jsx(ks,{account:o,customFields:d,followersTab:a,followingTab:t,isLoadingAccount:n,likesTab:r,postsTab:i})};export{qs as default};
1
+ import{m as J,r as u,b as $,j as e,Q as H,R as L,c7 as ye,g as Ne,e as Ce,P as Ue,U as Me,A as oe,B as j,n as ae,h as Be,f as W,bn as De,F as ie,aR as ce,a0 as de,cI as Pe,a1 as ue,a2 as Q,a3 as Y,a4 as K,H as q,bH as Te,aT as Fe,a5 as G,a6 as me,V as U,cq as Re,cr as Oe,ct as Ie,cJ as ne,a7 as Ee,a8 as Se,u as xe,ck as Ae,a as $e,J as He,K as Le,M as Ve,N as ze,L as te,E as _e,c as Qe,S as O,bK as Ye,D as Ke,q as qe,t as Ge,v as Je,w as We,O as Xe,$ as Ze,cK as es,o as ss,s as ls,cD as z,T as ns,bj as ts,bk as rs,cL as os,cM as fe,cN as as}from"./index-Bgo4hw-T.js";import{P as is}from"./tags-BQz2NtFF.js";import{E as cs}from"./edit-profile-B_ViIhsd.js";import{T as ds,a as us,b as S,f as _,c as A}from"./tabs-Bw13eFRh.js";import{a as ms}from"./settings-Q3y0Zw5o.js";import{U as xs}from"./lucide-react-7D_Tsesk.js";import{C as fs}from"./copy-CTHgI4YI.js";import"./label-BQ5mfFHN.js";import"./at-sign-V79EBNTJ.js";import"./index-D0RISNEd.js";import"./wallet-cards-Cl4bJBBw.js";import"./a-large-small-gBDqOWOy.js";import"./message-square-text-DzuHB7uU.js";import"./hash-CRtHv162.js";import"./inbox-DWYGFLuU.js";import"./list-filter-CofVbkA4.js";import"./minus-BIdO1CDG.js";import"./square-C8G-1gV_.js";import"./user-round-check-Df7ko4Tm.js";import"./repeat-YTCeIlQZ.js";import"./reply-CUazFbTY.js";import"./sprout-CXg43Zav.js";import"./trash-BKeiM6WP.js";function hs(s){return typeof s.name=="string"?s.name:typeof s.preferredUsername=="string"?s.preferredUsername:typeof s.preferredUsername=="object"&&s.preferredUsername!==null&&"@value"in s.preferredUsername&&typeof s.preferredUsername["@value"]=="string"?s.preferredUsername["@value"]:"Unknown"}const he=({noResultsMessage:s,actors:o,isLoading:n,fetchNextPage:c,hasNextPage:x,isFetchingNextPage:d})=>{const i=J("index","me"),{data:r}=i,t=u.useRef(null),a=u.useRef(null);u.useEffect(()=>(t.current&&t.current.disconnect(),t.current=new IntersectionObserver(l=>{l[0].isIntersecting&&x&&!d&&c()}),a.current&&t.current.observe(a.current),()=>{t.current&&t.current.disconnect()}),[x,d,c]);const m=$();return e.jsxs("div",{className:"pt-3","data-testid":"actor-list",children:[x===!1&&o.length===0?e.jsxs(H,{children:[e.jsx(L,{children:e.jsx(ye,{})}),s]}):e.jsx("div",{className:"flex flex-col",children:o.map(({actor:l,isFollowing:h,blockedByMe:b,domainBlockedByMe:k})=>{const w=l.handle||Ne(l),y=w===r?.handle;return e.jsx(Ce.Fragment,{children:e.jsx(Ue,{actor:l,align:"center",isCurrentUser:y,side:"left",children:e.jsx("div",{children:e.jsxs(Me,{"data-testid":"actor-item",onClick:()=>{Be(l,m)},children:[e.jsx(oe,{author:l}),e.jsx("div",{children:e.jsxs("div",{className:"text-gray-600 break-anywhere",children:[e.jsx("span",{className:"mr-1 line-clamp-1 font-bold text-black dark:text-white",children:hs(l)}),e.jsx("div",{className:"line-clamp-1 text-sm",children:w})]})}),b||k?e.jsx(j,{className:"pointer-events-none ml-auto min-w-[90px]",variant:"destructive",children:"Blocked"}):y?null:e.jsx(ae,{className:"ml-auto","data-testid":"follow-button",following:h,handle:w,type:"secondary"})]},l.id)})})},l.id)})}),e.jsx("div",{ref:a,className:"h-1"}),(d||n)&&e.jsx("div",{className:"mt-6 flex flex-col items-center justify-center space-y-4 text-center",children:e.jsx(W,{size:"md"})})]})},ps=({posts:s,fetchNextPage:o,hasNextPage:n,isFetchingNextPage:c,isLoading:x})=>{const d=u.useRef(null),i=u.useRef(null),r=u.useRef(null),t=Math.max(0,Math.floor(s.length*.75)-1);u.useEffect(()=>(d.current&&d.current.disconnect(),d.current=new IntersectionObserver(m=>{m[0].isIntersecting&&n&&!c&&o()}),i.current&&d.current.observe(i.current),r.current&&d.current.observe(r.current),()=>{d.current&&d.current.disconnect()}),[n,c,o]);const a=$();return e.jsxs(e.Fragment,{children:[n===!1&&s.length===0&&e.jsxs(H,{children:[e.jsx(L,{children:e.jsx(De,{})}),"You haven't liked anything yet."]}),e.jsxs("ul",{className:"mx-auto flex max-w-[640px] flex-col","data-testid":"profile-likes-list",children:[s.map((m,l)=>e.jsxs("li",{"data-testid":"profile-like-item","data-test-view-article":!0,children:[e.jsx(ie,{actor:m.actor,allowDelete:m.object.authored,commentCount:m.object.replyCount,isLoading:x,layout:"feed",likeCount:m.object.likeCount,object:m.object,repostCount:m.object.repostCount,type:m.type,onClick:()=>{m.object.type==="Note"?a(`/notes/${encodeURIComponent(m.object.id)}`):m.object.type==="Article"&&a(`/reader/${encodeURIComponent(m.object.id)}`)}}),l<s.length-1&&e.jsx(ce,{}),l===t&&e.jsx("div",{ref:i,className:"h-1"})]},`likes-${m.id}`)),c&&e.jsx("li",{className:"flex flex-col items-center justify-center space-y-4 text-center",children:e.jsx(W,{size:"md"})})]}),e.jsx("div",{ref:r,className:"h-1"})]})},js=({posts:s,fetchNextPage:o,hasNextPage:n,isFetchingNextPage:c,isLoading:x,noResultsMessage:d})=>{const i=u.useRef(null),r=u.useRef(null),t=u.useRef(null),a=Math.max(0,Math.floor(s.length*.75)-1);u.useEffect(()=>(i.current&&i.current.disconnect(),i.current=new IntersectionObserver(l=>{l[0].isIntersecting&&n&&!c&&o()}),r.current&&i.current.observe(r.current),t.current&&i.current.observe(t.current),()=>{i.current&&i.current.disconnect()}),[n,c,o]);const m=$();return e.jsxs(e.Fragment,{children:[n===!1&&s.length===0&&e.jsxs(H,{children:[e.jsx(L,{children:e.jsx(is,{})}),d]}),e.jsxs("ul",{className:"mx-auto flex max-w-[640px] flex-col","data-testid":"profile-posts-list",children:[s.map((l,h)=>e.jsxs("li",{"data-testid":"profile-post-item","data-test-view-article":!0,children:[e.jsx(ie,{actor:l.actor,allowDelete:l.object.authored,commentCount:l.object.replyCount,isLoading:x,layout:"feed",likeCount:l.object.likeCount,object:l.object,repostCount:l.object.repostCount,type:l.type,onClick:()=>{l.object.type==="Note"?m(`/notes/${encodeURIComponent(l.object.id)}`):l.object.type==="Article"&&m(`/reader/${encodeURIComponent(l.object.id)}`)}}),h<s.length-1&&e.jsx(ce,{}),h===a&&e.jsx("div",{ref:r,className:"h-1"})]},`posts-${l.id}`)),c&&e.jsx("li",{className:"flex flex-col items-center justify-center space-y-4 text-center",children:e.jsx(W,{size:"md"})})]}),e.jsx("div",{ref:t,className:"h-1"})]})},pe=({handle:s,isUserBlocked:o,isDomainBlocked:n,onUnblockUser:c,onUnblockDomain:x,trigger:d,onUnblockComplete:i,isOpen:r,onOpenChange:t})=>{const[a,m]=u.useState(!1),[l,h]=u.useState(()=>{const p=o&&n,N=o&&!n,F=!o&&n;let g="idle";return p?g="dual":N?g="userOnly":F&&(g="domainOnly"),{mode:g,userUnblocked:!1,domainUnblocked:!1}}),b=r!==void 0,k=b?r:a,[w,y]=u.useState(!1),M=u.useCallback(()=>{const p=o&&n,N=o&&!n,F=!o&&n;let g="idle";p?g="dual":N?g="userOnly":F&&(g="domainOnly"),h(C=>({...C,mode:g,userUnblocked:!1,domainUnblocked:!1}))},[o,n]);u.useEffect(()=>{k&&!w?(M(),y(!0)):k||y(!1)},[k,w,M]);const P=()=>{b?t?.(!0):m(!0)},f=p=>{p||(b?t?.(!1):m(!1))},I=async()=>{await c(),h(p=>({...p,userUnblocked:!0})),(l.mode!=="dual"||l.domainUnblocked)&&(f(!1),i?.()),U.success("User unblocked")},E=async()=>{await x(),h(p=>({...p,domainUnblocked:!0})),(l.mode!=="dual"||l.userUnblocked)&&(f(!1),i?.()),U.success("Domain unblocked")},T=s.split("@").filter(Boolean)[1],B=()=>e.jsxs(e.Fragment,{children:[e.jsxs(Q,{children:[e.jsx(Y,{className:"mb-1 flex flex-col gap-1",children:"Unblock"}),e.jsx(K,{className:"!mt-4",asChild:!0,children:e.jsxs("div",{className:"flex flex-col rounded-md border",children:[e.jsxs("div",{className:"flex justify-between gap-6 p-5",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(q,{children:"Unblock user"}),e.jsxs("p",{children:[e.jsx("span",{className:"font-semibold text-black",children:s})," will be able to follow you and engage with your public posts."]})]}),e.jsxs(j,{className:`gap-1 ${l.userUnblocked?"pointer-events-none border-green bg-green text-white hover:bg-green hover:text-white":"text-red hover:text-red-400"}`,variant:"outline",onClick:I,children:[e.jsx(Te,{}),l.userUnblocked?"User unblocked":"Unblock user"]})]}),e.jsx("div",{className:"border-t"}),e.jsxs("div",{className:"flex justify-between gap-6 p-5",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(q,{children:"Unblock domain"}),e.jsxs("p",{children:["Users from ",e.jsx("span",{className:"font-semibold text-black",children:T})," will be able to follow you and engage with your public posts."]})]}),e.jsxs(j,{className:`gap-1 ${l.domainUnblocked?"pointer-events-none border-green bg-green text-white hover:bg-green hover:text-white":"text-red hover:text-red-400"}`,variant:"outline",onClick:E,children:[e.jsx(Fe,{}),l.domainUnblocked?"Domain unblocked":"Unblock domain"]})]})]})})]}),e.jsx(G,{children:e.jsx(j,{onClick:()=>f(!1),children:"OK"})})]}),D=()=>{const p=l.mode==="userOnly";return e.jsxs(e.Fragment,{children:[e.jsxs(Q,{children:[e.jsx(Y,{className:"mb-1 flex flex-col gap-1",children:p?"Unblock this user?":"Unblock this domain?"}),e.jsx(K,{children:p?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-semibold text-black",children:s})," will be able to follow you and engage with your public posts."]}):e.jsxs(e.Fragment,{children:["Users from ",e.jsx("span",{className:"font-semibold text-black",children:T})," will be able to follow you and engage with your public posts."]})})]}),e.jsxs(G,{children:[e.jsx(me,{children:"Cancel"}),e.jsx(j,{onClick:p?I:E,children:"Unblock"})]})]})};return e.jsxs(de,{open:k,onOpenChange:f,children:[d&&e.jsx(Pe,{asChild:!0,onClick:P,children:d}),e.jsx(ue,{className:`${l.mode==="dual"&&"max-w-[600px]"}`,children:l.mode==="dual"?B():D()})]})},bs=({account:s,children:o,onCopyHandle:n,onBlockAccount:c,onBlockDomain:x,disabled:d=!1,isBlocked:i=!1,isDomainBlocked:r=!1})=>{const[t,a]=u.useState(null),[m,l]=u.useState(!1),h=f=>{f.stopPropagation(),n()},b=f=>{f.stopPropagation(),c()},k=f=>{f.stopPropagation(),x()},w=s?.handle,y=w?.split("@").filter(Boolean)[1],M=()=>e.jsx(de,{open:m,onOpenChange:l,children:e.jsxs(ue,{onClick:f=>f.stopPropagation(),children:[e.jsxs(Q,{children:[e.jsx(Y,{className:"mb-1 flex flex-col gap-1",children:t==="user"?"Block this user?":"Block this domain?"}),e.jsx(K,{children:t==="user"?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-semibold text-black",children:w})," will be able to see your public posts, but will no longer be able follow you or interact with your content on the social web."]}):e.jsxs(e.Fragment,{children:["All users from ",e.jsx("span",{className:"font-semibold text-black",children:y})," will be able to see your public posts, but won't be able to follow you or interact with your content."]})})]}),e.jsxs(G,{children:[t!=="domain"&&e.jsx(j,{className:"-ml-3 mr-auto hover:bg-transparent hover:opacity-80",variant:"ghost",onClick:f=>{f.stopPropagation(),a("domain")},children:"Block domain instead"}),e.jsx(me,{onClick:f=>f.stopPropagation(),children:"Cancel"}),e.jsx(Ee,{className:Se({variant:"destructive"}),onClick:t==="user"?b:k,children:"Block"})]})]})}),P=()=>s&&e.jsx(pe,{handle:s.handle,isDomainBlocked:s.domainBlockedByMe,isOpen:m,isUserBlocked:s.blockedByMe,onOpenChange:l,onUnblockDomain:x,onUnblockUser:c});return e.jsxs(e.Fragment,{children:[e.jsxs(Re,{children:[e.jsx(Oe,{disabled:d,asChild:!0,onClick:f=>f.stopPropagation(),children:o}),e.jsx(Ie,{align:"end",className:"p-2",children:e.jsxs("div",{className:"flex w-48 flex-col",children:[e.jsx(ne,{asChild:!0,children:e.jsx(j,{className:"justify-start",variant:"ghost",onClick:h,children:"Copy handle"})}),e.jsx(ne,{asChild:!0,children:e.jsx(j,{className:"justify-start text-red hover:bg-red/5 hover:text-red",variant:"ghost",onClick:f=>{f.stopPropagation(),!i&&!r&&a("user"),l(!0)},children:i?"Unblock user":r?"Unblock domain":"Block user"})})]})})]}),i||r?P():M()]})},gs=({account:s,onUnblock:o,onDomainUnblock:n,className:c=""})=>{const[x,d]=u.useState(!1),i=e.jsx(j,{className:`min-w-[90px] ${c}`,variant:"destructive",onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),children:x?"Unblock":"Blocked"});return e.jsx(pe,{handle:s.handle,isDomainBlocked:s.domainBlockedByMe,isUserBlocked:s.blockedByMe,trigger:i,onUnblockDomain:n,onUnblockUser:o})},re=()=>{},ks=({account:s,customFields:o,isLoadingAccount:n,postsTab:c,likesTab:x,followingTab:d,followersTab:i})=>{const r=xe(),t=Ae(),a=$(),{canGoBack:m}=$e(),l=r.handle?`/profile/${r.handle}`:"/profile",h=!r.handle,b=r.handle?r.tab||"":t.pathname.split("/").pop()||"",k=u.useMemo(()=>h?["likes","following","followers"]:["following","followers"],[h]),w=k.includes(b)?b:"posts",y=He("index"),M=Le("index"),P=Ve("index"),f=ze("index"),I=J("index","me"),{data:E}=r.handle?I:{data:void 0},T=r.handle===E?.handle||!r.handle,B=s?.blockedByMe,D=s?.domainBlockedByMe,[p,N]=u.useState(!1),[F,g]=u.useState(!1),C=u.useRef(null);u.useEffect(()=>()=>{C.current&&window.clearTimeout(C.current)},[]);const X=()=>{B?M.mutate(s):(y.mutate(s),U.success("User blocked")),N(!1)},Z=()=>{D?f.mutate({url:s.apId,handle:s.handle}):(P.mutate({url:s.apId,handle:s.handle}),U.success("Domain blocked")),N(!1)},ee=async()=>{if(!s?.handle||!navigator?.clipboard?.writeText){U.error("Unable to copy handle");return}try{await navigator.clipboard.writeText(s.handle),g(!0),U.success("Handle copied"),C.current&&window.clearTimeout(C.current),C.current=window.setTimeout(()=>g(!1),2e3)}catch{U.error("Failed to copy handle"),g(!1)}},[R,je]=u.useState(!1),[be,se]=u.useState(!1),ge=()=>{je(!R)},V=u.useRef(null),[le,ke]=u.useState(!1);u.useEffect(()=>{V.current&&ke(V.current.scrollHeight>160)},[R,s?.bio,o,n]),u.useEffect(()=>{b&&(k.includes(b)||a(l,{replace:!0}))},[k,l,a,b]);const we=v=>v==="posts"?l:`${l}/${v}`,ve=v=>{v!==w&&a(we(v),{replace:!0})};return!n&&!s?e.jsx(te,{children:e.jsx("div",{className:"mx-auto mt-4 flex w-full max-w-[620px] flex-col items-center [&_svg]:translate-x-px",children:e.jsxs(_e,{children:[e.jsx(Qe,{children:e.jsx(xs,{})}),e.jsx("div",{children:"Profile not found"})]})})}):e.jsx(te,{children:e.jsx("div",{className:"z-0 mx-[max(-4vw,-32px)] -mt-9 flex flex-col items-center pb-16",children:e.jsx("div",{className:"mx-auto w-full",children:e.jsxs(e.Fragment,{children:[s?.bannerImageUrl?e.jsx("div",{className:"h-[15vw] min-h-[200px] w-full overflow-hidden bg-gradient-to-tr from-gray-200 to-gray-100",children:e.jsx("img",{alt:s?.name,className:"size-full object-cover",referrerPolicy:"no-referrer",src:s?.bannerImageUrl})}):e.jsx("div",{className:"h-[max(8vw,132px)] w-full overflow-hidden bg-gradient-to-tr from-white to-white dark:from-black dark:to-black"}),e.jsxs("div",{className:`mx-auto max-w-[620px] px-6 ${!s?.bannerImageUrl&&!m?"-mt-8":"-mt-12"}`,children:[e.jsxs("div",{className:"flex items-end justify-between",children:[e.jsx("div",{className:"-ml-2 rounded-full bg-white p-1 dark:bg-black",children:n?e.jsx(O,{className:"size-[92px] rounded-full"}):e.jsx(oe,{author:{icon:{url:s?.avatarUrl},name:s?.name,handle:s?.handle},size:"lg"})}),!T&&!n&&e.jsxs("div",{className:"flex gap-2",children:[B||D?e.jsx(gs,{account:s,onDomainUnblock:Z,onUnblock:X}):e.jsx(ae,{following:s?.followedByMe,handle:s?.handle,type:"primary",onFollow:re,onUnfollow:re}),e.jsx(bs,{account:s,isBlocked:B,isDomainBlocked:D,onBlockAccount:X,onBlockDomain:Z,onCopyHandle:ee,children:e.jsx(j,{"aria-label":"Open profile menu",variant:"outline",children:e.jsx(Ye,{})})})]}),T&&!n&&e.jsxs(Ke,{open:be,onOpenChange:se,children:[e.jsx(qe,{children:e.jsx(ms,{children:e.jsx(j,{variant:"secondary",children:"Edit profile"})})}),e.jsxs(Ge,{className:"w-full max-w-[520px]",onOpenAutoFocus:v=>v.preventDefault(),children:[e.jsx(Je,{children:e.jsx(We,{children:"Profile settings"})}),s&&e.jsx(cs,{account:s,setIsEditingProfile:se})]})]})]}),e.jsx(Xe,{className:"mt-4 truncate break-anywhere",children:n?e.jsx(O,{className:"w-32"}):s?.name}),e.jsxs("div",{className:"mb-4 flex items-center gap-2",children:[e.jsx("a",{className:"inline-flex max-w-full truncate text-[1.5rem] text-gray-800 hover:text-gray-900 dark:text-gray-600 dark:hover:text-gray-500",href:s?.url,rel:"noopener noreferrer",target:"_blank",children:e.jsx("span",{className:"truncate",children:n?e.jsx(O,{className:"w-full max-w-56"}):s?.handle})}),!n&&e.jsx(j,{className:"-ml-1.5 size-6 p-0 text-gray-800 hover:text-gray-900 dark:text-gray-700 dark:hover:text-gray-600",title:"Copy handle",variant:"link",onClick:ee,children:F?e.jsx(Ze,{size:16}):e.jsx(fs,{size:16})}),s?.followsMe&&!n&&e.jsx(es,{className:"mt-px whitespace-nowrap",variant:"secondary",children:"Follows you"})]}),(s?.bio||o?.length>0)&&e.jsxs("div",{ref:V,className:`ap-profile-content relative text-[1.5rem] break-anywhere [&>p]:mb-3 ${R?"max-h-none pb-7":"max-h-[160px] overflow-hidden"} relative`,children:[n?e.jsxs(e.Fragment,{children:[e.jsx(O,{}),e.jsx(O,{className:"w-full max-w-48"})]}):e.jsx("div",{dangerouslySetInnerHTML:{__html:ss(ls(s?.bio??"",["a","br"]))}}),o?.map(v=>e.jsxs("span",{className:"mt-3 line-clamp-1 flex flex-col text-[1.5rem]",children:[e.jsx("span",{className:"text-xs font-semibold",children:v.name}),e.jsx("span",{dangerouslySetInnerHTML:{__html:v.value},className:"ap-profile-content truncate"})]})),!R&&le&&e.jsx("div",{className:"absolute inset-x-0 bottom-0 h-16 bg-gradient-to-t from-white via-white/100 via-60% to-transparent dark:from-black dark:via-black/100"}),le&&e.jsx(j,{className:"absolute bottom-0 h-auto p-0 text-md",variant:"link",onClick:ge,children:R?"Show less":"Show all"})]}),e.jsxs(ds,{className:"mt-5",value:w,variant:"underline",onValueChange:v=>ve(v),children:[e.jsxs(us,{children:[e.jsx(S,{value:"posts",children:"Posts"}),h&&e.jsxs(S,{value:"likes",children:["Likes",e.jsx(_,{children:z(s?.likedCount||0)})]}),e.jsxs(S,{value:"following",children:["Following",e.jsx(_,{children:z(s?.followingCount||0)})]}),e.jsxs(S,{value:"followers",children:["Followers",e.jsx(_,{children:z(s?.followerCount||0)})]})]}),e.jsx(A,{value:"posts",children:(B||D)&&!p?e.jsxs(H,{children:[e.jsx(L,{children:e.jsx(ns,{})}),e.jsxs("div",{className:"mt-2 flex flex-col items-center gap-0.5",children:[e.jsxs(q,{children:[s.name," is blocked"]}),e.jsx("p",{children:"You can view the posts, but it won't unblock the user."}),e.jsx(j,{className:"mt-4",variant:"secondary",onClick:()=>N(!0),children:"View posts"})]})]}):c}),h&&e.jsx(A,{value:"likes",children:x}),e.jsx(A,{value:"following",children:d}),e.jsx(A,{value:"followers",children:i})]},r.handle||s?.handle||"current-user")]})]})})})})},ws=({handle:s})=>{const{postsByAccountQuery:o}=os(s||"me",{enabled:!0}),{data:n,fetchNextPage:c,hasNextPage:x,isFetchingNextPage:d,isLoading:i}=o,r=n?.pages.flatMap(t=>t.posts)??Array.from({length:5},(t,a)=>({id:`placeholder-${a}`,object:{}}));return e.jsx(js,{fetchNextPage:c,hasNextPage:x,isFetchingNextPage:d,isLoading:i,noResultsMessage:s?`${s} hasn't posted anything yet`:"You haven't posted anything yet.",posts:r})},vs=()=>{const{postsLikedByAccountQuery:s}=as({enabled:!0}),{data:o,fetchNextPage:n,hasNextPage:c,isFetchingNextPage:x,isLoading:d}=s,i=o?.pages.flatMap(r=>r.posts)??Array.from({length:5},(r,t)=>({id:`placeholder-${t}`,object:{}}));return e.jsx(ps,{fetchNextPage:n,hasNextPage:c,isFetchingNextPage:x,isLoading:d,posts:i})},ys=({handle:s})=>{const o=fe(s===""?"me":s,"following"),{data:n,fetchNextPage:c,hasNextPage:x,isFetchingNextPage:d,isLoading:i}=o,r=n?.pages.flatMap(t=>"following"in t?t.following:"accounts"in t?t.accounts.map(a=>({actor:{id:a.id,name:a.name,handle:a.handle,icon:{url:a.avatarUrl}},isFollowing:a.isFollowing,blockedByMe:a.blockedByMe,domainBlockedByMe:a.domainBlockedByMe})):[])??[];return e.jsx(he,{actors:r,fetchNextPage:c,hasNextPage:x,isFetchingNextPage:d,isLoading:i,noResultsMessage:`${s||"You"} have no following`})},Ns=({handle:s})=>{const o=fe(s===""?"me":s,"followers"),{data:n,fetchNextPage:c,hasNextPage:x,isFetchingNextPage:d,isLoading:i}=o,r=n?.pages.flatMap(t=>"followers"in t?t.followers:"accounts"in t?t.accounts.map(a=>({actor:{id:a.id,name:a.name,handle:a.handle,icon:{url:a.avatarUrl}},isFollowing:a.isFollowing})):[])??[];return e.jsx(he,{actors:r,fetchNextPage:c,hasNextPage:x,isFetchingNextPage:d,isLoading:i,noResultsMessage:`${s||"You"} have no followers yet`})},qs=({})=>{const s=xe(),{data:o,isLoading:n,error:c,refetch:x}=J("index",s.handle||"me");if(u.useEffect(()=>{x()},[s.handle,x]),c&&ts(c)&&c.statusCode!==404)return e.jsx(rs,{errorCode:c.code,statusCode:c.statusCode});const d=Object.keys(o?.customFields||{}).map(m=>({name:m,value:o.customFields[m]}))||[],i=e.jsx(ws,{handle:s.handle||""}),r=e.jsx(vs,{}),t=e.jsx(ys,{handle:s.handle||""}),a=e.jsx(Ns,{handle:s.handle||""});return e.jsx(ks,{account:o,customFields:d,followersTab:a,followingTab:t,isLoadingAccount:n,likesTab:r,postsTab:i})};export{qs as default};
@@ -1 +1 @@
1
- import{r as v,aq as N,ar as P,j as u,as as S,at as w,au as p,av as x,aw as F,ax as D,ay as T,az as V}from"./index-DCTdAEHx.js";var g="Tabs",[G]=S(g,[x]),C=x(),[L,m]=G(g),h=v.forwardRef((e,n)=>{const{__scopeTabs:i,value:a,onValueChange:r,defaultValue:c,orientation:t="horizontal",dir:d,activationMode:b="automatic",...f}=e,s=N(d),[o,l]=P({prop:a,onChange:r,defaultProp:c??"",caller:g});return u.jsx(L,{scope:i,baseId:w(),value:o,onValueChange:l,orientation:t,dir:s,activationMode:b,children:u.jsx(p.div,{dir:s,"data-orientation":t,...f,ref:n})})});h.displayName=g;var I="TabsList",R=v.forwardRef((e,n)=>{const{__scopeTabs:i,loop:a=!0,...r}=e,c=m(I,i),t=C(i);return u.jsx(F,{asChild:!0,...t,orientation:c.orientation,dir:c.dir,loop:a,children:u.jsx(p.div,{role:"tablist","aria-orientation":c.orientation,...r,ref:n})})});R.displayName=I;var y="TabsTrigger",_=v.forwardRef((e,n)=>{const{__scopeTabs:i,value:a,disabled:r=!1,...c}=e,t=m(y,i),d=C(i),b=j(t.baseId,a),f=M(t.baseId,a),s=a===t.value;return u.jsx(D,{asChild:!0,...d,focusable:!r,active:s,children:u.jsx(p.button,{type:"button",role:"tab","aria-selected":s,"aria-controls":f,"data-state":s?"active":"inactive","data-disabled":r?"":void 0,disabled:r,id:b,...c,ref:n,onMouseDown:T(e.onMouseDown,o=>{!r&&o.button===0&&o.ctrlKey===!1?t.onValueChange(a):o.preventDefault()}),onKeyDown:T(e.onKeyDown,o=>{[" ","Enter"].includes(o.key)&&t.onValueChange(a)}),onFocus:T(e.onFocus,()=>{const o=t.activationMode!=="manual";!s&&!r&&o&&t.onValueChange(a)})})})});_.displayName=y;var A="TabsContent",E=v.forwardRef((e,n)=>{const{__scopeTabs:i,value:a,forceMount:r,children:c,...t}=e,d=m(A,i),b=j(d.baseId,a),f=M(d.baseId,a),s=a===d.value,o=v.useRef(s);return v.useEffect(()=>{const l=requestAnimationFrame(()=>o.current=!1);return()=>cancelAnimationFrame(l)},[]),u.jsx(V,{present:r||s,children:({present:l})=>u.jsx(p.div,{"data-state":s?"active":"inactive","data-orientation":d.orientation,role:"tabpanel","aria-labelledby":b,hidden:!l,id:f,tabIndex:0,...t,ref:n,style:{...e.style,animationDuration:o.current?"0s":void 0},children:l&&c})})});E.displayName=A;function j(e,n){return`${e}-trigger-${n}`}function M(e,n){return`${e}-content-${n}`}var k=h,K=R,q=_,z=E;export{z as C,K as L,k as R,q as T};
1
+ import{r as v,aq as N,ar as P,j as u,as as S,at as w,au as p,av as x,aw as F,ax as D,ay as T,az as V}from"./index-Bgo4hw-T.js";var g="Tabs",[G]=S(g,[x]),C=x(),[L,m]=G(g),h=v.forwardRef((e,n)=>{const{__scopeTabs:i,value:a,onValueChange:r,defaultValue:c,orientation:t="horizontal",dir:d,activationMode:b="automatic",...f}=e,s=N(d),[o,l]=P({prop:a,onChange:r,defaultProp:c??"",caller:g});return u.jsx(L,{scope:i,baseId:w(),value:o,onValueChange:l,orientation:t,dir:s,activationMode:b,children:u.jsx(p.div,{dir:s,"data-orientation":t,...f,ref:n})})});h.displayName=g;var I="TabsList",R=v.forwardRef((e,n)=>{const{__scopeTabs:i,loop:a=!0,...r}=e,c=m(I,i),t=C(i);return u.jsx(F,{asChild:!0,...t,orientation:c.orientation,dir:c.dir,loop:a,children:u.jsx(p.div,{role:"tablist","aria-orientation":c.orientation,...r,ref:n})})});R.displayName=I;var y="TabsTrigger",_=v.forwardRef((e,n)=>{const{__scopeTabs:i,value:a,disabled:r=!1,...c}=e,t=m(y,i),d=C(i),b=j(t.baseId,a),f=M(t.baseId,a),s=a===t.value;return u.jsx(D,{asChild:!0,...d,focusable:!r,active:s,children:u.jsx(p.button,{type:"button",role:"tab","aria-selected":s,"aria-controls":f,"data-state":s?"active":"inactive","data-disabled":r?"":void 0,disabled:r,id:b,...c,ref:n,onMouseDown:T(e.onMouseDown,o=>{!r&&o.button===0&&o.ctrlKey===!1?t.onValueChange(a):o.preventDefault()}),onKeyDown:T(e.onKeyDown,o=>{[" ","Enter"].includes(o.key)&&t.onValueChange(a)}),onFocus:T(e.onFocus,()=>{const o=t.activationMode!=="manual";!s&&!r&&o&&t.onValueChange(a)})})})});_.displayName=y;var A="TabsContent",E=v.forwardRef((e,n)=>{const{__scopeTabs:i,value:a,forceMount:r,children:c,...t}=e,d=m(A,i),b=j(d.baseId,a),f=M(d.baseId,a),s=a===d.value,o=v.useRef(s);return v.useEffect(()=>{const l=requestAnimationFrame(()=>o.current=!1);return()=>cancelAnimationFrame(l)},[]),u.jsx(V,{present:r||s,children:({present:l})=>u.jsx(p.div,{"data-state":s?"active":"inactive","data-orientation":d.orientation,role:"tabpanel","aria-labelledby":b,hidden:!l,id:f,tabIndex:0,...t,ref:n,style:{...e.style,animationDuration:o.current?"0s":void 0},children:l&&c})})});E.displayName=A;function j(e,n){return`${e}-trigger-${n}`}function M(e,n){return`${e}-content-${n}`}var k=h,K=R,q=_,z=E;export{z as C,K as L,k as R,q as T};
@@ -1 +1 @@
1
- import{aP as K,r as A,bV as L,bW as W,j as e,S as N,bO as se,B as T,aT as M,aj as m,y as D,ai as Q,cz as te,aQ as le,cA as H,e as ce,cB as q,cC as de,bB as me,cD as J,bH as ue,cE as pe,af as xe,ag as z,aW as U,_ as he,bS as ge}from"./index-DCTdAEHx.js";import{g as S,S as fe,a as be,D as je,b as ve}from"./stats-view-BJVawuIv.js";import{C as E,a as $,b as F,f as V,c as I,E as Ne,K as we,d as ye,e as ke,u as _e,j as Ce}from"./pagemenu-Cd45frnF.js";import{E as Y}from"./empty-indicator-C6BBh99D.js";import{P as Ae}from"./post-share-modal-D1JQfuYx.js";import{g as Le,c as Te}from"./post-helpers-gInwAwEv.js";import{g as ae,a as ze}from"./audience-Cy9gLIa9.js";import{S as Me,P as We,U as re}from"./wallet-cards-ddLuIN-b.js";import{C as De,h as P,d as Ee,i as $e,L as Fe,j as X,k as Z,l as Ve}from"./lucide-react-DtMIZssr.js";import{G as B}from"./gh-chart-D9KI0_sO.js";import{u as Ie}from"./use-growth-stats-BrLZI7da.js";import{u as Re}from"./posts-DFiJPOft.js";import{h as Ue,i as Be}from"./stats-lnFiOQZx.js";import"./select-WwMsbBbg.js";import"./message-square-text-BDZtUW-2.js";import"./sprout-DRqlFJSK.js";import"./a-large-small-p58xibEK.js";import"./at-sign-BZPuAx5m.js";import"./copy-Bi7VpgPR.js";import"./hash-DFhnGHId.js";import"./inbox-p-Y5uScT.js";import"./list-filter-3EF6cVg-.js";import"./minus-CSphShdJ.js";import"./tags-CKrBptuC.js";import"./square-CwHQ9sJ2.js";import"./user-round-check-zOuzV3OS.js";import"./repeat-Smml9n0k.js";import"./reply-CooY4lmk.js";import"./trash-CJY1Wro_.js";import"./chart--RFLGIL4.js";import"./_baseAssignValue-Bwn07Ln5.js";import"./currency-fEUUCkj0.js";const Ge=s=>s.email_only?"Sent":s.email?"Published and sent":"Published",Oe=({latestPostStats:s,isLoading:n})=>{const t=K(),[r,i]=A.useState(!1),{site:c,settings:p}=L(),{appSettings:l}=W(),{emailTrackClicks:o,emailTrackOpens:h,webAnalytics:d=!1,membersTrackSources:v=!1}=l?.analytics||{},a=c.title||String(p.find(j=>j.key==="title")?.value||"Ghost Site"),x=String(p.find(j=>j.key==="timezone")?.value||"Etc/UTC"),f=s?Le(s,{membersTrackSources:v}):null,b="group mr-2 flex flex-col gap-1.5 hover:cursor-pointer",y=!!s?.email,_=ae({postId:s?.id,hasEmailData:y,analytics:{webAnalytics:d,membersTrackSources:v}}),w=_.startsWith("/editor/");return e.jsxs(E,{className:"group/card bg-gradient-to-tr from-muted/40 to-muted/0 to-50%","data-testid":"latest-post",children:[e.jsxs($,{children:[e.jsx(F,{className:"flex items-baseline justify-between font-medium leading-snug text-muted-foreground",children:"Latest post performance"}),e.jsx(V,{className:"hidden",children:"How your last post did"})]}),e.jsxs(I,{className:"flex flex-col gap-6 px-0 lg:flex-row xl:grid xl:grid-cols-3",children:[n&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex w-full items-center gap-6 px-6 xl:col-span-2",children:[e.jsx("div",{className:"w-full max-w-[232px] grow",children:e.jsx(N,{className:"aspect-[16/10] rounded-md"})}),e.jsxs("div",{className:"w-full grow",children:[e.jsx(N,{className:"w-full max-w-[420px]"}),e.jsx(N,{className:"w-1/2"})]})]}),e.jsx("div",{className:"flex flex-col items-stretch gap-2 px-6 text-sm",children:e.jsxs("div",{className:"grid grid-cols-2 gap-5",children:[e.jsxs("div",{children:[e.jsx(N,{className:"w-3/4"}),e.jsx(N,{className:"h-10 w-1/3"})]}),e.jsxs("div",{children:[e.jsx(N,{className:"w-3/4"}),e.jsx(N,{className:"h-10 w-1/3"})]}),e.jsxs("div",{children:[e.jsx(N,{className:"w-3/4"}),e.jsx(N,{className:"h-10 w-1/3"})]}),e.jsxs("div",{children:[e.jsx(N,{className:"w-3/4"}),e.jsx(N,{className:"h-10 w-1/3"})]})]})})]}),!n&&s&&f?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col gap-6 px-6 transition-all md:flex-row md:items-start xl:col-span-2",children:[s.feature_image&&e.jsx("div",{className:"aspect-[16/10] w-full min-w-[100px] rounded-sm bg-cover bg-center sm:max-w-[170px] lg:max-w-[170px] xl:max-w-[232px]",style:{backgroundImage:`url(${s.feature_image})`}}),e.jsxs("div",{className:"flex grow flex-col items-start justify-center self-stretch",children:[e.jsx("div",{className:"text-lg font-semibold leading-tighter tracking-tight hover:cursor-pointer hover:opacity-75",onClick:()=>{!n&&s&&t(_,{crossApp:!0})},children:s.title}),e.jsxs("div",{className:"mt-0.5 text-sm text-muted-foreground",children:[s.authors&&s.authors.length>0&&e.jsxs("div",{children:["By ",s.authors.map(j=>j.name).join(", ")," – ",se(s.published_at,x)]}),e.jsx("div",{className:"mt-0.5",children:Ge(s)})]}),e.jsxs("div",{className:"mt-6 flex items-center gap-2",children:[!s.email_only&&e.jsx(Ae,{author:s.authors?.map(j=>j.name).join(", ")||"",description:"",faviconURL:c.icon||"",featureImageURL:s.feature_image||"",open:r,postExcerpt:s.excerpt||"",postTitle:s.title,postURL:s.url||"",siteTitle:a,onClose:()=>i(!1),onOpenChange:i,children:e.jsxs(T,{onClick:()=>i(!0),children:[e.jsx(Me,{})," Share post"]})}),e.jsx(T,{className:s.email_only?"w-full":"",variant:"outline",onClick:()=>{t(_,{crossApp:!0})},children:w?e.jsxs(e.Fragment,{children:[e.jsx(We,{}),e.jsx("span",{className:"hidden md:!visible md:!block",children:"Edit post"})]}):e.jsxs(e.Fragment,{children:[e.jsx(De,{}),e.jsx("span",{className:"hidden md:!visible md:!block",children:s.email_only?"Post analytics":"Analytics"})]})})]})]})]}),e.jsx("div",{className:"-ml-4 flex w-full flex-col items-stretch gap-2 pr-6 text-sm xl:h-full xl:max-w-none",children:e.jsxs("div",{className:"grid grid-cols-2 gap-6 pl-10 lg:border-l xl:h-full",children:[f.showWebMetrics&&d&&e.jsxs("div",{className:b,"data-testid":"latest-post-visitors",onClick:()=>{t(`/posts/analytics/${s.id}/web`,{crossApp:!0})},children:[e.jsxs("div",{className:"flex items-center gap-1.5 font-medium text-muted-foreground transition-all group-hover:text-foreground",children:[e.jsx(M,{size:16,strokeWidth:1.25}),e.jsx("span",{className:"hidden md:!visible md:!block",children:"Visitors"})]}),e.jsx("span",{className:"text-[2.2rem] font-semibold leading-none tracking-tighter",children:m(s.visitors)})]}),f.showMemberGrowth&&e.jsxs("div",{className:D(b,f.showEmailMetrics&&(!f.showWebMetrics||!d)&&"row-[2/3] col-[1/2]"),"data-testid":"latest-post-members",onClick:()=>{t(`/posts/analytics/${s.id}/growth`,{crossApp:!0})},children:[e.jsxs("div",{className:"flex items-center gap-1.5 font-medium text-muted-foreground transition-all group-hover:text-foreground",children:[e.jsx(re,{size:16,strokeWidth:1.25}),e.jsx("span",{className:"hidden md:!visible md:!block",children:"Members"})]}),e.jsx("span",{className:"text-[2.2rem] font-semibold leading-none tracking-tighter",children:s.member_delta?e.jsxs(e.Fragment,{children:["+",m(s.member_delta)]}):0})]}),f.showEmailMetrics&&s.email&&e.jsxs(e.Fragment,{children:[h&&e.jsxs("div",{className:b,onClick:()=>{t(`/posts/analytics/${s.id}/newsletter`,{crossApp:!0})},children:[e.jsxs("div",{className:"flex items-center gap-1.5 font-medium text-muted-foreground transition-all group-hover:text-foreground",children:[e.jsx(P,{size:16,strokeWidth:1.25}),e.jsx("span",{className:"hidden whitespace-nowrap md:!visible md:!block",children:"Opens"})]}),e.jsx("span",{className:"text-[2.2rem] font-semibold leading-none tracking-tighter",children:s.email.email_count?Q((s.email.opened_count||0)/s.email.email_count):"0%"})]}),o&&e.jsxs("div",{className:b,onClick:()=>{t(`/posts/analytics/${s.id}/newsletter`,{crossApp:!0})},children:[e.jsxs("div",{className:"flex items-center gap-1.5 font-medium text-muted-foreground transition-all group-hover:text-foreground",children:[e.jsx(Ee,{size:16,strokeWidth:1.25}),e.jsx("span",{className:"hidden whitespace-nowrap md:!visible md:!block",children:"Clicks"})]}),e.jsx("span",{className:"text-[2.2rem] font-semibold leading-none tracking-tighter",children:s.email.email_count&&s.count?.clicks?Q((s.count.clicks||0)/s.email.email_count):"0%"})]})]})]})})]}):!n&&e.jsx(Y,{actions:e.jsx(T,{variant:"secondary",onClick:()=>{t("/editor/post",{crossApp:!0})},children:"New post"}),className:"w-full pb-10 xl:col-span-3",description:"Once it's live, you can track performance here",title:"Publish your first post",children:e.jsx(te,{strokeWidth:1.5})})]})]})},He=()=>{const{data:s}=L();return{isLimited:t=>{const r=s?.config;return r?.hostSettings?.limits&&t==="limitAnalytics"?r.hostSettings.limits.limitAnalytics?.disabled===!0:!1}}},G=({title:s,iconName:n,description:t,color:r,diffDirection:i,diffValue:c,formattedValue:p,trendingFromValue:l,children:o,onClick:h})=>{const{range:d}=L(),v=n&&Fe[n],a=ce.useMemo(()=>{if(!i||i==="empty"||d===q.allTime.value||!c)return"";const x=i==="up"?"up":i==="down"?"down":"at",b=S(d).replace("in the ","").replace(/^\(|\)$/g,"");return i==="same"?e.jsxs("span",{children:["You're trending at the same level as ",e.jsx("span",{className:"font-semibold",children:p})," compared to the ",e.jsx("span",{className:"font-semibold",children:b})]}):e.jsxs("span",{children:["You're trending ",e.jsxs("span",{className:"font-semibold",children:[x," ",c]})," from ",e.jsx("span",{className:"font-semibold",children:l})," compared to the ",b]})},[i,c,l,p,d]);return e.jsxs(E,{className:"group","data-testid":s,children:[e.jsxs($,{className:"hidden",children:[e.jsx(F,{children:s}),e.jsx(V,{children:t})]}),e.jsxs(we,{className:"relative flex grow flex-row items-start justify-between gap-5 border-none pb-2 xl:pb-4",children:[e.jsxs("div",{className:"flex grow flex-col gap-1.5 border-none pb-0",children:[e.jsxs(ye,{className:h&&"transition-all group-hover:text-foreground",children:[r&&e.jsx("span",{className:"inline-block size-2 rounded-full opacity-50",style:{backgroundColor:r}}),v&&e.jsx(v,{size:16,strokeWidth:1.5}),s]}),e.jsx(ke,{diffDirection:d===q.allTime.value?"hidden":i,diffTooltip:a,diffValue:c,value:p})]}),h&&e.jsx(T,{className:"absolute right-6 translate-x-10 opacity-0 transition-all duration-200 group-hover:translate-x-0 group-hover:opacity-100",size:"sm",variant:"outline",onClick:h,children:"View more"})]}),e.jsx(I,{children:o})]})},Se=({kpiValues:s,visitorsChartData:n,visitorsYRange:t,growthTotals:r,membersChartData:i,mrrChartData:c,currencySymbol:p,isLoading:l})=>{const o=K(),{range:h}=L(),{appSettings:d}=W(),a=He().isLimited("limitAnalytics"),x="-mb-3 h-[10vw] max-h-[200px] min-h-[100px] hover:!cursor-pointer";if(l)return e.jsx(Ne,{className:"flex h-[calc(10vw+116px)] max-h-[416px] min-h-20 items-center justify-center hover:!cursor-pointer",children:e.jsx(le,{})});const f=d?.analytics.webAnalytics,b=a&&!f,y=!0,_=d?.paidMembersEnabled,w=[f,b,y,_].filter(Boolean).length;let j="lg:grid-cols-3";w===2?j="lg:grid-cols-2":w===1&&(j="lg:grid-cols-1");const R=`flex flex-col lg:grid ${j} gap-6`;return e.jsxs("div",{className:R,children:[f&&!b&&e.jsx(G,{description:"Number of individual people who visited your website",diffDirection:"empty",formattedValue:s.visits,iconName:"Globe",linkto:"/analytics/web/",title:"Unique visitors",onClick:()=>{o("/analytics/web/")},children:e.jsx(B,{className:x,color:"hsl(var(--chart-blue))",data:n,id:"visitors",range:h,showHorizontalLines:!0,showYAxisValues:!1,syncId:"overview-charts",yAxisRange:t})}),b&&e.jsxs(E,{children:[e.jsxs($,{className:"hidden",children:[e.jsx(F,{children:"Unlock web analytics"}),e.jsx(V,{children:"Get the full picture of what's working with detailed, cookie-free traffic analytics."})]}),e.jsx(I,{className:"flex h-full items-center justify-center p-6",children:e.jsx(Y,{actions:e.jsx(T,{variant:"outline",onClick:()=>o("/pro",{crossApp:!0}),children:"Upgrade now"}),className:"py-10",description:"Get the full picture of what's working with detailed, cookie-free traffic analytics.",title:"Unlock web analytics",children:e.jsx($e,{})})})]}),e.jsx(G,{description:"How number of members of your publication changed over time",diffDirection:r.directions.total,diffValue:r.percentChanges.total,formattedValue:m(r.totalMembers),iconName:"User",linkto:"/analytics/growth/",title:"Members",trendingFromValue:`${m(i[0].value)}`,onClick:()=>{o("/analytics/growth/?tab=total-members")},children:e.jsx(B,{className:x,color:"hsl(var(--chart-darkblue))",data:i,id:"members",range:h,showHorizontalLines:!0,showYAxisValues:!1,syncId:"overview-charts"})}),_&&e.jsx(G,{description:"Monthly recurring revenue changes over time",diffDirection:r.directions.mrr,diffValue:r.percentChanges.mrr,formattedValue:`${p}${m(H(r.mrr))}`,iconName:"Coins",linkto:"/analytics/growth/",title:"MRR",trendingFromValue:`${p}${m(c[0].value)}`,onClick:()=>{o("/analytics/growth/?tab=mrr")},children:e.jsx(B,{className:x,color:"hsl(var(--chart-teal))",data:c,id:"mrr",range:h,showHorizontalLines:!0,showYAxisValues:!1,syncId:"overview-charts"})})]})},Pe=({className:s})=>e.jsx("div",{className:D("rounded-sm bg-muted dark:bg-[#36373a] flex flex-col items-center justify-center gap-1 p-6",s),children:e.jsx(de,{className:"text-muted-foreground/50",size:18,strokeWidth:1.5})}),O=({className:s,metrics:n,title:t})=>e.jsx(e.Fragment,{children:e.jsxs("div",{className:D("pointer-events-none absolute bottom-[calc(100%+2px)] left-1/2 z-50 min-w-[160px] -translate-x-1/2 rounded-md bg-background p-3 text-sm opacity-0 shadow-md transition-all group-hover/tooltip:bottom-[calc(100%+12px)] group-hover/tooltip:opacity-100",s),children:[e.jsx("div",{className:"mb-1.5 whitespace-nowrap border-b pb-1.5 pr-10 font-medium text-muted-foreground",children:t}),e.jsx("div",{className:"flex flex-col gap-1.5",children:n?.map(r=>e.jsxs("div",{className:"flex items-center justify-between gap-5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 whitespace-nowrap",children:[r.icon,r.label]}),e.jsx("span",{className:"font-mono",children:r.metric})]},r.label))})]})}),Ke=({topPostsData:s,isLoading:n})=>{const t=K(),{range:r,settings:i}=L(),{appSettings:c}=W(),p=String(i.find(a=>a.key==="timezone")?.value||"Etc/UTC"),{webAnalytics:l=!1,membersTrackSources:o=!1,emailTrackClicks:h=!1,emailTrackOpens:d=!1}=c?.analytics||{},v="flex items-center justify-end gap-1 rounded-md px-2 py-1 font-mono text-gray-800 hover:bg-muted-foreground/10 group-hover:text-foreground";return e.jsxs(E,{className:"group/card w-full lg:col-span-2","data-testid":"top-posts-card",children:[e.jsxs($,{children:[e.jsxs(F,{className:"flex items-baseline justify-between font-medium leading-snug text-muted-foreground",children:["Top posts ",S(r)]}),e.jsx(V,{className:"hidden",children:"Most viewed posts in this period"})]}),e.jsx(I,{children:n?e.jsx(me,{className:"mt-6"}):e.jsxs(e.Fragment,{children:[s?.stats?.map(a=>e.jsxs("div",{className:'group relative flex w-full items-start justify-between gap-5 border-t border-border/50 py-4 before:absolute before:-inset-x-4 before:inset-y-0 before:z-0 before:hidden before:rounded-md before:bg-accent before:opacity-80 before:content-[""] first:!border-border hover:cursor-pointer hover:border-transparent hover:before:block md:items-center dark:before:bg-accent/50 [&+div]:hover:border-transparent',children:[e.jsxs("div",{className:"z-10 flex min-w-[160px] grow items-start gap-4 md:items-center lg:min-w-[320px]",onClick:()=>{t(ae({postId:a.post_id,hasEmailData:a.sent_count!==null,analytics:{webAnalytics:l,membersTrackSources:o}}),{crossApp:!0})},children:[a.feature_image?e.jsx("div",{className:"hidden aspect-[16/10] w-[80px] shrink-0 rounded-sm bg-cover bg-center sm:!visible sm:!block lg:w-[100px]",style:{backgroundImage:`url(${a.feature_image})`}}):e.jsx(Pe,{className:"hidden aspect-[16/10] w-[80px] shrink-0 group-hover:bg-muted-foreground/10 sm:!visible sm:!flex lg:w-[100px]"}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"line-clamp-2 text-lg font-semibold leading-[1.35em]",children:a.title}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["By ",a.authors," – ",se(a.published_at,p)]}),e.jsx("span",{className:"text-sm text-muted-foreground",children:Te(a)})]})]}),e.jsxs("div",{className:"z-10 flex flex-col items-end justify-center gap-0.5 text-sm md:flex-row md:items-center md:justify-end md:gap-3",children:[l&&e.jsxs("div",{className:"group/tooltip relative flex w-[66px] lg:w-[92px]","data-testid":"statistics-visitors",onClick:x=>{x.stopPropagation(),t(`/posts/analytics/${a.post_id}/web`,{crossApp:!0})},children:[e.jsx(O,{metrics:[{icon:e.jsx(M,{className:"shrink-0 text-muted-foreground",size:16,strokeWidth:1.5}),label:"Unique visitors",metric:m(a.views)}],title:"Web traffic"}),e.jsxs("div",{className:v,children:[e.jsx(M,{className:"text-muted-foreground group-hover:text-foreground",size:16,strokeWidth:1.5}),J(a.views)]})]}),a.sent_count!==null&&e.jsxs("div",{className:"group/tooltip relative flex w-[66px] lg:w-[92px]",onClick:x=>{x.stopPropagation(),t(`/posts/analytics/${a.post_id}/newsletter`,{crossApp:!0})},children:[e.jsx(O,{className:`${o?"":"left-auto right-0 translate-x-0"}`,metrics:[{icon:e.jsx(X,{className:"shrink-0 text-muted-foreground",size:16,strokeWidth:1.5}),label:"Sent",metric:m(a.sent_count||0)},...d?[{icon:e.jsx(P,{className:"shrink-0 text-muted-foreground",size:16,strokeWidth:1.5}),label:"Opens",metric:m(a.opened_count||0)}]:[],...h?[{icon:e.jsx(Z,{className:"shrink-0 text-muted-foreground",size:16,strokeWidth:1.5}),label:"Clicks",metric:m(a.clicked_count||0)}]:[]],title:"Newsletter performance"}),e.jsx("div",{className:v,children:d?e.jsxs(e.Fragment,{children:[e.jsx(P,{className:"text-muted-foreground group-hover:text-foreground",size:16,strokeWidth:1.5}),a.open_rate?`${Math.round(a.open_rate)}%`:"0%"]}):h?e.jsxs(e.Fragment,{children:[e.jsx(Z,{className:"text-muted-foreground group-hover:text-foreground",size:16,strokeWidth:1.5}),a.click_rate?`${Math.round(a.click_rate)}%`:"0%"]}):e.jsxs(e.Fragment,{children:[e.jsx(X,{className:"text-muted-foreground group-hover:text-foreground",size:16,strokeWidth:1.5}),J(a.sent_count||0)]})})]}),o&&e.jsxs("div",{className:"group/tooltip relative flex w-[66px] lg:w-[92px]","data-testid":"statistics-members",onClick:x=>{x.stopPropagation(),t(`/posts/analytics/${a.post_id}/growth`,{crossApp:!0})},children:[e.jsx(O,{className:"left-auto right-0 translate-x-0",metrics:[{icon:e.jsx(ue,{className:"shrink-0 text-muted-foreground",size:16,strokeWidth:1.5}),label:"Free",metric:a.free_members>0?`+${m(a.free_members)}`:"0"},...c?.paidMembersEnabled?[{icon:e.jsx(pe,{className:"shrink-0 text-muted-foreground",size:16,strokeWidth:1.5}),label:"Paid",metric:a.paid_members>0?`+${m(a.paid_members)}`:"0"}]:[]],title:"New members"}),e.jsxs("div",{className:v,children:[e.jsx(re,{className:"text-muted-foreground group-hover:text-foreground",size:16,strokeWidth:1.5}),a.members>0?`+${m(a.members)}`:"0"]})]})]})]},a.post_id)),(!s?.stats||s.stats.length===0)&&e.jsx(Y,{className:"w-full pb-10",title:`No posts ${S(r)}`,children:e.jsx(te,{strokeWidth:1.5})})]})})]})},Ye=()=>{const{data:{posts:[s]}={posts:[]},isLoading:n}=Re({searchParams:{filter:"status:[published,sent]",order:"published_at DESC",limit:"1",include:"authors,email,count.clicks"}}),t=s,r=Ue(t?.id||"",{enabled:!!t?.id}),{data:i,isLoading:c}=r;return{data:A.useMemo(()=>{if(!t)return null;const l=i?.stats?.[0]||{id:t.id,recipient_count:null,opened_count:null,open_rate:null,member_delta:0,free_members:0,paid_members:0,visitors:0};return{id:t.id,uuid:t.uuid,title:t.title||"",slug:t.slug||"",feature_image:t.feature_image||null,published_at:t.published_at||"",url:t.url||"",excerpt:t.excerpt||"",email_only:t.email_only||!1,status:t.status,email:t.email,count:t.count,authors:t.authors||[],recipient_count:l.recipient_count,opened_count:l.opened_count,open_rate:l.open_rate,member_delta:l.member_delta,free_members:l.free_members,paid_members:l.paid_members,visitors:l.visitors,click_rate:null}},[t,i]),isLoading:n||!!t?.id&&c}},ee=({className:s,title:n,description:t,url:r,children:i})=>e.jsx("a",{className:D("block rounded-xl border bg-card p-6 transition-all hover:shadow-xs hover:bg-accent/50 group/card",s),href:r,rel:"noreferrer",target:"_blank",children:e.jsxs("div",{className:"flex items-center gap-6",children:[i,e.jsxs("div",{className:"flex flex-col gap-0.5 leading-tight",children:[e.jsx("span",{className:"text-base font-semibold",children:n}),e.jsx("span",{className:"text-sm font-normal text-gray-700",children:t})]})]})}),As=()=>{const{appSettings:s}=W(),{statsConfig:n,isLoading:t,range:r}=L(),{startDate:i,endDate:c,timezone:p}=xe(r),{isLoading:l,chartData:o,totals:h,currencySymbol:d}=Ie(r),{data:v,isLoading:a}=Ye(),{data:x,isLoading:f}=Be({searchParams:{date_from:z(i),date_to:z(c),limit:"5",timezone:p}}),b={site_uuid:n?.id||"",date_from:z(i),date_to:z(c),timezone:p,member_status:ze(ge)},{data:y,loading:_}=_e({endpoint:"api_kpis",statsConfig:n,params:b}),w=A.useMemo(()=>U(y||[],r,"visits","sum")?.map(g=>{const k=Number(g.visits),C=isNaN(k)?0:k;return{date:String(g.date),value:C,formattedValue:m(C),label:"Visitors"}}),[y,r]),j=A.useMemo(()=>{const g=[0,1];if(!w||w.length===0)return g;const k=w.map(u=>u.value).filter(u=>u>=0);return k.length===0?g:[0,Math.max(...k)||g[1]]},[w]),R=A.useMemo(()=>{if(!o||o.length===0)return[];let g=[];return g=U(o,r,"value","exact"),g.map(u=>({date:u.date,value:u.free+u.paid,formattedValue:m(u.free+u.paid),label:"Members"}))},[o,r]),ie=A.useMemo(()=>{if(!s?.paidMembersEnabled||!o||o.length===0)return[];let g=[];return g=U(o,r,"mrr","exact"),g.map(u=>({date:u.date,value:H(u.mrr),formattedValue:`${d}${m(H(u.mrr))}`,label:"MRR"}))},[o,r,d,s]),ne=A.useMemo(()=>{if(!y?.length)return{visits:"0"};const g=y.reduce((k,C)=>{const u=Number(C.visits);return k+(isNaN(u)?0:u)},0);return{visits:m(g)}},[y]),oe=t;return e.jsxs(fe,{children:[e.jsx(be,{children:e.jsx(Ce,{children:e.jsx(je,{excludeRanges:["today"]})})}),e.jsxs(ve,{isLoading:oe,loadingComponent:e.jsx(e.Fragment,{}),children:[e.jsx(Se,{currencySymbol:d,growthTotals:h,isLoading:_||l,kpiValues:ne,membersChartData:R,mrrChartData:ie,visitorsChartData:w,visitorsYRange:j}),e.jsx(Oe,{isLoading:a,latestPostStats:v}),e.jsx(Ke,{isLoading:f,topPostsData:x}),e.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2",children:[e.jsx(he,{className:"-mb-4 mt-4 lg:col-span-2",children:"Grow your audience"}),e.jsx(ee,{description:"Find out how to review the performance of your content and get the most out of post analytics in Ghost.",title:"Understanding analytics in Ghost",url:"https://ghost.org/help/native-analytics",children:e.jsx("div",{className:"flex h-18 w-[100px] min-w-[100px] items-center justify-center rounded-md bg-gradient-to-tr from-[#14B8FF]/20 to-[#00BBA7]/20 p-4 opacity-80 transition-all group-hover/card:opacity-100",children:e.jsx(Ve,{className:"text-[#00BBA7]",size:20,strokeWidth:1.5})})}),e.jsx(ee,{description:"Use these content distribution tactics to get more people to discover your work and increase engagement.",title:"How to get your content seen online",url:"https://ghost.org/resources/content-distribution/",children:e.jsx("div",{className:"flex h-18 w-[100px] min-w-[100px] items-center justify-center rounded-md bg-gradient-to-tl from-[#FDC700]/20 to-[#FF2056]/20 p-4 opacity-80 transition-all group-hover/card:opacity-100",children:e.jsx(M,{className:"text-[#FE9A00]",size:20,strokeWidth:1.5})})})]})]})]})};export{As as default};
1
+ import{aP as K,r as A,bV as L,bW as W,j as e,S as N,bO as se,B as T,aT as M,aj as m,y as D,ai as Q,cz as te,aQ as le,cA as H,e as ce,cB as q,cC as de,bB as me,cD as J,bH as ue,cE as pe,af as xe,ag as z,aW as U,_ as he,bS as ge}from"./index-Bgo4hw-T.js";import{g as S,S as fe,a as be,D as je,b as ve}from"./stats-view-BRy4IDHe.js";import{C as E,a as $,b as F,f as V,c as I,E as Ne,K as we,d as ye,e as ke,u as _e,j as Ce}from"./pagemenu-D3ByoZIR.js";import{E as Y}from"./empty-indicator-CzTRebSi.js";import{P as Ae}from"./post-share-modal-Dz4BNSV-.js";import{g as Le,c as Te}from"./post-helpers-gInwAwEv.js";import{g as ae,a as ze}from"./audience-DF--nR_q.js";import{S as Me,P as We,U as re}from"./wallet-cards-Cl4bJBBw.js";import{C as De,h as P,d as Ee,i as $e,L as Fe,j as X,k as Z,l as Ve}from"./lucide-react-7D_Tsesk.js";import{G as B}from"./gh-chart-ldqA2tQU.js";import{u as Ie}from"./use-growth-stats-C5TiRW1S.js";import{u as Re}from"./posts-C94RiQ4S.js";import{h as Ue,i as Be}from"./stats-B2vPCVx7.js";import"./select-MVpx-Kfp.js";import"./message-square-text-DzuHB7uU.js";import"./sprout-CXg43Zav.js";import"./a-large-small-gBDqOWOy.js";import"./at-sign-V79EBNTJ.js";import"./copy-CTHgI4YI.js";import"./hash-CRtHv162.js";import"./inbox-DWYGFLuU.js";import"./list-filter-CofVbkA4.js";import"./minus-BIdO1CDG.js";import"./tags-BQz2NtFF.js";import"./square-C8G-1gV_.js";import"./user-round-check-Df7ko4Tm.js";import"./repeat-YTCeIlQZ.js";import"./reply-CUazFbTY.js";import"./trash-BKeiM6WP.js";import"./chart-0ezwQhyB.js";import"./_baseAssignValue-D0bBhNG1.js";import"./currency-fEUUCkj0.js";const Ge=s=>s.email_only?"Sent":s.email?"Published and sent":"Published",Oe=({latestPostStats:s,isLoading:n})=>{const t=K(),[r,i]=A.useState(!1),{site:c,settings:p}=L(),{appSettings:l}=W(),{emailTrackClicks:o,emailTrackOpens:h,webAnalytics:d=!1,membersTrackSources:v=!1}=l?.analytics||{},a=c.title||String(p.find(j=>j.key==="title")?.value||"Ghost Site"),x=String(p.find(j=>j.key==="timezone")?.value||"Etc/UTC"),f=s?Le(s,{membersTrackSources:v}):null,b="group mr-2 flex flex-col gap-1.5 hover:cursor-pointer",y=!!s?.email,_=ae({postId:s?.id,hasEmailData:y,analytics:{webAnalytics:d,membersTrackSources:v}}),w=_.startsWith("/editor/");return e.jsxs(E,{className:"group/card bg-gradient-to-tr from-muted/40 to-muted/0 to-50%","data-testid":"latest-post",children:[e.jsxs($,{children:[e.jsx(F,{className:"flex items-baseline justify-between font-medium leading-snug text-muted-foreground",children:"Latest post performance"}),e.jsx(V,{className:"hidden",children:"How your last post did"})]}),e.jsxs(I,{className:"flex flex-col gap-6 px-0 lg:flex-row xl:grid xl:grid-cols-3",children:[n&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex w-full items-center gap-6 px-6 xl:col-span-2",children:[e.jsx("div",{className:"w-full max-w-[232px] grow",children:e.jsx(N,{className:"aspect-[16/10] rounded-md"})}),e.jsxs("div",{className:"w-full grow",children:[e.jsx(N,{className:"w-full max-w-[420px]"}),e.jsx(N,{className:"w-1/2"})]})]}),e.jsx("div",{className:"flex flex-col items-stretch gap-2 px-6 text-sm",children:e.jsxs("div",{className:"grid grid-cols-2 gap-5",children:[e.jsxs("div",{children:[e.jsx(N,{className:"w-3/4"}),e.jsx(N,{className:"h-10 w-1/3"})]}),e.jsxs("div",{children:[e.jsx(N,{className:"w-3/4"}),e.jsx(N,{className:"h-10 w-1/3"})]}),e.jsxs("div",{children:[e.jsx(N,{className:"w-3/4"}),e.jsx(N,{className:"h-10 w-1/3"})]}),e.jsxs("div",{children:[e.jsx(N,{className:"w-3/4"}),e.jsx(N,{className:"h-10 w-1/3"})]})]})})]}),!n&&s&&f?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col gap-6 px-6 transition-all md:flex-row md:items-start xl:col-span-2",children:[s.feature_image&&e.jsx("div",{className:"aspect-[16/10] w-full min-w-[100px] rounded-sm bg-cover bg-center sm:max-w-[170px] lg:max-w-[170px] xl:max-w-[232px]",style:{backgroundImage:`url(${s.feature_image})`}}),e.jsxs("div",{className:"flex grow flex-col items-start justify-center self-stretch",children:[e.jsx("div",{className:"text-lg font-semibold leading-tighter tracking-tight hover:cursor-pointer hover:opacity-75",onClick:()=>{!n&&s&&t(_,{crossApp:!0})},children:s.title}),e.jsxs("div",{className:"mt-0.5 text-sm text-muted-foreground",children:[s.authors&&s.authors.length>0&&e.jsxs("div",{children:["By ",s.authors.map(j=>j.name).join(", ")," – ",se(s.published_at,x)]}),e.jsx("div",{className:"mt-0.5",children:Ge(s)})]}),e.jsxs("div",{className:"mt-6 flex items-center gap-2",children:[!s.email_only&&e.jsx(Ae,{author:s.authors?.map(j=>j.name).join(", ")||"",description:"",faviconURL:c.icon||"",featureImageURL:s.feature_image||"",open:r,postExcerpt:s.excerpt||"",postTitle:s.title,postURL:s.url||"",siteTitle:a,onClose:()=>i(!1),onOpenChange:i,children:e.jsxs(T,{onClick:()=>i(!0),children:[e.jsx(Me,{})," Share post"]})}),e.jsx(T,{className:s.email_only?"w-full":"",variant:"outline",onClick:()=>{t(_,{crossApp:!0})},children:w?e.jsxs(e.Fragment,{children:[e.jsx(We,{}),e.jsx("span",{className:"hidden md:!visible md:!block",children:"Edit post"})]}):e.jsxs(e.Fragment,{children:[e.jsx(De,{}),e.jsx("span",{className:"hidden md:!visible md:!block",children:s.email_only?"Post analytics":"Analytics"})]})})]})]})]}),e.jsx("div",{className:"-ml-4 flex w-full flex-col items-stretch gap-2 pr-6 text-sm xl:h-full xl:max-w-none",children:e.jsxs("div",{className:"grid grid-cols-2 gap-6 pl-10 lg:border-l xl:h-full",children:[f.showWebMetrics&&d&&e.jsxs("div",{className:b,"data-testid":"latest-post-visitors",onClick:()=>{t(`/posts/analytics/${s.id}/web`,{crossApp:!0})},children:[e.jsxs("div",{className:"flex items-center gap-1.5 font-medium text-muted-foreground transition-all group-hover:text-foreground",children:[e.jsx(M,{size:16,strokeWidth:1.25}),e.jsx("span",{className:"hidden md:!visible md:!block",children:"Visitors"})]}),e.jsx("span",{className:"text-[2.2rem] font-semibold leading-none tracking-tighter",children:m(s.visitors)})]}),f.showMemberGrowth&&e.jsxs("div",{className:D(b,f.showEmailMetrics&&(!f.showWebMetrics||!d)&&"row-[2/3] col-[1/2]"),"data-testid":"latest-post-members",onClick:()=>{t(`/posts/analytics/${s.id}/growth`,{crossApp:!0})},children:[e.jsxs("div",{className:"flex items-center gap-1.5 font-medium text-muted-foreground transition-all group-hover:text-foreground",children:[e.jsx(re,{size:16,strokeWidth:1.25}),e.jsx("span",{className:"hidden md:!visible md:!block",children:"Members"})]}),e.jsx("span",{className:"text-[2.2rem] font-semibold leading-none tracking-tighter",children:s.member_delta?e.jsxs(e.Fragment,{children:["+",m(s.member_delta)]}):0})]}),f.showEmailMetrics&&s.email&&e.jsxs(e.Fragment,{children:[h&&e.jsxs("div",{className:b,onClick:()=>{t(`/posts/analytics/${s.id}/newsletter`,{crossApp:!0})},children:[e.jsxs("div",{className:"flex items-center gap-1.5 font-medium text-muted-foreground transition-all group-hover:text-foreground",children:[e.jsx(P,{size:16,strokeWidth:1.25}),e.jsx("span",{className:"hidden whitespace-nowrap md:!visible md:!block",children:"Opens"})]}),e.jsx("span",{className:"text-[2.2rem] font-semibold leading-none tracking-tighter",children:s.email.email_count?Q((s.email.opened_count||0)/s.email.email_count):"0%"})]}),o&&e.jsxs("div",{className:b,onClick:()=>{t(`/posts/analytics/${s.id}/newsletter`,{crossApp:!0})},children:[e.jsxs("div",{className:"flex items-center gap-1.5 font-medium text-muted-foreground transition-all group-hover:text-foreground",children:[e.jsx(Ee,{size:16,strokeWidth:1.25}),e.jsx("span",{className:"hidden whitespace-nowrap md:!visible md:!block",children:"Clicks"})]}),e.jsx("span",{className:"text-[2.2rem] font-semibold leading-none tracking-tighter",children:s.email.email_count&&s.count?.clicks?Q((s.count.clicks||0)/s.email.email_count):"0%"})]})]})]})})]}):!n&&e.jsx(Y,{actions:e.jsx(T,{variant:"secondary",onClick:()=>{t("/editor/post",{crossApp:!0})},children:"New post"}),className:"w-full pb-10 xl:col-span-3",description:"Once it's live, you can track performance here",title:"Publish your first post",children:e.jsx(te,{strokeWidth:1.5})})]})]})},He=()=>{const{data:s}=L();return{isLimited:t=>{const r=s?.config;return r?.hostSettings?.limits&&t==="limitAnalytics"?r.hostSettings.limits.limitAnalytics?.disabled===!0:!1}}},G=({title:s,iconName:n,description:t,color:r,diffDirection:i,diffValue:c,formattedValue:p,trendingFromValue:l,children:o,onClick:h})=>{const{range:d}=L(),v=n&&Fe[n],a=ce.useMemo(()=>{if(!i||i==="empty"||d===q.allTime.value||!c)return"";const x=i==="up"?"up":i==="down"?"down":"at",b=S(d).replace("in the ","").replace(/^\(|\)$/g,"");return i==="same"?e.jsxs("span",{children:["You're trending at the same level as ",e.jsx("span",{className:"font-semibold",children:p})," compared to the ",e.jsx("span",{className:"font-semibold",children:b})]}):e.jsxs("span",{children:["You're trending ",e.jsxs("span",{className:"font-semibold",children:[x," ",c]})," from ",e.jsx("span",{className:"font-semibold",children:l})," compared to the ",b]})},[i,c,l,p,d]);return e.jsxs(E,{className:"group","data-testid":s,children:[e.jsxs($,{className:"hidden",children:[e.jsx(F,{children:s}),e.jsx(V,{children:t})]}),e.jsxs(we,{className:"relative flex grow flex-row items-start justify-between gap-5 border-none pb-2 xl:pb-4",children:[e.jsxs("div",{className:"flex grow flex-col gap-1.5 border-none pb-0",children:[e.jsxs(ye,{className:h&&"transition-all group-hover:text-foreground",children:[r&&e.jsx("span",{className:"inline-block size-2 rounded-full opacity-50",style:{backgroundColor:r}}),v&&e.jsx(v,{size:16,strokeWidth:1.5}),s]}),e.jsx(ke,{diffDirection:d===q.allTime.value?"hidden":i,diffTooltip:a,diffValue:c,value:p})]}),h&&e.jsx(T,{className:"absolute right-6 translate-x-10 opacity-0 transition-all duration-200 group-hover:translate-x-0 group-hover:opacity-100",size:"sm",variant:"outline",onClick:h,children:"View more"})]}),e.jsx(I,{children:o})]})},Se=({kpiValues:s,visitorsChartData:n,visitorsYRange:t,growthTotals:r,membersChartData:i,mrrChartData:c,currencySymbol:p,isLoading:l})=>{const o=K(),{range:h}=L(),{appSettings:d}=W(),a=He().isLimited("limitAnalytics"),x="-mb-3 h-[10vw] max-h-[200px] min-h-[100px] hover:!cursor-pointer";if(l)return e.jsx(Ne,{className:"flex h-[calc(10vw+116px)] max-h-[416px] min-h-20 items-center justify-center hover:!cursor-pointer",children:e.jsx(le,{})});const f=d?.analytics.webAnalytics,b=a&&!f,y=!0,_=d?.paidMembersEnabled,w=[f,b,y,_].filter(Boolean).length;let j="lg:grid-cols-3";w===2?j="lg:grid-cols-2":w===1&&(j="lg:grid-cols-1");const R=`flex flex-col lg:grid ${j} gap-6`;return e.jsxs("div",{className:R,children:[f&&!b&&e.jsx(G,{description:"Number of individual people who visited your website",diffDirection:"empty",formattedValue:s.visits,iconName:"Globe",linkto:"/analytics/web/",title:"Unique visitors",onClick:()=>{o("/analytics/web/")},children:e.jsx(B,{className:x,color:"hsl(var(--chart-blue))",data:n,id:"visitors",range:h,showHorizontalLines:!0,showYAxisValues:!1,syncId:"overview-charts",yAxisRange:t})}),b&&e.jsxs(E,{children:[e.jsxs($,{className:"hidden",children:[e.jsx(F,{children:"Unlock web analytics"}),e.jsx(V,{children:"Get the full picture of what's working with detailed, cookie-free traffic analytics."})]}),e.jsx(I,{className:"flex h-full items-center justify-center p-6",children:e.jsx(Y,{actions:e.jsx(T,{variant:"outline",onClick:()=>o("/pro",{crossApp:!0}),children:"Upgrade now"}),className:"py-10",description:"Get the full picture of what's working with detailed, cookie-free traffic analytics.",title:"Unlock web analytics",children:e.jsx($e,{})})})]}),e.jsx(G,{description:"How number of members of your publication changed over time",diffDirection:r.directions.total,diffValue:r.percentChanges.total,formattedValue:m(r.totalMembers),iconName:"User",linkto:"/analytics/growth/",title:"Members",trendingFromValue:`${m(i[0].value)}`,onClick:()=>{o("/analytics/growth/?tab=total-members")},children:e.jsx(B,{className:x,color:"hsl(var(--chart-darkblue))",data:i,id:"members",range:h,showHorizontalLines:!0,showYAxisValues:!1,syncId:"overview-charts"})}),_&&e.jsx(G,{description:"Monthly recurring revenue changes over time",diffDirection:r.directions.mrr,diffValue:r.percentChanges.mrr,formattedValue:`${p}${m(H(r.mrr))}`,iconName:"Coins",linkto:"/analytics/growth/",title:"MRR",trendingFromValue:`${p}${m(c[0].value)}`,onClick:()=>{o("/analytics/growth/?tab=mrr")},children:e.jsx(B,{className:x,color:"hsl(var(--chart-teal))",data:c,id:"mrr",range:h,showHorizontalLines:!0,showYAxisValues:!1,syncId:"overview-charts"})})]})},Pe=({className:s})=>e.jsx("div",{className:D("rounded-sm bg-muted dark:bg-[#36373a] flex flex-col items-center justify-center gap-1 p-6",s),children:e.jsx(de,{className:"text-muted-foreground/50",size:18,strokeWidth:1.5})}),O=({className:s,metrics:n,title:t})=>e.jsx(e.Fragment,{children:e.jsxs("div",{className:D("pointer-events-none absolute bottom-[calc(100%+2px)] left-1/2 z-50 min-w-[160px] -translate-x-1/2 rounded-md bg-background p-3 text-sm opacity-0 shadow-md transition-all group-hover/tooltip:bottom-[calc(100%+12px)] group-hover/tooltip:opacity-100",s),children:[e.jsx("div",{className:"mb-1.5 whitespace-nowrap border-b pb-1.5 pr-10 font-medium text-muted-foreground",children:t}),e.jsx("div",{className:"flex flex-col gap-1.5",children:n?.map(r=>e.jsxs("div",{className:"flex items-center justify-between gap-5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 whitespace-nowrap",children:[r.icon,r.label]}),e.jsx("span",{className:"font-mono",children:r.metric})]},r.label))})]})}),Ke=({topPostsData:s,isLoading:n})=>{const t=K(),{range:r,settings:i}=L(),{appSettings:c}=W(),p=String(i.find(a=>a.key==="timezone")?.value||"Etc/UTC"),{webAnalytics:l=!1,membersTrackSources:o=!1,emailTrackClicks:h=!1,emailTrackOpens:d=!1}=c?.analytics||{},v="flex items-center justify-end gap-1 rounded-md px-2 py-1 font-mono text-gray-800 hover:bg-muted-foreground/10 group-hover:text-foreground";return e.jsxs(E,{className:"group/card w-full lg:col-span-2","data-testid":"top-posts-card",children:[e.jsxs($,{children:[e.jsxs(F,{className:"flex items-baseline justify-between font-medium leading-snug text-muted-foreground",children:["Top posts ",S(r)]}),e.jsx(V,{className:"hidden",children:"Most viewed posts in this period"})]}),e.jsx(I,{children:n?e.jsx(me,{className:"mt-6"}):e.jsxs(e.Fragment,{children:[s?.stats?.map(a=>e.jsxs("div",{className:'group relative flex w-full items-start justify-between gap-5 border-t border-border/50 py-4 before:absolute before:-inset-x-4 before:inset-y-0 before:z-0 before:hidden before:rounded-md before:bg-accent before:opacity-80 before:content-[""] first:!border-border hover:cursor-pointer hover:border-transparent hover:before:block md:items-center dark:before:bg-accent/50 [&+div]:hover:border-transparent',children:[e.jsxs("div",{className:"z-10 flex min-w-[160px] grow items-start gap-4 md:items-center lg:min-w-[320px]",onClick:()=>{t(ae({postId:a.post_id,hasEmailData:a.sent_count!==null,analytics:{webAnalytics:l,membersTrackSources:o}}),{crossApp:!0})},children:[a.feature_image?e.jsx("div",{className:"hidden aspect-[16/10] w-[80px] shrink-0 rounded-sm bg-cover bg-center sm:!visible sm:!block lg:w-[100px]",style:{backgroundImage:`url(${a.feature_image})`}}):e.jsx(Pe,{className:"hidden aspect-[16/10] w-[80px] shrink-0 group-hover:bg-muted-foreground/10 sm:!visible sm:!flex lg:w-[100px]"}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"line-clamp-2 text-lg font-semibold leading-[1.35em]",children:a.title}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["By ",a.authors," – ",se(a.published_at,p)]}),e.jsx("span",{className:"text-sm text-muted-foreground",children:Te(a)})]})]}),e.jsxs("div",{className:"z-10 flex flex-col items-end justify-center gap-0.5 text-sm md:flex-row md:items-center md:justify-end md:gap-3",children:[l&&e.jsxs("div",{className:"group/tooltip relative flex w-[66px] lg:w-[92px]","data-testid":"statistics-visitors",onClick:x=>{x.stopPropagation(),t(`/posts/analytics/${a.post_id}/web`,{crossApp:!0})},children:[e.jsx(O,{metrics:[{icon:e.jsx(M,{className:"shrink-0 text-muted-foreground",size:16,strokeWidth:1.5}),label:"Unique visitors",metric:m(a.views)}],title:"Web traffic"}),e.jsxs("div",{className:v,children:[e.jsx(M,{className:"text-muted-foreground group-hover:text-foreground",size:16,strokeWidth:1.5}),J(a.views)]})]}),a.sent_count!==null&&e.jsxs("div",{className:"group/tooltip relative flex w-[66px] lg:w-[92px]",onClick:x=>{x.stopPropagation(),t(`/posts/analytics/${a.post_id}/newsletter`,{crossApp:!0})},children:[e.jsx(O,{className:`${o?"":"left-auto right-0 translate-x-0"}`,metrics:[{icon:e.jsx(X,{className:"shrink-0 text-muted-foreground",size:16,strokeWidth:1.5}),label:"Sent",metric:m(a.sent_count||0)},...d?[{icon:e.jsx(P,{className:"shrink-0 text-muted-foreground",size:16,strokeWidth:1.5}),label:"Opens",metric:m(a.opened_count||0)}]:[],...h?[{icon:e.jsx(Z,{className:"shrink-0 text-muted-foreground",size:16,strokeWidth:1.5}),label:"Clicks",metric:m(a.clicked_count||0)}]:[]],title:"Newsletter performance"}),e.jsx("div",{className:v,children:d?e.jsxs(e.Fragment,{children:[e.jsx(P,{className:"text-muted-foreground group-hover:text-foreground",size:16,strokeWidth:1.5}),a.open_rate?`${Math.round(a.open_rate)}%`:"0%"]}):h?e.jsxs(e.Fragment,{children:[e.jsx(Z,{className:"text-muted-foreground group-hover:text-foreground",size:16,strokeWidth:1.5}),a.click_rate?`${Math.round(a.click_rate)}%`:"0%"]}):e.jsxs(e.Fragment,{children:[e.jsx(X,{className:"text-muted-foreground group-hover:text-foreground",size:16,strokeWidth:1.5}),J(a.sent_count||0)]})})]}),o&&e.jsxs("div",{className:"group/tooltip relative flex w-[66px] lg:w-[92px]","data-testid":"statistics-members",onClick:x=>{x.stopPropagation(),t(`/posts/analytics/${a.post_id}/growth`,{crossApp:!0})},children:[e.jsx(O,{className:"left-auto right-0 translate-x-0",metrics:[{icon:e.jsx(ue,{className:"shrink-0 text-muted-foreground",size:16,strokeWidth:1.5}),label:"Free",metric:a.free_members>0?`+${m(a.free_members)}`:"0"},...c?.paidMembersEnabled?[{icon:e.jsx(pe,{className:"shrink-0 text-muted-foreground",size:16,strokeWidth:1.5}),label:"Paid",metric:a.paid_members>0?`+${m(a.paid_members)}`:"0"}]:[]],title:"New members"}),e.jsxs("div",{className:v,children:[e.jsx(re,{className:"text-muted-foreground group-hover:text-foreground",size:16,strokeWidth:1.5}),a.members>0?`+${m(a.members)}`:"0"]})]})]})]},a.post_id)),(!s?.stats||s.stats.length===0)&&e.jsx(Y,{className:"w-full pb-10",title:`No posts ${S(r)}`,children:e.jsx(te,{strokeWidth:1.5})})]})})]})},Ye=()=>{const{data:{posts:[s]}={posts:[]},isLoading:n}=Re({searchParams:{filter:"status:[published,sent]",order:"published_at DESC",limit:"1",include:"authors,email,count.clicks"}}),t=s,r=Ue(t?.id||"",{enabled:!!t?.id}),{data:i,isLoading:c}=r;return{data:A.useMemo(()=>{if(!t)return null;const l=i?.stats?.[0]||{id:t.id,recipient_count:null,opened_count:null,open_rate:null,member_delta:0,free_members:0,paid_members:0,visitors:0};return{id:t.id,uuid:t.uuid,title:t.title||"",slug:t.slug||"",feature_image:t.feature_image||null,published_at:t.published_at||"",url:t.url||"",excerpt:t.excerpt||"",email_only:t.email_only||!1,status:t.status,email:t.email,count:t.count,authors:t.authors||[],recipient_count:l.recipient_count,opened_count:l.opened_count,open_rate:l.open_rate,member_delta:l.member_delta,free_members:l.free_members,paid_members:l.paid_members,visitors:l.visitors,click_rate:null}},[t,i]),isLoading:n||!!t?.id&&c}},ee=({className:s,title:n,description:t,url:r,children:i})=>e.jsx("a",{className:D("block rounded-xl border bg-card p-6 transition-all hover:shadow-xs hover:bg-accent/50 group/card",s),href:r,rel:"noreferrer",target:"_blank",children:e.jsxs("div",{className:"flex items-center gap-6",children:[i,e.jsxs("div",{className:"flex flex-col gap-0.5 leading-tight",children:[e.jsx("span",{className:"text-base font-semibold",children:n}),e.jsx("span",{className:"text-sm font-normal text-gray-700",children:t})]})]})}),As=()=>{const{appSettings:s}=W(),{statsConfig:n,isLoading:t,range:r}=L(),{startDate:i,endDate:c,timezone:p}=xe(r),{isLoading:l,chartData:o,totals:h,currencySymbol:d}=Ie(r),{data:v,isLoading:a}=Ye(),{data:x,isLoading:f}=Be({searchParams:{date_from:z(i),date_to:z(c),limit:"5",timezone:p}}),b={site_uuid:n?.id||"",date_from:z(i),date_to:z(c),timezone:p,member_status:ze(ge)},{data:y,loading:_}=_e({endpoint:"api_kpis",statsConfig:n,params:b}),w=A.useMemo(()=>U(y||[],r,"visits","sum")?.map(g=>{const k=Number(g.visits),C=isNaN(k)?0:k;return{date:String(g.date),value:C,formattedValue:m(C),label:"Visitors"}}),[y,r]),j=A.useMemo(()=>{const g=[0,1];if(!w||w.length===0)return g;const k=w.map(u=>u.value).filter(u=>u>=0);return k.length===0?g:[0,Math.max(...k)||g[1]]},[w]),R=A.useMemo(()=>{if(!o||o.length===0)return[];let g=[];return g=U(o,r,"value","exact"),g.map(u=>({date:u.date,value:u.free+u.paid,formattedValue:m(u.free+u.paid),label:"Members"}))},[o,r]),ie=A.useMemo(()=>{if(!s?.paidMembersEnabled||!o||o.length===0)return[];let g=[];return g=U(o,r,"mrr","exact"),g.map(u=>({date:u.date,value:H(u.mrr),formattedValue:`${d}${m(H(u.mrr))}`,label:"MRR"}))},[o,r,d,s]),ne=A.useMemo(()=>{if(!y?.length)return{visits:"0"};const g=y.reduce((k,C)=>{const u=Number(C.visits);return k+(isNaN(u)?0:u)},0);return{visits:m(g)}},[y]),oe=t;return e.jsxs(fe,{children:[e.jsx(be,{children:e.jsx(Ce,{children:e.jsx(je,{excludeRanges:["today"]})})}),e.jsxs(ve,{isLoading:oe,loadingComponent:e.jsx(e.Fragment,{}),children:[e.jsx(Se,{currencySymbol:d,growthTotals:h,isLoading:_||l,kpiValues:ne,membersChartData:R,mrrChartData:ie,visitorsChartData:w,visitorsYRange:j}),e.jsx(Oe,{isLoading:a,latestPostStats:v}),e.jsx(Ke,{isLoading:f,topPostsData:x}),e.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2",children:[e.jsx(he,{className:"-mb-4 mt-4 lg:col-span-2",children:"Grow your audience"}),e.jsx(ee,{description:"Find out how to review the performance of your content and get the most out of post analytics in Ghost.",title:"Understanding analytics in Ghost",url:"https://ghost.org/help/native-analytics",children:e.jsx("div",{className:"flex h-18 w-[100px] min-w-[100px] items-center justify-center rounded-md bg-gradient-to-tr from-[#14B8FF]/20 to-[#00BBA7]/20 p-4 opacity-80 transition-all group-hover/card:opacity-100",children:e.jsx(Ve,{className:"text-[#00BBA7]",size:20,strokeWidth:1.5})})}),e.jsx(ee,{description:"Use these content distribution tactics to get more people to discover your work and increase engagement.",title:"How to get your content seen online",url:"https://ghost.org/resources/content-distribution/",children:e.jsx("div",{className:"flex h-18 w-[100px] min-w-[100px] items-center justify-center rounded-md bg-gradient-to-tl from-[#FDC700]/20 to-[#FF2056]/20 p-4 opacity-80 transition-all group-hover/card:opacity-100",children:e.jsx(M,{className:"text-[#FE9A00]",size:20,strokeWidth:1.5})})})]})]})]})};export{As as default};
@@ -1 +1 @@
1
- import{k as v,u as b,b as j,l as y,r as k,j as e,L as F,H as P,B,X as E,e as C,f as T,m as S,P as U,A,S as x,n as H,o as L,s as M}from"./index-DCTdAEHx.js";import{T as I}from"./topic-filter-U3qUH2P_.js";import{S as z}from"./sprout-DRqlFJSK.js";const f=({profile:s,update:l,isLoading:t,onOpenChange:r})=>{const o=S("index","me"),{data:m}=o,n=s.handle===m?.handle,p=()=>{l(s.id,{followedByMe:!0})},i=()=>{l(s.id,{followedByMe:!1})},c=j();return e.jsx("div",{className:"flex w-full cursor-pointer items-start gap-3 pt-4 [&:last-of-type>:nth-child(2)]:border-none",onClick:()=>{c(`/profile/${s.handle}`)},children:e.jsxs("div",{className:"flex w-full flex-col gap-1 border-b border-gray-200 pb-4 dark:border-gray-950",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(U,{actor:s,isCurrentUser:n,children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(A,{author:{icon:{url:s.avatarUrl},name:s.name,handle:s.handle},onClick:()=>r?.(!1)}),e.jsxs("div",{className:"-mt-0.5 flex grow flex-col break-anywhere",children:[e.jsx("span",{className:"line-clamp-1 font-semibold text-black dark:text-white",children:t?e.jsx(x,{className:"w-full max-w-48"}):s.name}),e.jsx("span",{className:"line-clamp-1 text-md text-gray-700 dark:text-gray-600",children:t?e.jsx(x,{className:"w-32"}):s.handle})]})]})}),t?e.jsx("div",{className:"inline-flex items-center",children:e.jsx(x,{className:"w-24"})}):n?null:e.jsx(H,{className:"ml-auto",following:s.followedByMe,handle:s.handle,type:"primary",onFollow:p,onUnfollow:i})]}),e.jsx("div",{className:"pl-[52px]",children:t?e.jsx(x,{className:"w-full max-w-96"}):s.bio&&e.jsx("div",{dangerouslySetInnerHTML:{__html:L(M(s.bio,["a","br"]))},className:"ap-profile-content pointer-events-none mt-0 line-clamp-2 max-w-[460px] break-anywhere"})})]})})},Q=()=>{const{isExplainerClosed:s,setExplainerClosed:l}=v(),t=b(),r=j(),o=t.topic||"top",{exploreProfilesQuery:m,updateExploreProfile:n}=y("index",o),{data:p,isLoading:i,fetchNextPage:c,hasNextPage:h,isFetchingNextPage:u}=m,g=Array(10).fill(null).map((a,d)=>({id:`skeleton-${d}`,name:"",handle:"",avatarUrl:"",bio:"",url:"",followedByMe:!1})),w=p?.pages.flatMap(a=>a.accounts)||[];return k.useEffect(()=>{const a=document.querySelector(".load-more-trigger");if(!a)return;const d=new IntersectionObserver(N=>{N[0].isIntersecting&&h&&!u&&c()},{threshold:.1});return d.observe(a),()=>d.disconnect()},[h,u,c]),e.jsxs(F,{children:[!s&&e.jsxs("div",{className:"relative mb-6 flex items-start gap-1 rounded-md bg-gradient-to-r from-[#CFB0FF66] to-[#B6E8FF66] p-4 pr-10 dark:from-[#CFB0FF20] dark:to-[#B6E8FF20]",children:[e.jsx("div",{className:"min-w-[46px]",children:e.jsx(z,{className:"text-purple",size:46,strokeWidth:.75})}),e.jsxs("div",{className:"mt-1 flex flex-col gap-[2px]",children:[e.jsx(P,{className:"text-pretty",children:"The fastest way to grow your followers, is to follow others!"}),e.jsx("p",{className:"2xl:text-pretty text-balance text-sm text-black/60 dark:text-white/60",children:"Here are some recommendations to get you started, from Ghost publishers and other great accounts from around the social web."})]}),e.jsx(B,{className:"absolute right-4 top-[17px] size-6 opacity-40",variant:"link",onClick:()=>l(!0),children:e.jsx(E,{size:20})})]}),e.jsx(I,{currentTopic:o,excludeTopics:["following"],onTopicChange:a=>{a==="top"?r("/explore",{replace:!0}):r(`/explore/${a}`,{replace:!0})}}),e.jsx("div",{className:"mt-12 flex flex-col gap-12 pb-20 max-md:mt-5",children:i?e.jsx("div",{children:g.map(a=>e.jsx("div",{className:"mx-auto w-full max-w-[640px]",children:e.jsx(f,{isLoading:i,profile:a,update:()=>{}})},a.id))}):e.jsxs("div",{className:"mx-auto flex w-full max-w-[640px] flex-col items-center",children:[e.jsx("div",{className:"w-full",children:w.map(a=>e.jsx(C.Fragment,{children:e.jsx(f,{isLoading:!1,profile:a,update:n})},a.id))}),e.jsx("div",{className:"load-more-trigger h-4 w-full"}),u&&e.jsx("div",{className:"mt-2 flex w-full justify-center",children:e.jsx(T,{size:"sm"})})]})})]})};export{Q as default};
1
+ import{k as v,u as b,b as j,l as y,r as k,j as e,L as F,H as P,B,X as E,e as C,f as T,m as S,P as U,A,S as x,n as H,o as L,s as M}from"./index-Bgo4hw-T.js";import{T as I}from"./topic-filter-BPOZf5IO.js";import{S as z}from"./sprout-CXg43Zav.js";const f=({profile:s,update:l,isLoading:t,onOpenChange:r})=>{const o=S("index","me"),{data:m}=o,n=s.handle===m?.handle,p=()=>{l(s.id,{followedByMe:!0})},i=()=>{l(s.id,{followedByMe:!1})},c=j();return e.jsx("div",{className:"flex w-full cursor-pointer items-start gap-3 pt-4 [&:last-of-type>:nth-child(2)]:border-none",onClick:()=>{c(`/profile/${s.handle}`)},children:e.jsxs("div",{className:"flex w-full flex-col gap-1 border-b border-gray-200 pb-4 dark:border-gray-950",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(U,{actor:s,isCurrentUser:n,children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(A,{author:{icon:{url:s.avatarUrl},name:s.name,handle:s.handle},onClick:()=>r?.(!1)}),e.jsxs("div",{className:"-mt-0.5 flex grow flex-col break-anywhere",children:[e.jsx("span",{className:"line-clamp-1 font-semibold text-black dark:text-white",children:t?e.jsx(x,{className:"w-full max-w-48"}):s.name}),e.jsx("span",{className:"line-clamp-1 text-md text-gray-700 dark:text-gray-600",children:t?e.jsx(x,{className:"w-32"}):s.handle})]})]})}),t?e.jsx("div",{className:"inline-flex items-center",children:e.jsx(x,{className:"w-24"})}):n?null:e.jsx(H,{className:"ml-auto",following:s.followedByMe,handle:s.handle,type:"primary",onFollow:p,onUnfollow:i})]}),e.jsx("div",{className:"pl-[52px]",children:t?e.jsx(x,{className:"w-full max-w-96"}):s.bio&&e.jsx("div",{dangerouslySetInnerHTML:{__html:L(M(s.bio,["a","br"]))},className:"ap-profile-content pointer-events-none mt-0 line-clamp-2 max-w-[460px] break-anywhere"})})]})})},Q=()=>{const{isExplainerClosed:s,setExplainerClosed:l}=v(),t=b(),r=j(),o=t.topic||"top",{exploreProfilesQuery:m,updateExploreProfile:n}=y("index",o),{data:p,isLoading:i,fetchNextPage:c,hasNextPage:h,isFetchingNextPage:u}=m,g=Array(10).fill(null).map((a,d)=>({id:`skeleton-${d}`,name:"",handle:"",avatarUrl:"",bio:"",url:"",followedByMe:!1})),w=p?.pages.flatMap(a=>a.accounts)||[];return k.useEffect(()=>{const a=document.querySelector(".load-more-trigger");if(!a)return;const d=new IntersectionObserver(N=>{N[0].isIntersecting&&h&&!u&&c()},{threshold:.1});return d.observe(a),()=>d.disconnect()},[h,u,c]),e.jsxs(F,{children:[!s&&e.jsxs("div",{className:"relative mb-6 flex items-start gap-1 rounded-md bg-gradient-to-r from-[#CFB0FF66] to-[#B6E8FF66] p-4 pr-10 dark:from-[#CFB0FF20] dark:to-[#B6E8FF20]",children:[e.jsx("div",{className:"min-w-[46px]",children:e.jsx(z,{className:"text-purple",size:46,strokeWidth:.75})}),e.jsxs("div",{className:"mt-1 flex flex-col gap-[2px]",children:[e.jsx(P,{className:"text-pretty",children:"The fastest way to grow your followers, is to follow others!"}),e.jsx("p",{className:"2xl:text-pretty text-balance text-sm text-black/60 dark:text-white/60",children:"Here are some recommendations to get you started, from Ghost publishers and other great accounts from around the social web."})]}),e.jsx(B,{className:"absolute right-4 top-[17px] size-6 opacity-40",variant:"link",onClick:()=>l(!0),children:e.jsx(E,{size:20})})]}),e.jsx(I,{currentTopic:o,excludeTopics:["following"],onTopicChange:a=>{a==="top"?r("/explore",{replace:!0}):r(`/explore/${a}`,{replace:!0})}}),e.jsx("div",{className:"mt-12 flex flex-col gap-12 pb-20 max-md:mt-5",children:i?e.jsx("div",{children:g.map(a=>e.jsx("div",{className:"mx-auto w-full max-w-[640px]",children:e.jsx(f,{isLoading:i,profile:a,update:()=>{}})},a.id))}):e.jsxs("div",{className:"mx-auto flex w-full max-w-[640px] flex-col items-center",children:[e.jsx("div",{className:"w-full",children:w.map(a=>e.jsx(C.Fragment,{children:e.jsx(f,{isLoading:!1,profile:a,update:n})},a.id))}),e.jsx("div",{className:"load-more-trigger h-4 w-full"}),u&&e.jsx("div",{className:"mt-2 flex w-full justify-center",children:e.jsx(T,{size:"sm"})})]})})]})};export{Q as default};
@@ -1,4 +1,4 @@
1
- import{r as o,j as n,cq as Cn,cr as Sn,B as A,ch as Wn,ct as zn,cs as Kn,e as rn,cV as Vn,b as En,d1 as gn,S as E,P as Yn,A as Qn,h as Zn,g as fn,d as Jn,n as Xn,br as Gn,f as pn,F as an,i as on,d2 as ne,o as ee,a as te,u as ae,p as oe,L as re,aR as ie,D as de,t as ce,v as se,w as le,a9 as ge,d3 as pe,d4 as ue,bj as bn,bk as he}from"./index-DCTdAEHx.js";import{M as me}from"./minus-CSphShdJ.js";import{u as ke,D as fe,A as be,S as xn}from"./deleted-feed-item-B-doIIKc.js";import{T as xe}from"./topic-filter-U3qUH2P_.js";import{E as vn}from"./empty-indicator-C6BBh99D.js";import{I as yn}from"./inbox-p-Y5uScT.js";import"./trash-CJY1Wro_.js";const un=["1.5rem","1.6rem","1.7rem","1.8rem","2rem"],U={BACKGROUND_COLOR:"ghost-ap-background-color",FONT_SIZE:"ghost-ap-font-size",FONT_STYLE:"ghost-ap-font-style"},P={SYSTEM:{id:"system",color:"#fff",background:"bg-white dark:bg-black",button:"bg-white dark:bg-black",border:"border-black/[8%] dark:border-gray-950"},SEPIA:{id:"sepia",color:"#FCF8F1",background:"bg-[#FCF8F1]",button:"bg-[#FCF8F1] hover:bg-black/[3%] text-black hover:text-black",border:"border-black/[8%]"},LIGHT:{id:"light",color:"#fff",background:"bg-white",button:"hover:bg-black/[3%] text-black hover:text-black",border:"border-black/[8%] dark:border-gray-950"},DARK:{id:"dark",color:"#15171a",background:"bg-black",button:"text-white dark:bg-black dark:hover:bg-gray-900",border:"border-black/[8%] dark:border-gray-950"}},ve=()=>{const[a,s]=o.useState(()=>localStorage.getItem(U.BACKGROUND_COLOR)?.toUpperCase()||"SYSTEM"),[t,p]=o.useState(()=>{const r=localStorage.getItem(U.FONT_SIZE);return r?parseInt(r):2}),[c,k]=o.useState(()=>localStorage.getItem(U.FONT_STYLE)||"sans"),i=r=>{s(r),localStorage.setItem(U.BACKGROUND_COLOR,P[r].id)};return o.useEffect(()=>{localStorage.setItem(U.FONT_SIZE,t.toString())},[t]),o.useEffect(()=>{localStorage.setItem(U.FONT_STYLE,c)},[c]),{backgroundColor:a,currentFontSizeIndex:t,fontStyle:c,handleColorChange:i,setFontStyle:k,increaseFontSize:()=>{p(r=>Math.min(r+1,un.length-1))},decreaseFontSize:()=>{p(r=>Math.max(r-1,0))},resetFontSize:()=>p(2),fontSize:un[t]}},wn=({backgroundColor:a,currentFontSizeIndex:s,fontStyle:t,onColorChange:p,onFontStyleChange:c,onDecreaseFontSize:k,onIncreaseFontSize:i,onResetFontSize:u,onOpenChange:v})=>{const h=l=>a===l,r=l=>t===l;return n.jsx(ye,{backgroundColor:a,currentFontSizeIndex:s,fontStyle:t,isActiveColor:h,isActiveFont:r,onColorChange:p,onDecreaseFontSize:k,onFontStyleChange:c,onIncreaseFontSize:i,onOpenChange:v,onResetFontSize:u})},ye=({backgroundColor:a,isActiveColor:s,isActiveFont:t,onColorChange:p,onFontStyleChange:c,currentFontSizeIndex:k,onDecreaseFontSize:i,onIncreaseFontSize:u,onResetFontSize:v,onOpenChange:h})=>n.jsxs(Cn,{modal:!1,onOpenChange:h,children:[n.jsx(Sn,{asChild:!0,children:n.jsx(A,{className:`size-9 rounded-full ${P[a].button}`,variant:"ghost",children:n.jsx(Wn.Typography,{className:"!size-[18px]"})})}),n.jsx(zn,{align:"end",className:"w-[224px]",onCloseAutoFocus:r=>r.preventDefault(),onOpenAutoFocus:r=>r.preventDefault(),children:n.jsxs("div",{className:"flex flex-col gap-4",children:[n.jsxs("div",{className:"flex items-center justify-between gap-[6px]",children:[n.jsx(A,{className:`h-7 flex-1 rounded-[6px] bg-gray-200 p-0 text-[1.1rem] text-black hover:bg-gray-250 dark:bg-gray-925 dark:text-white dark:hover:bg-gray-900 [&_svg]:size-[14px] ${s("SYSTEM")?"outline outline-2 outline-green":""}`,variant:"secondary",onClick:()=>p("SYSTEM"),children:"Auto"}),n.jsx(A,{className:`h-7 flex-1 rounded-[6px] bg-[#ece6d9] p-0 hover:bg-[#ece6d9] ${s("SEPIA")?"outline outline-2 outline-green":"border border-[#ece6d9]"}`,onClick:()=>p("SEPIA")}),n.jsx(A,{className:`h-7 flex-1 rounded-[6px] bg-white p-0 hover:bg-white ${s("LIGHT")?"outline outline-2 outline-green":"border border-gray-200"}`,onClick:()=>p("LIGHT")}),n.jsx(A,{className:`h-7 flex-1 rounded-[6px] bg-black p-0 hover:bg-black dark:border dark:border-gray-925 ${s("DARK")?"outline outline-2 outline-green":""}`,onClick:()=>p("DARK")})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsxs(A,{className:`flex h-auto w-full flex-col gap-1 rounded-[6px] bg-gray-200 text-black hover:bg-gray-250 dark:bg-gray-925 dark:text-white dark:hover:bg-gray-900 ${t("sans")&&"outline outline-2 outline-green"}`,variant:"secondary",onClick:()=>c("sans"),children:[n.jsx("span",{className:"text-[2rem] font-bold leading-none",children:"Aa"}),n.jsx("span",{className:"text-[1.1rem]",children:"System"})]}),n.jsxs(A,{className:`flex h-auto w-full flex-col gap-1 rounded-[6px] bg-gray-200 text-black hover:bg-gray-250 dark:bg-gray-925 dark:text-white dark:hover:bg-gray-900 ${t("serif")&&"outline outline-2 outline-green"}`,variant:"secondary",onClick:()=>c("serif"),children:[n.jsx("span",{className:"pt-1 font-serif text-[2rem] font-bold leading-none",children:"Aa"}),n.jsx("span",{className:"font-serif text-[1.2rem]",children:"Serif"})]})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(A,{className:"h-8 w-full rounded-[6px] bg-gray-200 text-black hover:bg-gray-250 dark:bg-gray-925 dark:text-white dark:hover:bg-gray-900 [&_svg]:size-[14px]",disabled:k===0,variant:"secondary",onClick:i,children:n.jsx(me,{})}),n.jsx(A,{className:"h-8 w-full rounded-[6px] bg-gray-200 text-black hover:bg-gray-250 dark:bg-gray-925 dark:text-white dark:hover:bg-gray-900",variant:"secondary",onClick:v,children:n.jsx("span",{className:"text-[1.6rem] font-bold",children:"Aa"})}),n.jsx(A,{className:"h-8 w-full rounded-[6px] bg-gray-200 text-black hover:bg-gray-250 dark:bg-gray-925 dark:text-white dark:hover:bg-gray-900 [&_svg]:size-[14px]",disabled:k===un.length-1,variant:"secondary",onClick:u,children:n.jsx(Kn,{})})]})]})})]}),we=({tocItems:a,iframeElement:s,modalRef:t,className:p="!visible absolute inset-y-0 right-7 z-40 hidden lg:!block",onOpenChange:c})=>{const[k,i]=o.useState(null),u=rn.useRef(!1),v=h=>{if(!s?.contentDocument)return;const r=s.contentDocument.getElementById(h);r&&t.current&&(u.current=!0,i(h),t.current.scrollTo({top:r.offsetTop-20,behavior:"smooth"}),setTimeout(()=>{u.current=!1},1e3))};return o.useEffect(()=>{if(!s?.contentDocument||a.length<=1)return;const h=t.current;if(!h)return;const r=()=>{if(u.current)return;const d=s.contentDocument;if(!d)return;const _=h.scrollTop,F=100,D=a.map(S=>d.getElementById(S.id)).filter(S=>S!==null).map(S=>({id:S.id,top:S.offsetTop}));if(!D.length)return;const L=D.reduce((S,M)=>M.top-F<=_?M:S);i(L?.id||null)},l=()=>{requestAnimationFrame(r)};return h.addEventListener("scroll",l),r(),()=>{h.removeEventListener("scroll",l)}},[s,a,t]),a.length<=1?null:n.jsx("div",{className:p,children:n.jsx("div",{className:"sticky top-1/2 -translate-y-1/2",children:n.jsx(Se,{activeHeading:k||"",items:a,onItemClick:v,onOpenChange:c})})})},je={1:"w-3",2:"w-2",3:"w-1"},Ce={1:"pl-2",2:"pl-6",3:"pl-10"},Se=({items:a,activeHeading:s,onItemClick:t,onOpenChange:p})=>{const[c,k]=o.useState(!1),i=rn.useRef();if(rn.useEffect(()=>()=>{i.current&&clearTimeout(i.current)},[]),a.length===0)return null;const u=d=>Math.min(d,3),v=d=>je[u(d)],h=d=>Ce[u(d)],r=()=>{i.current&&clearTimeout(i.current),k(!0),p?.(!0)},l=()=>{i.current=setTimeout(()=>{k(!1),p?.(!1)},100)};return n.jsxs(Cn,{modal:!1,open:c,onOpenChange:k,children:[n.jsx(Sn,{asChild:!0,children:n.jsx("div",{className:"absolute right-2 top-1/2 flex -translate-y-1/2 flex-col items-end gap-2 rounded-md p-2 text-base dark:bg-black",onMouseEnter:r,onMouseLeave:l,children:a.map(d=>n.jsx("div",{className:`h-[2px] rounded-sm ${s===d.id?"bg-black dark:bg-white":"bg-gray-400 dark:bg-gray-700"} pr-1 transition-all ${v(d.level)}`},d.id))})}),n.jsx(zn,{align:"center",className:"w-[240px] p-2",side:"left",sideOffset:-28,onCloseAutoFocus:d=>d.preventDefault(),onMouseEnter:r,onMouseLeave:l,onOpenAutoFocus:d=>d.preventDefault(),children:n.jsx("nav",{"aria-label":"Table of contents navigation",className:"max-h-[60vh] overflow-y-auto",role:"navigation",children:a.map(d=>n.jsx("button",{className:`line-clamp-2 block w-full cursor-pointer rounded py-1 text-left text-sm leading-tight ${s===d.id?"text-black dark:text-white":"text-gray-700 dark:text-gray-600"} hover:bg-gray-75 hover:text-gray-900 dark:hover:bg-grey-925 dark:hover:text-white ${h(d.level)}`,type:"button",onClick:()=>t(d.id),children:n.jsx("span",{className:"line-clamp-2",children:d.text})},d.id))})})]})},ze=()=>`<style>
1
+ import{r as o,j as n,cq as Cn,cr as Sn,B as A,ch as Wn,ct as zn,cs as Kn,e as rn,cV as Vn,b as En,d1 as gn,S as E,P as Yn,A as Qn,h as Zn,g as fn,d as Jn,n as Xn,br as Gn,f as pn,F as an,i as on,d2 as ne,o as ee,a as te,u as ae,p as oe,L as re,aR as ie,D as de,t as ce,v as se,w as le,a9 as ge,d3 as pe,d4 as ue,bj as bn,bk as he}from"./index-Bgo4hw-T.js";import{M as me}from"./minus-BIdO1CDG.js";import{u as ke,D as fe,A as be,S as xn}from"./deleted-feed-item-CK_4qToF.js";import{T as xe}from"./topic-filter-BPOZf5IO.js";import{E as vn}from"./empty-indicator-CzTRebSi.js";import{I as yn}from"./inbox-DWYGFLuU.js";import"./trash-BKeiM6WP.js";const un=["1.5rem","1.6rem","1.7rem","1.8rem","2rem"],U={BACKGROUND_COLOR:"ghost-ap-background-color",FONT_SIZE:"ghost-ap-font-size",FONT_STYLE:"ghost-ap-font-style"},P={SYSTEM:{id:"system",color:"#fff",background:"bg-white dark:bg-black",button:"bg-white dark:bg-black",border:"border-black/[8%] dark:border-gray-950"},SEPIA:{id:"sepia",color:"#FCF8F1",background:"bg-[#FCF8F1]",button:"bg-[#FCF8F1] hover:bg-black/[3%] text-black hover:text-black",border:"border-black/[8%]"},LIGHT:{id:"light",color:"#fff",background:"bg-white",button:"hover:bg-black/[3%] text-black hover:text-black",border:"border-black/[8%] dark:border-gray-950"},DARK:{id:"dark",color:"#15171a",background:"bg-black",button:"text-white dark:bg-black dark:hover:bg-gray-900",border:"border-black/[8%] dark:border-gray-950"}},ve=()=>{const[a,s]=o.useState(()=>localStorage.getItem(U.BACKGROUND_COLOR)?.toUpperCase()||"SYSTEM"),[t,p]=o.useState(()=>{const r=localStorage.getItem(U.FONT_SIZE);return r?parseInt(r):2}),[c,k]=o.useState(()=>localStorage.getItem(U.FONT_STYLE)||"sans"),i=r=>{s(r),localStorage.setItem(U.BACKGROUND_COLOR,P[r].id)};return o.useEffect(()=>{localStorage.setItem(U.FONT_SIZE,t.toString())},[t]),o.useEffect(()=>{localStorage.setItem(U.FONT_STYLE,c)},[c]),{backgroundColor:a,currentFontSizeIndex:t,fontStyle:c,handleColorChange:i,setFontStyle:k,increaseFontSize:()=>{p(r=>Math.min(r+1,un.length-1))},decreaseFontSize:()=>{p(r=>Math.max(r-1,0))},resetFontSize:()=>p(2),fontSize:un[t]}},wn=({backgroundColor:a,currentFontSizeIndex:s,fontStyle:t,onColorChange:p,onFontStyleChange:c,onDecreaseFontSize:k,onIncreaseFontSize:i,onResetFontSize:u,onOpenChange:v})=>{const h=l=>a===l,r=l=>t===l;return n.jsx(ye,{backgroundColor:a,currentFontSizeIndex:s,fontStyle:t,isActiveColor:h,isActiveFont:r,onColorChange:p,onDecreaseFontSize:k,onFontStyleChange:c,onIncreaseFontSize:i,onOpenChange:v,onResetFontSize:u})},ye=({backgroundColor:a,isActiveColor:s,isActiveFont:t,onColorChange:p,onFontStyleChange:c,currentFontSizeIndex:k,onDecreaseFontSize:i,onIncreaseFontSize:u,onResetFontSize:v,onOpenChange:h})=>n.jsxs(Cn,{modal:!1,onOpenChange:h,children:[n.jsx(Sn,{asChild:!0,children:n.jsx(A,{className:`size-9 rounded-full ${P[a].button}`,variant:"ghost",children:n.jsx(Wn.Typography,{className:"!size-[18px]"})})}),n.jsx(zn,{align:"end",className:"w-[224px]",onCloseAutoFocus:r=>r.preventDefault(),onOpenAutoFocus:r=>r.preventDefault(),children:n.jsxs("div",{className:"flex flex-col gap-4",children:[n.jsxs("div",{className:"flex items-center justify-between gap-[6px]",children:[n.jsx(A,{className:`h-7 flex-1 rounded-[6px] bg-gray-200 p-0 text-[1.1rem] text-black hover:bg-gray-250 dark:bg-gray-925 dark:text-white dark:hover:bg-gray-900 [&_svg]:size-[14px] ${s("SYSTEM")?"outline outline-2 outline-green":""}`,variant:"secondary",onClick:()=>p("SYSTEM"),children:"Auto"}),n.jsx(A,{className:`h-7 flex-1 rounded-[6px] bg-[#ece6d9] p-0 hover:bg-[#ece6d9] ${s("SEPIA")?"outline outline-2 outline-green":"border border-[#ece6d9]"}`,onClick:()=>p("SEPIA")}),n.jsx(A,{className:`h-7 flex-1 rounded-[6px] bg-white p-0 hover:bg-white ${s("LIGHT")?"outline outline-2 outline-green":"border border-gray-200"}`,onClick:()=>p("LIGHT")}),n.jsx(A,{className:`h-7 flex-1 rounded-[6px] bg-black p-0 hover:bg-black dark:border dark:border-gray-925 ${s("DARK")?"outline outline-2 outline-green":""}`,onClick:()=>p("DARK")})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsxs(A,{className:`flex h-auto w-full flex-col gap-1 rounded-[6px] bg-gray-200 text-black hover:bg-gray-250 dark:bg-gray-925 dark:text-white dark:hover:bg-gray-900 ${t("sans")&&"outline outline-2 outline-green"}`,variant:"secondary",onClick:()=>c("sans"),children:[n.jsx("span",{className:"text-[2rem] font-bold leading-none",children:"Aa"}),n.jsx("span",{className:"text-[1.1rem]",children:"System"})]}),n.jsxs(A,{className:`flex h-auto w-full flex-col gap-1 rounded-[6px] bg-gray-200 text-black hover:bg-gray-250 dark:bg-gray-925 dark:text-white dark:hover:bg-gray-900 ${t("serif")&&"outline outline-2 outline-green"}`,variant:"secondary",onClick:()=>c("serif"),children:[n.jsx("span",{className:"pt-1 font-serif text-[2rem] font-bold leading-none",children:"Aa"}),n.jsx("span",{className:"font-serif text-[1.2rem]",children:"Serif"})]})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(A,{className:"h-8 w-full rounded-[6px] bg-gray-200 text-black hover:bg-gray-250 dark:bg-gray-925 dark:text-white dark:hover:bg-gray-900 [&_svg]:size-[14px]",disabled:k===0,variant:"secondary",onClick:i,children:n.jsx(me,{})}),n.jsx(A,{className:"h-8 w-full rounded-[6px] bg-gray-200 text-black hover:bg-gray-250 dark:bg-gray-925 dark:text-white dark:hover:bg-gray-900",variant:"secondary",onClick:v,children:n.jsx("span",{className:"text-[1.6rem] font-bold",children:"Aa"})}),n.jsx(A,{className:"h-8 w-full rounded-[6px] bg-gray-200 text-black hover:bg-gray-250 dark:bg-gray-925 dark:text-white dark:hover:bg-gray-900 [&_svg]:size-[14px]",disabled:k===un.length-1,variant:"secondary",onClick:u,children:n.jsx(Kn,{})})]})]})})]}),we=({tocItems:a,iframeElement:s,modalRef:t,className:p="!visible absolute inset-y-0 right-7 z-40 hidden lg:!block",onOpenChange:c})=>{const[k,i]=o.useState(null),u=rn.useRef(!1),v=h=>{if(!s?.contentDocument)return;const r=s.contentDocument.getElementById(h);r&&t.current&&(u.current=!0,i(h),t.current.scrollTo({top:r.offsetTop-20,behavior:"smooth"}),setTimeout(()=>{u.current=!1},1e3))};return o.useEffect(()=>{if(!s?.contentDocument||a.length<=1)return;const h=t.current;if(!h)return;const r=()=>{if(u.current)return;const d=s.contentDocument;if(!d)return;const _=h.scrollTop,F=100,D=a.map(S=>d.getElementById(S.id)).filter(S=>S!==null).map(S=>({id:S.id,top:S.offsetTop}));if(!D.length)return;const L=D.reduce((S,M)=>M.top-F<=_?M:S);i(L?.id||null)},l=()=>{requestAnimationFrame(r)};return h.addEventListener("scroll",l),r(),()=>{h.removeEventListener("scroll",l)}},[s,a,t]),a.length<=1?null:n.jsx("div",{className:p,children:n.jsx("div",{className:"sticky top-1/2 -translate-y-1/2",children:n.jsx(Se,{activeHeading:k||"",items:a,onItemClick:v,onOpenChange:c})})})},je={1:"w-3",2:"w-2",3:"w-1"},Ce={1:"pl-2",2:"pl-6",3:"pl-10"},Se=({items:a,activeHeading:s,onItemClick:t,onOpenChange:p})=>{const[c,k]=o.useState(!1),i=rn.useRef();if(rn.useEffect(()=>()=>{i.current&&clearTimeout(i.current)},[]),a.length===0)return null;const u=d=>Math.min(d,3),v=d=>je[u(d)],h=d=>Ce[u(d)],r=()=>{i.current&&clearTimeout(i.current),k(!0),p?.(!0)},l=()=>{i.current=setTimeout(()=>{k(!1),p?.(!1)},100)};return n.jsxs(Cn,{modal:!1,open:c,onOpenChange:k,children:[n.jsx(Sn,{asChild:!0,children:n.jsx("div",{className:"absolute right-2 top-1/2 flex -translate-y-1/2 flex-col items-end gap-2 rounded-md p-2 text-base dark:bg-black",onMouseEnter:r,onMouseLeave:l,children:a.map(d=>n.jsx("div",{className:`h-[2px] rounded-sm ${s===d.id?"bg-black dark:bg-white":"bg-gray-400 dark:bg-gray-700"} pr-1 transition-all ${v(d.level)}`},d.id))})}),n.jsx(zn,{align:"center",className:"w-[240px] p-2",side:"left",sideOffset:-28,onCloseAutoFocus:d=>d.preventDefault(),onMouseEnter:r,onMouseLeave:l,onOpenAutoFocus:d=>d.preventDefault(),children:n.jsx("nav",{"aria-label":"Table of contents navigation",className:"max-h-[60vh] overflow-y-auto",role:"navigation",children:a.map(d=>n.jsx("button",{className:`line-clamp-2 block w-full cursor-pointer rounded py-1 text-left text-sm leading-tight ${s===d.id?"text-black dark:text-white":"text-gray-700 dark:text-gray-600"} hover:bg-gray-75 hover:text-gray-900 dark:hover:bg-grey-925 dark:hover:text-white ${h(d.level)}`,type:"button",onClick:()=>t(d.id),children:n.jsx("span",{className:"line-clamp-2",children:d.text})},d.id))})})]})},ze=()=>`<style>
2
2
 
3
3
  /* Variables */
4
4
 
@@ -1 +1 @@
1
- import{r as a,j as u,as as D,az as L,au as I,ar as O,aE as S,ay as j,aF as z,aG as G}from"./index-DCTdAEHx.js";var R="Checkbox",[H]=D(R),[K,P]=H(R);function U(t){const{__scopeCheckbox:c,checked:s,children:l,defaultChecked:r,disabled:e,form:f,name:h,onCheckedChange:d,required:C,value:k="on",internal_do_not_use_render:i}=t,[p,v]=O({prop:s,defaultProp:r??!1,onChange:d,caller:R}),[x,m]=a.useState(null),[E,o]=a.useState(null),n=a.useRef(!1),_=x?!!f||!!x.closest("form"):!0,y={checked:p,disabled:e,setChecked:v,control:x,setControl:m,name:h,form:f,value:k,hasConsumerStoppedPropagationRef:n,required:C,defaultChecked:b(r)?!1:r,isFormControl:_,bubbleInput:E,setBubbleInput:o};return u.jsx(K,{scope:c,...y,children:Q(i)?i(y):l})}var N="CheckboxTrigger",w=a.forwardRef(({__scopeCheckbox:t,onKeyDown:c,onClick:s,...l},r)=>{const{control:e,value:f,disabled:h,checked:d,required:C,setControl:k,setChecked:i,hasConsumerStoppedPropagationRef:p,isFormControl:v,bubbleInput:x}=P(N,t),m=S(r,k),E=a.useRef(d);return a.useEffect(()=>{const o=e?.form;if(o){const n=()=>i(E.current);return o.addEventListener("reset",n),()=>o.removeEventListener("reset",n)}},[e,i]),u.jsx(I.button,{type:"button",role:"checkbox","aria-checked":b(d)?"mixed":d,"aria-required":C,"data-state":q(d),"data-disabled":h?"":void 0,disabled:h,value:f,...l,ref:m,onKeyDown:j(c,o=>{o.key==="Enter"&&o.preventDefault()}),onClick:j(s,o=>{i(n=>b(n)?!0:!n),x&&v&&(p.current=o.isPropagationStopped(),p.current||o.stopPropagation())})})});w.displayName=N;var X=a.forwardRef((t,c)=>{const{__scopeCheckbox:s,name:l,checked:r,defaultChecked:e,required:f,disabled:h,value:d,onCheckedChange:C,form:k,...i}=t;return u.jsx(U,{__scopeCheckbox:s,checked:r,defaultChecked:e,disabled:h,required:f,onCheckedChange:C,name:l,form:k,value:d,internal_do_not_use_render:({isFormControl:p})=>u.jsxs(u.Fragment,{children:[u.jsx(w,{...i,ref:c,__scopeCheckbox:s}),p&&u.jsx(T,{__scopeCheckbox:s})]})})});X.displayName=R;var B="CheckboxIndicator",J=a.forwardRef((t,c)=>{const{__scopeCheckbox:s,forceMount:l,...r}=t,e=P(B,s);return u.jsx(L,{present:l||b(e.checked)||e.checked===!0,children:u.jsx(I.span,{"data-state":q(e.checked),"data-disabled":e.disabled?"":void 0,...r,ref:c,style:{pointerEvents:"none",...t.style}})})});J.displayName=B;var M="CheckboxBubbleInput",T=a.forwardRef(({__scopeCheckbox:t,...c},s)=>{const{control:l,hasConsumerStoppedPropagationRef:r,checked:e,defaultChecked:f,required:h,disabled:d,name:C,value:k,form:i,bubbleInput:p,setBubbleInput:v}=P(M,t),x=S(s,v),m=z(e),E=G(l);a.useEffect(()=>{const n=p;if(!n)return;const _=window.HTMLInputElement.prototype,g=Object.getOwnPropertyDescriptor(_,"checked").set,A=!r.current;if(m!==e&&g){const F=new Event("click",{bubbles:A});n.indeterminate=b(e),g.call(n,b(e)?!1:e),n.dispatchEvent(F)}},[p,m,e,r]);const o=a.useRef(b(e)?!1:e);return u.jsx(I.input,{type:"checkbox","aria-hidden":!0,defaultChecked:f??o.current,required:h,disabled:d,name:C,value:k,form:i,...c,tabIndex:-1,ref:x,style:{...c.style,...E,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});T.displayName=M;function Q(t){return typeof t=="function"}function b(t){return t==="indeterminate"}function q(t){return b(t)?"indeterminate":t?"checked":"unchecked"}export{X as C,J as a};
1
+ import{r as a,j as u,as as D,az as L,au as I,ar as O,aE as S,ay as j,aF as z,aG as G}from"./index-Bgo4hw-T.js";var R="Checkbox",[H]=D(R),[K,P]=H(R);function U(t){const{__scopeCheckbox:c,checked:s,children:l,defaultChecked:r,disabled:e,form:f,name:h,onCheckedChange:d,required:C,value:k="on",internal_do_not_use_render:i}=t,[p,v]=O({prop:s,defaultProp:r??!1,onChange:d,caller:R}),[x,m]=a.useState(null),[E,o]=a.useState(null),n=a.useRef(!1),_=x?!!f||!!x.closest("form"):!0,y={checked:p,disabled:e,setChecked:v,control:x,setControl:m,name:h,form:f,value:k,hasConsumerStoppedPropagationRef:n,required:C,defaultChecked:b(r)?!1:r,isFormControl:_,bubbleInput:E,setBubbleInput:o};return u.jsx(K,{scope:c,...y,children:Q(i)?i(y):l})}var N="CheckboxTrigger",w=a.forwardRef(({__scopeCheckbox:t,onKeyDown:c,onClick:s,...l},r)=>{const{control:e,value:f,disabled:h,checked:d,required:C,setControl:k,setChecked:i,hasConsumerStoppedPropagationRef:p,isFormControl:v,bubbleInput:x}=P(N,t),m=S(r,k),E=a.useRef(d);return a.useEffect(()=>{const o=e?.form;if(o){const n=()=>i(E.current);return o.addEventListener("reset",n),()=>o.removeEventListener("reset",n)}},[e,i]),u.jsx(I.button,{type:"button",role:"checkbox","aria-checked":b(d)?"mixed":d,"aria-required":C,"data-state":q(d),"data-disabled":h?"":void 0,disabled:h,value:f,...l,ref:m,onKeyDown:j(c,o=>{o.key==="Enter"&&o.preventDefault()}),onClick:j(s,o=>{i(n=>b(n)?!0:!n),x&&v&&(p.current=o.isPropagationStopped(),p.current||o.stopPropagation())})})});w.displayName=N;var X=a.forwardRef((t,c)=>{const{__scopeCheckbox:s,name:l,checked:r,defaultChecked:e,required:f,disabled:h,value:d,onCheckedChange:C,form:k,...i}=t;return u.jsx(U,{__scopeCheckbox:s,checked:r,defaultChecked:e,disabled:h,required:f,onCheckedChange:C,name:l,form:k,value:d,internal_do_not_use_render:({isFormControl:p})=>u.jsxs(u.Fragment,{children:[u.jsx(w,{...i,ref:c,__scopeCheckbox:s}),p&&u.jsx(T,{__scopeCheckbox:s})]})})});X.displayName=R;var B="CheckboxIndicator",J=a.forwardRef((t,c)=>{const{__scopeCheckbox:s,forceMount:l,...r}=t,e=P(B,s);return u.jsx(L,{present:l||b(e.checked)||e.checked===!0,children:u.jsx(I.span,{"data-state":q(e.checked),"data-disabled":e.disabled?"":void 0,...r,ref:c,style:{pointerEvents:"none",...t.style}})})});J.displayName=B;var M="CheckboxBubbleInput",T=a.forwardRef(({__scopeCheckbox:t,...c},s)=>{const{control:l,hasConsumerStoppedPropagationRef:r,checked:e,defaultChecked:f,required:h,disabled:d,name:C,value:k,form:i,bubbleInput:p,setBubbleInput:v}=P(M,t),x=S(s,v),m=z(e),E=G(l);a.useEffect(()=>{const n=p;if(!n)return;const _=window.HTMLInputElement.prototype,g=Object.getOwnPropertyDescriptor(_,"checked").set,A=!r.current;if(m!==e&&g){const F=new Event("click",{bubbles:A});n.indeterminate=b(e),g.call(n,b(e)?!1:e),n.dispatchEvent(F)}},[p,m,e,r]);const o=a.useRef(b(e)?!1:e);return u.jsx(I.input,{type:"checkbox","aria-hidden":!0,defaultChecked:f??o.current,required:h,disabled:d,name:C,value:k,form:i,...c,tabIndex:-1,ref:x,style:{...c.style,...E,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});T.displayName=M;function Q(t){return typeof t=="function"}function b(t){return t==="indeterminate"}function q(t){return b(t)?"indeterminate":t?"checked":"unchecked"}export{X as C,J as a};