ghost 6.17.1 → 6.17.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/components/tryghost-i18n-6.17.2.tgz +0 -0
  2. package/components/{tryghost-parse-email-address-6.17.1.tgz → tryghost-parse-email-address-6.17.2.tgz} +0 -0
  3. package/content/themes/source/package.json +1 -1
  4. package/core/built/admin/assets/{PolarAngleAxis-DVj7Sw2n.js → PolarAngleAxis-B8JrAxf_.js} +1 -1
  5. package/core/built/admin/assets/{_baseAssignValue-CrCkbXur.js → _baseAssignValue-Bbalamaq.js} +1 -1
  6. package/core/built/admin/assets/{a-large-small-BLquRSNr.js → a-large-small-CgWPeKpi.js} +1 -1
  7. package/core/built/admin/assets/{at-sign-Cj4_ORaa.js → at-sign-BottTo2X.js} +1 -1
  8. package/core/built/admin/assets/{audience-ACTBvUSt.js → audience-CcGOt5Fb.js} +1 -1
  9. package/core/built/admin/assets/{avatar-flipboard-BeKL4BEF.js → avatar-flipboard-MxW2k124.js} +1 -1
  10. package/core/built/admin/assets/{bluesky-sharing-CP7ej5rz.js → bluesky-sharing-BBmDBlxr.js} +1 -1
  11. package/core/built/admin/assets/{chart-B6jk72FT.js → chart-pimL5Chk.js} +1 -1
  12. package/core/built/admin/assets/{chunk.524.6c12997c856012ea06f5.js → chunk.524.9a8f5123fd3ecf3e4451.js} +6 -6
  13. package/core/built/admin/assets/{chunk.582.a0abd5b93eb1bc50335a.js → chunk.582.41886d06af2895d571bd.js} +7 -7
  14. package/core/built/admin/assets/{code-editor-view-CVRtsOBM.js → code-editor-view-tCZOpc_h.js} +1 -1
  15. package/core/built/admin/assets/{comments-CxjhZH_T.js → comments-OXqhcC0t.js} +1 -1
  16. package/core/built/admin/assets/{copy-YhtJexiS.js → copy-aC0WUVtq.js} +1 -1
  17. package/core/built/admin/assets/{data-list-BPSXm3ej.js → data-list-BOdyZGWI.js} +1 -1
  18. package/core/built/admin/assets/{deleted-feed-item-D8BHDEHh.js → deleted-feed-item-BnUJ8bWP.js} +1 -1
  19. package/core/built/admin/assets/{edit-profile-FrkkXMG7.js → edit-profile-CEgPhWMJ.js} +1 -1
  20. package/core/built/admin/assets/{empty-indicator-SsCyCd50.js → empty-indicator-CR_9BHAH.js} +1 -1
  21. package/core/built/admin/assets/{en-ZWZBSdFY.js → en-ajofhc7o.js} +1 -1
  22. package/core/built/admin/assets/{feed-BvVJCTy8.js → feed-Ci-ODCHE.js} +1 -1
  23. package/core/built/admin/assets/{filters-BupJ4mUj.js → filters-CmJJOv3I.js} +1 -1
  24. package/core/built/admin/assets/{gh-chart-Dp9VXeON.js → gh-chart-hn7wEnik.js} +1 -1
  25. package/core/built/admin/assets/{growth-CRDHOGrZ.js → growth-CQceZQ1g.js} +1 -1
  26. package/core/built/admin/assets/{hash-CPAX2PwN.js → hash-BcaWmkw5.js} +1 -1
  27. package/core/built/admin/assets/{inbox-DuT2edmx.js → inbox-D9hID-rO.js} +1 -1
  28. package/core/built/admin/assets/{index-bl5YmBtG.js → index-B1rKIiOr.js} +1 -1
  29. package/core/built/admin/assets/{index-B2oDZJ9B.js → index-BJS8H75W.js} +1 -1
  30. package/core/built/admin/assets/{index-BPYePamp.js → index-BmK6ThYl.js} +1 -1
  31. package/core/built/admin/assets/{index-BX3kQzlo.js → index-CZ3lARQ2.js} +1 -1
  32. package/core/built/admin/assets/{index-8ECl7z0l.js → index-Cl2eSBwg.js} +1 -1
  33. package/core/built/admin/assets/{index-BwUQiVrX.js → index-D8syEvSm.js} +1 -1
  34. package/core/built/admin/assets/{index-Dk-Wh_Fw.js → index-DJDgMk-T.js} +1 -1
  35. package/core/built/admin/assets/{index-DnY4rls4.js → index-DO76vL0R.js} +1 -1
  36. package/core/built/admin/assets/{index-CjzFwwKZ.js → index-DYM1MbXR.js} +1 -1
  37. package/core/built/admin/assets/{index-B1rQYn0h.js → index-Do091GLu.js} +1 -1
  38. package/core/built/admin/assets/{index-CQP2hNBo.js → index-d_UH71zm.js} +1 -1
  39. package/core/built/admin/assets/{index-exFCQBCk.js → index-f5Lv9kLb.js} +9 -9
  40. package/core/built/admin/assets/{index--Nwo3958.js → index-g4BWcHhl.js} +1 -1
  41. package/core/built/admin/assets/{index-ByYZ5TiM.js → index-kXF42nga.js} +1 -1
  42. package/core/built/admin/assets/{index-CeFAaI2v.js → index-rluYcfd-.js} +1 -1
  43. package/core/built/admin/assets/{koenig-lexical-eRS1y7PS.js → koenig-lexical-D2XHvS2J.js} +1 -1
  44. package/core/built/admin/assets/{kpi-card-DShFKtte.js → kpi-card-Dga9rFZ5.js} +1 -1
  45. package/core/built/admin/assets/{kpis-Bxyr_zYY.js → kpis-BbnqD1za.js} +1 -1
  46. package/core/built/admin/assets/{label-hgdYQhmm.js → label-D8WHEOe0.js} +1 -1
  47. package/core/built/admin/assets/{links-5NNDFN65.js → links-dgwx7ko1.js} +1 -1
  48. package/core/built/admin/assets/{lucide-react-f58FO8MB.js → lucide-react-BARFK2PZ.js} +1 -1
  49. package/core/built/admin/assets/{main-layout-BDz_2UZs.js → main-layout-CcjtCuF_.js} +1 -1
  50. package/core/built/admin/assets/{message-square-text-6dTKbQKA.js → message-square-text-BxquqPhA.js} +1 -1
  51. package/core/built/admin/assets/{minus-D2C19Fiu.js → minus-Ziy4LSYD.js} +1 -1
  52. package/core/built/admin/assets/{modals-DzetQgXf.js → modals-fMQzR7L6.js} +1 -1
  53. package/core/built/admin/assets/{moderation-87QsKbyf.js → moderation-Ci9UNwiZ.js} +1 -1
  54. package/core/built/admin/assets/{newsletter-BhI9Lgkn.js → newsletter-DnrS7Fvi.js} +1 -1
  55. package/core/built/admin/assets/{newsletters-adLgF_Re.js → newsletters-D78pgnas.js} +1 -1
  56. package/core/built/admin/assets/{note-BbPR57Yw.js → note-BAfNweZN.js} +1 -1
  57. package/core/built/admin/assets/{overview-CqyRlIVM.js → overview-CWQPNOF0.js} +1 -1
  58. package/core/built/admin/assets/{pagemenu-DlQF5jN4.js → pagemenu-DjSqq3Wu.js} +1 -1
  59. package/core/built/admin/assets/{post-analytics-BudH7GCA.js → post-analytics-c8kRV0YB.js} +1 -1
  60. package/core/built/admin/assets/{post-analytics-context-CxuzZluw.js → post-analytics-context-CEqWyqgm.js} +1 -1
  61. package/core/built/admin/assets/{post-analytics-header-BV_8onIF.js → post-analytics-header-CpPPBAz4.js} +1 -1
  62. package/core/built/admin/assets/{post-share-modal-CnM21JFK.js → post-share-modal-Dln0kZhn.js} +1 -1
  63. package/core/built/admin/assets/{posts-C5zAbpdG.js → posts-C1Eh5Ypq.js} +1 -1
  64. package/core/built/admin/assets/{repeat-BbSnXois.js → repeat-CN4fiG5H.js} +1 -1
  65. package/core/built/admin/assets/{reply-CuCJJfZj.js → reply-BfWgvH7y.js} +1 -1
  66. package/core/built/admin/assets/{select-Bv-dkHeU.js → select-B_0NBkLz.js} +1 -1
  67. package/core/built/admin/assets/{settings-Cit2-dRQ.js → settings-BqaVcJee.js} +4 -4
  68. package/core/built/admin/assets/{settings-wlK_oNsg.js → settings-Dk9E7Fqv.js} +1 -1
  69. package/core/built/admin/assets/{sort-button-Dmyldyzm.js → sort-button-C2M35dLh.js} +1 -1
  70. package/core/built/admin/assets/{source-icon-DjyV6RS6.js → source-icon-DkGi13e_.js} +1 -1
  71. package/core/built/admin/assets/{sprout-jOQR37se.js → sprout-BKiwQsGn.js} +1 -1
  72. package/core/built/admin/assets/{square-IrYxuAJL.js → square-BEpRc_fY.js} +1 -1
  73. package/core/built/admin/assets/{stats-C4LbW8IV.js → stats-CRgy_cWm.js} +1 -1
  74. package/core/built/admin/assets/{stats-view-BwaLDryw.js → stats-view-CTQ4qO3S.js} +1 -1
  75. package/core/built/admin/assets/{step-1-C0QApeYD.js → step-1-CNbdmB8C.js} +1 -1
  76. package/core/built/admin/assets/{step-2-h0b6Njyb.js → step-2-Ddrl2uae.js} +1 -1
  77. package/core/built/admin/assets/{step-3-CaM-Hz3F.js → step-3-CbqkEtwh.js} +1 -1
  78. package/core/built/admin/assets/{table-P4FGxGxN.js → table-Dw9xFlFd.js} +1 -1
  79. package/core/built/admin/assets/{tabs-Cj65mCsJ.js → tabs-DCHagOip.js} +1 -1
  80. package/core/built/admin/assets/{tags-CDvEkvxr.js → tags-BsDlfsPN.js} +1 -1
  81. package/core/built/admin/assets/{tags-Dnv6zTag.js → tags-DV2SSdMK.js} +1 -1
  82. package/core/built/admin/assets/{tiers-Y3OCOT03.js → tiers-tc5tafWV.js} +1 -1
  83. package/core/built/admin/assets/{toggle-group-kZZo_vdJ.js → toggle-group-DS-ZVhCr.js} +1 -1
  84. package/core/built/admin/assets/{topic-filter-Cn1_Z9I7.js → topic-filter-BfoEqHRD.js} +1 -1
  85. package/core/built/admin/assets/{trash-ln90Rlgi.js → trash-CpnxYen-.js} +1 -1
  86. package/core/built/admin/assets/{url-helpers-B5_oMSPb.js → url-helpers-wKPPeCtD.js} +1 -1
  87. package/core/built/admin/assets/{use-growth-stats-DQsJauHH.js → use-growth-stats-CbHIETF_.js} +1 -1
  88. package/core/built/admin/assets/{use-infinite-virtual-scroll-4OIpSNMH.js → use-infinite-virtual-scroll-DU1EUhyj.js} +1 -1
  89. package/core/built/admin/assets/{use-simple-pagination-BedA-MMT.js → use-simple-pagination-X6kmRz2u.js} +1 -1
  90. package/core/built/admin/assets/{user-round-check-CYI147XP.js → user-round-check-DYkrjHxF.js} +1 -1
  91. package/core/built/admin/assets/{wallet-cards-xpilOd6G.js → wallet-cards-CSdWOmJE.js} +1 -1
  92. package/core/built/admin/assets/{web-VPMnLvnh.js → web-C39IKnvl.js} +1 -1
  93. package/core/built/admin/index.html +2 -2
  94. package/core/server/services/email-address/email-address-service-wrapper.js +3 -0
  95. package/core/server/services/email-address/email-address-service.js +11 -0
  96. package/core/server/services/email-address/email-address-service.ts +13 -0
  97. package/core/server/services/members/api.js +3 -1
  98. package/core/server/services/members/members-api/controllers/router-controller.js +5 -2
  99. package/core/server/services/members/members-api/members-api.js +4 -2
  100. package/package.json +5 -5
  101. package/tsconfig.tsbuildinfo +1 -1
  102. package/components/tryghost-i18n-6.17.1.tgz +0 -0
@@ -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,bq 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,bK 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,bN 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,bm as ts,bn as rs,cL as os,cM as fe,cN as as}from"./index-exFCQBCk.js";import{P as is}from"./tags-Dnv6zTag.js";import{E as cs}from"./edit-profile-FrkkXMG7.js";import{T as ds,a as us,b as S,f as _,c as A}from"./tabs-Cj65mCsJ.js";import{a as ms}from"./settings-wlK_oNsg.js";import{U as xs}from"./lucide-react-f58FO8MB.js";import{C as fs}from"./copy-YhtJexiS.js";import"./label-hgdYQhmm.js";import"./at-sign-Cj4_ORaa.js";import"./index-DnY4rls4.js";import"./wallet-cards-xpilOd6G.js";import"./a-large-small-BLquRSNr.js";import"./message-square-text-6dTKbQKA.js";import"./hash-CPAX2PwN.js";import"./inbox-DuT2edmx.js";import"./minus-D2C19Fiu.js";import"./square-IrYxuAJL.js";import"./user-round-check-CYI147XP.js";import"./repeat-BbSnXois.js";import"./reply-CuCJJfZj.js";import"./sprout-jOQR37se.js";import"./trash-ln90Rlgi.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`})},Ks=({})=>{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{Ks 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,bq 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,bK 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,bN 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,bm as ts,bn as rs,cL as os,cM as fe,cN as as}from"./index-f5Lv9kLb.js";import{P as is}from"./tags-DV2SSdMK.js";import{E as cs}from"./edit-profile-CEgPhWMJ.js";import{T as ds,a as us,b as S,f as _,c as A}from"./tabs-DCHagOip.js";import{a as ms}from"./settings-Dk9E7Fqv.js";import{U as xs}from"./lucide-react-BARFK2PZ.js";import{C as fs}from"./copy-aC0WUVtq.js";import"./label-D8WHEOe0.js";import"./at-sign-BottTo2X.js";import"./index-DO76vL0R.js";import"./wallet-cards-CSdWOmJE.js";import"./a-large-small-CgWPeKpi.js";import"./message-square-text-BxquqPhA.js";import"./hash-BcaWmkw5.js";import"./inbox-D9hID-rO.js";import"./minus-Ziy4LSYD.js";import"./square-BEpRc_fY.js";import"./user-round-check-DYkrjHxF.js";import"./repeat-CN4fiG5H.js";import"./reply-BfWgvH7y.js";import"./sprout-BKiwQsGn.js";import"./trash-CpnxYen-.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`})},Ks=({})=>{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{Ks as default};
@@ -1,3 +1,3 @@
1
- import{e as I,aH as ye,r as P,aP as De,j as e,B as Ce,bV as Te,bW as je,bG as Ke,aj as T,cA as J,aQ as rt,cB as $,bH as nt,ap as it,bI as ot,bJ as de,cU as z,aR as lt,af as se,aX as ct,ag as W,S as Ge,cz as dt,by as ut,bz as mt,bA as pt,bB as ht,bC as ft,bD as xt,ah as B,bR as Oe}from"./index-exFCQBCk.js";import{s as oe,g as U,d as bt,S as gt,a as vt,D as jt,b as yt}from"./stats-view-BwaLDryw.js";import{E as ce}from"./empty-indicator-SsCyCd50.js";import{A as St,a as At}from"./wallet-cards-xpilOd6G.js";import{G as wt,C as Nt,X as Dt,Y as Ct}from"./gh-chart-Dp9VXeON.js";import{T as Ve,a as $e,K as ue,d as Y,e as Tt,b as me}from"./tabs-Cj65mCsJ.js";import{g as _t}from"./audience-ACTBvUSt.js";import{S as te,B as kt}from"./sort-button-Dmyldyzm.js";import{S as Pt,C as Q,g as Ot,c as Mt,b as Rt}from"./url-helpers-B5_oMSPb.js";import{e as le,c as K,f as F,g as Et,a as Ye,b as ze,d as H}from"./table-P4FGxGxN.js";import{g as Se}from"./currency-fEUUCkj0.js";import{g as Bt}from"./source-utils-B1S3ZHA2.js";import{a as It,b as Ft,u as Lt,k as Kt}from"./stats-C4LbW8IV.js";import{u as Gt,a as Vt}from"./tiers-Y3OCOT03.js";import{C as be,a as _e,b as ke,f as Pe,c as ge,j as $t}from"./pagemenu-DlQF5jN4.js";import{h as ne,F as Yt,T as zt,b as he,r as Ae,H as ae,L as ie,o as X,c as Ht,S as Ut,A as Wt,I as qt,i as Me,d as Qt,J as Z,u as He,e as Xt,K as Jt,G as Zt,m as fe,l as ea,n as ta,M as aa,N as pe,O as Re,g as sa,s as ra,C as Ue,a as We,v as na,B as Ee}from"./chart-B6jk72FT.js";import{S as qe,a as Qe,b as Xe,c as Je,f as we}from"./select-Bv-dkHeU.js";import{P as ia,a as oa}from"./PolarAngleAxis-DVj7Sw2n.js";import{n as la,o as ca,l as da}from"./lucide-react-f58FO8MB.js";import{u as ua}from"./use-growth-stats-DQsJauHH.js";import"./message-square-text-6dTKbQKA.js";import"./sprout-jOQR37se.js";import"./index-DnY4rls4.js";import"./_baseAssignValue-CrCkbXur.js";import"./a-large-small-BLquRSNr.js";import"./at-sign-Cj4_ORaa.js";import"./copy-YhtJexiS.js";import"./hash-CPAX2PwN.js";import"./inbox-DuT2edmx.js";import"./minus-D2C19Fiu.js";import"./tags-Dnv6zTag.js";import"./square-IrYxuAJL.js";import"./user-round-check-CYI147XP.js";import"./repeat-BbSnXois.js";import"./reply-CuCJJfZj.js";import"./trash-ln90Rlgi.js";var xe;function re(s){"@babel/helpers - typeof";return re=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(a){return typeof a}:function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},re(s)}function ee(){return ee=Object.assign?Object.assign.bind():function(s){for(var a=1;a<arguments.length;a++){var n=arguments[a];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(s[t]=n[t])}return s},ee.apply(this,arguments)}function Be(s,a){var n=Object.keys(s);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(s);a&&(t=t.filter(function(r){return Object.getOwnPropertyDescriptor(s,r).enumerable})),n.push.apply(n,t)}return n}function R(s){for(var a=1;a<arguments.length;a++){var n=arguments[a]!=null?arguments[a]:{};a%2?Be(Object(n),!0).forEach(function(t){L(s,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(n)):Be(Object(n)).forEach(function(t){Object.defineProperty(s,t,Object.getOwnPropertyDescriptor(n,t))})}return s}function ma(s,a){if(!(s instanceof a))throw new TypeError("Cannot call a class as a function")}function Ie(s,a){for(var n=0;n<a.length;n++){var t=a[n];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(s,et(t.key),t)}}function pa(s,a,n){return a&&Ie(s.prototype,a),n&&Ie(s,n),Object.defineProperty(s,"prototype",{writable:!1}),s}function ha(s,a,n){return a=ve(a),fa(s,Ze()?Reflect.construct(a,n||[],ve(s).constructor):a.apply(s,n))}function fa(s,a){if(a&&(re(a)==="object"||typeof a=="function"))return a;if(a!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return xa(s)}function xa(s){if(s===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s}function Ze(){try{var s=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Ze=function(){return!!s})()}function ve(s){return ve=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},ve(s)}function ba(s,a){if(typeof a!="function"&&a!==null)throw new TypeError("Super expression must either be null or a function");s.prototype=Object.create(a&&a.prototype,{constructor:{value:s,writable:!0,configurable:!0}}),Object.defineProperty(s,"prototype",{writable:!1}),a&&Ne(s,a)}function Ne(s,a){return Ne=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},Ne(s,a)}function L(s,a,n){return a=et(a),a in s?Object.defineProperty(s,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):s[a]=n,s}function et(s){var a=ga(s,"string");return re(a)=="symbol"?a:a+""}function ga(s,a){if(re(s)!="object"||!s)return s;var n=s[Symbol.toPrimitive];if(n!==void 0){var t=n.call(s,a);if(re(t)!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(s)}var G=(function(s){function a(n){var t;return ma(this,a),t=ha(this,a,[n]),L(t,"pieRef",null),L(t,"sectorRefs",[]),L(t,"id",Jt("recharts-pie-")),L(t,"handleAnimationEnd",function(){var r=t.props.onAnimationEnd;t.setState({isAnimationFinished:!0}),ne(r)&&r()}),L(t,"handleAnimationStart",function(){var r=t.props.onAnimationStart;t.setState({isAnimationFinished:!1}),ne(r)&&r()}),t.state={isAnimationFinished:!n.isAnimationActive,prevIsAnimationActive:n.isAnimationActive,prevAnimationId:n.animationId,sectorToFocus:0},t}return ba(a,s),pa(a,[{key:"isActiveIndex",value:function(t){var r=this.props.activeIndex;return Array.isArray(r)?r.indexOf(t)!==-1:t===r}},{key:"hasActiveIndex",value:function(){var t=this.props.activeIndex;return Array.isArray(t)?t.length!==0:t||t===0}},{key:"renderLabels",value:function(t){var r=this.props.isAnimationActive;if(r&&!this.state.isAnimationFinished)return null;var l=this.props,i=l.label,f=l.labelLine,g=l.dataKey,c=l.valueKey,o=he(this.props,!1),j=he(i,!1),A=he(f,!1),x=i&&i.offsetRadius||20,w=t.map(function(m,b){var N=(m.startAngle+m.endAngle)/2,p=Ae(m.cx,m.cy,m.outerRadius+x,N),h=R(R(R(R({},o),m),{},{stroke:"none"},j),{},{index:b,textAnchor:a.getTextAnchor(p.x,m.cx)},p),u=R(R(R(R({},o),m),{},{fill:"none",stroke:m.fill},A),{},{index:b,points:[Ae(m.cx,m.cy,m.outerRadius,N),p]}),v=g;return ae(g)&&ae(c)?v="value":ae(g)&&(v=c),I.createElement(ie,{key:"label-".concat(m.startAngle,"-").concat(m.endAngle,"-").concat(m.midAngle,"-").concat(b)},f&&a.renderLabelLineItem(f,u,"line"),a.renderLabelItem(i,h,X(m,v)))});return I.createElement(ie,{className:"recharts-pie-labels"},w)}},{key:"renderSectorsStatically",value:function(t){var r=this,l=this.props,i=l.activeShape,f=l.blendStroke,g=l.inactiveShape;return t.map(function(c,o){if(c?.startAngle===0&&c?.endAngle===0&&t.length!==1)return null;var j=r.isActiveIndex(o),A=g&&r.hasActiveIndex()?g:null,x=j?i:A,w=R(R({},c),{},{stroke:f?c.fill:c.stroke,tabIndex:-1});return I.createElement(ie,ee({ref:function(b){b&&!r.sectorRefs.includes(b)&&r.sectorRefs.push(b)},tabIndex:-1,className:"recharts-pie-sector"},Ht(r.props,c,o),{key:"sector-".concat(c?.startAngle,"-").concat(c?.endAngle,"-").concat(c.midAngle,"-").concat(o)}),I.createElement(Ut,ee({option:x,isActive:j,shapeType:"sector"},w)))})}},{key:"renderSectorsWithAnimation",value:function(){var t=this,r=this.props,l=r.sectors,i=r.isAnimationActive,f=r.animationBegin,g=r.animationDuration,c=r.animationEasing,o=r.animationId,j=this.state,A=j.prevSectors,x=j.prevIsAnimationActive;return I.createElement(Wt,{begin:f,duration:g,isActive:i,easing:c,from:{t:0},to:{t:1},key:"pie-".concat(o,"-").concat(x),onAnimationStart:this.handleAnimationStart,onAnimationEnd:this.handleAnimationEnd},function(w){var m=w.t,b=[],N=l&&l[0],p=N.startAngle;return l.forEach(function(h,u){var v=A&&A[u],C=u>0?qt(h,"paddingAngle",0):0;if(v){var S=Me(v.endAngle-v.startAngle,h.endAngle-h.startAngle),d=R(R({},h),{},{startAngle:p+C,endAngle:p+S(m)+C});b.push(d),p=d.endAngle}else{var k=h.endAngle,y=h.startAngle,D=Me(0,k-y),O=D(m),M=R(R({},h),{},{startAngle:p+C,endAngle:p+O+C});b.push(M),p=M.endAngle}}),I.createElement(ie,null,t.renderSectorsStatically(b))})}},{key:"attachKeyboardHandlers",value:function(t){var r=this;t.onkeydown=function(l){if(!l.altKey)switch(l.key){case"ArrowLeft":{var i=++r.state.sectorToFocus%r.sectorRefs.length;r.sectorRefs[i].focus(),r.setState({sectorToFocus:i});break}case"ArrowRight":{var f=--r.state.sectorToFocus<0?r.sectorRefs.length-1:r.state.sectorToFocus%r.sectorRefs.length;r.sectorRefs[f].focus(),r.setState({sectorToFocus:f});break}case"Escape":{r.sectorRefs[r.state.sectorToFocus].blur(),r.setState({sectorToFocus:0});break}}}}},{key:"renderSectors",value:function(){var t=this.props,r=t.sectors,l=t.isAnimationActive,i=this.state.prevSectors;return l&&r&&r.length&&(!i||!Qt(i,r))?this.renderSectorsWithAnimation():this.renderSectorsStatically(r)}},{key:"componentDidMount",value:function(){this.pieRef&&this.attachKeyboardHandlers(this.pieRef)}},{key:"render",value:function(){var t=this,r=this.props,l=r.hide,i=r.sectors,f=r.className,g=r.label,c=r.cx,o=r.cy,j=r.innerRadius,A=r.outerRadius,x=r.isAnimationActive,w=this.state.isAnimationFinished;if(l||!i||!i.length||!Z(c)||!Z(o)||!Z(j)||!Z(A))return null;var m=ye("recharts-pie",f);return I.createElement(ie,{tabIndex:this.props.rootTabIndex,className:m,ref:function(N){t.pieRef=N}},this.renderSectors(),g&&this.renderLabels(i),He.renderCallByParent(this.props,null,!1),(!x||w)&&Xt.renderCallByParent(this.props,i,!1))}}],[{key:"getDerivedStateFromProps",value:function(t,r){return r.prevIsAnimationActive!==t.isAnimationActive?{prevIsAnimationActive:t.isAnimationActive,prevAnimationId:t.animationId,curSectors:t.sectors,prevSectors:[],isAnimationFinished:!0}:t.isAnimationActive&&t.animationId!==r.prevAnimationId?{prevAnimationId:t.animationId,curSectors:t.sectors,prevSectors:r.curSectors,isAnimationFinished:!0}:t.sectors!==r.curSectors?{curSectors:t.sectors,isAnimationFinished:!0}:null}},{key:"getTextAnchor",value:function(t,r){return t>r?"start":t<r?"end":"middle"}},{key:"renderLabelLineItem",value:function(t,r,l){if(I.isValidElement(t))return I.cloneElement(t,r);if(ne(t))return t(r);var i=ye("recharts-pie-label-line",typeof t!="boolean"?t.className:"");return I.createElement(Yt,ee({},r,{key:l,type:"linear",className:i}))}},{key:"renderLabelItem",value:function(t,r,l){if(I.isValidElement(t))return I.cloneElement(t,r);var i=l;if(ne(t)&&(i=t(r),I.isValidElement(i)))return i;var f=ye("recharts-pie-label-text",typeof t!="boolean"&&!ne(t)?t.className:"");return I.createElement(zt,ee({},r,{alignmentBaseline:"middle",className:f}),i)}}])})(P.PureComponent);xe=G;L(G,"displayName","Pie");L(G,"defaultProps",{stroke:"#fff",fill:"#808080",legendType:"rect",cx:"50%",cy:"50%",startAngle:0,endAngle:360,innerRadius:0,outerRadius:"80%",paddingAngle:0,labelLine:!0,hide:!1,minAngle:0,isAnimationActive:!Zt.isSsr,animationBegin:400,animationDuration:1500,animationEasing:"ease",nameKey:"name",blendStroke:!1,rootTabIndex:0});L(G,"parseDeltaAngle",function(s,a){var n=fe(a-s),t=Math.min(Math.abs(a-s),360);return n*t});L(G,"getRealPieData",function(s){var a=s.data,n=s.children,t=he(s,!1),r=ea(n,ta);return a&&a.length?a.map(function(l,i){return R(R(R({payload:l},t),l),r&&r[i]&&r[i].props)}):r&&r.length?r.map(function(l){return R(R({},t),l.props)}):[]});L(G,"parseCoordinateOfPie",function(s,a){var n=a.top,t=a.left,r=a.width,l=a.height,i=aa(r,l),f=t+pe(s.cx,r,r/2),g=n+pe(s.cy,l,l/2),c=pe(s.innerRadius,i,0),o=pe(s.outerRadius,i,i*.8),j=s.maxRadius||Math.sqrt(r*r+l*l)/2;return{cx:f,cy:g,innerRadius:c,outerRadius:o,maxRadius:j}});L(G,"getComposedData",function(s){var a=s.item,n=s.offset,t=a.type.defaultProps!==void 0?R(R({},a.type.defaultProps),a.props):a.props,r=xe.getRealPieData(t);if(!r||!r.length)return null;var l=t.cornerRadius,i=t.startAngle,f=t.endAngle,g=t.paddingAngle,c=t.dataKey,o=t.nameKey,j=t.valueKey,A=t.tooltipType,x=Math.abs(t.minAngle),w=xe.parseCoordinateOfPie(t,n),m=xe.parseDeltaAngle(i,f),b=Math.abs(m),N=c;ae(c)&&ae(j)?(Re(!1,`Use "dataKey" to specify the value of pie,
1
+ import{e as I,aH as ye,r as P,aP as De,j as e,B as Ce,bV as Te,bW as je,bG as Ke,aj as T,cA as J,aQ as rt,cB as $,bH as nt,ap as it,bI as ot,bJ as de,cU as z,aR as lt,af as se,aX as ct,ag as W,S as Ge,cz as dt,by as ut,bz as mt,bA as pt,bB as ht,bC as ft,bD as xt,ah as B,bR as Oe}from"./index-f5Lv9kLb.js";import{s as oe,g as U,d as bt,S as gt,a as vt,D as jt,b as yt}from"./stats-view-CTQ4qO3S.js";import{E as ce}from"./empty-indicator-CR_9BHAH.js";import{A as St,a as At}from"./wallet-cards-CSdWOmJE.js";import{G as wt,C as Nt,X as Dt,Y as Ct}from"./gh-chart-hn7wEnik.js";import{T as Ve,a as $e,K as ue,d as Y,e as Tt,b as me}from"./tabs-DCHagOip.js";import{g as _t}from"./audience-CcGOt5Fb.js";import{S as te,B as kt}from"./sort-button-C2M35dLh.js";import{S as Pt,C as Q,g as Ot,c as Mt,b as Rt}from"./url-helpers-wKPPeCtD.js";import{e as le,c as K,f as F,g as Et,a as Ye,b as ze,d as H}from"./table-Dw9xFlFd.js";import{g as Se}from"./currency-fEUUCkj0.js";import{g as Bt}from"./source-utils-B1S3ZHA2.js";import{a as It,b as Ft,u as Lt,k as Kt}from"./stats-CRgy_cWm.js";import{u as Gt,a as Vt}from"./tiers-tc5tafWV.js";import{C as be,a as _e,b as ke,f as Pe,c as ge,j as $t}from"./pagemenu-DjSqq3Wu.js";import{h as ne,F as Yt,T as zt,b as he,r as Ae,H as ae,L as ie,o as X,c as Ht,S as Ut,A as Wt,I as qt,i as Me,d as Qt,J as Z,u as He,e as Xt,K as Jt,G as Zt,m as fe,l as ea,n as ta,M as aa,N as pe,O as Re,g as sa,s as ra,C as Ue,a as We,v as na,B as Ee}from"./chart-pimL5Chk.js";import{S as qe,a as Qe,b as Xe,c as Je,f as we}from"./select-B_0NBkLz.js";import{P as ia,a as oa}from"./PolarAngleAxis-B8JrAxf_.js";import{n as la,o as ca,l as da}from"./lucide-react-BARFK2PZ.js";import{u as ua}from"./use-growth-stats-CbHIETF_.js";import"./message-square-text-BxquqPhA.js";import"./sprout-BKiwQsGn.js";import"./index-DO76vL0R.js";import"./_baseAssignValue-Bbalamaq.js";import"./a-large-small-CgWPeKpi.js";import"./at-sign-BottTo2X.js";import"./copy-aC0WUVtq.js";import"./hash-BcaWmkw5.js";import"./inbox-D9hID-rO.js";import"./minus-Ziy4LSYD.js";import"./tags-DV2SSdMK.js";import"./square-BEpRc_fY.js";import"./user-round-check-DYkrjHxF.js";import"./repeat-CN4fiG5H.js";import"./reply-BfWgvH7y.js";import"./trash-CpnxYen-.js";var xe;function re(s){"@babel/helpers - typeof";return re=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(a){return typeof a}:function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},re(s)}function ee(){return ee=Object.assign?Object.assign.bind():function(s){for(var a=1;a<arguments.length;a++){var n=arguments[a];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(s[t]=n[t])}return s},ee.apply(this,arguments)}function Be(s,a){var n=Object.keys(s);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(s);a&&(t=t.filter(function(r){return Object.getOwnPropertyDescriptor(s,r).enumerable})),n.push.apply(n,t)}return n}function R(s){for(var a=1;a<arguments.length;a++){var n=arguments[a]!=null?arguments[a]:{};a%2?Be(Object(n),!0).forEach(function(t){L(s,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(n)):Be(Object(n)).forEach(function(t){Object.defineProperty(s,t,Object.getOwnPropertyDescriptor(n,t))})}return s}function ma(s,a){if(!(s instanceof a))throw new TypeError("Cannot call a class as a function")}function Ie(s,a){for(var n=0;n<a.length;n++){var t=a[n];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(s,et(t.key),t)}}function pa(s,a,n){return a&&Ie(s.prototype,a),n&&Ie(s,n),Object.defineProperty(s,"prototype",{writable:!1}),s}function ha(s,a,n){return a=ve(a),fa(s,Ze()?Reflect.construct(a,n||[],ve(s).constructor):a.apply(s,n))}function fa(s,a){if(a&&(re(a)==="object"||typeof a=="function"))return a;if(a!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return xa(s)}function xa(s){if(s===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s}function Ze(){try{var s=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Ze=function(){return!!s})()}function ve(s){return ve=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},ve(s)}function ba(s,a){if(typeof a!="function"&&a!==null)throw new TypeError("Super expression must either be null or a function");s.prototype=Object.create(a&&a.prototype,{constructor:{value:s,writable:!0,configurable:!0}}),Object.defineProperty(s,"prototype",{writable:!1}),a&&Ne(s,a)}function Ne(s,a){return Ne=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},Ne(s,a)}function L(s,a,n){return a=et(a),a in s?Object.defineProperty(s,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):s[a]=n,s}function et(s){var a=ga(s,"string");return re(a)=="symbol"?a:a+""}function ga(s,a){if(re(s)!="object"||!s)return s;var n=s[Symbol.toPrimitive];if(n!==void 0){var t=n.call(s,a);if(re(t)!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(s)}var G=(function(s){function a(n){var t;return ma(this,a),t=ha(this,a,[n]),L(t,"pieRef",null),L(t,"sectorRefs",[]),L(t,"id",Jt("recharts-pie-")),L(t,"handleAnimationEnd",function(){var r=t.props.onAnimationEnd;t.setState({isAnimationFinished:!0}),ne(r)&&r()}),L(t,"handleAnimationStart",function(){var r=t.props.onAnimationStart;t.setState({isAnimationFinished:!1}),ne(r)&&r()}),t.state={isAnimationFinished:!n.isAnimationActive,prevIsAnimationActive:n.isAnimationActive,prevAnimationId:n.animationId,sectorToFocus:0},t}return ba(a,s),pa(a,[{key:"isActiveIndex",value:function(t){var r=this.props.activeIndex;return Array.isArray(r)?r.indexOf(t)!==-1:t===r}},{key:"hasActiveIndex",value:function(){var t=this.props.activeIndex;return Array.isArray(t)?t.length!==0:t||t===0}},{key:"renderLabels",value:function(t){var r=this.props.isAnimationActive;if(r&&!this.state.isAnimationFinished)return null;var l=this.props,i=l.label,f=l.labelLine,g=l.dataKey,c=l.valueKey,o=he(this.props,!1),j=he(i,!1),A=he(f,!1),x=i&&i.offsetRadius||20,w=t.map(function(m,b){var N=(m.startAngle+m.endAngle)/2,p=Ae(m.cx,m.cy,m.outerRadius+x,N),h=R(R(R(R({},o),m),{},{stroke:"none"},j),{},{index:b,textAnchor:a.getTextAnchor(p.x,m.cx)},p),u=R(R(R(R({},o),m),{},{fill:"none",stroke:m.fill},A),{},{index:b,points:[Ae(m.cx,m.cy,m.outerRadius,N),p]}),v=g;return ae(g)&&ae(c)?v="value":ae(g)&&(v=c),I.createElement(ie,{key:"label-".concat(m.startAngle,"-").concat(m.endAngle,"-").concat(m.midAngle,"-").concat(b)},f&&a.renderLabelLineItem(f,u,"line"),a.renderLabelItem(i,h,X(m,v)))});return I.createElement(ie,{className:"recharts-pie-labels"},w)}},{key:"renderSectorsStatically",value:function(t){var r=this,l=this.props,i=l.activeShape,f=l.blendStroke,g=l.inactiveShape;return t.map(function(c,o){if(c?.startAngle===0&&c?.endAngle===0&&t.length!==1)return null;var j=r.isActiveIndex(o),A=g&&r.hasActiveIndex()?g:null,x=j?i:A,w=R(R({},c),{},{stroke:f?c.fill:c.stroke,tabIndex:-1});return I.createElement(ie,ee({ref:function(b){b&&!r.sectorRefs.includes(b)&&r.sectorRefs.push(b)},tabIndex:-1,className:"recharts-pie-sector"},Ht(r.props,c,o),{key:"sector-".concat(c?.startAngle,"-").concat(c?.endAngle,"-").concat(c.midAngle,"-").concat(o)}),I.createElement(Ut,ee({option:x,isActive:j,shapeType:"sector"},w)))})}},{key:"renderSectorsWithAnimation",value:function(){var t=this,r=this.props,l=r.sectors,i=r.isAnimationActive,f=r.animationBegin,g=r.animationDuration,c=r.animationEasing,o=r.animationId,j=this.state,A=j.prevSectors,x=j.prevIsAnimationActive;return I.createElement(Wt,{begin:f,duration:g,isActive:i,easing:c,from:{t:0},to:{t:1},key:"pie-".concat(o,"-").concat(x),onAnimationStart:this.handleAnimationStart,onAnimationEnd:this.handleAnimationEnd},function(w){var m=w.t,b=[],N=l&&l[0],p=N.startAngle;return l.forEach(function(h,u){var v=A&&A[u],C=u>0?qt(h,"paddingAngle",0):0;if(v){var S=Me(v.endAngle-v.startAngle,h.endAngle-h.startAngle),d=R(R({},h),{},{startAngle:p+C,endAngle:p+S(m)+C});b.push(d),p=d.endAngle}else{var k=h.endAngle,y=h.startAngle,D=Me(0,k-y),O=D(m),M=R(R({},h),{},{startAngle:p+C,endAngle:p+O+C});b.push(M),p=M.endAngle}}),I.createElement(ie,null,t.renderSectorsStatically(b))})}},{key:"attachKeyboardHandlers",value:function(t){var r=this;t.onkeydown=function(l){if(!l.altKey)switch(l.key){case"ArrowLeft":{var i=++r.state.sectorToFocus%r.sectorRefs.length;r.sectorRefs[i].focus(),r.setState({sectorToFocus:i});break}case"ArrowRight":{var f=--r.state.sectorToFocus<0?r.sectorRefs.length-1:r.state.sectorToFocus%r.sectorRefs.length;r.sectorRefs[f].focus(),r.setState({sectorToFocus:f});break}case"Escape":{r.sectorRefs[r.state.sectorToFocus].blur(),r.setState({sectorToFocus:0});break}}}}},{key:"renderSectors",value:function(){var t=this.props,r=t.sectors,l=t.isAnimationActive,i=this.state.prevSectors;return l&&r&&r.length&&(!i||!Qt(i,r))?this.renderSectorsWithAnimation():this.renderSectorsStatically(r)}},{key:"componentDidMount",value:function(){this.pieRef&&this.attachKeyboardHandlers(this.pieRef)}},{key:"render",value:function(){var t=this,r=this.props,l=r.hide,i=r.sectors,f=r.className,g=r.label,c=r.cx,o=r.cy,j=r.innerRadius,A=r.outerRadius,x=r.isAnimationActive,w=this.state.isAnimationFinished;if(l||!i||!i.length||!Z(c)||!Z(o)||!Z(j)||!Z(A))return null;var m=ye("recharts-pie",f);return I.createElement(ie,{tabIndex:this.props.rootTabIndex,className:m,ref:function(N){t.pieRef=N}},this.renderSectors(),g&&this.renderLabels(i),He.renderCallByParent(this.props,null,!1),(!x||w)&&Xt.renderCallByParent(this.props,i,!1))}}],[{key:"getDerivedStateFromProps",value:function(t,r){return r.prevIsAnimationActive!==t.isAnimationActive?{prevIsAnimationActive:t.isAnimationActive,prevAnimationId:t.animationId,curSectors:t.sectors,prevSectors:[],isAnimationFinished:!0}:t.isAnimationActive&&t.animationId!==r.prevAnimationId?{prevAnimationId:t.animationId,curSectors:t.sectors,prevSectors:r.curSectors,isAnimationFinished:!0}:t.sectors!==r.curSectors?{curSectors:t.sectors,isAnimationFinished:!0}:null}},{key:"getTextAnchor",value:function(t,r){return t>r?"start":t<r?"end":"middle"}},{key:"renderLabelLineItem",value:function(t,r,l){if(I.isValidElement(t))return I.cloneElement(t,r);if(ne(t))return t(r);var i=ye("recharts-pie-label-line",typeof t!="boolean"?t.className:"");return I.createElement(Yt,ee({},r,{key:l,type:"linear",className:i}))}},{key:"renderLabelItem",value:function(t,r,l){if(I.isValidElement(t))return I.cloneElement(t,r);var i=l;if(ne(t)&&(i=t(r),I.isValidElement(i)))return i;var f=ye("recharts-pie-label-text",typeof t!="boolean"&&!ne(t)?t.className:"");return I.createElement(zt,ee({},r,{alignmentBaseline:"middle",className:f}),i)}}])})(P.PureComponent);xe=G;L(G,"displayName","Pie");L(G,"defaultProps",{stroke:"#fff",fill:"#808080",legendType:"rect",cx:"50%",cy:"50%",startAngle:0,endAngle:360,innerRadius:0,outerRadius:"80%",paddingAngle:0,labelLine:!0,hide:!1,minAngle:0,isAnimationActive:!Zt.isSsr,animationBegin:400,animationDuration:1500,animationEasing:"ease",nameKey:"name",blendStroke:!1,rootTabIndex:0});L(G,"parseDeltaAngle",function(s,a){var n=fe(a-s),t=Math.min(Math.abs(a-s),360);return n*t});L(G,"getRealPieData",function(s){var a=s.data,n=s.children,t=he(s,!1),r=ea(n,ta);return a&&a.length?a.map(function(l,i){return R(R(R({payload:l},t),l),r&&r[i]&&r[i].props)}):r&&r.length?r.map(function(l){return R(R({},t),l.props)}):[]});L(G,"parseCoordinateOfPie",function(s,a){var n=a.top,t=a.left,r=a.width,l=a.height,i=aa(r,l),f=t+pe(s.cx,r,r/2),g=n+pe(s.cy,l,l/2),c=pe(s.innerRadius,i,0),o=pe(s.outerRadius,i,i*.8),j=s.maxRadius||Math.sqrt(r*r+l*l)/2;return{cx:f,cy:g,innerRadius:c,outerRadius:o,maxRadius:j}});L(G,"getComposedData",function(s){var a=s.item,n=s.offset,t=a.type.defaultProps!==void 0?R(R({},a.type.defaultProps),a.props):a.props,r=xe.getRealPieData(t);if(!r||!r.length)return null;var l=t.cornerRadius,i=t.startAngle,f=t.endAngle,g=t.paddingAngle,c=t.dataKey,o=t.nameKey,j=t.valueKey,A=t.tooltipType,x=Math.abs(t.minAngle),w=xe.parseCoordinateOfPie(t,n),m=xe.parseDeltaAngle(i,f),b=Math.abs(m),N=c;ae(c)&&ae(j)?(Re(!1,`Use "dataKey" to specify the value of pie,
2
2
  the props "valueKey" will be deprecated in 1.1.0`),N="value"):ae(c)&&(Re(!1,`Use "dataKey" to specify the value of pie,
3
3
  the props "valueKey" will be deprecated in 1.1.0`),N=j);var p=r.filter(function(d){return X(d,N,0)!==0}).length,h=(b>=360?p:p-1)*g,u=b-p*x-h,v=r.reduce(function(d,k){var y=X(k,N,0);return d+(Z(y)?y:0)},0),C;if(v>0){var S;C=r.map(function(d,k){var y=X(d,N,0),D=X(d,o,k),O=(Z(y)?y:0)/v,M;k?M=S.endAngle+fe(m)*g*(y!==0?1:0):M=i;var _=M+fe(m)*((y!==0?x:0)+O*u),E=(M+_)/2,V=(w.innerRadius+w.outerRadius)/2,q=[{name:D,value:y,payload:d,dataKey:N,type:A}],st=Ae(w.cx,w.cy,V,E);return S=R(R(R({percent:O,cornerRadius:l,name:D,tooltipPayload:q,midAngle:E,middleRadius:V,tooltipPosition:st},d),w),{},{value:X(d,N),startAngle:M,endAngle:_,payload:d,paddingAngle:fe(m)*g}),S})}return R(R({},w),{},{sectors:C,data:r})});var va=sa({chartName:"PieChart",GraphicalChild:G,validateTooltipEventTypes:["item"],defaultTooltipEventType:"item",legendContent:"children",axisComponents:[{axisType:"angleAxis",AxisComp:ia},{axisType:"radiusAxis",AxisComp:oa}],formatAxisMap:ra,defaultProps:{layout:"centric",startAngle:0,endAngle:360,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"}});const tt=({className:s})=>{const a=De();return e.jsx(ce,{actions:e.jsx(Ce,{variant:"outline",onClick:()=>a("/settings/analytics",{crossApp:!0}),children:"Open settings"}),className:s,description:"Enable member source tracking in settings to see which content drives member growth.",title:"Member sources have been disabled",children:e.jsx(St,{})})},ja=s=>s==="total-members"||s==="free-members"||s==="paid-members"||s==="mrr",ya=({active:s,payload:a,range:n,color:t,showBreakdown:r})=>{if(!s||!a?.length)return null;const l=a[0].payload,{date:i,formattedValue:f,label:g,comped:c}=l,o=l.value-(c||0);return e.jsxs("div",{className:"min-w-[200px] rounded-lg border bg-background px-3 py-2 shadow-lg",children:[i&&e.jsx("div",{className:"mb-1 text-sm text-foreground",children:z(i,n||0)}),e.jsxs("div",{className:"flex flex-col gap-1",children:[r&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("div",{className:"flex grow items-center justify-between gap-5",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"Paid subscriptions"}),e.jsx("div",{className:"font-mono text-xs",children:T(o)})]})}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("div",{className:"flex grow items-center justify-between gap-5",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"Complimentary"}),e.jsx("div",{className:"font-mono text-xs",children:c!==void 0&&c>0?T(c):"0"})]})}),e.jsx(lt,{})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"inline-block size-2 rounded-full opacity-50",style:{backgroundColor:t||"hsl(var(--chart-purple))"}}),e.jsxs("div",{className:"flex grow items-center justify-between gap-5",children:[g&&e.jsx("div",{className:"text-sm text-muted-foreground",children:g}),e.jsx("div",{className:"font-mono font-medium",children:f})]})]})]})]})},Sa=({chartData:s,totals:a,initialTab:n,currencySymbol:t,isLoading:r,onTabChange:l})=>{const i=ja(n)?n:"total-members",[f,g]=P.useState(i),{range:c}=Te(),{appSettings:o}=je(),j=De(),[A]=Ke();P.useEffect(()=>{g(i)},[i]);const x=S=>{g(S);const d=new URLSearchParams(A);d.set("tab",S),j(`?${d.toString()}`,{replace:!0}),l&&l(S)},{totalMembers:w,freeMembers:m,paidMembers:b,mrr:N,percentChanges:p,directions:h}=a,u=P.useMemo(()=>{if(!s||s.length===0)return[];let S=[],d="value";switch(f){case"free-members":d="free";break;case"paid-members":d="paid";break;case"mrr":{d="mrr";break}default:d="value"}S=oe(s,c,d,"exact");let k=[];switch(f){case"free-members":k=S.map(y=>({...y,value:y.free,formattedValue:T(y.free),label:"Free members"}));break;case"paid-members":k=S.map(y=>({...y,value:y.paid,formattedValue:T(y.paid),label:"Paid members",comped:y.comped,paid_subscribed:y.paid_subscribed}));break;case"mrr":k=S.map(y=>({...y,value:J(y.mrr),formattedValue:`${t}${T(J(y.mrr))}`,label:"MRR"}));break;default:k=S.map(y=>{const D=y.free+y.paid;return{...y,value:D,formattedValue:T(D),label:"Total members"}})}return k},[f,s,c,t]),v={"total-members":{color:"hsl(var(--chart-darkblue))"},"free-members":{color:"hsl(var(--chart-blue))"},"paid-members":{color:"hsl(var(--chart-purple))"},mrr:{color:"hsl(var(--chart-teal))"}};return r?e.jsx("div",{className:"-mb-6 flex h-[calc(16vw+132px)] w-full items-start justify-center",children:e.jsx(rt,{})}):e.jsxs(Ve,{defaultValue:i,variant:"kpis",children:[e.jsxs($e,{className:`-mx-6 ${o?.paidMembersEnabled?"hidden grid-cols-4 lg:!visible lg:!grid":"grid grid-cols-4"}`,children:[e.jsx(ue,{className:o?.paidMembersEnabled?"":"cursor-auto after:hidden",value:"total-members",onClick:()=>{o?.paidMembersEnabled&&x("total-members")},children:e.jsx(Y,{color:"hsl(var(--chart-darkblue))",diffDirection:c===$.allTime.value?"hidden":h.total,diffValue:p.total,label:"Total members",value:T(w)})}),o?.paidMembersEnabled&&e.jsxs(e.Fragment,{children:[e.jsx(ue,{value:"free-members",onClick:()=>{x("free-members")},children:e.jsx(Y,{color:"hsl(var(--chart-blue))",diffDirection:c===$.allTime.value?"hidden":h.free,diffValue:p.free,label:"Free members",value:T(m)})}),e.jsx(ue,{value:"paid-members",onClick:()=>{x("paid-members")},children:e.jsx(Y,{color:"hsl(var(--chart-purple))",diffDirection:c===$.allTime.value?"hidden":h.paid,diffValue:p.paid,label:"Paid members",value:T(b)})}),e.jsx(ue,{value:"mrr",onClick:()=>{x("mrr")},children:e.jsx(Y,{color:"hsl(var(--chart-teal))",diffDirection:c===$.allTime.value?"hidden":h.mrr,diffValue:p.mrr,label:"MRR",value:`${t}${T(J(N))}`})})]})]}),o?.paidMembersEnabled&&e.jsxs(nt,{children:[e.jsx(it,{className:"lg:hidden",asChild:!0,children:e.jsxs(Tt,{children:[f==="total-members"&&e.jsx(Y,{color:"hsl(var(--chart-darkblue))",diffDirection:c===$.allTime.value?"hidden":h.total,diffValue:p.total,label:"Total members",value:T(w)}),f==="free-members"&&e.jsx(Y,{color:"hsl(var(--chart-blue))",diffDirection:c===$.allTime.value?"hidden":h.free,diffValue:p.free,label:"Free members",value:T(m)}),f==="paid-members"&&e.jsx(Y,{color:"hsl(var(--chart-purple))",diffDirection:c===$.allTime.value?"hidden":h.paid,diffValue:p.paid,label:"Paid members",value:T(b)}),f==="mrr"&&e.jsx(Y,{color:"hsl(var(--chart-teal))",diffDirection:c===$.allTime.value?"hidden":h.mrr,diffValue:p.mrr,label:"MRR",value:`${t}${T(J(N))}`})]})}),e.jsxs(ot,{align:"end",className:"w-56",children:[e.jsx(de,{onClick:()=>x("total-members"),children:"Total members"}),e.jsx(de,{onClick:()=>x("free-members"),children:"Free members"}),e.jsx(de,{onClick:()=>x("paid-members"),children:"Paid members"}),e.jsx(de,{onClick:()=>x("mrr"),children:"MRR"})]})]}),e.jsx("div",{className:"my-4 [&_.recharts-cartesian-axis-tick-value]:fill-gray-500",children:e.jsx(wt,{className:"-mb-3 h-[16vw] max-h-[320px] w-full min-h-[180px]",color:v[f].color,data:u,dataFormatter:f==="mrr"?S=>`${t}${T(S)}`:T,id:f,range:c,tooltipContent:f==="paid-members"?e.jsx(ya,{color:v["paid-members"].color,range:c,showBreakdown:!0}):void 0})})]})},Aa=(s,a="signups desc",n=50)=>{const{startDate:t,endDate:r,timezone:l}=se(s),i={date_from:W(t),date_to:W(r),member_status:_t(ct),order:a,limit:n.toString()};return l&&(i.timezone=l),Gt({searchParams:i})},Fe=({data:s,currencySymbol:a,limit:n,defaultSourceIconUrl:t})=>{const r=n?s.slice(0,n):s,{appSettings:l}=je();return e.jsx(le,{children:r.map(i=>e.jsxs(K,{className:"last:border-none",children:[e.jsx(F,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Pt,{defaultSourceIconUrl:t,displayName:i.displayName,iconSrc:i.iconSrc}),i.linkUrl?e.jsx("a",{className:"hover:underline",href:i.linkUrl,rel:"noreferrer",target:"_blank",children:i.displayName}):e.jsx("span",{children:i.displayName})]})}),e.jsxs(F,{className:"text-right font-mono text-sm",children:["+",T(i.free_members)]}),l?.paidMembersEnabled&&e.jsxs(e.Fragment,{children:[e.jsxs(F,{className:"text-right font-mono text-sm",children:["+",T(i.paid_members)]}),e.jsxs(F,{className:"text-right font-mono text-sm",children:["+",a,T(J(i.mrr))]})]})]},i.source))})},wa=({range:s,limit:a=20,showViewAll:n=!1,sortBy:t,setSortBy:r})=>{const{data:l}=Te(),{data:i}=It(),{appSettings:f}=je(),[g,c]=P.useState("free_members desc"),o=t||g,j=r||c,A=o.replace("free_members","signups").replace("paid_members","paid_conversions"),{data:x,isLoading:w}=Aa(s,A,a),m=l?.url,b="https://www.google.com/s2/favicons?domain=ghost.org&sz=64",N=I.useMemo(()=>{if(i?.stats&&i?.meta?.totals){const v=i.meta.totals;let C=v[0];if(!C)return Se("usd");for(const S of v)S.mrr>C.mrr&&(C=S);return Se(C.currency)}return Se("usd")},[i]),p=I.useMemo(()=>x?.stats?x.stats.map(v=>{const C=v.source||"Direct",{domain:S}=Bt(C,m),d=S?`https://www.faviconextractor.com/favicon/${S}?larger=true`:b,k=S&&C!=="Direct"?`https://${S}`:void 0;return{source:C,free_members:v.signups,paid_members:v.paid_conversions,mrr:v.mrr,iconSrc:d,displayName:C,linkUrl:k}}):[],[x,m]),h="Top sources",u=`Where did your growth come from ${U(s)}`;return f?.analytics.membersTrackSources?w?e.jsx(le,{children:e.jsx(K,{className:"last:border-none",children:e.jsx(F,{className:"border-none py-2",colSpan:1,children:e.jsx(Ge,{containerClassName:"space-y-2",count:5,maxWidth:75,randomize:!0})})})}):e.jsxs(e.Fragment,{children:[p.length>0?e.jsx(Fe,{currencySymbol:N,data:p,defaultSourceIconUrl:b,limit:a}):e.jsx(le,{children:e.jsx(K,{className:"last:border-none",children:e.jsx(F,{className:"border-none py-12 group-hover:!bg-transparent",colSpan:f?.paidMembersEnabled?4:2,children:e.jsx(ce,{description:"Try adjusting your date range to see more data.",title:`No conversions ${U(s)}`,children:e.jsx(dt,{strokeWidth:1.5})})})})}),n&&p.length>a&&e.jsx(Et,{className:"border-none bg-transparent hover:!bg-transparent",children:e.jsx(K,{children:e.jsx(F,{className:"border-none bg-transparent px-0 pb-0 hover:!bg-transparent",colSpan:4,children:e.jsxs(ut,{children:[e.jsx(mt,{asChild:!0,children:e.jsxs(Ce,{variant:"outline",children:["View all ",e.jsx(At,{})]})}),e.jsxs(pt,{className:"overflow-y-auto pt-0 sm:max-w-[600px]",children:[e.jsxs(ht,{className:"sticky top-0 z-40 -mx-6 bg-background/60 p-6 backdrop-blur",children:[e.jsx(ft,{children:h}),e.jsx(xt,{children:u})]}),e.jsx("div",{className:"group/datalist",children:e.jsxs(Ye,{children:[e.jsx(ze,{children:e.jsxs(K,{children:[e.jsx(H,{children:"Source"}),e.jsx(H,{className:"w-[110px] text-right",children:e.jsx(te,{activeSortBy:o,setSortBy:j,sortBy:"free_members desc",children:"Free members"})}),f?.paidMembersEnabled&&e.jsxs(e.Fragment,{children:[e.jsx(H,{className:"w-[110px] text-right",children:e.jsx(te,{activeSortBy:o,setSortBy:j,sortBy:"paid_members desc",children:"Paid members"})}),e.jsx(H,{className:"w-[110px] text-right",children:e.jsx(te,{activeSortBy:o,setSortBy:j,sortBy:"mrr desc",children:"MRR impact"})})]})]})}),e.jsx(Fe,{currencySymbol:N,data:p,defaultSourceIconUrl:b})]})})]})]})})})})]}):e.jsx(le,{children:e.jsx(K,{className:"last:border-none",children:e.jsx(F,{className:"border-none py-12 group-hover:!bg-transparent",colSpan:f?.paidMembersEnabled?4:2,children:e.jsx(tt,{})})})})},Na=({active:s,payload:a})=>{if(s&&a&&a.length){const n=a[0];return e.jsx("div",{className:"rounded-lg border bg-background p-2 shadow-sm",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"size-2 rounded-full opacity-50",style:{backgroundColor:n.payload.color}}),e.jsx("span",{className:"font-medium",children:n.name}),e.jsx("span",{className:"font-mono",children:T(n.value)})]})})}return null},Da=({isLoading:s,range:a})=>{const{data:n}=Ft(),{data:t}=Lt({searchParams:{date_from:W(se(a).startDate)}}),{data:{tiers:r=[]}={}}=Vt(),[l,i]=P.useState("billing-period"),{startDate:f,endDate:g}=P.useMemo(()=>se(a),[a]),c=P.useMemo(()=>W(f),[f]),o=P.useMemo(()=>W(g),[g]),j=P.useMemo(()=>r.filter(u=>u.type==="paid"&&u.active).map(u=>({id:u.id,name:u.name})),[r]),A=P.useMemo(()=>{if(!t?.stats||t.stats.length===0)return 0;const u=t.stats,v=B(c),C=B(o),S=u.filter(O=>{const M=B(O.date);return M.isSameOrAfter(v)&&M.isSameOrBefore(C)});if(S.length===0)return 0;const d=[...S].sort((O,M)=>new Date(O.date).getTime()-new Date(M.date).getTime()),k=d[0].comped,D=d[d.length-1].comped-k;return D>0?D:0},[t,c,o]),x=P.useMemo(()=>{if(!n?.stats)return[];const u=B(c),v=B(o),C=n.stats.filter(d=>{const k=B(d.date);return k.isSameOrAfter(u)&&k.isSameOrBefore(v)}).reduce((d,k)=>{const y=k.cadence;return d[y]||(d[y]=0),d[y]+=k.signups,d},{});return A>0&&(C.complimentary=A),Object.entries(C).map(([d,k],y)=>{let D=d,O="url(#gradientPurple)",M="hsl(var(--chart-purple))";return d==="month"?(D="Monthly",O="url(#gradientPurple)",M="hsl(var(--chart-purple))"):d==="year"?(D="Annual",O="url(#gradientTeal)",M="hsl(var(--chart-teal))"):d==="complimentary"&&(D="Complimentary",O="url(#gradientBlue)",M="hsl(var(--chart-blue))"),{id:`cadence-${y}`,name:D,count:k,fill:O,color:M}})},[n,c,o,A]),w=P.useMemo(()=>{if(!n?.stats||j.length===0)return[];const u=B(c),v=B(o),C=n.stats.filter(D=>{const O=B(D.date);return O.isSameOrAfter(u)&&O.isSameOrBefore(v)}).reduce((D,O)=>{const M=O.tier;return D[M]||(D[M]=0),D[M]+=O.signups,D},{}),S=[{gradient:"url(#gradientPurple)",solid:"hsl(var(--chart-purple))"},{gradient:"url(#gradientTeal)",solid:"hsl(var(--chart-teal))"},{gradient:"url(#gradientBlue)",solid:"hsl(var(--chart-blue))"},{gradient:"url(#gradientRose)",solid:"hsl(var(--chart-rose))"},{gradient:"url(#gradientOrange)",solid:"hsl(var(--chart-orange))"},{gradient:"url(#gradientGreen)",solid:"hsl(var(--chart-green))"},{gradient:"url(#gradientAmber)",solid:"hsl(var(--chart-amber))"},{gradient:"url(#gradientYellow)",solid:"hsl(var(--chart-yellow))"},{gradient:"url(#gradientDarkblue)",solid:"hsl(var(--chart-darkblue))"},{gradient:"url(#gradientGray)",solid:"hsl(var(--chart-darkgray))"}];return[...j.map(D=>{const O=C[D.id]||0;return{id:D.id,name:D.name,count:O}})].sort((D,O)=>O.count-D.count).map((D,O)=>{const M=O%S.length;return{...D,fill:S[M].gradient,color:S[M].solid}})},[n,j,c,o]),m=l==="billing-period"?x:w,b=P.useMemo(()=>m.reduce((u,v)=>u+v.count,0),[m]),N=P.useMemo(()=>{const u={count:{label:"Subscriptions"}};return m.forEach(v=>{u[v.id]={label:v.name,color:v.color}}),u},[m]),p=P.useMemo(()=>b===0?[]:m.map(u=>({label:u.name,count:u.count,percentage:u.count/b*100,color:u.color})),[m,b]);if(s||!n?.stats)return null;const h=m.length>0&&b>0;return e.jsxs(be,{children:[e.jsx(_e,{children:e.jsxs("div",{className:"flex items-start justify-between gap-1.5",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(ke,{children:"Paid subscription breakdown"}),e.jsxs(Pe,{children:["New paid subscriptions ",U(a)]})]}),j.length>1&&e.jsx("div",{children:e.jsxs(qe,{value:l,onValueChange:u=>i(u),children:[e.jsx(Qe,{className:"w-full",children:e.jsx(Xe,{})}),e.jsxs(Je,{align:"end",children:[e.jsx(we,{value:"billing-period",children:"Billing period"}),e.jsx(we,{value:"tiers",children:"Tiers"})]})]})})]})}),e.jsx(ge,{children:h?e.jsxs(e.Fragment,{children:[e.jsx(Ue,{className:"mx-auto aspect-square h-[250px] min-h-[250px] w-full",config:N,children:e.jsxs(va,{children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"gradientPurple",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"hsl(var(--chart-purple))",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"hsl(var(--chart-purple))",stopOpacity:.6})]}),e.jsxs("linearGradient",{id:"gradientTeal",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"hsl(var(--chart-teal))",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"hsl(var(--chart-teal))",stopOpacity:.6})]}),e.jsxs("linearGradient",{id:"gradientRose",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"hsl(var(--chart-rose))",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"hsl(var(--chart-rose))",stopOpacity:.6})]}),e.jsxs("linearGradient",{id:"gradientBlue",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"hsl(var(--chart-blue))",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"hsl(var(--chart-blue))",stopOpacity:.6})]}),e.jsxs("linearGradient",{id:"gradientOrange",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"hsl(var(--chart-orange))",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"hsl(var(--chart-orange))",stopOpacity:.6})]}),e.jsxs("linearGradient",{id:"gradientGreen",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"hsl(var(--chart-green))",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"hsl(var(--chart-green))",stopOpacity:.6})]}),e.jsxs("linearGradient",{id:"gradientAmber",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"hsl(var(--chart-amber))",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"hsl(var(--chart-amber))",stopOpacity:.6})]}),e.jsxs("linearGradient",{id:"gradientYellow",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"hsl(var(--chart-yellow))",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"hsl(var(--chart-yellow))",stopOpacity:.6})]}),e.jsxs("linearGradient",{id:"gradientDarkblue",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"hsl(var(--chart-darkblue))",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"hsl(var(--chart-darkblue))",stopOpacity:.6})]}),e.jsxs("linearGradient",{id:"gradientGray",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"hsl(var(--chart-darkgray))",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"hsl(var(--chart-darkgray))",stopOpacity:.6})]})]}),e.jsx(We,{content:e.jsx(Na,{}),cursor:!1}),e.jsx(G,{animationBegin:0,animationDuration:1e3,data:m,dataKey:"count",innerRadius:70,nameKey:"name",strokeWidth:5,children:e.jsx(He,{content:({viewBox:u})=>{if(u&&"cx"in u&&"cy"in u)return e.jsxs("text",{dominantBaseline:"middle",textAnchor:"middle",x:u.cx,y:u.cy,children:[e.jsx("tspan",{className:"fill-foreground text-2xl font-semibold tracking-tight",x:u.cx,y:u.cy,children:T(b)}),e.jsx("tspan",{className:"fill-muted-foreground",x:u.cx,y:(u.cy||0)+20,children:"Total"})]})}})})]})}),p.length>0&&e.jsx("div",{className:"mt-4 flex flex-wrap items-center justify-center gap-x-6 gap-y-1 text-sm text-muted-foreground",children:p.map(u=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"size-2 rounded-full opacity-50",style:{backgroundColor:u.color}}),e.jsx("span",{className:"max-w-[150px] truncate whitespace-nowrap",title:u.label,children:u.label}),e.jsxs("span",{className:"font-medium text-foreground",children:[Math.round(Number(u.percentage)||0),"%"]})]},u.label))})]}):e.jsx("div",{className:"py-12",children:e.jsx(ce,{description:`No new paid subscriptions ${U(a)}.`,title:"No new subscribers",children:e.jsx(la,{strokeWidth:1.5})})})})]})},Ca=(s,a,n)=>{if(a===1){const o=B().format("YYYY-MM-DD"),j=s.find(A=>A.date===o);return[{date:o,signups:j?.signups||0,cancellations:j?.cancellations||0}]}const{startDate:t,endDate:r}=se(a),l=B(r).diff(B(t),"days"),i=bt(a,l,"sum",n),f=new Map(s.map(o=>[o.date,o])),g=[],c=new Set;if(i==="monthly"){const o=B(t).startOf("month"),j=B(r).startOf("month");for(;o.isSameOrBefore(j);){const A=o.format("YYYY-MM-DD");if(!c.has(A)){c.add(A);const x=f.get(A);x?g.push(x):g.push({date:A,signups:0,cancellations:0})}o.add(1,"month")}}else if(i==="weekly"){const o=B(t).startOf("week"),j=B(r).startOf("week");for(;o.isSameOrBefore(j);){const A=o.format("YYYY-MM-DD");if(!c.has(A)){c.add(A);const x=f.get(A);x?g.push(x):g.push({date:A,signups:0,cancellations:0})}o.add(1,"week")}}else{const o=B(t),j=B(r);for(;o.isSameOrBefore(j);){const A=o.format("YYYY-MM-DD"),x=f.get(A);x?g.push(x):g.push({date:A,signups:0,cancellations:0}),o.add(1,"day")}}return g},at=s=>{if(s===-1){const{startDate:a,endDate:n}=se(s);return B(n).diff(B(a),"days")}return s},Ta=s=>{const a=at(s);return a<30?["daily"]:a>=91?["weekly","monthly"]:["daily","weekly"]},Le=s=>{const a=at(s);return a<30?"daily":a>=91?"monthly":"weekly"},_a=({subscriptionData:s,memberData:a,range:n,isLoading:t})=>{const[r,l]=P.useState(()=>Le(n));P.useEffect(()=>{l(Le(n))},[n]);const i=P.useMemo(()=>Ta(n),[n]),f=P.useMemo(()=>{switch(r){case"daily":return"none";case"weekly":return"weekly";case"monthly":return"monthly"}},[r]),g=P.useMemo(()=>{if(s&&s.length>0){if(n===1){const h=B().format("YYYY-MM-DD"),u=s.find(v=>v.date===h);return[{date:z(h,n),rawDate:h,new:u?.signups||0,cancelled:-(u?.cancellations||0)}]}const x=oe(s,n,"signups","sum",f),w=oe(s,n,"cancellations","sum",f),m=new Map(w.map(h=>[h.date,h])),b=x.map(h=>({date:h.date,signups:h.signups||0,cancellations:m.get(h.date)?.cancellations||0})),N=new Set(b.map(h=>h.date));return w.forEach(h=>{N.has(h.date)||b.push({date:h.date,signups:0,cancellations:h.cancellations||0})}),b.sort((h,u)=>new Date(h.date).getTime()-new Date(u.date).getTime()),Ca(b,n,f).map(h=>{let u=n;return r==="weekly"&&n<91?u=91:r==="monthly"&&n<365&&(u=365),{date:z(h.date,u),rawDate:h.date,new:h.signups||0,cancelled:-(h.cancellations||0)}})}else{if(!a||a.length===0)return[];if(n===1){const p=B().format("YYYY-MM-DD"),h=a.find(u=>u.date===p);return[{date:z(p,n),rawDate:p,new:h?.paid_subscribed||0,cancelled:-(h?.paid_canceled||0)}]}const x=oe(a,n,"paid_subscribed","sum",f),w=oe(a,n,"paid_canceled","sum",f),m=new Map(w.map(p=>[p.date,p])),b=x.map(p=>({date:p.date,paid_subscribed:p.paid_subscribed||0,paid_canceled:m.get(p.date)?.paid_canceled||0})),N=new Set(b.map(p=>p.date));return w.forEach(p=>{N.has(p.date)||b.push({date:p.date,paid_subscribed:0,paid_canceled:p.paid_canceled||0})}),b.sort((p,h)=>new Date(p.date).getTime()-new Date(h.date).getTime()),b.map(p=>{let h=n;return r==="weekly"&&n<91?h=91:r==="monthly"&&n<365&&(h=365),{date:z(p.date,h),rawDate:p.date,new:p.paid_subscribed||0,cancelled:-(p.paid_canceled||0)}})}},[a,s,n,f,r]),c={new:{label:"New",color:"hsl(var(--chart-teal))"},cancelled:{label:"Cancelled",color:"hsl(var(--chart-rose))"}},o=P.useMemo(()=>{const x=g.reduce((m,b)=>m+b.new,0),w=g.reduce((m,b)=>m+Math.abs(b.cancelled),0);return{new:x,cancelled:w}},[g]);if(t)return null;const j=g.length>0&&(o.new>0||o.cancelled>0),A=x=>x.charAt(0).toUpperCase()+x.slice(1);return e.jsxs(be,{"data-testid":"paid-members-change-card",children:[e.jsx(_e,{children:e.jsxs("div",{className:"flex items-start justify-between gap-1.5",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(ke,{children:"Paid subscriptions"}),e.jsxs(Pe,{children:["New and cancelled paid subscriptions ",U(n)]})]}),i.length>1&&e.jsx("div",{children:e.jsxs(qe,{value:r,onValueChange:x=>l(x),children:[e.jsx(Qe,{className:"w-[110px]",children:e.jsx(Xe,{})}),e.jsx(Je,{align:"end",children:i.map(x=>e.jsx(we,{value:x,children:A(x)},x))})]})})]})}),e.jsx(ge,{children:j?e.jsxs("div",{children:[e.jsx(Ue,{className:"aspect-auto h-[200px] w-full md:h-[220px] xl:h-[260px]",config:c,children:e.jsxs(kt,{data:g,stackOffset:"sign",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"tealGradient",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"var(--color-new)",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"var(--color-new)",stopOpacity:.6})]})}),e.jsx("defs",{children:e.jsxs("linearGradient",{id:"roseGradient",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"var(--color-cancelled)",stopOpacity:.6}),e.jsx("stop",{offset:"100%",stopColor:"var(--color-cancelled)",stopOpacity:.8})]})}),e.jsx(Nt,{stroke:"hsl(var(--border))",vertical:!1}),e.jsx(Dt,{axisLine:!1,dataKey:"date",tickFormatter:()=>"",tickLine:!1,tickMargin:10}),e.jsx(Ct,{axisLine:!1,tickFormatter:x=>x<0?T(x*-1):T(x),tickLine:!1}),e.jsx(We,{content:e.jsx(na,{className:"!min-w-[120px] px-3 py-2",formatter:(x,w,m,b)=>{const N=Number(x);let p="0";N===0?p="0":p=N<0?T(N*-1):T(N);const h=Number(m?.payload?.new||0),u=Number(m?.payload?.cancelled||0),v=h+u,C=v===0?"0":v>0?`+${T(v)}`:T(v);let S=m?.payload?.date;return m?.payload?.rawDate&&(r==="monthly"?S=z(m.payload.rawDate,366):r==="weekly"?S=z(m.payload.rawDate,91):S=z(m.payload.rawDate,30)),e.jsxs("div",{className:"flex w-full flex-col",children:[b===0&&e.jsx("div",{className:"mb-1 text-sm font-medium text-foreground",children:S}),e.jsxs("div",{className:"flex w-full items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"size-2 shrink-0 rounded-full bg-[var(--color-bg)] opacity-50",style:{"--color-bg":`var(--color-${w})`}}),e.jsx("span",{className:"text-sm text-muted-foreground",children:c[w]?.label||w})]}),e.jsx("div",{className:"ml-auto flex items-baseline gap-0.5 font-mono font-medium tabular-nums text-foreground",children:p})]}),b===1&&e.jsxs("div",{className:"mt-1 flex w-full items-center justify-between gap-4 border-t pt-1",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Net change"}),e.jsx("div",{className:"ml-auto flex items-baseline gap-0.5 font-mono font-medium tabular-nums text-foreground",children:C})]})]})},hideLabel:!0}),cursor:!1,isAnimationActive:!1,position:{y:10}}),e.jsx(Ee,{activeBar:{fillOpacity:1},dataKey:"new",fill:"url(#tealGradient)",fillOpacity:.75,maxBarSize:32,minPointSize:3,radius:[4,4,0,0],stackId:"a"}),e.jsx(Ee,{activeBar:{fillOpacity:1},dataKey:"cancelled",fill:"url(#roseGradient)",fillOpacity:.75,maxBarSize:32,radius:[4,4,0,0],stackId:"a"})]})}),e.jsxs("div",{className:"mt-3 flex items-center justify-center gap-6 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"size-2 rounded-full opacity-50",style:{backgroundColor:c.new.color}}),e.jsx("span",{children:"New"}),e.jsx("span",{className:"font-medium text-foreground",children:T(o.new)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"size-2 rounded-full opacity-50",style:{backgroundColor:c.cancelled.color}}),e.jsx("span",{children:"Cancelled"}),e.jsx("span",{className:"font-medium text-foreground",children:T(o.cancelled)})]})]})]}):e.jsx("div",{className:"py-12",children:e.jsx(ce,{description:`No paid subscription changes ${U(n)}.`,title:"No paid member changes",children:e.jsx(ca,{strokeWidth:1.5})})})})]})},ka=(s,a,n)=>{const t=s??30,r=a??"mrr desc",{startDate:l,endDate:i}=P.useMemo(()=>se(t),[t]),f=P.useMemo(()=>{const o={date_from:W(l),date_to:W(i),order:r};return n==="posts"?o.post_type="post":n==="pages"&&(o.post_type="page"),o},[l,i,r,n]),g=Object.fromEntries(Object.entries(f).filter(([,o])=>o!==void 0));return Kt({searchParams:g})},ps=()=>{const{range:s,site:a,settings:n}=Te(),t=String(n.find(d=>d.key==="timezone")?.value||"Etc/UTC"),r=De(),[l,i]=P.useState("free_members desc"),[f,g]=P.useState(Q.POSTS_AND_PAGES),[c]=Ke(),{appSettings:o}=je(),j=c.get("tab")||"total-members",[A,x]=P.useState(j);P.useEffect(()=>{j!==A&&x(j)},[j]);const{isLoading:w,chartData:m,totals:b,currencySymbol:N,subscriptionData:p}=ua(s),{data:h,isLoading:u}=ka(s,l,f),v=P.useMemo(()=>{const k=(h?.stats||[]).reduce((_,E)=>{const V=E.post_id||(E.title&&E.title.trim()!==""?E.title:E.attribution_url);if(!V)return _;if(!_.has(V))_.set(V,E);else{const q=_.get(V);q.free_members+=E.free_members,q.paid_members+=E.paid_members,q.mrr+=E.mrr,_.set(V,q)}return _},new Map),y=Array.from(k.values()),D=y.reduce((_,E)=>_+E.free_members,0),O=y.reduce((_,E)=>_+E.paid_members,0),M=y.reduce((_,E)=>_+E.mrr,0);return y.map(_=>{let E=0;return l.includes("free_members")&&D>0?E=_.free_members/D:l.includes("paid_members")&&O>0?E=_.paid_members/O:l.includes("mrr")&&M>0&&(E=_.mrr/M),{title:_.title||_.attribution_url,post_id:_.post_id,attribution_url:_.attribution_url,attribution_type:_.attribution_type,attribution_id:_.attribution_id,free_members:_.free_members,paid_members:_.paid_members,mrr:_.mrr,percentage:E,published_at:_.published_at,url_exists:_.url_exists??!0}})},[h,l]),C=w,S=w||u;return e.jsxs(gt,{children:[e.jsx(vt,{children:e.jsx($t,{children:e.jsx(jt,{})})}),e.jsxs(yt,{data:C?void 0:m,isLoading:!1,loadingComponent:e.jsx(e.Fragment,{}),children:[e.jsx(be,{"data-testid":"total-members-card",children:e.jsx(ge,{children:e.jsx(Sa,{chartData:m,currencySymbol:N,initialTab:j,isLoading:C,totals:b,onTabChange:x})})}),o?.paidMembersEnabled&&A==="paid-members"&&e.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2 xl:grid-cols-[2fr_minmax(460px,1fr)]",children:[e.jsx(_a,{isLoading:C,memberData:m,range:s,subscriptionData:p}),e.jsx(Da,{isLoading:C,range:s})]}),e.jsxs(be,{className:"w-full overflow-x-auto","data-testid":"top-content-card",children:[e.jsxs(_e,{children:[e.jsx(ke,{children:Ot(f)}),e.jsx(Pe,{children:Mt(f,s,U)})]}),e.jsx(ge,{children:e.jsxs(Ye,{children:[e.jsx(ze,{children:e.jsxs(K,{className:"[&>th]:h-auto [&>th]:pb-2 [&>th]:pt-0",children:[e.jsx(H,{className:"min-w-[320px] pl-0",children:e.jsx(Ve,{defaultValue:f,variant:"button-sm",onValueChange:d=>{g(d)},children:e.jsxs($e,{children:[e.jsx(me,{value:Q.POSTS_AND_PAGES,children:"Posts & pages"}),e.jsx(me,{value:Q.POSTS,children:"Posts"}),e.jsx(me,{value:Q.PAGES,children:"Pages"}),e.jsx(me,{value:Q.SOURCES,children:"Sources"})]})})}),e.jsx(H,{className:"w-[140px] text-right",children:o?.paidMembersEnabled?e.jsx(te,{activeSortBy:l,setSortBy:i,sortBy:"free_members desc",children:"Free members"}):e.jsx(e.Fragment,{children:"Free members"})}),o?.paidMembersEnabled&&e.jsxs(e.Fragment,{children:[e.jsx(H,{className:"w-[140px] text-right",children:e.jsx(te,{activeSortBy:l,setSortBy:i,sortBy:"paid_members desc",children:"Paid members"})}),e.jsx(H,{className:"w-[140px] text-right",children:e.jsx(te,{activeSortBy:l,setSortBy:i,sortBy:"mrr desc",children:"MRR impact"})})]})]})}),f===Q.SOURCES?e.jsx(wa,{limit:20,range:s,setSortBy:d=>i(d),showViewAll:!0,sortBy:l}):e.jsx(le,{children:S?e.jsx(K,{className:"last:border-none",children:e.jsx(F,{className:"border-none py-2",colSpan:1,children:e.jsx(Ge,{containerClassName:"space-y-2",count:5,maxWidth:75,randomize:!0})})}):o?.analytics.membersTrackSources?v.length>0?v.map((d,k)=>e.jsxs(K,{className:"last:border-none",children:[e.jsx(F,{children:e.jsxs("div",{className:"group/link inline-flex flex-col items-start gap-px",children:[d.post_id&&d.attribution_type==="post"?e.jsx(Ce,{className:"h-auto whitespace-normal p-0 text-left font-medium leading-tight hover:!underline",title:"View post analytics",variant:"link",onClick:Rt(d.attribution_url,d.post_id,a.url||"",r,d.attribution_type),children:d.title}):e.jsx("span",{className:"font-medium",children:d.title}),d.published_at&&Oe&&new Date(d.published_at).getTime()>0&&e.jsxs("span",{className:"text-muted-foreground",children:["Published on ",Oe(d.published_at,t)]})]})}),e.jsxs(F,{className:"text-right font-mono text-sm",children:[d.free_members>0&&"+",T(d.free_members)]}),o?.paidMembersEnabled&&e.jsxs(e.Fragment,{children:[e.jsxs(F,{className:"text-right font-mono text-sm",children:[d.paid_members>0&&"+",T(d.paid_members)]}),e.jsxs(F,{className:"text-right font-mono text-sm",children:[d.mrr>0&&"+",N,T(J(d.mrr))]})]})]},`${f}-${d.post_id||`${d.title}-${k}`}`)):e.jsx(K,{className:"border-none",children:e.jsx(F,{className:"py-12 group-hover:!bg-transparent",colSpan:o?.paidMembersEnabled?4:2,children:e.jsx(ce,{description:"Try adjusting your date range to see more data.",title:`No conversions ${U(s)}`,children:e.jsx(da,{strokeWidth:1.5})})})}):e.jsx(K,{className:"last:border-none",children:e.jsx(F,{className:"border-none py-12 group-hover:!bg-transparent",colSpan:o?.paidMembersEnabled?4:2,children:e.jsx(tt,{})})})})]})})]})]})]})};export{ps as default};