ghost 6.19.0 → 6.19.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/components/tryghost-i18n-6.19.1.tgz +0 -0
  2. package/components/{tryghost-parse-email-address-6.19.0.tgz → tryghost-parse-email-address-6.19.1.tgz} +0 -0
  3. package/core/built/admin/assets/{PolarAngleAxis-CGprvq8M.js → PolarAngleAxis-BzbazaED.js} +1 -1
  4. package/core/built/admin/assets/{_baseAssignValue-Bwn07Ln5.js → _baseAssignValue-D0bBhNG1.js} +1 -1
  5. package/core/built/admin/assets/{a-large-small-p58xibEK.js → a-large-small-gBDqOWOy.js} +1 -1
  6. package/core/built/admin/assets/{at-sign-BZPuAx5m.js → at-sign-V79EBNTJ.js} +1 -1
  7. package/core/built/admin/assets/{audience-Cy9gLIa9.js → audience-DF--nR_q.js} +1 -1
  8. package/core/built/admin/assets/{avatar-flipboard-CLmWb5Xn.js → avatar-flipboard-GK39JNWl.js} +1 -1
  9. package/core/built/admin/assets/{bluesky-sharing-BHt0oiii.js → bluesky-sharing-BKRqTAow.js} +1 -1
  10. package/core/built/admin/assets/{chart--RFLGIL4.js → chart-0ezwQhyB.js} +1 -1
  11. package/core/built/admin/assets/{chunk.524.5c5c3f3273a86d1d9913.js → chunk.524.e62f8276cc561fcddb66.js} +6 -6
  12. package/core/built/admin/assets/{chunk.582.e6c787cdf7e6de7819e0.js → chunk.582.0cdc35e120cf621f18b9.js} +8 -8
  13. package/core/built/admin/assets/{code-editor-view-BW9y0JXN.js → code-editor-view-xVA7A1IE.js} +1 -1
  14. package/core/built/admin/assets/{comments-C_lilDBp.js → comments-Tt1iOjcd.js} +1 -1
  15. package/core/built/admin/assets/{content-helpers-BOnQQADZ.js → content-helpers-TSHyiXwF.js} +1 -1
  16. package/core/built/admin/assets/{copy-Bi7VpgPR.js → copy-CTHgI4YI.js} +1 -1
  17. package/core/built/admin/assets/{data-list-Bu3jzs1s.js → data-list-6rXP5AUF.js} +1 -1
  18. package/core/built/admin/assets/{deleted-feed-item-B-doIIKc.js → deleted-feed-item-CK_4qToF.js} +1 -1
  19. package/core/built/admin/assets/{edit-profile-ZBdjFfvL.js → edit-profile-B_ViIhsd.js} +1 -1
  20. package/core/built/admin/assets/{empty-indicator-C6BBh99D.js → empty-indicator-CzTRebSi.js} +1 -1
  21. package/core/built/admin/assets/{en-C7eSFQRw.js → en-D1H4BpXe.js} +1 -1
  22. package/core/built/admin/assets/{feed-CAioauwD.js → feed-0iLmr_Xb.js} +1 -1
  23. package/core/built/admin/assets/{filters-DEKF0tIB.js → filters-6zg35bLL.js} +1 -1
  24. package/core/built/admin/assets/{gh-chart-D9KI0_sO.js → gh-chart-ldqA2tQU.js} +1 -1
  25. package/core/built/admin/assets/{ghost-6bff5c535ef015b0ed9421ceb6c699a7.js → ghost-6b109ed708c502afee4ff1d9185ae40c.js} +256 -268
  26. package/core/built/admin/assets/ghost-b3dff8469d9c9af487866537210234bd.css +1 -0
  27. package/core/built/admin/assets/ghost-dark-16a7b98c352c1f70016e73af10962179.css +1 -0
  28. package/core/built/admin/assets/{growth-C6XGchvT.js → growth-BUQvBEMA.js} +1 -1
  29. package/core/built/admin/assets/{hash-DFhnGHId.js → hash-CRtHv162.js} +1 -1
  30. package/core/built/admin/assets/{inbox-p-Y5uScT.js → inbox-DWYGFLuU.js} +1 -1
  31. package/core/built/admin/assets/{index-CIZ_upe2.js → index-1J5JrBgd.js} +1 -1
  32. package/core/built/admin/assets/{index-CS4XqyC-.js → index-BFT8PQPd.js} +1 -1
  33. package/core/built/admin/assets/{index-BWnrLoWI.js → index-BeG1PnbN.js} +1 -1
  34. package/core/built/admin/assets/{index-DCTdAEHx.js → index-Bgo4hw-T.js} +3 -3
  35. package/core/built/admin/assets/{index-jAidr8jI.js → index-CCmy-hD6.js} +1 -1
  36. package/core/built/admin/assets/index-CKfif8kf.js +13 -0
  37. package/core/built/admin/assets/{index-FPf-AERu.js → index-Cc9yKRsT.js} +1 -1
  38. package/core/built/admin/assets/{index-3uU4zg_6.js → index-CvV71sVO.js} +1 -1
  39. package/core/built/admin/assets/{index-LyfDjTto.js → index-D0RISNEd.js} +1 -1
  40. package/core/built/admin/assets/{index-JmqyGBro.js → index-D1AppGlg.js} +1 -1
  41. package/core/built/admin/assets/{index-D17PEsUB.js → index-EFWmaChO.js} +1 -1
  42. package/core/built/admin/assets/{index-Wx8_AGZX.js → index-SulwGym9.js} +1 -1
  43. package/core/built/admin/assets/{index-lPLmWtv0.js → index-_dLVP2u2.js} +1 -1
  44. package/core/built/admin/assets/{index-BzU2odQq.js → index-nb8rSrz_.js} +1 -1
  45. package/core/built/admin/assets/{index--VlvGKWi.js → index-zvNmrx86.js} +1 -1
  46. package/core/built/admin/assets/{koenig-lexical-CWnkYKQt.js → koenig-lexical-D8K6acyr.js} +1 -1
  47. package/core/built/admin/assets/{kpi-card-B5UaJgOT.js → kpi-card-CaX6eHyr.js} +1 -1
  48. package/core/built/admin/assets/{kpis-Cc2RxnvZ.js → kpis-BfR_uoFr.js} +1 -1
  49. package/core/built/admin/assets/{label-CW7Kmp9w.js → label-BQ5mfFHN.js} +1 -1
  50. package/core/built/admin/assets/{links-wWNc9Uat.js → links-lZnz9cuZ.js} +1 -1
  51. package/core/built/admin/assets/{list-filter-3EF6cVg-.js → list-filter-CofVbkA4.js} +1 -1
  52. package/core/built/admin/assets/{lucide-react-DtMIZssr.js → lucide-react-7D_Tsesk.js} +1 -1
  53. package/core/built/admin/assets/{main-layout-BFYhCrLn.js → main-layout-DBVy-lM5.js} +1 -1
  54. package/core/built/admin/assets/{message-square-text-BDZtUW-2.js → message-square-text-DzuHB7uU.js} +1 -1
  55. package/core/built/admin/assets/{minus-CSphShdJ.js → minus-BIdO1CDG.js} +1 -1
  56. package/core/built/admin/assets/{modals-CDWP04Iy.js → modals-GY5yP0Bl.js} +1 -1
  57. package/core/built/admin/assets/{moderation-qcng2_lB.js → moderation-CB9TwdgZ.js} +1 -1
  58. package/core/built/admin/assets/{newsletter-R-IYcV4M.js → newsletter-Bww4nkp5.js} +1 -1
  59. package/core/built/admin/assets/{newsletters-BB4e24i1.js → newsletters-C8pT7kSQ.js} +1 -1
  60. package/core/built/admin/assets/{note-B_bpRX66.js → note-BeCIv25U.js} +1 -1
  61. package/core/built/admin/assets/{overview-Nh-IoP-v.js → overview-BCZDRsR0.js} +1 -1
  62. package/core/built/admin/assets/{pagemenu-Cd45frnF.js → pagemenu-D3ByoZIR.js} +1 -1
  63. package/core/built/admin/assets/{post-analytics-jHZOhQ8L.js → post-analytics-B4z47Loe.js} +1 -1
  64. package/core/built/admin/assets/{post-analytics-context-BST4bzps.js → post-analytics-context-BQ8IcW4n.js} +1 -1
  65. package/core/built/admin/assets/{post-analytics-header-DAZPp6M8.js → post-analytics-header-CpBVLNat.js} +1 -1
  66. package/core/built/admin/assets/{post-share-modal-D1JQfuYx.js → post-share-modal-Dz4BNSV-.js} +1 -1
  67. package/core/built/admin/assets/{posts-DFiJPOft.js → posts-C94RiQ4S.js} +1 -1
  68. package/core/built/admin/assets/{repeat-Smml9n0k.js → repeat-YTCeIlQZ.js} +1 -1
  69. package/core/built/admin/assets/{reply-CooY4lmk.js → reply-CUazFbTY.js} +1 -1
  70. package/core/built/admin/assets/{select-WwMsbBbg.js → select-MVpx-Kfp.js} +1 -1
  71. package/core/built/admin/assets/{settings-CQEhPDQU.js → settings-CEfmF6wO.js} +4 -4
  72. package/core/built/admin/assets/{settings-CxWtvcUf.js → settings-Q3y0Zw5o.js} +1 -1
  73. package/core/built/admin/assets/{sort-button-DFr8vezl.js → sort-button-CEXkgGLb.js} +1 -1
  74. package/core/built/admin/assets/{source-icon-VpYWpwYb.js → source-icon-BDparw9V.js} +1 -1
  75. package/core/built/admin/assets/{sprout-DRqlFJSK.js → sprout-CXg43Zav.js} +1 -1
  76. package/core/built/admin/assets/{square-CwHQ9sJ2.js → square-C8G-1gV_.js} +1 -1
  77. package/core/built/admin/assets/stats/{audience-Caf7BjaU.mjs → audience-DJv-je5C.mjs} +3 -3
  78. package/core/built/admin/assets/stats/{content-helpers-MbtAvUJh.mjs → content-helpers-Bq8zgCUT.mjs} +4 -4
  79. package/core/built/admin/assets/stats/{index-DMkZbbZs.mjs → index-B12PHa64.mjs} +8 -8
  80. package/core/built/admin/assets/stats/{index-wT0OIw_N.mjs → index-DRN41f8l.mjs} +5 -5
  81. package/core/built/admin/assets/stats/{index-ChjIxhHy.mjs → index-DwqY9qrn.mjs} +5 -5
  82. package/core/built/admin/assets/stats/{index-BGqKbF1D.mjs → index-GLg_cfiu.mjs} +464 -461
  83. package/core/built/admin/assets/stats/{index-BTjfXOi6.mjs → index-gS3EAScL.mjs} +5 -5
  84. package/core/built/admin/assets/stats/{sort-button-B8n8fYMi.mjs → sort-button-f_Dfri5f.mjs} +8 -8
  85. package/core/built/admin/assets/stats/{stats-CGH-0JNs.mjs → stats-CTWb7qo1.mjs} +96 -91
  86. package/core/built/admin/assets/stats/stats.js +1 -1
  87. package/core/built/admin/assets/stats/{tabs-EQCUj3Y9.mjs → tabs-DVvxZ7wa.mjs} +7 -7
  88. package/core/built/admin/assets/stats/{use-growth-stats--CIfag21.mjs → use-growth-stats-w7-2bD-r.mjs} +3 -3
  89. package/core/built/admin/assets/{stats-lnFiOQZx.js → stats-B2vPCVx7.js} +1 -1
  90. package/core/built/admin/assets/stats-view-BRy4IDHe.js +1 -0
  91. package/core/built/admin/assets/{step-1-Bx8MiQVF.js → step-1-MLqNxHrJ.js} +1 -1
  92. package/core/built/admin/assets/{step-2-CLLXppER.js → step-2-DY3jIa6G.js} +1 -1
  93. package/core/built/admin/assets/{step-3-C5WrQe8u.js → step-3-Dt6w5-MB.js} +1 -1
  94. package/core/built/admin/assets/{table-2waWpIF5.js → table-BWAnP2ln.js} +1 -1
  95. package/core/built/admin/assets/{tabs-CBD0hW8V.js → tabs-Bw13eFRh.js} +1 -1
  96. package/core/built/admin/assets/{tags-CKrBptuC.js → tags-BQz2NtFF.js} +1 -1
  97. package/core/built/admin/assets/{tags-Bgw5Hrb5.js → tags-Bj9RJW9l.js} +1 -1
  98. package/core/built/admin/assets/{tiers-CO-pz1FX.js → tiers-jCNws2RK.js} +1 -1
  99. package/core/built/admin/assets/{toggle-group-BXAZzvJ9.js → toggle-group-B0wGpmLS.js} +1 -1
  100. package/core/built/admin/assets/{topic-filter-U3qUH2P_.js → topic-filter-BPOZf5IO.js} +1 -1
  101. package/core/built/admin/assets/{trash-CJY1Wro_.js → trash-BKeiM6WP.js} +1 -1
  102. package/core/built/admin/assets/{use-growth-stats-BrLZI7da.js → use-growth-stats-C5TiRW1S.js} +1 -1
  103. package/core/built/admin/assets/{use-infinite-virtual-scroll-CiRn3kpz.js → use-infinite-virtual-scroll-CdNJ5RT5.js} +1 -1
  104. package/core/built/admin/assets/{use-simple-pagination-CskJ0MDP.js → use-simple-pagination-CCVB_aJH.js} +1 -1
  105. package/core/built/admin/assets/{user-round-check-zOuzV3OS.js → user-round-check-Df7ko4Tm.js} +1 -1
  106. package/core/built/admin/assets/{wallet-cards-ddLuIN-b.js → wallet-cards-Cl4bJBBw.js} +1 -1
  107. package/core/built/admin/assets/{web-CGbkZWn3.js → web-DxLX2yUi.js} +1 -1
  108. package/core/built/admin/index.html +5 -5
  109. package/core/frontend/helpers/get.js +51 -3
  110. package/core/server/api/endpoints/utils/serializers/input/utils/slug-filter-order.js +8 -5
  111. package/core/server/models/base/plugins/crud.js +6 -1
  112. package/core/server/services/email-suppression-list/email-suppression-list.js +1 -1
  113. package/package.json +16 -10
  114. package/yarn.lock +128 -181
  115. package/components/tryghost-i18n-6.19.0.tgz +0 -0
  116. package/core/built/admin/assets/ghost-3c48d37b32f4fcd7eb15cfd739905a03.css +0 -1
  117. package/core/built/admin/assets/ghost-dark-0100fe3ec7b4c3f6d8d043c904254a63.css +0 -1
  118. package/core/built/admin/assets/index-S62-c8TV.js +0 -13
  119. package/core/built/admin/assets/stats-view-BJVawuIv.js +0 -1
@@ -1 +1 @@
1
- import{aP as U,j as s,B as F,aU as T,e as _,y as I,bv as V,bw as q,bx as J,by as Q,bz as X,bA as Y,aj as b,r as g,u as Z,S as A,aR as D,bB as ss,bH as es}from"./index-DCTdAEHx.js";import{E as G}from"./empty-indicator-C6BBh99D.js";import{A as rs,U as as,a as ts,W as ns,C as os}from"./wallet-cards-ddLuIN-b.js";import{S as E}from"./source-icon-VpYWpwYb.js";import{p as cs,e as is}from"./source-utils-B1S3ZHA2.js";import{C as N,a as C,b as S,f as v,c as w,g as ls}from"./pagemenu-Cd45frnF.js";import{a as ds,b as ms,c as L,d as f,e as hs,f as y}from"./table-2waWpIF5.js";import{K as M,d as H,a as R,b as $,c as k}from"./kpi-card-B5UaJgOT.js";import{P as xs,a as ps}from"./post-analytics-header-DAZPp6M8.js";import{u as us}from"./post-analytics-context-BST4bzps.js";import{g as P}from"./currency-fEUUCkj0.js";import{c as js,d as bs,a as gs}from"./stats-lnFiOQZx.js";const fs=({className:o})=>{const t=U();return s.jsx(G,{actions:s.jsx(F,{variant:"outline",onClick:()=>t("/settings/analytics",{crossApp:!0}),children:"Open settings"}),className:o,description:"Enable member source tracking in settings to see which content drives member growth.",title:"Member sources have been disabled",children:s.jsx(rs,{})})},O="https://www.google.com/s2/favicons?domain=ghost.org&sz=64",W=({headerStyle:o="table",children:t="Source",data:h,mode:r,defaultSourceIconUrl:a=O})=>{const{appSettings:c}=T();if(r==="growth")return s.jsxs(ds,{children:[s.jsx(ms,{children:s.jsxs(L,{children:[s.jsx(f,{className:"min-w-[320px]",variant:o==="table"?"default":"cardhead",children:t}),s.jsx(f,{className:"w-[110px] text-right",children:"Free members"}),c?.paidMembersEnabled&&s.jsxs(s.Fragment,{children:[s.jsx(f,{className:"w-[110px] text-right",children:"Paid members"}),s.jsx(f,{className:"w-[100px] text-right",children:"MRR impact"})]})]})}),s.jsx(hs,{children:h?.map(e=>{const l=d=>Math.round(d/100);return s.jsxs(L,{className:"last:border-none",children:[s.jsx(y,{children:e.linkUrl?s.jsxs("a",{className:"group flex items-center gap-2",href:e.linkUrl,rel:"noreferrer",target:"_blank",children:[s.jsx(E,{defaultSourceIconUrl:a,displayName:e.displayName,iconSrc:e.iconSrc}),s.jsx("span",{className:"group-hover:underline",children:e.displayName})]}):s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(E,{defaultSourceIconUrl:a,displayName:e.displayName,iconSrc:e.iconSrc}),s.jsx("span",{children:e.displayName})]})}),s.jsxs(y,{className:"text-right font-mono text-sm",children:["+",b(e.free_members||0)]}),c?.paidMembersEnabled&&s.jsxs(s.Fragment,{children:[s.jsxs(y,{className:"text-right font-mono text-sm",children:["+",b(e.paid_members||0)]}),s.jsxs(y,{className:"text-right font-mono text-sm",children:["+$",b(l(e.mrr||0))]})]})]},e.source)})})]})},ys=({title:o="Top sources",description:t,data:h,mode:r="visits",range:a=30,totalVisitors:c=0,siteUrl:e,siteIcon:l,defaultSourceIconUrl:d=O,getPeriodText:i,className:p})=>{const{appSettings:x}=T(),n=_.useMemo(()=>cs({data:h,mode:r,siteUrl:e,siteIcon:l,defaultSourceIconUrl:d}),[h,e,l,r,d]),m=_.useMemo(()=>is({processedData:n,totalVisitors:c,mode:r}),[n,c,r]),u=m.slice(0,10),j=t||(r==="growth"?"Where did your growth come from?":`How readers found your ${a?"site":"post"}${a&&i?` ${i(a)}`:""}`),B=r==="growth"?"Sources":"Top sources",z=r==="growth"?"Where did your growth come from?":`How readers found your ${a?"site":"post"}${a&&i?` ${i(a)}`:""}`;return s.jsxs(N,{className:I("group/datalist w-full max-w-[calc(100vw-64px)] overflow-x-auto sidebar:max-w-[calc(100vw-64px-280px)]",p),"data-testid":"top-sources-card",children:[u.length<=0&&s.jsxs(C,{children:[s.jsx(S,{children:o}),s.jsx(v,{children:j})]}),s.jsx(w,{children:r==="growth"&&!x?.analytics.membersTrackSources?s.jsx(fs,{className:"py-10"}):u.length>0?s.jsx(W,{data:u,defaultSourceIconUrl:d,getPeriodText:i,headerStyle:"card",mode:r,range:a,children:s.jsxs(C,{children:[s.jsx(S,{children:o}),s.jsx(v,{children:j})]})}):s.jsx("div",{className:"py-20 text-center text-sm text-gray-700",children:s.jsx(G,{className:"h-full",description:r==="growth"&&"Once someone signs up on this post, sources will show here",title:`No sources data available ${i?i(a):""}`,children:s.jsx(as,{strokeWidth:1.5})})})}),m.length>10&&s.jsx(ls,{children:s.jsxs(V,{children:[s.jsx(q,{asChild:!0,children:s.jsxs(F,{variant:"outline",children:["View all ",s.jsx(ts,{})]})}),s.jsxs(J,{className:"overflow-y-auto pt-0 sm:max-w-[600px]",children:[s.jsxs(Q,{className:"sticky top-0 z-40 -mx-6 bg-background/60 p-6 backdrop-blur",children:[s.jsx(X,{children:B}),s.jsx(Y,{children:z})]}),s.jsx("div",{className:"group/datalist",children:s.jsx(W,{data:m,defaultSourceIconUrl:d,getPeriodText:i,mode:r,range:a})})]})]})})]})},Ns=o=>{const{data:t,isLoading:h}=js(o),{data:r,isLoading:a}=bs(o),{data:c,isLoading:e}=gs(),l=g.useMemo(()=>t?.stats||[],[t]),d=g.useMemo(()=>r?.stats.length===0?{free_members:0,paid_members:0,mrr:0}:r?.stats[0],[r]),{selectedCurrency:i,currencySymbol:p}=g.useMemo(()=>{if(c?.stats&&c?.meta?.totals){const n=c.meta.totals;let m=n[0];if(!m)return{selectedCurrency:"usd",currencySymbol:P("usd")};for(const j of n)j.mrr>m.mrr&&(m=j);const u=m.currency;return{selectedCurrency:u,currencySymbol:P(u)}}return{selectedCurrency:"usd",currencySymbol:P("usd")}},[c]);return{isLoading:g.useMemo(()=>h||a||e,[h,a,e]),stats:l,totals:d,selectedCurrency:i,currencySymbol:p}},K=o=>Math.round(o/100),ws=()=>{const{data:o}=us(),{postId:t}=Z(),{stats:h,totals:r,isLoading:a,currencySymbol:c}=Ns(t||""),{appSettings:e}=T(),l=U(),d=o?.url,i=o?.icon;let p="flex flex-col items-stretch gap-6",x="";return e?.paidMembersEnabled||(p="grid grid-cols-1 border rounded-md",x="border-none hover:shadow-none"),s.jsxs(s.Fragment,{children:[s.jsx(xs,{currentTab:"Growth"}),s.jsx(ps,{children:a?s.jsxs("div",{className:p,children:[s.jsx(N,{className:x,children:s.jsx(w,{className:"grid grid-cols-3 p-0",children:Array.from({length:3},(n,m)=>s.jsxs("div",{className:"h-[98px] gap-1 border-r px-6 py-5 last:border-r-0",children:[s.jsx(A,{className:"w-2/3"}),s.jsx(A,{className:"h-7 w-12"})]},m))})}),s.jsxs(N,{className:x,children:[s.jsxs(C,{children:[s.jsx(S,{children:"Top sources"}),s.jsx(v,{children:"Where did your growth come from?"})]}),s.jsxs(w,{children:[s.jsx(D,{}),s.jsx(ss,{className:"pt-6"})]})]})]}):s.jsxs("div",{className:p,children:[s.jsxs(N,{className:x,"data-testid":"members-card",children:[s.jsxs(C,{className:"hidden",children:[s.jsx(S,{children:"Newsletters"}),s.jsx(v,{children:"How did this post perform"})]}),s.jsx(w,{className:"p-0",children:s.jsxs("div",{className:`flex flex-col md:grid md:items-stretch ${e?.paidMembersEnabled?"md:grid-cols-3":"md:grid-cols-1"}`,children:[s.jsxs(M,{className:"grow",children:[s.jsx(H,{onClick:()=>{const n=encodeURIComponent(`signup:'${t}'+conversion:-'${t}'`);l(`/members?filterParam=${n}`,{crossApp:!0})},children:"View members →"}),s.jsxs(R,{onClick:()=>{const n=encodeURIComponent(`signup:'${t}'+conversion:-'${t}'`);l(`/members?filterParam=${n}`,{crossApp:!0})},children:[s.jsx(es,{strokeWidth:1.5}),"Free members"]}),s.jsx($,{children:s.jsx(k,{children:b(r?.free_members||0)})})]}),e?.paidMembersEnabled&&s.jsxs(s.Fragment,{children:[s.jsxs(M,{className:"grow",children:[s.jsx(H,{onClick:()=>{const n=encodeURIComponent(`conversion:'${t}'`);l(`/members?filterParam=${n}`,{crossApp:!0})},children:"View members →"}),s.jsxs(R,{onClick:()=>{const n=encodeURIComponent(`conversion:'${t}'`);l(`/members?filterParam=${n}`,{crossApp:!0})},children:[s.jsx(ns,{strokeWidth:1.5}),"Paid members"]}),s.jsx($,{children:s.jsx(k,{children:b(r?.paid_members||0)})})]}),s.jsxs(M,{className:"grow",children:[s.jsxs(R,{children:[s.jsx(os,{strokeWidth:1.5}),"MRR"]}),s.jsx($,{children:s.jsxs(k,{children:["+",c,K(r?.mrr||0)]})})]})]})]})})]}),!e?.paidMembersEnabled&&s.jsx(D,{}),s.jsx(ys,{className:x,data:h,mode:"growth",siteIcon:i,siteUrl:d})]})})]})},Es=Object.freeze(Object.defineProperty({__proto__:null,centsToDollars:K,default:ws},Symbol.toStringTag,{value:"Module"}));export{fs as D,K as c,Es as g,Ns as u};
1
+ import{aP as U,j as s,B as F,aU as T,e as _,y as I,bv as V,bw as q,bx as J,by as Q,bz as X,bA as Y,aj as b,r as g,u as Z,S as A,aR as D,bB as ss,bH as es}from"./index-Bgo4hw-T.js";import{E as G}from"./empty-indicator-CzTRebSi.js";import{A as rs,U as as,a as ts,W as ns,C as os}from"./wallet-cards-Cl4bJBBw.js";import{S as E}from"./source-icon-BDparw9V.js";import{p as cs,e as is}from"./source-utils-B1S3ZHA2.js";import{C as N,a as C,b as S,f as v,c as w,g as ls}from"./pagemenu-D3ByoZIR.js";import{a as ds,b as ms,c as L,d as f,e as hs,f as y}from"./table-BWAnP2ln.js";import{K as M,d as H,a as R,b as $,c as k}from"./kpi-card-CaX6eHyr.js";import{P as xs,a as ps}from"./post-analytics-header-CpBVLNat.js";import{u as us}from"./post-analytics-context-BQ8IcW4n.js";import{g as P}from"./currency-fEUUCkj0.js";import{c as js,d as bs,a as gs}from"./stats-B2vPCVx7.js";const fs=({className:o})=>{const t=U();return s.jsx(G,{actions:s.jsx(F,{variant:"outline",onClick:()=>t("/settings/analytics",{crossApp:!0}),children:"Open settings"}),className:o,description:"Enable member source tracking in settings to see which content drives member growth.",title:"Member sources have been disabled",children:s.jsx(rs,{})})},O="https://www.google.com/s2/favicons?domain=ghost.org&sz=64",W=({headerStyle:o="table",children:t="Source",data:h,mode:r,defaultSourceIconUrl:a=O})=>{const{appSettings:c}=T();if(r==="growth")return s.jsxs(ds,{children:[s.jsx(ms,{children:s.jsxs(L,{children:[s.jsx(f,{className:"min-w-[320px]",variant:o==="table"?"default":"cardhead",children:t}),s.jsx(f,{className:"w-[110px] text-right",children:"Free members"}),c?.paidMembersEnabled&&s.jsxs(s.Fragment,{children:[s.jsx(f,{className:"w-[110px] text-right",children:"Paid members"}),s.jsx(f,{className:"w-[100px] text-right",children:"MRR impact"})]})]})}),s.jsx(hs,{children:h?.map(e=>{const l=d=>Math.round(d/100);return s.jsxs(L,{className:"last:border-none",children:[s.jsx(y,{children:e.linkUrl?s.jsxs("a",{className:"group flex items-center gap-2",href:e.linkUrl,rel:"noreferrer",target:"_blank",children:[s.jsx(E,{defaultSourceIconUrl:a,displayName:e.displayName,iconSrc:e.iconSrc}),s.jsx("span",{className:"group-hover:underline",children:e.displayName})]}):s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(E,{defaultSourceIconUrl:a,displayName:e.displayName,iconSrc:e.iconSrc}),s.jsx("span",{children:e.displayName})]})}),s.jsxs(y,{className:"text-right font-mono text-sm",children:["+",b(e.free_members||0)]}),c?.paidMembersEnabled&&s.jsxs(s.Fragment,{children:[s.jsxs(y,{className:"text-right font-mono text-sm",children:["+",b(e.paid_members||0)]}),s.jsxs(y,{className:"text-right font-mono text-sm",children:["+$",b(l(e.mrr||0))]})]})]},e.source)})})]})},ys=({title:o="Top sources",description:t,data:h,mode:r="visits",range:a=30,totalVisitors:c=0,siteUrl:e,siteIcon:l,defaultSourceIconUrl:d=O,getPeriodText:i,className:p})=>{const{appSettings:x}=T(),n=_.useMemo(()=>cs({data:h,mode:r,siteUrl:e,siteIcon:l,defaultSourceIconUrl:d}),[h,e,l,r,d]),m=_.useMemo(()=>is({processedData:n,totalVisitors:c,mode:r}),[n,c,r]),u=m.slice(0,10),j=t||(r==="growth"?"Where did your growth come from?":`How readers found your ${a?"site":"post"}${a&&i?` ${i(a)}`:""}`),B=r==="growth"?"Sources":"Top sources",z=r==="growth"?"Where did your growth come from?":`How readers found your ${a?"site":"post"}${a&&i?` ${i(a)}`:""}`;return s.jsxs(N,{className:I("group/datalist w-full max-w-[calc(100vw-64px)] overflow-x-auto sidebar:max-w-[calc(100vw-64px-280px)]",p),"data-testid":"top-sources-card",children:[u.length<=0&&s.jsxs(C,{children:[s.jsx(S,{children:o}),s.jsx(v,{children:j})]}),s.jsx(w,{children:r==="growth"&&!x?.analytics.membersTrackSources?s.jsx(fs,{className:"py-10"}):u.length>0?s.jsx(W,{data:u,defaultSourceIconUrl:d,getPeriodText:i,headerStyle:"card",mode:r,range:a,children:s.jsxs(C,{children:[s.jsx(S,{children:o}),s.jsx(v,{children:j})]})}):s.jsx("div",{className:"py-20 text-center text-sm text-gray-700",children:s.jsx(G,{className:"h-full",description:r==="growth"&&"Once someone signs up on this post, sources will show here",title:`No sources data available ${i?i(a):""}`,children:s.jsx(as,{strokeWidth:1.5})})})}),m.length>10&&s.jsx(ls,{children:s.jsxs(V,{children:[s.jsx(q,{asChild:!0,children:s.jsxs(F,{variant:"outline",children:["View all ",s.jsx(ts,{})]})}),s.jsxs(J,{className:"overflow-y-auto pt-0 sm:max-w-[600px]",children:[s.jsxs(Q,{className:"sticky top-0 z-40 -mx-6 bg-background/60 p-6 backdrop-blur",children:[s.jsx(X,{children:B}),s.jsx(Y,{children:z})]}),s.jsx("div",{className:"group/datalist",children:s.jsx(W,{data:m,defaultSourceIconUrl:d,getPeriodText:i,mode:r,range:a})})]})]})})]})},Ns=o=>{const{data:t,isLoading:h}=js(o),{data:r,isLoading:a}=bs(o),{data:c,isLoading:e}=gs(),l=g.useMemo(()=>t?.stats||[],[t]),d=g.useMemo(()=>r?.stats.length===0?{free_members:0,paid_members:0,mrr:0}:r?.stats[0],[r]),{selectedCurrency:i,currencySymbol:p}=g.useMemo(()=>{if(c?.stats&&c?.meta?.totals){const n=c.meta.totals;let m=n[0];if(!m)return{selectedCurrency:"usd",currencySymbol:P("usd")};for(const j of n)j.mrr>m.mrr&&(m=j);const u=m.currency;return{selectedCurrency:u,currencySymbol:P(u)}}return{selectedCurrency:"usd",currencySymbol:P("usd")}},[c]);return{isLoading:g.useMemo(()=>h||a||e,[h,a,e]),stats:l,totals:d,selectedCurrency:i,currencySymbol:p}},K=o=>Math.round(o/100),ws=()=>{const{data:o}=us(),{postId:t}=Z(),{stats:h,totals:r,isLoading:a,currencySymbol:c}=Ns(t||""),{appSettings:e}=T(),l=U(),d=o?.url,i=o?.icon;let p="flex flex-col items-stretch gap-6",x="";return e?.paidMembersEnabled||(p="grid grid-cols-1 border rounded-md",x="border-none hover:shadow-none"),s.jsxs(s.Fragment,{children:[s.jsx(xs,{currentTab:"Growth"}),s.jsx(ps,{children:a?s.jsxs("div",{className:p,children:[s.jsx(N,{className:x,children:s.jsx(w,{className:"grid grid-cols-3 p-0",children:Array.from({length:3},(n,m)=>s.jsxs("div",{className:"h-[98px] gap-1 border-r px-6 py-5 last:border-r-0",children:[s.jsx(A,{className:"w-2/3"}),s.jsx(A,{className:"h-7 w-12"})]},m))})}),s.jsxs(N,{className:x,children:[s.jsxs(C,{children:[s.jsx(S,{children:"Top sources"}),s.jsx(v,{children:"Where did your growth come from?"})]}),s.jsxs(w,{children:[s.jsx(D,{}),s.jsx(ss,{className:"pt-6"})]})]})]}):s.jsxs("div",{className:p,children:[s.jsxs(N,{className:x,"data-testid":"members-card",children:[s.jsxs(C,{className:"hidden",children:[s.jsx(S,{children:"Newsletters"}),s.jsx(v,{children:"How did this post perform"})]}),s.jsx(w,{className:"p-0",children:s.jsxs("div",{className:`flex flex-col md:grid md:items-stretch ${e?.paidMembersEnabled?"md:grid-cols-3":"md:grid-cols-1"}`,children:[s.jsxs(M,{className:"grow",children:[s.jsx(H,{onClick:()=>{const n=encodeURIComponent(`signup:'${t}'+conversion:-'${t}'`);l(`/members?filterParam=${n}`,{crossApp:!0})},children:"View members →"}),s.jsxs(R,{onClick:()=>{const n=encodeURIComponent(`signup:'${t}'+conversion:-'${t}'`);l(`/members?filterParam=${n}`,{crossApp:!0})},children:[s.jsx(es,{strokeWidth:1.5}),"Free members"]}),s.jsx($,{children:s.jsx(k,{children:b(r?.free_members||0)})})]}),e?.paidMembersEnabled&&s.jsxs(s.Fragment,{children:[s.jsxs(M,{className:"grow",children:[s.jsx(H,{onClick:()=>{const n=encodeURIComponent(`conversion:'${t}'`);l(`/members?filterParam=${n}`,{crossApp:!0})},children:"View members →"}),s.jsxs(R,{onClick:()=>{const n=encodeURIComponent(`conversion:'${t}'`);l(`/members?filterParam=${n}`,{crossApp:!0})},children:[s.jsx(ns,{strokeWidth:1.5}),"Paid members"]}),s.jsx($,{children:s.jsx(k,{children:b(r?.paid_members||0)})})]}),s.jsxs(M,{className:"grow",children:[s.jsxs(R,{children:[s.jsx(os,{strokeWidth:1.5}),"MRR"]}),s.jsx($,{children:s.jsxs(k,{children:["+",c,K(r?.mrr||0)]})})]})]})]})})]}),!e?.paidMembersEnabled&&s.jsx(D,{}),s.jsx(ys,{className:x,data:h,mode:"growth",siteIcon:i,siteUrl:d})]})})]})},Es=Object.freeze(Object.defineProperty({__proto__:null,centsToDollars:K,default:ws},Symbol.toStringTag,{value:"Module"}));export{fs as D,K as c,Es as g,Ns as u};
@@ -1,4 +1,4 @@
1
- import{aA as e}from"./index-DCTdAEHx.js";/**
1
+ import{aA as e}from"./index-Bgo4hw-T.js";/**
2
2
  * @license lucide-react v0.553.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{aA as o}from"./index-DCTdAEHx.js";/**
1
+ import{aA as o}from"./index-Bgo4hw-T.js";/**
2
2
  * @license lucide-react v0.553.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +1 @@
1
- import{r as c}from"./index-DCTdAEHx.js";const z=(n,t)=>n==null?t:t==null?n:Math.max(n,t),C=new WeakMap,ut={onUpdate(n,t,e){if(C.set(e,void 0),!e.computedTrend)return;const i=t.integer.concat(t.fraction).filter(o=>o.type==="integer"||o.type==="fraction"),s=n.integer.concat(n.fraction).filter(o=>o.type==="integer"||o.type==="fraction"),r=i.find(o=>!s.find(l=>l.pos===o.pos&&l.value===o.value)),a=s.find(o=>!i.find(l=>o.pos===l.pos&&o.value===l.value));C.set(e,z(r?.pos,a?.pos))},getDelta(n,t,e){const i=n-t,s=C.get(e.flow);if(!i&&s!=null&&s>=e.pos)return e.length*e.flow.computedTrend}},y=(n,t,e)=>{const i=document.createElement(n),[s,r]=Array.isArray(t)?[void 0,t]:[t,e];return s&&Object.assign(i,s),r?.forEach(a=>i.appendChild(a)),i},J=(n,t)=>{var e;return t==="left"?n.offsetLeft:(((e=n.offsetParent instanceof HTMLElement?n.offsetParent:null)==null?void 0:e.offsetWidth)??0)-n.offsetWidth-n.offsetLeft},G=n=>n.offsetWidth>0&&n.offsetHeight>0,Y=(n,t)=>{!customElements.get(n)&&customElements.define(n,t)};function Z(n,t,{reverse:e=!1}={}){const i=n.length;for(let s=e?i-1:0;e?s>=0:s<i;e?s--:s++)t(n[s],s)}function q(n,t,e,i){const s=t.formatToParts(n);e&&s.unshift({type:"prefix",value:e}),i&&s.push({type:"suffix",value:i});const r=[],a=[],o=[],l=[],u={},p=d=>`${d}:${u[d]=(u[d]??-1)+1}`;let f="",m=!1,g=!1;for(const d of s){f+=d.value;const h=d.type==="minusSign"||d.type==="plusSign"?"sign":d.type;h==="integer"?(m=!0,a.push(...d.value.split("").map(A=>({type:h,value:parseInt(A)})))):h==="group"?a.push({type:h,value:d.value}):h==="decimal"?(g=!0,o.push({type:h,value:d.value,key:p(h)})):h==="fraction"?o.push(...d.value.split("").map(A=>({type:h,value:parseInt(A),key:p(h),pos:-1-u[h]}))):(m||g?l:r).push({type:h,value:d.value,key:p(h)})}const M=[];for(let d=a.length-1;d>=0;d--){const h=a[d];M.unshift(h.type==="integer"?{...h,key:p(h.type),pos:u[h.type]}:{...h,key:p(h.type)})}return{pre:r,integer:M,fraction:o,post:l,valueAsString:f,value:typeof n=="string"?parseFloat(n):n}}const Q=String.raw,K=(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0})(),tt=typeof CSS<"u"&&CSS.supports&&CSS.supports("line-height","mod(1,1)"),w=typeof matchMedia<"u"?matchMedia("(prefers-reduced-motion: reduce)"):null,E="--_number-flow-d-opacity",U="--_number-flow-d-width",R="--_number-flow-dx",k="--_number-flow-d",et=(()=>{try{return CSS.registerProperty({name:E,syntax:"<number>",inherits:!1,initialValue:"0"}),CSS.registerProperty({name:R,syntax:"<length>",inherits:!0,initialValue:"0px"}),CSS.registerProperty({name:U,syntax:"<number>",inherits:!1,initialValue:"0"}),CSS.registerProperty({name:k,syntax:"<number>",inherits:!0,initialValue:"0"}),!0}catch{return!1}})(),it="var(--number-flow-char-height, 1em)",v="var(--number-flow-mask-height, 0.25em)",N=`calc(${v} / 2)`,$="var(--number-flow-mask-width, 0.5em)",_=`calc(${$} / var(--scale-x))`,b="#000 0, transparent 71%",P=Q`:host{display:inline-block;direction:ltr;white-space:nowrap;isolation:isolate;line-height:${it} !important}.number,.number__inner{display:inline-block;transform-origin:left top}:host([data-will-change]) :is(.number,.number__inner,.section,.digit,.digit__num,.symbol){will-change:transform}.number{--scale-x:calc(1 + var(${U}) / var(--width));transform:translateX(var(${R})) scaleX(var(--scale-x));margin:0 calc(-1 * ${$});position:relative;-webkit-mask-image:linear-gradient(to right,transparent 0,#000 ${_},#000 calc(100% - ${_}),transparent ),linear-gradient(to bottom,transparent 0,#000 ${v},#000 calc(100% - ${v}),transparent 100% ),radial-gradient(at bottom right,${b}),radial-gradient(at bottom left,${b}),radial-gradient(at top left,${b}),radial-gradient(at top right,${b});-webkit-mask-size:100% calc(100% - ${v} * 2),calc(100% - ${_} * 2) 100%,${_} ${v},${_} ${v},${_} ${v},${_} ${v};-webkit-mask-position:center,center,top left,top right,bottom right,bottom left;-webkit-mask-repeat:no-repeat}.number__inner{padding:${N} ${$};transform:scaleX(calc(1 / var(--scale-x))) translateX(calc(-1 * var(${R})))}:host > :not(.number){z-index:5}.section,.symbol{display:inline-block;position:relative;isolation:isolate}.section::after{content:'\200b';display:inline-block}.section--justify-left{transform-origin:center left}.section--justify-right{transform-origin:center right}.section > [inert],.symbol > [inert]{margin:0 !important;position:absolute !important;z-index:-1}.digit{display:inline-block;position:relative;--c:var(--current) + var(${k})}.digit__num,.number .section::after{padding:${N} 0}.digit__num{display:inline-block;--offset-raw:mod(var(--length) + var(--n) - mod(var(--c),var(--length)),var(--length));--offset:calc( var(--offset-raw) - var(--length) * round(down,var(--offset-raw) / (var(--length) / 2),1) );--y:clamp(-100%,var(--offset) * 100%,100%);transform:translateY(var(--y))}.digit__num[inert]{position:absolute;top:0;left:50%;transform:translateX(-50%) translateY(var(--y))}.digit:not(.is-spinning) .digit__num[inert]{display:none}.symbol__value{display:inline-block;mix-blend-mode:plus-lighter;white-space:pre}.section--justify-left .symbol > [inert]{left:0}.section--justify-right .symbol > [inert]{right:0}.animate-presence{opacity:calc(1 + var(${E}))}`,st=HTMLElement,B=tt&&K&&et;let S;class I extends st{constructor(){super(),this.created=!1,this.batched=!1;const{animated:t,...e}=this.constructor.defaultProps;this._animated=this.computedAnimated=t,Object.assign(this,e)}get animated(){return this._animated}set animated(t){var e;this.animated!==t&&(this._animated=t,(e=this.shadowRoot)==null||e.getAnimations().forEach(i=>i.finish()))}set data(t){var e;if(t==null)return;const{pre:i,integer:s,fraction:r,post:a,value:o}=t;if(this.created){const l=this._data;this._data=t,this.computedTrend=typeof this.trend=="function"?this.trend(l.value,o):this.trend,this.computedAnimated=B&&this._animated&&(!this.respectMotionPreference||!(w!=null&&w.matches))&&G(this),(e=this.plugins)==null||e.forEach(u=>{var p;return(p=u.onUpdate)==null?void 0:p.call(u,t,l,this)}),this.batched||this.willUpdate(),this._pre.update(i),this._num.update({integer:s,fraction:r}),this._post.update(a),this.batched||this.didUpdate()}else{this._data=t,this.attachShadow({mode:"open"});try{this._internals??(this._internals=this.attachInternals()),this._internals.role="img"}catch{}if(typeof CSSStyleSheet<"u"&&this.shadowRoot.adoptedStyleSheets)S||(S=new CSSStyleSheet,S.replaceSync(P)),this.shadowRoot.adoptedStyleSheets=[S];else{const l=document.createElement("style");l.textContent=P,this.shadowRoot.appendChild(l)}this._pre=new F(this,i,{justify:"right",part:"left"}),this.shadowRoot.appendChild(this._pre.el),this._num=new nt(this,s,r),this.shadowRoot.appendChild(this._num.el),this._post=new F(this,a,{justify:"left",part:"right"}),this.shadowRoot.appendChild(this._post.el),this.created=!0}try{this._internals.ariaLabel=t.valueAsString}catch{}}willUpdate(){this._pre.willUpdate(),this._num.willUpdate(),this._post.willUpdate()}didUpdate(){if(!this.computedAnimated)return;this._abortAnimationsFinish?this._abortAnimationsFinish.abort():this.dispatchEvent(new Event("animationsstart")),this._pre.didUpdate(),this._num.didUpdate(),this._post.didUpdate();const t=new AbortController;Promise.all(this.shadowRoot.getAnimations().map(e=>e.finished)).then(()=>{t.signal.aborted||(this.dispatchEvent(new Event("animationsfinish")),this._abortAnimationsFinish=void 0)}),this._abortAnimationsFinish=t}}I.defaultProps={transformTiming:{duration:900,easing:"linear(0,.005,.019,.039,.066,.096,.129,.165,.202,.24,.278,.316,.354,.39,.426,.461,.494,.526,.557,.586,.614,.64,.665,.689,.711,.731,.751,.769,.786,.802,.817,.831,.844,.856,.867,.877,.887,.896,.904,.912,.919,.925,.931,.937,.942,.947,.951,.955,.959,.962,.965,.968,.971,.973,.976,.978,.98,.981,.983,.984,.986,.987,.988,.989,.99,.991,.992,.992,.993,.994,.994,.995,.995,.996,.996,.9963,.9967,.9969,.9972,.9975,.9977,.9979,.9981,.9982,.9984,.9985,.9987,.9988,.9989,1)"},spinTiming:void 0,opacityTiming:{duration:450,easing:"ease-out"},animated:!0,trend:(n,t)=>Math.sign(t-n),respectMotionPreference:!0,plugins:void 0,digits:void 0};class nt{constructor(t,e,i,{className:s,...r}={}){this.flow=t,this._integer=new L(t,e,{justify:"right",part:"integer"}),this._fraction=new L(t,i,{justify:"left",part:"fraction"}),this._inner=y("span",{className:"number__inner"},[this._integer.el,this._fraction.el]),this.el=y("span",{...r,part:"number",className:`number ${s??""}`},[this._inner])}willUpdate(){this._prevWidth=this.el.offsetWidth,this._prevLeft=this.el.getBoundingClientRect().left,this._integer.willUpdate(),this._fraction.willUpdate()}update({integer:t,fraction:e}){this._integer.update(t),this._fraction.update(e)}didUpdate(){const t=this.el.getBoundingClientRect();this._integer.didUpdate(),this._fraction.didUpdate();const e=this._prevLeft-t.left,i=this.el.offsetWidth,s=this._prevWidth-i;this.el.style.setProperty("--width",String(i)),this.el.animate({[R]:[`${e}px`,"0px"],[U]:[s,0]},{...this.flow.transformTiming,composite:"accumulate"})}}class D{constructor(t,e,{justify:i,className:s,...r},a){this.flow=t,this.children=new Map,this.onCharRemove=l=>()=>{this.children.delete(l)},this.justify=i;const o=e.map(l=>this.addChar(l).el);this.el=y("span",{...r,className:`section section--justify-${i} ${s??""}`},a?a(o):o)}addChar(t,{startDigitsAtZero:e=!1,...i}={}){const s=t.type==="integer"||t.type==="fraction"?new X(this,t.type,e?0:t.value,t.pos,{...i,onRemove:this.onCharRemove(t.key)}):new at(this,t.type,t.value,{...i,onRemove:this.onCharRemove(t.key)});return this.children.set(t.key,s),s}unpop(t){t.el.removeAttribute("inert"),t.el.style.top="",t.el.style[this.justify]=""}pop(t){t.forEach(e=>{e.el.style.top=`${e.el.offsetTop}px`,e.el.style[this.justify]=`${J(e.el,this.justify)}px`}),t.forEach(e=>{e.el.setAttribute("inert",""),e.present=!1})}addNewAndUpdateExisting(t){const e=new Map,i=new Map,s=this.justify==="left",r=s?"prepend":"append";if(Z(t,a=>{let o;this.children.has(a.key)?(o=this.children.get(a.key),i.set(a,o),this.unpop(o),o.present=!0):(o=this.addChar(a,{startDigitsAtZero:!0,animateIn:!0}),e.set(a,o)),this.el[r](o.el)},{reverse:s}),this.flow.computedAnimated){const a=this.el.getBoundingClientRect();e.forEach(o=>{o.willUpdate(a)})}e.forEach((a,o)=>{a.update(o.value)}),i.forEach((a,o)=>{a.update(o.value)})}willUpdate(){const t=this.el.getBoundingClientRect();this._prevOffset=t[this.justify],this.children.forEach(e=>e.willUpdate(t))}didUpdate(){const t=this.el.getBoundingClientRect();this.children.forEach(s=>s.didUpdate(t));const e=t[this.justify],i=this._prevOffset-e;i&&this.children.size&&this.el.animate({transform:[`translateX(${i}px)`,"none"]},{...this.flow.transformTiming,composite:"accumulate"})}}class L extends D{update(t){const e=new Map;this.children.forEach((i,s)=>{t.find(r=>r.key===s)||e.set(s,i),this.unpop(i)}),this.addNewAndUpdateExisting(t),e.forEach(i=>{i instanceof X&&i.update(0)}),this.pop(e)}}class F extends D{update(t){const e=new Map;this.children.forEach((i,s)=>{t.find(r=>r.key===s)||e.set(s,i)}),this.pop(e),this.addNewAndUpdateExisting(t)}}class x{constructor(t,e,{onRemove:i,animateIn:s=!1}={}){this.flow=t,this.el=e,this._present=!0,this._remove=()=>{var r;this.el.remove(),(r=this._onRemove)==null||r.call(this)},this.el.classList.add("animate-presence"),this.flow.computedAnimated&&s&&this.el.animate({[E]:[-.9999,0]},{...this.flow.opacityTiming,composite:"accumulate"}),this._onRemove=i}get present(){return this._present}set present(t){if(this._present!==t){if(this._present=t,t?this.el.removeAttribute("inert"):this.el.setAttribute("inert",""),!this.flow.computedAnimated){t||this._remove();return}this.el.style.setProperty("--_number-flow-d-opacity",t?"0":"-.999"),this.el.animate({[E]:t?[-.9999,0]:[.999,0]},{...this.flow.opacityTiming,composite:"accumulate"}),t?this.flow.removeEventListener("animationsfinish",this._remove):this.flow.addEventListener("animationsfinish",this._remove,{once:!0})}}}class W extends x{constructor(t,e,i,s){super(t.flow,i,s),this.section=t,this.value=e,this.el=i}}class X extends W{constructor(t,e,i,s,r){var a,o;const l=(((o=(a=t.flow.digits)==null?void 0:a[s])==null?void 0:o.max)??9)+1,u=Array.from({length:l}).map((f,m)=>{const g=y("span",{className:"digit__num"},[document.createTextNode(String(m))]);return m!==i&&g.setAttribute("inert",""),g.style.setProperty("--n",String(m)),g}),p=y("span",{part:`digit ${e}-digit`,className:"digit"},u);p.style.setProperty("--current",String(i)),p.style.setProperty("--length",String(l)),super(t,i,p,r),this.pos=s,this._onAnimationsFinish=()=>{this.el.classList.remove("is-spinning")},this._numbers=u,this.length=l}willUpdate(t){const e=this.el.getBoundingClientRect();this._prevValue=this.value;const i=e[this.section.justify]-t[this.section.justify],s=e.width/2;this._prevCenter=this.section.justify==="left"?i+s:i-s}update(t){this.el.style.setProperty("--current",String(t)),this._numbers.forEach((e,i)=>i===t?e.removeAttribute("inert"):e.setAttribute("inert","")),this.value=t}didUpdate(t){const e=this.el.getBoundingClientRect(),i=e[this.section.justify]-t[this.section.justify],s=e.width/2,r=this.section.justify==="left"?i+s:i-s,a=this._prevCenter-r;a&&this.el.animate({transform:[`translateX(${a}px)`,"none"]},{...this.flow.transformTiming,composite:"accumulate"});const o=this.getDelta();o&&(this.el.classList.add("is-spinning"),this.el.animate({[k]:[-o,0]},{...this.flow.spinTiming??this.flow.transformTiming,composite:"accumulate"}),this.flow.addEventListener("animationsfinish",this._onAnimationsFinish,{once:!0}))}getDelta(){var t;if(this.flow.plugins)for(const s of this.flow.plugins){const r=(t=s.getDelta)==null?void 0:t.call(s,this.value,this._prevValue,this);if(r!=null)return r}const e=this.value-this._prevValue,i=this.flow.computedTrend||Math.sign(e);return i<0&&this.value>this._prevValue?this.value-this.length-this._prevValue:i>0&&this.value<this._prevValue?this.length-this._prevValue+this.value:e}}class at extends W{constructor(t,e,i,s){const r=y("span",{className:"symbol__value",textContent:i});super(t,i,y("span",{part:`symbol ${e}`,className:"symbol"},[r]),s),this.type=e,this._children=new Map,this._onChildRemove=a=>()=>{this._children.delete(a)},this._children.set(i,new x(this.flow,r,{onRemove:this._onChildRemove(i)}))}willUpdate(t){if(this.type==="decimal")return;const e=this.el.getBoundingClientRect();this._prevOffset=e[this.section.justify]-t[this.section.justify]}update(t){if(this.value!==t){const e=this._children.get(this.value);e&&(e.present=!1);const i=this._children.get(t);if(i)i.present=!0;else{const s=y("span",{className:"symbol__value",textContent:t});this.el.appendChild(s),this._children.set(t,new x(this.flow,s,{animateIn:!0,onRemove:this._onChildRemove(t)}))}}this.value=t}didUpdate(t){if(this.type==="decimal")return;const e=this.el.getBoundingClientRect()[this.section.justify]-t[this.section.justify],i=this._prevOffset-e;i&&this.el.animate({transform:[`translateX(${i}px)`,"none"]},{...this.flow.transformTiming,composite:"accumulate"})}}const rt=parseInt(c.version.match(/^(\d+)\./)?.[1]),j=rt>=19,ot=["data","digits"];class T extends I{attributeChangedCallback(t,e,i){this[t]=JSON.parse(i)}}T.observedAttributes=j?[]:ot;Y("number-flow-react",T);const lt={},O=j?n=>n:JSON.stringify;function V(n){const{transformTiming:t,spinTiming:e,opacityTiming:i,animated:s,respectMotionPreference:r,trend:a,plugins:o,...l}=n;return[{transformTiming:t,spinTiming:e,opacityTiming:i,animated:s,respectMotionPreference:r,trend:a,plugins:o},l]}class ht extends c.Component{updateProperties(t){if(!this.el)return;this.el.batched=!this.props.isolate;const[e]=V(this.props);Object.entries(e).forEach(([i,s])=>{this.el[i]=s??T.defaultProps[i]}),t?.onAnimationsStart&&this.el.removeEventListener("animationsstart",t.onAnimationsStart),this.props.onAnimationsStart&&this.el.addEventListener("animationsstart",this.props.onAnimationsStart),t?.onAnimationsFinish&&this.el.removeEventListener("animationsfinish",t.onAnimationsFinish),this.props.onAnimationsFinish&&this.el.addEventListener("animationsfinish",this.props.onAnimationsFinish)}componentDidMount(){this.updateProperties(),j&&this.el&&(this.el.digits=this.props.digits,this.el.data=this.props.data)}getSnapshotBeforeUpdate(t){if(this.updateProperties(t),t.data!==this.props.data){if(this.props.group)return this.props.group.willUpdate(),()=>this.props.group?.didUpdate();if(!this.props.isolate)return this.el?.willUpdate(),()=>this.el?.didUpdate()}return null}componentDidUpdate(t,e,i){i?.()}handleRef(t){this.props.innerRef&&(this.props.innerRef.current=t),this.el=t}render(){const[t,{innerRef:e,className:i,data:s,willChange:r,isolate:a,group:o,digits:l,onAnimationsStart:u,onAnimationsFinish:p,...f}]=V(this.props);return c.createElement("number-flow-react",{ref:this.handleRef,"data-will-change":r?"":void 0,class:i,...f,dangerouslySetInnerHTML:{__html:""},suppressHydrationWarning:!0,digits:O(l),data:O(s)})}constructor(t){super(t),this.handleRef=this.handleRef.bind(this)}}const ft=c.forwardRef(function({value:t,locales:e,format:i,prefix:s,suffix:r,...a},o){c.useImperativeHandle(o,()=>l.current,[]);const l=c.useRef(),u=c.useContext(H);u?.useRegister(l);const p=c.useMemo(()=>e?JSON.stringify(e):"",[e]),f=c.useMemo(()=>i?JSON.stringify(i):"",[i]),m=c.useMemo(()=>{const g=lt[`${p}:${f}`]??=new Intl.NumberFormat(e,i);return q(t,g,s,r)},[t,p,f,s,r]);return c.createElement(ht,{...a,group:u,data:m,innerRef:l})}),H=c.createContext(void 0);function mt({children:n}){const t=c.useRef(new Set),e=c.useRef(!1),i=c.useRef(new WeakMap),s=c.useMemo(()=>({useRegister(r){c.useEffect(()=>(t.current.add(r),()=>{t.current.delete(r)}),[])},willUpdate(){e.current||(e.current=!0,t.current.forEach(r=>{const a=r.current;!a||!a.created||(a.willUpdate(),i.current.set(a,!0))}))},didUpdate(){t.current.forEach(r=>{const a=r.current;!a||!i.current.get(a)||(a.didUpdate(),i.current.delete(a))}),e.current=!1}}),[]);return c.createElement(H.Provider,{value:s},n)}const ct=()=>c.useSyncExternalStore(()=>()=>{},()=>B,()=>!1),dt=()=>c.useSyncExternalStore(n=>(w?.addEventListener("change",n),()=>w?.removeEventListener("change",n)),()=>w.matches,()=>!1);function gt({respectMotionPreference:n=!0}={}){const t=ct(),e=dt();return t&&(!n||!e)}export{T as NumberFlowElement,mt as NumberFlowGroup,ut as continuous,ft as default,gt as useCanAnimate,ct as useIsSupported,dt as usePrefersReducedMotion};
1
+ import{r as c}from"./index-Bgo4hw-T.js";const z=(n,t)=>n==null?t:t==null?n:Math.max(n,t),C=new WeakMap,ut={onUpdate(n,t,e){if(C.set(e,void 0),!e.computedTrend)return;const i=t.integer.concat(t.fraction).filter(o=>o.type==="integer"||o.type==="fraction"),s=n.integer.concat(n.fraction).filter(o=>o.type==="integer"||o.type==="fraction"),r=i.find(o=>!s.find(l=>l.pos===o.pos&&l.value===o.value)),a=s.find(o=>!i.find(l=>o.pos===l.pos&&o.value===l.value));C.set(e,z(r?.pos,a?.pos))},getDelta(n,t,e){const i=n-t,s=C.get(e.flow);if(!i&&s!=null&&s>=e.pos)return e.length*e.flow.computedTrend}},y=(n,t,e)=>{const i=document.createElement(n),[s,r]=Array.isArray(t)?[void 0,t]:[t,e];return s&&Object.assign(i,s),r?.forEach(a=>i.appendChild(a)),i},J=(n,t)=>{var e;return t==="left"?n.offsetLeft:(((e=n.offsetParent instanceof HTMLElement?n.offsetParent:null)==null?void 0:e.offsetWidth)??0)-n.offsetWidth-n.offsetLeft},G=n=>n.offsetWidth>0&&n.offsetHeight>0,Y=(n,t)=>{!customElements.get(n)&&customElements.define(n,t)};function Z(n,t,{reverse:e=!1}={}){const i=n.length;for(let s=e?i-1:0;e?s>=0:s<i;e?s--:s++)t(n[s],s)}function q(n,t,e,i){const s=t.formatToParts(n);e&&s.unshift({type:"prefix",value:e}),i&&s.push({type:"suffix",value:i});const r=[],a=[],o=[],l=[],u={},p=d=>`${d}:${u[d]=(u[d]??-1)+1}`;let f="",m=!1,g=!1;for(const d of s){f+=d.value;const h=d.type==="minusSign"||d.type==="plusSign"?"sign":d.type;h==="integer"?(m=!0,a.push(...d.value.split("").map(A=>({type:h,value:parseInt(A)})))):h==="group"?a.push({type:h,value:d.value}):h==="decimal"?(g=!0,o.push({type:h,value:d.value,key:p(h)})):h==="fraction"?o.push(...d.value.split("").map(A=>({type:h,value:parseInt(A),key:p(h),pos:-1-u[h]}))):(m||g?l:r).push({type:h,value:d.value,key:p(h)})}const M=[];for(let d=a.length-1;d>=0;d--){const h=a[d];M.unshift(h.type==="integer"?{...h,key:p(h.type),pos:u[h.type]}:{...h,key:p(h.type)})}return{pre:r,integer:M,fraction:o,post:l,valueAsString:f,value:typeof n=="string"?parseFloat(n):n}}const Q=String.raw,K=(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0})(),tt=typeof CSS<"u"&&CSS.supports&&CSS.supports("line-height","mod(1,1)"),w=typeof matchMedia<"u"?matchMedia("(prefers-reduced-motion: reduce)"):null,E="--_number-flow-d-opacity",U="--_number-flow-d-width",R="--_number-flow-dx",k="--_number-flow-d",et=(()=>{try{return CSS.registerProperty({name:E,syntax:"<number>",inherits:!1,initialValue:"0"}),CSS.registerProperty({name:R,syntax:"<length>",inherits:!0,initialValue:"0px"}),CSS.registerProperty({name:U,syntax:"<number>",inherits:!1,initialValue:"0"}),CSS.registerProperty({name:k,syntax:"<number>",inherits:!0,initialValue:"0"}),!0}catch{return!1}})(),it="var(--number-flow-char-height, 1em)",v="var(--number-flow-mask-height, 0.25em)",N=`calc(${v} / 2)`,$="var(--number-flow-mask-width, 0.5em)",_=`calc(${$} / var(--scale-x))`,b="#000 0, transparent 71%",P=Q`:host{display:inline-block;direction:ltr;white-space:nowrap;isolation:isolate;line-height:${it} !important}.number,.number__inner{display:inline-block;transform-origin:left top}:host([data-will-change]) :is(.number,.number__inner,.section,.digit,.digit__num,.symbol){will-change:transform}.number{--scale-x:calc(1 + var(${U}) / var(--width));transform:translateX(var(${R})) scaleX(var(--scale-x));margin:0 calc(-1 * ${$});position:relative;-webkit-mask-image:linear-gradient(to right,transparent 0,#000 ${_},#000 calc(100% - ${_}),transparent ),linear-gradient(to bottom,transparent 0,#000 ${v},#000 calc(100% - ${v}),transparent 100% ),radial-gradient(at bottom right,${b}),radial-gradient(at bottom left,${b}),radial-gradient(at top left,${b}),radial-gradient(at top right,${b});-webkit-mask-size:100% calc(100% - ${v} * 2),calc(100% - ${_} * 2) 100%,${_} ${v},${_} ${v},${_} ${v},${_} ${v};-webkit-mask-position:center,center,top left,top right,bottom right,bottom left;-webkit-mask-repeat:no-repeat}.number__inner{padding:${N} ${$};transform:scaleX(calc(1 / var(--scale-x))) translateX(calc(-1 * var(${R})))}:host > :not(.number){z-index:5}.section,.symbol{display:inline-block;position:relative;isolation:isolate}.section::after{content:'\200b';display:inline-block}.section--justify-left{transform-origin:center left}.section--justify-right{transform-origin:center right}.section > [inert],.symbol > [inert]{margin:0 !important;position:absolute !important;z-index:-1}.digit{display:inline-block;position:relative;--c:var(--current) + var(${k})}.digit__num,.number .section::after{padding:${N} 0}.digit__num{display:inline-block;--offset-raw:mod(var(--length) + var(--n) - mod(var(--c),var(--length)),var(--length));--offset:calc( var(--offset-raw) - var(--length) * round(down,var(--offset-raw) / (var(--length) / 2),1) );--y:clamp(-100%,var(--offset) * 100%,100%);transform:translateY(var(--y))}.digit__num[inert]{position:absolute;top:0;left:50%;transform:translateX(-50%) translateY(var(--y))}.digit:not(.is-spinning) .digit__num[inert]{display:none}.symbol__value{display:inline-block;mix-blend-mode:plus-lighter;white-space:pre}.section--justify-left .symbol > [inert]{left:0}.section--justify-right .symbol > [inert]{right:0}.animate-presence{opacity:calc(1 + var(${E}))}`,st=HTMLElement,B=tt&&K&&et;let S;class I extends st{constructor(){super(),this.created=!1,this.batched=!1;const{animated:t,...e}=this.constructor.defaultProps;this._animated=this.computedAnimated=t,Object.assign(this,e)}get animated(){return this._animated}set animated(t){var e;this.animated!==t&&(this._animated=t,(e=this.shadowRoot)==null||e.getAnimations().forEach(i=>i.finish()))}set data(t){var e;if(t==null)return;const{pre:i,integer:s,fraction:r,post:a,value:o}=t;if(this.created){const l=this._data;this._data=t,this.computedTrend=typeof this.trend=="function"?this.trend(l.value,o):this.trend,this.computedAnimated=B&&this._animated&&(!this.respectMotionPreference||!(w!=null&&w.matches))&&G(this),(e=this.plugins)==null||e.forEach(u=>{var p;return(p=u.onUpdate)==null?void 0:p.call(u,t,l,this)}),this.batched||this.willUpdate(),this._pre.update(i),this._num.update({integer:s,fraction:r}),this._post.update(a),this.batched||this.didUpdate()}else{this._data=t,this.attachShadow({mode:"open"});try{this._internals??(this._internals=this.attachInternals()),this._internals.role="img"}catch{}if(typeof CSSStyleSheet<"u"&&this.shadowRoot.adoptedStyleSheets)S||(S=new CSSStyleSheet,S.replaceSync(P)),this.shadowRoot.adoptedStyleSheets=[S];else{const l=document.createElement("style");l.textContent=P,this.shadowRoot.appendChild(l)}this._pre=new F(this,i,{justify:"right",part:"left"}),this.shadowRoot.appendChild(this._pre.el),this._num=new nt(this,s,r),this.shadowRoot.appendChild(this._num.el),this._post=new F(this,a,{justify:"left",part:"right"}),this.shadowRoot.appendChild(this._post.el),this.created=!0}try{this._internals.ariaLabel=t.valueAsString}catch{}}willUpdate(){this._pre.willUpdate(),this._num.willUpdate(),this._post.willUpdate()}didUpdate(){if(!this.computedAnimated)return;this._abortAnimationsFinish?this._abortAnimationsFinish.abort():this.dispatchEvent(new Event("animationsstart")),this._pre.didUpdate(),this._num.didUpdate(),this._post.didUpdate();const t=new AbortController;Promise.all(this.shadowRoot.getAnimations().map(e=>e.finished)).then(()=>{t.signal.aborted||(this.dispatchEvent(new Event("animationsfinish")),this._abortAnimationsFinish=void 0)}),this._abortAnimationsFinish=t}}I.defaultProps={transformTiming:{duration:900,easing:"linear(0,.005,.019,.039,.066,.096,.129,.165,.202,.24,.278,.316,.354,.39,.426,.461,.494,.526,.557,.586,.614,.64,.665,.689,.711,.731,.751,.769,.786,.802,.817,.831,.844,.856,.867,.877,.887,.896,.904,.912,.919,.925,.931,.937,.942,.947,.951,.955,.959,.962,.965,.968,.971,.973,.976,.978,.98,.981,.983,.984,.986,.987,.988,.989,.99,.991,.992,.992,.993,.994,.994,.995,.995,.996,.996,.9963,.9967,.9969,.9972,.9975,.9977,.9979,.9981,.9982,.9984,.9985,.9987,.9988,.9989,1)"},spinTiming:void 0,opacityTiming:{duration:450,easing:"ease-out"},animated:!0,trend:(n,t)=>Math.sign(t-n),respectMotionPreference:!0,plugins:void 0,digits:void 0};class nt{constructor(t,e,i,{className:s,...r}={}){this.flow=t,this._integer=new L(t,e,{justify:"right",part:"integer"}),this._fraction=new L(t,i,{justify:"left",part:"fraction"}),this._inner=y("span",{className:"number__inner"},[this._integer.el,this._fraction.el]),this.el=y("span",{...r,part:"number",className:`number ${s??""}`},[this._inner])}willUpdate(){this._prevWidth=this.el.offsetWidth,this._prevLeft=this.el.getBoundingClientRect().left,this._integer.willUpdate(),this._fraction.willUpdate()}update({integer:t,fraction:e}){this._integer.update(t),this._fraction.update(e)}didUpdate(){const t=this.el.getBoundingClientRect();this._integer.didUpdate(),this._fraction.didUpdate();const e=this._prevLeft-t.left,i=this.el.offsetWidth,s=this._prevWidth-i;this.el.style.setProperty("--width",String(i)),this.el.animate({[R]:[`${e}px`,"0px"],[U]:[s,0]},{...this.flow.transformTiming,composite:"accumulate"})}}class D{constructor(t,e,{justify:i,className:s,...r},a){this.flow=t,this.children=new Map,this.onCharRemove=l=>()=>{this.children.delete(l)},this.justify=i;const o=e.map(l=>this.addChar(l).el);this.el=y("span",{...r,className:`section section--justify-${i} ${s??""}`},a?a(o):o)}addChar(t,{startDigitsAtZero:e=!1,...i}={}){const s=t.type==="integer"||t.type==="fraction"?new X(this,t.type,e?0:t.value,t.pos,{...i,onRemove:this.onCharRemove(t.key)}):new at(this,t.type,t.value,{...i,onRemove:this.onCharRemove(t.key)});return this.children.set(t.key,s),s}unpop(t){t.el.removeAttribute("inert"),t.el.style.top="",t.el.style[this.justify]=""}pop(t){t.forEach(e=>{e.el.style.top=`${e.el.offsetTop}px`,e.el.style[this.justify]=`${J(e.el,this.justify)}px`}),t.forEach(e=>{e.el.setAttribute("inert",""),e.present=!1})}addNewAndUpdateExisting(t){const e=new Map,i=new Map,s=this.justify==="left",r=s?"prepend":"append";if(Z(t,a=>{let o;this.children.has(a.key)?(o=this.children.get(a.key),i.set(a,o),this.unpop(o),o.present=!0):(o=this.addChar(a,{startDigitsAtZero:!0,animateIn:!0}),e.set(a,o)),this.el[r](o.el)},{reverse:s}),this.flow.computedAnimated){const a=this.el.getBoundingClientRect();e.forEach(o=>{o.willUpdate(a)})}e.forEach((a,o)=>{a.update(o.value)}),i.forEach((a,o)=>{a.update(o.value)})}willUpdate(){const t=this.el.getBoundingClientRect();this._prevOffset=t[this.justify],this.children.forEach(e=>e.willUpdate(t))}didUpdate(){const t=this.el.getBoundingClientRect();this.children.forEach(s=>s.didUpdate(t));const e=t[this.justify],i=this._prevOffset-e;i&&this.children.size&&this.el.animate({transform:[`translateX(${i}px)`,"none"]},{...this.flow.transformTiming,composite:"accumulate"})}}class L extends D{update(t){const e=new Map;this.children.forEach((i,s)=>{t.find(r=>r.key===s)||e.set(s,i),this.unpop(i)}),this.addNewAndUpdateExisting(t),e.forEach(i=>{i instanceof X&&i.update(0)}),this.pop(e)}}class F extends D{update(t){const e=new Map;this.children.forEach((i,s)=>{t.find(r=>r.key===s)||e.set(s,i)}),this.pop(e),this.addNewAndUpdateExisting(t)}}class x{constructor(t,e,{onRemove:i,animateIn:s=!1}={}){this.flow=t,this.el=e,this._present=!0,this._remove=()=>{var r;this.el.remove(),(r=this._onRemove)==null||r.call(this)},this.el.classList.add("animate-presence"),this.flow.computedAnimated&&s&&this.el.animate({[E]:[-.9999,0]},{...this.flow.opacityTiming,composite:"accumulate"}),this._onRemove=i}get present(){return this._present}set present(t){if(this._present!==t){if(this._present=t,t?this.el.removeAttribute("inert"):this.el.setAttribute("inert",""),!this.flow.computedAnimated){t||this._remove();return}this.el.style.setProperty("--_number-flow-d-opacity",t?"0":"-.999"),this.el.animate({[E]:t?[-.9999,0]:[.999,0]},{...this.flow.opacityTiming,composite:"accumulate"}),t?this.flow.removeEventListener("animationsfinish",this._remove):this.flow.addEventListener("animationsfinish",this._remove,{once:!0})}}}class W extends x{constructor(t,e,i,s){super(t.flow,i,s),this.section=t,this.value=e,this.el=i}}class X extends W{constructor(t,e,i,s,r){var a,o;const l=(((o=(a=t.flow.digits)==null?void 0:a[s])==null?void 0:o.max)??9)+1,u=Array.from({length:l}).map((f,m)=>{const g=y("span",{className:"digit__num"},[document.createTextNode(String(m))]);return m!==i&&g.setAttribute("inert",""),g.style.setProperty("--n",String(m)),g}),p=y("span",{part:`digit ${e}-digit`,className:"digit"},u);p.style.setProperty("--current",String(i)),p.style.setProperty("--length",String(l)),super(t,i,p,r),this.pos=s,this._onAnimationsFinish=()=>{this.el.classList.remove("is-spinning")},this._numbers=u,this.length=l}willUpdate(t){const e=this.el.getBoundingClientRect();this._prevValue=this.value;const i=e[this.section.justify]-t[this.section.justify],s=e.width/2;this._prevCenter=this.section.justify==="left"?i+s:i-s}update(t){this.el.style.setProperty("--current",String(t)),this._numbers.forEach((e,i)=>i===t?e.removeAttribute("inert"):e.setAttribute("inert","")),this.value=t}didUpdate(t){const e=this.el.getBoundingClientRect(),i=e[this.section.justify]-t[this.section.justify],s=e.width/2,r=this.section.justify==="left"?i+s:i-s,a=this._prevCenter-r;a&&this.el.animate({transform:[`translateX(${a}px)`,"none"]},{...this.flow.transformTiming,composite:"accumulate"});const o=this.getDelta();o&&(this.el.classList.add("is-spinning"),this.el.animate({[k]:[-o,0]},{...this.flow.spinTiming??this.flow.transformTiming,composite:"accumulate"}),this.flow.addEventListener("animationsfinish",this._onAnimationsFinish,{once:!0}))}getDelta(){var t;if(this.flow.plugins)for(const s of this.flow.plugins){const r=(t=s.getDelta)==null?void 0:t.call(s,this.value,this._prevValue,this);if(r!=null)return r}const e=this.value-this._prevValue,i=this.flow.computedTrend||Math.sign(e);return i<0&&this.value>this._prevValue?this.value-this.length-this._prevValue:i>0&&this.value<this._prevValue?this.length-this._prevValue+this.value:e}}class at extends W{constructor(t,e,i,s){const r=y("span",{className:"symbol__value",textContent:i});super(t,i,y("span",{part:`symbol ${e}`,className:"symbol"},[r]),s),this.type=e,this._children=new Map,this._onChildRemove=a=>()=>{this._children.delete(a)},this._children.set(i,new x(this.flow,r,{onRemove:this._onChildRemove(i)}))}willUpdate(t){if(this.type==="decimal")return;const e=this.el.getBoundingClientRect();this._prevOffset=e[this.section.justify]-t[this.section.justify]}update(t){if(this.value!==t){const e=this._children.get(this.value);e&&(e.present=!1);const i=this._children.get(t);if(i)i.present=!0;else{const s=y("span",{className:"symbol__value",textContent:t});this.el.appendChild(s),this._children.set(t,new x(this.flow,s,{animateIn:!0,onRemove:this._onChildRemove(t)}))}}this.value=t}didUpdate(t){if(this.type==="decimal")return;const e=this.el.getBoundingClientRect()[this.section.justify]-t[this.section.justify],i=this._prevOffset-e;i&&this.el.animate({transform:[`translateX(${i}px)`,"none"]},{...this.flow.transformTiming,composite:"accumulate"})}}const rt=parseInt(c.version.match(/^(\d+)\./)?.[1]),j=rt>=19,ot=["data","digits"];class T extends I{attributeChangedCallback(t,e,i){this[t]=JSON.parse(i)}}T.observedAttributes=j?[]:ot;Y("number-flow-react",T);const lt={},O=j?n=>n:JSON.stringify;function V(n){const{transformTiming:t,spinTiming:e,opacityTiming:i,animated:s,respectMotionPreference:r,trend:a,plugins:o,...l}=n;return[{transformTiming:t,spinTiming:e,opacityTiming:i,animated:s,respectMotionPreference:r,trend:a,plugins:o},l]}class ht extends c.Component{updateProperties(t){if(!this.el)return;this.el.batched=!this.props.isolate;const[e]=V(this.props);Object.entries(e).forEach(([i,s])=>{this.el[i]=s??T.defaultProps[i]}),t?.onAnimationsStart&&this.el.removeEventListener("animationsstart",t.onAnimationsStart),this.props.onAnimationsStart&&this.el.addEventListener("animationsstart",this.props.onAnimationsStart),t?.onAnimationsFinish&&this.el.removeEventListener("animationsfinish",t.onAnimationsFinish),this.props.onAnimationsFinish&&this.el.addEventListener("animationsfinish",this.props.onAnimationsFinish)}componentDidMount(){this.updateProperties(),j&&this.el&&(this.el.digits=this.props.digits,this.el.data=this.props.data)}getSnapshotBeforeUpdate(t){if(this.updateProperties(t),t.data!==this.props.data){if(this.props.group)return this.props.group.willUpdate(),()=>this.props.group?.didUpdate();if(!this.props.isolate)return this.el?.willUpdate(),()=>this.el?.didUpdate()}return null}componentDidUpdate(t,e,i){i?.()}handleRef(t){this.props.innerRef&&(this.props.innerRef.current=t),this.el=t}render(){const[t,{innerRef:e,className:i,data:s,willChange:r,isolate:a,group:o,digits:l,onAnimationsStart:u,onAnimationsFinish:p,...f}]=V(this.props);return c.createElement("number-flow-react",{ref:this.handleRef,"data-will-change":r?"":void 0,class:i,...f,dangerouslySetInnerHTML:{__html:""},suppressHydrationWarning:!0,digits:O(l),data:O(s)})}constructor(t){super(t),this.handleRef=this.handleRef.bind(this)}}const ft=c.forwardRef(function({value:t,locales:e,format:i,prefix:s,suffix:r,...a},o){c.useImperativeHandle(o,()=>l.current,[]);const l=c.useRef(),u=c.useContext(H);u?.useRegister(l);const p=c.useMemo(()=>e?JSON.stringify(e):"",[e]),f=c.useMemo(()=>i?JSON.stringify(i):"",[i]),m=c.useMemo(()=>{const g=lt[`${p}:${f}`]??=new Intl.NumberFormat(e,i);return q(t,g,s,r)},[t,p,f,s,r]);return c.createElement(ht,{...a,group:u,data:m,innerRef:l})}),H=c.createContext(void 0);function mt({children:n}){const t=c.useRef(new Set),e=c.useRef(!1),i=c.useRef(new WeakMap),s=c.useMemo(()=>({useRegister(r){c.useEffect(()=>(t.current.add(r),()=>{t.current.delete(r)}),[])},willUpdate(){e.current||(e.current=!0,t.current.forEach(r=>{const a=r.current;!a||!a.created||(a.willUpdate(),i.current.set(a,!0))}))},didUpdate(){t.current.forEach(r=>{const a=r.current;!a||!i.current.get(a)||(a.didUpdate(),i.current.delete(a))}),e.current=!1}}),[]);return c.createElement(H.Provider,{value:s},n)}const ct=()=>c.useSyncExternalStore(()=>()=>{},()=>B,()=>!1),dt=()=>c.useSyncExternalStore(n=>(w?.addEventListener("change",n),()=>w?.removeEventListener("change",n)),()=>w.matches,()=>!1);function gt({respectMotionPreference:n=!0}={}){const t=ct(),e=dt();return t&&(!n||!e)}export{T as NumberFlowElement,mt as NumberFlowGroup,ut as continuous,ft as default,gt as useCanAnimate,ct as useIsSupported,dt as usePrefersReducedMotion};
@@ -1,3 +1,3 @@
1
- import{e as I,aH as ye,r as O,aP as De,j as e,B as Ce,bV as Te,bW as je,bD as Ke,aj as T,cA as J,aQ as rt,cB as $,bE as nt,ap as it,bF as ot,bG as de,cU as z,aR as lt,af as se,bS as ct,ag as W,S as Ge,cz as dt,bv as ut,bw as mt,bx as pt,by as ht,bz as ft,bA as xt,ah as B,bO as Pe}from"./index-DCTdAEHx.js";import{s as oe,g as U,d as bt,S as gt,a as vt,D as jt,b as yt}from"./stats-view-BJVawuIv.js";import{E as ce}from"./empty-indicator-C6BBh99D.js";import{A as St,a as At}from"./wallet-cards-ddLuIN-b.js";import{G as wt,C as Nt,X as Dt,Y as Ct}from"./gh-chart-D9KI0_sO.js";import{T as Ve,a as $e,K as ue,d as Y,e as Tt,b as me}from"./tabs-CBD0hW8V.js";import{a as _t,c as kt}from"./audience-Cy9gLIa9.js";import{S as te,B as Ot}from"./sort-button-DFr8vezl.js";import{S as Pt,C as Q,g as Mt,b as Rt}from"./content-helpers-BOnQQADZ.js";import{e as le,c as K,f as F,g as Et,a as Ye,b as ze,d as H}from"./table-2waWpIF5.js";import{g as Se}from"./currency-fEUUCkj0.js";import{g as Bt}from"./source-utils-B1S3ZHA2.js";import{a as It,b as Ft,u as Lt,k as Kt}from"./stats-lnFiOQZx.js";import{u as Gt,a as Vt}from"./tiers-CO-pz1FX.js";import{C as be,a as _e,b as ke,f as Oe,c as ge,j as $t}from"./pagemenu-Cd45frnF.js";import{h as ne,F as Yt,T as zt,b as he,r as Ae,H as ae,L as ie,o as X,c as Ht,S as Ut,A as Wt,I as qt,i as Me,d as Qt,J as Z,u as He,e as Xt,K as Jt,G as Zt,m as fe,l as ea,n as ta,M as aa,N as pe,O as Re,g as sa,s as ra,C as Ue,a as We,v as na,B as Ee}from"./chart--RFLGIL4.js";import{S as qe,a as Qe,b as Xe,c as Je,f as we}from"./select-WwMsbBbg.js";import{P as ia,a as oa}from"./PolarAngleAxis-CGprvq8M.js";import{n as la,o as ca,l as da}from"./lucide-react-DtMIZssr.js";import{u as ua}from"./use-growth-stats-BrLZI7da.js";import"./message-square-text-BDZtUW-2.js";import"./sprout-DRqlFJSK.js";import"./index-LyfDjTto.js";import"./_baseAssignValue-Bwn07Ln5.js";import"./a-large-small-p58xibEK.js";import"./at-sign-BZPuAx5m.js";import"./copy-Bi7VpgPR.js";import"./hash-DFhnGHId.js";import"./inbox-p-Y5uScT.js";import"./list-filter-3EF6cVg-.js";import"./minus-CSphShdJ.js";import"./tags-CKrBptuC.js";import"./square-CwHQ9sJ2.js";import"./user-round-check-zOuzV3OS.js";import"./repeat-Smml9n0k.js";import"./reply-CooY4lmk.js";import"./trash-CJY1Wro_.js";var xe;function re(s){"@babel/helpers - typeof";return re=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(a){return typeof a}:function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},re(s)}function ee(){return ee=Object.assign?Object.assign.bind():function(s){for(var a=1;a<arguments.length;a++){var n=arguments[a];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(s[t]=n[t])}return s},ee.apply(this,arguments)}function Be(s,a){var n=Object.keys(s);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(s);a&&(t=t.filter(function(r){return Object.getOwnPropertyDescriptor(s,r).enumerable})),n.push.apply(n,t)}return n}function R(s){for(var a=1;a<arguments.length;a++){var n=arguments[a]!=null?arguments[a]:{};a%2?Be(Object(n),!0).forEach(function(t){L(s,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(n)):Be(Object(n)).forEach(function(t){Object.defineProperty(s,t,Object.getOwnPropertyDescriptor(n,t))})}return s}function ma(s,a){if(!(s instanceof a))throw new TypeError("Cannot call a class as a function")}function Ie(s,a){for(var n=0;n<a.length;n++){var t=a[n];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(s,et(t.key),t)}}function pa(s,a,n){return a&&Ie(s.prototype,a),n&&Ie(s,n),Object.defineProperty(s,"prototype",{writable:!1}),s}function ha(s,a,n){return a=ve(a),fa(s,Ze()?Reflect.construct(a,n||[],ve(s).constructor):a.apply(s,n))}function fa(s,a){if(a&&(re(a)==="object"||typeof a=="function"))return a;if(a!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return xa(s)}function xa(s){if(s===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s}function Ze(){try{var s=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Ze=function(){return!!s})()}function ve(s){return ve=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},ve(s)}function ba(s,a){if(typeof a!="function"&&a!==null)throw new TypeError("Super expression must either be null or a function");s.prototype=Object.create(a&&a.prototype,{constructor:{value:s,writable:!0,configurable:!0}}),Object.defineProperty(s,"prototype",{writable:!1}),a&&Ne(s,a)}function Ne(s,a){return Ne=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},Ne(s,a)}function L(s,a,n){return a=et(a),a in s?Object.defineProperty(s,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):s[a]=n,s}function et(s){var a=ga(s,"string");return re(a)=="symbol"?a:a+""}function ga(s,a){if(re(s)!="object"||!s)return s;var n=s[Symbol.toPrimitive];if(n!==void 0){var t=n.call(s,a);if(re(t)!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(s)}var G=(function(s){function a(n){var t;return ma(this,a),t=ha(this,a,[n]),L(t,"pieRef",null),L(t,"sectorRefs",[]),L(t,"id",Jt("recharts-pie-")),L(t,"handleAnimationEnd",function(){var r=t.props.onAnimationEnd;t.setState({isAnimationFinished:!0}),ne(r)&&r()}),L(t,"handleAnimationStart",function(){var r=t.props.onAnimationStart;t.setState({isAnimationFinished:!1}),ne(r)&&r()}),t.state={isAnimationFinished:!n.isAnimationActive,prevIsAnimationActive:n.isAnimationActive,prevAnimationId:n.animationId,sectorToFocus:0},t}return ba(a,s),pa(a,[{key:"isActiveIndex",value:function(t){var r=this.props.activeIndex;return Array.isArray(r)?r.indexOf(t)!==-1:t===r}},{key:"hasActiveIndex",value:function(){var t=this.props.activeIndex;return Array.isArray(t)?t.length!==0:t||t===0}},{key:"renderLabels",value:function(t){var r=this.props.isAnimationActive;if(r&&!this.state.isAnimationFinished)return null;var l=this.props,i=l.label,f=l.labelLine,g=l.dataKey,c=l.valueKey,o=he(this.props,!1),j=he(i,!1),A=he(f,!1),x=i&&i.offsetRadius||20,w=t.map(function(m,b){var N=(m.startAngle+m.endAngle)/2,p=Ae(m.cx,m.cy,m.outerRadius+x,N),h=R(R(R(R({},o),m),{},{stroke:"none"},j),{},{index:b,textAnchor:a.getTextAnchor(p.x,m.cx)},p),u=R(R(R(R({},o),m),{},{fill:"none",stroke:m.fill},A),{},{index:b,points:[Ae(m.cx,m.cy,m.outerRadius,N),p]}),v=g;return ae(g)&&ae(c)?v="value":ae(g)&&(v=c),I.createElement(ie,{key:"label-".concat(m.startAngle,"-").concat(m.endAngle,"-").concat(m.midAngle,"-").concat(b)},f&&a.renderLabelLineItem(f,u,"line"),a.renderLabelItem(i,h,X(m,v)))});return I.createElement(ie,{className:"recharts-pie-labels"},w)}},{key:"renderSectorsStatically",value:function(t){var r=this,l=this.props,i=l.activeShape,f=l.blendStroke,g=l.inactiveShape;return t.map(function(c,o){if(c?.startAngle===0&&c?.endAngle===0&&t.length!==1)return null;var j=r.isActiveIndex(o),A=g&&r.hasActiveIndex()?g:null,x=j?i:A,w=R(R({},c),{},{stroke:f?c.fill:c.stroke,tabIndex:-1});return I.createElement(ie,ee({ref:function(b){b&&!r.sectorRefs.includes(b)&&r.sectorRefs.push(b)},tabIndex:-1,className:"recharts-pie-sector"},Ht(r.props,c,o),{key:"sector-".concat(c?.startAngle,"-").concat(c?.endAngle,"-").concat(c.midAngle,"-").concat(o)}),I.createElement(Ut,ee({option:x,isActive:j,shapeType:"sector"},w)))})}},{key:"renderSectorsWithAnimation",value:function(){var t=this,r=this.props,l=r.sectors,i=r.isAnimationActive,f=r.animationBegin,g=r.animationDuration,c=r.animationEasing,o=r.animationId,j=this.state,A=j.prevSectors,x=j.prevIsAnimationActive;return I.createElement(Wt,{begin:f,duration:g,isActive:i,easing:c,from:{t:0},to:{t:1},key:"pie-".concat(o,"-").concat(x),onAnimationStart:this.handleAnimationStart,onAnimationEnd:this.handleAnimationEnd},function(w){var m=w.t,b=[],N=l&&l[0],p=N.startAngle;return l.forEach(function(h,u){var v=A&&A[u],C=u>0?qt(h,"paddingAngle",0):0;if(v){var S=Me(v.endAngle-v.startAngle,h.endAngle-h.startAngle),d=R(R({},h),{},{startAngle:p+C,endAngle:p+S(m)+C});b.push(d),p=d.endAngle}else{var k=h.endAngle,y=h.startAngle,D=Me(0,k-y),P=D(m),M=R(R({},h),{},{startAngle:p+C,endAngle:p+P+C});b.push(M),p=M.endAngle}}),I.createElement(ie,null,t.renderSectorsStatically(b))})}},{key:"attachKeyboardHandlers",value:function(t){var r=this;t.onkeydown=function(l){if(!l.altKey)switch(l.key){case"ArrowLeft":{var i=++r.state.sectorToFocus%r.sectorRefs.length;r.sectorRefs[i].focus(),r.setState({sectorToFocus:i});break}case"ArrowRight":{var f=--r.state.sectorToFocus<0?r.sectorRefs.length-1:r.state.sectorToFocus%r.sectorRefs.length;r.sectorRefs[f].focus(),r.setState({sectorToFocus:f});break}case"Escape":{r.sectorRefs[r.state.sectorToFocus].blur(),r.setState({sectorToFocus:0});break}}}}},{key:"renderSectors",value:function(){var t=this.props,r=t.sectors,l=t.isAnimationActive,i=this.state.prevSectors;return l&&r&&r.length&&(!i||!Qt(i,r))?this.renderSectorsWithAnimation():this.renderSectorsStatically(r)}},{key:"componentDidMount",value:function(){this.pieRef&&this.attachKeyboardHandlers(this.pieRef)}},{key:"render",value:function(){var t=this,r=this.props,l=r.hide,i=r.sectors,f=r.className,g=r.label,c=r.cx,o=r.cy,j=r.innerRadius,A=r.outerRadius,x=r.isAnimationActive,w=this.state.isAnimationFinished;if(l||!i||!i.length||!Z(c)||!Z(o)||!Z(j)||!Z(A))return null;var m=ye("recharts-pie",f);return I.createElement(ie,{tabIndex:this.props.rootTabIndex,className:m,ref:function(N){t.pieRef=N}},this.renderSectors(),g&&this.renderLabels(i),He.renderCallByParent(this.props,null,!1),(!x||w)&&Xt.renderCallByParent(this.props,i,!1))}}],[{key:"getDerivedStateFromProps",value:function(t,r){return r.prevIsAnimationActive!==t.isAnimationActive?{prevIsAnimationActive:t.isAnimationActive,prevAnimationId:t.animationId,curSectors:t.sectors,prevSectors:[],isAnimationFinished:!0}:t.isAnimationActive&&t.animationId!==r.prevAnimationId?{prevAnimationId:t.animationId,curSectors:t.sectors,prevSectors:r.curSectors,isAnimationFinished:!0}:t.sectors!==r.curSectors?{curSectors:t.sectors,isAnimationFinished:!0}:null}},{key:"getTextAnchor",value:function(t,r){return t>r?"start":t<r?"end":"middle"}},{key:"renderLabelLineItem",value:function(t,r,l){if(I.isValidElement(t))return I.cloneElement(t,r);if(ne(t))return t(r);var i=ye("recharts-pie-label-line",typeof t!="boolean"?t.className:"");return I.createElement(Yt,ee({},r,{key:l,type:"linear",className:i}))}},{key:"renderLabelItem",value:function(t,r,l){if(I.isValidElement(t))return I.cloneElement(t,r);var i=l;if(ne(t)&&(i=t(r),I.isValidElement(i)))return i;var f=ye("recharts-pie-label-text",typeof t!="boolean"&&!ne(t)?t.className:"");return I.createElement(zt,ee({},r,{alignmentBaseline:"middle",className:f}),i)}}])})(O.PureComponent);xe=G;L(G,"displayName","Pie");L(G,"defaultProps",{stroke:"#fff",fill:"#808080",legendType:"rect",cx:"50%",cy:"50%",startAngle:0,endAngle:360,innerRadius:0,outerRadius:"80%",paddingAngle:0,labelLine:!0,hide:!1,minAngle:0,isAnimationActive:!Zt.isSsr,animationBegin:400,animationDuration:1500,animationEasing:"ease",nameKey:"name",blendStroke:!1,rootTabIndex:0});L(G,"parseDeltaAngle",function(s,a){var n=fe(a-s),t=Math.min(Math.abs(a-s),360);return n*t});L(G,"getRealPieData",function(s){var a=s.data,n=s.children,t=he(s,!1),r=ea(n,ta);return a&&a.length?a.map(function(l,i){return R(R(R({payload:l},t),l),r&&r[i]&&r[i].props)}):r&&r.length?r.map(function(l){return R(R({},t),l.props)}):[]});L(G,"parseCoordinateOfPie",function(s,a){var n=a.top,t=a.left,r=a.width,l=a.height,i=aa(r,l),f=t+pe(s.cx,r,r/2),g=n+pe(s.cy,l,l/2),c=pe(s.innerRadius,i,0),o=pe(s.outerRadius,i,i*.8),j=s.maxRadius||Math.sqrt(r*r+l*l)/2;return{cx:f,cy:g,innerRadius:c,outerRadius:o,maxRadius:j}});L(G,"getComposedData",function(s){var a=s.item,n=s.offset,t=a.type.defaultProps!==void 0?R(R({},a.type.defaultProps),a.props):a.props,r=xe.getRealPieData(t);if(!r||!r.length)return null;var l=t.cornerRadius,i=t.startAngle,f=t.endAngle,g=t.paddingAngle,c=t.dataKey,o=t.nameKey,j=t.valueKey,A=t.tooltipType,x=Math.abs(t.minAngle),w=xe.parseCoordinateOfPie(t,n),m=xe.parseDeltaAngle(i,f),b=Math.abs(m),N=c;ae(c)&&ae(j)?(Re(!1,`Use "dataKey" to specify the value of pie,
1
+ import{e as I,aH as ye,r as O,aP as De,j as e,B as Ce,bV as Te,bW as je,bD as Ke,aj as T,cA as J,aQ as rt,cB as $,bE as nt,ap as it,bF as ot,bG as de,cU as z,aR as lt,af as se,bS as ct,ag as W,S as Ge,cz as dt,bv as ut,bw as mt,bx as pt,by as ht,bz as ft,bA as xt,ah as B,bO as Pe}from"./index-Bgo4hw-T.js";import{s as oe,g as U,d as bt,S as gt,a as vt,D as jt,b as yt}from"./stats-view-BRy4IDHe.js";import{E as ce}from"./empty-indicator-CzTRebSi.js";import{A as St,a as At}from"./wallet-cards-Cl4bJBBw.js";import{G as wt,C as Nt,X as Dt,Y as Ct}from"./gh-chart-ldqA2tQU.js";import{T as Ve,a as $e,K as ue,d as Y,e as Tt,b as me}from"./tabs-Bw13eFRh.js";import{a as _t,c as kt}from"./audience-DF--nR_q.js";import{S as te,B as Ot}from"./sort-button-CEXkgGLb.js";import{S as Pt,C as Q,g as Mt,b as Rt}from"./content-helpers-TSHyiXwF.js";import{e as le,c as K,f as F,g as Et,a as Ye,b as ze,d as H}from"./table-BWAnP2ln.js";import{g as Se}from"./currency-fEUUCkj0.js";import{g as Bt}from"./source-utils-B1S3ZHA2.js";import{a as It,b as Ft,u as Lt,k as Kt}from"./stats-B2vPCVx7.js";import{u as Gt,a as Vt}from"./tiers-jCNws2RK.js";import{C as be,a as _e,b as ke,f as Oe,c as ge,j as $t}from"./pagemenu-D3ByoZIR.js";import{h as ne,F as Yt,T as zt,b as he,r as Ae,H as ae,L as ie,o as X,c as Ht,S as Ut,A as Wt,I as qt,i as Me,d as Qt,J as Z,u as He,e as Xt,K as Jt,G as Zt,m as fe,l as ea,n as ta,M as aa,N as pe,O as Re,g as sa,s as ra,C as Ue,a as We,v as na,B as Ee}from"./chart-0ezwQhyB.js";import{S as qe,a as Qe,b as Xe,c as Je,f as we}from"./select-MVpx-Kfp.js";import{P as ia,a as oa}from"./PolarAngleAxis-BzbazaED.js";import{n as la,o as ca,l as da}from"./lucide-react-7D_Tsesk.js";import{u as ua}from"./use-growth-stats-C5TiRW1S.js";import"./message-square-text-DzuHB7uU.js";import"./sprout-CXg43Zav.js";import"./index-D0RISNEd.js";import"./_baseAssignValue-D0bBhNG1.js";import"./a-large-small-gBDqOWOy.js";import"./at-sign-V79EBNTJ.js";import"./copy-CTHgI4YI.js";import"./hash-CRtHv162.js";import"./inbox-DWYGFLuU.js";import"./list-filter-CofVbkA4.js";import"./minus-BIdO1CDG.js";import"./tags-BQz2NtFF.js";import"./square-C8G-1gV_.js";import"./user-round-check-Df7ko4Tm.js";import"./repeat-YTCeIlQZ.js";import"./reply-CUazFbTY.js";import"./trash-BKeiM6WP.js";var xe;function re(s){"@babel/helpers - typeof";return re=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(a){return typeof a}:function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},re(s)}function ee(){return ee=Object.assign?Object.assign.bind():function(s){for(var a=1;a<arguments.length;a++){var n=arguments[a];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(s[t]=n[t])}return s},ee.apply(this,arguments)}function Be(s,a){var n=Object.keys(s);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(s);a&&(t=t.filter(function(r){return Object.getOwnPropertyDescriptor(s,r).enumerable})),n.push.apply(n,t)}return n}function R(s){for(var a=1;a<arguments.length;a++){var n=arguments[a]!=null?arguments[a]:{};a%2?Be(Object(n),!0).forEach(function(t){L(s,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(n)):Be(Object(n)).forEach(function(t){Object.defineProperty(s,t,Object.getOwnPropertyDescriptor(n,t))})}return s}function ma(s,a){if(!(s instanceof a))throw new TypeError("Cannot call a class as a function")}function Ie(s,a){for(var n=0;n<a.length;n++){var t=a[n];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(s,et(t.key),t)}}function pa(s,a,n){return a&&Ie(s.prototype,a),n&&Ie(s,n),Object.defineProperty(s,"prototype",{writable:!1}),s}function ha(s,a,n){return a=ve(a),fa(s,Ze()?Reflect.construct(a,n||[],ve(s).constructor):a.apply(s,n))}function fa(s,a){if(a&&(re(a)==="object"||typeof a=="function"))return a;if(a!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return xa(s)}function xa(s){if(s===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s}function Ze(){try{var s=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Ze=function(){return!!s})()}function ve(s){return ve=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},ve(s)}function ba(s,a){if(typeof a!="function"&&a!==null)throw new TypeError("Super expression must either be null or a function");s.prototype=Object.create(a&&a.prototype,{constructor:{value:s,writable:!0,configurable:!0}}),Object.defineProperty(s,"prototype",{writable:!1}),a&&Ne(s,a)}function Ne(s,a){return Ne=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},Ne(s,a)}function L(s,a,n){return a=et(a),a in s?Object.defineProperty(s,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):s[a]=n,s}function et(s){var a=ga(s,"string");return re(a)=="symbol"?a:a+""}function ga(s,a){if(re(s)!="object"||!s)return s;var n=s[Symbol.toPrimitive];if(n!==void 0){var t=n.call(s,a);if(re(t)!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(s)}var G=(function(s){function a(n){var t;return ma(this,a),t=ha(this,a,[n]),L(t,"pieRef",null),L(t,"sectorRefs",[]),L(t,"id",Jt("recharts-pie-")),L(t,"handleAnimationEnd",function(){var r=t.props.onAnimationEnd;t.setState({isAnimationFinished:!0}),ne(r)&&r()}),L(t,"handleAnimationStart",function(){var r=t.props.onAnimationStart;t.setState({isAnimationFinished:!1}),ne(r)&&r()}),t.state={isAnimationFinished:!n.isAnimationActive,prevIsAnimationActive:n.isAnimationActive,prevAnimationId:n.animationId,sectorToFocus:0},t}return ba(a,s),pa(a,[{key:"isActiveIndex",value:function(t){var r=this.props.activeIndex;return Array.isArray(r)?r.indexOf(t)!==-1:t===r}},{key:"hasActiveIndex",value:function(){var t=this.props.activeIndex;return Array.isArray(t)?t.length!==0:t||t===0}},{key:"renderLabels",value:function(t){var r=this.props.isAnimationActive;if(r&&!this.state.isAnimationFinished)return null;var l=this.props,i=l.label,f=l.labelLine,g=l.dataKey,c=l.valueKey,o=he(this.props,!1),j=he(i,!1),A=he(f,!1),x=i&&i.offsetRadius||20,w=t.map(function(m,b){var N=(m.startAngle+m.endAngle)/2,p=Ae(m.cx,m.cy,m.outerRadius+x,N),h=R(R(R(R({},o),m),{},{stroke:"none"},j),{},{index:b,textAnchor:a.getTextAnchor(p.x,m.cx)},p),u=R(R(R(R({},o),m),{},{fill:"none",stroke:m.fill},A),{},{index:b,points:[Ae(m.cx,m.cy,m.outerRadius,N),p]}),v=g;return ae(g)&&ae(c)?v="value":ae(g)&&(v=c),I.createElement(ie,{key:"label-".concat(m.startAngle,"-").concat(m.endAngle,"-").concat(m.midAngle,"-").concat(b)},f&&a.renderLabelLineItem(f,u,"line"),a.renderLabelItem(i,h,X(m,v)))});return I.createElement(ie,{className:"recharts-pie-labels"},w)}},{key:"renderSectorsStatically",value:function(t){var r=this,l=this.props,i=l.activeShape,f=l.blendStroke,g=l.inactiveShape;return t.map(function(c,o){if(c?.startAngle===0&&c?.endAngle===0&&t.length!==1)return null;var j=r.isActiveIndex(o),A=g&&r.hasActiveIndex()?g:null,x=j?i:A,w=R(R({},c),{},{stroke:f?c.fill:c.stroke,tabIndex:-1});return I.createElement(ie,ee({ref:function(b){b&&!r.sectorRefs.includes(b)&&r.sectorRefs.push(b)},tabIndex:-1,className:"recharts-pie-sector"},Ht(r.props,c,o),{key:"sector-".concat(c?.startAngle,"-").concat(c?.endAngle,"-").concat(c.midAngle,"-").concat(o)}),I.createElement(Ut,ee({option:x,isActive:j,shapeType:"sector"},w)))})}},{key:"renderSectorsWithAnimation",value:function(){var t=this,r=this.props,l=r.sectors,i=r.isAnimationActive,f=r.animationBegin,g=r.animationDuration,c=r.animationEasing,o=r.animationId,j=this.state,A=j.prevSectors,x=j.prevIsAnimationActive;return I.createElement(Wt,{begin:f,duration:g,isActive:i,easing:c,from:{t:0},to:{t:1},key:"pie-".concat(o,"-").concat(x),onAnimationStart:this.handleAnimationStart,onAnimationEnd:this.handleAnimationEnd},function(w){var m=w.t,b=[],N=l&&l[0],p=N.startAngle;return l.forEach(function(h,u){var v=A&&A[u],C=u>0?qt(h,"paddingAngle",0):0;if(v){var S=Me(v.endAngle-v.startAngle,h.endAngle-h.startAngle),d=R(R({},h),{},{startAngle:p+C,endAngle:p+S(m)+C});b.push(d),p=d.endAngle}else{var k=h.endAngle,y=h.startAngle,D=Me(0,k-y),P=D(m),M=R(R({},h),{},{startAngle:p+C,endAngle:p+P+C});b.push(M),p=M.endAngle}}),I.createElement(ie,null,t.renderSectorsStatically(b))})}},{key:"attachKeyboardHandlers",value:function(t){var r=this;t.onkeydown=function(l){if(!l.altKey)switch(l.key){case"ArrowLeft":{var i=++r.state.sectorToFocus%r.sectorRefs.length;r.sectorRefs[i].focus(),r.setState({sectorToFocus:i});break}case"ArrowRight":{var f=--r.state.sectorToFocus<0?r.sectorRefs.length-1:r.state.sectorToFocus%r.sectorRefs.length;r.sectorRefs[f].focus(),r.setState({sectorToFocus:f});break}case"Escape":{r.sectorRefs[r.state.sectorToFocus].blur(),r.setState({sectorToFocus:0});break}}}}},{key:"renderSectors",value:function(){var t=this.props,r=t.sectors,l=t.isAnimationActive,i=this.state.prevSectors;return l&&r&&r.length&&(!i||!Qt(i,r))?this.renderSectorsWithAnimation():this.renderSectorsStatically(r)}},{key:"componentDidMount",value:function(){this.pieRef&&this.attachKeyboardHandlers(this.pieRef)}},{key:"render",value:function(){var t=this,r=this.props,l=r.hide,i=r.sectors,f=r.className,g=r.label,c=r.cx,o=r.cy,j=r.innerRadius,A=r.outerRadius,x=r.isAnimationActive,w=this.state.isAnimationFinished;if(l||!i||!i.length||!Z(c)||!Z(o)||!Z(j)||!Z(A))return null;var m=ye("recharts-pie",f);return I.createElement(ie,{tabIndex:this.props.rootTabIndex,className:m,ref:function(N){t.pieRef=N}},this.renderSectors(),g&&this.renderLabels(i),He.renderCallByParent(this.props,null,!1),(!x||w)&&Xt.renderCallByParent(this.props,i,!1))}}],[{key:"getDerivedStateFromProps",value:function(t,r){return r.prevIsAnimationActive!==t.isAnimationActive?{prevIsAnimationActive:t.isAnimationActive,prevAnimationId:t.animationId,curSectors:t.sectors,prevSectors:[],isAnimationFinished:!0}:t.isAnimationActive&&t.animationId!==r.prevAnimationId?{prevAnimationId:t.animationId,curSectors:t.sectors,prevSectors:r.curSectors,isAnimationFinished:!0}:t.sectors!==r.curSectors?{curSectors:t.sectors,isAnimationFinished:!0}:null}},{key:"getTextAnchor",value:function(t,r){return t>r?"start":t<r?"end":"middle"}},{key:"renderLabelLineItem",value:function(t,r,l){if(I.isValidElement(t))return I.cloneElement(t,r);if(ne(t))return t(r);var i=ye("recharts-pie-label-line",typeof t!="boolean"?t.className:"");return I.createElement(Yt,ee({},r,{key:l,type:"linear",className:i}))}},{key:"renderLabelItem",value:function(t,r,l){if(I.isValidElement(t))return I.cloneElement(t,r);var i=l;if(ne(t)&&(i=t(r),I.isValidElement(i)))return i;var f=ye("recharts-pie-label-text",typeof t!="boolean"&&!ne(t)?t.className:"");return I.createElement(zt,ee({},r,{alignmentBaseline:"middle",className:f}),i)}}])})(O.PureComponent);xe=G;L(G,"displayName","Pie");L(G,"defaultProps",{stroke:"#fff",fill:"#808080",legendType:"rect",cx:"50%",cy:"50%",startAngle:0,endAngle:360,innerRadius:0,outerRadius:"80%",paddingAngle:0,labelLine:!0,hide:!1,minAngle:0,isAnimationActive:!Zt.isSsr,animationBegin:400,animationDuration:1500,animationEasing:"ease",nameKey:"name",blendStroke:!1,rootTabIndex:0});L(G,"parseDeltaAngle",function(s,a){var n=fe(a-s),t=Math.min(Math.abs(a-s),360);return n*t});L(G,"getRealPieData",function(s){var a=s.data,n=s.children,t=he(s,!1),r=ea(n,ta);return a&&a.length?a.map(function(l,i){return R(R(R({payload:l},t),l),r&&r[i]&&r[i].props)}):r&&r.length?r.map(function(l){return R(R({},t),l.props)}):[]});L(G,"parseCoordinateOfPie",function(s,a){var n=a.top,t=a.left,r=a.width,l=a.height,i=aa(r,l),f=t+pe(s.cx,r,r/2),g=n+pe(s.cy,l,l/2),c=pe(s.innerRadius,i,0),o=pe(s.outerRadius,i,i*.8),j=s.maxRadius||Math.sqrt(r*r+l*l)/2;return{cx:f,cy:g,innerRadius:c,outerRadius:o,maxRadius:j}});L(G,"getComposedData",function(s){var a=s.item,n=s.offset,t=a.type.defaultProps!==void 0?R(R({},a.type.defaultProps),a.props):a.props,r=xe.getRealPieData(t);if(!r||!r.length)return null;var l=t.cornerRadius,i=t.startAngle,f=t.endAngle,g=t.paddingAngle,c=t.dataKey,o=t.nameKey,j=t.valueKey,A=t.tooltipType,x=Math.abs(t.minAngle),w=xe.parseCoordinateOfPie(t,n),m=xe.parseDeltaAngle(i,f),b=Math.abs(m),N=c;ae(c)&&ae(j)?(Re(!1,`Use "dataKey" to specify the value of pie,
2
2
  the props "valueKey" will be deprecated in 1.1.0`),N="value"):ae(c)&&(Re(!1,`Use "dataKey" to specify the value of pie,
3
3
  the props "valueKey" will be deprecated in 1.1.0`),N=j);var p=r.filter(function(d){return X(d,N,0)!==0}).length,h=(b>=360?p:p-1)*g,u=b-p*x-h,v=r.reduce(function(d,k){var y=X(k,N,0);return d+(Z(y)?y:0)},0),C;if(v>0){var S;C=r.map(function(d,k){var y=X(d,N,0),D=X(d,o,k),P=(Z(y)?y:0)/v,M;k?M=S.endAngle+fe(m)*g*(y!==0?1:0):M=i;var _=M+fe(m)*((y!==0?x:0)+P*u),E=(M+_)/2,V=(w.innerRadius+w.outerRadius)/2,q=[{name:D,value:y,payload:d,dataKey:N,type:A}],st=Ae(w.cx,w.cy,V,E);return S=R(R(R({percent:P,cornerRadius:l,name:D,tooltipPayload:q,midAngle:E,middleRadius:V,tooltipPosition:st},d),w),{},{value:X(d,N),startAngle:M,endAngle:_,payload:d,paddingAngle:fe(m)*g}),S})}return R(R({},w),{},{sectors:C,data:r})});var va=sa({chartName:"PieChart",GraphicalChild:G,validateTooltipEventTypes:["item"],defaultTooltipEventType:"item",legendContent:"children",axisComponents:[{axisType:"angleAxis",AxisComp:ia},{axisType:"radiusAxis",AxisComp:oa}],formatAxisMap:ra,defaultProps:{layout:"centric",startAngle:0,endAngle:360,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"}});const tt=({className:s})=>{const a=De();return e.jsx(ce,{actions:e.jsx(Ce,{variant:"outline",onClick:()=>a("/settings/analytics",{crossApp:!0}),children:"Open settings"}),className:s,description:"Enable member source tracking in settings to see which content drives member growth.",title:"Member sources have been disabled",children:e.jsx(St,{})})},ja=s=>s==="total-members"||s==="free-members"||s==="paid-members"||s==="mrr",ya=({active:s,payload:a,range:n,color:t,showBreakdown:r})=>{if(!s||!a?.length)return null;const l=a[0].payload,{date:i,formattedValue:f,label:g,comped:c}=l,o=l.value-(c||0);return e.jsxs("div",{className:"min-w-[200px] rounded-lg border bg-background px-3 py-2 shadow-lg",children:[i&&e.jsx("div",{className:"mb-1 text-sm text-foreground",children:z(i,n||0)}),e.jsxs("div",{className:"flex flex-col gap-1",children:[r&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("div",{className:"flex grow items-center justify-between gap-5",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"Paid subscriptions"}),e.jsx("div",{className:"font-mono text-xs",children:T(o)})]})}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("div",{className:"flex grow items-center justify-between gap-5",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"Complimentary"}),e.jsx("div",{className:"font-mono text-xs",children:c!==void 0&&c>0?T(c):"0"})]})}),e.jsx(lt,{})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"inline-block size-2 rounded-full opacity-50",style:{backgroundColor:t||"hsl(var(--chart-purple))"}}),e.jsxs("div",{className:"flex grow items-center justify-between gap-5",children:[g&&e.jsx("div",{className:"text-sm text-muted-foreground",children:g}),e.jsx("div",{className:"font-mono font-medium",children:f})]})]})]})]})},Sa=({chartData:s,totals:a,initialTab:n,currencySymbol:t,isLoading:r,onTabChange:l})=>{const i=ja(n)?n:"total-members",[f,g]=O.useState(i),{range:c}=Te(),{appSettings:o}=je(),j=De(),[A]=Ke();O.useEffect(()=>{g(i)},[i]);const x=S=>{g(S);const d=new URLSearchParams(A);d.set("tab",S),j(`?${d.toString()}`,{replace:!0}),l&&l(S)},{totalMembers:w,freeMembers:m,paidMembers:b,mrr:N,percentChanges:p,directions:h}=a,u=O.useMemo(()=>{if(!s||s.length===0)return[];let S=[],d="value";switch(f){case"free-members":d="free";break;case"paid-members":d="paid";break;case"mrr":{d="mrr";break}default:d="value"}S=oe(s,c,d,"exact");let k=[];switch(f){case"free-members":k=S.map(y=>({...y,value:y.free,formattedValue:T(y.free),label:"Free members"}));break;case"paid-members":k=S.map(y=>({...y,value:y.paid,formattedValue:T(y.paid),label:"Paid members",comped:y.comped,paid_subscribed:y.paid_subscribed}));break;case"mrr":k=S.map(y=>({...y,value:J(y.mrr),formattedValue:`${t}${T(J(y.mrr))}`,label:"MRR"}));break;default:k=S.map(y=>{const D=y.free+y.paid;return{...y,value:D,formattedValue:T(D),label:"Total members"}})}return k},[f,s,c,t]),v={"total-members":{color:"hsl(var(--chart-darkblue))"},"free-members":{color:"hsl(var(--chart-blue))"},"paid-members":{color:"hsl(var(--chart-purple))"},mrr:{color:"hsl(var(--chart-teal))"}};return r?e.jsx("div",{className:"-mb-6 flex h-[calc(16vw+132px)] w-full items-start justify-center",children:e.jsx(rt,{})}):e.jsxs(Ve,{defaultValue:i,variant:"kpis",children:[e.jsxs($e,{className:`-mx-6 ${o?.paidMembersEnabled?"hidden grid-cols-4 lg:!visible lg:!grid":"grid grid-cols-4"}`,children:[e.jsx(ue,{className:o?.paidMembersEnabled?"":"cursor-auto after:hidden",value:"total-members",onClick:()=>{o?.paidMembersEnabled&&x("total-members")},children:e.jsx(Y,{color:"hsl(var(--chart-darkblue))",diffDirection:c===$.allTime.value?"hidden":h.total,diffValue:p.total,label:"Total members",value:T(w)})}),o?.paidMembersEnabled&&e.jsxs(e.Fragment,{children:[e.jsx(ue,{value:"free-members",onClick:()=>{x("free-members")},children:e.jsx(Y,{color:"hsl(var(--chart-blue))",diffDirection:c===$.allTime.value?"hidden":h.free,diffValue:p.free,label:"Free members",value:T(m)})}),e.jsx(ue,{value:"paid-members",onClick:()=>{x("paid-members")},children:e.jsx(Y,{color:"hsl(var(--chart-purple))",diffDirection:c===$.allTime.value?"hidden":h.paid,diffValue:p.paid,label:"Paid members",value:T(b)})}),e.jsx(ue,{value:"mrr",onClick:()=>{x("mrr")},children:e.jsx(Y,{color:"hsl(var(--chart-teal))",diffDirection:c===$.allTime.value?"hidden":h.mrr,diffValue:p.mrr,label:"MRR",value:`${t}${T(J(N))}`})})]})]}),o?.paidMembersEnabled&&e.jsxs(nt,{children:[e.jsx(it,{className:"lg:hidden",asChild:!0,children:e.jsxs(Tt,{children:[f==="total-members"&&e.jsx(Y,{color:"hsl(var(--chart-darkblue))",diffDirection:c===$.allTime.value?"hidden":h.total,diffValue:p.total,label:"Total members",value:T(w)}),f==="free-members"&&e.jsx(Y,{color:"hsl(var(--chart-blue))",diffDirection:c===$.allTime.value?"hidden":h.free,diffValue:p.free,label:"Free members",value:T(m)}),f==="paid-members"&&e.jsx(Y,{color:"hsl(var(--chart-purple))",diffDirection:c===$.allTime.value?"hidden":h.paid,diffValue:p.paid,label:"Paid members",value:T(b)}),f==="mrr"&&e.jsx(Y,{color:"hsl(var(--chart-teal))",diffDirection:c===$.allTime.value?"hidden":h.mrr,diffValue:p.mrr,label:"MRR",value:`${t}${T(J(N))}`})]})}),e.jsxs(ot,{align:"end",className:"w-56",children:[e.jsx(de,{onClick:()=>x("total-members"),children:"Total members"}),e.jsx(de,{onClick:()=>x("free-members"),children:"Free members"}),e.jsx(de,{onClick:()=>x("paid-members"),children:"Paid members"}),e.jsx(de,{onClick:()=>x("mrr"),children:"MRR"})]})]}),e.jsx("div",{className:"my-4 [&_.recharts-cartesian-axis-tick-value]:fill-gray-500",children:e.jsx(wt,{className:"-mb-3 h-[16vw] max-h-[320px] w-full min-h-[180px]",color:v[f].color,data:u,dataFormatter:f==="mrr"?S=>`${t}${T(S)}`:T,id:f,range:c,tooltipContent:f==="paid-members"?e.jsx(ya,{color:v["paid-members"].color,range:c,showBreakdown:!0}):void 0})})]})},Aa=(s,a="signups desc",n=50)=>{const{startDate:t,endDate:r,timezone:l}=se(s),i={date_from:W(t),date_to:W(r),member_status:_t(ct),order:a,limit:n.toString()};return l&&(i.timezone=l),Gt({searchParams:i})},Fe=({data:s,currencySymbol:a,limit:n,defaultSourceIconUrl:t})=>{const r=n?s.slice(0,n):s,{appSettings:l}=je();return e.jsx(le,{children:r.map(i=>e.jsxs(K,{className:"last:border-none",children:[e.jsx(F,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Pt,{defaultSourceIconUrl:t,displayName:i.displayName,iconSrc:i.iconSrc}),i.linkUrl?e.jsx("a",{className:"hover:underline",href:i.linkUrl,rel:"noreferrer",target:"_blank",children:i.displayName}):e.jsx("span",{children:i.displayName})]})}),e.jsxs(F,{className:"text-right font-mono text-sm",children:["+",T(i.free_members)]}),l?.paidMembersEnabled&&e.jsxs(e.Fragment,{children:[e.jsxs(F,{className:"text-right font-mono text-sm",children:["+",T(i.paid_members)]}),e.jsxs(F,{className:"text-right font-mono text-sm",children:["+",a,T(J(i.mrr))]})]})]},i.source))})},wa=({range:s,limit:a=20,showViewAll:n=!1,sortBy:t,setSortBy:r})=>{const{data:l}=Te(),{data:i}=It(),{appSettings:f}=je(),[g,c]=O.useState("free_members desc"),o=t||g,j=r||c,A=o.replace("free_members","signups").replace("paid_members","paid_conversions"),{data:x,isLoading:w}=Aa(s,A,a),m=l?.url,b="https://www.google.com/s2/favicons?domain=ghost.org&sz=64",N=I.useMemo(()=>{if(i?.stats&&i?.meta?.totals){const v=i.meta.totals;let C=v[0];if(!C)return Se("usd");for(const S of v)S.mrr>C.mrr&&(C=S);return Se(C.currency)}return Se("usd")},[i]),p=I.useMemo(()=>x?.stats?x.stats.map(v=>{const C=v.source||"Direct",{domain:S}=Bt(C,m),d=S?`https://www.faviconextractor.com/favicon/${S}?larger=true`:b,k=S&&C!=="Direct"?`https://${S}`:void 0;return{source:C,free_members:v.signups,paid_members:v.paid_conversions,mrr:v.mrr,iconSrc:d,displayName:C,linkUrl:k}}):[],[x,m]),h="Top sources",u=`Where did your growth come from ${U(s)}`;return f?.analytics.membersTrackSources?w?e.jsx(le,{children:e.jsx(K,{className:"last:border-none",children:e.jsx(F,{className:"border-none py-2",colSpan:1,children:e.jsx(Ge,{containerClassName:"space-y-2",count:5,maxWidth:75,randomize:!0})})})}):e.jsxs(e.Fragment,{children:[p.length>0?e.jsx(Fe,{currencySymbol:N,data:p,defaultSourceIconUrl:b,limit:a}):e.jsx(le,{children:e.jsx(K,{className:"last:border-none",children:e.jsx(F,{className:"border-none py-12 group-hover:!bg-transparent",colSpan:f?.paidMembersEnabled?4:2,children:e.jsx(ce,{description:"Try adjusting your date range to see more data.",title:`No conversions ${U(s)}`,children:e.jsx(dt,{strokeWidth:1.5})})})})}),n&&p.length>a&&e.jsx(Et,{className:"border-none bg-transparent hover:!bg-transparent",children:e.jsx(K,{children:e.jsx(F,{className:"border-none bg-transparent px-0 pb-0 hover:!bg-transparent",colSpan:4,children:e.jsxs(ut,{children:[e.jsx(mt,{asChild:!0,children:e.jsxs(Ce,{variant:"outline",children:["View all ",e.jsx(At,{})]})}),e.jsxs(pt,{className:"overflow-y-auto pt-0 sm:max-w-[600px]",children:[e.jsxs(ht,{className:"sticky top-0 z-40 -mx-6 bg-background/60 p-6 backdrop-blur",children:[e.jsx(ft,{children:h}),e.jsx(xt,{children:u})]}),e.jsx("div",{className:"group/datalist",children:e.jsxs(Ye,{children:[e.jsx(ze,{children:e.jsxs(K,{children:[e.jsx(H,{children:"Source"}),e.jsx(H,{className:"w-[110px] text-right",children:e.jsx(te,{activeSortBy:o,setSortBy:j,sortBy:"free_members desc",children:"Free members"})}),f?.paidMembersEnabled&&e.jsxs(e.Fragment,{children:[e.jsx(H,{className:"w-[110px] text-right",children:e.jsx(te,{activeSortBy:o,setSortBy:j,sortBy:"paid_members desc",children:"Paid members"})}),e.jsx(H,{className:"w-[110px] text-right",children:e.jsx(te,{activeSortBy:o,setSortBy:j,sortBy:"mrr desc",children:"MRR impact"})})]})]})}),e.jsx(Fe,{currencySymbol:N,data:p,defaultSourceIconUrl:b})]})})]})]})})})})]}):e.jsx(le,{children:e.jsx(K,{className:"last:border-none",children:e.jsx(F,{className:"border-none py-12 group-hover:!bg-transparent",colSpan:f?.paidMembersEnabled?4:2,children:e.jsx(tt,{})})})})},Na=({active:s,payload:a})=>{if(s&&a&&a.length){const n=a[0];return e.jsx("div",{className:"rounded-lg border bg-background p-2 shadow-sm",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"size-2 rounded-full opacity-50",style:{backgroundColor:n.payload.color}}),e.jsx("span",{className:"font-medium",children:n.name}),e.jsx("span",{className:"font-mono",children:T(n.value)})]})})}return null},Da=({isLoading:s,range:a})=>{const{data:n}=Ft(),{data:t}=Lt({searchParams:{date_from:W(se(a).startDate)}}),{data:{tiers:r=[]}={}}=Vt(),[l,i]=O.useState("billing-period"),{startDate:f,endDate:g}=O.useMemo(()=>se(a),[a]),c=O.useMemo(()=>W(f),[f]),o=O.useMemo(()=>W(g),[g]),j=O.useMemo(()=>r.filter(u=>u.type==="paid"&&u.active).map(u=>({id:u.id,name:u.name})),[r]),A=O.useMemo(()=>{if(!t?.stats||t.stats.length===0)return 0;const u=t.stats,v=B(c),C=B(o),S=u.filter(P=>{const M=B(P.date);return M.isSameOrAfter(v)&&M.isSameOrBefore(C)});if(S.length===0)return 0;const d=[...S].sort((P,M)=>new Date(P.date).getTime()-new Date(M.date).getTime()),k=d[0].comped,D=d[d.length-1].comped-k;return D>0?D:0},[t,c,o]),x=O.useMemo(()=>{if(!n?.stats)return[];const u=B(c),v=B(o),C=n.stats.filter(d=>{const k=B(d.date);return k.isSameOrAfter(u)&&k.isSameOrBefore(v)}).reduce((d,k)=>{const y=k.cadence;return d[y]||(d[y]=0),d[y]+=k.signups,d},{});return A>0&&(C.complimentary=A),Object.entries(C).map(([d,k],y)=>{let D=d,P="url(#gradientPurple)",M="hsl(var(--chart-purple))";return d==="month"?(D="Monthly",P="url(#gradientPurple)",M="hsl(var(--chart-purple))"):d==="year"?(D="Annual",P="url(#gradientTeal)",M="hsl(var(--chart-teal))"):d==="complimentary"&&(D="Complimentary",P="url(#gradientBlue)",M="hsl(var(--chart-blue))"),{id:`cadence-${y}`,name:D,count:k,fill:P,color:M}})},[n,c,o,A]),w=O.useMemo(()=>{if(!n?.stats||j.length===0)return[];const u=B(c),v=B(o),C=n.stats.filter(D=>{const P=B(D.date);return P.isSameOrAfter(u)&&P.isSameOrBefore(v)}).reduce((D,P)=>{const M=P.tier;return D[M]||(D[M]=0),D[M]+=P.signups,D},{}),S=[{gradient:"url(#gradientPurple)",solid:"hsl(var(--chart-purple))"},{gradient:"url(#gradientTeal)",solid:"hsl(var(--chart-teal))"},{gradient:"url(#gradientBlue)",solid:"hsl(var(--chart-blue))"},{gradient:"url(#gradientRose)",solid:"hsl(var(--chart-rose))"},{gradient:"url(#gradientOrange)",solid:"hsl(var(--chart-orange))"},{gradient:"url(#gradientGreen)",solid:"hsl(var(--chart-green))"},{gradient:"url(#gradientAmber)",solid:"hsl(var(--chart-amber))"},{gradient:"url(#gradientYellow)",solid:"hsl(var(--chart-yellow))"},{gradient:"url(#gradientDarkblue)",solid:"hsl(var(--chart-darkblue))"},{gradient:"url(#gradientGray)",solid:"hsl(var(--chart-darkgray))"}];return[...j.map(D=>{const P=C[D.id]||0;return{id:D.id,name:D.name,count:P}})].sort((D,P)=>P.count-D.count).map((D,P)=>{const M=P%S.length;return{...D,fill:S[M].gradient,color:S[M].solid}})},[n,j,c,o]),m=l==="billing-period"?x:w,b=O.useMemo(()=>m.reduce((u,v)=>u+v.count,0),[m]),N=O.useMemo(()=>{const u={count:{label:"Subscriptions"}};return m.forEach(v=>{u[v.id]={label:v.name,color:v.color}}),u},[m]),p=O.useMemo(()=>b===0?[]:m.map(u=>({label:u.name,count:u.count,percentage:u.count/b*100,color:u.color})),[m,b]);if(s||!n?.stats)return null;const h=m.length>0&&b>0;return e.jsxs(be,{children:[e.jsx(_e,{children:e.jsxs("div",{className:"flex items-start justify-between gap-1.5",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(ke,{children:"Paid subscription breakdown"}),e.jsxs(Oe,{children:["New paid subscriptions ",U(a)]})]}),j.length>1&&e.jsx("div",{children:e.jsxs(qe,{value:l,onValueChange:u=>i(u),children:[e.jsx(Qe,{className:"w-full",children:e.jsx(Xe,{})}),e.jsxs(Je,{align:"end",children:[e.jsx(we,{value:"billing-period",children:"Billing period"}),e.jsx(we,{value:"tiers",children:"Tiers"})]})]})})]})}),e.jsx(ge,{children:h?e.jsxs(e.Fragment,{children:[e.jsx(Ue,{className:"mx-auto aspect-square h-[250px] min-h-[250px] w-full",config:N,children:e.jsxs(va,{children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"gradientPurple",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"hsl(var(--chart-purple))",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"hsl(var(--chart-purple))",stopOpacity:.6})]}),e.jsxs("linearGradient",{id:"gradientTeal",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"hsl(var(--chart-teal))",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"hsl(var(--chart-teal))",stopOpacity:.6})]}),e.jsxs("linearGradient",{id:"gradientRose",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"hsl(var(--chart-rose))",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"hsl(var(--chart-rose))",stopOpacity:.6})]}),e.jsxs("linearGradient",{id:"gradientBlue",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"hsl(var(--chart-blue))",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"hsl(var(--chart-blue))",stopOpacity:.6})]}),e.jsxs("linearGradient",{id:"gradientOrange",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"hsl(var(--chart-orange))",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"hsl(var(--chart-orange))",stopOpacity:.6})]}),e.jsxs("linearGradient",{id:"gradientGreen",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"hsl(var(--chart-green))",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"hsl(var(--chart-green))",stopOpacity:.6})]}),e.jsxs("linearGradient",{id:"gradientAmber",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"hsl(var(--chart-amber))",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"hsl(var(--chart-amber))",stopOpacity:.6})]}),e.jsxs("linearGradient",{id:"gradientYellow",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"hsl(var(--chart-yellow))",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"hsl(var(--chart-yellow))",stopOpacity:.6})]}),e.jsxs("linearGradient",{id:"gradientDarkblue",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"hsl(var(--chart-darkblue))",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"hsl(var(--chart-darkblue))",stopOpacity:.6})]}),e.jsxs("linearGradient",{id:"gradientGray",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"hsl(var(--chart-darkgray))",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"hsl(var(--chart-darkgray))",stopOpacity:.6})]})]}),e.jsx(We,{content:e.jsx(Na,{}),cursor:!1}),e.jsx(G,{animationBegin:0,animationDuration:1e3,data:m,dataKey:"count",innerRadius:70,nameKey:"name",strokeWidth:5,children:e.jsx(He,{content:({viewBox:u})=>{if(u&&"cx"in u&&"cy"in u)return e.jsxs("text",{dominantBaseline:"middle",textAnchor:"middle",x:u.cx,y:u.cy,children:[e.jsx("tspan",{className:"fill-foreground text-2xl font-semibold tracking-tight",x:u.cx,y:u.cy,children:T(b)}),e.jsx("tspan",{className:"fill-muted-foreground",x:u.cx,y:(u.cy||0)+20,children:"Total"})]})}})})]})}),p.length>0&&e.jsx("div",{className:"mt-4 flex flex-wrap items-center justify-center gap-x-6 gap-y-1 text-sm text-muted-foreground",children:p.map(u=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"size-2 rounded-full opacity-50",style:{backgroundColor:u.color}}),e.jsx("span",{className:"max-w-[150px] truncate whitespace-nowrap",title:u.label,children:u.label}),e.jsxs("span",{className:"font-medium text-foreground",children:[Math.round(Number(u.percentage)||0),"%"]})]},u.label))})]}):e.jsx("div",{className:"py-12",children:e.jsx(ce,{description:`No new paid subscriptions ${U(a)}.`,title:"No new subscribers",children:e.jsx(la,{strokeWidth:1.5})})})})]})},Ca=(s,a,n)=>{if(a===1){const o=B().format("YYYY-MM-DD"),j=s.find(A=>A.date===o);return[{date:o,signups:j?.signups||0,cancellations:j?.cancellations||0}]}const{startDate:t,endDate:r}=se(a),l=B(r).diff(B(t),"days"),i=bt(a,l,"sum",n),f=new Map(s.map(o=>[o.date,o])),g=[],c=new Set;if(i==="monthly"){const o=B(t).startOf("month"),j=B(r).startOf("month");for(;o.isSameOrBefore(j);){const A=o.format("YYYY-MM-DD");if(!c.has(A)){c.add(A);const x=f.get(A);x?g.push(x):g.push({date:A,signups:0,cancellations:0})}o.add(1,"month")}}else if(i==="weekly"){const o=B(t).startOf("week"),j=B(r).startOf("week");for(;o.isSameOrBefore(j);){const A=o.format("YYYY-MM-DD");if(!c.has(A)){c.add(A);const x=f.get(A);x?g.push(x):g.push({date:A,signups:0,cancellations:0})}o.add(1,"week")}}else{const o=B(t),j=B(r);for(;o.isSameOrBefore(j);){const A=o.format("YYYY-MM-DD"),x=f.get(A);x?g.push(x):g.push({date:A,signups:0,cancellations:0}),o.add(1,"day")}}return g},at=s=>{if(s===-1){const{startDate:a,endDate:n}=se(s);return B(n).diff(B(a),"days")}return s},Ta=s=>{const a=at(s);return a<30?["daily"]:a>=91?["weekly","monthly"]:["daily","weekly"]},Le=s=>{const a=at(s);return a<30?"daily":a>=91?"monthly":"weekly"},_a=({subscriptionData:s,memberData:a,range:n,isLoading:t})=>{const[r,l]=O.useState(()=>Le(n));O.useEffect(()=>{l(Le(n))},[n]);const i=O.useMemo(()=>Ta(n),[n]),f=O.useMemo(()=>{switch(r){case"daily":return"none";case"weekly":return"weekly";case"monthly":return"monthly"}},[r]),g=O.useMemo(()=>{if(s&&s.length>0){if(n===1){const h=B().format("YYYY-MM-DD"),u=s.find(v=>v.date===h);return[{date:z(h,n),rawDate:h,new:u?.signups||0,cancelled:-(u?.cancellations||0)}]}const x=oe(s,n,"signups","sum",f),w=oe(s,n,"cancellations","sum",f),m=new Map(w.map(h=>[h.date,h])),b=x.map(h=>({date:h.date,signups:h.signups||0,cancellations:m.get(h.date)?.cancellations||0})),N=new Set(b.map(h=>h.date));return w.forEach(h=>{N.has(h.date)||b.push({date:h.date,signups:0,cancellations:h.cancellations||0})}),b.sort((h,u)=>new Date(h.date).getTime()-new Date(u.date).getTime()),Ca(b,n,f).map(h=>{let u=n;return r==="weekly"&&n<91?u=91:r==="monthly"&&n<365&&(u=365),{date:z(h.date,u),rawDate:h.date,new:h.signups||0,cancelled:-(h.cancellations||0)}})}else{if(!a||a.length===0)return[];if(n===1){const p=B().format("YYYY-MM-DD"),h=a.find(u=>u.date===p);return[{date:z(p,n),rawDate:p,new:h?.paid_subscribed||0,cancelled:-(h?.paid_canceled||0)}]}const x=oe(a,n,"paid_subscribed","sum",f),w=oe(a,n,"paid_canceled","sum",f),m=new Map(w.map(p=>[p.date,p])),b=x.map(p=>({date:p.date,paid_subscribed:p.paid_subscribed||0,paid_canceled:m.get(p.date)?.paid_canceled||0})),N=new Set(b.map(p=>p.date));return w.forEach(p=>{N.has(p.date)||b.push({date:p.date,paid_subscribed:0,paid_canceled:p.paid_canceled||0})}),b.sort((p,h)=>new Date(p.date).getTime()-new Date(h.date).getTime()),b.map(p=>{let h=n;return r==="weekly"&&n<91?h=91:r==="monthly"&&n<365&&(h=365),{date:z(p.date,h),rawDate:p.date,new:p.paid_subscribed||0,cancelled:-(p.paid_canceled||0)}})}},[a,s,n,f,r]),c={new:{label:"New",color:"hsl(var(--chart-teal))"},cancelled:{label:"Cancelled",color:"hsl(var(--chart-rose))"}},o=O.useMemo(()=>{const x=g.reduce((m,b)=>m+b.new,0),w=g.reduce((m,b)=>m+Math.abs(b.cancelled),0);return{new:x,cancelled:w}},[g]);if(t)return null;const j=g.length>0&&(o.new>0||o.cancelled>0),A=x=>x.charAt(0).toUpperCase()+x.slice(1);return e.jsxs(be,{"data-testid":"paid-members-change-card",children:[e.jsx(_e,{children:e.jsxs("div",{className:"flex items-start justify-between gap-1.5",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(ke,{children:"Paid subscriptions"}),e.jsxs(Oe,{children:["New and cancelled paid subscriptions ",U(n)]})]}),i.length>1&&e.jsx("div",{children:e.jsxs(qe,{value:r,onValueChange:x=>l(x),children:[e.jsx(Qe,{className:"w-[110px]",children:e.jsx(Xe,{})}),e.jsx(Je,{align:"end",children:i.map(x=>e.jsx(we,{value:x,children:A(x)},x))})]})})]})}),e.jsx(ge,{children:j?e.jsxs("div",{children:[e.jsx(Ue,{className:"aspect-auto h-[200px] w-full md:h-[220px] xl:h-[260px]",config:c,children:e.jsxs(Ot,{data:g,stackOffset:"sign",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"tealGradient",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"var(--color-new)",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"var(--color-new)",stopOpacity:.6})]})}),e.jsx("defs",{children:e.jsxs("linearGradient",{id:"roseGradient",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"var(--color-cancelled)",stopOpacity:.6}),e.jsx("stop",{offset:"100%",stopColor:"var(--color-cancelled)",stopOpacity:.8})]})}),e.jsx(Nt,{stroke:"hsl(var(--border))",vertical:!1}),e.jsx(Dt,{axisLine:!1,dataKey:"date",tickFormatter:()=>"",tickLine:!1,tickMargin:10}),e.jsx(Ct,{axisLine:!1,tickFormatter:x=>x<0?T(x*-1):T(x),tickLine:!1}),e.jsx(We,{content:e.jsx(na,{className:"!min-w-[120px] px-3 py-2",formatter:(x,w,m,b)=>{const N=Number(x);let p="0";N===0?p="0":p=N<0?T(N*-1):T(N);const h=Number(m?.payload?.new||0),u=Number(m?.payload?.cancelled||0),v=h+u,C=v===0?"0":v>0?`+${T(v)}`:T(v);let S=m?.payload?.date;return m?.payload?.rawDate&&(r==="monthly"?S=z(m.payload.rawDate,366):r==="weekly"?S=z(m.payload.rawDate,91):S=z(m.payload.rawDate,30)),e.jsxs("div",{className:"flex w-full flex-col",children:[b===0&&e.jsx("div",{className:"mb-1 text-sm font-medium text-foreground",children:S}),e.jsxs("div",{className:"flex w-full items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"size-2 shrink-0 rounded-full bg-[var(--color-bg)] opacity-50",style:{"--color-bg":`var(--color-${w})`}}),e.jsx("span",{className:"text-sm text-muted-foreground",children:c[w]?.label||w})]}),e.jsx("div",{className:"ml-auto flex items-baseline gap-0.5 font-mono font-medium tabular-nums text-foreground",children:p})]}),b===1&&e.jsxs("div",{className:"mt-1 flex w-full items-center justify-between gap-4 border-t pt-1",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Net change"}),e.jsx("div",{className:"ml-auto flex items-baseline gap-0.5 font-mono font-medium tabular-nums text-foreground",children:C})]})]})},hideLabel:!0}),cursor:!1,isAnimationActive:!1,position:{y:10}}),e.jsx(Ee,{activeBar:{fillOpacity:1},dataKey:"new",fill:"url(#tealGradient)",fillOpacity:.75,maxBarSize:32,minPointSize:3,radius:[4,4,0,0],stackId:"a"}),e.jsx(Ee,{activeBar:{fillOpacity:1},dataKey:"cancelled",fill:"url(#roseGradient)",fillOpacity:.75,maxBarSize:32,radius:[4,4,0,0],stackId:"a"})]})}),e.jsxs("div",{className:"mt-3 flex items-center justify-center gap-6 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"size-2 rounded-full opacity-50",style:{backgroundColor:c.new.color}}),e.jsx("span",{children:"New"}),e.jsx("span",{className:"font-medium text-foreground",children:T(o.new)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"size-2 rounded-full opacity-50",style:{backgroundColor:c.cancelled.color}}),e.jsx("span",{children:"Cancelled"}),e.jsx("span",{className:"font-medium text-foreground",children:T(o.cancelled)})]})]})]}):e.jsx("div",{className:"py-12",children:e.jsx(ce,{description:`No paid subscription changes ${U(n)}.`,title:"No paid member changes",children:e.jsx(ca,{strokeWidth:1.5})})})})]})},ka=(s,a,n)=>{const t=s??30,r=a??"mrr desc",{startDate:l,endDate:i}=O.useMemo(()=>se(t),[t]),f=O.useMemo(()=>{const o={date_from:W(l),date_to:W(i),order:r};return n==="posts"?o.post_type="post":n==="pages"&&(o.post_type="page"),o},[l,i,r,n]),g=Object.fromEntries(Object.entries(f).filter(([,o])=>o!==void 0));return Kt({searchParams:g})},hs=()=>{const{range:s,site:a,settings:n}=Te(),t=String(n.find(d=>d.key==="timezone")?.value||"Etc/UTC"),r=De(),[l,i]=O.useState("free_members desc"),[f,g]=O.useState(Q.POSTS_AND_PAGES),[c]=Ke(),{appSettings:o}=je(),j=c.get("tab")||"total-members",[A,x]=O.useState(j);O.useEffect(()=>{j!==A&&x(j)},[j]);const{isLoading:w,chartData:m,totals:b,currencySymbol:N,subscriptionData:p}=ua(s),{data:h,isLoading:u}=ka(s,l,f),v=O.useMemo(()=>{const k=(h?.stats||[]).reduce((_,E)=>{const V=E.post_id||(E.title&&E.title.trim()!==""?E.title:E.attribution_url);if(!V)return _;if(!_.has(V))_.set(V,E);else{const q=_.get(V);q.free_members+=E.free_members,q.paid_members+=E.paid_members,q.mrr+=E.mrr,_.set(V,q)}return _},new Map),y=Array.from(k.values()),D=y.reduce((_,E)=>_+E.free_members,0),P=y.reduce((_,E)=>_+E.paid_members,0),M=y.reduce((_,E)=>_+E.mrr,0);return y.map(_=>{let E=0;return l.includes("free_members")&&D>0?E=_.free_members/D:l.includes("paid_members")&&P>0?E=_.paid_members/P:l.includes("mrr")&&M>0&&(E=_.mrr/M),{title:_.title||_.attribution_url,post_id:_.post_id,attribution_url:_.attribution_url,attribution_type:_.attribution_type,attribution_id:_.attribution_id,free_members:_.free_members,paid_members:_.paid_members,mrr:_.mrr,percentage:E,published_at:_.published_at,url_exists:_.url_exists??!0}})},[h,l]),C=w,S=w||u;return e.jsxs(gt,{children:[e.jsx(vt,{children:e.jsx($t,{children:e.jsx(jt,{})})}),e.jsxs(yt,{data:C?void 0:m,isLoading:!1,loadingComponent:e.jsx(e.Fragment,{}),children:[e.jsx(be,{"data-testid":"total-members-card",children:e.jsx(ge,{children:e.jsx(Sa,{chartData:m,currencySymbol:N,initialTab:j,isLoading:C,totals:b,onTabChange:x})})}),o?.paidMembersEnabled&&A==="paid-members"&&e.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2 xl:grid-cols-[2fr_minmax(460px,1fr)]",children:[e.jsx(_a,{isLoading:C,memberData:m,range:s,subscriptionData:p}),e.jsx(Da,{isLoading:C,range:s})]}),e.jsxs(be,{className:"w-full overflow-x-auto","data-testid":"top-content-card",children:[e.jsxs(_e,{children:[e.jsx(ke,{children:Mt(f)}),e.jsx(Oe,{children:Rt(f,s,U)})]}),e.jsx(ge,{children:e.jsxs(Ye,{children:[e.jsx(ze,{children:e.jsxs(K,{className:"[&>th]:h-auto [&>th]:pb-2 [&>th]:pt-0",children:[e.jsx(H,{className:"min-w-[320px] pl-0",children:e.jsx(Ve,{defaultValue:f,variant:"button-sm",onValueChange:d=>{g(d)},children:e.jsxs($e,{children:[e.jsx(me,{value:Q.POSTS_AND_PAGES,children:"Posts & pages"}),e.jsx(me,{value:Q.POSTS,children:"Posts"}),e.jsx(me,{value:Q.PAGES,children:"Pages"}),e.jsx(me,{value:Q.SOURCES,children:"Sources"})]})})}),e.jsx(H,{className:"w-[140px] text-right",children:o?.paidMembersEnabled?e.jsx(te,{activeSortBy:l,setSortBy:i,sortBy:"free_members desc",children:"Free members"}):e.jsx(e.Fragment,{children:"Free members"})}),o?.paidMembersEnabled&&e.jsxs(e.Fragment,{children:[e.jsx(H,{className:"w-[140px] text-right",children:e.jsx(te,{activeSortBy:l,setSortBy:i,sortBy:"paid_members desc",children:"Paid members"})}),e.jsx(H,{className:"w-[140px] text-right",children:e.jsx(te,{activeSortBy:l,setSortBy:i,sortBy:"mrr desc",children:"MRR impact"})})]})]})}),f===Q.SOURCES?e.jsx(wa,{limit:20,range:s,setSortBy:d=>i(d),showViewAll:!0,sortBy:l}):e.jsx(le,{children:S?e.jsx(K,{className:"last:border-none",children:e.jsx(F,{className:"border-none py-2",colSpan:1,children:e.jsx(Ge,{containerClassName:"space-y-2",count:5,maxWidth:75,randomize:!0})})}):o?.analytics.membersTrackSources?v.length>0?v.map((d,k)=>e.jsxs(K,{className:"last:border-none",children:[e.jsx(F,{children:e.jsxs("div",{className:"group/link inline-flex flex-col items-start gap-px",children:[d.post_id&&d.attribution_type==="post"?e.jsx(Ce,{className:"h-auto whitespace-normal p-0 text-left font-medium leading-tight hover:!underline",title:"View post analytics",variant:"link",onClick:kt(d.attribution_url,d.post_id,a.url||"",r,d.attribution_type),children:d.title}):e.jsx("span",{className:"font-medium",children:d.title}),d.published_at&&Pe&&new Date(d.published_at).getTime()>0&&e.jsxs("span",{className:"text-muted-foreground",children:["Published on ",Pe(d.published_at,t)]})]})}),e.jsxs(F,{className:"text-right font-mono text-sm",children:[d.free_members>0&&"+",T(d.free_members)]}),o?.paidMembersEnabled&&e.jsxs(e.Fragment,{children:[e.jsxs(F,{className:"text-right font-mono text-sm",children:[d.paid_members>0&&"+",T(d.paid_members)]}),e.jsxs(F,{className:"text-right font-mono text-sm",children:[d.mrr>0&&"+",N,T(J(d.mrr))]})]})]},`${f}-${d.post_id||`${d.title}-${k}`}`)):e.jsx(K,{className:"border-none",children:e.jsx(F,{className:"py-12 group-hover:!bg-transparent",colSpan:o?.paidMembersEnabled?4:2,children:e.jsx(ce,{description:"Try adjusting your date range to see more data.",title:`No conversions ${U(s)}`,children:e.jsx(da,{strokeWidth:1.5})})})}):e.jsx(K,{className:"last:border-none",children:e.jsx(F,{className:"border-none py-12 group-hover:!bg-transparent",colSpan:o?.paidMembersEnabled?4:2,children:e.jsx(tt,{})})})})]})})]})]})]})};export{hs as default};