ghost 6.18.1 → 6.18.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 (131) hide show
  1. package/components/tryghost-i18n-6.18.2.tgz +0 -0
  2. package/components/{tryghost-parse-email-address-6.18.1.tgz → tryghost-parse-email-address-6.18.2.tgz} +0 -0
  3. package/content/themes/source/package.json +1 -1
  4. package/core/built/admin/assets/{PolarAngleAxis-Dod0DwfL.js → PolarAngleAxis-DALH8FDm.js} +1 -1
  5. package/core/built/admin/assets/{_baseAssignValue-DnkbkowM.js → _baseAssignValue-D_UsvJRN.js} +1 -1
  6. package/core/built/admin/assets/{a-large-small-C5mgFBRg.js → a-large-small-DVyx4GMu.js} +1 -1
  7. package/core/built/admin/assets/admin-x-settings/admin-x-settings.js +2 -2
  8. package/core/built/admin/assets/admin-x-settings/{code-editor-view-BWi3-ftq.mjs → code-editor-view-DBrulgE8.mjs} +12 -12
  9. package/core/built/admin/assets/admin-x-settings/{index-B3PtvbUw.mjs → index-CsGHbqSU.mjs} +2 -2
  10. package/core/built/admin/assets/admin-x-settings/{index-Did70N9h.mjs → index-Cypgljb3.mjs} +2 -2
  11. package/core/built/admin/assets/admin-x-settings/{index-JaMlaX9G.mjs → index-DgGwb1L-.mjs} +1390 -1381
  12. package/core/built/admin/assets/admin-x-settings/{modals-Bwrf9ptQ.mjs → modals-rdo7i0D3.mjs} +9320 -8655
  13. package/core/built/admin/assets/{at-sign-Bz-SU-S_.js → at-sign-CGNkBrZS.js} +1 -1
  14. package/core/built/admin/assets/{audience-DmVdEmIe.js → audience-CJHVR7kD.js} +1 -1
  15. package/core/built/admin/assets/{avatar-flipboard-C7sxDVEM.js → avatar-flipboard-jqr9Aapd.js} +1 -1
  16. package/core/built/admin/assets/{bluesky-sharing-DJniSF6N.js → bluesky-sharing-C2749SVt.js} +1 -1
  17. package/core/built/admin/assets/{chart-mYz3IJwm.js → chart-BAQCVPCH.js} +1 -1
  18. package/core/built/admin/assets/{chunk.524.9d300778a63b42b0de62.js → chunk.524.428356d01feabbc7b932.js} +7 -7
  19. package/core/built/admin/assets/{chunk.582.2e363cd976d9bba998b9.js → chunk.582.b8b41ba720f49d724992.js} +9 -9
  20. package/core/built/admin/assets/{code-editor-view-BIQWFJ01.js → code-editor-view-YNhJ1w71.js} +1 -1
  21. package/core/built/admin/assets/{comments-B_-hdjc6.js → comments-CPd_iCc3.js} +1 -1
  22. package/core/built/admin/assets/{copy-Bpq3uhnh.js → copy-CNsHZEFR.js} +1 -1
  23. package/core/built/admin/assets/{data-list-BYNMbRIq.js → data-list-Dn5MkmyD.js} +1 -1
  24. package/core/built/admin/assets/{deleted-feed-item-B_AwUKZy.js → deleted-feed-item-Dmm_clMl.js} +1 -1
  25. package/core/built/admin/assets/{edit-profile-DZo2ZcOu.js → edit-profile-BLSdtROQ.js} +1 -1
  26. package/core/built/admin/assets/{empty-indicator-Bn5wG9-T.js → empty-indicator-C2Z0dddU.js} +1 -1
  27. package/core/built/admin/assets/{en-D4zIrMLN.js → en-DuTkaMAI.js} +1 -1
  28. package/core/built/admin/assets/{feed-Bgq4RarU.js → feed-B4Xp4C2J.js} +1 -1
  29. package/core/built/admin/assets/{filters-CpVwu1Gk.js → filters-gnOx5Z45.js} +1 -1
  30. package/core/built/admin/assets/{gh-chart-Br7NXn_b.js → gh-chart-B2aWYkGg.js} +1 -1
  31. package/core/built/admin/assets/{ghost-98a3c5fd6235ebd344594f491cb6d17b.js → ghost-29f8f3c80e41126ba5e3c52ad5727e8a.js} +176 -176
  32. package/core/built/admin/assets/ghost-transistor-BXCFhTPG.png +0 -0
  33. package/core/built/admin/assets/{growth-CiPDnWxJ.js → growth-BysawIWe.js} +1 -1
  34. package/core/built/admin/assets/{hash-Bc1e38oH.js → hash-j3sh-UI3.js} +1 -1
  35. package/core/built/admin/assets/{inbox-BcZNBNhk.js → inbox-1cUdr8Mm.js} +1 -1
  36. package/core/built/admin/assets/index-B2yksBz4.js +13 -0
  37. package/core/built/admin/assets/{index-CMTzNTew.js → index-B8G0f0hb.js} +3 -3
  38. package/core/built/admin/assets/{index-DU3bv9jz.js → index-BVoBTlp_.js} +1 -1
  39. package/core/built/admin/assets/{index-ETsoQLbU.js → index-BgrwCpgw.js} +1 -1
  40. package/core/built/admin/assets/{index-Bm5ZeLtt.js → index-BhY_SbGB.js} +1 -1
  41. package/core/built/admin/assets/index-CkAUXgAi.js +1 -0
  42. package/core/built/admin/assets/index-Cl_EPbQ2.js +1 -0
  43. package/core/built/admin/assets/{index-B_7QsC5T.js → index-D8CXbJm4.js} +1 -1
  44. package/core/built/admin/assets/index-DGBK5k9H.js +1 -0
  45. package/core/built/admin/assets/{index-D212VvOz.js → index-DKAlEWM4.js} +1 -1
  46. package/core/built/admin/assets/index-D_sGUCda.css +1 -0
  47. package/core/built/admin/assets/{index-BFEx_ouC.js → index-DarAAzVH.js} +1 -1
  48. package/core/built/admin/assets/{index-Brg4tecQ.js → index-Dz8eTtOq.js} +1 -1
  49. package/core/built/admin/assets/{index-Cn32t_gv.js → index-I9n711UW.js} +1 -1
  50. package/core/built/admin/assets/{index-CsidX7Si.js → index-WjY3mGep.js} +2 -2
  51. package/core/built/admin/assets/{index-Dv13wKfX.js → index-mhojl7aD.js} +1 -1
  52. package/core/built/admin/assets/{koenig-lexical-DZUWzN0P.js → koenig-lexical-coiS9dIC.js} +1 -1
  53. package/core/built/admin/assets/{kpi-card-DENsK2xK.js → kpi-card-BEFHo2gr.js} +1 -1
  54. package/core/built/admin/assets/{kpis-CDrs2iS1.js → kpis-D-gz-lUk.js} +1 -1
  55. package/core/built/admin/assets/{label-BznQtEEo.js → label-BvlHzzcJ.js} +1 -1
  56. package/core/built/admin/assets/{links-lpAC3T1p.js → links-tdJvBrsT.js} +1 -1
  57. package/core/built/admin/assets/list-filter-DPE4Xj2T.js +6 -0
  58. package/core/built/admin/assets/{lucide-react-CBigk-fq.js → lucide-react-ClQ3Iy7l.js} +1448 -1453
  59. package/core/built/admin/assets/{main-layout-_SYQRjIl.js → main-layout-DY96wK-_.js} +1 -1
  60. package/core/built/admin/assets/{message-square-text-cV8O_qKq.js → message-square-text-Dd1XS5-H.js} +1 -1
  61. package/core/built/admin/assets/{minus-NvnQTlW7.js → minus-CyEc3BE5.js} +1 -1
  62. package/core/built/admin/assets/modals-C06GcVIm.js +77 -0
  63. package/core/built/admin/assets/moderation-B0fdmlig.js +1 -0
  64. package/core/built/admin/assets/newsletter-Byg3ARa5.js +1 -0
  65. package/core/built/admin/assets/{newsletters-BexdXUhn.js → newsletters-DbH39vgA.js} +1 -1
  66. package/core/built/admin/assets/{note-DuaUGOeZ.js → note-Cwy-rIAF.js} +1 -1
  67. package/core/built/admin/assets/overview-CVMLGrVt.js +1 -0
  68. package/core/built/admin/assets/{pagemenu-CZyroidv.js → pagemenu-CkzsZrHC.js} +1 -1
  69. package/core/built/admin/assets/{post-analytics-DLK2SOSQ.js → post-analytics-aA-nG9Fq.js} +1 -1
  70. package/core/built/admin/assets/{post-analytics-context-CF7C67-0.js → post-analytics-context-BLkup0Xh.js} +1 -1
  71. package/core/built/admin/assets/{post-analytics-header-7GtJCx0W.js → post-analytics-header-D9srAPT5.js} +1 -1
  72. package/core/built/admin/assets/{post-share-modal-D8R7DUZP.js → post-share-modal-CkvJtrRw.js} +1 -1
  73. package/core/built/admin/assets/{posts-CL9UDYoW.js → posts-DDkuYoN7.js} +1 -1
  74. package/core/built/admin/assets/{repeat-DgH39UKE.js → repeat-B-SL0yPM.js} +1 -1
  75. package/core/built/admin/assets/{reply-DAaNxiy8.js → reply-BdCPoUQ9.js} +1 -1
  76. package/core/built/admin/assets/{select-Cor2wFXT.js → select-C7aNW8QS.js} +1 -1
  77. package/core/built/admin/assets/{settings-xRx917Gj.js → settings-Bzy1GNfD.js} +1 -1
  78. package/core/built/admin/assets/{settings-BeumESEN.js → settings-D-dhma2e.js} +23 -23
  79. package/core/built/admin/assets/{sort-button-BNW3i4Lb.js → sort-button-Dv8vjh13.js} +1 -1
  80. package/core/built/admin/assets/{source-icon-DvDuzw73.js → source-icon-DTz4isLK.js} +1 -1
  81. package/core/built/admin/assets/{sprout-C3cc0c-K.js → sprout-BwLQTzMf.js} +1 -1
  82. package/core/built/admin/assets/{square-tZp0_n7e.js → square-YF1YE9ex.js} +1 -1
  83. package/core/built/admin/assets/{stats-2Jelnn-Q.js → stats-C5ad0fgQ.js} +1 -1
  84. package/core/built/admin/assets/{stats-view-CESy8ELH.js → stats-view-BvkxPYNX.js} +1 -1
  85. package/core/built/admin/assets/{step-1-DrqdolAh.js → step-1-D7_s-D99.js} +1 -1
  86. package/core/built/admin/assets/{step-2-DmEpKck5.js → step-2-B94Yf7FF.js} +1 -1
  87. package/core/built/admin/assets/{step-3-Bus-0o0n.js → step-3-DswXYYf4.js} +1 -1
  88. package/core/built/admin/assets/{table-BQUcKHfm.js → table-D30IXfUP.js} +1 -1
  89. package/core/built/admin/assets/{tabs-BmdL0X4U.js → tabs-CjNdfW0y.js} +1 -1
  90. package/core/built/admin/assets/{tags-EchqlZUJ.js → tags-B0ux9_dT.js} +1 -1
  91. package/core/built/admin/assets/{tags-CLxXZlOO.js → tags-PGeGAafJ.js} +1 -1
  92. package/core/built/admin/assets/{tiers-nCGyTly9.js → tiers-BaXK0JoI.js} +1 -1
  93. package/core/built/admin/assets/{toggle-group-CM5uf7J1.js → toggle-group-DdY8HF3Y.js} +1 -1
  94. package/core/built/admin/assets/{topic-filter-LTRvZ8aU.js → topic-filter-Boh22uGD.js} +1 -1
  95. package/core/built/admin/assets/{trash-u5BxolyH.js → trash-D7ZWrnDq.js} +1 -1
  96. package/core/built/admin/assets/{url-helpers-D41fEt51.js → url-helpers-mt6MBIi0.js} +1 -1
  97. package/core/built/admin/assets/{use-growth-stats-BJ0O9ewi.js → use-growth-stats-Bg0nE0WG.js} +1 -1
  98. package/core/built/admin/assets/{use-infinite-virtual-scroll-APZWciOk.js → use-infinite-virtual-scroll-DoeI5IY-.js} +1 -1
  99. package/core/built/admin/assets/{use-simple-pagination-DVRHeaAR.js → use-simple-pagination-BJzBULR3.js} +1 -1
  100. package/core/built/admin/assets/{user-round-check-B6j98D6d.js → user-round-check-BLc3L-ei.js} +1 -1
  101. package/core/built/admin/assets/{wallet-cards-KmOh29LP.js → wallet-cards-xX4QZik7.js} +1 -1
  102. package/core/built/admin/assets/web-DQ2qBymm.js +1 -0
  103. package/core/built/admin/index.html +5 -5
  104. package/core/server/lib/image/cached-image-size-from-url.js +37 -25
  105. package/core/server/lib/lexical.js +1 -0
  106. package/core/server/lib/mobiledoc.js +1 -0
  107. package/core/server/services/email-service/email-renderer.js +6 -2
  108. package/core/server/services/email-service/email-service-wrapper.js +2 -2
  109. package/core/server/services/koenig/node-renderers/call-to-action-renderer.js +2 -2
  110. package/core/server/services/koenig/node-renderers/gallery-renderer.js +3 -3
  111. package/core/server/services/koenig/node-renderers/image-renderer.js +3 -3
  112. package/core/server/services/koenig/render-utils/is-content-image.js +18 -0
  113. package/core/server/services/koenig/render-utils/srcset-attribute.js +4 -4
  114. package/core/server/services/members/members-api/controllers/router-controller.js +21 -36
  115. package/core/server/services/members/members-api/repositories/member-repository.js +8 -1
  116. package/core/server/services/offers/offer-bookshelf-repository.js +3 -3
  117. package/core/shared/config/defaults.json +1 -1
  118. package/core/shared/labs.js +2 -1
  119. package/package.json +5 -5
  120. package/components/tryghost-i18n-6.18.1.tgz +0 -0
  121. package/core/built/admin/assets/index-BBrewxpF.css +0 -1
  122. package/core/built/admin/assets/index-BpcL7RmI.js +0 -13
  123. package/core/built/admin/assets/index-CTfJflJ2.js +0 -1
  124. package/core/built/admin/assets/index-D67LJ_H4.js +0 -1
  125. package/core/built/admin/assets/index-ZYDRMgcT.js +0 -1
  126. package/core/built/admin/assets/modals-XRSkribf.js +0 -77
  127. package/core/built/admin/assets/moderation-BQp1GEWG.js +0 -1
  128. package/core/built/admin/assets/newsletter-foM6KNNV.js +0 -1
  129. package/core/built/admin/assets/overview-DgKBNqyc.js +0 -1
  130. package/core/built/admin/assets/web-Cclotbnz.js +0 -1
  131. package/core/server/services/koenig/render-utils/is-local-content-image.js +0 -9
@@ -0,0 +1 @@
1
+ import{r as c,bV as G,aP as te,bG as se,bW as K,aj as D,j as e,aQ as ee,ai as y,bH as pe,ap as he,bI as xe,bJ as Y,bX as fe,bR as ae,af as Q,ag as $,bY as ge,e as U,bE as be,B as je}from"./index-B8G0f0hb.js";import{s as ve,g as J,S as ke,a as we,D as Ne,b as Se}from"./stats-view-BvkxPYNX.js";import{C as ye,a as _e,R as Ce,B as Te}from"./chart-BAQCVPCH.js";import{E as re}from"./empty-indicator-C2Z0dddU.js";import{G as De,C as Me,X as Le,Y as Re}from"./gh-chart-B2aWYkGg.js";import{T as Ee,a as Be,K as X,d as B,e as Pe}from"./tabs-CjNdfW0y.js";import{B as Oe,S as H}from"./sort-button-Dv8vjh13.js";import{M as ne}from"./wallet-cards-xX4QZik7.js";import{S as Ae,a as Ve,b as ze,c as He,d as We,e as $e,f as Ge}from"./select-C7aNW8QS.js";import{M as Ke}from"./lucide-react-ClQ3Iy7l.js";import{j as Fe,C as le,c as ie,a as Ie,b as Ye,f as Xe}from"./pagemenu-CkzsZrHC.js";import{a as Qe,e as Ue,b as Je,c as W,d as O,f as L}from"./table-D30IXfUP.js";import{u as qe}from"./newsletters-DbH39vgA.js";import{e as Ze,f as et,g as tt}from"./stats-C5ad0fgQ.js";import"./message-square-text-Dd1XS5-H.js";import"./sprout-BwLQTzMf.js";import"./_baseAssignValue-D_UsvJRN.js";import"./index-DKAlEWM4.js";import"./a-large-small-DVyx4GMu.js";import"./at-sign-CGNkBrZS.js";import"./copy-CNsHZEFR.js";import"./hash-j3sh-UI3.js";import"./inbox-1cUdr8Mm.js";import"./list-filter-DPE4Xj2T.js";import"./minus-CyEc3BE5.js";import"./tags-PGeGAafJ.js";import"./square-YF1YE9ex.js";import"./user-round-check-BLc3L-ei.js";import"./repeat-B-SL0yPM.js";import"./reply-BdCPoUQ9.js";import"./trash-D7ZWrnDq.js";const st=({active:a,payload:s})=>{if(!a||!s?.length)return null;const r=s[0].payload,l=r.send_date;return e.jsxs("div",{className:"min-w-[220px] max-w-[240px] rounded-lg border bg-background px-3 py-2 shadow-lg",children:[e.jsxs("div",{className:"mb-2 flex w-full flex-col border-b pb-2",children:[e.jsx("span",{className:"text-sm font-semibold leading-tight",children:r.post_title}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["Sent on ",ae(l)]})]}),e.jsxs("div",{className:"mb-1 flex w-full justify-between",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Sent"}),e.jsx("div",{className:"ml-2 w-full text-right font-mono",children:D(r.sent_to)})]}),e.jsxs("div",{className:"mb-1 flex w-full justify-between",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Opens"}),e.jsxs("div",{className:"ml-2 w-full text-right font-mono",children:[e.jsxs("span",{className:"text-muted-foreground",children:[D(r.total_opens)," / "]}),y(r.open_rate)]})]}),e.jsxs("div",{className:"mb-1 flex w-full justify-between",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Clicks"}),e.jsxs("div",{className:"ml-2 w-full text-right font-mono",children:[e.jsxs("span",{className:"text-muted-foreground",children:[D(r.total_clicks)," / "]}),y(r.click_rate)]})]})]})},at=({subscribersData:a,avgsData:s,totals:r,isLoading:l,isAvgsLoading:t,initialTab:i="total-subscribers"})=>{const[n,h]=c.useState(i),[p,j]=c.useState(!1),{range:u}=G(),w=te(),[g]=se(),{appSettings:N}=K(),{emailTrackClicks:v,emailTrackOpens:S}=N?.analytics||{},{totalSubscribers:R,avgOpenRate:m,avgClickRate:d}=r,f=c.useMemo(()=>{if(!a||a.length===0)return[];let o=[];return o=ve(a,u,"value","exact"),o.map(M=>({...M,formattedValue:D(M.value),label:"Total Subscribers"}))},[a,u]),_=c.useMemo(()=>{if(!f||f.length<=1)return{direction:"same",value:"0%"};const o=f[0]?.value??0,k=f[f.length-1]?.value??0;let M="same";k>o?M="up":k<o&&(M="down");let P;if(o===0)P=k===0?"0%":"+100%";else{const A=(k-o)/o*100,V=Math.round(A*10)/10;P=`${A>=0?"+":""}${V}%`}return{direction:M,value:P}},[f]);c.useEffect(()=>{h(i)},[i]);const x=o=>{h(o);const k=new URLSearchParams(g);k.set("tab",o),w(`?${k.toString()}`,{replace:!0})},C={open_rate:{label:"Open rate"}},b=c.useMemo(()=>({"total-subscribers":{color:"hsl(var(--chart-darkblue))",datakey:"value"},"avg-open-rate":{color:"hsl(var(--chart-blue))",datakey:"open_rate"},"avg-click-rate":{color:"hsl(var(--chart-teal))",datakey:"click_rate"}}),[]),{barDomain:T,barTicks:E}=c.useMemo(()=>{if(!s||s.length===0||n==="total-subscribers")return{barDomain:[0,1],barTicks:[0,1]};const o=b[n]?.datakey;if(!o)return{barDomain:[0,1],barTicks:[0,1]};const k=s.map(I=>I[o]).filter(I=>typeof I=="number");if(k.length===0)return{barDomain:[0,1],barTicks:[0,1]};const M=Math.min(...k),P=Math.max(...k),A=Math.floor(M*10)/10,V=Math.ceil(P*10)/10,z=Math.max(0,A),Z=V===z?z+.1:V;return{barDomain:[z,Z],barTicks:[z,Z]}},[s,n,b]);if(l)return e.jsx("div",{className:"-mb-6 flex h-[calc(16vw+132px)] w-full items-start justify-center",children:e.jsx(ee,{})});let F="grid-cols-3";(!v||!S)&&(F="grid-cols-2"),!v&&!S&&(F="grid-cols-1");const ue=n==="avg-open-rate"&&m>T[0]&&m<T[1]||n==="avg-click-rate"&&d>T[0]&&d<T[1],q=n==="avg-open-rate"?m:d;return e.jsxs(Ee,{defaultValue:i,variant:"kpis",children:[e.jsxs(Be,{className:`-mx-6 hidden grid-cols-3 md:!visible md:!grid ${F}`,children:[e.jsx(X,{className:`${!S&&!v&&"cursor-auto after:hidden"}`,value:"total-subscribers",onClick:()=>{x("total-subscribers")},children:e.jsx(B,{color:b["total-subscribers"].color,"data-testid":"total-subscribers-value",diffDirection:_.direction,diffValue:_.value,label:"Total subscribers",value:D(R)})}),S&&e.jsx(X,{value:"avg-open-rate",onClick:()=>{x("avg-open-rate")},children:e.jsx(B,{className:t?"opacity-50":"",color:b["avg-open-rate"].color,label:"Avg. open rate",value:y(m)})}),v&&e.jsx(X,{value:"avg-click-rate",onClick:()=>{x("avg-click-rate")},children:e.jsx(B,{className:t?"opacity-50":"",color:b["avg-click-rate"].color,label:"Avg. click rate",value:y(d)})})]}),e.jsxs(pe,{children:[e.jsx(he,{className:"md:hidden",asChild:!0,children:e.jsxs(Pe,{children:[n==="total-subscribers"&&e.jsx(B,{color:b["total-subscribers"].color,label:"Total subscribers",value:D(R)}),n==="avg-open-rate"&&S&&e.jsx(B,{className:t?"opacity-50":"",color:b["avg-open-rate"].color,label:"Avg. open rate",value:y(m)}),n==="avg-click-rate"&&v&&e.jsx(B,{className:t?"opacity-50":"",color:b["avg-click-rate"].color,label:"Avg. click rate",value:y(d)})]})}),e.jsxs(xe,{align:"end",className:"w-56",children:[e.jsx(Y,{onClick:()=>x("total-subscribers"),children:"Total subscribers"}),S&&e.jsx(Y,{onClick:()=>x("avg-open-rate"),children:"Avg. open rate"}),v&&e.jsx(Y,{onClick:()=>x("avg-click-rate"),children:"Avg. click rate"})]})]}),e.jsxs("div",{className:"my-4 [&_.recharts-cartesian-axis-tick-value]:fill-gray-500",children:[n==="total-subscribers"&&e.jsx(De,{className:"-mb-3 h-[16vw] max-h-[320px] min-h-[180px] w-full",color:b["total-subscribers"].color,data:f,id:"mrr",range:u}),(n==="avg-open-rate"&&S||n==="avg-click-rate"&&v)&&e.jsx(e.Fragment,{children:t?e.jsx("div",{className:"h-[320px] w-full items-center justify-center",children:e.jsx(ee,{})}):s&&s.length>0?e.jsxs(e.Fragment,{children:[e.jsx(ye,{className:"aspect-auto h-[200px] w-full md:h-[220px] xl:h-[320px]",config:C,children:e.jsxs(Oe,{className:p?"!cursor-pointer":"",data:s,margin:{top:20},onClick:o=>{o.activePayload&&o.activePayload[0].payload.post_id&&w(`/posts/analytics/${o.activePayload[0].payload.post_id}`,{crossApp:!0})},onMouseLeave:()=>j(!1),onMouseMove:o=>{j(!!(o.activePayload&&o.activePayload[0].payload.post_id))},children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"barGradient",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:b[n].color,stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:b[n].color,stopOpacity:.6})]})}),e.jsx(Me,{horizontal:!0,stroke:"hsl(var(--border))",vertical:!1}),e.jsx(Le,{axisLine:{stroke:"hsl(var(--border))",strokeWidth:1},dataKey:"post_id",interval:0,stroke:"hsl(var(--border))",tickFormatter:()=>"",tickLine:!1,tickMargin:10}),e.jsx(Re,{axisLine:!1,domain:T,tickFormatter:o=>y(o),tickLine:!1,ticks:E,width:fe(E,o=>y(o))}),e.jsx(_e,{content:e.jsx(st,{}),cursor:!1,isAnimationActive:!1,position:{y:10}}),ue&&e.jsx(Ce,{label:{value:`${y(q)}`,position:"left",offset:8,fill:"hsl(var(--muted-foreground))"},opacity:.5,stroke:"hsl(var(--muted-foreground))",strokeDasharray:"4 4",y:q}),e.jsx(Te,{activeBar:{fillOpacity:1},dataKey:b[n].datakey,fill:"url(#barGradient)",fillOpacity:.6,isAnimationActive:!1,maxBarSize:32,minPointSize:3,radius:4})]})}),e.jsxs("div",{className:"-mt-4 text-center text-sm text-muted-foreground",children:["Newsletters ",n==="avg-open-rate"?"opens":"clicks"," in this period"]})]}):e.jsx(re,{className:"size-full py-20",title:`No newsletters ${J(u)}`,children:e.jsx(ne,{strokeWidth:1.5})})})]})]})},rt=({newsletters:a})=>{const{selectedNewsletterId:s,setSelectedNewsletterId:r}=G(),l=c.useMemo(()=>a?.filter(t=>t.status==="active")||[],[a]);return c.useEffect(()=>{if(l.length>0&&!s){const t=l.find(i=>i.sort_order===0);r(t?t.id:l[0].id)}},[l,s,r]),l.length<=1?null:e.jsxs(Ae,{value:s||"",onValueChange:t=>{r(t)},children:[e.jsxs(Ve,{className:"w-auto",children:[e.jsx(Ke,{className:"mr-2",size:16,strokeWidth:1.5}),e.jsx(ze,{placeholder:"Select a newsletter"})]}),e.jsx(He,{align:"end",children:e.jsxs(We,{children:[e.jsx($e,{children:"Newsletters"}),l.map(t=>e.jsx(Ge,{value:t.id,children:t.name},t.id))]})})]})},nt=(a,s,r=!0)=>{const l=a??30,{startDate:t,endDate:i}=c.useMemo(()=>Q(l),[l]),n=c.useMemo(()=>{const p={date_from:$(t),date_to:$(i)};return s&&(p.newsletter_id=s),p},[t,i,s]),h=Ze({searchParams:n,enabled:r});return r?h:{data:void 0,isLoading:!1,error:null,isError:!1,refetch:h.refetch}},lt=(a,s,r,l=!0)=>{const t=a??30,i=s??"date desc",{startDate:n,endDate:h}=c.useMemo(()=>Q(t),[t]),p=c.useMemo(()=>{const u={date_from:$(n),date_to:$(h),order:i};return r&&(u.newsletter_id=r),u},[n,h,i,r]),j=et({searchParams:p,enabled:l});return l?j:{data:void 0,isLoading:!1,error:null,isError:!1,refetch:j.refetch}},it=(a,s=[],r=!0)=>{const l=c.useMemo(()=>{const i={};return a&&(i.newsletter_id=a),s.length>0&&(i.post_ids=s.join(",")),i},[a,s]),t=tt({searchParams:l,enabled:r});return r?t:{data:void 0,isLoading:!1,error:null,isError:!1,refetch:t.refetch}},oe=(a,s,r,l=!0)=>{const t=lt(a,s,r,l),i=c.useMemo(()=>t.data?.stats?t.data.stats.map(p=>p.post_id):[],[t.data]),n=it(r,i,l&&i.length>0);return{data:c.useMemo(()=>{if(!t.data?.stats)return;const p=t.data.stats,j=n.data?.stats||[],u=new Map;j.forEach(g=>{u.set(g.post_id,g)});const w=p.map(g=>{const N=u.get(g.post_id);return{...g,total_clicks:N?.total_clicks||0,click_rate:N?.click_rate||0}});return{...t.data,stats:w}},[t.data,n.data]),isLoading:t.isLoading,isClicksLoading:n.isLoading,error:t.error||n.error,isError:t.isError||n.isError,refetch:()=>{t.refetch(),n.refetch()}}},ce=U.memo(({range:a,selectedNewsletterId:s,shouldFetchStats:r,sortBy:l})=>{const t=te(),{settings:i}=G(),n=String(i.find(m=>m.key==="timezone")?.value||"Etc/UTC"),{data:h,isLoading:p,isClicksLoading:j}=oe(a,l,s||void 0,!!r),{appSettings:u}=K(),{emailTrackClicks:w,emailTrackOpens:g}=u?.analytics||{},N=c.useMemo(()=>h?.stats||[],[h]),v=g&&w?5:g||w?4:3,S=c.useMemo(()=>e.jsx(e.Fragment,{children:e.jsx(W,{className:"last:border-none [&>td]:py-2.5",children:e.jsx(L,{className:"font-medium",colSpan:v,children:e.jsx(be,{className:"mt-5"})})})}),[v]),R=c.useMemo(()=>N.length>0?e.jsx(e.Fragment,{children:N.map(m=>e.jsxs(W,{className:"last:border-none [&>td]:py-2.5",children:[e.jsx(L,{className:"font-medium",children:e.jsx("div",{className:"group/link inline-flex items-center gap-2",children:m.post_id?e.jsx(je,{className:"h-auto whitespace-normal p-0 text-left hover:!underline",title:"View post analytics",variant:"link",onClick:()=>{t(`/posts/analytics/${m.post_id}/`,{crossApp:!0})},children:m.post_title}):e.jsx(e.Fragment,{children:m.post_title})})}),e.jsx(L,{className:"whitespace-nowrap text-sm",children:ae(m.send_date,n)}),e.jsx(L,{className:"text-right font-mono text-sm",children:D(m.sent_to)}),g&&e.jsxs(L,{className:"text-right font-mono text-sm",children:[e.jsx("span",{className:"group-hover:hidden",children:y(m.open_rate)}),e.jsx("span",{className:"hidden group-hover:!visible group-hover:!block",children:D(m.total_opens)})]}),w&&e.jsx(L,{className:"text-right font-mono text-sm",children:j?e.jsx("span",{className:"inline-block h-4 w-8 animate-pulse rounded bg-gray-200"}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"group-hover:hidden",children:y(m.click_rate)}),e.jsx("span",{className:"hidden group-hover:!visible group-hover:!block",children:D(m.total_clicks)})]})})]},m.post_id))}):e.jsx(W,{className:"border-none hover:bg-transparent",children:e.jsx(L,{className:"text-center group-hover:!bg-transparent",colSpan:5,children:e.jsx(re,{className:"size-full py-20",title:`No newsletters ${J(a)}`,children:e.jsx(ne,{strokeWidth:1.5})})})}),[N,j,t,w,g,a]);return p||!h?S:R});ce.displayName="NewsletterTableRows";const de=U.memo(({sortBy:a,setSortBy:s,range:r})=>{const l=c.useMemo(()=>e.jsxs(Ie,{children:[e.jsx(Ye,{children:"Top newsletters"}),e.jsxs(Xe,{children:[" Your best performing newsletters ",J(r)]})]}),[r]),{appSettings:t}=K(),{emailTrackClicks:i,emailTrackOpens:n}=t?.analytics||{};return e.jsx(Je,{children:e.jsxs(W,{children:[e.jsx(O,{className:"min-w-[320px]",variant:"cardhead",children:l}),e.jsx(O,{className:"w-[65px]",children:e.jsx(H,{activeSortBy:a,setSortBy:s,sortBy:"date desc",children:"Date"})}),e.jsx(O,{className:"w-[90px] text-right",children:e.jsx(H,{activeSortBy:a,setSortBy:s,sortBy:"sent_to desc",children:"Sent"})}),n&&e.jsx(O,{className:"w-[90px] text-right",children:e.jsx(H,{activeSortBy:a,setSortBy:s,sortBy:"open_rate desc",children:"Opens"})}),i&&e.jsx(O,{className:"w-[90px] text-right",children:e.jsx(H,{activeSortBy:a,setSortBy:s,sortBy:"click_rate desc",children:"Clicks"})})]})})});de.displayName="NewsletterTableHeader";const me=U.memo(({range:a,selectedNewsletterId:s,shouldFetchStats:r})=>{const[l,t]=c.useState("open_rate desc");return e.jsx(le,{className:"w-full max-w-[calc(100vw-64px)] overflow-x-auto sidebar:max-w-[calc(100vw-64px-280px)]","data-testid":"top-newsletters-card",children:e.jsx(ie,{children:e.jsxs(Qe,{children:[e.jsx(de,{range:a,setSortBy:t,sortBy:l}),e.jsx(Ue,{children:e.jsx(ce,{range:a,selectedNewsletterId:s,shouldFetchStats:r,sortBy:l})})]})})})});me.displayName="TopNewslettersTable";const zt=()=>{const{range:a,selectedNewsletterId:s}=G(),[r]=se(),{appSettings:l}=K(),t=r.get("tab")||"total-subscribers",{data:i,isLoading:n}=qe({searchParams:{limit:"50"}}),h=!n&&i&&i.newsletters.length>0&&!!s,{data:p,isLoading:j}=nt(a,s||void 0,h||!1),{data:u,isLoading:w,isClicksLoading:g}=oe(a,"date asc",s||void 0,h||!1),N=c.useMemo(()=>!i?.newsletters||!s?null:i.newsletters.find(d=>d.id===s)||null,[i,s]),v=c.useMemo(()=>{const d=N?.count?.active_members||p?.stats?.[0]?.total||0;let f=0,_=0;if(u?.stats&&u.stats.length>0){const x=u.stats,C=x.reduce((T,E)=>T+(E.open_rate||0),0),b=x.reduce((T,E)=>T+(E.click_rate||0),0);f=C/x.length,_=b/x.length}return{totalSubscribers:d,avgOpenRate:f,avgClickRate:_}},[N,p,u]),S=c.useMemo(()=>{if(!p?.stats?.[0]?.values||p.stats[0].values.length===0){const{startDate:f,endDate:_}=Q(a),x=[],C=new Date(f);for(;C<=_;)x.push({date:C.toISOString().split("T")[0],value:0}),C.setDate(C.getDate()+1);return x}const d=p.stats[0].values;if(d.length===1){const f=d[0],_=new Date,x=a,C=new Date(_.getTime()-x*24*60*60*1e3);return[{...f,date:C.toISOString().split("T")[0]},{...f,date:_.toISOString().split("T")[0]}]}return d},[p,a]),R=c.useMemo(()=>u?.stats?u.stats.map(d=>({post_id:d.post_id,post_title:d.post_title,send_date:d.send_date,sent_to:d.sent_to,total_opens:d.total_opens,open_rate:d.open_rate,total_clicks:d.total_clicks||0,click_rate:d.click_rate||0})):[],[u]),m=j||g||w;return l&&!l.newslettersEnabled?e.jsx(ge,{to:"/analytics"}):e.jsxs(ke,{children:[e.jsx(we,{children:e.jsxs(Fe,{children:[e.jsx(rt,{newsletters:i?.newsletters}),e.jsx(Ne,{})]})}),e.jsx(Se,{isLoading:!1,loadingComponent:e.jsx(e.Fragment,{}),children:e.jsxs(e.Fragment,{children:[e.jsx(le,{"data-testid":"newsletters-card",children:e.jsx(ie,{children:e.jsx(at,{avgsData:R,initialTab:t,isAvgsLoading:!1,isLoading:m,subscribersData:S,totals:v})})}),e.jsx(me,{range:a,selectedNewsletterId:s,shouldFetchStats:!!h})]})})]})};export{zt as default};
@@ -0,0 +1 @@
1
+ import{aP as Y,r as _,bV as C,bW as W,j as e,S as j,bR as se,B as T,aT as M,aj as u,y as $,ai as Q,cz as te,aQ as oe,cA as O,e as le,cB as q,cC as ce,bE as de,cD as X,bK as me,cE as ue,af as pe,ag as z,aW as I,_ as xe,aX as he}from"./index-B8G0f0hb.js";import{g as H,S as ge,a as fe,D as be,b as je}from"./stats-view-BvkxPYNX.js";import{C as D,a as E,b as F,f as R,c as V,E as ve,K as Ne,d as we,e as ye,u as ke,j as _e}from"./pagemenu-CkzsZrHC.js";import{E as P}from"./empty-indicator-C2Z0dddU.js";import{P as Ce}from"./post-share-modal-CkvJtrRw.js";import{g as Ae,c as Te}from"./post-helpers-gInwAwEv.js";import{S as Le,U as ae}from"./wallet-cards-xX4QZik7.js";import{C as ze,h as K,d as Me,i as We,L as $e,j as J,k as Z,l as De}from"./lucide-react-ClQ3Iy7l.js";import{G as B}from"./gh-chart-B2aWYkGg.js";import{g as Ee}from"./audience-CJHVR7kD.js";import{u as Fe}from"./use-growth-stats-Bg0nE0WG.js";import{u as Re}from"./posts-DDkuYoN7.js";import{h as Ve,i as Ue}from"./stats-C5ad0fgQ.js";import"./select-C7aNW8QS.js";import"./message-square-text-Dd1XS5-H.js";import"./sprout-BwLQTzMf.js";import"./a-large-small-DVyx4GMu.js";import"./at-sign-CGNkBrZS.js";import"./copy-CNsHZEFR.js";import"./hash-j3sh-UI3.js";import"./inbox-1cUdr8Mm.js";import"./list-filter-DPE4Xj2T.js";import"./minus-CyEc3BE5.js";import"./tags-PGeGAafJ.js";import"./square-YF1YE9ex.js";import"./user-round-check-BLc3L-ei.js";import"./repeat-B-SL0yPM.js";import"./reply-BdCPoUQ9.js";import"./trash-D7ZWrnDq.js";import"./chart-BAQCVPCH.js";import"./_baseAssignValue-D_UsvJRN.js";import"./currency-fEUUCkj0.js";const Ie=s=>s.email_only?"Sent":s.email?"Published and sent":"Published",Be=({latestPostStats:s,isLoading:o})=>{const t=Y(),[r,i]=_.useState(!1),{site:n,settings:x}=C(),{appSettings:l}=W(),{emailTrackClicks:c,emailTrackOpens:h}=l?.analytics||{},m=n.title||String(x.find(g=>g.key==="title")?.value||"Ghost Site"),a=String(x.find(g=>g.key==="timezone")?.value||"Etc/UTC"),d=s?Ae(s,{membersTrackSources:l?.analytics.membersTrackSources}):null,b="group mr-2 flex flex-col gap-1.5 hover:cursor-pointer";return e.jsxs(D,{className:"group/card bg-gradient-to-tr from-muted/40 to-muted/0 to-50%","data-testid":"latest-post",children:[e.jsxs(E,{children:[e.jsx(F,{className:"flex items-baseline justify-between font-medium leading-snug text-muted-foreground",children:"Latest post performance"}),e.jsx(R,{className:"hidden",children:"How your last post did"})]}),e.jsxs(V,{className:"flex flex-col gap-6 px-0 lg:flex-row xl:grid xl:grid-cols-3",children:[o&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex w-full items-center gap-6 px-6 xl:col-span-2",children:[e.jsx("div",{className:"w-full max-w-[232px] grow",children:e.jsx(j,{className:"aspect-[16/10] rounded-md"})}),e.jsxs("div",{className:"w-full grow",children:[e.jsx(j,{className:"w-full max-w-[420px]"}),e.jsx(j,{className:"w-1/2"})]})]}),e.jsx("div",{className:"flex flex-col items-stretch gap-2 px-6 text-sm",children:e.jsxs("div",{className:"grid grid-cols-2 gap-5",children:[e.jsxs("div",{children:[e.jsx(j,{className:"w-3/4"}),e.jsx(j,{className:"h-10 w-1/3"})]}),e.jsxs("div",{children:[e.jsx(j,{className:"w-3/4"}),e.jsx(j,{className:"h-10 w-1/3"})]}),e.jsxs("div",{children:[e.jsx(j,{className:"w-3/4"}),e.jsx(j,{className:"h-10 w-1/3"})]}),e.jsxs("div",{children:[e.jsx(j,{className:"w-3/4"}),e.jsx(j,{className:"h-10 w-1/3"})]})]})})]}),!o&&s&&d?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col gap-6 px-6 transition-all md:flex-row md:items-start xl:col-span-2",children:[s.feature_image&&e.jsx("div",{className:"aspect-[16/10] w-full min-w-[100px] rounded-sm bg-cover bg-center sm:max-w-[170px] lg:max-w-[170px] xl:max-w-[232px]",style:{backgroundImage:`url(${s.feature_image})`}}),e.jsxs("div",{className:"flex grow flex-col items-start justify-center self-stretch",children:[e.jsx("div",{className:"text-lg font-semibold leading-tighter tracking-tight hover:cursor-pointer hover:opacity-75",onClick:()=>{!o&&s&&t(`/posts/analytics/${s.id}`,{crossApp:!0})},children:s.title}),e.jsxs("div",{className:"mt-0.5 text-sm text-muted-foreground",children:[s.authors&&s.authors.length>0&&e.jsxs("div",{children:["By ",s.authors.map(g=>g.name).join(", ")," – ",se(s.published_at,a)]}),e.jsx("div",{className:"mt-0.5",children:Ie(s)})]}),e.jsxs("div",{className:"mt-6 flex items-center gap-2",children:[!s.email_only&&e.jsx(Ce,{author:s.authors?.map(g=>g.name).join(", ")||"",description:"",faviconURL:n.icon||"",featureImageURL:s.feature_image||"",open:r,postExcerpt:s.excerpt||"",postTitle:s.title,postURL:s.url||"",siteTitle:m,onClose:()=>i(!1),onOpenChange:i,children:e.jsxs(T,{onClick:()=>i(!0),children:[e.jsx(Le,{})," Share post"]})}),e.jsxs(T,{className:s.email_only?"w-full":"",variant:"outline",onClick:()=>{t(`/posts/analytics/${s.id}`,{crossApp:!0})},children:[e.jsx(ze,{}),e.jsx("span",{className:"hidden md:!visible md:!block",children:s.email_only?"Post analytics":"Analytics"})]})]})]})]}),e.jsx("div",{className:"-ml-4 flex w-full flex-col items-stretch gap-2 pr-6 text-sm xl:h-full xl:max-w-none",children:e.jsxs("div",{className:"grid grid-cols-2 gap-6 pl-10 lg:border-l xl:h-full",children:[d.showWebMetrics&&l?.analytics.webAnalytics&&e.jsxs("div",{className:b,"data-testid":"latest-post-visitors",onClick:()=>{t(`/posts/analytics/${s.id}/web`,{crossApp:!0})},children:[e.jsxs("div",{className:"flex items-center gap-1.5 font-medium text-muted-foreground transition-all group-hover:text-foreground",children:[e.jsx(M,{size:16,strokeWidth:1.25}),e.jsx("span",{className:"hidden md:!visible md:!block",children:"Visitors"})]}),e.jsx("span",{className:"text-[2.2rem] font-semibold leading-none tracking-tighter",children:u(s.visitors)})]}),d.showMemberGrowth&&e.jsxs("div",{className:$(b,d.showEmailMetrics&&(!d.showWebMetrics||!l?.analytics.webAnalytics)&&"row-[2/3] col-[1/2]"),"data-testid":"latest-post-members",onClick:()=>{t(`/posts/analytics/${s.id}/growth`,{crossApp:!0})},children:[e.jsxs("div",{className:"flex items-center gap-1.5 font-medium text-muted-foreground transition-all group-hover:text-foreground",children:[e.jsx(ae,{size:16,strokeWidth:1.25}),e.jsx("span",{className:"hidden md:!visible md:!block",children:"Members"})]}),e.jsx("span",{className:"text-[2.2rem] font-semibold leading-none tracking-tighter",children:s.member_delta?e.jsxs(e.Fragment,{children:["+",u(s.member_delta)]}):0})]}),d.showEmailMetrics&&s.email&&e.jsxs(e.Fragment,{children:[h&&e.jsxs("div",{className:b,onClick:()=>{t(`/posts/analytics/${s.id}/newsletter`,{crossApp:!0})},children:[e.jsxs("div",{className:"flex items-center gap-1.5 font-medium text-muted-foreground transition-all group-hover:text-foreground",children:[e.jsx(K,{size:16,strokeWidth:1.25}),e.jsx("span",{className:"hidden whitespace-nowrap md:!visible md:!block",children:"Opens"})]}),e.jsx("span",{className:"text-[2.2rem] font-semibold leading-none tracking-tighter",children:s.email.email_count?Q((s.email.opened_count||0)/s.email.email_count):"0%"})]}),c&&e.jsxs("div",{className:b,onClick:()=>{t(`/posts/analytics/${s.id}/newsletter`,{crossApp:!0})},children:[e.jsxs("div",{className:"flex items-center gap-1.5 font-medium text-muted-foreground transition-all group-hover:text-foreground",children:[e.jsx(Me,{size:16,strokeWidth:1.25}),e.jsx("span",{className:"hidden whitespace-nowrap md:!visible md:!block",children:"Clicks"})]}),e.jsx("span",{className:"text-[2.2rem] font-semibold leading-none tracking-tighter",children:s.email.email_count&&s.count?.clicks?Q((s.count.clicks||0)/s.email.email_count):"0%"})]})]})]})})]}):!o&&e.jsx(P,{actions:e.jsx(T,{variant:"secondary",onClick:()=>{t("/editor/post",{crossApp:!0})},children:"New post"}),className:"w-full pb-10 xl:col-span-3",description:"Once it's live, you can track performance here",title:"Publish your first post",children:e.jsx(te,{strokeWidth:1.5})})]})]})},Ge=()=>{const{data:s}=C();return{isLimited:t=>{const r=s?.config;return r?.hostSettings?.limits&&t==="limitAnalytics"?r.hostSettings.limits.limitAnalytics?.disabled===!0:!1}}},G=({title:s,iconName:o,description:t,color:r,diffDirection:i,diffValue:n,formattedValue:x,trendingFromValue:l,children:c,onClick:h})=>{const{range:m}=C(),a=o&&$e[o],d=le.useMemo(()=>{if(!i||i==="empty"||m===q.allTime.value||!n)return"";const b=i==="up"?"up":i==="down"?"down":"at",N=H(m).replace("in the ","").replace(/^\(|\)$/g,"");return i==="same"?e.jsxs("span",{children:["You're trending at the same level as ",e.jsx("span",{className:"font-semibold",children:x})," compared to the ",e.jsx("span",{className:"font-semibold",children:N})]}):e.jsxs("span",{children:["You're trending ",e.jsxs("span",{className:"font-semibold",children:[b," ",n]})," from ",e.jsx("span",{className:"font-semibold",children:l})," compared to the ",N]})},[i,n,l,x,m]);return e.jsxs(D,{className:"group","data-testid":s,children:[e.jsxs(E,{className:"hidden",children:[e.jsx(F,{children:s}),e.jsx(R,{children:t})]}),e.jsxs(Ne,{className:"relative flex grow flex-row items-start justify-between gap-5 border-none pb-2 xl:pb-4",children:[e.jsxs("div",{className:"flex grow flex-col gap-1.5 border-none pb-0",children:[e.jsxs(we,{className:h&&"transition-all group-hover:text-foreground",children:[r&&e.jsx("span",{className:"inline-block size-2 rounded-full opacity-50",style:{backgroundColor:r}}),a&&e.jsx(a,{size:16,strokeWidth:1.5}),s]}),e.jsx(ye,{diffDirection:m===q.allTime.value?"hidden":i,diffTooltip:d,diffValue:n,value:x})]}),h&&e.jsx(T,{className:"absolute right-6 translate-x-10 opacity-0 transition-all duration-200 group-hover:translate-x-0 group-hover:opacity-100",size:"sm",variant:"outline",onClick:h,children:"View more"})]}),e.jsx(V,{children:c})]})},Se=({kpiValues:s,visitorsChartData:o,visitorsYRange:t,growthTotals:r,membersChartData:i,mrrChartData:n,currencySymbol:x,isLoading:l})=>{const c=Y(),{range:h}=C(),{appSettings:m}=W(),d=Ge().isLimited("limitAnalytics"),b="-mb-3 h-[10vw] max-h-[200px] min-h-[100px] hover:!cursor-pointer";if(l)return e.jsx(ve,{className:"flex h-[calc(10vw+116px)] max-h-[416px] min-h-20 items-center justify-center hover:!cursor-pointer",children:e.jsx(oe,{})});const g=m?.analytics.webAnalytics,N=d&&!g,y=!0,L=m?.paidMembersEnabled,w=[g,N,y,L].filter(Boolean).length;let A="lg:grid-cols-3";w===2?A="lg:grid-cols-2":w===1&&(A="lg:grid-cols-1");const U=`flex flex-col lg:grid ${A} gap-6`;return e.jsxs("div",{className:U,children:[g&&!N&&e.jsx(G,{description:"Number of individual people who visited your website",diffDirection:"empty",formattedValue:s.visits,iconName:"Globe",linkto:"/analytics/web/",title:"Unique visitors",onClick:()=>{c("/analytics/web/")},children:e.jsx(B,{className:b,color:"hsl(var(--chart-blue))",data:o,id:"visitors",range:h,showHorizontalLines:!0,showYAxisValues:!1,syncId:"overview-charts",yAxisRange:t})}),N&&e.jsxs(D,{children:[e.jsxs(E,{className:"hidden",children:[e.jsx(F,{children:"Unlock web analytics"}),e.jsx(R,{children:"Get the full picture of what's working with detailed, cookie-free traffic analytics."})]}),e.jsx(V,{className:"flex h-full items-center justify-center p-6",children:e.jsx(P,{actions:e.jsx(T,{variant:"outline",onClick:()=>c("/pro",{crossApp:!0}),children:"Upgrade now"}),className:"py-10",description:"Get the full picture of what's working with detailed, cookie-free traffic analytics.",title:"Unlock web analytics",children:e.jsx(We,{})})})]}),e.jsx(G,{description:"How number of members of your publication changed over time",diffDirection:r.directions.total,diffValue:r.percentChanges.total,formattedValue:u(r.totalMembers),iconName:"User",linkto:"/analytics/growth/",title:"Members",trendingFromValue:`${u(i[0].value)}`,onClick:()=>{c("/analytics/growth/?tab=total-members")},children:e.jsx(B,{className:b,color:"hsl(var(--chart-darkblue))",data:i,id:"members",range:h,showHorizontalLines:!0,showYAxisValues:!1,syncId:"overview-charts"})}),L&&e.jsx(G,{description:"Monthly recurring revenue changes over time",diffDirection:r.directions.mrr,diffValue:r.percentChanges.mrr,formattedValue:`${x}${u(O(r.mrr))}`,iconName:"Coins",linkto:"/analytics/growth/",title:"MRR",trendingFromValue:`${x}${u(n[0].value)}`,onClick:()=>{c("/analytics/growth/?tab=mrr")},children:e.jsx(B,{className:b,color:"hsl(var(--chart-teal))",data:n,id:"mrr",range:h,showHorizontalLines:!0,showYAxisValues:!1,syncId:"overview-charts"})})]})},Oe=({className:s})=>e.jsx("div",{className:$("rounded-sm bg-muted dark:bg-[#36373a] flex flex-col items-center justify-center gap-1 p-6",s),children:e.jsx(ce,{className:"text-muted-foreground/50",size:18,strokeWidth:1.5})}),S=({className:s,metrics:o,title:t})=>e.jsx(e.Fragment,{children:e.jsxs("div",{className:$("pointer-events-none absolute bottom-[calc(100%+2px)] left-1/2 z-50 min-w-[160px] -translate-x-1/2 rounded-md bg-background p-3 text-sm opacity-0 shadow-md transition-all group-hover/tooltip:bottom-[calc(100%+12px)] group-hover/tooltip:opacity-100",s),children:[e.jsx("div",{className:"mb-1.5 whitespace-nowrap border-b pb-1.5 pr-10 font-medium text-muted-foreground",children:t}),e.jsx("div",{className:"flex flex-col gap-1.5",children:o?.map(r=>e.jsxs("div",{className:"flex items-center justify-between gap-5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 whitespace-nowrap",children:[r.icon,r.label]}),e.jsx("span",{className:"font-mono",children:r.metric})]},r.label))})]})}),He=({topPostsData:s,isLoading:o})=>{const t=Y(),{range:r,settings:i}=C(),{appSettings:n}=W(),x=String(i.find(a=>a.key==="timezone")?.value||"Etc/UTC"),l=n?.analytics.webAnalytics,c=n?.analytics.emailTrackClicks,h=n?.analytics.emailTrackOpens,m="flex items-center justify-end gap-1 rounded-md px-2 py-1 font-mono text-gray-800 hover:bg-muted-foreground/10 group-hover:text-foreground";return e.jsxs(D,{className:"group/card w-full lg:col-span-2","data-testid":"top-posts-card",children:[e.jsxs(E,{children:[e.jsxs(F,{className:"flex items-baseline justify-between font-medium leading-snug text-muted-foreground",children:["Top posts ",H(r)]}),e.jsx(R,{className:"hidden",children:"Most viewed posts in this period"})]}),e.jsx(V,{children:o?e.jsx(de,{className:"mt-6"}):e.jsxs(e.Fragment,{children:[s?.stats?.map(a=>e.jsxs("div",{className:'group relative flex w-full items-start justify-between gap-5 border-t border-border/50 py-4 before:absolute before:-inset-x-4 before:inset-y-0 before:z-0 before:hidden before:rounded-md before:bg-accent before:opacity-80 before:content-[""] first:!border-border hover:cursor-pointer hover:border-transparent hover:before:block md:items-center dark:before:bg-accent/50 [&+div]:hover:border-transparent',children:[e.jsxs("div",{className:"z-10 flex min-w-[160px] grow items-start gap-4 md:items-center lg:min-w-[320px]",onClick:()=>{t(`/posts/analytics/${a.post_id}`,{crossApp:!0})},children:[a.feature_image?e.jsx("div",{className:"hidden aspect-[16/10] w-[80px] shrink-0 rounded-sm bg-cover bg-center sm:!visible sm:!block lg:w-[100px]",style:{backgroundImage:`url(${a.feature_image})`}}):e.jsx(Oe,{className:"hidden aspect-[16/10] w-[80px] shrink-0 group-hover:bg-muted-foreground/10 sm:!visible sm:!flex lg:w-[100px]"}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"line-clamp-2 text-lg font-semibold leading-[1.35em]",children:a.title}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["By ",a.authors," – ",se(a.published_at,x)]}),e.jsx("span",{className:"text-sm text-muted-foreground",children:Te(a)})]})]}),e.jsxs("div",{className:"z-10 flex flex-col items-end justify-center gap-0.5 text-sm md:flex-row md:items-center md:justify-end md:gap-3",children:[l&&e.jsxs("div",{className:"group/tooltip relative flex w-[66px] lg:w-[92px]","data-testid":"statistics-visitors",onClick:d=>{d.stopPropagation(),t(`/posts/analytics/${a.post_id}/web`,{crossApp:!0})},children:[e.jsx(S,{metrics:[{icon:e.jsx(M,{className:"shrink-0 text-muted-foreground",size:16,strokeWidth:1.5}),label:"Unique visitors",metric:u(a.views)}],title:"Web traffic"}),e.jsxs("div",{className:m,children:[e.jsx(M,{className:"text-muted-foreground group-hover:text-foreground",size:16,strokeWidth:1.5}),X(a.views)]})]}),a.sent_count!==null&&e.jsxs("div",{className:"group/tooltip relative flex w-[66px] lg:w-[92px]",onClick:d=>{d.stopPropagation(),t(`/posts/analytics/${a.post_id}/newsletter`,{crossApp:!0})},children:[e.jsx(S,{className:`${n?.analytics.membersTrackSources?"":"left-auto right-0 translate-x-0"}`,metrics:[{icon:e.jsx(J,{className:"shrink-0 text-muted-foreground",size:16,strokeWidth:1.5}),label:"Sent",metric:u(a.sent_count||0)},...h?[{icon:e.jsx(K,{className:"shrink-0 text-muted-foreground",size:16,strokeWidth:1.5}),label:"Opens",metric:u(a.opened_count||0)}]:[],...c?[{icon:e.jsx(Z,{className:"shrink-0 text-muted-foreground",size:16,strokeWidth:1.5}),label:"Clicks",metric:u(a.clicked_count||0)}]:[]],title:"Newsletter performance"}),e.jsx("div",{className:m,children:h?e.jsxs(e.Fragment,{children:[e.jsx(K,{className:"text-muted-foreground group-hover:text-foreground",size:16,strokeWidth:1.5}),a.open_rate?`${Math.round(a.open_rate)}%`:"0%"]}):c?e.jsxs(e.Fragment,{children:[e.jsx(Z,{className:"text-muted-foreground group-hover:text-foreground",size:16,strokeWidth:1.5}),a.click_rate?`${Math.round(a.click_rate)}%`:"0%"]}):e.jsxs(e.Fragment,{children:[e.jsx(J,{className:"text-muted-foreground group-hover:text-foreground",size:16,strokeWidth:1.5}),X(a.sent_count||0)]})})]}),n?.analytics.membersTrackSources&&e.jsxs("div",{className:"group/tooltip relative flex w-[66px] lg:w-[92px]","data-testid":"statistics-members",onClick:d=>{d.stopPropagation(),t(`/posts/analytics/${a.post_id}/growth`,{crossApp:!0})},children:[e.jsx(S,{className:"left-auto right-0 translate-x-0",metrics:[{icon:e.jsx(me,{className:"shrink-0 text-muted-foreground",size:16,strokeWidth:1.5}),label:"Free",metric:a.free_members>0?`+${u(a.free_members)}`:"0"},...n?.paidMembersEnabled?[{icon:e.jsx(ue,{className:"shrink-0 text-muted-foreground",size:16,strokeWidth:1.5}),label:"Paid",metric:a.paid_members>0?`+${u(a.paid_members)}`:"0"}]:[]],title:"New members"}),e.jsxs("div",{className:m,children:[e.jsx(ae,{className:"text-muted-foreground group-hover:text-foreground",size:16,strokeWidth:1.5}),a.members>0?`+${u(a.members)}`:"0"]})]})]})]},a.post_id)),(!s?.stats||s.stats.length===0)&&e.jsx(P,{className:"w-full pb-10",title:`No posts ${H(r)}`,children:e.jsx(te,{strokeWidth:1.5})})]})})]})},Ke=()=>{const{data:{posts:[s]}={posts:[]},isLoading:o}=Re({searchParams:{filter:"status:[published,sent]",order:"published_at DESC",limit:"1",include:"authors,email,count.clicks"}}),t=s,r=Ve(t?.id||"",{enabled:!!t?.id}),{data:i,isLoading:n}=r;return{data:_.useMemo(()=>{if(!t)return null;const l=i?.stats?.[0]||{id:t.id,recipient_count:null,opened_count:null,open_rate:null,member_delta:0,free_members:0,paid_members:0,visitors:0};return{id:t.id,uuid:t.uuid,title:t.title||"",slug:t.slug||"",feature_image:t.feature_image||null,published_at:t.published_at||"",url:t.url||"",excerpt:t.excerpt||"",email_only:t.email_only||!1,status:t.status,email:t.email,count:t.count,authors:t.authors||[],recipient_count:l.recipient_count,opened_count:l.opened_count,open_rate:l.open_rate,member_delta:l.member_delta,free_members:l.free_members,paid_members:l.paid_members,visitors:l.visitors,click_rate:null}},[t,i]),isLoading:o||!!t?.id&&n}},ee=({className:s,title:o,description:t,url:r,children:i})=>e.jsx("a",{className:$("block rounded-xl border bg-card p-6 transition-all hover:shadow-xs hover:bg-accent/50 group/card",s),href:r,rel:"noreferrer",target:"_blank",children:e.jsxs("div",{className:"flex items-center gap-6",children:[i,e.jsxs("div",{className:"flex flex-col gap-0.5 leading-tight",children:[e.jsx("span",{className:"text-base font-semibold",children:o}),e.jsx("span",{className:"text-sm font-normal text-gray-700",children:t})]})]})}),_s=()=>{const{appSettings:s}=W(),{statsConfig:o,isLoading:t,range:r}=C(),{startDate:i,endDate:n,timezone:x}=pe(r),{isLoading:l,chartData:c,totals:h,currencySymbol:m}=Fe(r),{data:a,isLoading:d}=Ke(),{data:b,isLoading:g}=Ue({searchParams:{date_from:z(i),date_to:z(n),limit:"5",timezone:x}}),N={site_uuid:o?.id||"",date_from:z(i),date_to:z(n),timezone:x,member_status:Ee(he)},{data:y,loading:L}=ke({endpoint:"api_kpis",statsConfig:o,params:N}),w=_.useMemo(()=>I(y||[],r,"visits","sum")?.map(f=>{const v=Number(f.visits),k=isNaN(v)?0:v;return{date:String(f.date),value:k,formattedValue:u(k),label:"Visitors"}}),[y,r]),A=_.useMemo(()=>{const f=[0,1];if(!w||w.length===0)return f;const v=w.map(p=>p.value).filter(p=>p>=0);return v.length===0?f:[0,Math.max(...v)||f[1]]},[w]),U=_.useMemo(()=>{if(!c||c.length===0)return[];let f=[];return f=I(c,r,"value","exact"),f.map(p=>({date:p.date,value:p.free+p.paid,formattedValue:u(p.free+p.paid),label:"Members"}))},[c,r]),re=_.useMemo(()=>{if(!s?.paidMembersEnabled||!c||c.length===0)return[];let f=[];return f=I(c,r,"mrr","exact"),f.map(p=>({date:p.date,value:O(p.mrr),formattedValue:`${m}${u(O(p.mrr))}`,label:"MRR"}))},[c,r,m,s]),ie=_.useMemo(()=>{if(!y?.length)return{visits:"0"};const f=y.reduce((v,k)=>{const p=Number(k.visits);return v+(isNaN(p)?0:p)},0);return{visits:u(f)}},[y]),ne=t;return e.jsxs(ge,{children:[e.jsx(fe,{children:e.jsx(_e,{children:e.jsx(be,{excludeRanges:["today"]})})}),e.jsxs(je,{isLoading:ne,loadingComponent:e.jsx(e.Fragment,{}),children:[e.jsx(Se,{currencySymbol:m,growthTotals:h,isLoading:L||l,kpiValues:ie,membersChartData:U,mrrChartData:re,visitorsChartData:w,visitorsYRange:A}),e.jsx(Be,{isLoading:d,latestPostStats:a}),e.jsx(He,{isLoading:g,topPostsData:b}),e.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2",children:[e.jsx(xe,{className:"-mb-4 mt-4 lg:col-span-2",children:"Grow your audience"}),e.jsx(ee,{description:"Find out how to review the performance of your content and get the most out of post analytics in Ghost.",title:"Understanding analytics in Ghost",url:"https://ghost.org/help/native-analytics",children:e.jsx("div",{className:"flex h-18 w-[100px] min-w-[100px] items-center justify-center rounded-md bg-gradient-to-tr from-[#14B8FF]/20 to-[#00BBA7]/20 p-4 opacity-80 transition-all group-hover/card:opacity-100",children:e.jsx(De,{className:"text-[#00BBA7]",size:20,strokeWidth:1.5})})}),e.jsx(ee,{description:"Use these content distribution tactics to get more people to discover your work and increase engagement.",title:"How to get your content seen online",url:"https://ghost.org/resources/content-distribution/",children:e.jsx("div",{className:"flex h-18 w-[100px] min-w-[100px] items-center justify-center rounded-md bg-gradient-to-tl from-[#FDC700]/20 to-[#FF2056]/20 p-4 opacity-80 transition-all group-hover/card:opacity-100",children:e.jsx(M,{className:"text-[#FE9A00]",size:20,strokeWidth:1.5})})})]})]})]})};export{_s as default};
@@ -1,4 +1,4 @@
1
- import{r as o,j as n,cq as Cn,cr as Sn,B as A,ch as Wn,ct as zn,cs as Kn,e as rn,cV as Vn,b as En,d1 as gn,S as E,P as Yn,A as Qn,h as Zn,g as fn,d as Jn,n as Xn,bu as Gn,f as pn,F as an,i as on,d2 as ne,o as ee,a as te,u as ae,p as oe,L as re,aR as ie,D as de,t as ce,v as se,w as le,a9 as ge,d3 as pe,d4 as ue,bm as bn,bn as he}from"./index-CMTzNTew.js";import{M as me}from"./minus-NvnQTlW7.js";import{u as ke,D as fe,A as be,S as xn}from"./deleted-feed-item-B_AwUKZy.js";import{T as xe}from"./topic-filter-LTRvZ8aU.js";import{E as vn}from"./empty-indicator-Bn5wG9-T.js";import{I as yn}from"./inbox-BcZNBNhk.js";import"./trash-u5BxolyH.js";const un=["1.5rem","1.6rem","1.7rem","1.8rem","2rem"],U={BACKGROUND_COLOR:"ghost-ap-background-color",FONT_SIZE:"ghost-ap-font-size",FONT_STYLE:"ghost-ap-font-style"},P={SYSTEM:{id:"system",color:"#fff",background:"bg-white dark:bg-black",button:"bg-white dark:bg-black",border:"border-black/[8%] dark:border-gray-950"},SEPIA:{id:"sepia",color:"#FCF8F1",background:"bg-[#FCF8F1]",button:"bg-[#FCF8F1] hover:bg-black/[3%] text-black hover:text-black",border:"border-black/[8%]"},LIGHT:{id:"light",color:"#fff",background:"bg-white",button:"hover:bg-black/[3%] text-black hover:text-black",border:"border-black/[8%] dark:border-gray-950"},DARK:{id:"dark",color:"#15171a",background:"bg-black",button:"text-white dark:bg-black dark:hover:bg-gray-900",border:"border-black/[8%] dark:border-gray-950"}},ve=()=>{const[a,s]=o.useState(()=>localStorage.getItem(U.BACKGROUND_COLOR)?.toUpperCase()||"SYSTEM"),[t,p]=o.useState(()=>{const r=localStorage.getItem(U.FONT_SIZE);return r?parseInt(r):2}),[c,k]=o.useState(()=>localStorage.getItem(U.FONT_STYLE)||"sans"),i=r=>{s(r),localStorage.setItem(U.BACKGROUND_COLOR,P[r].id)};return o.useEffect(()=>{localStorage.setItem(U.FONT_SIZE,t.toString())},[t]),o.useEffect(()=>{localStorage.setItem(U.FONT_STYLE,c)},[c]),{backgroundColor:a,currentFontSizeIndex:t,fontStyle:c,handleColorChange:i,setFontStyle:k,increaseFontSize:()=>{p(r=>Math.min(r+1,un.length-1))},decreaseFontSize:()=>{p(r=>Math.max(r-1,0))},resetFontSize:()=>p(2),fontSize:un[t]}},wn=({backgroundColor:a,currentFontSizeIndex:s,fontStyle:t,onColorChange:p,onFontStyleChange:c,onDecreaseFontSize:k,onIncreaseFontSize:i,onResetFontSize:u,onOpenChange:v})=>{const h=l=>a===l,r=l=>t===l;return n.jsx(ye,{backgroundColor:a,currentFontSizeIndex:s,fontStyle:t,isActiveColor:h,isActiveFont:r,onColorChange:p,onDecreaseFontSize:k,onFontStyleChange:c,onIncreaseFontSize:i,onOpenChange:v,onResetFontSize:u})},ye=({backgroundColor:a,isActiveColor:s,isActiveFont:t,onColorChange:p,onFontStyleChange:c,currentFontSizeIndex:k,onDecreaseFontSize:i,onIncreaseFontSize:u,onResetFontSize:v,onOpenChange:h})=>n.jsxs(Cn,{modal:!1,onOpenChange:h,children:[n.jsx(Sn,{asChild:!0,children:n.jsx(A,{className:`size-9 rounded-full ${P[a].button}`,variant:"ghost",children:n.jsx(Wn.Typography,{className:"!size-[18px]"})})}),n.jsx(zn,{align:"end",className:"w-[224px]",onCloseAutoFocus:r=>r.preventDefault(),onOpenAutoFocus:r=>r.preventDefault(),children:n.jsxs("div",{className:"flex flex-col gap-4",children:[n.jsxs("div",{className:"flex items-center justify-between gap-[6px]",children:[n.jsx(A,{className:`h-7 flex-1 rounded-[6px] bg-gray-200 p-0 text-[1.1rem] text-black hover:bg-gray-250 dark:bg-gray-925 dark:text-white dark:hover:bg-gray-900 [&_svg]:size-[14px] ${s("SYSTEM")?"outline outline-2 outline-green":""}`,variant:"secondary",onClick:()=>p("SYSTEM"),children:"Auto"}),n.jsx(A,{className:`h-7 flex-1 rounded-[6px] bg-[#ece6d9] p-0 hover:bg-[#ece6d9] ${s("SEPIA")?"outline outline-2 outline-green":"border border-[#ece6d9]"}`,onClick:()=>p("SEPIA")}),n.jsx(A,{className:`h-7 flex-1 rounded-[6px] bg-white p-0 hover:bg-white ${s("LIGHT")?"outline outline-2 outline-green":"border border-gray-200"}`,onClick:()=>p("LIGHT")}),n.jsx(A,{className:`h-7 flex-1 rounded-[6px] bg-black p-0 hover:bg-black dark:border dark:border-gray-925 ${s("DARK")?"outline outline-2 outline-green":""}`,onClick:()=>p("DARK")})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsxs(A,{className:`flex h-auto w-full flex-col gap-1 rounded-[6px] bg-gray-200 text-black hover:bg-gray-250 dark:bg-gray-925 dark:text-white dark:hover:bg-gray-900 ${t("sans")&&"outline outline-2 outline-green"}`,variant:"secondary",onClick:()=>c("sans"),children:[n.jsx("span",{className:"text-[2rem] font-bold leading-none",children:"Aa"}),n.jsx("span",{className:"text-[1.1rem]",children:"System"})]}),n.jsxs(A,{className:`flex h-auto w-full flex-col gap-1 rounded-[6px] bg-gray-200 text-black hover:bg-gray-250 dark:bg-gray-925 dark:text-white dark:hover:bg-gray-900 ${t("serif")&&"outline outline-2 outline-green"}`,variant:"secondary",onClick:()=>c("serif"),children:[n.jsx("span",{className:"pt-1 font-serif text-[2rem] font-bold leading-none",children:"Aa"}),n.jsx("span",{className:"font-serif text-[1.2rem]",children:"Serif"})]})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(A,{className:"h-8 w-full rounded-[6px] bg-gray-200 text-black hover:bg-gray-250 dark:bg-gray-925 dark:text-white dark:hover:bg-gray-900 [&_svg]:size-[14px]",disabled:k===0,variant:"secondary",onClick:i,children:n.jsx(me,{})}),n.jsx(A,{className:"h-8 w-full rounded-[6px] bg-gray-200 text-black hover:bg-gray-250 dark:bg-gray-925 dark:text-white dark:hover:bg-gray-900",variant:"secondary",onClick:v,children:n.jsx("span",{className:"text-[1.6rem] font-bold",children:"Aa"})}),n.jsx(A,{className:"h-8 w-full rounded-[6px] bg-gray-200 text-black hover:bg-gray-250 dark:bg-gray-925 dark:text-white dark:hover:bg-gray-900 [&_svg]:size-[14px]",disabled:k===un.length-1,variant:"secondary",onClick:u,children:n.jsx(Kn,{})})]})]})})]}),we=({tocItems:a,iframeElement:s,modalRef:t,className:p="!visible absolute inset-y-0 right-7 z-40 hidden lg:!block",onOpenChange:c})=>{const[k,i]=o.useState(null),u=rn.useRef(!1),v=h=>{if(!s?.contentDocument)return;const r=s.contentDocument.getElementById(h);r&&t.current&&(u.current=!0,i(h),t.current.scrollTo({top:r.offsetTop-20,behavior:"smooth"}),setTimeout(()=>{u.current=!1},1e3))};return o.useEffect(()=>{if(!s?.contentDocument||a.length<=1)return;const h=t.current;if(!h)return;const r=()=>{if(u.current)return;const d=s.contentDocument;if(!d)return;const _=h.scrollTop,F=100,D=a.map(S=>d.getElementById(S.id)).filter(S=>S!==null).map(S=>({id:S.id,top:S.offsetTop}));if(!D.length)return;const L=D.reduce((S,M)=>M.top-F<=_?M:S);i(L?.id||null)},l=()=>{requestAnimationFrame(r)};return h.addEventListener("scroll",l),r(),()=>{h.removeEventListener("scroll",l)}},[s,a,t]),a.length<=1?null:n.jsx("div",{className:p,children:n.jsx("div",{className:"sticky top-1/2 -translate-y-1/2",children:n.jsx(Se,{activeHeading:k||"",items:a,onItemClick:v,onOpenChange:c})})})},je={1:"w-3",2:"w-2",3:"w-1"},Ce={1:"pl-2",2:"pl-6",3:"pl-10"},Se=({items:a,activeHeading:s,onItemClick:t,onOpenChange:p})=>{const[c,k]=o.useState(!1),i=rn.useRef();if(rn.useEffect(()=>()=>{i.current&&clearTimeout(i.current)},[]),a.length===0)return null;const u=d=>Math.min(d,3),v=d=>je[u(d)],h=d=>Ce[u(d)],r=()=>{i.current&&clearTimeout(i.current),k(!0),p?.(!0)},l=()=>{i.current=setTimeout(()=>{k(!1),p?.(!1)},100)};return n.jsxs(Cn,{modal:!1,open:c,onOpenChange:k,children:[n.jsx(Sn,{asChild:!0,children:n.jsx("div",{className:"absolute right-2 top-1/2 flex -translate-y-1/2 flex-col items-end gap-2 rounded-md p-2 text-base dark:bg-black",onMouseEnter:r,onMouseLeave:l,children:a.map(d=>n.jsx("div",{className:`h-[2px] rounded-sm ${s===d.id?"bg-black dark:bg-white":"bg-gray-400 dark:bg-gray-700"} pr-1 transition-all ${v(d.level)}`},d.id))})}),n.jsx(zn,{align:"center",className:"w-[240px] p-2",side:"left",sideOffset:-28,onCloseAutoFocus:d=>d.preventDefault(),onMouseEnter:r,onMouseLeave:l,onOpenAutoFocus:d=>d.preventDefault(),children:n.jsx("nav",{"aria-label":"Table of contents navigation",className:"max-h-[60vh] overflow-y-auto",role:"navigation",children:a.map(d=>n.jsx("button",{className:`line-clamp-2 block w-full cursor-pointer rounded py-1 text-left text-sm leading-tight ${s===d.id?"text-black dark:text-white":"text-gray-700 dark:text-gray-600"} hover:bg-gray-75 hover:text-gray-900 dark:hover:bg-grey-925 dark:hover:text-white ${h(d.level)}`,type:"button",onClick:()=>t(d.id),children:n.jsx("span",{className:"line-clamp-2",children:d.text})},d.id))})})]})},ze=()=>`<style>
1
+ import{r as o,j as n,cq as Cn,cr as Sn,B as A,ch as Wn,ct as zn,cs as Kn,e as rn,cV as Vn,b as En,d1 as gn,S as E,P as Yn,A as Qn,h as Zn,g as fn,d as Jn,n as Xn,bu as Gn,f as pn,F as an,i as on,d2 as ne,o as ee,a as te,u as ae,p as oe,L as re,aR as ie,D as de,t as ce,v as se,w as le,a9 as ge,d3 as pe,d4 as ue,bm as bn,bn as he}from"./index-B8G0f0hb.js";import{M as me}from"./minus-CyEc3BE5.js";import{u as ke,D as fe,A as be,S as xn}from"./deleted-feed-item-Dmm_clMl.js";import{T as xe}from"./topic-filter-Boh22uGD.js";import{E as vn}from"./empty-indicator-C2Z0dddU.js";import{I as yn}from"./inbox-1cUdr8Mm.js";import"./trash-D7ZWrnDq.js";const un=["1.5rem","1.6rem","1.7rem","1.8rem","2rem"],U={BACKGROUND_COLOR:"ghost-ap-background-color",FONT_SIZE:"ghost-ap-font-size",FONT_STYLE:"ghost-ap-font-style"},P={SYSTEM:{id:"system",color:"#fff",background:"bg-white dark:bg-black",button:"bg-white dark:bg-black",border:"border-black/[8%] dark:border-gray-950"},SEPIA:{id:"sepia",color:"#FCF8F1",background:"bg-[#FCF8F1]",button:"bg-[#FCF8F1] hover:bg-black/[3%] text-black hover:text-black",border:"border-black/[8%]"},LIGHT:{id:"light",color:"#fff",background:"bg-white",button:"hover:bg-black/[3%] text-black hover:text-black",border:"border-black/[8%] dark:border-gray-950"},DARK:{id:"dark",color:"#15171a",background:"bg-black",button:"text-white dark:bg-black dark:hover:bg-gray-900",border:"border-black/[8%] dark:border-gray-950"}},ve=()=>{const[a,s]=o.useState(()=>localStorage.getItem(U.BACKGROUND_COLOR)?.toUpperCase()||"SYSTEM"),[t,p]=o.useState(()=>{const r=localStorage.getItem(U.FONT_SIZE);return r?parseInt(r):2}),[c,k]=o.useState(()=>localStorage.getItem(U.FONT_STYLE)||"sans"),i=r=>{s(r),localStorage.setItem(U.BACKGROUND_COLOR,P[r].id)};return o.useEffect(()=>{localStorage.setItem(U.FONT_SIZE,t.toString())},[t]),o.useEffect(()=>{localStorage.setItem(U.FONT_STYLE,c)},[c]),{backgroundColor:a,currentFontSizeIndex:t,fontStyle:c,handleColorChange:i,setFontStyle:k,increaseFontSize:()=>{p(r=>Math.min(r+1,un.length-1))},decreaseFontSize:()=>{p(r=>Math.max(r-1,0))},resetFontSize:()=>p(2),fontSize:un[t]}},wn=({backgroundColor:a,currentFontSizeIndex:s,fontStyle:t,onColorChange:p,onFontStyleChange:c,onDecreaseFontSize:k,onIncreaseFontSize:i,onResetFontSize:u,onOpenChange:v})=>{const h=l=>a===l,r=l=>t===l;return n.jsx(ye,{backgroundColor:a,currentFontSizeIndex:s,fontStyle:t,isActiveColor:h,isActiveFont:r,onColorChange:p,onDecreaseFontSize:k,onFontStyleChange:c,onIncreaseFontSize:i,onOpenChange:v,onResetFontSize:u})},ye=({backgroundColor:a,isActiveColor:s,isActiveFont:t,onColorChange:p,onFontStyleChange:c,currentFontSizeIndex:k,onDecreaseFontSize:i,onIncreaseFontSize:u,onResetFontSize:v,onOpenChange:h})=>n.jsxs(Cn,{modal:!1,onOpenChange:h,children:[n.jsx(Sn,{asChild:!0,children:n.jsx(A,{className:`size-9 rounded-full ${P[a].button}`,variant:"ghost",children:n.jsx(Wn.Typography,{className:"!size-[18px]"})})}),n.jsx(zn,{align:"end",className:"w-[224px]",onCloseAutoFocus:r=>r.preventDefault(),onOpenAutoFocus:r=>r.preventDefault(),children:n.jsxs("div",{className:"flex flex-col gap-4",children:[n.jsxs("div",{className:"flex items-center justify-between gap-[6px]",children:[n.jsx(A,{className:`h-7 flex-1 rounded-[6px] bg-gray-200 p-0 text-[1.1rem] text-black hover:bg-gray-250 dark:bg-gray-925 dark:text-white dark:hover:bg-gray-900 [&_svg]:size-[14px] ${s("SYSTEM")?"outline outline-2 outline-green":""}`,variant:"secondary",onClick:()=>p("SYSTEM"),children:"Auto"}),n.jsx(A,{className:`h-7 flex-1 rounded-[6px] bg-[#ece6d9] p-0 hover:bg-[#ece6d9] ${s("SEPIA")?"outline outline-2 outline-green":"border border-[#ece6d9]"}`,onClick:()=>p("SEPIA")}),n.jsx(A,{className:`h-7 flex-1 rounded-[6px] bg-white p-0 hover:bg-white ${s("LIGHT")?"outline outline-2 outline-green":"border border-gray-200"}`,onClick:()=>p("LIGHT")}),n.jsx(A,{className:`h-7 flex-1 rounded-[6px] bg-black p-0 hover:bg-black dark:border dark:border-gray-925 ${s("DARK")?"outline outline-2 outline-green":""}`,onClick:()=>p("DARK")})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsxs(A,{className:`flex h-auto w-full flex-col gap-1 rounded-[6px] bg-gray-200 text-black hover:bg-gray-250 dark:bg-gray-925 dark:text-white dark:hover:bg-gray-900 ${t("sans")&&"outline outline-2 outline-green"}`,variant:"secondary",onClick:()=>c("sans"),children:[n.jsx("span",{className:"text-[2rem] font-bold leading-none",children:"Aa"}),n.jsx("span",{className:"text-[1.1rem]",children:"System"})]}),n.jsxs(A,{className:`flex h-auto w-full flex-col gap-1 rounded-[6px] bg-gray-200 text-black hover:bg-gray-250 dark:bg-gray-925 dark:text-white dark:hover:bg-gray-900 ${t("serif")&&"outline outline-2 outline-green"}`,variant:"secondary",onClick:()=>c("serif"),children:[n.jsx("span",{className:"pt-1 font-serif text-[2rem] font-bold leading-none",children:"Aa"}),n.jsx("span",{className:"font-serif text-[1.2rem]",children:"Serif"})]})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(A,{className:"h-8 w-full rounded-[6px] bg-gray-200 text-black hover:bg-gray-250 dark:bg-gray-925 dark:text-white dark:hover:bg-gray-900 [&_svg]:size-[14px]",disabled:k===0,variant:"secondary",onClick:i,children:n.jsx(me,{})}),n.jsx(A,{className:"h-8 w-full rounded-[6px] bg-gray-200 text-black hover:bg-gray-250 dark:bg-gray-925 dark:text-white dark:hover:bg-gray-900",variant:"secondary",onClick:v,children:n.jsx("span",{className:"text-[1.6rem] font-bold",children:"Aa"})}),n.jsx(A,{className:"h-8 w-full rounded-[6px] bg-gray-200 text-black hover:bg-gray-250 dark:bg-gray-925 dark:text-white dark:hover:bg-gray-900 [&_svg]:size-[14px]",disabled:k===un.length-1,variant:"secondary",onClick:u,children:n.jsx(Kn,{})})]})]})})]}),we=({tocItems:a,iframeElement:s,modalRef:t,className:p="!visible absolute inset-y-0 right-7 z-40 hidden lg:!block",onOpenChange:c})=>{const[k,i]=o.useState(null),u=rn.useRef(!1),v=h=>{if(!s?.contentDocument)return;const r=s.contentDocument.getElementById(h);r&&t.current&&(u.current=!0,i(h),t.current.scrollTo({top:r.offsetTop-20,behavior:"smooth"}),setTimeout(()=>{u.current=!1},1e3))};return o.useEffect(()=>{if(!s?.contentDocument||a.length<=1)return;const h=t.current;if(!h)return;const r=()=>{if(u.current)return;const d=s.contentDocument;if(!d)return;const _=h.scrollTop,F=100,D=a.map(S=>d.getElementById(S.id)).filter(S=>S!==null).map(S=>({id:S.id,top:S.offsetTop}));if(!D.length)return;const L=D.reduce((S,M)=>M.top-F<=_?M:S);i(L?.id||null)},l=()=>{requestAnimationFrame(r)};return h.addEventListener("scroll",l),r(),()=>{h.removeEventListener("scroll",l)}},[s,a,t]),a.length<=1?null:n.jsx("div",{className:p,children:n.jsx("div",{className:"sticky top-1/2 -translate-y-1/2",children:n.jsx(Se,{activeHeading:k||"",items:a,onItemClick:v,onOpenChange:c})})})},je={1:"w-3",2:"w-2",3:"w-1"},Ce={1:"pl-2",2:"pl-6",3:"pl-10"},Se=({items:a,activeHeading:s,onItemClick:t,onOpenChange:p})=>{const[c,k]=o.useState(!1),i=rn.useRef();if(rn.useEffect(()=>()=>{i.current&&clearTimeout(i.current)},[]),a.length===0)return null;const u=d=>Math.min(d,3),v=d=>je[u(d)],h=d=>Ce[u(d)],r=()=>{i.current&&clearTimeout(i.current),k(!0),p?.(!0)},l=()=>{i.current=setTimeout(()=>{k(!1),p?.(!1)},100)};return n.jsxs(Cn,{modal:!1,open:c,onOpenChange:k,children:[n.jsx(Sn,{asChild:!0,children:n.jsx("div",{className:"absolute right-2 top-1/2 flex -translate-y-1/2 flex-col items-end gap-2 rounded-md p-2 text-base dark:bg-black",onMouseEnter:r,onMouseLeave:l,children:a.map(d=>n.jsx("div",{className:`h-[2px] rounded-sm ${s===d.id?"bg-black dark:bg-white":"bg-gray-400 dark:bg-gray-700"} pr-1 transition-all ${v(d.level)}`},d.id))})}),n.jsx(zn,{align:"center",className:"w-[240px] p-2",side:"left",sideOffset:-28,onCloseAutoFocus:d=>d.preventDefault(),onMouseEnter:r,onMouseLeave:l,onOpenAutoFocus:d=>d.preventDefault(),children:n.jsx("nav",{"aria-label":"Table of contents navigation",className:"max-h-[60vh] overflow-y-auto",role:"navigation",children:a.map(d=>n.jsx("button",{className:`line-clamp-2 block w-full cursor-pointer rounded py-1 text-left text-sm leading-tight ${s===d.id?"text-black dark:text-white":"text-gray-700 dark:text-gray-600"} hover:bg-gray-75 hover:text-gray-900 dark:hover:bg-grey-925 dark:hover:text-white ${h(d.level)}`,type:"button",onClick:()=>t(d.id),children:n.jsx("span",{className:"line-clamp-2",children:d.text})},d.id))})})]})},ze=()=>`<style>
2
2
 
3
3
  /* Variables */
4
4
 
@@ -0,0 +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-B8G0f0hb.js";import{P as is}from"./tags-PGeGAafJ.js";import{E as cs}from"./edit-profile-BLSdtROQ.js";import{T as ds,a as us,b as S,f as _,c as A}from"./tabs-CjNdfW0y.js";import{a as ms}from"./settings-Bzy1GNfD.js";import{U as xs}from"./lucide-react-ClQ3Iy7l.js";import{C as fs}from"./copy-CNsHZEFR.js";import"./label-BvlHzzcJ.js";import"./at-sign-CGNkBrZS.js";import"./index-DKAlEWM4.js";import"./wallet-cards-xX4QZik7.js";import"./a-large-small-DVyx4GMu.js";import"./message-square-text-Dd1XS5-H.js";import"./hash-j3sh-UI3.js";import"./inbox-1cUdr8Mm.js";import"./list-filter-DPE4Xj2T.js";import"./minus-CyEc3BE5.js";import"./square-YF1YE9ex.js";import"./user-round-check-BLc3L-ei.js";import"./repeat-B-SL0yPM.js";import"./reply-BdCPoUQ9.js";import"./sprout-BwLQTzMf.js";import"./trash-D7ZWrnDq.js";function hs(s){return typeof s.name=="string"?s.name:typeof s.preferredUsername=="string"?s.preferredUsername:typeof s.preferredUsername=="object"&&s.preferredUsername!==null&&"@value"in s.preferredUsername&&typeof s.preferredUsername["@value"]=="string"?s.preferredUsername["@value"]:"Unknown"}const he=({noResultsMessage:s,actors:o,isLoading:n,fetchNextPage:c,hasNextPage:x,isFetchingNextPage:d})=>{const i=J("index","me"),{data:r}=i,t=u.useRef(null),a=u.useRef(null);u.useEffect(()=>(t.current&&t.current.disconnect(),t.current=new IntersectionObserver(l=>{l[0].isIntersecting&&x&&!d&&c()}),a.current&&t.current.observe(a.current),()=>{t.current&&t.current.disconnect()}),[x,d,c]);const m=$();return e.jsxs("div",{className:"pt-3","data-testid":"actor-list",children:[x===!1&&o.length===0?e.jsxs(H,{children:[e.jsx(L,{children:e.jsx(ye,{})}),s]}):e.jsx("div",{className:"flex flex-col",children:o.map(({actor:l,isFollowing:h,blockedByMe:b,domainBlockedByMe:k})=>{const w=l.handle||Ne(l),y=w===r?.handle;return e.jsx(Ce.Fragment,{children:e.jsx(Ue,{actor:l,align:"center",isCurrentUser:y,side:"left",children:e.jsx("div",{children:e.jsxs(Me,{"data-testid":"actor-item",onClick:()=>{Be(l,m)},children:[e.jsx(oe,{author:l}),e.jsx("div",{children:e.jsxs("div",{className:"text-gray-600 break-anywhere",children:[e.jsx("span",{className:"mr-1 line-clamp-1 font-bold text-black dark:text-white",children:hs(l)}),e.jsx("div",{className:"line-clamp-1 text-sm",children:w})]})}),b||k?e.jsx(j,{className:"pointer-events-none ml-auto min-w-[90px]",variant:"destructive",children:"Blocked"}):y?null:e.jsx(ae,{className:"ml-auto","data-testid":"follow-button",following:h,handle:w,type:"secondary"})]},l.id)})})},l.id)})}),e.jsx("div",{ref:a,className:"h-1"}),(d||n)&&e.jsx("div",{className:"mt-6 flex flex-col items-center justify-center space-y-4 text-center",children:e.jsx(W,{size:"md"})})]})},ps=({posts:s,fetchNextPage:o,hasNextPage:n,isFetchingNextPage:c,isLoading:x})=>{const d=u.useRef(null),i=u.useRef(null),r=u.useRef(null),t=Math.max(0,Math.floor(s.length*.75)-1);u.useEffect(()=>(d.current&&d.current.disconnect(),d.current=new IntersectionObserver(m=>{m[0].isIntersecting&&n&&!c&&o()}),i.current&&d.current.observe(i.current),r.current&&d.current.observe(r.current),()=>{d.current&&d.current.disconnect()}),[n,c,o]);const a=$();return e.jsxs(e.Fragment,{children:[n===!1&&s.length===0&&e.jsxs(H,{children:[e.jsx(L,{children:e.jsx(De,{})}),"You haven't liked anything yet."]}),e.jsxs("ul",{className:"mx-auto flex max-w-[640px] flex-col","data-testid":"profile-likes-list",children:[s.map((m,l)=>e.jsxs("li",{"data-testid":"profile-like-item","data-test-view-article":!0,children:[e.jsx(ie,{actor:m.actor,allowDelete:m.object.authored,commentCount:m.object.replyCount,isLoading:x,layout:"feed",likeCount:m.object.likeCount,object:m.object,repostCount:m.object.repostCount,type:m.type,onClick:()=>{m.object.type==="Note"?a(`/notes/${encodeURIComponent(m.object.id)}`):m.object.type==="Article"&&a(`/reader/${encodeURIComponent(m.object.id)}`)}}),l<s.length-1&&e.jsx(ce,{}),l===t&&e.jsx("div",{ref:i,className:"h-1"})]},`likes-${m.id}`)),c&&e.jsx("li",{className:"flex flex-col items-center justify-center space-y-4 text-center",children:e.jsx(W,{size:"md"})})]}),e.jsx("div",{ref:r,className:"h-1"})]})},js=({posts:s,fetchNextPage:o,hasNextPage:n,isFetchingNextPage:c,isLoading:x,noResultsMessage:d})=>{const i=u.useRef(null),r=u.useRef(null),t=u.useRef(null),a=Math.max(0,Math.floor(s.length*.75)-1);u.useEffect(()=>(i.current&&i.current.disconnect(),i.current=new IntersectionObserver(l=>{l[0].isIntersecting&&n&&!c&&o()}),r.current&&i.current.observe(r.current),t.current&&i.current.observe(t.current),()=>{i.current&&i.current.disconnect()}),[n,c,o]);const m=$();return e.jsxs(e.Fragment,{children:[n===!1&&s.length===0&&e.jsxs(H,{children:[e.jsx(L,{children:e.jsx(is,{})}),d]}),e.jsxs("ul",{className:"mx-auto flex max-w-[640px] flex-col","data-testid":"profile-posts-list",children:[s.map((l,h)=>e.jsxs("li",{"data-testid":"profile-post-item","data-test-view-article":!0,children:[e.jsx(ie,{actor:l.actor,allowDelete:l.object.authored,commentCount:l.object.replyCount,isLoading:x,layout:"feed",likeCount:l.object.likeCount,object:l.object,repostCount:l.object.repostCount,type:l.type,onClick:()=>{l.object.type==="Note"?m(`/notes/${encodeURIComponent(l.object.id)}`):l.object.type==="Article"&&m(`/reader/${encodeURIComponent(l.object.id)}`)}}),h<s.length-1&&e.jsx(ce,{}),h===a&&e.jsx("div",{ref:r,className:"h-1"})]},`posts-${l.id}`)),c&&e.jsx("li",{className:"flex flex-col items-center justify-center space-y-4 text-center",children:e.jsx(W,{size:"md"})})]}),e.jsx("div",{ref:t,className:"h-1"})]})},pe=({handle:s,isUserBlocked:o,isDomainBlocked:n,onUnblockUser:c,onUnblockDomain:x,trigger:d,onUnblockComplete:i,isOpen:r,onOpenChange:t})=>{const[a,m]=u.useState(!1),[l,h]=u.useState(()=>{const p=o&&n,N=o&&!n,F=!o&&n;let g="idle";return p?g="dual":N?g="userOnly":F&&(g="domainOnly"),{mode:g,userUnblocked:!1,domainUnblocked:!1}}),b=r!==void 0,k=b?r:a,[w,y]=u.useState(!1),M=u.useCallback(()=>{const p=o&&n,N=o&&!n,F=!o&&n;let g="idle";p?g="dual":N?g="userOnly":F&&(g="domainOnly"),h(C=>({...C,mode:g,userUnblocked:!1,domainUnblocked:!1}))},[o,n]);u.useEffect(()=>{k&&!w?(M(),y(!0)):k||y(!1)},[k,w,M]);const P=()=>{b?t?.(!0):m(!0)},f=p=>{p||(b?t?.(!1):m(!1))},I=async()=>{await c(),h(p=>({...p,userUnblocked:!0})),(l.mode!=="dual"||l.domainUnblocked)&&(f(!1),i?.()),U.success("User unblocked")},E=async()=>{await x(),h(p=>({...p,domainUnblocked:!0})),(l.mode!=="dual"||l.userUnblocked)&&(f(!1),i?.()),U.success("Domain unblocked")},T=s.split("@").filter(Boolean)[1],B=()=>e.jsxs(e.Fragment,{children:[e.jsxs(Q,{children:[e.jsx(Y,{className:"mb-1 flex flex-col gap-1",children:"Unblock"}),e.jsx(K,{className:"!mt-4",asChild:!0,children:e.jsxs("div",{className:"flex flex-col rounded-md border",children:[e.jsxs("div",{className:"flex justify-between gap-6 p-5",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(q,{children:"Unblock user"}),e.jsxs("p",{children:[e.jsx("span",{className:"font-semibold text-black",children:s})," will be able to follow you and engage with your public posts."]})]}),e.jsxs(j,{className:`gap-1 ${l.userUnblocked?"pointer-events-none border-green bg-green text-white hover:bg-green hover:text-white":"text-red hover:text-red-400"}`,variant:"outline",onClick:I,children:[e.jsx(Te,{}),l.userUnblocked?"User unblocked":"Unblock user"]})]}),e.jsx("div",{className:"border-t"}),e.jsxs("div",{className:"flex justify-between gap-6 p-5",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(q,{children:"Unblock domain"}),e.jsxs("p",{children:["Users from ",e.jsx("span",{className:"font-semibold text-black",children:T})," will be able to follow you and engage with your public posts."]})]}),e.jsxs(j,{className:`gap-1 ${l.domainUnblocked?"pointer-events-none border-green bg-green text-white hover:bg-green hover:text-white":"text-red hover:text-red-400"}`,variant:"outline",onClick:E,children:[e.jsx(Fe,{}),l.domainUnblocked?"Domain unblocked":"Unblock domain"]})]})]})})]}),e.jsx(G,{children:e.jsx(j,{onClick:()=>f(!1),children:"OK"})})]}),D=()=>{const p=l.mode==="userOnly";return e.jsxs(e.Fragment,{children:[e.jsxs(Q,{children:[e.jsx(Y,{className:"mb-1 flex flex-col gap-1",children:p?"Unblock this user?":"Unblock this domain?"}),e.jsx(K,{children:p?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-semibold text-black",children:s})," will be able to follow you and engage with your public posts."]}):e.jsxs(e.Fragment,{children:["Users from ",e.jsx("span",{className:"font-semibold text-black",children:T})," will be able to follow you and engage with your public posts."]})})]}),e.jsxs(G,{children:[e.jsx(me,{children:"Cancel"}),e.jsx(j,{onClick:p?I:E,children:"Unblock"})]})]})};return e.jsxs(de,{open:k,onOpenChange:f,children:[d&&e.jsx(Pe,{asChild:!0,onClick:P,children:d}),e.jsx(ue,{className:`${l.mode==="dual"&&"max-w-[600px]"}`,children:l.mode==="dual"?B():D()})]})},bs=({account:s,children:o,onCopyHandle:n,onBlockAccount:c,onBlockDomain:x,disabled:d=!1,isBlocked:i=!1,isDomainBlocked:r=!1})=>{const[t,a]=u.useState(null),[m,l]=u.useState(!1),h=f=>{f.stopPropagation(),n()},b=f=>{f.stopPropagation(),c()},k=f=>{f.stopPropagation(),x()},w=s?.handle,y=w?.split("@").filter(Boolean)[1],M=()=>e.jsx(de,{open:m,onOpenChange:l,children:e.jsxs(ue,{onClick:f=>f.stopPropagation(),children:[e.jsxs(Q,{children:[e.jsx(Y,{className:"mb-1 flex flex-col gap-1",children:t==="user"?"Block this user?":"Block this domain?"}),e.jsx(K,{children:t==="user"?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-semibold text-black",children:w})," will be able to see your public posts, but will no longer be able follow you or interact with your content on the social web."]}):e.jsxs(e.Fragment,{children:["All users from ",e.jsx("span",{className:"font-semibold text-black",children:y})," will be able to see your public posts, but won't be able to follow you or interact with your content."]})})]}),e.jsxs(G,{children:[t!=="domain"&&e.jsx(j,{className:"-ml-3 mr-auto hover:bg-transparent hover:opacity-80",variant:"ghost",onClick:f=>{f.stopPropagation(),a("domain")},children:"Block domain instead"}),e.jsx(me,{onClick:f=>f.stopPropagation(),children:"Cancel"}),e.jsx(Ee,{className:Se({variant:"destructive"}),onClick:t==="user"?b:k,children:"Block"})]})]})}),P=()=>s&&e.jsx(pe,{handle:s.handle,isDomainBlocked:s.domainBlockedByMe,isOpen:m,isUserBlocked:s.blockedByMe,onOpenChange:l,onUnblockDomain:x,onUnblockUser:c});return e.jsxs(e.Fragment,{children:[e.jsxs(Re,{children:[e.jsx(Oe,{disabled:d,asChild:!0,onClick:f=>f.stopPropagation(),children:o}),e.jsx(Ie,{align:"end",className:"p-2",children:e.jsxs("div",{className:"flex w-48 flex-col",children:[e.jsx(ne,{asChild:!0,children:e.jsx(j,{className:"justify-start",variant:"ghost",onClick:h,children:"Copy handle"})}),e.jsx(ne,{asChild:!0,children:e.jsx(j,{className:"justify-start text-red hover:bg-red/5 hover:text-red",variant:"ghost",onClick:f=>{f.stopPropagation(),!i&&!r&&a("user"),l(!0)},children:i?"Unblock user":r?"Unblock domain":"Block user"})})]})})]}),i||r?P():M()]})},gs=({account:s,onUnblock:o,onDomainUnblock:n,className:c=""})=>{const[x,d]=u.useState(!1),i=e.jsx(j,{className:`min-w-[90px] ${c}`,variant:"destructive",onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),children:x?"Unblock":"Blocked"});return e.jsx(pe,{handle:s.handle,isDomainBlocked:s.domainBlockedByMe,isUserBlocked:s.blockedByMe,trigger:i,onUnblockDomain:n,onUnblockUser:o})},re=()=>{},ks=({account:s,customFields:o,isLoadingAccount:n,postsTab:c,likesTab:x,followingTab:d,followersTab:i})=>{const r=xe(),t=Ae(),a=$(),{canGoBack:m}=$e(),l=r.handle?`/profile/${r.handle}`:"/profile",h=!r.handle,b=r.handle?r.tab||"":t.pathname.split("/").pop()||"",k=u.useMemo(()=>h?["likes","following","followers"]:["following","followers"],[h]),w=k.includes(b)?b:"posts",y=He("index"),M=Le("index"),P=Ve("index"),f=ze("index"),I=J("index","me"),{data:E}=r.handle?I:{data:void 0},T=r.handle===E?.handle||!r.handle,B=s?.blockedByMe,D=s?.domainBlockedByMe,[p,N]=u.useState(!1),[F,g]=u.useState(!1),C=u.useRef(null);u.useEffect(()=>()=>{C.current&&window.clearTimeout(C.current)},[]);const X=()=>{B?M.mutate(s):(y.mutate(s),U.success("User blocked")),N(!1)},Z=()=>{D?f.mutate({url:s.apId,handle:s.handle}):(P.mutate({url:s.apId,handle:s.handle}),U.success("Domain blocked")),N(!1)},ee=async()=>{if(!s?.handle||!navigator?.clipboard?.writeText){U.error("Unable to copy handle");return}try{await navigator.clipboard.writeText(s.handle),g(!0),U.success("Handle copied"),C.current&&window.clearTimeout(C.current),C.current=window.setTimeout(()=>g(!1),2e3)}catch{U.error("Failed to copy handle"),g(!1)}},[R,je]=u.useState(!1),[be,se]=u.useState(!1),ge=()=>{je(!R)},V=u.useRef(null),[le,ke]=u.useState(!1);u.useEffect(()=>{V.current&&ke(V.current.scrollHeight>160)},[R,s?.bio,o,n]),u.useEffect(()=>{b&&(k.includes(b)||a(l,{replace:!0}))},[k,l,a,b]);const we=v=>v==="posts"?l:`${l}/${v}`,ve=v=>{v!==w&&a(we(v),{replace:!0})};return!n&&!s?e.jsx(te,{children:e.jsx("div",{className:"mx-auto mt-4 flex w-full max-w-[620px] flex-col items-center [&_svg]:translate-x-px",children:e.jsxs(_e,{children:[e.jsx(Qe,{children:e.jsx(xs,{})}),e.jsx("div",{children:"Profile not found"})]})})}):e.jsx(te,{children:e.jsx("div",{className:"z-0 mx-[max(-4vw,-32px)] -mt-9 flex flex-col items-center pb-16",children:e.jsx("div",{className:"mx-auto w-full",children:e.jsxs(e.Fragment,{children:[s?.bannerImageUrl?e.jsx("div",{className:"h-[15vw] min-h-[200px] w-full overflow-hidden bg-gradient-to-tr from-gray-200 to-gray-100",children:e.jsx("img",{alt:s?.name,className:"size-full object-cover",referrerPolicy:"no-referrer",src:s?.bannerImageUrl})}):e.jsx("div",{className:"h-[max(8vw,132px)] w-full overflow-hidden bg-gradient-to-tr from-white to-white dark:from-black dark:to-black"}),e.jsxs("div",{className:`mx-auto max-w-[620px] px-6 ${!s?.bannerImageUrl&&!m?"-mt-8":"-mt-12"}`,children:[e.jsxs("div",{className:"flex items-end justify-between",children:[e.jsx("div",{className:"-ml-2 rounded-full bg-white p-1 dark:bg-black",children:n?e.jsx(O,{className:"size-[92px] rounded-full"}):e.jsx(oe,{author:{icon:{url:s?.avatarUrl},name:s?.name,handle:s?.handle},size:"lg"})}),!T&&!n&&e.jsxs("div",{className:"flex gap-2",children:[B||D?e.jsx(gs,{account:s,onDomainUnblock:Z,onUnblock:X}):e.jsx(ae,{following:s?.followedByMe,handle:s?.handle,type:"primary",onFollow:re,onUnfollow:re}),e.jsx(bs,{account:s,isBlocked:B,isDomainBlocked:D,onBlockAccount:X,onBlockDomain:Z,onCopyHandle:ee,children:e.jsx(j,{"aria-label":"Open profile menu",variant:"outline",children:e.jsx(Ye,{})})})]}),T&&!n&&e.jsxs(Ke,{open:be,onOpenChange:se,children:[e.jsx(qe,{children:e.jsx(ms,{children:e.jsx(j,{variant:"secondary",children:"Edit profile"})})}),e.jsxs(Ge,{className:"w-full max-w-[520px]",onOpenAutoFocus:v=>v.preventDefault(),children:[e.jsx(Je,{children:e.jsx(We,{children:"Profile settings"})}),s&&e.jsx(cs,{account:s,setIsEditingProfile:se})]})]})]}),e.jsx(Xe,{className:"mt-4 truncate break-anywhere",children:n?e.jsx(O,{className:"w-32"}):s?.name}),e.jsxs("div",{className:"mb-4 flex items-center gap-2",children:[e.jsx("a",{className:"inline-flex max-w-full truncate text-[1.5rem] text-gray-800 hover:text-gray-900 dark:text-gray-600 dark:hover:text-gray-500",href:s?.url,rel:"noopener noreferrer",target:"_blank",children:e.jsx("span",{className:"truncate",children:n?e.jsx(O,{className:"w-full max-w-56"}):s?.handle})}),!n&&e.jsx(j,{className:"-ml-1.5 size-6 p-0 text-gray-800 hover:text-gray-900 dark:text-gray-700 dark:hover:text-gray-600",title:"Copy handle",variant:"link",onClick:ee,children:F?e.jsx(Ze,{size:16}):e.jsx(fs,{size:16})}),s?.followsMe&&!n&&e.jsx(es,{className:"mt-px whitespace-nowrap",variant:"secondary",children:"Follows you"})]}),(s?.bio||o?.length>0)&&e.jsxs("div",{ref:V,className:`ap-profile-content relative text-[1.5rem] break-anywhere [&>p]:mb-3 ${R?"max-h-none pb-7":"max-h-[160px] overflow-hidden"} relative`,children:[n?e.jsxs(e.Fragment,{children:[e.jsx(O,{}),e.jsx(O,{className:"w-full max-w-48"})]}):e.jsx("div",{dangerouslySetInnerHTML:{__html:ss(ls(s?.bio??"",["a","br"]))}}),o?.map(v=>e.jsxs("span",{className:"mt-3 line-clamp-1 flex flex-col text-[1.5rem]",children:[e.jsx("span",{className:"text-xs font-semibold",children:v.name}),e.jsx("span",{dangerouslySetInnerHTML:{__html:v.value},className:"ap-profile-content truncate"})]})),!R&&le&&e.jsx("div",{className:"absolute inset-x-0 bottom-0 h-16 bg-gradient-to-t from-white via-white/100 via-60% to-transparent dark:from-black dark:via-black/100"}),le&&e.jsx(j,{className:"absolute bottom-0 h-auto p-0 text-md",variant:"link",onClick:ge,children:R?"Show less":"Show all"})]}),e.jsxs(ds,{className:"mt-5",value:w,variant:"underline",onValueChange:v=>ve(v),children:[e.jsxs(us,{children:[e.jsx(S,{value:"posts",children:"Posts"}),h&&e.jsxs(S,{value:"likes",children:["Likes",e.jsx(_,{children:z(s?.likedCount||0)})]}),e.jsxs(S,{value:"following",children:["Following",e.jsx(_,{children:z(s?.followingCount||0)})]}),e.jsxs(S,{value:"followers",children:["Followers",e.jsx(_,{children:z(s?.followerCount||0)})]})]}),e.jsx(A,{value:"posts",children:(B||D)&&!p?e.jsxs(H,{children:[e.jsx(L,{children:e.jsx(ns,{})}),e.jsxs("div",{className:"mt-2 flex flex-col items-center gap-0.5",children:[e.jsxs(q,{children:[s.name," is blocked"]}),e.jsx("p",{children:"You can view the posts, but it won't unblock the user."}),e.jsx(j,{className:"mt-4",variant:"secondary",onClick:()=>N(!0),children:"View posts"})]})]}):c}),h&&e.jsx(A,{value:"likes",children:x}),e.jsx(A,{value:"following",children:d}),e.jsx(A,{value:"followers",children:i})]},r.handle||s?.handle||"current-user")]})]})})})})},ws=({handle:s})=>{const{postsByAccountQuery:o}=os(s||"me",{enabled:!0}),{data:n,fetchNextPage:c,hasNextPage:x,isFetchingNextPage:d,isLoading:i}=o,r=n?.pages.flatMap(t=>t.posts)??Array.from({length:5},(t,a)=>({id:`placeholder-${a}`,object:{}}));return e.jsx(js,{fetchNextPage:c,hasNextPage:x,isFetchingNextPage:d,isLoading:i,noResultsMessage:s?`${s} hasn't posted anything yet`:"You haven't posted anything yet.",posts:r})},vs=()=>{const{postsLikedByAccountQuery:s}=as({enabled:!0}),{data:o,fetchNextPage:n,hasNextPage:c,isFetchingNextPage:x,isLoading:d}=s,i=o?.pages.flatMap(r=>r.posts)??Array.from({length:5},(r,t)=>({id:`placeholder-${t}`,object:{}}));return e.jsx(ps,{fetchNextPage:n,hasNextPage:c,isFetchingNextPage:x,isLoading:d,posts:i})},ys=({handle:s})=>{const o=fe(s===""?"me":s,"following"),{data:n,fetchNextPage:c,hasNextPage:x,isFetchingNextPage:d,isLoading:i}=o,r=n?.pages.flatMap(t=>"following"in t?t.following:"accounts"in t?t.accounts.map(a=>({actor:{id:a.id,name:a.name,handle:a.handle,icon:{url:a.avatarUrl}},isFollowing:a.isFollowing,blockedByMe:a.blockedByMe,domainBlockedByMe:a.domainBlockedByMe})):[])??[];return e.jsx(he,{actors:r,fetchNextPage:c,hasNextPage:x,isFetchingNextPage:d,isLoading:i,noResultsMessage:`${s||"You"} have no following`})},Ns=({handle:s})=>{const o=fe(s===""?"me":s,"followers"),{data:n,fetchNextPage:c,hasNextPage:x,isFetchingNextPage:d,isLoading:i}=o,r=n?.pages.flatMap(t=>"followers"in t?t.followers:"accounts"in t?t.accounts.map(a=>({actor:{id:a.id,name:a.name,handle:a.handle,icon:{url:a.avatarUrl}},isFollowing:a.isFollowing})):[])??[];return e.jsx(he,{actors:r,fetchNextPage:c,hasNextPage:x,isFetchingNextPage:d,isLoading:i,noResultsMessage:`${s||"You"} have no followers yet`})},qs=({})=>{const s=xe(),{data:o,isLoading:n,error:c,refetch:x}=J("index",s.handle||"me");if(u.useEffect(()=>{x()},[s.handle,x]),c&&ts(c)&&c.statusCode!==404)return e.jsx(rs,{errorCode:c.code,statusCode:c.statusCode});const d=Object.keys(o?.customFields||{}).map(m=>({name:m,value:o.customFields[m]}))||[],i=e.jsx(ws,{handle:s.handle||""}),r=e.jsx(vs,{}),t=e.jsx(ys,{handle:s.handle||""}),a=e.jsx(Ns,{handle:s.handle||""});return e.jsx(ks,{account:o,customFields:d,followersTab:a,followingTab:t,isLoadingAccount:n,likesTab:r,postsTab:i})};export{qs as default};
@@ -1 +1 @@
1
- import{r as v,aq as N,ar as P,j as u,as as S,at as w,au as p,av as x,aw as F,ax as D,ay as T,az as V}from"./index-CMTzNTew.js";var g="Tabs",[G]=S(g,[x]),C=x(),[L,m]=G(g),h=v.forwardRef((e,n)=>{const{__scopeTabs:i,value:a,onValueChange:r,defaultValue:c,orientation:t="horizontal",dir:d,activationMode:b="automatic",...f}=e,s=N(d),[o,l]=P({prop:a,onChange:r,defaultProp:c??"",caller:g});return u.jsx(L,{scope:i,baseId:w(),value:o,onValueChange:l,orientation:t,dir:s,activationMode:b,children:u.jsx(p.div,{dir:s,"data-orientation":t,...f,ref:n})})});h.displayName=g;var I="TabsList",R=v.forwardRef((e,n)=>{const{__scopeTabs:i,loop:a=!0,...r}=e,c=m(I,i),t=C(i);return u.jsx(F,{asChild:!0,...t,orientation:c.orientation,dir:c.dir,loop:a,children:u.jsx(p.div,{role:"tablist","aria-orientation":c.orientation,...r,ref:n})})});R.displayName=I;var y="TabsTrigger",_=v.forwardRef((e,n)=>{const{__scopeTabs:i,value:a,disabled:r=!1,...c}=e,t=m(y,i),d=C(i),b=j(t.baseId,a),f=M(t.baseId,a),s=a===t.value;return u.jsx(D,{asChild:!0,...d,focusable:!r,active:s,children:u.jsx(p.button,{type:"button",role:"tab","aria-selected":s,"aria-controls":f,"data-state":s?"active":"inactive","data-disabled":r?"":void 0,disabled:r,id:b,...c,ref:n,onMouseDown:T(e.onMouseDown,o=>{!r&&o.button===0&&o.ctrlKey===!1?t.onValueChange(a):o.preventDefault()}),onKeyDown:T(e.onKeyDown,o=>{[" ","Enter"].includes(o.key)&&t.onValueChange(a)}),onFocus:T(e.onFocus,()=>{const o=t.activationMode!=="manual";!s&&!r&&o&&t.onValueChange(a)})})})});_.displayName=y;var A="TabsContent",E=v.forwardRef((e,n)=>{const{__scopeTabs:i,value:a,forceMount:r,children:c,...t}=e,d=m(A,i),b=j(d.baseId,a),f=M(d.baseId,a),s=a===d.value,o=v.useRef(s);return v.useEffect(()=>{const l=requestAnimationFrame(()=>o.current=!1);return()=>cancelAnimationFrame(l)},[]),u.jsx(V,{present:r||s,children:({present:l})=>u.jsx(p.div,{"data-state":s?"active":"inactive","data-orientation":d.orientation,role:"tabpanel","aria-labelledby":b,hidden:!l,id:f,tabIndex:0,...t,ref:n,style:{...e.style,animationDuration:o.current?"0s":void 0},children:l&&c})})});E.displayName=A;function j(e,n){return`${e}-trigger-${n}`}function M(e,n){return`${e}-content-${n}`}var k=h,K=R,q=_,z=E;export{z as C,K as L,k as R,q as T};
1
+ import{r as v,aq as N,ar as P,j as u,as as S,at as w,au as p,av as x,aw as F,ax as D,ay as T,az as V}from"./index-B8G0f0hb.js";var g="Tabs",[G]=S(g,[x]),C=x(),[L,m]=G(g),h=v.forwardRef((e,n)=>{const{__scopeTabs:i,value:a,onValueChange:r,defaultValue:c,orientation:t="horizontal",dir:d,activationMode:b="automatic",...f}=e,s=N(d),[o,l]=P({prop:a,onChange:r,defaultProp:c??"",caller:g});return u.jsx(L,{scope:i,baseId:w(),value:o,onValueChange:l,orientation:t,dir:s,activationMode:b,children:u.jsx(p.div,{dir:s,"data-orientation":t,...f,ref:n})})});h.displayName=g;var I="TabsList",R=v.forwardRef((e,n)=>{const{__scopeTabs:i,loop:a=!0,...r}=e,c=m(I,i),t=C(i);return u.jsx(F,{asChild:!0,...t,orientation:c.orientation,dir:c.dir,loop:a,children:u.jsx(p.div,{role:"tablist","aria-orientation":c.orientation,...r,ref:n})})});R.displayName=I;var y="TabsTrigger",_=v.forwardRef((e,n)=>{const{__scopeTabs:i,value:a,disabled:r=!1,...c}=e,t=m(y,i),d=C(i),b=j(t.baseId,a),f=M(t.baseId,a),s=a===t.value;return u.jsx(D,{asChild:!0,...d,focusable:!r,active:s,children:u.jsx(p.button,{type:"button",role:"tab","aria-selected":s,"aria-controls":f,"data-state":s?"active":"inactive","data-disabled":r?"":void 0,disabled:r,id:b,...c,ref:n,onMouseDown:T(e.onMouseDown,o=>{!r&&o.button===0&&o.ctrlKey===!1?t.onValueChange(a):o.preventDefault()}),onKeyDown:T(e.onKeyDown,o=>{[" ","Enter"].includes(o.key)&&t.onValueChange(a)}),onFocus:T(e.onFocus,()=>{const o=t.activationMode!=="manual";!s&&!r&&o&&t.onValueChange(a)})})})});_.displayName=y;var A="TabsContent",E=v.forwardRef((e,n)=>{const{__scopeTabs:i,value:a,forceMount:r,children:c,...t}=e,d=m(A,i),b=j(d.baseId,a),f=M(d.baseId,a),s=a===d.value,o=v.useRef(s);return v.useEffect(()=>{const l=requestAnimationFrame(()=>o.current=!1);return()=>cancelAnimationFrame(l)},[]),u.jsx(V,{present:r||s,children:({present:l})=>u.jsx(p.div,{"data-state":s?"active":"inactive","data-orientation":d.orientation,role:"tabpanel","aria-labelledby":b,hidden:!l,id:f,tabIndex:0,...t,ref:n,style:{...e.style,animationDuration:o.current?"0s":void 0},children:l&&c})})});E.displayName=A;function j(e,n){return`${e}-trigger-${n}`}function M(e,n){return`${e}-content-${n}`}var k=h,K=R,q=_,z=E;export{z as C,K as L,k as R,q as T};